Mercurial > hg > openttd
changeset 15444:8c30e5e0908d draft
(svn r20087) -Fix [FS#3876, FS#3887, FS#3920, FS#3923]: if after loading a savegame (including intro game) one tried to save a game (including autosave) and that failed (very) early on because it couldn't open the file for writing all pointers would be converted to NULLs which then causes corrupted game states
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 08 Jul 2010 11:50:42 +0000 |
parents | 000c20f153e5 |
children | 6dcdc3eb8d53 |
files | src/saveload/saveload.cpp |
diffstat | 1 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -1961,6 +1961,15 @@ if (mode == SL_LOAD_CHECK) _load_check_data.checkable = true; _sl.excpt_uninit = NULL; + _sl.bufe = _sl.bufp = NULL; + _sl.offs_base = 0; + switch (mode) { + case SL_LOAD_CHECK: _sl.action = SLA_LOAD_CHECK; break; + case SL_LOAD: _sl.action = SLA_LOAD; break; + case SL_SAVE: _sl.action = SLA_SAVE; break; + default: NOT_REACHED(); + } + try { _sl.fh = (mode == SL_SAVE) ? FioFOpenFile(filename, "wb", sb) : FioFOpenFile(filename, "rb", sb); @@ -1972,15 +1981,6 @@ SlError(mode == SL_SAVE ? STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE : STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); } - _sl.bufe = _sl.bufp = NULL; - _sl.offs_base = 0; - switch (mode) { - case SL_LOAD_CHECK: _sl.action = SLA_LOAD_CHECK; break; - case SL_LOAD: _sl.action = SLA_LOAD; break; - case SL_SAVE: _sl.action = SLA_SAVE; break; - default: NOT_REACHED(); - } - /* General tactic is to first save the game to memory, then use an available writer * to write it to file, either in threaded mode if possible, or single-threaded */ if (mode == SL_SAVE) { // SAVE game