(svn r23415) -Feature: Infrastructure maintenance costs.

This commit is contained in:
michi_cc
2011-12-03 23:40:46 +00:00
parent bf5ef7537e
commit fc8633e1ac
21 changed files with 300 additions and 32 deletions

View File

@@ -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);