| 30 | } |
| 31 | |
| 32 | void Phobos::PassiveSaveGame() |
| 33 | { |
| 34 | auto PrintMessage = [](const wchar_t* pMessage) |
| 35 | { |
| 36 | MessageListClass::Instance.PrintMessage( |
| 37 | pMessage, |
| 38 | RulesClass::Instance->MessageDelay, |
| 39 | HouseClass::CurrentPlayer->ColorSchemeIndex, |
| 40 | /* bSilent: */ true |
| 41 | ); |
| 42 | |
| 43 | // Force a redraw so that our message gets printed. |
| 44 | if (Game::SpecialDialog == 0) |
| 45 | { |
| 46 | MapClass::Instance.MarkNeedsRedraw(2); |
| 47 | MapClass::Instance.Render(); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | PrintMessage(StringTable::LoadString(GameStrings::TXT_SAVING_GAME)); |
| 52 | char fName[0x80]; |
| 53 | |
| 54 | if (SessionClass::IsSingleplayer()) |
| 55 | { |
| 56 | SYSTEMTIME time; |
| 57 | GetLocalTime(&time); |
| 58 | |
| 59 | _snprintf_s(fName, sizeof(fName), "Map.%04u%02u%02u-%02u%02u%02u-%05u.sav", |
| 60 | time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds); |
| 61 | } |
| 62 | else if (SessionClass::IsMultiplayer()) |
| 63 | { |
| 64 | // Support for this is in the YRpp Spawner, be sure to read the respective comments |
| 65 | |
| 66 | _snprintf_s(fName, sizeof(fName), GameStrings::SAVEGAME_NET); |
| 67 | } |
| 68 | |
| 69 | if (ScenarioClass::SaveGame(fName, Phobos::CustomGameSaveDescription.c_str())) |
| 70 | PrintMessage(StringTable::LoadString(GameStrings::TXT_GAME_WAS_SAVED)); |
| 71 | else |
| 72 | PrintMessage(StringTable::LoadString(GameStrings::TXT_ERROR_SAVING_GAME)); |
| 73 | |
| 74 | Phobos::ShouldSave = false; |
| 75 | Phobos::CustomGameSaveDescription.clear(); |
| 76 | } |
| 77 | |
| 78 | #define SVGM_XXX_NET "SVGM_XXX.NET" |
| 79 | #define SVGM_FORMAT "SVGM_%03d.NET" |