/* src/server/init.c */
#include "init.h"
-#include <errno.h> /* errno */
#include <stddef.h> /* NULL */
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* exit(), free() */
extern void remake_world(uint32_t seed)
{
+ char * f_name = "remake_world()";
free(world.log);
world.log = NULL; /* map_object_action.c's update_log() checks for this. */
world.seed = seed;
free(world.map.cells);
free_map_objects(world.map_objs);
world.last_update_turn = 0;
- world.turn = 1;
init_map();
add_map_objects(0, 1);
add_map_objects(1, 1 + rrand() % 27);
add_map_objects(4, 1 + rrand() % 3);
add_map_objects(5, 1 + rrand() % 3);
set_cleanup_flag(CLEANUP_MAP_OBJECTS);
- int test = unlink(world.path_record);
- char * err = "remake_world() fails to unlink() record file.";
- exit_err(test && errno != ENOENT, err);
+ if (world.turn)
+ {
+ exit_trouble(unlink(world.path_record), f_name, "unlink()");
+ }
+ world.turn = 1;
}
extern void obey_argv(int argc, char * argv[]);
/* Dissolves old game world if it exists, and generates a new one from "seed".
- * Unlinks any pre-existing file at world.path_record to re-start record.
+ * Unlinks a pre-existing file at world.path_record if called on a world.turn>0,
+ * i.e. if called after iterating through an already established game world.
*
* Map object (action) definitions read in from server config directory are not
* affected. world.last_update_turn is set to 0 and world.turn to 1, so that