(svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE

This commit is contained in:
peter1138 2008-04-29 07:11:54 +00:00
parent 868c17a175
commit 5ca6fd67fc
5 changed files with 27 additions and 27 deletions

View File

@ -191,7 +191,6 @@ static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b)
*/ */
static void GenerateReplaceVehList(Window *w, bool draw_left) static void GenerateReplaceVehList(Window *w, bool draw_left)
{ {
EngineID e;
EngineID selected_engine = INVALID_ENGINE; EngineID selected_engine = INVALID_ENGINE;
VehicleType type = (VehicleType)w->window_number; VehicleType type = (VehicleType)w->window_number;
byte i = draw_left ? 0 : 1; byte i = draw_left ? 0 : 1;
@ -199,27 +198,28 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
EngineList *list = &WP(w, replaceveh_d).list[i]; EngineList *list = &WP(w, replaceveh_d).list[i];
EngList_RemoveAll(list); EngList_RemoveAll(list);
FOR_ALL_ENGINEIDS_OF_TYPE(e, type) { EngineID eid;
if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains FOR_ALL_ENGINEIDS_OF_TYPE(eid, type) {
if (type == VEH_TRAIN && !GenerateReplaceRailList(eid, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains
if (draw_left) { if (draw_left) {
const GroupID selected_group = WP(w, replaceveh_d).sel_group; const GroupID selected_group = WP(w, replaceveh_d).sel_group;
const uint num_engines = GetGroupNumEngines(_local_player, selected_group, e); const uint num_engines = GetGroupNumEngines(_local_player, selected_group, eid);
/* Skip drawing the engines we don't have any of and haven't set for replacement */ /* Skip drawing the engines we don't have any of and haven't set for replacement */
if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue; if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), eid, selected_group) == INVALID_ENGINE) continue;
} else { } else {
/* This is for engines we can replace to and they should depend on what we selected to replace from */ /* This is for engines we can replace to and they should depend on what we selected to replace from */
if (!IsEngineBuildable(e, type, _local_player)) continue; // we need to be able to build the engine if (!IsEngineBuildable(eid, type, _local_player)) continue; // we need to be able to build the engine
if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo if (!EnginesGotCargoInCommon(eid, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
/* Road vehicles can't be replaced by trams and vice-versa */ /* Road vehicles can't be replaced by trams and vice-versa */
if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(e)->misc_flags, EF_ROAD_TRAM)) continue; if (type == VEH_ROAD && HasBit(EngInfo(WP(w, replaceveh_d).sel_engine[0])->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM)) continue;
if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew) if (eid == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
} }
EngList_Add(list, e); EngList_Add(list, eid);
if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list if (eid == WP(w, replaceveh_d).sel_engine[i]) selected_engine = eid; // The selected engine is still in the list
} }
WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore) WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore)
if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter); if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);

View File

@ -653,17 +653,17 @@ static void ResizeDefaultWindowSizeForRoadVehicles()
static void ResizeDefaultWindowSize(VehicleType type) static void ResizeDefaultWindowSize(VehicleType type)
{ {
EngineID engine;
uint max_width = 0; uint max_width = 0;
uint max_height = 0; uint max_height = 0;
FOR_ALL_ENGINEIDS_OF_TYPE(engine, type) { EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(eid, type) {
uint x, y; uint x, y;
switch (type) { switch (type) {
default: NOT_REACHED(); default: NOT_REACHED();
case VEH_SHIP: GetShipSpriteSize( engine, x, y); break; case VEH_SHIP: GetShipSpriteSize( eid, x, y); break;
case VEH_AIRCRAFT: GetAircraftSpriteSize(engine, x, y); break; case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y); break;
} }
if (x > max_width) max_width = x; if (x > max_width) max_width = x;
if (y > max_height) max_height = y; if (y > max_height) max_height = y;

View File

@ -202,14 +202,14 @@ RailTypes GetPlayerRailtypes(PlayerID p)
{ {
RailTypes rt = RAILTYPES_NONE; RailTypes rt = RAILTYPES_NONE;
EngineID i; EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_TRAIN) { FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_TRAIN) {
const Engine* e = GetEngine(i); const Engine* e = GetEngine(eid);
const EngineInfo *ei = EngInfo(i); const EngineInfo *ei = EngInfo(eid);
if (HasBit(ei->climates, _opt.landscape) && if (HasBit(ei->climates, _opt.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = RailVehInfo(i); const RailVehicleInfo *rvi = RailVehInfo(eid);
if (rvi->railveh_type != RAILVEH_WAGON) { if (rvi->railveh_type != RAILVEH_WAGON) {
assert(rvi->railtype < RAILTYPE_END); assert(rvi->railtype < RAILTYPE_END);

View File

@ -96,10 +96,10 @@ RoadTypes GetPlayerRoadtypes(PlayerID p)
{ {
RoadTypes rt = ROADTYPES_NONE; RoadTypes rt = ROADTYPES_NONE;
EngineID i; EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) { FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_ROAD) {
const Engine* e = GetEngine(i); const Engine* e = GetEngine(eid);
const EngineInfo *ei = EngInfo(i); const EngineInfo *ei = EngInfo(eid);
if (HasBit(ei->climates, _opt.landscape) && if (HasBit(ei->climates, _opt.landscape) &&
(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {

View File

@ -1985,9 +1985,9 @@ bool CanBuildVehicleInfrastructure(VehicleType type)
/* We can build vehicle infrastructure when we may build the vehicle type */ /* We can build vehicle infrastructure when we may build the vehicle type */
if (max > 0) { if (max > 0) {
/* Can we actually build the vehicle type? */ /* Can we actually build the vehicle type? */
EngineID e; EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(e, type) { FOR_ALL_ENGINEIDS_OF_TYPE(eid, type) {
if (HasBit(GetEngine(e)->player_avail, _local_player)) return true; if (HasBit(GetEngine(eid)->player_avail, _local_player)) return true;
} }
return false; return false;
} }