Functions for access to (shared) infrastructure. More...
#include "vehicle_base.h"
#include "command_type.h"
#include "company_func.h"
#include "tile_cmd.h"
Go to the source code of this file.
Functions | |
void | PayStationSharingFee (Vehicle *v, const Station *st) |
Pay the fee for spending a single tick inside a station. | |
void | PayDailyTrackSharingFee (Train *v) |
Pay the daily fee for trains on foreign tracks. | |
bool | CheckSharingChangePossible (VehicleType type) |
Check if a sharing change is possible. | |
void | HandleSharingCompanyDeletion (Owner owner) |
Handle the removal (through reset_company or bankruptcy) of a company. | |
void | UpdateAllBlockSignals (Owner owner=INVALID_OWNER) |
Update all block signals on the map. | |
static FORCEINLINE bool | IsInfraUsageAllowed (VehicleType type, Owner veh_owner, Owner infra_owner) |
Check whether a vehicle of a given owner and type can use the infrastrucutre of a given company. | |
static FORCEINLINE bool | IsInfraTileUsageAllowed (VehicleType type, Owner veh_owner, TileIndex tile) |
Check whether a vehicle of a given owner and type can use the infrastrucutre on a given tile. | |
static FORCEINLINE CommandCost | CheckInfraUsageAllowed (VehicleType type, Owner infra_owner, TileIndex tile=0) |
Is a vehicle owned by _current_company allowed to use the infrastructure of infra_owner? If this is not allowed, this function provides the appropriate error message. | |
static FORCEINLINE bool | IsVehicleControlAllowed (const Vehicle *v, Owner o) |
Check whether a given company can control this vehicle. | |
static FORCEINLINE CommandCost | CheckVehicleControlAllowed (const Vehicle *v) |
Check whether _current_company can control this vehicle. | |
static FORCEINLINE bool | IsOneSignalBlock (Owner o1, Owner o2) |
Do signal states propagate from the tracks of one owner to the other? |
Functions for access to (shared) infrastructure.
Definition in file infrastructure_func.h.
static FORCEINLINE CommandCost CheckInfraUsageAllowed | ( | VehicleType | type, | |
Owner | infra_owner, | |||
TileIndex | tile = 0 | |||
) | [static] |
Is a vehicle owned by _current_company allowed to use the infrastructure of infra_owner? If this is not allowed, this function provides the appropriate error message.
type | Type of vehicle. | |
infra_owner | Owner of the infrastructure. | |
tile | Tile of the infrastructure. |
Definition at line 61 of file infrastructure_func.h.
References _settings_game, CheckOwnership(), GameSettings::economy, EconomySettings::infrastructure_sharing, and OWNER_NONE.
Referenced by CmdInsertOrder().
bool CheckSharingChangePossible | ( | VehicleType | type | ) |
Check if a sharing change is possible.
If vehicles are still on others' infrastructure or using others' stations, The change is not possible and false is returned.
type | The type of vehicle whose setting will be changed. |
Definition at line 206 of file infrastructure.cpp.
References _settings_game, Vehicle::current_order, GameSettings::economy, Vehicle::FirstShared(), FixAllReservations(), FOR_ALL_VEHICLES, EconomySettings::infrastructure_sharing, INVALID_STRING_ID, INVALID_TILE, INVALID_TRACK, OrderDestinationIsAllowed(), Vehicle::Previous(), ShowErrorMessage(), BaseVehicle::type, VEH_AIRCRAFT, VEH_TRAIN, VehiclePositionIsAllowed(), WL_ERROR, and YapfNotifyTrackLayoutChange().
static FORCEINLINE CommandCost CheckVehicleControlAllowed | ( | const Vehicle * | v | ) | [static] |
Check whether _current_company can control this vehicle.
If this is not allowed, this function provides the appropriate error message.
v | The vehicle which may or may not be controlled. |
Definition at line 86 of file infrastructure_func.h.
References _current_company, CheckOwnership(), IsTileOwner(), Vehicle::owner, Vehicle::tile, BaseVehicle::type, and VEH_TRAIN.
Referenced by CmdForceTrainProceed(), CmdStartStopVehicle(), and CmdTurnRoadVeh().
void HandleSharingCompanyDeletion | ( | Owner | owner | ) |
Handle the removal (through reset_company or bankruptcy) of a company.
i.e. remove all vehicles owned by that company or on its infrastructure, and delete all now-invalid orders.
Owner | the company to be removed. |
Definition at line 256 of file infrastructure.cpp.
References Vehicle::current_order, Vehicle::FirstShared(), FOR_ALL_VEHICLES, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, INVALID_TRACK, INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), IsCompanyBuildableVehicleType(), Order::IsType(), Vehicle::LeaveStation(), Order::MakeDummy(), Vehicle::NextShared(), OrderDestinationIsAllowed(), Vehicle::owner, Vehicle::Previous(), RemoveAndSellVehicle(), SetWindowDirty(), VehiclePositionIsAllowed(), and YapfNotifyTrackLayoutChange().
Referenced by ChangeOwnershipOfCompanyItems().
static FORCEINLINE bool IsInfraTileUsageAllowed | ( | VehicleType | type, | |
Owner | veh_owner, | |||
TileIndex | tile | |||
) | [static] |
Check whether a vehicle of a given owner and type can use the infrastrucutre on a given tile.
type | Type of vehicle we are talking about. | |
veh_owner | Owner of the vehicle in question. | |
tile | The tile that may or may not be used. |
Definition at line 46 of file infrastructure_func.h.
References GetTileOwner(), and IsInfraUsageAllowed().
Referenced by CanEnterTileOwnerCheck(), CmdBuildVehicle(), DepotWindow::OnPaint(), RoadFindPathToDest(), and VehiclePositionIsAllowed().
static FORCEINLINE bool IsInfraUsageAllowed | ( | VehicleType | type, | |
Owner | veh_owner, | |||
Owner | infra_owner | |||
) | [static] |
Check whether a vehicle of a given owner and type can use the infrastrucutre of a given company.
type | Type of vehicle we are talking about. | |
veh_owner | Owner of the vehicle in question. | |
infra_owner | The owner of the infrastructure. |
Definition at line 34 of file infrastructure_func.h.
References _settings_game, GameSettings::economy, EconomySettings::infrastructure_sharing, and OWNER_NONE.
Referenced by CmdBuildAircraft(), CmdBuildRailVehicle(), CmdBuildRoadVehicle(), CmdBuildShip(), CmdDepotMassAutoReplace(), FindNearestHangar(), IsInfraTileUsageAllowed(), OrderDestinationIsAllowed(), and VehiclePositionIsAllowed().
Do signal states propagate from the tracks of one owner to the other?
o1 | First track owner. | |
o2 | Second track owner. |
Definition at line 100 of file infrastructure_func.h.
References _settings_game, GameSettings::economy, and EconomySettings::infrastructure_sharing.
Referenced by AddSideToSignalBuffer(), AddTrackToSignalBuffer(), ExploreSegment(), and UpdateAllBlockSignals().
Check whether a given company can control this vehicle.
Controlling a vehicle means permission to start, stop or reverse it or to make it ignore signals.
v | The vehicle which may or may not be controlled. | |
o | The company which may or may not control this vehicle. |
Definition at line 74 of file infrastructure_func.h.
References IsTileOwner(), Vehicle::owner, Vehicle::tile, BaseVehicle::type, and VEH_TRAIN.
Referenced by VehicleViewWindow::OnPaint().
void PayDailyTrackSharingFee | ( | Train * | v | ) |
Pay the daily fee for trains on foreign tracks.
v | The vehicle to pay the fee for. |
Definition at line 63 of file infrastructure.cpp.
References _settings_game, GroundVehicleCache::cached_weight, GameSettings::economy, GroundVehicle< T, Type >::gcache, GetTileOwner(), Vehicle::owner, PaySharingFee(), Vehicle::running_ticks, EconomySettings::sharing_fee, and Vehicle::tile.
Referenced by Train::OnNewDay().
Pay the fee for spending a single tick inside a station.
v | The vehicle that is using the station. | |
st | The station that it uses. |
Definition at line 52 of file infrastructure.cpp.
References _settings_game, DAY_TICKS, GameSettings::economy, BaseStation::owner, Vehicle::owner, OWNER_NONE, PaySharingFee(), EconomySettings::sharing_fee, BaseVehicle::type, and VEH_TRAIN.
Referenced by Vehicle::HandleLoading().
void UpdateAllBlockSignals | ( | Owner | owner | ) |
Update all block signals on the map.
To be called after the setting for sharing of rails changes.
owner | Owner whose signals to update. If INVALID_OWNER, update everything. |
Definition at line 302 of file infrastructure.cpp.
References AddTrackToSignalBuffer(), GetTileOwner(), GetTrackBits(), HasSignalOnTrack(), HasSignals(), INVALID_OWNER, IsLevelCrossingTile(), IsOneSignalBlock(), IsTileType(), MapSize(), MP_RAILWAY, RemoveFirstTrack(), TRACK_BIT_NONE, UpdateLevelCrossing(), and UpdateSignalsInBuffer().
Referenced by ChangeOwnershipOfCompanyItems().