home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Server: Make code in build_fov_map() slightly less bizarre.
[plomrogue]
/
src
/
server
/
cleanup.c
diff --git
a/src/server/cleanup.c
b/src/server/cleanup.c
index 4ad970ceaf44365e6b16202b00b4ce8ba3fa6ed2..1eebbaf01a3a76b281332831f5a5b11385147191 100644
(file)
--- a/
src/server/cleanup.c
+++ b/
src/server/cleanup.c
@@
-4,12
+4,15
@@
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* free() */
#include <unistd.h> /* unlink() */
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* free() */
#include <unistd.h> /* unlink() */
-#include "map_object_actions.h" /* free_map_object_actions() */
-#include "map_objects.h" /* free_map_objects(), free_map_object_defs() */
+#include "../common/readwrite.h" /* try_fclose() */
+#include "hardcoded_strings.h" /* s */
+#include "thing_actions.h" /* free_thing_actions() */
+#include "things.h" /* free_things(), free_thing_types() */
#include "world.h" /* global world */
#include "world.h" /* global world */
+
/* The clean-up flags set by set_cleanup_flag(). */
static uint32_t cleanup_flags = 0x0000;
/* The clean-up flags set by set_cleanup_flag(). */
static uint32_t cleanup_flags = 0x0000;
@@
-20,26
+23,33
@@
extern void cleanup()
free(world.queue);
free(world.log);
free(world.map.cells);
free(world.queue);
free(world.log);
free(world.map.cells);
- if (cleanup_flags & CLEANUP_OUTFILE)
+ if (cleanup_flags & CLEANUP_WORLDSTATE)
+ {
+ unlink(s[S_PATH_WORLDSTATE]);
+ }
+ if (cleanup_flags & CLEANUP_THINGS)
+ {
+ free_things(world.things);
+ }
+ if (cleanup_flags & CLEANUP_THING_TYPES)
{
{
-
unlink(world.path_out
);
+
free_thing_types(world.thing_types
);
}
}
- if (cleanup_flags & CLEANUP_
MAP_OBJECT
S)
+ if (cleanup_flags & CLEANUP_
THING_ACTION
S)
{
{
- free_
map_objects(world.map_obj
s);
+ free_
thing_actions(world.thing_action
s);
}
}
- if (cleanup_flags & CLEANUP_
MAP_OBJECT_DEFS
)
+ if (cleanup_flags & CLEANUP_
IN
)
{
{
- free_map_object_defs(world.map_obj_defs);
+ try_fclose(world.file_in, __func__);
+ unlink(s[S_PATH_IN]);
}
}
- if (cleanup_flags & CLEANUP_
MAP_OBJECT_ACTS
)
+ if (cleanup_flags & CLEANUP_
OUT
)
{
{
- free_map_object_actions(world.map_obj_acts);
+ try_fclose(world.file_out, __func__);
+ free(world.server_test);
+ unlink(s[S_PATH_OUT]);
}
}
- if (cleanup_flags & CLEANUP_FIFO) /* Fifo also serves as lockfile that */
- { /* affirms the running of a server */
- unlink(world.path_in); /* instance. Therefore it should be */
- } /* the last thing to be deleted. */
}
}
@@
-47,3
+57,10
@@
extern void set_cleanup_flag(enum cleanup_flag flag)
{
cleanup_flags = cleanup_flags | flag;
}
{
cleanup_flags = cleanup_flags | flag;
}
+
+
+
+extern void unset_cleanup_flag(enum cleanup_flag flag)
+{
+ cleanup_flags = cleanup_flags ^ flag;
+}