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 "functions.h"
00017 #include "company_func.h"
00018 
00019 void PayStationSharingFee(Vehicle *v, const Station *st);
00020 void PayDailyTrackSharingFee(Train *v);
00021 bool CheckSharingChangePossible(VehicleType type);
00022 void HandleSharingCompanyDeletion(Owner owner);
00023 void UpdateAllBlockSignals(Owner owner = INVALID_OWNER);
00024 
00030 static FORCEINLINE bool GetSharingSetting(VehicleType type)
00031 {
00032   switch (type) {
00033     case VEH_TRAIN:    return _settings_game.sharing.sharing_rail;
00034     case VEH_ROAD:     return _settings_game.sharing.sharing_road;
00035     case VEH_SHIP:     return _settings_game.sharing.sharing_water;
00036     case VEH_AIRCRAFT: return _settings_game.sharing.sharing_air;
00037     default: NOT_REACHED();
00038   }
00039 }
00040 
00048 static FORCEINLINE bool IsInfraUsageAllowed(Owner infra_owner, Owner veh_owner, VehicleType type)
00049 {
00050   return infra_owner == veh_owner || infra_owner == OWNER_NONE || GetSharingSetting(type);
00051 }
00052 
00060 static FORCEINLINE bool IsInfraTileUsageAllowed(TileIndex tile, Owner veh_owner, VehicleType type)
00061 {
00062   return IsInfraUsageAllowed(GetTileOwner(tile), veh_owner, type);
00063 }
00064 
00073 static FORCEINLINE bool CheckInfraUsageAllowed(Owner infra_owner, VehicleType type)
00074 {
00075   return infra_owner == OWNER_NONE || GetSharingSetting(type) || CheckOwnership(infra_owner);
00076 }
00077 
00085 static FORCEINLINE bool IsVehicleControlAllowed(const Vehicle *v, Owner o)
00086 {
00087   return v->owner == o || (v->type == VEH_TRAIN && IsTileOwner(v->tile, o));
00088 }
00089 
00097 static FORCEINLINE bool CheckVehicleControlAllowed(const Vehicle *v)
00098 {
00099   return (v->type == VEH_TRAIN && IsTileOwner(v->tile, _current_company)) || CheckOwnership(v->owner);
00100 }
00101 
00110 static FORCEINLINE bool IsOneSignalBlock(Owner o1, Owner o2)
00111 {
00112   return o1 == o2 || _settings_game.sharing.sharing_rail;
00113 }
00114 
00115 #endif /* INFRASTRUCTURE_FUNC_H */

Generated on Sat Dec 26 20:06:01 2009 for OpenTTD by  doxygen 1.5.6