mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-02 04:13:26 +00:00
(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.
This commit is contained in:
parent
4164d2488f
commit
d1c741db4c
@ -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),
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user