(svn r13884) -Fix (r11822): custom vehicle names from TTD(Patch) games were lost

This commit is contained in:
smatz 2008-07-30 17:41:02 +00:00
parent faaa637987
commit 515b55c635
1 changed files with 11 additions and 2 deletions

View File

@ -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;
}