Explorar el Código

simplify icon parsing + handle no npc data

jblanked hace 8 meses
padre
commit
34c0efd85a
Se han modificado 4 ficheros con 39 adiciones y 39 borrados
  1. 1 1
      game/player.h
  2. 26 23
      game/storage.c
  3. 0 0
      game/story.c
  4. 12 15
      game/world.c

+ 1 - 1
game/player.h

@@ -4,7 +4,7 @@
 #include <game/game.h>
 #include "engine/sensors/imu.h"
 
-#define MAX_ENEMIES 5
+#define MAX_ENEMIES 12
 #define MAX_LEVELS 5
 #define MAX_NPCS 1
 

+ 26 - 23
game/storage.c

@@ -1157,34 +1157,37 @@ bool separate_world_data(char *id, FuriString *world_data)
         FURI_LOG_E("Game", "Failed to get npc data");
         return false;
     }
+    else
+    {
 
-    snprintf(file_path, sizeof(file_path),
-             STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/worlds/%s/%s_npc_data.json",
-             id, id);
+        snprintf(file_path, sizeof(file_path),
+                 STORAGE_EXT_PATH_PREFIX "/apps_data/flip_world/worlds/%s/%s_npc_data.json",
+                 id, id);
 
-    if (!storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS))
-    {
-        FURI_LOG_E("Game", "Failed to open file for writing: %s", file_path);
-        storage_file_free(file);
-        furi_record_close(RECORD_STORAGE);
-        furi_string_free(file_npc_data);
-        return false;
-    }
+        if (!storage_file_open(file, file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS))
+        {
+            FURI_LOG_E("Game", "Failed to open file for writing: %s", file_path);
+            storage_file_free(file);
+            furi_record_close(RECORD_STORAGE);
+            furi_string_free(file_npc_data);
+            return false;
+        }
 
-    data_size = furi_string_size(file_npc_data);
-    if (storage_file_write(file, furi_string_get_cstr(file_npc_data), data_size) != data_size)
-    {
-        FURI_LOG_E("Game", "Failed to write npc_data");
-    }
-    storage_file_close(file);
+        data_size = furi_string_size(file_npc_data);
+        if (storage_file_write(file, furi_string_get_cstr(file_npc_data), data_size) != data_size)
+        {
+            FURI_LOG_E("Game", "Failed to write npc_data");
+        }
+        storage_file_close(file);
 
-    furi_string_replace_at(file_npc_data, 0, 1, "");
-    furi_string_replace_at(file_npc_data, furi_string_size(file_npc_data) - 1, 1, "");
-    // include the comma at the end of the npc_data array
-    furi_string_cat_str(file_npc_data, ",");
+        furi_string_replace_at(file_npc_data, 0, 1, "");
+        furi_string_replace_at(file_npc_data, furi_string_size(file_npc_data) - 1, 1, "");
+        // include the comma at the end of the npc_data array
+        furi_string_cat_str(file_npc_data, ",");
 
-    furi_string_remove_str(world_data, furi_string_get_cstr(file_npc_data));
-    furi_string_free(file_npc_data);
+        furi_string_remove_str(world_data, furi_string_get_cstr(file_npc_data));
+        furi_string_free(file_npc_data);
+    }
 
     // Save enemy_data to disk
     FuriString *file_enemy_data = json_data(world_data, "enemy_data");

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
game/story.c


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 12 - 15
game/world.c


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio