MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / WriteSavegame

Method WriteSavegame

src/crashlog.cpp:223–239  ·  view source on GitHub ↗

* Write the (crash) savegame to a file. * @note The filename will be written to \c savegame_filename. * @return true when the crash save was successfully made. */

Source from the content-addressed store, hash-verified

221 * @return true when the crash save was successfully made.
222 */
223bool CrashLog::WriteSavegame()
224{
225 /* If the map doesn't exist, saving will fail too. If the map got
226 * initialised, there is a big chance the rest is initialised too. */
227 if (!Map::IsInitialized()) return false;
228
229 try {
230 _gamelog.Emergency();
231
232 this->savegame_filename = this->CreateFileName(".sav");
233
234 /* Don't do a threaded saveload. */
235 return SaveOrLoad(this->savegame_filename, SLO_SAVE, DFT_GAME_FILE, NO_DIRECTORY, false) == SL_OK;
236 } catch (...) {
237 return false;
238 }
239}
240
241/**
242 * Write the (crash) screenshot to a file.

Callers 1

MakeCrashLogMethod · 0.95

Calls 3

CreateFileNameMethod · 0.95
SaveOrLoadFunction · 0.85
EmergencyMethod · 0.80

Tested by

no test coverage detected