MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / PassiveSaveGame

Method PassiveSaveGame

src/Phobos.Save.cpp:32–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void 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"

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected