@@ -241,42 +241,47 @@ int UpdateCompanyRatingAndValue(Player *
// use OWNER_SPECTATOR as new_player to delete the player.
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
{
PlayerID old = _current_player;
_current_player = old_player;
/* Temporarily increase the player's money, to be sure that
* removing his/her property doesn't fail because of lack of money */
if (new_player == OWNER_SPECTATOR) {
GetPlayer(old_player)->money64 = ((uint64)-1)>>1; // jackpot ;p
}
Subsidy *s;
for (s = _subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age >= 12) {
if (GetStation(s->to)->owner == old_player) s->cargo_type = CT_INVALID;
/* Take care of rating in towns */
{ Town *t;
if (new_player != OWNER_SPECTATOR) {
FOR_ALL_TOWNS(t) {
/* If a player takes over, give the ratings to that player. */
if (IsValidTown(t) && HASBIT(t->have_ratings, old_player)) {
if (HASBIT(t->have_ratings, new_player)) {
// use max of the two ratings.
t->ratings[new_player] = max(t->ratings[new_player], t->ratings[old_player]);
} else {
SETBIT(t->have_ratings, new_player);
t->ratings[new_player] = t->ratings[old_player];
Town *t;
/* Reset ratings for the town */
if (IsValidTown(t)) {
t->ratings[old_player] = 500;
CLRBIT(t->have_ratings, old_player);
int num_train = 0;
@@ -432,14 +437,13 @@ static void PlayersCheckBankrupt(Player
if (IS_HUMAN_PLAYER(owner) && owner == _local_player) {
// Switch the player to spectator..
_local_player = OWNER_SPECTATOR;
#endif /* ENABLE_NETWORK */
// Convert everything the player owns to NO_OWNER
p->money64 = p->player_money = 100000000;
/* Remove the player */
ChangeOwnershipOfPlayerItems(owner, OWNER_SPECTATOR);
// Register the player as not-active
p->is_active = false;
if (!IS_HUMAN_PLAYER(owner) && (!_networking || _network_server) && _ai.enabled)
AI_PlayerDied(owner);
@@ -768,22 +768,24 @@ void SwitchMode(int new_mode)
break;
case SM_LOAD_SCENARIO: { /* Load scenario from scenario editor */
if (SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_EDITOR)) {
PlayerID i;
Player *p;
_opt_ptr = &_opt;
_local_player = OWNER_NONE;
_generating_world = true;
// delete all players.
for (i = 0; i != MAX_PLAYERS; i++) {
ChangeOwnershipOfPlayerItems(i, OWNER_SPECTATOR);
_players[i].is_active = false;
/* Delete all players */
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
ChangeOwnershipOfPlayerItems(p->index, OWNER_SPECTATOR);
_generating_world = false;
// delete all stations owned by a player
DeleteAllPlayerStations();
ShowErrorMessage(INVALID_STRING_ID, STR_4009_GAME_LOAD_FAILED, 0, 0);
@@ -910,13 +910,12 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
AddNewsItem( (StringID)(p->index + 16*3), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
/* Remove the company */
p->money64 = p->player_money = 100000000; // XXX - wtf?
RemoveAllEngineReplacementForPlayer(p);
} break;
Status change: