summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/economy.cpp2
-rw-r--r--src/economy.h2
-rw-r--r--src/graph_gui.cpp4
-rw-r--r--src/misc.cpp2
-rw-r--r--src/misc_gui.cpp6
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/station_cmd.cpp14
-rw-r--r--src/station_gui.cpp12
-rw-r--r--src/town_cmd.cpp4
-rw-r--r--src/train_gui.cpp7
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_gui.cpp5
13 files changed, 29 insertions, 35 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 624c0afe9..6bd9a4a1c 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1408,7 +1408,7 @@ static void MaybeCrashAirplane(Vehicle *v)
if (GB(Random(), 0, 16) > prob) return;
/* Crash the airplane. Remove all goods stored at the station. */
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
st->goods[i].rating = 1;
SB(st->goods[i].waiting_acceptance, 0, 12, 0);
}
diff --git a/src/economy.cpp b/src/economy.cpp
index 2856af8e6..12b5bb5ee 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -652,7 +652,7 @@ static void AddInflation()
_economy.max_loan += 50000;
inf = _economy.infl_amount_pr * 54;
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
AddSingleInflation(
(int32*)_cargo_payment_rates + i,
_cargo_payment_rates_frac + i,
diff --git a/src/economy.h b/src/economy.h
index 4519e182f..b15f42221 100644
--- a/src/economy.h
+++ b/src/economy.h
@@ -66,6 +66,6 @@ void DeleteSubsidyWithIndustry(IndustryID index);
void DeleteSubsidyWithStation(StationID index);
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
-uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount);
+uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount);
#endif /* ECONOMY_H */
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index f03e89d47..7e91666f8 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -721,7 +721,7 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
gd.x_values_increment = 10;
uint i = 0;
- for (CargoID c = 0; c != NUM_CARGO; c++) {
+ for (CargoID c = 0; c < NUM_CARGO; c++) {
const CargoSpec *cs = GetCargo(c);
if (!cs->IsValid()) continue;
@@ -791,7 +791,7 @@ void ShowCargoPaymentRates()
/* Count the number of active cargo types */
uint num_active = 0;
- for (CargoID c = 0; c != NUM_CARGO; c++) {
+ for (CargoID c = 0; c < NUM_CARGO; c++) {
if (GetCargo(c)->IsValid()) num_active++;
}
diff --git a/src/misc.cpp b/src/misc.cpp
index fdd35ad56..62a824714 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -243,7 +243,7 @@ void InitializeLandscapeVariables(bool only_constants)
{
if (only_constants) return;
- for (CargoID i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
_cargo_payment_rates_frac[i] = 0;
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 792afe302..04a20c290 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -141,11 +141,10 @@ static void Place_LandInfo(TileIndex tile)
GetString(_landinfo_data[4], STR_01A8_LOCAL_AUTHORITY, lastof(_landinfo_data[4]));
{
- int i;
char *p = GetString(_landinfo_data[5], STR_01CE_CARGO_ACCEPTED, lastof(_landinfo_data[5]));
bool found = false;
- for (i = 0; i < NUM_CARGO; ++i) {
+ for (CargoID i = 0; i < NUM_CARGO; ++i) {
if (ac[i] > 0) {
/* Add a comma between each item. */
if (found) {
@@ -732,11 +731,10 @@ static void DrawStationCoverageText(const AcceptedCargo accepts,
{
char *b = _userstring;
bool first = true;
- int i;
b = InlineString(b, STR_000D_ACCEPTS);
- for (i = 0; i != NUM_CARGO; i++, mask >>= 1) {
+ for (CargoID i = 0; i < NUM_CARGO; i++, mask >>= 1) {
if (b >= lastof(_userstring) - 5) break;
if (accepts[i] >= 8 && mask & 1) {
if (first) {
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index c21749719..d113b8244 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -4006,7 +4006,7 @@ static void ResetNewGRFData()
/* Generate default cargo translation table */
memset(_default_cargo_list, 0, sizeof(_default_cargo_list));
- for (CargoID c = 0; c != NUM_CARGO; c++) {
+ for (CargoID c = 0; c < NUM_CARGO; c++) {
const CargoSpec *cs = GetCargo(c);
if (cs->IsValid()) _default_cargo_list[cs->bitnum] = cs->label;
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 663263bbf..3865b41e1 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -352,7 +352,7 @@ static uint GetAcceptanceMask(const Station *st)
{
uint mask = 0;
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (st->goods[i].waiting_acceptance & 0x8000) mask |= 1 << i;
}
return mask;
@@ -525,7 +525,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
}
// Adjust in case our station only accepts fewer kinds of goods
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
uint amt = min(accepts[i], 15);
// Make sure the station can accept the goods type.
@@ -2336,7 +2336,7 @@ void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint
FOR_ALL_STATIONS(st) {
if (st->owner == owner &&
DistanceManhattan(tile, st->xy) <= radius) {
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
GoodsEntry* ge = &st->goods[i];
if (ge->enroute_from != INVALID_STATION) {
@@ -2347,7 +2347,7 @@ void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint
}
}
-static void UpdateStationWaiting(Station *st, int type, uint amount)
+static void UpdateStationWaiting(Station *st, CargoID type, uint amount)
{
SB(st->goods[type].waiting_acceptance, 0, 12,
min(0xFFF, GB(st->goods[type].waiting_acceptance, 0, 12) + amount)
@@ -2391,7 +2391,7 @@ int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
}
-uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
+uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
{
Station* around[8];
@@ -2553,7 +2553,7 @@ void BuildOilRig(TileIndex tile)
st->facilities = FACIL_AIRPORT | FACIL_DOCK;
st->build_date = _date;
- for (uint j = 0; j != NUM_CARGO; j++) {
+ for (CargoID j = 0; j < NUM_CARGO; j++) {
st->goods[j].waiting_acceptance = 0;
st->goods[j].days_since_pickup = 0;
st->goods[j].enroute_from = INVALID_STATION;
@@ -2801,7 +2801,7 @@ static const SaveLoad _station_speclist_desc[] = {
static void SaveLoad_STNS(Station *st)
{
SlObject(st, _station_desc);
- for (uint i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
SlObject(&st->goods[i], _goods_desc);
}
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 309e311a1..095ea4295 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -364,7 +364,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
x = DrawString(xb, y, STR_3049_0, 0) + 5;
// show cargo waiting and station ratings
- for (CargoID j = 0; j != NUM_CARGO; j++) {
+ for (CargoID j = 0; j < NUM_CARGO; j++) {
uint amount = GB(st->goods[j].waiting_acceptance, 0, 12);
if (amount != 0) {
StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating);
@@ -677,7 +677,7 @@ static void DrawStationViewWindow(Window *w)
StringID str;
num = 1;
- for (CargoID i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) {
num++;
if (st->goods[i].enroute_from != station_id) num++;
@@ -701,7 +701,7 @@ static void DrawStationViewWindow(Window *w)
if (--pos < 0) {
str = STR_00D0_NOTHING;
- for (CargoID i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY;
}
SetDParam(0, str);
@@ -709,7 +709,7 @@ static void DrawStationViewWindow(Window *w)
y += 10;
}
- for (CargoID i = 0; i != NUM_CARGO && pos > -5; i++) {
+ for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) {
uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12);
if (waiting == 0) continue;
@@ -753,7 +753,7 @@ static void DrawStationViewWindow(Window *w)
b = InlineString(b, STR_000C_ACCEPTS);
- for (CargoID i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (b >= endof(_userstring) - 5 - 1) break;
if (st->goods[i].waiting_acceptance & 0x8000) {
if (first) {
@@ -776,7 +776,7 @@ static void DrawStationViewWindow(Window *w)
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);
y = 77;
- for (CargoID i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = GetCargo(i);
if (!cs->IsValid()) continue;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 84166b689..115d02d42 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1587,9 +1587,7 @@ static void TownActionBribe(Town* t)
// set all close by station ratings to 0
FOR_ALL_STATIONS(st) {
if (st->town == t && st->owner == _current_player) {
- uint i;
-
- for (i = 0; i != NUM_CARGO; i++) st->goods[i].rating = 0;
+ for (CargoID i = 0; i < NUM_CARGO; i++) st->goods[i].rating = 0;
}
}
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 6abc36c79..130bcfa34 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -371,7 +371,6 @@ static void DrawTrainDetailsWindow(Window *w)
const Vehicle *u;
AcceptedCargo act_cargo;
AcceptedCargo max_cargo;
- uint i;
int num;
int x;
int y;
@@ -380,7 +379,7 @@ static void DrawTrainDetailsWindow(Window *w)
num = 0;
u = v = GetVehicle(w->window_number);
if (det_tab == 3) { // Total cargo tab
- for (i = 0; i < lengthof(act_cargo); i++) {
+ for (CargoID i = 0; i < lengthof(act_cargo); i++) {
act_cargo[i] = 0;
max_cargo[i] = 0;
}
@@ -393,7 +392,7 @@ static void DrawTrainDetailsWindow(Window *w)
/* Set scroll-amount seperately from counting, as to not compute num double
* for more carriages of the same type
*/
- for (i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (max_cargo[i] > 0) num++; // only count carriages that the train has
}
num++; // needs one more because first line is description string
@@ -492,7 +491,7 @@ static void DrawTrainDetailsWindow(Window *w)
} else {
// draw total cargo tab
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
- for (i = 0; i != NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) {
y += 14;
SetDParam(0, i); // {CARGO} #1
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 29e66640f..5e8d64538 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -772,7 +772,7 @@ CargoID FindFirstRefittableCargo(EngineID engine_type)
uint32 refit_mask = EngInfo(engine_type)->refit_mask;
if (refit_mask != 0) {
- for (CargoID cid = CT_PASSENGERS; cid < NUM_CARGO; cid++) {
+ for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
if (HASBIT(refit_mask, cid)) return cid;
}
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index d93544167..14c5583e5 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -209,7 +209,7 @@ static RefitList *BuildRefitList(const Vehicle *v)
if (u->cargo_cap == 0) continue;
/* Loop through all cargos in the refit mask */
- for (CargoID cid = 0; cid != NUM_CARGO && num_lines < max_lines; cid++) {
+ for (CargoID cid = 0; cid < NUM_CARGO && num_lines < max_lines; cid++) {
/* Skip cargo type if it's not listed */
if (!HASBIT(cmask, cid)) continue;
@@ -616,14 +616,13 @@ static int CDECL VehicleCargoSorter(const void *a, const void *b)
AcceptedCargo cargoa;
AcceptedCargo cargob;
int r = 0;
- int i;
memset(cargoa, 0, sizeof(cargoa));
memset(cargob, 0, sizeof(cargob));
for (v = va; v != NULL; v = v->next) cargoa[v->cargo_type] += v->cargo_cap;
for (v = vb; v != NULL; v = v->next) cargob[v->cargo_type] += v->cargo_cap;
- for (i = 0; i < NUM_CARGO; i++) {
+ for (CargoID i = 0; i < NUM_CARGO; i++) {
r = cargoa[i] - cargob[i];
if (r != 0) break;
}