summaryrefslogtreecommitdiff
path: root/oldloader.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-06 10:18:47 +0000
committertruelight <truelight@openttd.org>2005-02-06 10:18:47 +0000
commite9c93f9c0ca76117ac1315b6aff03f1f138f62e4 (patch)
tree0b6bfe4dfd7abf3e94d0f7210b1b842e429c4a02 /oldloader.c
parent6493e12bfbb147e41fc0f533bb3618b2931fed1f (diff)
downloadopenttd-e9c93f9c0ca76117ac1315b6aff03f1f138f62e4.tar.xz
(svn r1817) -Codechange: Moved depot-functions to depot.c
-Codechange: Added wrappers around depot-access (GetDepot no exists) -Codechange: Made depot-functions a bit more logic (no longer GetDepotByTile crashes your game when you request it on a non-depot tile) -Add: made depots dynamic (yes, 64k depots are possible now)
Diffstat (limited to 'oldloader.c')
-rw-r--r--oldloader.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/oldloader.c b/oldloader.c
index 24db721cc..08165476f 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -11,6 +11,7 @@
#include "engine.h"
#include "vehicle.h"
#include "signs.h"
+#include "depot.h"
extern byte _name_array[512][32];
extern TileIndex _animated_tile_list[256];
@@ -777,15 +778,23 @@ static void FixStation(OldStation *o, int num)
} while (i++,o++,--num);
}
-static void FixDepot(Depot *n, OldDepot *o, int num)
+static void FixDepot(OldDepot *o, int num)
{
+ Depot *depot;
+ uint i = 0;
+
do {
if (o->xy == 0)
continue;
- n->town_index = REMAP_TOWN_IDX(o->town);
- n->xy = o->xy;
- } while (n++,o++,--num);
+ if (!AddBlockIfNeeded(&_depot_pool, i))
+ error("Depots: failed loading savegame: too many depots");
+
+ depot = GetDepot(i);
+
+ depot->town_index = REMAP_TOWN_IDX(o->town);
+ depot->xy = o->xy;
+ } while (i++,o++,--num);
}
static void FixOrder(uint16 *o, int num)
@@ -1533,7 +1542,7 @@ bool LoadOldSaveGame(const char *file)
FixIndustry(m->industries, lengthof(m->industries));
FixStation(m->stations, lengthof(m->stations));
- FixDepot(_depots, m->depots, lengthof(m->depots));
+ FixDepot(m->depots, lengthof(m->depots));
FixOrder(m->order_list, lengthof(m->order_list));
FixVehicle(m->vehicles, lengthof(m->vehicles));
FixSubsidy(_subsidies, m->subsidies, lengthof(m->subsidies));