MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / loadSaveQuit

Function loadSaveQuit

src/OpenLoco/src/GameCommands/General/LoadSaveQuit.cpp:15–72  ·  view source on GitHub ↗

0x0043BFCB

Source from the content-addressed store, hash-verified

13{
14 // 0x0043BFCB
15 static uint32_t loadSaveQuit(const LoadSaveQuitGameArgs& args, const uint8_t flags)
16 {
17 if ((flags & Flags::apply) == 0)
18 {
19 return 0;
20 }
21
22 if (args.saveMode == LoadSaveQuitGameArgs::SaveMode::closeSavePrompt)
23 {
24 Ui::WindowManager::close(Ui::WindowType::saveGamePrompt);
25 return 0;
26 }
27
28 auto loadOrQuitMode = args.loadQuitMode;
29
30 if (args.saveMode == LoadSaveQuitGameArgs::SaveMode::promptSave)
31 {
32 Ui::Windows::TextInput::cancel();
33 Ui::Windows::PromptSaveWindow::open(loadOrQuitMode);
34
35 if (!SceneManager::isTitleMode())
36 {
37 // 0x0043C369
38 // NB: tutorial recording has been omitted.
39 if (Tutorial::state() == Tutorial::State::playing)
40 {
41 Tutorial::stop();
42 }
43 else if (!SceneManager::isNetworked() || loadOrQuitMode != LoadOrQuitMode::quitGamePrompt)
44 {
45 if (SceneManager::getSceneAge() >= 0xF00)
46 {
47 auto window = Ui::WindowManager::bringToFront(Ui::WindowType::saveGamePrompt);
48 Audio::playSound(Audio::SoundId::openWindow, Audio::ChannelId::ui, window->x + (window->width / 2));
49 return 0;
50 }
51 }
52 }
53 }
54
55 // 0x0043BFE3
56 switch (loadOrQuitMode)
57 {
58 case LoadOrQuitMode::loadGamePrompt:
59 Game::loadGame();
60 break;
61
62 case LoadOrQuitMode::returnToTitlePrompt:
63 Game::returnToTitle();
64 break;
65
66 case LoadOrQuitMode::quitGamePrompt:
67 Game::quitGame();
68 break;
69 }
70
71 return 0;
72 }

Callers

nothing calls this directly

Calls 14

cancelFunction · 0.85
isTitleModeFunction · 0.85
isNetworkedFunction · 0.85
getSceneAgeFunction · 0.85
bringToFrontFunction · 0.85
playSoundFunction · 0.85
loadGameFunction · 0.85
returnToTitleFunction · 0.85
quitGameFunction · 0.85
closeFunction · 0.50
openFunction · 0.50

Tested by

no test coverage detected