summaryrefslogtreecommitdiff
path: root/src/rail.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2007-12-08 19:53:30 +0000
committersmatz <smatz@openttd.org>2007-12-08 19:53:30 +0000
commitdfba33819b68aa04c96f60666bf436e6474765dd (patch)
tree94c6bceeae9a2d453ac8cce16bd83009b7e5a776 /src/rail.h
parent58b4a981e1912812df844e4c04ea64d9e5435922 (diff)
downloadopenttd-dfba33819b68aa04c96f60666bf436e6474765dd.tar.xz
(svn r11603) -Fix [FS#1481]: make price for railtype conversion more realistic
Diffstat (limited to 'src/rail.h')
-rw-r--r--src/rail.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rail.h b/src/rail.h
index b24714f9d..8f965aa7b 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -807,6 +807,34 @@ static inline Money RailBuildCost(RailType railtype)
return (_price.build_rail * _railtype_cost_multiplier[railtype]) >> 3;
}
+/**
+ * Calculates the cost of rail conversion
+ * @param from The railtype we are converting from
+ * @param to The railtype we are converting to
+ * @return Cost per TrackBit
+ */
+static inline Money RailConvertCost(RailType from, RailType to)
+{
+ /* rail -> el. rail
+ * calculate the price as 5 / 4 of (cost build el. rail) - (cost build rail)
+ * (the price of workers to get to place is that 1/4)
+ */
+ if (HasPowerOnRail(from, to)) {
+ return ((RailBuildCost(to) - RailBuildCost(from)) * 5) >> 2;
+ }
+
+ /* el. rail -> rail
+ * calculate the price as 1 / 4 of (cost build el. rail) - (cost build rail)
+ * (the price of workers is 1 / 4 + price of copper sold to a recycle center)
+ */
+ if (HasPowerOnRail(to, from)) {
+ return (RailBuildCost(from) - RailBuildCost(to)) >> 2;
+ }
+
+ /* make the price the same as remove + build new type */
+ return RailBuildCost(to) + _price.remove_rail;
+}
+
void *UpdateTrainPowerProc(Vehicle *v, void *data);
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);