summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-12-09 16:55:03 +0000
committerfrosch <frosch@openttd.org>2012-12-09 16:55:03 +0000
commit0e4b212c4539afb9d8622862d7e03bf2217058f8 (patch)
tree676292ccfbd04f4b61e621682f9546535e2a479d /src/saveload
parent2bb54f09d8ad249f009ab10c9b398fc8b444e5b3 (diff)
downloadopenttd-0e4b212c4539afb9d8622862d7e03bf2217058f8.tar.xz
(svn r24810) -Fix: Make engine preview offers more robust wrt. changes in the company ranking.
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/engine_sl.cpp15
-rw-r--r--src/saveload/oldloader_sl.cpp5
-rw-r--r--src/saveload/saveload.cpp3
3 files changed, 18 insertions, 5 deletions
diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp
index 188db2dea..d02264cd6 100644
--- a/src/saveload/engine_sl.cpp
+++ b/src/saveload/engine_sl.cpp
@@ -30,7 +30,9 @@ static const SaveLoad _engine_desc[] = {
SLE_CONDNULL(1, 0, 120),
SLE_VAR(Engine, flags, SLE_UINT8),
- SLE_VAR(Engine, preview_company_rank,SLE_UINT8),
+ SLE_CONDNULL(1, 0, 178), // old preview_company_rank
+ SLE_CONDVAR(Engine, preview_asked, SLE_UINT16, 179, SL_MAX_VERSION),
+ SLE_CONDVAR(Engine, preview_company, SLE_UINT8, 179, SL_MAX_VERSION),
SLE_VAR(Engine, preview_wait, SLE_UINT8),
SLE_CONDNULL(1, 0, 44),
SLE_CONDVAR(Engine, company_avail, SLE_FILE_U8 | SLE_VAR_U16, 0, 103),
@@ -67,6 +69,14 @@ static void Load_ENGN()
while ((index = SlIterateArray()) != -1) {
Engine *e = GetTempDataEngine(index);
SlObject(e, _engine_desc);
+
+ if (IsSavegameVersionBefore(179)) {
+ /* preview_company_rank was replaced with preview_company and preview_asked.
+ * Just cancel any previews. */
+ e->flags &= ~4; // ENGINE_OFFER_WINDOW_OPEN
+ e->preview_company = INVALID_COMPANY;
+ e->preview_asked = (CompanyMask)-1;
+ }
}
}
@@ -91,7 +101,8 @@ void CopyTempEngineData()
e->duration_phase_2 = se->duration_phase_2;
e->duration_phase_3 = se->duration_phase_3;
e->flags = se->flags;
- e->preview_company_rank= se->preview_company_rank;
+ e->preview_asked = se->preview_asked;
+ e->preview_company = se->preview_company;
e->preview_wait = se->preview_wait;
e->company_avail = se->company_avail;
if (se->name != NULL) e->name = strdup(se->name);
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index d36ba54f8..0ee7eea2b 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -445,7 +445,8 @@ static bool FixTTOEngines()
e->info.climates = 1;
}
- e->preview_company_rank = 0;
+ e->preview_company = INVALID_COMPANY;
+ e->preview_asked = (CompanyMask)-1;
e->preview_wait = 0;
e->name = NULL;
}
@@ -1401,7 +1402,7 @@ static const OldChunks engine_chunk[] = {
OCL_NULL( 1 ), // lifelength
OCL_SVAR( OC_UINT8, Engine, flags ),
- OCL_SVAR( OC_UINT8, Engine, preview_company_rank ),
+ OCL_NULL( 1 ), // preview_company_rank
OCL_SVAR( OC_UINT8, Engine, preview_wait ),
OCL_CNULL( OC_TTD, 2 ), ///< railtype + junk
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 6a6f8db13..ac8a7e81b 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -242,8 +242,9 @@
* 176 24446
* 177 24619
* 178 24789
+ * 179 24810
*/
-extern const uint16 SAVEGAME_VERSION = 178; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 179; ///< Current savegame version of OpenTTD.
SavegameType _savegame_type; ///< type of savegame we are loading