(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)

This commit is contained in:
tron 2005-10-01 12:43:34 +00:00
parent eb1d025d08
commit 0cc45ecd8e
12 changed files with 82 additions and 83 deletions

View File

@ -102,7 +102,7 @@ int GetAircraftImage(const Vehicle *v, byte direction)
return direction + _aircraft_sprite[spritenum]; 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 spritenum = AircraftVehInfo(engine)->image_index;
int sprite = (6 + _aircraft_sprite[spritenum]); 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->max_speed = avi->max_speed;
v->acceleration = avi->acceleration; v->acceleration = avi->acceleration;
v->engine_type = (byte)p1; v->engine_type = p1;
v->subtype = (avi->subtype & 1) == 0 ? 0 : 2; v->subtype = (avi->subtype & 1) == 0 ? 0 : 2;
v->value = value; v->value = value;

View File

@ -128,7 +128,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
int y = 15; int y = 15;
int sel = WP(w,buildtrain_d).sel_index; int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos; int pos = w->vscroll.pos;
int engine_id = AIRCRAFT_ENGINES_INDEX; EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
int selected_id = -1; int selected_id = -1;
do { do {

View File

@ -93,7 +93,7 @@ const uint32 _default_refitmasks[NUM_VEHICLE_TYPES] = {
}; };
#undef MC #undef MC
void ShowEnginePreviewWindow(int engine); void ShowEnginePreviewWindow(EngineID engine);
void DeleteCustomEngineNames(void) void DeleteCustomEngineNames(void)
{ {
@ -250,7 +250,7 @@ typedef struct WagonOverrides {
static WagonOverrides _engine_wagon_overrides[TOTAL_NUM_ENGINES]; 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) int trains)
{ {
WagonOverrides *wos; WagonOverrides *wos;
@ -271,7 +271,7 @@ void SetWagonOverrideSprites(byte engine, SpriteGroup *group, byte *train_id,
memcpy(wo->train_id, train_id, trains); 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]; const WagonOverrides *wos = &_engine_wagon_overrides[engine];
int i; int i;
@ -300,7 +300,7 @@ static const SpriteGroup *GetWagonOverrideSpriteSet(byte engine, byte overriding
// memory. --pasky) // memory. --pasky)
static SpriteGroup _engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; 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 /* FIXME: If we are replacing an override, release original SpriteGroup
* to prevent leaks. But first we need to refcount the 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; const SpriteGroup *group;
byte cargo = GC_PURCHASE; byte cargo = GC_PURCHASE;
@ -515,7 +515,7 @@ static const SpriteGroup *GetVehicleSpriteGroup(byte engine, const Vehicle *v)
return group; return group;
} }
int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction) int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction)
{ {
const SpriteGroup *group; const SpriteGroup *group;
const RealSpriteGroup *rsg; 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) * @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 * @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; const SpriteGroup *group;
byte cargo = GC_DEFAULT; byte cargo = GC_DEFAULT;
@ -716,7 +716,7 @@ void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger)
static char *_engine_custom_names[TOTAL_NUM_ENGINES]; 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); _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]) if (!_engine_custom_names[engine])
return _engine_name_strings[engine]; return _engine_name_strings[engine];
@ -780,7 +780,7 @@ static PlayerID GetBestPlayer(PlayerID pp)
void EnginesDailyLoop(void) void EnginesDailyLoop(void)
{ {
uint i; EngineID i;
if (_cur_year >= 130) return; 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) // 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; return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->flags & RVI_WAGON;
} }
@ -846,7 +846,7 @@ static void NewVehicleAvailable(Engine *e)
{ {
Vehicle *v; Vehicle *v;
Player *p; Player *p;
int index = e - _engines; EngineID index = e - _engines;
// In case the player didn't build the vehicle during the intro period, // In case the player didn't build the vehicle during the intro period,
// prevent that player from getting future intro periods for a while. // 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); 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); 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); AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_SHIPAVAIL), 0, 0);
} else { } else {
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_AIRCRAFTAVAIL), 0, 0); AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_AIRCRAFTAVAIL), 0, 0);

View File

@ -172,11 +172,11 @@ VARDEF const uint32 _landscape_global_cargo_mask[NUM_LANDSCAPE];
VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID]; VARDEF const CargoID _local_cargo_id_ctype[NUM_GLOBAL_CID];
VARDEF uint32 _engine_refit_masks[256]; VARDEF uint32 _engine_refit_masks[256];
void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group, byte *train_id, int trains); void SetWagonOverrideSprites(EngineID engine, struct SpriteGroup *group, byte *train_id, int trains);
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group); void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group);
// loaded is in percents, overriding_engine 0xffff is none // loaded is in percents, overriding_engine 0xffff is none
int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction); int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction);
uint16 GetCallBackResult(uint16 callback_info, byte engine, const Vehicle *v); uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v);
bool UsesWagonOverride(const Vehicle *v); bool UsesWagonOverride(const Vehicle *v);
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction) #define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction) #define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
@ -192,14 +192,14 @@ typedef enum VehicleTrigger {
} VehicleTrigger; } VehicleTrigger;
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger); void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger);
void SetCustomEngineName(int engine, const char *name); void SetCustomEngineName(EngineID engine, const char *name);
StringID GetCustomEngineName(int engine); StringID GetCustomEngineName(EngineID engine);
void DrawTrainEngine(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, int engine, uint32 image_ormod); void DrawRoadVehEngine(int x, int y, EngineID engine, uint32 image_ormod);
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod); void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod);
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod); void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod);
void AcceptEnginePreview(Engine *e, PlayerID player); void AcceptEnginePreview(Engine *e, PlayerID player);
@ -225,7 +225,7 @@ enum {
VARDEF Engine _engines[TOTAL_NUM_ENGINES]; VARDEF Engine _engines[TOTAL_NUM_ENGINES];
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++) #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)); assert(i < lengthof(_engines));
return &_engines[i]; return &_engines[i];
@ -252,27 +252,27 @@ ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES];
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES];
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_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)); assert(e < lengthof(_rail_vehicle_info));
return &_rail_vehicle_info[e]; 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]; 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]; 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]; return &_road_vehicle_info[e - ROAD_ENGINES_INDEX];
} }

View File

@ -15,7 +15,7 @@
#include "variables.h" #include "variables.h"
static StringID GetEngineCategoryName(byte engine) static StringID GetEngineCategoryName(EngineID engine)
{ {
if (engine < NUM_TRAIN_ENGINES) { if (engine < NUM_TRAIN_ENGINES) {
switch (GetEngine(engine)->railtype) { switch (GetEngine(engine)->railtype) {
@ -46,18 +46,18 @@ static const Widget _engine_preview_widgets[] = {
{ WIDGETS_END}, { WIDGETS_END},
}; };
typedef void DrawEngineProc(int x, int y, int engine, uint32 image_ormod); typedef void DrawEngineProc(int x, int y, EngineID engine, uint32 image_ormod);
typedef void DrawEngineInfoProc(int x, int y, int engine, int maxw); typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw);
typedef struct DrawEngineInfo { typedef struct DrawEngineInfo {
DrawEngineProc *engine_proc; DrawEngineProc *engine_proc;
DrawEngineInfoProc *info_proc; DrawEngineInfoProc *info_proc;
} DrawEngineInfo; } DrawEngineInfo;
static void DrawTrainEngineInfo(int engine, int x, int y, int maxw); static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw);
static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw);
static void DrawShipEngineInfo(int engine, int x, int y, int maxw); static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw);
static void DrawAircraftEngineInfo(int 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] = { static const DrawEngineInfo _draw_engine_list[4] = {
{DrawTrainEngine,DrawTrainEngineInfo}, {DrawTrainEngine,DrawTrainEngineInfo},
@ -68,31 +68,30 @@ static const DrawEngineInfo _draw_engine_list[4] = {
static void EnginePreviewWndProc(Window *w, WindowEvent *e) static void EnginePreviewWndProc(Window *w, WindowEvent *e)
{ {
byte eng;
int engine;
const DrawEngineInfo *dei; const DrawEngineInfo *dei;
int width; int width;
switch(e->event) { switch(e->event) {
case WE_PAINT: case WE_PAINT: {
EngineID engine = w->window_number;
DrawWindowWidgets(w); DrawWindowWidgets(w);
engine = w->window_number;
SetDParam(0, GetEngineCategoryName(engine)); SetDParam(0, GetEngineCategoryName(engine));
DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296); DrawStringMultiCenter(150, 44, STR_8101_WE_HAVE_JUST_DESIGNED_A, 296);
DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10); DrawStringCentered(w->width >> 1, 80, GetCustomEngineName(engine), 0x10);
eng = (byte)engine; (dei = _draw_engine_list,engine < NUM_TRAIN_ENGINES) ||
(dei = _draw_engine_list,eng < NUM_TRAIN_ENGINES) || (dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) ||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) || (dei++,engine < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
(dei++,eng < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) ||
(dei++, true); (dei++, true);
width = w->width; width = w->width;
dei->engine_proc(width >> 1, 100, engine, 0); dei->engine_proc(width >> 1, 100, engine, 0);
dei->info_proc(engine, width >> 1, 130, width - 52); dei->info_proc(engine, width >> 1, 130, width - 52);
break; break;
}
case WE_CLICK: case WE_CLICK:
switch(e->click.widget) { switch(e->click.widget) {
@ -115,7 +114,7 @@ static const WindowDesc _engine_preview_desc = {
}; };
void ShowEnginePreviewWindow(int engine) void ShowEnginePreviewWindow(EngineID engine)
{ {
Window *w; Window *w;
@ -123,7 +122,7 @@ void ShowEnginePreviewWindow(int engine)
w->window_number = 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); const RailVehicleInfo *rvi = RailVehInfo(engine);
int cap; int cap;
@ -147,7 +146,7 @@ static void DrawTrainEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewTrainAvail(Window *w) void DrawNewsNewTrainAvail(Window *w)
{ {
int engine; EngineID engine;
DrawNewsBorder(w); DrawNewsBorder(w);
@ -167,14 +166,14 @@ void DrawNewsNewTrainAvail(Window *w)
StringID GetNewsStringNewTrainAvail(const NewsItem *ni) StringID GetNewsStringNewTrainAvail(const NewsItem *ni)
{ {
int engine = ni->string_id; EngineID engine = ni->string_id;
SetDParam(0, STR_8859_NEW_NOW_AVAILABLE); SetDParam(0, STR_8859_NEW_NOW_AVAILABLE);
SetDParam(1, GetEngineCategoryName(engine)); SetDParam(1, GetEngineCategoryName(engine));
SetDParam(2, GetCustomEngineName(engine)); SetDParam(2, GetCustomEngineName(engine));
return STR_02B6; 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); const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); 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) void DrawNewsNewAircraftAvail(Window *w)
{ {
int engine; EngineID engine;
DrawNewsBorder(w); DrawNewsBorder(w);
@ -207,13 +206,13 @@ void DrawNewsNewAircraftAvail(Window *w)
StringID GetNewsStringNewAircraftAvail(const NewsItem *ni) StringID GetNewsStringNewAircraftAvail(const NewsItem *ni)
{ {
int engine = ni->string_id; EngineID engine = ni->string_id;
SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE); SetDParam(0, STR_A02C_NEW_AIRCRAFT_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine)); SetDParam(1, GetCustomEngineName(engine));
return STR_02B6; 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); const RoadVehicleInfo *rvi = RoadVehInfo(engine);
@ -229,7 +228,7 @@ static void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw)
void DrawNewsNewRoadVehAvail(Window *w) void DrawNewsNewRoadVehAvail(Window *w)
{ {
int engine; EngineID engine;
DrawNewsBorder(w); DrawNewsBorder(w);
@ -247,13 +246,13 @@ void DrawNewsNewRoadVehAvail(Window *w)
StringID GetNewsStringNewRoadVehAvail(const NewsItem *ni) 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(0, STR_9028_NEW_ROAD_VEHICLE_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine)); SetDParam(1, GetCustomEngineName(engine));
return STR_02B6; 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); const ShipVehicleInfo *svi = ShipVehInfo(engine);
SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); 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) void DrawNewsNewShipAvail(Window *w)
{ {
int engine; EngineID engine;
DrawNewsBorder(w); DrawNewsBorder(w);
@ -285,7 +284,7 @@ void DrawNewsNewShipAvail(Window *w)
StringID GetNewsStringNewShipAvail(const NewsItem *ni) StringID GetNewsStringNewShipAvail(const NewsItem *ni)
{ {
int engine = ni->string_id; EngineID engine = ni->string_id;
SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE); SetDParam(0, STR_982C_NEW_SHIP_NOW_AVAILABLE);
SetDParam(1, GetCustomEngineName(engine)); SetDParam(1, GetCustomEngineName(engine));
return STR_02B6; return STR_02B6;

View File

@ -77,7 +77,7 @@ int GetRoadVehImage(const Vehicle *v, byte direction)
return image; 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; int spritenum = RoadVehInfo(engine)->image_index;

View File

@ -411,7 +411,7 @@ static void DrawNewRoadVehWindow(Window *w)
int y = 15; int y = 15;
int sel = WP(w,buildtrain_d).sel_index; int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos; int pos = w->vscroll.pos;
int engine_id = ROAD_ENGINES_INDEX; EngineID engine_id = ROAD_ENGINES_INDEX;
int selected_id = -1; int selected_id = -1;
do { do {

View File

@ -28,7 +28,7 @@ static byte GetTileShipTrackStatus(TileIndex tile)
return r | r >> 8; 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; 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->last_station_visited = INVALID_STATION;
v->max_speed = svi->max_speed; v->max_speed = svi->max_speed;
v->engine_type = (byte)p1; v->engine_type = p1;
e = GetEngine(p1); e = GetEngine(p1);
v->reliability = e->reliability; v->reliability = e->reliability;

View File

@ -351,7 +351,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
int y = 15; int y = 15;
int sel = WP(w,buildtrain_d).sel_index; int sel = WP(w,buildtrain_d).sel_index;
int pos = w->vscroll.pos; int pos = w->vscroll.pos;
int engine_id = SHIP_ENGINES_INDEX; EngineID engine_id = SHIP_ENGINES_INDEX;
int selected_id = -1; int selected_id = -1;
do { do {

View File

@ -364,7 +364,7 @@ int GetTrainImage(const Vehicle *v, byte direction)
return base; 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); 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; int32 value;
Vehicle *v; 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->last_station_visited = INVALID_STATION;
v->dest_tile = 0; v->dest_tile = 0;
v->engine_type = (byte)p1; v->engine_type = p1;
v->reliability = e->reliability; v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec; 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) static Vehicle *FindGoodVehiclePos(const Vehicle *src)
{ {
Vehicle *dst; Vehicle *dst;
uint16 eng = src->engine_type; EngineID eng = src->engine_type;
TileIndex tile = src->tile; TileIndex tile = src->tile;
FOR_ALL_VEHICLES(dst) { 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 * engine is 'started', first 'close' that before 'closing' our
* searched engine * searched engine
*/ */
static Vehicle *GetRearEngine(const Vehicle *v, uint16 engine) static Vehicle *GetRearEngine(const Vehicle *v, EngineID engine)
{ {
Vehicle *u; Vehicle *u;
int en_count = 1; int en_count = 1;
@ -1737,7 +1737,7 @@ static void HandleLocomotiveSmokeCloud(Vehicle *v)
u = v; u = v;
do { do {
int engtype = v->engine_type; EngineID engtype = v->engine_type;
// no smoke? // no smoke?
if (RailVehInfo(engtype)->flags & 2 || if (RailVehInfo(engtype)->flags & 2 ||
@ -1783,7 +1783,7 @@ static void TrainPlayLeaveStationSound(Vehicle *v)
SND_0A_TRAIN_HORN SND_0A_TRAIN_HORN
}; };
int engtype = v->engine_type; EngineID engtype = v->engine_type;
switch (GetEngine(engtype)->railtype) { switch (GetEngine(engtype)->railtype) {
case 0: case 0:

View File

@ -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, 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 *selected_id, byte railtype, byte show_max, bool is_engine)
{ {
int i; EngineID i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
const Engine *e = GetEngine(i); const Engine *e = GetEngine(i);
@ -209,7 +209,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
{ {
int count = 0; int count = 0;
byte railtype = WP(w,buildtrain_d).railtype; byte railtype = WP(w,buildtrain_d).railtype;
int i; EngineID i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
const Engine *e = GetEngine(i); const Engine *e = GetEngine(i);

View File

@ -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, 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) uint8 lines_drawn, bool is_engine, bool show_cars, bool show_outdated)
{ {
int i; EngineID i;
byte colour; byte colour;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) { for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
@ -467,7 +467,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
int sel[2]; int sel[2];
int count = 0; int count = 0;
int count2 = 0; int count2 = 0;
int engine_id; EngineID engine_id;
sel[0] = WP(w,replaceveh_d).sel_index[0]; sel[0] = WP(w,replaceveh_d).sel_index[0];
sel[1] = WP(w,replaceveh_d).sel_index[1]; 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: { case VEH_Road: {
int num = NUM_ROAD_ENGINES; int num = NUM_ROAD_ENGINES;
Engine *e = GetEngine(ROAD_ENGINES_INDEX); Engine *e = GetEngine(ROAD_ENGINES_INDEX);
int engine_id = ROAD_ENGINES_INDEX; EngineID engine_id = ROAD_ENGINES_INDEX;
byte cargo; byte cargo;
EngineInfo *info; EngineInfo *info;
@ -679,7 +679,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Ship: { case VEH_Ship: {
int num = NUM_SHIP_ENGINES; int num = NUM_SHIP_ENGINES;
Engine *e = GetEngine(SHIP_ENGINES_INDEX); Engine *e = GetEngine(SHIP_ENGINES_INDEX);
int engine_id = SHIP_ENGINES_INDEX; EngineID engine_id = SHIP_ENGINES_INDEX;
byte cargo, refittable; byte cargo, refittable;
EngineInfo *info; EngineInfo *info;
@ -718,7 +718,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
if ( selected_id[0] != -1 ) { if ( selected_id[0] != -1 ) {
int num = NUM_AIRCRAFT_ENGINES; int num = NUM_AIRCRAFT_ENGINES;
Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX); 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; byte subtype = AircraftVehInfo(selected_id[0])->subtype;
EngineInfo *info; EngineInfo *info;