summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-10-01 12:43:34 +0000
committertron <tron@openttd.org>2005-10-01 12:43:34 +0000
commit0ad3902acfe4a10d1ef31e43765cbcd7cf82eb1e (patch)
tree6eb5ead43a3cbbdd3042baf3269401e60838aebd
parent42db6338505959e6f1d59986615944cc1fb0ca86 (diff)
downloadopenttd-0ad3902acfe4a10d1ef31e43765cbcd7cf82eb1e.tar.xz
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
-rw-r--r--aircraft_cmd.c4
-rw-r--r--aircraft_gui.c2
-rw-r--r--engine.c30
-rw-r--r--engine.h36
-rw-r--r--engine_gui.c55
-rw-r--r--roadveh_cmd.c2
-rw-r--r--roadveh_gui.c2
-rw-r--r--ship_cmd.c4
-rw-r--r--ship_gui.c2
-rw-r--r--train_cmd.c14
-rw-r--r--train_gui.c4
-rw-r--r--vehicle_gui.c10
12 files changed, 82 insertions, 83 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 55568c474..948d27742 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -102,7 +102,7 @@ int GetAircraftImage(const Vehicle *v, byte direction)
return direction + _aircraft_sprite[spritenum];
}
-void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod)
+void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod)
{
int spritenum = AircraftVehInfo(engine)->image_index;
int sprite = (6 + _aircraft_sprite[spritenum]);
@@ -237,7 +237,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->max_speed = avi->max_speed;
v->acceleration = avi->acceleration;
- v->engine_type = (byte)p1;
+ v->engine_type = p1;
v->subtype = (avi->subtype & 1) == 0 ? 0 : 2;
v->value = value;
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 234a94ff5..b01b52129 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -128,7 +128,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos;
- int engine_id = AIRCRAFT_ENGINES_INDEX;
+ EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
int selected_id = -1;
do {
diff --git a/engine.c b/engine.c
index 306d6af99..3871330cc 100644
--- a/engine.c
+++ b/engine.c
@@ -93,7 +93,7 @@ const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = {
};
#undef MC
-void ShowEnginePreviewWindow(int engine);
+void ShowEnginePreviewWindow(EngineID engine);
void DeleteCustomEngineNames(void)
{
@@ -250,7 +250,7 @@ typedef struct WagonOverrides {
static WagonOverrides _engine_wagon_overrides[TOTAL_NUM_ENGINES];
-void SetWagonOverrideSprites(byte engine, SpriteGroup *group, byte *train_id,
+void SetWagonOverrideSprites(EngineID engine, SpriteGroup *group, byte *train_id,
int trains)
{
WagonOverrides *wos;
@@ -271,7 +271,7 @@ void SetWagonOverrideSprites(byte engine, SpriteGroup *group, byte *train_id,
memcpy(wo->train_id, train_id, trains);
}
-static const SpriteGroup *GetWagonOverrideSpriteSet(byte engine, byte overriding_engine)
+static const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, byte overriding_engine)
{
const WagonOverrides *wos = &_engine_wagon_overrides[engine];
int i;
@@ -300,7 +300,7 @@ static const SpriteGroup *GetWagonOverrideSpriteSet(byte engine, byte overriding
// memory. --pasky)
static SpriteGroup _engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID];
-void SetCustomEngineSprites(byte engine, byte cargo, SpriteGroup *group)
+void SetCustomEngineSprites(EngineID engine, byte cargo, SpriteGroup *group)
{
/* FIXME: If we are replacing an override, release original SpriteGroup
* to prevent leaks. But first we need to refcount the SpriteGroup.
@@ -494,7 +494,7 @@ static const SpriteGroup* ResolveVehicleSpriteGroup(const SpriteGroup *spritegro
}
}
-static const SpriteGroup *GetVehicleSpriteGroup(byte engine, const Vehicle *v)
+static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *v)
{
const SpriteGroup *group;
byte cargo = GC_PURCHASE;
@@ -515,7 +515,7 @@ static const SpriteGroup *GetVehicleSpriteGroup(byte engine, const Vehicle *v)
return group;
}
-int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction)
+int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction)
{
const SpriteGroup *group;
const RealSpriteGroup *rsg;
@@ -597,7 +597,7 @@ bool UsesWagonOverride(const Vehicle *v) {
* @param vehicle The vehicle to evaluate the callback for, NULL if it doesnt exist (yet)
* @return The value the callback returned, or CALLBACK_FAILED if it failed
*/
-uint16 GetCallBackResult(uint16 callback_info, byte engine, const Vehicle *v)
+uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v)
{
const SpriteGroup *group;
byte cargo = GC_DEFAULT;
@@ -716,7 +716,7 @@ void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger)
static char *_engine_custom_names[TOTAL_NUM_ENGINES];
-void SetCustomEngineName(int engine, const char *name)
+void SetCustomEngineName(EngineID engine, const char *name)
{
_engine_custom_names[engine] = strdup(name);
}
@@ -730,7 +730,7 @@ void UnInitNewgrEngines(void)
}
}
-StringID GetCustomEngineName(int engine)
+StringID GetCustomEngineName(EngineID engine)
{
if (!_engine_custom_names[engine])
return _engine_name_strings[engine];
@@ -780,7 +780,7 @@ static PlayerID GetBestPlayer(PlayerID pp)
void EnginesDailyLoop(void)
{
- uint i;
+ EngineID i;
if (_cur_year >= 130) return;
@@ -837,7 +837,7 @@ int32 CmdWantEnginePreview(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
// Determine if an engine type is a wagon (and not a loco)
-static bool IsWagon(byte index)
+static bool IsWagon(EngineID index)
{
return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->flags & RVI_WAGON;
}
@@ -846,7 +846,7 @@ static void NewVehicleAvailable(Engine *e)
{
Vehicle *v;
Player *p;
- int index = e - _engines;
+ EngineID index = e - _engines;
// In case the player didn't build the vehicle during the intro period,
// prevent that player from getting future intro periods for a while.
@@ -892,11 +892,11 @@ static void NewVehicleAvailable(Engine *e)
}
}
- if ((byte)index < NUM_TRAIN_ENGINES) {
+ if (index < NUM_TRAIN_ENGINES) {
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_TRAINAVAIL), 0, 0);
- } else if ((byte)index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) {
+ } else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) {
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_ROADAVAIL), 0, 0);
- } else if ((byte)index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) {
+ } else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) {
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_SHIPAVAIL), 0, 0);
} else {
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_AIRCRAFTAVAIL), 0, 0);
diff --git a/engine.h b/engine.h
index d672d82d4..f8bdbe0ee 100644
--- a/engine.h
+++ b/engine.h
@@ -172,11 +172,11 @@ VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE];
VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID];
VARDEF uint32 _engine_refit_masks[256];
-void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group, byte *train_id, int trains);
-void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group);
+void SetWagonOverrideSprites(EngineID engine, struct SpriteGroup *group, byte *train_id, int trains);
+void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group);
// loaded is in percents, overriding_engine 0xffff is none
-int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction);
-uint16 GetCallBackResult(uint16 callback_info, byte engine, const Vehicle *v);
+int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction);
+uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v);
bool UsesWagonOverride(const Vehicle *v);
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
@@ -192,14 +192,14 @@ typedef enum VehicleTrigger {
} VehicleTrigger;
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
-void SetCustomEngineName(int engine, const char *name);
-StringID GetCustomEngineName(int engine);
+void SetCustomEngineName(EngineID engine, const char *name);
+StringID GetCustomEngineName(EngineID engine);
-void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod);
-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 DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod);
+void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod);
+void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod);
+void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod);
void AcceptEnginePreview(Engine *e, PlayerID player);
@@ -225,7 +225,7 @@ enum {
VARDEF Engine _engines[TOTAL_NUM_ENGINES];
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
-static inline Engine* GetEngine(uint i)
+static inline Engine* GetEngine(EngineID i)
{
assert(i < lengthof(_engines));
return &_engines[i];
@@ -252,27 +252,27 @@ ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES];
-static inline const RailVehicleInfo *RailVehInfo(uint e)
+static inline const RailVehicleInfo* RailVehInfo(EngineID e)
{
assert(e < lengthof(_rail_vehicle_info));
return &_rail_vehicle_info[e];
}
-static inline const ShipVehicleInfo *ShipVehInfo(uint e)
+static inline const ShipVehicleInfo* ShipVehInfo(EngineID e)
{
- assert(e - SHIP_ENGINES_INDEX < lengthof(_ship_vehicle_info));
+ assert(e >= SHIP_ENGINES_INDEX && e < SHIP_ENGINES_INDEX + lengthof(_ship_vehicle_info));
return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX];
}
-static inline const AircraftVehicleInfo *AircraftVehInfo(uint e)
+static inline const AircraftVehicleInfo* AircraftVehInfo(EngineID e)
{
- assert(e - AIRCRAFT_ENGINES_INDEX < lengthof(_aircraft_vehicle_info));
+ assert(e >= AIRCRAFT_ENGINES_INDEX && e < AIRCRAFT_ENGINES_INDEX + lengthof(_aircraft_vehicle_info));
return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX];
}
-static inline const RoadVehicleInfo *RoadVehInfo(uint e)
+static inline const RoadVehicleInfo* RoadVehInfo(EngineID e)
{
- assert(e - ROAD_ENGINES_INDEX < lengthof(_road_vehicle_info));
+ assert(e >= ROAD_ENGINES_INDEX && e < ROAD_ENGINES_INDEX + lengthof(_road_vehicle_info));
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
}
diff --git a/engine_gui.c b/engine_gui.c
index 0c89c81c5..606b5909e 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -15,7 +15,7 @@
#include "variables.h"
-static StringID GetEngineCategoryName(byte engine)
+static StringID GetEngineCategoryName(EngineID engine)
{
if (engine < NUM_TRAIN_ENGINES) {
switch (GetEngine(engine)->railtype) {
@@ -46,18 +46,18 @@ static const Widget _engine_preview_widgets[] = {
{ WIDGETS_END},
};
-typedef void DrawEngineProc(int x, int y, int engine, uint32 image_ormod);
-typedef void DrawEngineInfoProc(int x, int y, int engine, int maxw);
+typedef void DrawEngineProc(int x, int y, EngineID engine, uint32 image_ormod);
+typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw);
typedef struct DrawEngineInfo {
DrawEngineProc *engine_proc;
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 void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw);
+static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw);
+static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw);
+static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw);
static const DrawEngineInfo _draw_engine_list[4] = {
{DrawTrainEngine,DrawTrainEngineInfo},
@@ -68,31 +68,30 @@ static const DrawEngineInfo _draw_engine_list[4] = {
static void EnginePreviewWndProc(Window *w, WindowEvent *e)
{
- byte eng;
- int engine;
const DrawEngineInfo *dei;
int width;
switch(e->event) {
- case WE_PAINT:
+ case WE_PAINT: {
+ EngineID engine = w->window_number;
+
DrawWindowWidgets(w);
- engine = w->window_number;
SetDParam(0, GetEngineCategoryName(engine));
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10);
- eng = (byte)engine;
- (dei = _draw_engine_list,eng < NUM_TRAIN_ENGINES) ||
- (dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
- (dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
+ (dei = _draw_engine_list,engine < NUM_TRAIN_ENGINES) ||
+ (dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
+ (dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
(dei++, true);
width = w->width;
dei->engine_proc(width >> 1, 100, engine, 0);
dei->info_proc(engine, width >> 1, 130, width - 52);
break;
+ }
case WE_CLICK:
switch(e->click.widget) {
@@ -115,7 +114,7 @@ static const WindowDesc _engine_preview_desc = {
};
-void ShowEnginePreviewWindow(int engine)
+void ShowEnginePreviewWindow(EngineID engine)
{
Window *w;
@@ -123,7 +122,7 @@ void ShowEnginePreviewWindow(int engine)
w->window_number = engine;
}
-static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
+static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
{
const RailVehicleInfo *rvi = RailVehInfo(engine);
int cap;
@@ -147,7 +146,7 @@ static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewTrainAvail(Window *w)
{
- int engine;
+ EngineID engine;
DrawNewsBorder(w);
@@ -167,14 +166,14 @@ void DrawNewsNewTrainAvail(Window *w)
StringID GetNewsStringNewTrainAvail(const NewsItem *ni)
{
- int engine = ni->string_id;
+ EngineID engine = ni->string_id;
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE);
SetDParam(1, GetEngineCategoryName(engine));
SetDParam(2, GetCustomEngineName(engine));
return STR_02B6;
}
-static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
+static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
{
const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5);
@@ -188,7 +187,7 @@ static void DrawAircraftEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewAircraftAvail(Window *w)
{
- int engine;
+ EngineID engine;
DrawNewsBorder(w);
@@ -207,13 +206,13 @@ void DrawNewsNewAircraftAvail(Window *w)
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni)
{
- int engine = ni->string_id;
+ EngineID engine = ni->string_id;
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
}
-static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
+static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)
{
const RoadVehicleInfo *rvi = RoadVehInfo(engine);
@@ -229,7 +228,7 @@ static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewRoadVehAvail(Window *w)
{
- int engine;
+ EngineID engine;
DrawNewsBorder(w);
@@ -247,13 +246,13 @@ void DrawNewsNewRoadVehAvail(Window *w)
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni)
{
- int engine = ni->string_id;
+ EngineID engine = ni->string_id;
SetDParam(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
}
-static void DrawShipEngineInfo(int engine, int x, int y, int maxw)
+static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
{
const ShipVehicleInfo *svi = ShipVehInfo(engine);
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5);
@@ -266,7 +265,7 @@ static void DrawShipEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewShipAvail(Window *w)
{
- int engine;
+ EngineID engine;
DrawNewsBorder(w);
@@ -285,7 +284,7 @@ void DrawNewsNewShipAvail(Window *w)
StringID GetNewsStringNewShipAvail(const NewsItem *ni)
{
- int engine = ni->string_id;
+ EngineID engine = ni->string_id;
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine));
return STR_02B6;
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index db1a7778b..382f1d8da 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -77,7 +77,7 @@ int GetRoadVehImage(const Vehicle *v, byte direction)
return image;
}
-void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod)
+void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod)
{
int spritenum = RoadVehInfo(engine)->image_index;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index e107dc2d4..8d82a2949 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -411,7 +411,7 @@ static void DrawNewRoadVehWindow(Window *w)
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos;
- int engine_id = ROAD_ENGINES_INDEX;
+ EngineID engine_id = ROAD_ENGINES_INDEX;
int selected_id = -1;
do {
diff --git a/ship_cmd.c b/ship_cmd.c
index ac67056ca..aa42a7b2b 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -28,7 +28,7 @@ static byte GetTileShipTrackStatus(TileIndex tile)
return r | r >> 8;
}
-void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
+void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod)
{
int spritenum = ShipVehInfo(engine)->image_index;
@@ -905,7 +905,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->last_station_visited = INVALID_STATION;
v->max_speed = svi->max_speed;
- v->engine_type = (byte)p1;
+ v->engine_type = p1;
e = GetEngine(p1);
v->reliability = e->reliability;
diff --git a/ship_gui.c b/ship_gui.c
index aa522a574..898591482 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -351,7 +351,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos;
- int engine_id = SHIP_ENGINES_INDEX;
+ EngineID engine_id = SHIP_ENGINES_INDEX;
int selected_id = -1;
do {
diff --git a/train_cmd.c b/train_cmd.c
index cc34c3169..606dde670 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -364,7 +364,7 @@ int GetTrainImage(const Vehicle *v, byte direction)
return base;
}
-void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod)
+void DrawTrainEngine(int x, int y, EngineID engine, uint32 image_ormod)
{
const RailVehicleInfo *rvi = RailVehInfo(engine);
@@ -397,7 +397,7 @@ void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod)
}
-static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
+static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
{
int32 value;
Vehicle *v;
@@ -642,7 +642,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->last_station_visited = INVALID_STATION;
v->dest_tile = 0;
- v->engine_type = (byte)p1;
+ v->engine_type = p1;
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
@@ -735,7 +735,7 @@ static Vehicle *UnlinkWagon(Vehicle *v, Vehicle *first)
static Vehicle *FindGoodVehiclePos(const Vehicle *src)
{
Vehicle *dst;
- uint16 eng = src->engine_type;
+ EngineID eng = src->engine_type;
TileIndex tile = src->tile;
FOR_ALL_VEHICLES(dst) {
@@ -955,7 +955,7 @@ int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* engine is 'started', first 'close' that before 'closing' our
* searched engine
*/
-static Vehicle *GetRearEngine(const Vehicle *v, uint16 engine)
+static Vehicle *GetRearEngine(const Vehicle *v, EngineID engine)
{
Vehicle *u;
int en_count = 1;
@@ -1737,7 +1737,7 @@ static void HandleLocomotiveSmokeCloud(Vehicle *v)
u = v;
do {
- int engtype = v->engine_type;
+ EngineID engtype = v->engine_type;
// no smoke?
if (RailVehInfo(engtype)->flags & 2 ||
@@ -1783,7 +1783,7 @@ static void TrainPlayLeaveStationSound(Vehicle *v)
SND_0A_TRAIN_HORN
};
- int engtype = v->engine_type;
+ EngineID engtype = v->engine_type;
switch (GetEngine(engtype)->railtype) {
case 0:
diff --git a/train_gui.c b/train_gui.c
index 08b4a15f6..4d8a69e57 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -175,7 +175,7 @@ void CcCloneTrain(bool success, uint tile, uint32 p1, uint32 p2)
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
int *selected_id, byte railtype, byte show_max, bool is_engine)
{
- int i;
+ EngineID i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
const Engine *e = GetEngine(i);
@@ -209,7 +209,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
{
int count = 0;
byte railtype = WP(w,buildtrain_d).railtype;
- int i;
+ EngineID i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
const Engine *e = GetEngine(i);
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 93da38d3f..475c73f5a 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -417,7 +417,7 @@ static int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, int *selected_id, byte railtype,
uint8 lines_drawn, bool is_engine, bool show_cars, bool show_outdated)
{
- int i;
+ EngineID i;
byte colour;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
@@ -467,7 +467,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
int sel[2];
int count = 0;
int count2 = 0;
- int engine_id;
+ EngineID engine_id;
sel[0] = WP(w,replaceveh_d).sel_index[0];
sel[1] = WP(w,replaceveh_d).sel_index[1];
@@ -643,7 +643,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Road: {
int num = NUM_ROAD_ENGINES;
Engine *e = GetEngine(ROAD_ENGINES_INDEX);
- int engine_id = ROAD_ENGINES_INDEX;
+ EngineID engine_id = ROAD_ENGINES_INDEX;
byte cargo;
EngineInfo *info;
@@ -679,7 +679,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Ship: {
int num = NUM_SHIP_ENGINES;
Engine *e = GetEngine(SHIP_ENGINES_INDEX);
- int engine_id = SHIP_ENGINES_INDEX;
+ EngineID engine_id = SHIP_ENGINES_INDEX;
byte cargo, refittable;
EngineInfo *info;
@@ -718,7 +718,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if ( selected_id[0] != -1 ) {
int num = NUM_AIRCRAFT_ENGINES;
Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
- int engine_id = AIRCRAFT_ENGINES_INDEX;
+ EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
byte subtype = AircraftVehInfo(selected_id[0])->subtype;
EngineInfo *info;