summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.cpp24
-rw-r--r--src/engine.h2
-rw-r--r--src/oldloader.cpp2
3 files changed, 14 insertions, 14 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index d1475602d..4005eac5e 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -191,20 +191,20 @@ static void AcceptEnginePreview(EngineID eid, PlayerID player)
SetBit(p->avail_roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
- e->preview_player = INVALID_PLAYER;
+ e->preview_player_rank = 0xFF;
if (player == _local_player) {
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
}
}
-static PlayerID GetBestPlayer(PlayerID pp)
+static PlayerID GetBestPlayer(uint8 pp)
{
const Player *p;
int32 best_hist;
PlayerID best_player;
uint mask = 0;
- do {
+ for (; pp != 0; pp--) {
best_hist = -1;
best_player = PLAYER_SPECTATOR;
FOR_ALL_PLAYERS(p) {
@@ -218,7 +218,7 @@ static PlayerID GetBestPlayer(PlayerID pp)
if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR;
SetBit(mask, best_player);
- } while (pp--, pp != 0);
+ }
return best_player;
}
@@ -234,16 +234,16 @@ void EnginesDailyLoop()
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) {
if (e->flags & ENGINE_OFFER_WINDOW_OPEN) {
- if (e->preview_player != 0xFF && !--e->preview_wait) {
+ if (e->preview_player_rank != 0xFF && !--e->preview_wait) {
e->flags &= ~ENGINE_OFFER_WINDOW_OPEN;
DeleteWindowById(WC_ENGINE_PREVIEW, i);
- e->preview_player++;
+ e->preview_player_rank++;
}
- } else if (e->preview_player != 0xFF) {
- PlayerID best_player = GetBestPlayer(e->preview_player);
+ } else if (e->preview_player_rank != 0xFF) {
+ PlayerID best_player = GetBestPlayer(e->preview_player_rank);
if (best_player == PLAYER_SPECTATOR) {
- e->preview_player = INVALID_PLAYER;
+ e->preview_player_rank = 0xFF;
continue;
}
@@ -273,7 +273,7 @@ CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32
if (!IsEngineIndex(p1)) return CMD_ERROR;
e = GetEngine(p1);
- if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR;
+ if (GetBestPlayer(e->preview_player_rank) != _current_player) return CMD_ERROR;
if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_player);
@@ -361,7 +361,7 @@ void EnginesMonthlyLoop()
/* Do not introduce new rail wagons */
if (!IsWagon(e - _engines))
- e->preview_player = (PlayerID)1; // Give to the player with the highest rating.
+ e->preview_player_rank = 1; // Give to the player with the highest rating.
}
}
}
@@ -613,7 +613,7 @@ static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine, lifelength, SLE_UINT8),
SLE_VAR(Engine, flags, SLE_UINT8),
- SLE_VAR(Engine, preview_player, SLE_UINT8),
+ SLE_VAR(Engine, preview_player_rank, SLE_UINT8),
SLE_VAR(Engine, preview_wait, SLE_UINT8),
SLE_CONDNULL(1, 0, 44),
SLE_VAR(Engine, player_avail, SLE_UINT8),
diff --git a/src/engine.h b/src/engine.h
index 67ddf9996..9b44fdb9a 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -124,7 +124,7 @@ struct Engine {
uint16 duration_phase_1, duration_phase_2, duration_phase_3;
byte lifelength;
byte flags;
- PlayerByte preview_player;
+ uint8 preview_player_rank;
byte preview_wait;
byte player_avail;
VehicleType type; ///< type, ie VEH_ROAD, VEH_TRAIN, etc.
diff --git a/src/oldloader.cpp b/src/oldloader.cpp
index ec5f7b9e0..0140f2200 100644
--- a/src/oldloader.cpp
+++ b/src/oldloader.cpp
@@ -1289,7 +1289,7 @@ static const OldChunks engine_chunk[] = {
OCL_SVAR( OC_UINT8, Engine, lifelength ),
OCL_SVAR( OC_UINT8, Engine, flags ),
- OCL_SVAR( OC_UINT8, Engine, preview_player ),
+ OCL_SVAR( OC_UINT8, Engine, preview_player_rank ),
OCL_SVAR( OC_UINT8, Engine, preview_wait ),
OCL_NULL( 2 ), ///< Junk