mirror of https://github.com/OpenTTD/OpenTTD
(svn r16863) -Codechange: GetWaypointByTile -> Waypoint::GetByTile, like used for e.g. stations
parent
c9cab7ba19
commit
d8f16ea199
|
@ -352,7 +352,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
if (IsRailWaypointTile(tile) &&
|
if (IsRailWaypointTile(tile) &&
|
||||||
v->type == VEH_TRAIN &&
|
v->type == VEH_TRAIN &&
|
||||||
IsTileOwner(tile, _local_company)) {
|
IsTileOwner(tile, _local_company)) {
|
||||||
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
|
order.MakeGoToWaypoint(Waypoint::GetByTile(tile)->index);
|
||||||
if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
|
if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1938,7 +1938,7 @@ static void DrawTile_Track(TileInfo *ti)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* look for customization */
|
/* look for customization */
|
||||||
const Waypoint *wp = GetWaypointByTile(ti->tile);
|
const Waypoint *wp = Waypoint::GetByTile(ti->tile);
|
||||||
|
|
||||||
if (wp->num_specs != 0) {
|
if (wp->num_specs != 0) {
|
||||||
const StationSpec *statspec = wp->speclist->spec;
|
const StationSpec *statspec = wp->speclist->spec;
|
||||||
|
@ -2315,8 +2315,8 @@ static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode,
|
||||||
static bool ClickTile_Track(TileIndex tile)
|
static bool ClickTile_Track(TileIndex tile)
|
||||||
{
|
{
|
||||||
switch (GetRailTileType(tile)) {
|
switch (GetRailTileType(tile)) {
|
||||||
case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); return true;
|
case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); return true;
|
||||||
case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); return true;
|
case RAIL_TILE_WAYPOINT: ShowWaypointWindow(Waypoint::GetByTile(tile)); return true;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void WaypointsDailyLoop()
|
||||||
*/
|
*/
|
||||||
Station *ComposeWaypointStation(TileIndex tile)
|
Station *ComposeWaypointStation(TileIndex tile)
|
||||||
{
|
{
|
||||||
Waypoint *wp = GetWaypointByTile(tile);
|
Waypoint *wp = Waypoint::GetByTile(tile);
|
||||||
|
|
||||||
/* instead of 'static Station stat' use byte array to avoid Station's destructor call upon exit. As
|
/* instead of 'static Station stat' use byte array to avoid Station's destructor call upon exit. As
|
||||||
* a side effect, the station is not constructed now. */
|
* a side effect, the station is not constructed now. */
|
||||||
|
|
|
@ -39,23 +39,21 @@ struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
|
||||||
void UpdateVirtCoord();
|
void UpdateVirtCoord();
|
||||||
|
|
||||||
void AssignStationSpec(uint index);
|
void AssignStationSpec(uint index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch a waypoint by tile
|
||||||
|
* @param tile Tile of waypoint
|
||||||
|
* @return Waypoint
|
||||||
|
*/
|
||||||
|
static FORCEINLINE Waypoint *GetByTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
return Waypoint::Get(GetWaypointIndex(tile));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
|
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
|
||||||
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_WAYPOINTS_FROM(var, 0)
|
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_WAYPOINTS_FROM(var, 0)
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch a waypoint by tile
|
|
||||||
* @param tile Tile of waypoint
|
|
||||||
* @return Waypoint
|
|
||||||
*/
|
|
||||||
static inline Waypoint *GetWaypointByTile(TileIndex tile)
|
|
||||||
{
|
|
||||||
assert(IsRailWaypointTile(tile));
|
|
||||||
return Waypoint::Get(GetWaypointIndex(tile));
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
|
CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
|
||||||
Station *ComposeWaypointStation(TileIndex tile);
|
Station *ComposeWaypointStation(TileIndex tile);
|
||||||
void ShowWaypointWindow(const Waypoint *wp);
|
void ShowWaypointWindow(const Waypoint *wp);
|
||||||
|
|
|
@ -224,7 +224,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justre
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Track track = GetRailWaypointTrack(tile);
|
Track track = GetRailWaypointTrack(tile);
|
||||||
wp = GetWaypointByTile(tile);
|
wp = Waypoint::GetByTile(tile);
|
||||||
|
|
||||||
wp->delete_ctr = 30; // let it live for this many days before we do the actual deletion.
|
wp->delete_ctr = 30; // let it live for this many days before we do the actual deletion.
|
||||||
wp->sign.MarkDirty();
|
wp->sign.MarkDirty();
|
||||||
|
|
Loading…
Reference in New Issue