summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-02-23 12:24:19 +0000
committertron <tron@openttd.org>2006-02-23 12:24:19 +0000
commitb26d54585f5867a91b7119df83509398fc650f02 (patch)
treef5ac06f102968f6cf3cbe40e0fca7d7a55514d1b
parenta975616303292c5762a256a66aa24ff707614cc1 (diff)
downloadopenttd-b26d54585f5867a91b7119df83509398fc650f02.tar.xz
(svn r3660) Convert further road bits and type references to the functions/enums
-rw-r--r--ai/default/default.c13
-rw-r--r--ai/trolly/trolly.c6
-rw-r--r--order_gui.c3
-rw-r--r--rail_cmd.c12
-rw-r--r--road_cmd.c2
-rw-r--r--town_cmd.c3
6 files changed, 22 insertions, 17 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index dd0700fd1..50b5c7674 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -4,6 +4,7 @@
#include "../../openttd.h"
#include "../../functions.h"
#include "../../map.h"
+#include "../../road.h"
#include "../../tile.h"
#include "../../player.h"
#include "../../vehicle.h"
@@ -2506,12 +2507,12 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData
if (p->mode == 2) {
if (IsTileType(c, MP_STREET) &&
- (_m[c].m5 & 0xF0) == 0 &&
- (_m[c].m5 & p->attr) != 0) {
+ GetRoadType(c) == ROAD_NORMAL &&
+ (GetRoadBits(c) & p->attr) != 0) {
roadflag |= 2;
// all bits are already built?
- if ((_m[c].m5 & p->attr) == p->attr) continue;
+ if ((GetRoadBits(c) & p->attr) == p->attr) continue;
}
ret = DoCommandByTile(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
@@ -2548,7 +2549,7 @@ clear_town_stuff:;
if (GetTileSlope(c, NULL) != 0) return CMD_ERROR;
- if (!IsTileType(c, MP_STREET) || (_m[c].m5 & 0xF0) != 0) {
+ if (!IsTileType(c, MP_STREET) || GetRoadType(c) != ROAD_NORMAL) {
ret = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
}
@@ -2726,7 +2727,7 @@ static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint leng
if (dist <= a->best_dist) {
TileIndex tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track]));
- if (IsTileType(tile2, MP_STREET) && GB(_m[tile2].m5, 4, 4) == 0) {
+ if (IsTileType(tile2, MP_STREET) && GetRoadType(tile2) == ROAD_NORMAL) {
a->best_dist = dist;
a->best_tile = tile;
a->best_track = track;
@@ -3631,7 +3632,7 @@ pos_3:
if (IsLevelCrossing(tile)) goto is_rail_crossing;
- if ((_m[tile].m5 & 0xF0) == 0x20) { // depot
+ if (GetRoadType(tile) == ROAD_DEPOT) {
uint dir;
// Check if there are any stations around.
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index c46324cd0..30eda929e 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -21,6 +21,7 @@
#include "../../openttd.h"
#include "../../debug.h"
#include "../../functions.h"
+#include "../../road.h"
#include "../../table/strings.h"
#include "../../map.h"
#include "../../tile.h"
@@ -793,8 +794,7 @@ static void AiNew_State_FindDepot(Player *p)
tile = p->ainew.path_info.route[i];
for (j = 0; j < 4; j++) {
if (IsTileType(tile + TileOffsByDir(j), MP_STREET)) {
- // Its a street, test if it is a depot
- if (_m[tile + TileOffsByDir(j)].m5 & 0x20) {
+ if (GetRoadType(tile + TileOffsByDir(j)) == ROAD_DEPOT) {
// We found a depot, is it ours? (TELL ME!!!)
if (IsTileOwner(tile + TileOffsByDir(j), _current_player)) {
// Now, is it pointing to the right direction.........
@@ -1100,7 +1100,7 @@ static void AiNew_State_BuildDepot(Player *p)
int res = 0;
assert(p->ainew.state == AI_STATE_BUILD_DEPOT);
- if (IsTileType(p->ainew.depot_tile, MP_STREET) && _m[p->ainew.depot_tile].m5 & 0x20) {
+ if (IsTileType(p->ainew.depot_tile, MP_STREET) && GetRoadType(p->ainew.depot_tile) == ROAD_DEPOT) {
if (IsTileOwner(p->ainew.depot_tile, _current_player)) {
// The depot is already builded!
p->ainew.state = AI_STATE_BUILD_VEHICLE;
diff --git a/order_gui.c b/order_gui.c
index 35351a30f..c1b842617 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -2,6 +2,7 @@
#include "stdafx.h"
#include "openttd.h"
+#include "road.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
@@ -206,7 +207,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
break;
case MP_STREET:
- if ((_m[tile].m5 & 0xF0) == 0x20 && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
+ if (GetRoadType(tile) == ROAD_DEPOT && v->type == VEH_Road && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.station = GetDepotByTile(tile)->index;
diff --git a/rail_cmd.c b/rail_cmd.c
index e166c2290..da7dcf157 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -403,7 +403,6 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Track track = (Track)p2;
TrackBits trackbit;
TileIndex tile;
- byte m5;
int32 cost = _price.remove_rail;
if (!ValParamTrackOrientation(p2)) return CMD_ERROR;
@@ -442,27 +441,30 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
_m[tile].m5 = _m[tile].m5 & 0xC7;
break;
- case MP_STREET:
+ case MP_STREET: {
+ RoadBits bits;
+
if (!IsLevelCrossing(tile)) return CMD_ERROR;
/* This is a crossing, let's check if the direction is correct */
if (_m[tile].m5 & 8) {
- m5 = 5;
if (track != TRACK_DIAG1)
return CMD_ERROR;
+ bits = ROAD_Y;
} else {
- m5 = 10;
if (track != TRACK_DIAG2)
return CMD_ERROR;
+ bits = ROAD_X;
}
if (!(flags & DC_EXEC))
return _price.remove_rail;
- _m[tile].m5 = m5;
SetTileOwner(tile, _m[tile].m3);
_m[tile].m2 = 0;
+ _m[tile].m5 = (ROAD_NORMAL << 4) | bits;
break;
+ }
case MP_RAILWAY:
if (!IsPlainRailTile(tile))
diff --git a/road_cmd.c b/road_cmd.c
index 82c5116be..320c71b9a 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -1112,7 +1112,7 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
return _m[tile].m5 & 8 ? 0x101 : 0x202;
case TRANSPORT_ROAD:
- switch (GB(_m[tile].m5, 4, 4)) {
+ switch (GetRoadType(tile)) {
case ROAD_NORMAL:
return !_road_special_gettrackstatus && GB(_m[tile].m4, 4, 3) >= 6 ?
0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
diff --git a/town_cmd.c b/town_cmd.c
index f4b14909f..1d957a39e 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -4,6 +4,7 @@
#include "openttd.h"
#include "functions.h"
#include "strings.h"
+#include "road.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "map.h"
@@ -489,7 +490,7 @@ static bool IsRoadAllowedHere(TileIndex tile, int dir)
// No, try to build one in the direction.
// if that fails clear the land, and if that fails exit.
// This is to make sure that we can build a road here later.
- if (CmdFailed(DoCommandByTile(tile, (dir&1)?0xA:0x5, 0, DC_AUTO, CMD_BUILD_ROAD)) &&
+ if (CmdFailed(DoCommandByTile(tile, (dir & 1 ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
return false;
}