diff options
author | truelight <truelight@openttd.org> | 2005-02-06 10:18:47 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-06 10:18:47 +0000 |
commit | e9c93f9c0ca76117ac1315b6aff03f1f138f62e4 (patch) | |
tree | 0b6bfe4dfd7abf3e94d0f7210b1b842e429c4a02 /water_cmd.c | |
parent | 6493e12bfbb147e41fc0f533bb3618b2931fed1f (diff) | |
download | openttd-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 'water_cmd.c')
-rw-r--r-- | water_cmd.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/water_cmd.c b/water_cmd.c index 5f5a4c59f..c1533e04c 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -9,14 +9,10 @@ #include "town.h" #include "news.h" #include "sound.h" +#include "depot.h" static void FloodVehicle(Vehicle *v); -bool IsShipDepotTile(TileIndex tile) -{ - return IsTileType(tile, MP_WATER) && (_map5[tile] & ~3) == 0x80; -} - static bool IsClearWaterTile(uint tile) { TileInfo ti; @@ -33,7 +29,7 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) uint tile, tile2; int32 cost, ret; - Depot *dep; + Depot *depot; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -57,14 +53,14 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) // pretend that we're not making land from the water even though we actually are. cost = 0; - dep = AllocateDepot(); - if (dep == NULL) + depot = AllocateDepot(); + if (depot == NULL) return CMD_ERROR; if (flags & DC_EXEC) { - dep->xy = tile; + depot->xy = tile; _last_built_ship_depot_tile = tile; - dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; + depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER_CURRENT | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, @@ -96,17 +92,12 @@ static int32 RemoveShipDepot(uint tile, uint32 flags) return CMD_ERROR; if (flags & DC_EXEC) { - Depot *d; + /* Kill the depot */ + DoDeleteDepot(tile); - // convert the cleared tiles to water + /* Make the tiles water */ ModifyTile(tile, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); ModifyTile(tile2, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0); - - // Kill the entry from the depot table - for(d=_depots; d->xy != tile; d++) {} - d->xy = 0; - - DeleteWindowById(WC_VEHICLE_DEPOT, tile); } return _price.remove_ship_depot; |