- make server and client communicate by specific world state info requests
in server/out, replacing server/worldstate
+- on start, alarm about _tmp files (savefile/record) to avoid gameplay data loss
+
SERVER:
- consider
- save confserver/world data in record and save file, too; handle them like god
commands
-- ensure atomic re-writing of savefile
-
CLIENT:
- enable toggling of window borders
extern void save_world()
{
char * f_name = "save_world()";
- char * path = s[S_PATH_SAVE];
- FILE * file = try_fopen(path, "w", f_name);
+ uint16_t size = strlen(s[S_PATH_SAVE]) + strlen(s[S_PATH_SUFFIX_TMP]) + 1;
+ char * path_tmp = try_malloc(size, f_name);
+ int test=sprintf(path_tmp,"%s%s",s[S_PATH_SAVE], s[S_PATH_SUFFIX_TMP]);
+ exit_trouble(test < 0, f_name, s[S_FCN_SPRINTF]);
+ FILE * file = try_fopen(path_tmp, "w", f_name);
write_key_value(file, s[S_CMD_DO_FOV], 0);
try_fputc('\n', file, f_name);
write_key_value(file, s[S_CMD_SEED_MAP], world.seed_map);
write_thing(file, t);
}
write_key_value(file, s[S_CMD_DO_FOV], 1);
- try_fclose(file, f_name);
+ try_fclose_unlink_rename(file, path_tmp, s[S_PATH_SAVE], f_name);
}
*/
extern char * io_round();
-/* Write to savefile god commands (one per line) to rebuild the current world
- * state.
+/* Write to savefile (atomically) god commands (one per line) to rebuild the
+ * current world state.
*/
extern void save_world();