summaryrefslogtreecommitdiff
path: root/tunnelbridge_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-17 10:10:31 +0000
committertron <tron@openttd.org>2006-03-17 10:10:31 +0000
commit89090790c2405a738f5977310549cf94df9c06cb (patch)
tree0fa3ce74d133cc13b1aaf01d162e59d16ce3371e /tunnelbridge_cmd.c
parentd8677f1afad4e706b92689b471d6c7a6c210aa82 (diff)
downloadopenttd-89090790c2405a738f5977310549cf94df9c06cb.tar.xz
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
Diffstat (limited to 'tunnelbridge_cmd.c')
-rw-r--r--tunnelbridge_cmd.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index 13e76260f..58b72bf2a 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -333,7 +333,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
transport_under = TRANSPORT_RAIL;
owner_under = GetTileOwner(tile);
- rail_under = GB(_m[tile].m3, 0, 4);
+ rail_under = GetRailType(tile);
break;
case MP_STREET:
@@ -672,7 +672,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
for (c = tile + delta; c != endtile; c += delta) {
if (IsTransportUnderBridge(c)) {
if (GetTransportTypeUnderBridge(c) == TRANSPORT_RAIL) {
- MakeRailNormal(c, GetTileOwner(c), GetRailBitsUnderBridge(c), GB(_m[c].m3, 0, 3));
+ MakeRailNormal(c, GetTileOwner(c), GetRailBitsUnderBridge(c), GetRailType(tile));
} else {
uint town = IsTileOwner(c, OWNER_TOWN) ? ClosestTownFromTile(c, (uint)-1)->index : 0;
MakeRoadNormal(c, GetTileOwner(c), GetRoadBitsUnderBridge(c), town);
@@ -721,14 +721,14 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
if (!CheckTileOwnership(tile)) return CMD_ERROR;
- if (GB(_m[tile].m3, 0, 4) == totype) return CMD_ERROR;
+ if (GetRailType(tile) == totype) return CMD_ERROR;
endtile = CheckTunnelBusy(tile, &length);
if (endtile == INVALID_TILE) return CMD_ERROR;
if (exec) {
- SB(_m[tile].m3, 0, 4, totype);
- SB(_m[endtile].m3, 0, 4, totype);
+ SetRailType(tile, totype);
+ SetRailType(endtile, totype);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(endtile);
}
@@ -741,11 +741,10 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile)))
return CMD_ERROR;
- // tile is already of requested type?
- if (GB(_m[tile].m3, 0, 4) == totype) return CMD_ERROR;
- // change type.
+ if (GetRailType(tile) == totype) return CMD_ERROR;
+
if (exec) {
- SB(_m[tile].m3, 0, 4, totype);
+ SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
}
return _price.build_rail >> 1;
@@ -771,11 +770,11 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
return CMD_ERROR;
}
- if (GB(_m[tile].m3, 0, 4) == totype) return CMD_ERROR;
+ if (GetRailType(tile) == totype) return CMD_ERROR;
if (exec) {
- SB(_m[tile].m3, 0, 4, totype);
- SB(_m[endtile].m3, 0, 4, totype);
+ SetRailType(tile, totype);
+ SetRailType(endtile, totype);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(endtile);
}
@@ -783,7 +782,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
delta = TileOffsByDir(GetBridgeRampDirection(tile));
for (tile += delta; tile != endtile; tile += delta) {
if (exec) {
- SB(_m[tile].m3, 4, 4, totype);
+ SetRailTypeOnBridge(tile, totype);
MarkTileDirtyByTile(tile);
}
cost += _price.build_rail >> 1;
@@ -918,7 +917,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
if (IsTunnel(ti->tile)) {
if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
- image = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4))->base_sprites.tunnel;
+ image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
} else {
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
}
@@ -936,9 +935,9 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
RailType rt;
if (IsBridgeRamp(ti->tile)) {
- rt = GB(_m[ti->tile].m3, 0, 3);
+ rt = GetRailType(ti->tile);
} else {
- rt = GB(_m[ti->tile].m3, 4, 3);
+ rt = GetRailTypeOnBridge(ti->tile);
}
base_offset = GetRailTypeInfo(rt)->bridge_offset;
@@ -987,7 +986,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
}
if (GetTransportTypeUnderBridge(ti->tile) == TRANSPORT_RAIL) {
- const RailtypeInfo *rti = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4));
+ const RailtypeInfo* rti = GetRailTypeInfo(GetRailType(ti->tile));
if (ti->tileh == 0) {
image = (axis == AXIS_X ? SPR_RAIL_TRACK_Y : SPR_RAIL_TRACK_X);