1
0
Fork 0

(svn r4164) Use acessor functions

release/0.5
tron 2006-03-30 09:08:43 +00:00
parent 1bb8d3a3b5
commit d9e705ae52
4 changed files with 26 additions and 20 deletions

View File

@ -45,6 +45,7 @@ the pylon would be rectangular to the track). PPPs are represented by the Direct
#include "stdafx.h" #include "stdafx.h"
#include "openttd.h" #include "openttd.h"
#include "station_map.h"
#include "tile.h" #include "tile.h"
#include "viewport.h" #include "viewport.h"
#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */ #include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */
@ -83,7 +84,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
if (IsTunnel(t)) { if (IsTunnel(t)) {
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
if (override != NULL) *override = 1 << GetTunnelDirection(t); if (override != NULL) *override = 1 << GetTunnelDirection(t);
return (_m[t].m5 & 1) ? TRACK_BIT_Y : TRACK_BIT_X; return DiagDirToAxis(GetTunnelDirection(t)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y;
} else { } else {
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
if ( if (
@ -98,11 +99,11 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
} }
} }
case MP_STREET: case MP_STREET:
if ((_m[t].m4 & 0xF) != RAILTYPE_ELECTRIC) return 0; if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0;
return GetCrossingRailBits(t); return GetCrossingRailBits(t);
case MP_STATION: case MP_STATION:
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X; return GetRailStationTrack(t);
default: default:
return 0; return 0;
} }

View File

@ -13,6 +13,7 @@
#define VARDEF #define VARDEF
#include "openttd.h" #include "openttd.h"
#include "bridge_map.h"
#include "functions.h" #include "functions.h"
#include "mixer.h" #include "mixer.h"
#include "spritecache.h" #include "spritecache.h"
@ -20,6 +21,8 @@
#include "gfxinit.h" #include "gfxinit.h"
#include "gui.h" #include "gui.h"
#include "station.h" #include "station.h"
#include "station_map.h"
#include "tunnel_map.h"
#include "vehicle.h" #include "vehicle.h"
#include "viewport.h" #include "viewport.h"
#include "window.h" #include "window.h"
@ -1274,23 +1277,25 @@ bool AfterLoadGame(void)
break; break;
case MP_STATION: case MP_STATION:
if (_m[t].m5 < 8 && (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail)) AB(_m[t].m3, 0, 4, 1); if (IsRailwayStation(t) && (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail)) AB(_m[t].m3, 0, 4, 1);
break; break;
case MP_TUNNELBRIDGE: case MP_TUNNELBRIDGE:
if (GB(_m[t].m5, 4, 4) == 0) { // tunnel? if (IsTunnel(t)) {
if (GB(_m[t].m5, 2, 2) == 0) { // railway tunnel? if (GetTunnelTransportType(t) == TRANSPORT_RAIL) {
if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1);
} }
} else { } else {
if (GB(_m[t].m5, 1, 2) == 0) { // railway bridge? if (GetBridgeTransportType(t) == TRANSPORT_RAIL) {
if (GB(_m[t].m5, 6, 1) == 0) { // bridge ending? if (IsBridgeRamp(t)) {
if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1);
} else { } else {
if (GB(_m[t].m3, 4, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 4, 4, 1); if (GB(_m[t].m3, 4, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 4, 4, 1);
} }
} }
if ((_m[t].m5 & 0xF8) == 0xE0) { // bridge middle part with rails below? if (IsBridgeMiddle(t) &&
IsTransportUnderBridge(t) &&
GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL) {
if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1); if (GB(_m[t].m3, 0, 4) > RAILTYPE_RAIL || make_elrail) AB(_m[t].m3, 0, 4, 1);
} }
} }

View File

@ -787,7 +787,7 @@ static void DrawTile_Road(TileInfo *ti)
} }
DrawGroundSprite(image); DrawGroundSprite(image);
if (GB(_m[ti->tile].m4, 0, 4) == RAILTYPE_ELECTRIC) DrawCatenary(ti); if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
break; break;
} }
@ -1014,9 +1014,9 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
0 : _road_trackbits[GetRoadBits(tile)] * 0x101; 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
case ROAD_CROSSING: { case ROAD_CROSSING: {
uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101; uint32 r = GetCrossingRailBits(tile) * 0x101;
if (_m[tile].m5 & 4) r *= 0x10001; if (IsCrossingBarred(tile)) r *= 0x10001;
return r; return r;
} }

View File

@ -1252,14 +1252,14 @@ static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode
return DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? 0x101 : 0x202; return DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? 0x101 : 0x202;
} }
} else if (IsBridge(tile)) { // XXX is this necessary? } else if (IsBridge(tile)) { // XXX is this necessary?
/* This is a bridge */ if (IsBridgeRamp(tile)) {
result = 0; if (GetBridgeTransportType(tile) != mode) return 0;
if (GetBridgeTransportType(tile) == mode) { return (DiagDirToAxis(GetBridgeRampDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
/* Transport over the bridge is compatible */ } else {
result = (GetBridgeAxis(tile) == AXIS_X ? 0x101 : 0x202); result = 0;
} if (GetBridgeTransportType(tile) == mode) {
if (IsBridgeMiddle(tile)) { result = (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
/* Bridge middle part */ }
if (IsTransportUnderBridge(tile)) { if (IsTransportUnderBridge(tile)) {
if (GetTransportTypeUnderBridge(tile) != mode) return result; if (GetTransportTypeUnderBridge(tile) != mode) return result;
} else { } else {