summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-07-01 14:05:44 +0000
committertron <tron@openttd.org>2005-07-01 14:05:44 +0000
commitb64c9b8b1f7de8609c25c367d3ad90a86b0b5c95 (patch)
treee0c185ad1ca2dc285b30b8887758db92c451d5cd
parentcd8d2643d3d21add68816bcf2d25391f4faee4f4 (diff)
downloadopenttd-b64c9b8b1f7de8609c25c367d3ad90a86b0b5c95.tar.xz
(svn r2504) Move Draw*EngineInfo to engine_gui.c to reduce dependencies
-rw-r--r--aircraft_cmd.c13
-rw-r--r--engine.h5
-rw-r--r--engine_gui.c64
-rw-r--r--roadveh_cmd.c15
-rw-r--r--ship_cmd.c12
-rw-r--r--train_cmd.c23
6 files changed, 64 insertions, 68 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 7d15fa9f5..131d00250 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -10,7 +10,6 @@
#include "command.h"
#include "station.h"
#include "news.h"
-#include "gfx.h"
#include "sound.h"
#include "player.h"
#include "airport.h"
@@ -118,18 +117,6 @@ void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod)
}
}
-void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
-{
- const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
- SetDParam(0, ((_price.aircraft_base >> 3) * avi->base_cost) >> 5);
- SetDParam(1, avi->max_speed << 3);
- SetDParam(2, avi->passenger_capacity);
- SetDParam(3, avi->mail_capacity);
- SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
-
- DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
-}
-
/* Allocate many vehicles */
static bool AllocateVehicles(Vehicle **vl, int num)
{
diff --git a/engine.h b/engine.h
index b87ff7d7b..616f5344d 100644
--- a/engine.h
+++ b/engine.h
@@ -194,11 +194,6 @@ void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod);
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod);
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod);
-void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
-void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
-void DrawShipEngineInfo(int engine, int x, int y, int maxw);
-void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
-
void AcceptEnginePreview(Engine *e, PlayerID player);
void LoadCustomEngineNames(void);
diff --git a/engine_gui.c b/engine_gui.c
index 791d0f046..f5817e4f0 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -49,6 +49,11 @@ typedef struct DrawEngineInfo {
DrawEngineInfoProc *info_proc;
} DrawEngineInfo;
+static void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
+static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
+static void DrawShipEngineInfo(int engine, int x, int y, int maxw);
+static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
+
static const DrawEngineInfo _draw_engine_list[4] = {
{DrawTrainEngine,DrawTrainEngineInfo},
{DrawRoadVehEngine,DrawRoadVehEngineInfo},
@@ -113,6 +118,28 @@ void ShowEnginePreviewWindow(int engine)
w->window_number = engine;
}
+static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
+{
+ const RailVehicleInfo *rvi = RailVehInfo(engine);
+ int cap;
+ uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
+
+ SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5);
+ SetDParam(2, rvi->max_speed * 10 >> 4);
+ SetDParam(3, rvi->power << multihead);
+ SetDParam(1, rvi->weight << multihead);
+
+ SetDParam(4, rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8 << multihead);
+
+ cap = rvi->capacity;
+ SetDParam(5, STR_8838_N_A);
+ if (cap != 0) {
+ SetDParam(6, cap << multihead);
+ SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
+ }
+ DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
+}
+
void DrawNewsNewTrainAvail(Window *w)
{
int engine;
@@ -142,6 +169,18 @@ StringID GetNewsStringNewTrainAvail(NewsItem *ni)
return STR_02B6;
}
+static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
+{
+ const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
+ SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5);
+ SetDParam(1, avi->max_speed << 3);
+ SetDParam(2, avi->passenger_capacity);
+ SetDParam(3, avi->mail_capacity);
+ SetDParam(4, avi->running_cost * _price.aircraft_running >> 8);
+
+ DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
+}
+
void DrawNewsNewAircraftAvail(Window *w)
{
int engine;
@@ -169,6 +208,20 @@ StringID GetNewsStringNewAircraftAvail(NewsItem *ni)
return STR_02B6;
}
+static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
+{
+ const RoadVehicleInfo *rvi = RoadVehInfo(engine);
+
+ SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5);
+ SetDParam(1, rvi->max_speed * 10 >> 5);
+ SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
+
+ SetDParam(4, rvi->capacity);
+ SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]);
+
+ DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
+}
+
void DrawNewsNewRoadVehAvail(Window *w)
{
int engine;
@@ -195,6 +248,17 @@ StringID GetNewsStringNewRoadVehAvail(NewsItem *ni)
return STR_02B6;
}
+static void DrawShipEngineInfo(int engine, int x, int y, int maxw)
+{
+ const ShipVehicleInfo *svi = ShipVehInfo(engine);
+ SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
+ SetDParam(1, svi->max_speed * 10 >> 5);
+ SetDParam(2, _cargoc.names_long_p[svi->cargo_type]);
+ SetDParam(3, svi->capacity);
+ SetDParam(4, svi->running_cost * _price.ship_running >> 8);
+ DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
+}
+
void DrawNewsNewShipAvail(Window *w)
{
int engine;
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index f8854ead1..f28002cd2 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -9,7 +9,6 @@
#include "command.h"
#include "station.h"
#include "news.h"
-#include "gfx.h"
#include "pathfind.h"
#include "npf.h"
#include "player.h"
@@ -91,20 +90,6 @@ void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod)
DrawSprite((6 + _roadveh_images[spritenum]) | image_ormod, x, y);
}
-void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
-{
- const RoadVehicleInfo *rvi = RoadVehInfo(engine);
-
- SetDParam(0, ((_price.roadveh_base >> 3) * rvi->base_cost) >> 5);
- SetDParam(1, rvi->max_speed * 10 >> 5);
- SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8);
-
- SetDParam(4, rvi->capacity);
- SetDParam(3, _cargoc.names_long_p[rvi->cargo_type]);
-
- DrawStringMultiCenter(x, y, STR_902A_COST_SPEED_RUNNING_COST, maxw);
-}
-
int32 EstimateRoadVehCost(EngineID engine_type)
{
return ((_price.roadveh_base >> 3) * RoadVehInfo(engine_type)->base_cost) >> 5;
diff --git a/ship_cmd.c b/ship_cmd.c
index 5db2b2b63..fe53aa8a8 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -7,7 +7,6 @@
#include "command.h"
#include "pathfind.h"
#include "station.h"
-#include "gfx.h"
#include "news.h"
#include "engine.h"
#include "gui.h"
@@ -41,17 +40,6 @@ void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y);
}
-void DrawShipEngineInfo(int engine, int x, int y, int maxw)
-{
- const ShipVehicleInfo *svi = ShipVehInfo(engine);
- SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
- SetDParam(1, svi->max_speed * 10 >> 5);
- SetDParam(2, _cargoc.names_long_p[svi->cargo_type]);
- SetDParam(3, svi->capacity);
- SetDParam(4, svi->running_cost * _price.ship_running >> 8);
- DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
-}
-
int GetShipImage(const Vehicle *v, byte direction)
{
int spritenum = v->spritenum;
diff --git a/train_cmd.c b/train_cmd.c
index b40d70c23..3806e0f16 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -10,7 +10,6 @@
#include "npf.h"
#include "station.h"
#include "table/train_cmd.h"
-#include "gfx.h"
#include "news.h"
#include "engine.h"
#include "player.h"
@@ -392,28 +391,6 @@ void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod)
DrawSprite(image | image_ormod, x, y);
}
-void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
-{
- const RailVehicleInfo *rvi = RailVehInfo(engine);
- int cap;
- uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
-
- SetDParam(0, ((_price.build_railvehicle >> 3) * rvi->base_cost) >> 5);
- SetDParam(2, rvi->max_speed * 10 >> 4);
- SetDParam(3, rvi->power << multihead);
- SetDParam(1, rvi->weight << multihead);
-
- SetDParam(4, (rvi->running_cost_base * _price.running_rail[rvi->engclass] >> 8) << multihead);
-
- cap = rvi->capacity;
- SetDParam(5, STR_8838_N_A);
- if (cap != 0) {
- SetDParam(6, cap << multihead);
- SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
- }
- DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
-}
-
static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
{