summaryrefslogtreecommitdiff
path: root/road_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-07-16 23:47:37 +0000
committercelestar <celestar@openttd.org>2005-07-16 23:47:37 +0000
commitde19186be3001000286e0893cd0e2da2f3f5925d (patch)
treeb32b3e56573203f32982f2fc2b3966529a6d1857 /road_cmd.c
parent594dd34e84e78b03e1cdeb7cf262707fd714a5fa (diff)
downloadopenttd-de19186be3001000286e0893cd0e2da2f3f5925d.tar.xz
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
(i.e. spans two height levels) and use it throughout the code. -Codechange: Add CanBuildDepotByTileh to find if a tile is suitable to build a depot on it. Wraps some bitmagic which seems quite unreadable at first glance
Diffstat (limited to 'road_cmd.c')
-rw-r--r--road_cmd.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/road_cmd.c b/road_cmd.c
index 3996901ef..4fa262641 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -322,7 +322,7 @@ static const byte _valid_tileh_slopes_road[3][15] = {
static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing)
{
- if (!(tileh & 0x10)) {
+ if (!IsSteepTileh(tileh)) {
byte road_bits = *pieces | existing;
// no special foundation
@@ -385,7 +385,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
} else if (ti.type == MP_RAILWAY) {
byte m5;
- if (ti.tileh & 0x10) // very steep tile
+ if (IsSteepTileh(ti.tile)) // very steep tile
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
if(!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes
@@ -417,7 +417,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
} else if (ti.type == MP_TUNNELBRIDGE) {
/* check for flat land */
- if (ti.tileh & 0x10) // very steep tile
+ if (IsSteepTileh(ti.tileh)) // very steep tile
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
/* is this middle part of a bridge? */
@@ -620,6 +620,9 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* @param x,y tile coordinates where the depot will be built
* @param p1 depot direction (0 through 3), where 0 is NW, 1 is NE, etc.
* @param p2 unused
+ *
+ * @todo When checking for the tile slope,
+ * distingush between "Flat land required" and "land sloped in wrong direction"
*/
int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
@@ -639,8 +642,12 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!EnsureNoVehicle(tile))
return CMD_ERROR;
- if (ti.tileh != 0) {
- if (!_patches.build_on_slopes || (ti.tileh & 0x10 || !((0x4C >> p1) & ti.tileh) ))
+ if ((ti.tileh != 0) && (
+ !_patches.build_on_slopes ||
+ IsSteepTileh(ti.tileh) ||
+ !CanBuildDepotByTileh(p1, ti.tileh)
+ )
+ ) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}