|
|
@@ -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");
|