MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / QuickSaveGame

Function QuickSaveGame

Descent3/gamesave.cpp:327–370  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325int Quicksave_game_slot = -1;
326
327void QuickSaveGame() {
328 if (Game_mode & GM_MULTI) {
329 DoMessageBox(TXT_ERROR, TXT_CANT_SAVE_MULTI, MSGBOX_OK);
330 return;
331 }
332
333#ifdef _DEBUG
334 if (GetFunctionMode() == EDITOR_GAME_MODE || !Current_mission.filename) {
335 DoMessageBox(TXT_ERROR, "You need to be playing a mission.", MSGBOX_OK);
336 return;
337 }
338#endif
339
340 if (Quicksave_game_slot == -1) {
341 SaveGameDialog();
342 } else {
343 // verify savegame still exists in the appropriate slot, if not just run dialog, if so then save
344 char filename[PSFILENAME_LEN + 1];
345 char pathname[_MAX_PATH];
346 char desc[GAMESAVE_DESCLEN + 1];
347 FILE *fp;
348 int i;
349
350 i = Quicksave_game_slot;
351
352 snprintf(filename, sizeof(filename), "saveg00%d", i);
353 ddio_MakePath(pathname, Base_directory, "savegame", filename, NULL);
354
355 fp = fopen(pathname, "rb");
356 if (fp) {
357 // slot valid, save here.
358 fclose(fp);
359 if (GetGameStateInfo(pathname, desc)) {
360 if (SaveGameState(pathname, desc)) {
361 AddHUDMessage(TXT_QUICKSAVE);
362 return; // we're okay. game saved. put up hud message?
363 }
364 DoMessageBox(TXT_ERROR, TXT_SAVEGAMEFAILED, MSGBOX_OK);
365 }
366 }
367 Quicksave_game_slot = -1;
368 SaveGameDialog();
369 }
370}
371
372void SaveGameDialog() {
373 newuiTiledWindow wnd;

Callers 1

ProcessNormalKeyFunction · 0.85

Calls 7

DoMessageBoxFunction · 0.85
GetFunctionModeFunction · 0.85
SaveGameDialogFunction · 0.85
GetGameStateInfoFunction · 0.85
SaveGameStateFunction · 0.85
AddHUDMessageFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected