diff options
author | tron <tron@openttd.org> | 2006-05-09 09:56:09 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-05-09 09:56:09 +0000 |
commit | c9defc0fea20dc900c0c6d3f8aac8984b024052f (patch) | |
tree | 559b2b4b3e046cf2cb59f9c2eacbb8ea4f57cbb5 | |
parent | e5bd292dabdf5bbf58e5ce83c13688bbe047a62a (diff) | |
download | openttd-c9defc0fea20dc900c0c6d3f8aac8984b024052f.tar.xz |
(svn r4790) Remove slope magic from EnsureNoVehicleZ() and rename it to EnsureNoVehicleOnGround() to make more clear what it does
-rw-r--r-- | functions.h | 3 | ||||
-rw-r--r-- | rail_cmd.c | 2 | ||||
-rw-r--r-- | road_cmd.c | 2 | ||||
-rw-r--r-- | tile.h | 7 | ||||
-rw-r--r-- | tunnelbridge_cmd.c | 6 | ||||
-rw-r--r-- | vehicle.c | 17 |
6 files changed, 9 insertions, 28 deletions
diff --git a/functions.h b/functions.h index 3d47bca61..11730800c 100644 --- a/functions.h +++ b/functions.h @@ -193,9 +193,8 @@ bool ScrollWindowTo(int x, int y, Window * w); bool ScrollMainWindowToTile(TileIndex tile); bool ScrollMainWindowTo(int x, int y); void DrawSprite(uint32 img, int x, int y); -uint GetCorrectTileHeight(TileIndex tile); bool EnsureNoVehicle(TileIndex tile); -bool EnsureNoVehicleZ(TileIndex tile, byte z); +bool EnsureNoVehicleOnGround(TileIndex tile); void MarkAllViewportsDirty(int left, int top, int right, int bottom); void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost); void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost); diff --git a/rail_cmd.c b/rail_cmd.c index 773c981cd..89a03d047 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -349,7 +349,7 @@ int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) GetTransportTypeUnderBridge(tile) != TRANSPORT_RAIL || GetRailBitsUnderBridge(tile) != trackbit || (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) || - !EnsureNoVehicleZ(tile, TilePixelHeight(tile))) { + !EnsureNoVehicleOnGround(tile)) { return CMD_ERROR; } diff --git a/road_cmd.c b/road_cmd.c index e1d7a09a3..52c2df2b2 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -125,7 +125,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) switch (GetTileType(tile)) { case MP_TUNNELBRIDGE: - if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (!IsBridge(tile) || !IsBridgeMiddle(tile) || @@ -32,13 +32,6 @@ Slope GetTileSlope(TileIndex tile, uint *h); uint GetTileZ(TileIndex tile); uint GetTileMaxZ(TileIndex tile); -static inline bool CorrectZ(Slope tileh) -{ - /* tile height must be corrected if the north corner is not raised, but - * any other corner is. These are the cases 1 till 7 */ - return IS_INT_INSIDE(tileh, 1, 8); -} - static inline uint TileHeight(TileIndex tile) { assert(tile < MapSize()); diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 3076cc236..bae9977f0 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -608,7 +608,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags) int32 cost; // check if we own the tile below the bridge.. - if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile)))) + if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile))) return CMD_ERROR; if (GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) { @@ -626,7 +626,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags) /* delete canal under bridge */ // check for vehicles under bridge - if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR; + if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { SetClearUnderBridge(tile); @@ -752,7 +752,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec) IsTransportUnderBridge(tile) && GetTransportTypeUnderBridge(tile) == TRANSPORT_RAIL) { // only check for train under bridge - if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile))) + if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (GetRailType(tile) == totype) return CMD_ERROR; @@ -131,30 +131,19 @@ static void *EnsureNoVehicleProcZ(Vehicle *v, void *data) const TileInfo *ti = data; if (v->tile != ti->tile || v->type == VEH_Disaster) return NULL; - if (!IS_INT_INSIDE(ti->z - v->z_pos, 0, TILE_HEIGHT + 1)) return NULL; + if (v->z_pos > ti->z) return NULL; VehicleInTheWayErrMsg(v); return v; } -static inline uint Correct_Z(Slope tileh) -{ - // needs z correction for slope-type graphics that have the NORTHERN tile lowered - return CorrectZ(tileh) ? TILE_HEIGHT : 0; -} - -uint GetCorrectTileHeight(TileIndex tile) -{ - return Correct_Z(GetTileSlope(tile, NULL)); -} -bool EnsureNoVehicleZ(TileIndex tile, byte z) +bool EnsureNoVehicleOnGround(TileIndex tile) { TileInfo ti; ti.tile = tile; - ti.z = z + GetCorrectTileHeight(tile); - + ti.z = GetTileMaxZ(tile); return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL; } |