summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-26 19:20:15 +0000
committertron <tron@openttd.org>2006-03-26 19:20:15 +0000
commitcda8934a557f6a7066b48a7eecf46360aa795dee (patch)
treeab641b54ed908fa761cf34615a8966e70f7e78d1
parent8f60df1817b9d45f8baa5ab96ab9affb6a7025f0 (diff)
downloadopenttd-cda8934a557f6a7066b48a7eecf46360aa795dee.tar.xz
(svn r4120) Use the new station functions where appropriate
-rw-r--r--ai/default/default.c17
-rw-r--r--ai/trolly/trolly.c4
-rw-r--r--aircraft_cmd.c14
-rw-r--r--aircraft_gui.c8
-rw-r--r--disaster_cmd.c6
-rw-r--r--industry_cmd.c3
-rw-r--r--order_gui.c2
-rw-r--r--roadveh_cmd.c5
-rw-r--r--smallmap_gui.c18
-rw-r--r--station_map.h6
-rw-r--r--vehicle.h1
-rw-r--r--water_cmd.c9
12 files changed, 38 insertions, 55 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 847ef12e9..7b89d0b1f 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -359,7 +359,7 @@ static void AiHandleReplaceAircraft(Player *p)
BackuppedOrders orderbak[1];
EngineID veh;
- if (!IsAircraftHangarTile(v->tile) || !(v->vehstatus&VS_STOPPED)) {
+ if (!IsHangarTile(v->tile) || !(v->vehstatus & VS_STOPPED)) {
AiHandleGotoDepot(p, CMD_SEND_AIRCRAFT_TO_HANGAR);
return;
}
@@ -3176,15 +3176,6 @@ static void AiStateDeleteRoadBlocks(Player *p)
p->ai.state = AIS_0;
}
-static bool AiCheckIfHangar(Station *st)
-{
- TileIndex tile = st->airport_tile;
-
- // HANGAR of airports
- // 0x20 - hangar large airport (32)
- // 0x41 - hangar small airport (65)
- return (_m[tile].m5 == 32 || _m[tile].m5 == 65);
-}
static void AiStateAirportStuff(Player *p)
{
@@ -3245,7 +3236,7 @@ static void AiStateAirportStuff(Player *p)
* here for now (some of the new airport types would be
* broken because they will probably need different
* tileoff values etc), no matter that
- * AiCheckIfHangar() makes no sense. --pasky */
+ * IsHangarTile() makes no sense. --pasky */
if (acc_planes == HELICOPTERS_ONLY) {
/* Heliports should have maybe own rulesets but
* OTOH we don't want AI to pick them up when
@@ -3255,7 +3246,7 @@ static void AiStateAirportStuff(Player *p)
* because we have no such rule. */
rule = 1;
} else {
- rule = AiCheckIfHangar(st);
+ rule = IsHangarTile(st->airport_tile);
}
aib->cur_building_rule = rule;
@@ -3504,7 +3495,7 @@ static void AiStateSellVeh(Player *p)
DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
} else if (v->type == VEH_Aircraft) {
- if (!IsAircraftHangarTile(v->tile) || !(v->vehstatus & VS_STOPPED)) {
+ if (!IsHangarTile(v->tile) || !(v->vehstatus & VS_STOPPED)) {
if (v->current_order.type != OT_GOTO_DEPOT)
DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
goto going_to_depot;
diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c
index eac7793ae..9f00579cb 100644
--- a/ai/trolly/trolly.c
+++ b/ai/trolly/trolly.c
@@ -617,9 +617,7 @@ static void AiNew_State_FindStation(Player *p)
if (AiNew_CheckVehicleStation(p, st)) {
// We did found a station that was good enough!
new_tile = st->xy;
- // Cheap way to get the direction of the station...
- // Bus stations save it as 0x47 .. 0x4A, so decrease it with 0x47, and tada!
- direction = _m[st->xy].m5 - 0x47;
+ direction = GetRoadStationDir(st->xy);
break;
}
}
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 60904f4e6..1a9e123cf 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -150,7 +150,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// to just query the cost, it is not neccessary to have a valid tile (automation/AI)
if (flags & DC_QUERY_COST) return value;
- if (!IsAircraftHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
@@ -305,18 +305,10 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return value;
}
-bool IsAircraftHangarTile(TileIndex tile)
-{
- // 0x56 - hangar facing other way international airport (86)
- // 0x20 - hangar large airport (32)
- // 0x41 - hangar small airport (65)
- return IsTileType(tile, MP_STATION) &&
- (_m[tile].m5 == 32 || _m[tile].m5 == 65 || _m[tile].m5 == 86);
-}
bool CheckStoppedInHangar(const Vehicle* v)
{
- return v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile);
+ return v->vehstatus & VS_STOPPED && IsHangarTile(v->tile);
}
@@ -378,7 +370,7 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT);
if (flags & DC_EXEC) {
- if (v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile)) {
+ if (v->vehstatus & VS_STOPPED && IsHangarTile(v->tile)) {
DeleteVehicleNews(p1, STR_A014_AIRCRAFT_IS_WAITING_IN);
}
diff --git a/aircraft_gui.c b/aircraft_gui.c
index bed7ace18..60af41598 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -502,9 +502,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
uint32 disabled = 1 << 8;
StringID str;
- if (v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile)) {
- disabled = 0;
- }
+ if (v->vehstatus & VS_STOPPED && IsHangarTile(v->tile)) disabled = 0;
if (v->owner != _local_player) disabled |= 1 << 8 | 1 << 7;
w->disabled_state = disabled;
@@ -1033,7 +1031,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
DrawVehicleProfitButton(v, x, y + 13);
SetDParam(0, v->unitnumber);
- if (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_HIDDEN)) {
+ if (IsHangarTile(v->tile) && v->vehstatus & VS_HIDDEN) {
str = STR_021F;
} else {
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
@@ -1096,7 +1094,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
tile = _last_built_aircraft_depot_tile;
do {
- if (IsAircraftHangarTile(tile) && IsTileOwner(tile, _local_player)) {
+ if (IsHangarTile(tile) && IsTileOwner(tile, _local_player)) {
ShowAircraftDepotWindow(tile);
ShowBuildAircraftWindow(tile);
return;
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 95481db5f..95e7089b0 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -179,7 +179,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
+ IsAirport(tile) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
v->current_order.station = 1;
v->age = 0;
@@ -204,7 +204,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
+ IsAirport(tile) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
st = GetStationByTile(tile);
CLRBITS(st->airport_flags, RUNWAY_IN_block);
@@ -246,7 +246,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
tile = v->tile;/**/
if (IsValidTile(tile) &&
IsTileType(tile, MP_STATION) &&
- IS_BYTE_INSIDE(_m[tile].m5, 8, 0x43) &&
+ IsAirport(tile) &&
IS_HUMAN_PLAYER(GetTileOwner(tile))) {
st = GetStationByTile(tile);
SETBITS(st->airport_flags, RUNWAY_IN_block);
diff --git a/industry_cmd.c b/industry_cmd.c
index 420233624..4fe8afe51 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -4,6 +4,7 @@
#include "openttd.h"
#include "clear_map.h"
#include "industry_map.h"
+#include "station_map.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "functions.h"
@@ -877,7 +878,7 @@ void DeleteIndustry(Industry *i)
if (GetIndustryIndex(tile_cur) == i->index) {
DoClearSquare(tile_cur);
}
- } else if (IsTileType(tile_cur, MP_STATION) && _m[tile_cur].m5 == 0x4B) {
+ } else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
DeleteOilRig(tile_cur);
}
END_TILE_LOOP(tile_cur, i->width, i->height, i->xy);
diff --git a/order_gui.c b/order_gui.c
index c1f4bc79b..a414bba8c 100644
--- a/order_gui.c
+++ b/order_gui.c
@@ -218,7 +218,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
case MP_STATION:
if (v->type != VEH_Aircraft) break;
- if (IsAircraftHangarTile(tile) && IsTileOwner(tile, _local_player)) {
+ if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
order.flags = OF_PART_OF_ORDERS;
order.station = GetStationIndex(tile);
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index e3f1c6fb4..d3b6ae63d 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1088,8 +1088,7 @@ static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir
goto do_it;
}
} else if (IsTileType(desttile, MP_STATION)) {
- if (IS_BYTE_INSIDE(_m[desttile].m5, 0x43, 0x4B)) {
- /* We are heading for a station */
+ if (IsRoadStop(desttile)) {
dir = GetRoadStationDir(desttile);
do_it:;
/* When we are heading for a depot or station, we just
@@ -1321,7 +1320,7 @@ again:
v->cur_speed = 0;
return;
}
- if (IS_BYTE_INSIDE(_m[v->tile].m5, 0x43, 0x4B)) {
+ if (IsRoadStop(v->tile)) {
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
// reached a loading bay, mark it as used and clear the usage bit
diff --git a/smallmap_gui.c b/smallmap_gui.c
index 4f8ae49a3..181ab2ee3 100644
--- a/smallmap_gui.c
+++ b/smallmap_gui.c
@@ -6,6 +6,7 @@
#include "clear_map.h"
#include "functions.h"
#include "spritecache.h"
+#include "station_map.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "map.h"
@@ -445,14 +446,15 @@ static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
uint32 bits;
if (t == MP_STATION) {
- byte m5 = _m[tile].m5;
- (bits = MKCOLOR(0x56565656), m5 < 8) || // 8 - railroad station (green)
- (bits = MKCOLOR(0xB8B8B8B8), m5 < 0x43) || // 67 - airport (red)
- (bits = MKCOLOR(0xC2C2C2C2), m5 < 0x47) || // 71 - truck loading bay (orange)
- (bits = MKCOLOR(0xBFBFBFBF), m5 < 0x4B) || // 75 - bus station (yellow)
- (bits = MKCOLOR(0x98989898), m5 < 0x53) || // 83 - docks (blue)
- (bits = MKCOLOR(0xB8B8B8B8), m5 < 0x73) || // 115 - airport (red) (new airports)
- (bits = MKCOLOR(0xFFFFFFFF), true); // all others
+ switch (GetStationType(tile)) {
+ case STATION_RAIL: bits = MKCOLOR(0x56565656); break;
+ case STATION_HANGAR:
+ case STATION_AIRPORT: bits = MKCOLOR(0xB8B8B8B8); break;
+ case STATION_TRUCK: bits = MKCOLOR(0xC2C2C2C2); break;
+ case STATION_BUS: bits = MKCOLOR(0xBFBFBFBF); break;
+ case STATION_DOCK: bits = MKCOLOR(0x98989898); break;
+ default: bits = MKCOLOR(0xFFFFFFFF); break;
+ }
} else {
// ground color
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]);
diff --git a/station_map.h b/station_map.h
index 84693f9d9..97b848eed 100644
--- a/station_map.h
+++ b/station_map.h
@@ -111,6 +111,12 @@ static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
}
+static inline bool IsHangarTile(TileIndex t)
+{
+ return IsTileType(t, MP_STATION) && IsHangar(t);
+}
+
+
static inline Axis GetRailStationAxis(TileIndex t)
{
assert(IsRailwayStation(t));
diff --git a/vehicle.h b/vehicle.h
index ecc250963..f2ce6efb1 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -300,7 +300,6 @@ void VehicleEnteredDepotThisTick(Vehicle *v);
void BeginVehicleMove(Vehicle *v);
void EndVehicleMove(Vehicle *v);
-bool IsAircraftHangarTile(TileIndex tile);
void ShowAircraftViewWindow(const Vehicle* v);
UnitID GetFreeUnitNumber(byte type);
diff --git a/water_cmd.c b/water_cmd.c
index 952ab3145..78f4e82be 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -3,6 +3,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
+#include "station_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
@@ -340,17 +341,13 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
// return true if a tile is a water tile.
static bool IsWateredTile(TileIndex tile)
{
- byte m5 = _m[tile].m5;
-
switch (GetTileType(tile)) {
case MP_WATER:
// true, if not coast/riverbank
- return m5 != 1;
+ return _m[tile].m5 != 1;
case MP_STATION:
- // returns true if it is a dock-station
- // m5 inside values is m5 < 75 all stations, 83 <= m5 <= 114 new airports
- return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
+ return IsOilRig(tile) || IsDock(tile) || IsBuoy_(tile);
case MP_TUNNELBRIDGE:
return IsBridge(tile) && IsBridgeMiddle(tile) && IsWaterUnderBridge(tile);