(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()

This commit is contained in:
smatz 2009-06-24 17:39:54 +00:00
parent b18bf87c90
commit 8343340acb
38 changed files with 70 additions and 55 deletions

View File

@ -4,7 +4,7 @@
#include "ai_airport.hpp"
#include "ai_station.hpp"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../company_func.h"
#include "../../command_type.h"
#include "../../town.h"
@ -82,7 +82,7 @@
if (!::IsValidTile(tile)) return -1;
if (!::IsTileType(tile, MP_STATION)) return -1;
const Station *st = ::GetStationByTile(tile);
const Station *st = ::Station::GetByTile(tile);
if (st->owner != _current_company) return -1;
if ((st->facilities & FACIL_AIRPORT) == 0) return -1;
@ -95,7 +95,7 @@
if (!::IsTileType(tile, MP_STATION)) return INVALID_TILE;
if (GetNumHangars(tile) < 1) return INVALID_TILE;
const Station *st = ::GetStationByTile(tile);
const Station *st = ::Station::GetByTile(tile);
if (st->owner != _current_company) return INVALID_TILE;
if ((st->facilities & FACIL_AIRPORT) == 0) return INVALID_TILE;

View File

@ -8,7 +8,7 @@
#include "../../tile_type.h"
#include "../../industry.h"
#include "../../strings_func.h"
#include "../../station_map.h"
#include "../../station_base.h"
#include "table/strings.h"
/* static */ int32 AIIndustry::GetIndustryCount()

View File

@ -4,7 +4,7 @@
#include "ai_marine.hpp"
#include "ai_station.hpp"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../tile_cmd.h"

View File

@ -10,7 +10,7 @@
#include "../../vehicle_base.h"
#include "../../roadstop_base.h"
#include "../../depot_base.h"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../waypoint.h"
/**

View File

@ -6,7 +6,7 @@
#include "ai_map.hpp"
#include "ai_station.hpp"
#include "../../debug.h"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../company_func.h"
#include "../../waypoint.h"
#include "../../newgrf_generic.h"

View File

@ -6,7 +6,7 @@
#include "ai_map.hpp"
#include "ai_station.hpp"
#include "ai_cargo.hpp"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../command_type.h"
#include "../../settings_type.h"
#include "../../company_func.h"

View File

@ -8,7 +8,7 @@
#include "ai_town.hpp"
#include "../../command_func.h"
#include "../../debug.h"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../roadstop_base.h"
#include "../../string_func.h"
#include "../../strings_func.h"

View File

@ -6,7 +6,7 @@
#include "ai_industry.hpp"
#include "../../tile_map.h"
#include "../../industry_map.h"
#include "../../station_map.h"
#include "../../station_base.h"
#include "../../settings_type.h"
void AITileList::FixRectangleSpan(TileIndex &t1, TileIndex &t2)

View File

@ -6,7 +6,6 @@
#define AIRCRAFT_H
#include "station_map.h"
#include "station_base.h"
#include "vehicle_base.h"
#include "engine_func.h"
#include "engine_base.h"

View File

@ -28,6 +28,7 @@
#include "company_func.h"
#include "effectvehicle_func.h"
#include "settings_type.h"
#include "station_base.h"
#include "table/strings.h"
#include "table/sprites.h"
@ -262,7 +263,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
/* Prevent building aircraft types at places which can't handle them */
if (!CanVehicleUseStation(p1, GetStationByTile(tile))) return CMD_ERROR;
if (!CanVehicleUseStation(p1, Station::GetByTile(tile))) return CMD_ERROR;
/* We will need to allocate 2 or 3 vehicle structs, depending on type */
if (!Vehicle::CanAllocateItem(avi->subtype & AIR_CTOL ? 2 : 3)) {
@ -343,7 +344,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
* layout for #th position of depot. Since layout must start with a listing
* of all depots, it is simple */
for (uint i = 0;; i++) {
const Station *st = GetStationByTile(tile);
const Station *st = Station::GetByTile(tile);
const AirportFTAClass *apc = st->Airport();
assert(i != apc->nof_depots);

View File

@ -6,6 +6,7 @@
#include "roadveh.h"
#include "ship.h"
#include "aircraft.h"
#include "station_base.h"
#include "articulated_vehicles.h"
#include "textbuf_gui.h"
#include "command_func.h"
@ -843,7 +844,7 @@ struct BuildVehicleWindow : Window {
break;
case VEH_AIRCRAFT:
this->filter.flags =
tile == INVALID_TILE ? AirportFTAClass::ALL : GetStationByTile(tile)->Airport()->flags;
tile == INVALID_TILE ? AirportFTAClass::ALL : Station::GetByTile(tile)->Airport()->flags;
break;
}
this->SetupWindowStrings(type);
@ -1023,7 +1024,7 @@ struct BuildVehicleWindow : Window {
this->eng_list.Clear();
const Station *st = this->listview_mode ? NULL : GetStationByTile(this->window_number);
const Station *st = this->listview_mode ? NULL : Station::GetByTile(this->window_number);
/* Make list of all available planes.
* Also check to see if the previously selected plane is still available,

View File

@ -20,7 +20,7 @@
#include "landscape.h"
#include "industry_map.h"
#include "station_map.h"
#include "station_base.h"
#include "command_func.h"
#include "news_func.h"
#include "town.h"
@ -228,7 +228,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
if (IsValidTile(v->tile) &&
IsTileType(v->tile, MP_STATION) &&
IsAirport(v->tile)) {
Station *st = GetStationByTile(v->tile);
Station *st = Station::GetByTile(v->tile);
CLRBITS(st->airport_flags, RUNWAY_IN_block);
AI::NewEvent(GetTileOwner(v->tile), new AIEventDisasterZeppelinerCleared(st->index));
}
@ -268,7 +268,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
if (IsValidTile(v->tile) &&
IsTileType(v->tile, MP_STATION) &&
IsAirport(v->tile)) {
SETBITS(GetStationByTile(v->tile)->airport_flags, RUNWAY_IN_block);
SETBITS(Station::GetByTile(v->tile)->airport_flags, RUNWAY_IN_block);
}
return true;

View File

@ -34,6 +34,7 @@
#include "company_gui.h"
#include "signs_base.h"
#include "subsidy_func.h"
#include "station_base.h"
#include "table/strings.h"
#include "table/sprites.h"

View File

@ -6,7 +6,7 @@
#include "openttd.h"
#include "clear_map.h"
#include "industry_map.h"
#include "station_map.h"
#include "station_base.h"
#include "train.h"
#include "landscape.h"
#include "viewport_func.h"

View File

@ -15,6 +15,7 @@
#include "aircraft.h"
#include "core/smallmap_type.hpp"
#include "settings_type.h"
#include "station_base.h"
int _traininfo_vehicle_pitch = 0;
int _traininfo_vehicle_width = 29;

View File

@ -6,7 +6,7 @@
#include "variables.h"
#include "landscape.h"
#include "debug.h"
#include "station_map.h"
#include "station_base.h"
#include "roadstop_base.h"
#include "newgrf_commons.h"
#include "newgrf_station.h"
@ -469,7 +469,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, by
uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
if (IsCustomStationSpecIndex(nearby_tile)) {
const StationSpecList ssl = GetStationByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
const StationSpecList ssl = Station::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ssl.localidx;
}
return res;
@ -858,7 +858,7 @@ const StationSpec *GetStationSpec(TileIndex t)
if (!IsCustomStationSpecIndex(t)) return NULL;
st = GetStationByTile(t);
st = Station::GetByTile(t);
specindex = GetCustomStationSpecIndex(t);
return specindex < st->num_specs ? st->speclist[specindex].spec : NULL;
}
@ -890,7 +890,7 @@ void AnimateStationTile(TileIndex tile)
const StationSpec *ss = GetStationSpec(tile);
if (ss == NULL) return;
const Station *st = GetStationByTile(tile);
const Station *st = Station::GetByTile(tile);
uint8 animation_speed = ss->anim_speed;
@ -1023,7 +1023,7 @@ void StationAnimationTrigger(const Station *st, TileIndex tile, StatAnimTrigger
};
/* Get Station if it wasn't supplied */
if (st == NULL) st = GetStationByTile(tile);
if (st == NULL) st = Station::GetByTile(tile);
/* Check the cached animation trigger bitmask to see if we need
* to bother with any further processing. */

View File

@ -12,6 +12,7 @@
#include "tunnelbridge_map.h"
#include "functions.h"
#include "vehicle_base.h"
#include "station_base.h"
#include "tunnelbridge.h"
#include "pbs.h"
#include "settings_type.h"
@ -514,7 +515,7 @@ static void NPFSaveTargetData(AyStar *as, OpenListNode *current)
/* If the target is a station skip to platform end. */
if (IsRailwayStationTile(target->node.tile)) {
DiagDirection dir = TrackdirToExitdir(target->node.direction);
uint len = GetStationByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir);
uint len = Station::GetByTile(target->node.tile)->GetPlatformLength(target->node.tile, dir);
TileIndex end_tile = TILE_ADD(target->node.tile, (len - 1) * TileOffsByDiagDir(dir));
/* Update only end tile, trackdir of a station stays the same. */

View File

@ -54,6 +54,7 @@
#include "rev.h"
#include "highscore.h"
#include "thread.h"
#include "station_base.h"
#include "newgrf_commons.h"

View File

@ -23,6 +23,7 @@
#include "core/pool_func.hpp"
#include "aircraft.h"
#include "roadveh.h"
#include "station_base.h"
#include "table/strings.h"

View File

@ -24,6 +24,7 @@
#include "tilehighlight_func.h"
#include "network/network.h"
#include "settings_type.h"
#include "station_base.h"
#include "table/sprites.h"
#include "table/strings.h"

View File

@ -3,7 +3,7 @@
/** @file pathfind.cpp Implementation of the oldest supported pathfinder. */
#include "stdafx.h"
#include "station_map.h"
#include "station_base.h"
#include "settings_type.h"
#include "pathfind.h"
#include "debug.h"

View File

@ -12,6 +12,7 @@
#include "core/bitmath_func.hpp"
#include "economy_func.h"
#include "slope_type.h"
#include "strings_type.h"
enum RailTypeFlag {
RTF_CATENARY = 0, ///< Set if the rail type should have catenary drawn

View File

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "landscape.h"
#include "roadveh.h"
#include "station_map.h"
#include "station_base.h"
#include "command_func.h"
#include "news_func.h"
#include "pathfind.h"
@ -1639,7 +1639,7 @@ again:
v->frame == RVC_DRIVE_THROUGH_STOP_FRAME))) {
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
Station *st = GetStationByTile(v->tile);
Station *st = Station::GetByTile(v->tile);
/* Vehicle is at the stop position (at a bay) in a road stop.
* Note, if vehicle is loading/unloading it has already been handled,

View File

@ -602,7 +602,7 @@ bool AfterLoadGame()
for (TileIndex t = 0; t < map_size; t++) {
switch (GetTileType(t)) {
case MP_STATION: {
Station *st = GetStationByTile(t);
Station *st = Station::GetByTile(t);
/* Set up station spread; buoys do not have one */
if (!IsBuoy(t)) st->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
@ -635,7 +635,7 @@ bool AfterLoadGame()
* It was 3 (till 2.2) and later 5 (till 5.1).
* Setting it unconditionally does not hurt.
*/
GetStationByTile(t)->airport_type = AT_OILRIG;
Station::GetByTile(t)->airport_type = AT_OILRIG;
} else {
DeleteOilRig(t);
}
@ -1575,7 +1575,7 @@ bool AfterLoadGame()
if (IsBuoyTile(t)) {
/* reset buoy owner to OWNER_NONE in the station struct
* (even if it is owned by active company) */
GetStationByTile(t)->owner = OWNER_NONE;
Station::GetByTile(t)->owner = OWNER_NONE;
}
} else if (IsTileType(t, MP_ROAD)) {
/* works for all RoadTileType */

View File

@ -11,6 +11,7 @@
#include "../ship.h"
#include "../train.h"
#include "../signs_base.h"
#include "../station_base.h"
#include "../subsidy_type.h"
#include "../debug.h"
#include "../depot_base.h"

View File

@ -8,6 +8,7 @@
#include "../roadveh.h"
#include "../ship.h"
#include "../aircraft.h"
#include "../station_base.h"
#include "../effectvehicle_base.h"
#include "saveload.h"

View File

@ -7,7 +7,7 @@
#include "landscape.h"
#include "timetable.h"
#include "command_func.h"
#include "station_map.h"
#include "station_base.h"
#include "news_func.h"
#include "company_func.h"
#include "npf.h"

View File

@ -22,6 +22,7 @@
#include "settings_type.h"
#include "subsidy_func.h"
#include "core/pool_func.hpp"
#include "station_base.h"
#include "roadstop_base.h"
#include "table/strings.h"

View File

@ -18,6 +18,7 @@
#include "industry_type.h"
#include "core/geometry_type.hpp"
#include "viewport_type.h"
#include "station_map.h"
#include <list>
typedef Pool<Station, StationID, 32, 64000> StationPool;
@ -161,6 +162,11 @@ public:
bool IsBuoy() const;
uint GetCatchmentRadius() const;
static FORCEINLINE Station *GetByTile(TileIndex tile)
{
return Station::Get(GetStationIndex(tile));
}
};
#define FOR_ALL_STATIONS_FROM(var, start) FOR_ALL_ITEMS_FROM(Station, station_index, var, start)

View File

@ -31,6 +31,7 @@
#include "string_func.h"
#include "animated_tile_func.h"
#include "elrail_func.h"
#include "station_base.h"
#include "roadstop_base.h"
#include "table/strings.h"
@ -45,7 +46,7 @@ bool IsHangar(TileIndex t)
{
assert(IsTileType(t, MP_STATION));
const Station *st = GetStationByTile(t);
const Station *st = Station::GetByTile(t);
const AirportFTAClass *apc = st->Airport();
for (uint i = 0; i < apc->nof_depots; i++) {
@ -57,7 +58,7 @@ bool IsHangar(TileIndex t)
RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type)
{
const Station *st = GetStationByTile(tile);
const Station *st = Station::GetByTile(tile);
for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) {
if (rs->xy == tile) return rs;
@ -1179,7 +1180,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui
}
/* Check ownership of station */
Station *st = GetStationByTile(tile2);
Station *st = Station::GetByTile(tile2);
if (_current_company != OWNER_WATER && !CheckOwnership(st->owner)) {
continue;
}
@ -1576,7 +1577,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
{
/* Make sure the specified tile is a road stop of the correct type */
if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != GB(p2, 0, 1)) return CMD_ERROR;
Station *st = GetStationByTile(tile);
Station *st = Station::GetByTile(tile);
/* Save the stop info before it is removed */
bool is_drive_through = IsDriveThroughStopTile(tile);
RoadTypes rts = GetRoadTypes(tile);
@ -2208,7 +2209,7 @@ static void DrawTile_Station(TileInfo *ti)
if (IsCustomStationSpecIndex(ti->tile)) {
/* look for customization */
st = GetStationByTile(ti->tile);
st = Station::GetByTile(ti->tile);
statspec = st->speclist[GetCustomStationSpecIndex(ti->tile)].spec;
if (statspec != NULL) {
@ -2365,7 +2366,7 @@ static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
}
}
}
td->build_date = GetStationByTile(tile)->build_date;
td->build_date = Station::GetByTile(tile)->build_date;
const StationSpec *spec = GetStationSpec(tile);
@ -2860,7 +2861,7 @@ void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList
TileIndex cur_tile = TileAddWrap(tile, dx, dy);
if (cur_tile == INVALID_TILE || !IsTileType(cur_tile, MP_STATION)) continue;
Station *st = GetStationByTile(cur_tile);
Station *st = Station::GetByTile(cur_tile);
if (st->IsBuoy()) continue; // bouys don't accept cargo
@ -2999,7 +3000,7 @@ void BuildOilRig(TileIndex tile)
void DeleteOilRig(TileIndex tile)
{
Station *st = GetStationByTile(tile);
Station *st = Station::GetByTile(tile);
MakeWaterKeepingClass(tile, OWNER_NONE);
MarkTileDirtyByTile(tile);
@ -3087,7 +3088,7 @@ static CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
}
}
Station *st = GetStationByTile(tile);
Station *st = Station::GetByTile(tile);
switch (GetStationType(tile)) {
case STATION_RAIL: return RemoveRailroadStation(st, tile, flags);

View File

@ -19,7 +19,7 @@
#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "newgrf_cargo.h"
#include "station_map.h"
#include "station_base.h"
#include "tilehighlight_func.h"
#include "core/smallmap_type.hpp"
#include "company_base.h"
@ -1136,7 +1136,7 @@ static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool dist
/* Check the inside, to return, if we sit on another station */
BEGIN_TILE_LOOP(t, w, h, tile)
if (t < MapSize() && IsTileType(t, MP_STATION)) return GetStationByTile(t);
if (t < MapSize() && IsTileType(t, MP_STATION)) return Station::GetByTile(t);
END_TILE_LOOP(t, w, h, tile)
/* Look for deleted stations */

View File

@ -9,7 +9,6 @@
#include "road_map.h"
#include "water_map.h"
#include "station_func.h"
#include "station_base.h"
#include "rail.h"
typedef byte StationGfx;
@ -24,11 +23,6 @@ static inline StationID GetStationIndex(TileIndex t)
return (StationID)_m[t].m2;
}
static inline Station *GetStationByTile(TileIndex t)
{
return Station::Get(GetStationIndex(t));
}
enum {
GFX_RADAR_LARGE_FIRST = 31,

View File

@ -31,6 +31,7 @@
#include "vehicle_func.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "station_base.h"
#include "ai/ai.hpp"
#include "core/smallmap_type.hpp"
#include "depot_func.h"

View File

@ -6,6 +6,7 @@
#include "roadveh.h"
#include "gfx_func.h"
#include "news_func.h"
#include "airport.h"
#include "command_func.h"
#include "company_func.h"
#include "vehicle_gui.h"

View File

@ -16,7 +16,7 @@
#include "gfx_func.h"
#include "newgrf_engine.h"
#include "newgrf_text.h"
#include "station_map.h"
#include "station_base.h"
#include "roadveh.h"
#include "train.h"
#include "depot_base.h"

View File

@ -32,6 +32,7 @@
#include "newgrf_cargo.h"
#include "effectvehicle_func.h"
#include "tunnelbridge_map.h"
#include "station_base.h"
#include "ai/ai.hpp"
#include "table/sprites.h"
@ -740,7 +741,7 @@ static void FloodVehicles(TileIndex tile)
byte z = 0;
if (IsTileType(tile, MP_STATION) && IsAirport(tile)) {
const Station *st = GetStationByTile(tile);
const Station *st = Station::GetByTile(tile);
const AirportFTAClass *airport = st->Airport();
z = 1 + airport->delta_z;
for (uint x = 0; x < airport->size_x; x++) {
@ -756,7 +757,7 @@ static void FloodVehicles(TileIndex tile)
/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */
if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) {
const Station *st = GetStationByTile(tile);
const Station *st = Station::GetByTile(tile);
BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile)
if (st->TileBelongsToRailStation(t)) {
@ -790,7 +791,7 @@ static void FloodVehicle(Vehicle *v)
* because that's always the shadow. Except for the heliport, because
* that station has a big z_offset for the aircraft. */
if (!IsTileType(v->tile, MP_STATION) || !IsAirport(v->tile) || GetTileMaxZ(v->tile) != 0) return;
const Station *st = GetStationByTile(v->tile);
const Station *st = Station::GetByTile(v->tile);
const AirportFTAClass *airport = st->Airport();
if (v->z_pos != airport->delta_z + 1) return;

View File

@ -346,7 +346,7 @@ protected:
if (IsRailTT() && m_is_station) {
/* entered railway station
* get platform length */
uint length = GetStationByTile(m_new_tile)->GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td));
uint length = Station::GetByTile(m_new_tile)->GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td));
/* how big step we must do to get to the last platform tile; */
m_tiles_skipped = length - 1;
/* move to the platform end */

View File

@ -543,7 +543,7 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Station platform-length penalty. */
if ((end_segment_reason & ESRB_STATION) != ESRB_NONE) {
Station *st = GetStationByTile(n.GetLastTile());
Station *st = Station::GetByTile(n.GetLastTile());
assert(st != NULL);
uint platform_length = st->GetPlatformLength(n.GetLastTile(), ReverseDiagDir(TrackdirToExitdir(n.GetLastTrackdir())));
/* Reduce the extra cost caused by passing-station penalty (each station receives it in the segment cost). */