summaryrefslogtreecommitdiff
path: root/src/road_func.h
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-12-03 23:40:46 +0000
committermichi_cc <michi_cc@openttd.org>2011-12-03 23:40:46 +0000
commitd3b7b89493e025654d218fb77da095649b4f6ba2 (patch)
tree6667e4164c5c8bda4c1b7092376872b315c65610 /src/road_func.h
parentf98312eb77e12cfa45de40a1b4e8359160b0d9ff (diff)
downloadopenttd-d3b7b89493e025654d218fb77da095649b4f6ba2.tar.xz
(svn r23415) -Feature: Infrastructure maintenance costs.
Diffstat (limited to 'src/road_func.h')
-rw-r--r--src/road_func.h14
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);