summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-02-05 23:22:34 +0000
committerpeter1138 <peter1138@openttd.org>2008-02-05 23:22:34 +0000
commitf29c748d4c0e2e3a3deed96fc045d128a9d7671b (patch)
treeb6a1aab969ec51ec44ea36d25d1b8ea33de942e7
parent62b3520e51fb51c66c094f304a85461564c0b364 (diff)
downloadopenttd-f29c748d4c0e2e3a3deed96fc045d128a9d7671b.tar.xz
(svn r12067) -Cleanup: Codestyle on loading object references
-rw-r--r--src/saveload.cpp80
1 files changed, 36 insertions, 44 deletions
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();
}