summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-18 16:20:04 +0000
committersmatz <smatz@openttd.org>2009-01-18 16:20:04 +0000
commit9cc64bfa21a21ccaa6d96d34019655df79ba6a0b (patch)
tree37c973887ee481b7ae9fa97c49d8eeceba2ff131
parent730ceecb8bae9df247386a49f92eb1d847b36923 (diff)
downloadopenttd-9cc64bfa21a21ccaa6d96d34019655df79ba6a0b.tar.xz
(svn r15137) -Fix (r11822)(r14340): signs with sign 'Sign' were lost when converting from TTD savegames
-rw-r--r--src/saveload/afterload.cpp19
-rw-r--r--src/saveload/oldloader.cpp7
-rw-r--r--src/saveload/signs_sl.cpp9
3 files changed, 14 insertions, 21 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 13aeac2af..3de834342 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -206,14 +206,6 @@ static void UpdateVoidTiles()
for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i);
}
-/* since savegame version 6.0 each sign has an "owner", signs without owner (from old games are set to 255) */
-static void UpdateSignOwner()
-{
- Sign *si;
-
- FOR_ALL_SIGNS(si) si->owner = OWNER_NONE;
-}
-
static inline RailType UpdateRailType(RailType rt, RailType min)
{
return rt >= min ? (RailType)(rt + 1): rt;
@@ -351,9 +343,6 @@ bool AfterLoadGame()
/* from version 4.2 of the savegame, currencies are in a different order */
if (CheckSavegameVersionOldStyle(4, 2)) UpdateCurrencies();
- /* from version 6.1 of the savegame, signs have an "owner" */
- if (CheckSavegameVersionOldStyle(6, 1)) UpdateSignOwner();
-
/* In old version there seems to be a problem that water is owned by
* OWNER_NONE, not OWNER_WATER.. I can't replicate it for the current
* (4.3) version, so I just check when versions are older, and then
@@ -392,14 +381,6 @@ bool AfterLoadGame()
wp->name = CopyFromOldName(wp->string);
wp->string = STR_EMPTY;
}
-
- for (uint i = 0; i < GetSignPoolSize(); i++) {
- /* invalid signs are determined by si->ower == INVALID_COMPANY now */
- Sign *si = GetSign(i);
- if (!si->IsValid() && si->name != NULL) {
- si->owner = OWNER_NONE;
- }
- }
}
/* From this point the old names array is cleared. */
diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp
index 910188938..922b0875e 100644
--- a/src/saveload/oldloader.cpp
+++ b/src/saveload/oldloader.cpp
@@ -1145,8 +1145,11 @@ static bool LoadOldSign(LoadgameState *ls, int num)
Sign *si = new (num) Sign();
if (!LoadChunk(ls, si, sign_chunk)) return false;
- _old_string_id = RemapOldStringID(_old_string_id);
- si->name = CopyFromOldName(_old_string_id);
+ if (_old_string_id != 0) {
+ _old_string_id = RemapOldStringID(_old_string_id);
+ si->name = CopyFromOldName(_old_string_id);
+ si->owner = OWNER_NONE;
+ }
return true;
}
diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp
index ef4530dcd..7dbb9e355 100644
--- a/src/saveload/signs_sl.cpp
+++ b/src/saveload/signs_sl.cpp
@@ -41,6 +41,15 @@ static void Load_SIGN()
while ((index = SlIterateArray()) != -1) {
Sign *si = new (index) Sign();
SlObject(si, _sign_desc);
+ /* Before version 6.1, signs didn't have owner.
+ * Before version 83, invalid signs were determined by si->str == 0.
+ * Before version 103, owner could be a bankrupted company.
+ * - we can't use IsValidCompany() now, so this is fixed in AfterLoadGame()
+ * All signs that were saved are valid (including those with just 'Sign' and INVALID_OWNER).
+ * - so set owner to OWNER_NONE if needed (signs from pre-version 6.1 would be lost) */
+ if (CheckSavegameVersionOldStyle(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) {
+ si->owner = OWNER_NONE;
+ }
}
}