diff -r 31fcaa5375a1 -r e72987579514 src/oldloader.cpp --- a/src/oldloader.cpp Fri Aug 03 19:16:36 2007 +0000 +++ b/src/oldloader.cpp Fri Aug 03 22:09:42 2007 +0000 @@ -477,10 +477,7 @@ }; static bool LoadOldTown(LoadgameState *ls, int num) { - if (!AddBlockIfNeeded(&_Town_pool, num)) - error("Towns: failed loading savegame: too many towns"); - - return LoadChunk(ls, GetTown(num), town_chunk); + return LoadChunk(ls, new (num) Town(), town_chunk); } static uint16 _old_order; @@ -491,12 +488,9 @@ static bool LoadOldOrder(LoadgameState *ls, int num) { - if (!AddBlockIfNeeded(&_Order_pool, num)) - error("Orders: failed loading savegame: too many orders"); - if (!LoadChunk(ls, NULL, order_chunk)) return false; - AssignOrder(GetOrder(num), UnpackOldOrder(_old_order)); + AssignOrder(new (num) Order(), UnpackOldOrder(_old_order)); /* Relink the orders to eachother (in TTD(Patch) the orders for one vehicle are behind eachother, with an invalid order (OT_NOTHING) as indication that @@ -515,12 +509,9 @@ static bool LoadOldDepot(LoadgameState *ls, int num) { - if (!AddBlockIfNeeded(&_Depot_pool, num)) - error("Depots: failed loading savegame: too many depots"); + if (!LoadChunk(ls, new (num) Depot(), depot_chunk)) return false; - if (!LoadChunk(ls, GetDepot(num), depot_chunk)) return false; - - if (IsValidDepot(GetDepot(num))) { + if (IsValidDepotID(num)) { GetDepot(num)->town_index = REMAP_TOWN_IDX(_old_town_index); } @@ -707,15 +698,10 @@ static bool LoadOldIndustry(LoadgameState *ls, int num) { - Industry *i; - - if (!AddBlockIfNeeded(&_Industry_pool, num)) - error("Industries: failed loading savegame: too many industries"); - - i = GetIndustry(num); + Industry *i = new (num) Industry(); if (!LoadChunk(ls, i, industry_chunk)) return false; - if (IsValidIndustry(i)) { + if (i->IsValid()) { i->town = GetTown(REMAP_TOWN_IDX(_old_town_index)); } @@ -906,8 +892,8 @@ }; static const OldChunks vehicle_special_chunk[] = { - OCL_SVAR( OC_UINT16, VehicleSpecial, unk0 ), - OCL_SVAR( OC_UINT8, VehicleSpecial, unk2 ), + OCL_SVAR( OC_UINT16, VehicleSpecial, animation_state ), + OCL_SVAR( OC_UINT8, VehicleSpecial, animation_substate ), OCL_NULL( 7 ), // Junk @@ -916,7 +902,7 @@ static const OldChunks vehicle_disaster_chunk[] = { OCL_SVAR( OC_UINT16, VehicleDisaster, image_override ), - OCL_SVAR( OC_UINT16, VehicleDisaster, unk2 ), + OCL_SVAR( OC_UINT16, VehicleDisaster, big_ufo_destroyer_target ), OCL_NULL( 6 ), ///< Junk @@ -1047,14 +1033,9 @@ ReadTTDPatchFlags(); for (i = 0; i < _old_vehicle_multiplier; i++) { - Vehicle *v; - _current_vehicle_id = num * _old_vehicle_multiplier + i; - if (!AddBlockIfNeeded(&_Vehicle_pool, _current_vehicle_id)) - error("Vehicles: failed loading savegame: too many vehicles"); - - v = GetVehicle(_current_vehicle_id); + Vehicle *v = new (_current_vehicle_id) InvalidVehicle(); if (!LoadChunk(ls, v, vehicle_chunk)) return false; /* This should be consistent, else we have a big problem... */ @@ -1105,10 +1086,7 @@ static bool LoadOldSign(LoadgameState *ls, int num) { - if (!AddBlockIfNeeded(&_Sign_pool, num)) - error("Signs: failed loading savegame: too many signs"); - - return LoadChunk(ls, GetSign(num), sign_chunk); + return LoadChunk(ls, new (num) Sign(), sign_chunk); } static const OldChunks engine_chunk[] = {