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

Function quitGame

src/OpenLoco/src/Game.cpp:164–217  ·  view source on GitHub ↗

0x0043C182

Source from the content-addressed store, hash-verified

162
163 // 0x0043C182
164 void quitGame()
165 {
166 GameCommands::resetCommandNestLevel();
167
168 // Path for networked games; untested.
169 if (SceneManager::isNetworked())
170 {
171 SceneManager::removeSceneFlags(SceneManager::Flags::networked);
172 auto playerCompanyId = CompanyManager::getControllingId();
173 auto previousUpdatingId = GameCommands::getUpdatingCompanyId();
174 GameCommands::setUpdatingCompanyId(playerCompanyId);
175
176 Ui::WindowManager::closeAllFloatingWindows();
177
178 GameCommands::setUpdatingCompanyId(previousUpdatingId);
179 SceneManager::addSceneFlags(SceneManager::Flags::networked);
180
181 // If the other party is leaving the game, go back to the title screen.
182 if (playerCompanyId != previousUpdatingId)
183 {
184 // 0x0043C1CD
185 SceneManager::removeSceneFlags(SceneManager::Flags::networked);
186 SceneManager::removeSceneFlags(SceneManager::Flags::networkHost);
187 CompanyManager::setControllingId(CompanyId(0));
188 CompanyManager::setSecondaryPlayerId(CompanyId::null);
189
190 Gfx::invalidateScreen();
191 ObjectManager::loadIndex();
192
193 Ui::WindowManager::close(Ui::WindowType::options);
194 Ui::WindowManager::close(Ui::WindowType::companyFaceSelection);
195 Ui::WindowManager::close(Ui::WindowType::objectSelection);
196
197 SceneManager::removeSceneFlags(SceneManager::Flags::editor);
198 Audio::pauseSound();
199 Audio::unpauseSound();
200
201 if (Input::hasFlag(Input::Flags::rightMousePressed))
202 {
203 Input::stopCursorDrag();
204 Input::resetFlag(Input::Flags::rightMousePressed);
205 }
206
207 Title::start();
208
209 Ui::Windows::Error::open(StringIds::error_the_other_player_has_exited_the_game);
210
211 throw GameException::Interrupt;
212 }
213 }
214
215 // 0x0043C1C8
216 exitCleanly();
217 }
218
219 // 0x0043C0FD
220 void returnToTitle()

Callers 1

loadSaveQuitFunction · 0.85

Calls 15

resetCommandNestLevelFunction · 0.85
isNetworkedFunction · 0.85
removeSceneFlagsFunction · 0.85
getControllingIdFunction · 0.85
getUpdatingCompanyIdFunction · 0.85
setUpdatingCompanyIdFunction · 0.85
addSceneFlagsFunction · 0.85
setControllingIdFunction · 0.85
CompanyIdEnum · 0.85
setSecondaryPlayerIdFunction · 0.85
invalidateScreenFunction · 0.85
pauseSoundFunction · 0.85

Tested by

no test coverage detected