| 325 | int Quicksave_game_slot = -1; |
| 326 | |
| 327 | void 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 | |
| 372 | void SaveGameDialog() { |
| 373 | newuiTiledWindow wnd; |
no test coverage detected