diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 88f404109..78e6d2170 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6665,6 +6665,24 @@ MAIN_LOOP_RESTART: while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME); } + // handle CON_SAVE and CON_SAVENN + if (g_requestedSaveSlot != -1) + { + g_lastSaveSlot = g_requestedSaveSlot; + + OSD_Printf("Saving to slot %d\n", g_requestedSaveSlot); + + KB_FlushKeyboardQueue(); + + g_screenCapture = 1; + G_DrawRooms(myconnectindex, 65536); + g_screenCapture = 0; + + G_SavePlayerMaybeMulti(g_requestedSaveSlot); + + g_requestedSaveSlot = -1; + } + G_DoCheats(); if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART)) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index b6f25d6a8..14c19d009 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -3479,31 +3479,23 @@ nullquote: case CON_SAVE: insptr++; { - g_lastSaveSlot = *insptr++; + int32_t const requestedSlot = *insptr++; - if ((unsigned)g_lastSaveSlot >= MAXSAVEGAMES) + if ((unsigned)requestedSlot >= MAXSAVEGAMES) continue; - if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0) + g_requestedSaveSlot = requestedSlot; + + if (tw == CON_SAVE || ud.savegame[requestedSlot][0] == 0) { time_t timeStruct = time(NULL); struct tm *pTime = localtime(&timeStruct); - Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]), - "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday, + Bsnprintf(ud.savegame[requestedSlot], sizeof(ud.savegame[requestedSlot]), + "Auto %.4d%.2d%.2d %.2d%.2d%.2d", pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday, pTime->tm_hour, pTime->tm_min, pTime->tm_sec); } - OSD_Printf("Saving to slot %d\n",g_lastSaveSlot); - - KB_FlushKeyboardQueue(); - - g_screenCapture = 1; - G_DrawRooms(myconnectindex,65536); - g_screenCapture = 0; - - G_SavePlayerMaybeMulti(g_lastSaveSlot); - continue; } diff --git a/source/duke3d/src/global.cpp b/source/duke3d/src/global.cpp index f6a6df70a..2a4bbefcf 100644 --- a/source/duke3d/src/global.cpp +++ b/source/duke3d/src/global.cpp @@ -60,6 +60,8 @@ int g_bouncemineRadius = 2500; int g_deleteQueueSize = 64; int g_itemRespawnTime = 768; int g_lastSaveSlot = -1; +int32_t g_requestedSaveSlot = -1; + int g_morterRadius = 2500; int g_numFreezeBounces = 3; int g_gametypeCnt = 5; diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index 4b33ae1b6..be35e3b30 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -175,6 +175,7 @@ extern int32_t g_deleteQueueSize; extern int32_t g_gametypeCnt; extern int32_t g_itemRespawnTime; extern int32_t g_lastSaveSlot; +extern int32_t g_requestedSaveSlot; extern int32_t g_morterRadius; extern int32_t g_numFreezeBounces; extern int32_t g_pipebombRadius;