From f29c748d4c0e2e3a3deed96fc045d128a9d7671b Mon Sep 17 00:00:00 2001 From: peter1138 Date: Tue, 5 Feb 2008 23:22:34 +0000 Subject: (svn r12067) -Cleanup: Codestyle on loading object references --- src/saveload.cpp | 80 +++++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 44 deletions(-) (limited to 'src/saveload.cpp') diff --git a/src/saveload.cpp b/src/saveload.cpp index 3b62a3991..85c3c01d6 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -1329,64 +1329,56 @@ static void *IntToReference(uint index, SLRefType rt) { /* After version 4.3 REF_VEHICLE_OLD is saved as REF_VEHICLE, * and should be loaded like that */ - if (rt == REF_VEHICLE_OLD && !CheckSavegameVersionOldStyle(4, 4)) + if (rt == REF_VEHICLE_OLD && !CheckSavegameVersionOldStyle(4, 4)) { rt = REF_VEHICLE; + } /* No need to look up NULL pointers, just return immediately */ - if (rt != REF_VEHICLE_OLD && index == 0) + if (rt != REF_VEHICLE_OLD && index == 0) { return NULL; + } index--; // correct for the NULL index switch (rt) { - case REF_ORDER: { - if (!_Order_pool.AddBlockIfNeeded(index)) - error("Orders: failed loading savegame: too many orders"); - return GetOrder(index); - } - case REF_VEHICLE: { - if (!_Vehicle_pool.AddBlockIfNeeded(index)) - error("Vehicles: failed loading savegame: too many vehicles"); - return GetVehicle(index); - } - case REF_STATION: { - if (!_Station_pool.AddBlockIfNeeded(index)) - error("Stations: failed loading savegame: too many stations"); - return GetStation(index); - } - case REF_TOWN: { - if (!_Town_pool.AddBlockIfNeeded(index)) - error("Towns: failed loading savegame: too many towns"); - return GetTown(index); - } - case REF_ROADSTOPS: { - if (!_RoadStop_pool.AddBlockIfNeeded(index)) - error("RoadStops: failed loading savegame: too many RoadStops"); - return GetRoadStop(index); - } - case REF_ENGINE_RENEWS: { - if (!_EngineRenew_pool.AddBlockIfNeeded(index)) - error("EngineRenews: failed loading savegame: too many EngineRenews"); - return GetEngineRenew(index); - } - case REF_CARGO_PACKET: { - if (!_CargoPacket_pool.AddBlockIfNeeded(index)) - error("CargoPackets: failed loading savegame: too many Cargo packets"); - return GetCargoPacket(index); - } + case REF_ORDER: + if (_Order_pool.AddBlockIfNeeded(index)) return GetOrder(index); + error("Orders: failed loading savegame: too many orders"); - case REF_VEHICLE_OLD: { + case REF_VEHICLE: + if (_Vehicle_pool.AddBlockIfNeeded(index)) return GetVehicle(index); + error("Vehicles: failed loading savegame: too many vehicles"); + + case REF_STATION: + if (_Station_pool.AddBlockIfNeeded(index)) return GetStation(index); + error("Stations: failed loading savegame: too many stations"); + + case REF_TOWN: + if (_Town_pool.AddBlockIfNeeded(index)) return GetTown(index); + error("Towns: failed loading savegame: too many towns"); + + case REF_ROADSTOPS: + if (_RoadStop_pool.AddBlockIfNeeded(index)) return GetRoadStop(index); + error("RoadStops: failed loading savegame: too many RoadStops"); + + case REF_ENGINE_RENEWS: + if (_EngineRenew_pool.AddBlockIfNeeded(index)) return GetEngineRenew(index); + error("EngineRenews: failed loading savegame: too many EngineRenews"); + + case REF_CARGO_PACKET: + if (_CargoPacket_pool.AddBlockIfNeeded(index)) return GetCargoPacket(index); + error("CargoPackets: failed loading savegame: too many Cargo packets"); + + case REF_VEHICLE_OLD: /* Old vehicles were saved differently: * invalid vehicle was 0xFFFF, * and the index was not - 1.. correct for this */ index++; - if (index == INVALID_VEHICLE) - return NULL; + if (index == INVALID_VEHICLE) return NULL; + + if (_Vehicle_pool.AddBlockIfNeeded(index)) GetVehicle(index); + error("Vehicles: failed loading savegame: too many vehicles"); - if (!_Vehicle_pool.AddBlockIfNeeded(index)) - error("Vehicles: failed loading savegame: too many vehicles"); - return GetVehicle(index); - } default: NOT_REACHED(); } -- cgit v1.2.3-54-g00ecf