# infrastructure_func.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    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 /* INFRASTRUCTURE_FUNC_H */