summaryrefslogtreecommitdiff
path: root/economy.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-08-14 11:44:19 +0000
committerDarkvater <darkvater@openttd.org>2006-08-14 11:44:19 +0000
commit01cd75cc10a9a9d2cd1687b9914a5e7dfc4888c3 (patch)
tree82c7c2e1fac461511a05bfa1c29cf9eed5fa1d8c /economy.c
parent4b030f190c93a46e760808faaf9cd719605b02f0 (diff)
downloadopenttd-01cd75cc10a9a9d2cd1687b9914a5e7dfc4888c3.tar.xz
(svn r5886) -Fix [FS#273]: Incomplete removal of player owned property due to lack of money.
Diffstat (limited to 'economy.c')
-rw-r--r--economy.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/economy.c b/economy.c
index 7eb6a7da5..9794adb29 100644
--- a/economy.c
+++ b/economy.c
@@ -244,6 +244,12 @@ 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
+ }
+
if (new_player == OWNER_SPECTATOR) {
Subsidy *s;
@@ -255,25 +261,24 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
}
/* 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];
- }
+ if (new_player != OWNER_SPECTATOR) {
+ Town *t;
+ 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];
}
+ }
- /* Reset ratings for the town */
- if (IsValidTown(t)) {
- t->ratings[old_player] = 500;
- CLRBIT(t->have_ratings, old_player);
- }
+ /* Reset ratings for the town */
+ if (IsValidTown(t)) {
+ t->ratings[old_player] = 500;
+ CLRBIT(t->have_ratings, old_player);
}
}
}
@@ -435,8 +440,7 @@ static void PlayersCheckBankrupt(Player *p)
}
#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;