Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef INFRASTRUCTURE_FUNC_H
00013 #define INFRASTRUCTURE_FUNC_H
00014
00015 #include "vehicle_base.h"
00016 #include "command_type.h"
00017 #include "company_func.h"
00018 #include "tile_cmd.h"
00019
00020 void PayStationSharingFee(Vehicle *v, const Station *st);
00021 void PayDailyTrackSharingFee(Train *v);
00022
00023 bool CheckSharingChangePossible(VehicleType type);
00024 void HandleSharingCompanyDeletion(Owner owner);
00025 void UpdateAllBlockSignals(Owner owner = INVALID_OWNER);
00026
00034 static FORCEINLINE bool IsInfraUsageAllowed(VehicleType type, Owner veh_owner, Owner infra_owner)
00035 {
00036 return infra_owner == veh_owner || infra_owner == OWNER_NONE || _settings_game.economy.infrastructure_sharing[type];
00037 }
00038
00046 static FORCEINLINE bool IsInfraTileUsageAllowed(VehicleType type, Owner veh_owner, TileIndex tile)
00047 {
00048 return IsInfraUsageAllowed(type, veh_owner, GetTileOwner(tile));
00049 }
00050
00061 static FORCEINLINE CommandCost CheckInfraUsageAllowed(VehicleType type, Owner infra_owner, TileIndex tile = 0)
00062 {
00063 if (infra_owner == OWNER_NONE || _settings_game.economy.infrastructure_sharing[type]) return CommandCost();
00064 return CheckOwnership(infra_owner, tile);
00065 }
00066
00074 static FORCEINLINE bool IsVehicleControlAllowed(const Vehicle *v, Owner o)
00075 {
00076 return v->owner == o || (v->type == VEH_TRAIN && IsTileOwner(v->tile, o));
00077 }
00078
00086 static FORCEINLINE CommandCost CheckVehicleControlAllowed(const Vehicle *v)
00087 {
00088 if (v->type == VEH_TRAIN && IsTileOwner(v->tile, _current_company)) return CommandCost();
00089 return CheckOwnership(v->owner);
00090 }
00091
00100 static FORCEINLINE bool IsOneSignalBlock(Owner o1, Owner o2)
00101 {
00102 return o1 == o2 || _settings_game.economy.infrastructure_sharing[VEH_TRAIN];
00103 }
00104
00105 #endif