mirror of https://github.com/OpenTTD/OpenTTD
(svn r11717) -Fix [FS#1590]: make sure invalid players have all shares owned by PLAYER_SPECTATOR
parent
c87f20ff37
commit
108ab3b910
|
@ -285,6 +285,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
/* See if the old_player had shares in other companies */
|
/* See if the old_player had shares in other companies */
|
||||||
_current_player = old_player;
|
_current_player = old_player;
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
|
if (!p->is_active) continue;
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (p->share_owners[i] == old_player) {
|
if (p->share_owners[i] == old_player) {
|
||||||
/* Sell his shares */
|
/* Sell his shares */
|
||||||
|
|
|
@ -2239,14 +2239,33 @@ bool AfterLoadGame()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update go to buoy orders because they are just waypoints */
|
|
||||||
if (CheckSavegameVersion(84)) {
|
if (CheckSavegameVersion(84)) {
|
||||||
|
/* Update go to buoy orders because they are just waypoints */
|
||||||
Order *order;
|
Order *order;
|
||||||
FOR_ALL_ORDERS(order) {
|
FOR_ALL_ORDERS(order) {
|
||||||
if (order->type == OT_GOTO_STATION && GetStation(order->dest)->IsBuoy()) {
|
if (order->type == OT_GOTO_STATION && GetStation(order->dest)->IsBuoy()) {
|
||||||
order->flags = 0;
|
order->flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set all share owners to PLAYER_SPECTATOR for
|
||||||
|
* 1) all inactive players
|
||||||
|
* (when inactive players were stored in the savegame - TTD, TTDP and some
|
||||||
|
* *really* old revisions of OTTD; else it is already set in InitializePlayers())
|
||||||
|
* 2) shares that are owned by inactive players or self
|
||||||
|
* (caused by cheating players in earlier revisions) */
|
||||||
|
Player *p;
|
||||||
|
FOR_ALL_PLAYERS(p) {
|
||||||
|
if (!p->is_active) {
|
||||||
|
for (uint i = 0; i < 4; i++) { p->share_owners[i] = PLAYER_SPECTATOR; }
|
||||||
|
} else {
|
||||||
|
for (uint i = 0; i < 4; i++) {
|
||||||
|
PlayerID o = p->share_owners[i];
|
||||||
|
if (o == PLAYER_SPECTATOR) continue;
|
||||||
|
if (!IsValidPlayer(o) || o == p->index || !GetPlayer(o)->is_active) p->share_owners[i] = PLAYER_SPECTATOR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return InitializeWindowsAndCaches();
|
return InitializeWindowsAndCaches();
|
||||||
|
|
|
@ -544,7 +544,10 @@ static void MaybeStartNewPlayer()
|
||||||
void InitializePlayers()
|
void InitializePlayers()
|
||||||
{
|
{
|
||||||
memset(_players, 0, sizeof(_players));
|
memset(_players, 0, sizeof(_players));
|
||||||
for (PlayerID i = PLAYER_FIRST; i != MAX_PLAYERS; i++) _players[i].index = i;
|
for (PlayerID i = PLAYER_FIRST; i != MAX_PLAYERS; i++) {
|
||||||
|
_players[i].index = i;
|
||||||
|
for (uint j = 0; j < 4; j++) _players[i].share_owners[j] = PLAYER_SPECTATOR;
|
||||||
|
}
|
||||||
_cur_player_tick_index = 0;
|
_cur_player_tick_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue