summaryrefslogtreecommitdiff
path: root/src/server/commands.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2014-12-03 13:28:16 +0300
committerAndrey Nazarov <skuller@skuller.net>2014-12-03 18:33:25 +0300
commit924ff39aa48df1d6cd985b42a2fe5a60ff154030 (patch)
tree79dc211425cf4689ec56308fb93c4f4bbc17d464 /src/server/commands.c
parent7525450fb6d79d7371375d7f710ba4fe484494b3 (diff)
Stop fiddling around with jmp_buf.
Implement custom abort function handler for cleaning up CM after failed server startup. Less hacky and more portable than previous solution that involved swapping copies of jmp_buf around. Fixes a weird Win64 crash when loading savegames.
Diffstat (limited to 'src/server/commands.c')
-rw-r--r--src/server/commands.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/server/commands.c b/src/server/commands.c
index 09a7990..b5c09fe 100644
--- a/src/server/commands.c
+++ b/src/server/commands.c
@@ -257,11 +257,16 @@ another level:
map tram.cin+jail_e3
======================
*/
+
+static void abort_func(void *arg)
+{
+ CM_FreeMap(arg);
+}
+
static void SV_Map(qboolean restart)
{
mapcmd_t cmd;
size_t len;
- jmp_buf tmp;
memset(&cmd, 0, sizeof(cmd));
@@ -275,15 +280,8 @@ static void SV_Map(qboolean restart)
if (!SV_ParseMapCmd(&cmd))
return;
- // save error frame
- memcpy(tmp, com_abortframe, sizeof(jmp_buf));
-
- // catch ERR_DROP and free the map
- if (setjmp(com_abortframe)) {
- memcpy(com_abortframe, tmp, sizeof(jmp_buf));
- CM_FreeMap(&cmd.cm);
- return;
- }
+ // save pending CM to be freed later if ERR_DROP is thrown
+ Com_AbortFunc(abort_func, &cmd.cm);
// wipe savegames
cmd.endofunit |= restart;
@@ -294,8 +292,8 @@ static void SV_Map(qboolean restart)
if ((sv.state != ss_game && sv.state != ss_pic) || restart)
SV_InitGame(MVD_SPAWN_DISABLED); // the game is just starting
- // restore error frame
- memcpy(com_abortframe, tmp, sizeof(jmp_buf));
+ // clear pending CM
+ Com_AbortFunc(NULL, NULL);
SV_SpawnServer(&cmd);