#include "stdafx.h"
#include "infrastructure_func.h"
#include "train.h"
#include "aircraft.h"
#include "vehicle_func.h"
#include "station_base.h"
#include "depot_base.h"
#include "pbs.h"
#include "signal_func.h"
#include "window_func.h"
#include "gui.h"
#include "pathfinder/yapf/yapf_cache.h"
#include "table/strings.h"
Go to the source code of this file.
Functions | |
static void | PaySharingFee (Vehicle *v, Owner infra_owner, Money cost) |
Helper function for transferring sharing fees. | |
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. | |
static bool | VehiclePositionIsAllowed (const Vehicle *v, Owner owner=INVALID_OWNER) |
Check whether a vehicle is in an allowed position. | |
static bool | OrderDestinationIsAllowed (const Order *order, const Vehicle *v, Owner owner=INVALID_OWNER) |
Check whether an order has a destination that is allowed. | |
static void | RemoveAndSellVehicle (Vehicle *v, bool give_money) |
Sell a vehicle, no matter where it may be. | |
static void | FixAllReservations () |
Check all path reservations, and reserve a new path if the current path is invalid. | |
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) |
Update all block signals on the map. |
Definition in file infrastructure.cpp.
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 211 of file infrastructure.cpp.
References FixAllReservations(), GetSharingSetting(), INVALID_STRING_ID, INVALID_TILE, INVALID_TRACK, OrderDestinationIsAllowed(), ShowErrorMessage(), VEH_AIRCRAFT, VEH_TRAIN, VehiclePositionIsAllowed(), and YapfNotifyTrackLayoutChange().
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 261 of file infrastructure.cpp.
References INVALID_TILE, INVALID_TRACK, INVALID_VEH_ORDER_ID, InvalidateVehicleOrder(), OrderDestinationIsAllowed(), RemoveAndSellVehicle(), SetWindowDirty(), VehiclePositionIsAllowed(), and YapfNotifyTrackLayoutChange().
static bool OrderDestinationIsAllowed | ( | const Order * | order, | |
const Vehicle * | v, | |||
Owner | owner = INVALID_OWNER | |||
) | [static] |
Check whether an order has a destination that is allowed.
I.e. it refers to a station/depot/waypoint the vehicle is allowed to visit.
order | The order to check | |
v | The vehicle this order belongs to. | |
owner | Owner whose infrastructure is not allowed, because the company will be removed. Ignored if INVALID_OWNER. |
Definition at line 126 of file infrastructure.cpp.
References SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::Get(), GetTileOwner(), IsInfraUsageAllowed(), BaseStation::owner, and VEH_AIRCRAFT.
Referenced by CheckSharingChangePossible(), and HandleSharingCompanyDeletion().
void PayDailyTrackSharingFee | ( | Train * | v | ) |
Pay the daily fee for trains on foreign tracks.
v | The vehicle to pay the fee for. |
Definition at line 68 of file infrastructure.cpp.
References _settings_game, TrainCache::cached_weight, DAY_TICKS, SharingSettings::fee_rail, GetTileOwner(), PaySharingFee(), GameSettings::sharing, and Train::tcache.
Helper function for transferring sharing fees.
v | The vehicle involved | |
infra_owner | The owner of the infrastructure | |
cost | Amount to transfer as money fraction (shifted 8 bits to the left) |
Definition at line 33 of file infrastructure.cpp.
References _settings_game, min(), SharingSettings::payment_in_debt, and GameSettings::sharing.
Referenced by PayDailyTrackSharingFee(), and PayStationSharingFee().
void PayStationSharingFee | ( | Vehicle * | v, | |
const Station * | st | |||
) |
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 51 of file infrastructure.cpp.
References _settings_game, DAY_TICKS, SharingSettings::fee_air, SharingSettings::fee_road, SharingSettings::fee_water, BaseStation::owner, OWNER_NONE, PaySharingFee(), GameSettings::sharing, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
static void RemoveAndSellVehicle | ( | Vehicle * | v, | |
bool | give_money | |||
) | [static] |
Sell a vehicle, no matter where it may be.
v | The vehicle to sell | |
give_money | Do we actually need to give money to the vehicle owner? |
Definition at line 144 of file infrastructure.cpp.
References _settings_game, DeleteVisibleTrain(), SpecializedVehicle< Train, VEH_TRAIN >::From(), Train::IsFrontEngine(), GameSettings::sharing, SharingSettings::sharing_rail, and VEH_TRAIN.
Referenced by HandleSharingCompanyDeletion().
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 307 of file infrastructure.cpp.
References AddTrackToSignalBuffer(), GetTileOwner(), GetTrackBits(), HasSignalOnTrack(), HasSignals(), INVALID_OWNER, IsOneSignalBlock(), IsTileType(), MapSize(), MP_RAILWAY, RemoveFirstTrack(), TRACK_BIT_NONE, UpdateLevelCrossing(), and UpdateSignalsInBuffer().
static bool VehiclePositionIsAllowed | ( | const Vehicle * | v, | |
Owner | owner = INVALID_OWNER | |||
) | [static] |
Check whether a vehicle is in an allowed position.
v | The vehicle to check. | |
owner | Owner whose infrastructure is not allowed, because the company will be removed. Ignored if INVALID_OWNER. |
Definition at line 86 of file infrastructure.cpp.
References SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedStation< Station, false >::Get(), GetTileOwner(), IsInfraUsageAllowed(), IsStandardRoadStopTile(), SpecializedStation< Station, false >::IsValidID(), BaseStation::owner, Aircraft::state, Aircraft::targetairport, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by CheckSharingChangePossible(), and HandleSharingCompanyDeletion().