diff options
author | michi_cc <michi_cc@openttd.org> | 2011-12-03 23:40:46 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-12-03 23:40:46 +0000 |
commit | d3b7b89493e025654d218fb77da095649b4f6ba2 (patch) | |
tree | 6667e4164c5c8bda4c1b7092376872b315c65610 /src/road_func.h | |
parent | f98312eb77e12cfa45de40a1b4e8359160b0d9ff (diff) | |
download | openttd-d3b7b89493e025654d218fb77da095649b4f6ba2.tar.xz |
(svn r23415) -Feature: Infrastructure maintenance costs.
Diffstat (limited to 'src/road_func.h')
-rw-r--r-- | src/road_func.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/road_func.h b/src/road_func.h index 2f286730f..126ab5c82 100644 --- a/src/road_func.h +++ b/src/road_func.h @@ -17,6 +17,7 @@ #include "direction_type.h" #include "company_type.h" #include "tile_type.h" +#include "economy_func.h" /** * Iterate through each set RoadType in a RoadTypes value. @@ -148,6 +149,19 @@ static inline RoadBits AxisToRoadBits(Axis a) return a == AXIS_X ? ROAD_X : ROAD_Y; } + +/** + * Calculates the maintenance cost of a number of road bits. + * @param roadtype Road type to get the cost for. + * @param num Number of road bits. + * @return Total cost. + */ +static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num) +{ + assert(roadtype < ROADTYPE_END); + return (_price[PR_INFRASTRUCTURE_ROAD] * (roadtype == ROADTYPE_TRAM ? 3 : 2) * num * (1 + IntSqrt(num))) >> 9; // 2 bits fraction for the multiplier and 7 bits scaling. +} + bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts); bool ValParamRoadType(const RoadType rt); RoadTypes GetCompanyRoadtypes(const CompanyID company); |