summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2009-01-25 00:57:03 +0000
committerglx <glx@openttd.org>2009-01-25 00:57:03 +0000
commitc1cf3934fa5bd523dd1df01cf505c9f06927701d (patch)
treea8b3e55a2f1168021a45917b6fbf5777c3476634 /src/roadveh_cmd.cpp
parent80ee3d3440233b50bbe818b2f74f6aac8841edfa (diff)
downloadopenttd-c1cf3934fa5bd523dd1df01cf505c9f06927701d.tar.xz
(svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 914f8e2d8..7e587b5be 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -134,11 +134,6 @@ void DrawRoadVehEngine(int x, int y, EngineID engine, SpriteID pal)
DrawSprite(GetRoadVehIcon(engine), pal, x, y);
}
-static CommandCost EstimateRoadVehCost(EngineID engine_type)
-{
- return CommandCost(EXPENSES_NEW_VEHICLES, ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->cost_factor)) >> 5);
-}
-
byte GetRoadVehLength(const Vehicle *v)
{
byte length = 8;
@@ -176,14 +171,13 @@ void RoadVehUpdateCache(Vehicle *v)
*/
CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{
- CommandCost cost;
Vehicle *v;
UnitID unit_num;
- Engine *e;
if (!IsEngineBuildable(p1, VEH_ROAD, _current_company)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
- cost = EstimateRoadVehCost(p1);
+ const Engine *e = GetEngine(p1);
+ CommandCost cost(EXPENSES_NEW_VEHICLES, e->GetCost());
if (flags & DC_QUERY_COST) return cost;
/* The ai_new queries the vehicle cost before building the route,
@@ -251,7 +245,6 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2,
v->max_speed = rvi->max_speed;
v->engine_type = (EngineID)p1;
- e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * DAYS_IN_LEAP_YEAR;