(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)
{
EngineID e;
EngineID selected_engine = INVALID_ENGINE;
VehicleType type = (VehicleType)w->window_number;
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];
EngList_RemoveAll(list);
FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains
EngineID eid;
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) {
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 */
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 {
/* 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 (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo
if (!IsEngineBuildable(eid, type, _local_player)) continue; // we need to be able to build the engine
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 */
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 (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew)
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 (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);
if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list
EngList_Add(list, eid);
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)
if (type == VEH_TRAIN) EngList_Sort(list, &TrainEngineNumberSorter);

View File

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

View File

@ -202,14 +202,14 @@ RailTypes GetPlayerRailtypes(PlayerID p)
{
RailTypes rt = RAILTYPES_NONE;
EngineID i;
FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_TRAIN) {
const Engine* e = GetEngine(i);
const EngineInfo *ei = EngInfo(i);
EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_TRAIN) {
const Engine* e = GetEngine(eid);
const EngineInfo *ei = EngInfo(eid);
if (HasBit(ei->climates, _opt.landscape) &&
(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) {
assert(rvi->railtype < RAILTYPE_END);

View File

@ -96,10 +96,10 @@ RoadTypes GetPlayerRoadtypes(PlayerID p)
{
RoadTypes rt = ROADTYPES_NONE;
EngineID i;
FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) {
const Engine* e = GetEngine(i);
const EngineInfo *ei = EngInfo(i);
EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(eid, VEH_ROAD) {
const Engine* e = GetEngine(eid);
const EngineInfo *ei = EngInfo(eid);
if (HasBit(ei->climates, _opt.landscape) &&
(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 */
if (max > 0) {
/* Can we actually build the vehicle type? */
EngineID e;
FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
if (HasBit(GetEngine(e)->player_avail, _local_player)) return true;
EngineID eid;
FOR_ALL_ENGINEIDS_OF_TYPE(eid, type) {
if (HasBit(GetEngine(eid)->player_avail, _local_player)) return true;
}
return false;
}