summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-07-30 17:41:02 +0000
committersmatz <smatz@openttd.org>2008-07-30 17:41:02 +0000
commit515b55c635199db71a41ff2bd9959b9844d0dfa1 (patch)
tree51d98790c0ec07fa530d2e500fa4b8e1bee0d8f0 /src
parentfaaa637987425ec9c9dee78a653c398136c36fc7 (diff)
downloadopenttd-515b55c635199db71a41ff2bd9959b9844d0dfa1.tar.xz
(svn r13884) -Fix (r11822): custom vehicle names from TTD(Patch) games were lost
Diffstat (limited to 'src')
-rw-r--r--src/oldloader.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index 9175ababe..2cea5c842 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -337,6 +337,8 @@ static void FixOldStations()
}
}
+static StringID *_old_vehicle_names = NULL;
+
static void FixOldVehicles()
{
/* Check for shared orders, and link them correctly */
@@ -345,6 +347,8 @@ static void FixOldVehicles()
FOR_ALL_VEHICLES(v) {
Vehicle *u;
+ v->name = CopyFromOldName(_old_vehicle_names[v->index]);
+
/* We haven't used this bit for stations for ages */
if (v->type == VEH_ROAD &&
v->u.road.state != RVSB_IN_DEPOT &&
@@ -427,6 +431,8 @@ static void ReadTTDPatchFlags()
and 1 becomes 2. The rest of the values are okay */
if (_old_vehicle_multiplier < 2) _old_vehicle_multiplier++;
+ _old_vehicle_names = MallocT<StringID>(_old_vehicle_multiplier * 850);
+
/* TTDPatch increases the Vehicle-part in the middle of the game,
so if the multipler is anything else but 1, the assert fails..
bump the assert value so it doesn't!
@@ -1279,8 +1285,8 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
if (_old_next_ptr != 0xFFFF) v->next = GetVehiclePoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : GetVehicle(_old_next_ptr);
- _old_string_id = RemapOldStringID(_old_string_id);
- v->name = CopyFromOldName(_old_string_id);
+ _old_vehicle_names[_current_vehicle_id] = RemapOldStringID(_old_string_id);
+ v->name = NULL;
/* Vehicle-subtype is different in TTD(Patch) */
if (v->type == VEH_EFFECT) v->subtype = v->subtype >> 1;
@@ -1626,9 +1632,11 @@ static bool LoadOldMain(LoadgameState *ls)
DEBUG(oldloader, 3, "Reading main chunk...");
/* Load the biggest chunk */
_old_map3 = MallocT<byte>(OLD_MAP_SIZE * 2);
+ _old_vehicle_names = NULL;
if (!LoadChunk(ls, NULL, main_chunk)) {
DEBUG(oldloader, 0, "Loading failed");
free(_old_map3);
+ free(_old_vehicle_names);
return false;
}
DEBUG(oldloader, 3, "Done, converting game data...");
@@ -1702,6 +1710,7 @@ static bool LoadOldMain(LoadgameState *ls)
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
free(_old_map3);
+ free(_old_vehicle_names);
return true;
}