Mercurial > hg > openttd
changeset 8565:1c6548020275 draft
(svn r12143) -Fix (r8038): Engine::preview_player does not contain a Player ID. Rename this to preview_player_rank and change back to a uint8 to avoid confusion.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Fri, 15 Feb 2008 11:02:50 +0000 |
parents | 2785566a8c4e |
children | 6d3f10e5fe7f |
files | src/engine.cpp src/engine.h src/oldloader.cpp |
diffstat | 3 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/engine.cpp +++ b/src/engine.cpp @@ -191,20 +191,20 @@ 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 @@ if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR; SetBit(mask, best_player); - } while (pp--, pp != 0); + } return best_player; } @@ -234,16 +234,16 @@ 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 @@ 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 @@ /* 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 @@ 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),
--- a/src/engine.h +++ b/src/engine.h @@ -124,7 +124,7 @@ 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.
--- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -1289,7 +1289,7 @@ 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