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

Function confirmSaveGame

src/OpenLoco/src/Game.cpp:247–314  ·  view source on GitHub ↗

0x0043C427

Source from the content-addressed store, hash-verified

245
246 // 0x0043C427
247 void confirmSaveGame(LoadOrQuitMode promptSaveType)
248 {
249 ToolManager::toolCancel();
250
251 if (SceneManager::isEditorMode())
252 {
253 if (auto res = Game::saveLandscapeOpen())
254 {
255 if (saveLandscape(*res))
256 {
257 // load landscape
258 GameCommands::LoadSaveQuitGameArgs args{};
259 args.loadQuitMode = LoadOrQuitMode::loadGamePrompt;
260 args.saveMode = GameCommands::LoadSaveQuitGameArgs::SaveMode::dontSave;
261 GameCommands::doCommand(args, GameCommands::Flags::apply);
262 }
263 }
264 }
265 else if (!SceneManager::isNetworked())
266 {
267 if (auto res = Game::saveSaveGameOpen())
268 {
269 // 0x0043C446
270 auto path = fs::u8path(*res).replace_extension(S5::extensionSV5);
271 _activeSavePath = path.u8string();
272
273 S5::SaveFlags flags = S5::SaveFlags::none;
274 if (Config::get().exportObjectsWithSaves)
275 {
276 flags = S5::SaveFlags::packCustomObjects;
277 }
278
279 if (!S5::exportGameStateToFile(path, flags))
280 {
281 Ui::Windows::Error::open(StringIds::error_game_save_failed, StringIds::null);
282 }
283 else
284 {
285 GameCommands::LoadSaveQuitGameArgs args{};
286 args.loadQuitMode = LoadOrQuitMode::loadGamePrompt;
287 args.saveMode = GameCommands::LoadSaveQuitGameArgs::SaveMode::dontSave;
288 GameCommands::doCommand(args, GameCommands::Flags::apply);
289 }
290 }
291 }
292 else
293 {
294 // 0x0043C511
295 GameCommands::do_72();
296 MultiPlayer::setFlag(MultiPlayer::flags::flag_2);
297
298 switch (promptSaveType)
299 {
300 case LoadOrQuitMode::loadGamePrompt:
301 MultiPlayer::setFlag(MultiPlayer::flags::flag_13); // intend to load?
302 break;
303 case LoadOrQuitMode::returnToTitlePrompt:
304 MultiPlayer::setFlag(MultiPlayer::flags::flag_14); // intend to return to title?

Callers 1

onMouseUpFunction · 0.85

Calls 13

isEditorModeFunction · 0.85
saveLandscapeOpenFunction · 0.85
saveLandscapeFunction · 0.85
isNetworkedFunction · 0.85
saveSaveGameOpenFunction · 0.85
exportGameStateToFileFunction · 0.85
do_72Function · 0.85
invalidateScreenFunction · 0.85
getFunction · 0.70
setFlagFunction · 0.70
toolCancelFunction · 0.50
doCommandFunction · 0.50

Tested by

no test coverage detected