summaryrefslogtreecommitdiff
path: root/src/ship_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/ship_cmd.cpp
parent80ee3d3440233b50bbe818b2f74f6aac8841edfa (diff)
downloadopenttd-c1cf3934fa5bd523dd1df01cf505c9f06927701d.tar.xz
(svn r15263) -Codechange: added Engine::GetCost() to remove some code duplication.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 45361fc96..37d2ef78e 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -341,11 +341,6 @@ static bool ShipAccelerate(Vehicle *v)
return (t < v->progress);
}
-static CommandCost EstimateShipCost(EngineID engine_type)
-{
- return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->cost_factor) * (_price.ship_base >> 3) >> 5);
-}
-
static void ShipArrivesAt(const Vehicle *v, Station *st)
{
/* Check if station was ever visited before */
@@ -746,13 +741,13 @@ void Ship::Tick()
*/
CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{
- CommandCost value;
UnitID unit_num;
- Engine *e;
if (!IsEngineBuildable(p1, VEH_SHIP, _current_company)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
- value = EstimateShipCost(p1);
+ const Engine *e = GetEngine(p1);
+ CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
+
if (flags & DC_QUERY_COST) return value;
/* The ai_new queries the vehicle cost before building the route,
@@ -797,7 +792,6 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, con
v->max_speed = svi->max_speed;
v->engine_type = 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;