summaryrefslogtreecommitdiff
path: root/station_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-04-23 13:48:16 +0000
committertron <tron@openttd.org>2006-04-23 13:48:16 +0000
commit0347fb2ab67e942826523424c35ede66d27339fe (patch)
tree3f0769bd955cefba7ab80063e64546c1874e0a62 /station_cmd.c
parentb5ce99c52d1ce36f56431652f7fcc67eb9d5bf6d (diff)
downloadopenttd-0347fb2ab67e942826523424c35ede66d27339fe.tar.xz
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
Diffstat (limited to 'station_cmd.c')
-rw-r--r--station_cmd.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/station_cmd.c b/station_cmd.c
index cf9876149..08edf3eb3 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -776,7 +776,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
{
int32 cost = 0, ret;
- uint tileh;
+ Slope tileh;
uint z;
int allowed_z = -1;
int flat_z;
@@ -794,18 +794,18 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
-OR-
b) the build_on_slopes switch is disabled
*/
- if (IsSteepTileh(tileh) ||
- ((_is_old_ai_player || !_patches.build_on_slopes) && tileh != 0)) {
+ if (IsSteepSlope(tileh) ||
+ ((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
flat_z = z;
- if (tileh) {
+ if (tileh != SLOPE_FLAT) {
// need to check so the entrance to the station is not pointing at a slope.
- if ((invalid_dirs&1 && !(tileh & 0xC) && (uint)w_cur == w) ||
- (invalid_dirs&2 && !(tileh & 6) && h_cur == 1) ||
- (invalid_dirs&4 && !(tileh & 3) && w_cur == 1) ||
- (invalid_dirs&8 && !(tileh & 9) && (uint)h_cur == h)) {
+ if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
+ (invalid_dirs&2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
+ (invalid_dirs&4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
+ (invalid_dirs&8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
cost += _price.terraform;
@@ -1823,10 +1823,10 @@ int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
switch (GetTileSlope(tile, NULL)) {
- case 3: direction = DIAGDIR_NE; break;
- case 6: direction = DIAGDIR_NW; break;
- case 9: direction = DIAGDIR_SE; break;
- case 12: direction = DIAGDIR_SW; break;
+ case SLOPE_SW: direction = DIAGDIR_NE; break;
+ case SLOPE_SE: direction = DIAGDIR_NW; break;
+ case SLOPE_NW: direction = DIAGDIR_SE; break;
+ case SLOPE_NE: direction = DIAGDIR_SW; break;
default: return_cmd_error(STR_304B_SITE_UNSUITABLE);
}
@@ -1839,7 +1839,7 @@ int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR;
- if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != 0) {
+ if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_304B_SITE_UNSUITABLE);
}
@@ -1847,7 +1847,7 @@ int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (CmdFailed(cost)) return CMD_ERROR;
tile_cur = tile_cur + TileOffsByDir(direction);
- if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != 0) {
+ if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_304B_SITE_UNSUITABLE);
}
@@ -1957,7 +1957,7 @@ static void DrawTile_Station(TileInfo *ti)
}
// don't show foundation for docks
- if (ti->tileh != 0 && !IsDock(ti->tile))
+ if (ti->tileh != SLOPE_FLAT && !IsDock(ti->tile))
DrawFoundation(ti, ti->tileh);
if (IsCustomStationSpecIndex(ti->tile)) {
@@ -2032,12 +2032,12 @@ void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
static uint GetSlopeZ_Station(const TileInfo* ti)
{
- return ti->z + (ti->tileh == 0 ? 0 : 8);
+ return ti->z + (ti->tileh == SLOPE_FLAT ? 0 : 8);
}
-static uint GetSlopeTileh_Station(TileIndex tile, uint tileh)
+static Slope GetSlopeTileh_Station(TileIndex tile, Slope tileh)
{
- return 0;
+ return SLOPE_FLAT;
}
static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac)