summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-07 22:38:30 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-07 22:38:30 +0000
commit4479c06e2dada9acd4f407f90dc2233bc35bbbc3 (patch)
treebbce11ea61db0e1dcc5a88ef937b2633cdd79152
parent77717563e15b277147ac47f45965ed3a98f25462 (diff)
downloadopenttd-4479c06e2dada9acd4f407f90dc2233bc35bbbc3.tar.xz
(svn r11781) -Codechange: variable scope and initialization
-rw-r--r--src/build_vehicle_gui.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 2b8c44ea7..e2799f772 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -743,7 +743,7 @@ int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
/* Figure out what train EngineIDs to put in the list */
static void GenerateBuildTrainList(Window *w)
{
- EngineID eid, sel_id;
+ EngineID sel_id = INVALID_ENGINE;
int num_engines = 0;
int num_wagons = 0;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
@@ -756,7 +756,7 @@ static void GenerateBuildTrainList(Window *w)
* Also check to see if the previously selected engine is still available,
* and if not, reset selection to INVALID_ENGINE. This could be the case
* when engines become obsolete and are removed */
- for (sel_id = INVALID_ENGINE, eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
+ for (EngineID eid = 0; eid < NUM_TRAIN_ENGINES; eid++) {
const RailVehicleInfo *rvi = RailVehInfo(eid);
if (bv->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, bv->filter.railtype)) continue;
@@ -789,14 +789,12 @@ static void GenerateBuildTrainList(Window *w)
/* Figure out what road vehicle EngineIDs to put in the list */
static void GenerateBuildRoadVehList(Window *w)
{
- EngineID eid, sel_id;
+ EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
- sel_id = INVALID_ENGINE;
-
- for (eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
+ for (EngineID eid = ROAD_ENGINES_INDEX; eid < ROAD_ENGINES_INDEX + NUM_ROAD_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
if (!HasBit(bv->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
EngList_Add(&bv->eng_list, eid);
@@ -809,14 +807,12 @@ static void GenerateBuildRoadVehList(Window *w)
/* Figure out what ship EngineIDs to put in the list */
static void GenerateBuildShipList(Window *w)
{
- EngineID eid, sel_id;
+ EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
- sel_id = INVALID_ENGINE;
-
- for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
+ for (EngineID eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
EngList_Add(&bv->eng_list, eid);
@@ -828,7 +824,7 @@ static void GenerateBuildShipList(Window *w)
/* Figure out what aircraft EngineIDs to put in the list */
static void GenerateBuildAircraftList(Window *w)
{
- EngineID eid, sel_id;
+ EngineID sel_id = INVALID_ENGINE;
buildvehicle_d *bv = &WP(w, buildvehicle_d);
EngList_RemoveAll(&bv->eng_list);
@@ -837,8 +833,7 @@ static void GenerateBuildAircraftList(Window *w)
* Also check to see if the previously selected plane is still available,
* and if not, reset selection to INVALID_ENGINE. This could be the case
* when planes become obsolete and are removed */
- sel_id = INVALID_ENGINE;
- for (eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
+ for (EngineID eid = AIRCRAFT_ENGINES_INDEX; eid < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; eid++) {
if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
if (w->window_number > VEH_END && !CanAircraftUseStation(eid, w->window_number)) continue;