From 515b55c635199db71a41ff2bd9959b9844d0dfa1 Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 30 Jul 2008 17:41:02 +0000 Subject: [PATCH] (svn r13884) -Fix (r11822): custom vehicle names from TTD(Patch) games were lost --- src/oldloader.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 9175ababe6..2cea5c8420 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(_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(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; }