summaryrefslogtreecommitdiff
path: root/src/road_func.h
diff options
context:
space:
mode:
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);