(svn r10207) -Codechange: remove the redundant player_money in favour of the money64, which is now renamed to player_money.
--- a/src/autoreplace_cmd.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/autoreplace_cmd.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -260,7 +260,7 @@
/* Ensure that the player will not end up having negative money while autoreplacing
* This is needed because the only other check is done after the income from selling the old vehicle is substracted from the cost */
- if (CmdFailed(tmp_move) || p->money64 < (cost.GetCost() + total_cost)) {
+ if (CmdFailed(tmp_move) || p->player_money < (cost.GetCost() + total_cost)) {
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
/* Pay back the loan */
sell_value.MultiplyCost(-1);
@@ -372,8 +372,8 @@
cost.AddCost(temp_cost);
} while (w->type == VEH_TRAIN && (w = GetNextVehicle(w)) != NULL);
- if (!(flags & DC_EXEC) && (p->money64 < (int32)(cost.GetCost() + p->engine_renew_money) || cost.GetCost() == 0)) {
- if (!check && p->money64 < (int32)(cost.GetCost() + p->engine_renew_money) && ( _local_player == v->owner ) && cost.GetCost() != 0) {
+ if (!(flags & DC_EXEC) && (p->player_money < (cost.GetCost() + p->engine_renew_money) || cost.GetCost() == 0)) {
+ if (!check && p->player_money < (cost.GetCost() + p->engine_renew_money) && ( _local_player == v->owner ) && cost.GetCost() != 0) {
StringID message;
SetDParam(0, v->unitnumber);
switch (v->type) {
--- a/src/economy.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/economy.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -88,7 +88,7 @@
}
}
- value += p->money64 - p->current_loan; // add real money value
+ value += p->player_money - p->current_loan; // add real money value
return max(value, 1LL);
}
@@ -287,8 +287,7 @@
* removing his/her property doesn't fail because of lack of money.
* Not too drastically though, because it could overflow */
if (new_player == PLAYER_SPECTATOR) {
- GetPlayer(old_player)->money64 = MAX_UVALUE(uint64) >>2; // jackpot ;p
- UpdatePlayerMoney32(GetPlayer(old_player));
+ GetPlayer(old_player)->player_money = MAX_UVALUE(uint64) >> 2; // jackpot ;p
}
if (new_player == PLAYER_SPECTATOR) {
@@ -1788,9 +1787,8 @@
for (i = 0; i != 4; i++) {
if (p->share_owners[i] != PLAYER_SPECTATOR) {
owner = GetPlayer(p->share_owners[i]);
- owner->money64 += value;
+ owner->player_money += value;
owner->yearly_expenses[0][EXPENSES_OTHER] += value;
- UpdatePlayerMoney32(owner);
}
}
--- a/src/main_gui.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/main_gui.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -92,7 +92,7 @@
#ifdef ENABLE_NETWORK
case 3: { // Give money, you can only give money in excess of loan
const Player *p = GetPlayer(_current_player);
- int32 money = min(p->money64 - p->current_loan, atoi(str) / _currency->rate);
+ int32 money = min(p->player_money - p->current_loan, atoi(str) / _currency->rate);
money = clamp(money, 0, 20000000); // Clamp between 20 million and 0
@@ -2208,7 +2208,7 @@
if (p != NULL) {
/* Draw player money */
- SetDParam64(0, p->money64);
+ SetDParam64(0, p->player_money);
DrawStringCentered(570, 1, p->player_money >= 0 ? STR_0004 : STR_0005, 0);
}
--- a/src/misc_cmd.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/misc_cmd.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -145,9 +145,8 @@
}
if (flags & DC_EXEC) {
- p->money64 += loan;
+ p->player_money += loan;
p->current_loan += loan;
- UpdatePlayerMoney32(p);
InvalidatePlayerWindows(p);
}
@@ -185,9 +184,8 @@
}
if (flags & DC_EXEC) {
- p->money64 -= loan;
+ p->player_money -= loan;
p->current_loan -= loan;
- UpdatePlayerMoney32(p);
InvalidatePlayerWindows(p);
}
return CommandCost();
@@ -311,7 +309,7 @@
SET_EXPENSES_TYPE(EXPENSES_OTHER);
/* You can only transfer funds that is in excess of your loan */
- if (p->money64 - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
+ if (p->player_money - p->current_loan < amount.GetCost() || amount.GetCost() <= 0) return CMD_ERROR;
if (!_networking || !IsValidPlayer((PlayerID)p2)) return CMD_ERROR;
if (flags & DC_EXEC) {
--- a/src/misc_gui.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/misc_gui.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -103,11 +103,10 @@
p = GetPlayer(IsValidPlayer(_local_player) ? _local_player : PLAYER_FIRST);
t = ClosestTownFromTile(tile, _patches.dist_local_authority);
- old_money = p->money64;
- p->money64 = p->player_money = 0x7fffffff;
+ old_money = p->player_money;
+ p->player_money = 0x7fffffff;
costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
- p->money64 = old_money;
- UpdatePlayerMoney32(p);
+ p->player_money = old_money;
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
td.build_date = 0;
--- a/src/network/network_server.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/network/network_server.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -1278,7 +1278,7 @@
// Set some general stuff
_network_player_info[p->index].inaugurated_year = p->inaugurated_year;
_network_player_info[p->index].company_value = p->old_economy[0].company_value;
- _network_player_info[p->index].money = p->money64;
+ _network_player_info[p->index].money = p->player_money;
_network_player_info[p->index].performance = p->old_economy[0].performance_history;
}
--- a/src/oldloader.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/oldloader.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -954,7 +954,7 @@
p->name_1 = RemapOldStringID(_old_string_id);
p->president_name_1 = RemapOldStringID(_old_string_id_2);
- p->money64 = p->player_money;
+ p->player_money = p->player_money;
if (num == 0) {
/* If the first player has no name, make sure we call it UNNAMED */
@@ -972,7 +972,7 @@
Ps: this also means that if you had exact 893288 pounds, you will go back
to 10000.. this is a very VERY small chance ;) */
if (p->player_money == 893288)
- p->money64 = p->player_money = p->current_loan = 100000;
+ p->player_money = p->current_loan = 100000;
_player_colors[num] = p->player_color;
p->inaugurated_year -= ORIGINAL_BASE_YEAR;
--- a/src/player.h Mon Jun 18 20:08:21 2007 +0000
+++ b/src/player.h Mon Jun 18 21:00:14 2007 +0000
@@ -166,9 +166,8 @@
PlayerFace face;
- int32 player_money;
int32 current_loan;
- int64 money64; ///< internal 64-bit version of the money. the 32-bit field will be clamped to plus minus 2 billion
+ int64 player_money;
byte player_color;
Livery livery[LS_END];
@@ -215,7 +214,6 @@
void GetNameOfOwner(Owner owner, TileIndex tile);
int64 CalculateCompanyValue(const Player* p);
void InvalidatePlayerWindows(const Player* p);
-void UpdatePlayerMoney32(Player *p);
void SetLocalPlayer(PlayerID new_player);
#define FOR_ALL_PLAYERS(p) for (p = _players; p != endof(_players); p++)
--- a/src/player_gui.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/player_gui.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -87,7 +87,7 @@
}
DrawString(2, y, STR_7026_BANK_BALANCE, 0);
- SetDParam64(0, p->money64);
+ SetDParam64(0, p->player_money);
DrawStringRightAligned(182, y, STR_7028, 0);
y += 10;
@@ -100,7 +100,7 @@
GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
- SetDParam64(0, p->money64 - p->current_loan);
+ SetDParam64(0, p->player_money - p->current_loan);
DrawStringRightAligned(182, y, STR_7028, 0);
}
--- a/src/players.cpp Mon Jun 18 20:08:21 2007 +0000
+++ b/src/players.cpp Mon Jun 18 21:00:14 2007 +0000
@@ -188,8 +188,7 @@
static void SubtractMoneyFromAnyPlayer(Player *p, CommandCost cost)
{
- p->money64 -= cost.GetCost();
- UpdatePlayerMoney32(p);
+ p->player_money -= cost.GetCost();
p->yearly_expenses[0][_yearly_expenses_type] += cost.GetCost();
@@ -229,18 +228,6 @@
if (cost != 0) SubtractMoneyFromAnyPlayer(p, CommandCost(cost));
}
-/** the player_money field is kept as it is, but money64 contains the actual amount of money. */
-void UpdatePlayerMoney32(Player *p)
-{
- if (p->money64 < -2000000000) {
- p->player_money = -2000000000;
- } else if (p->money64 > 2000000000) {
- p->player_money = 2000000000;
- } else {
- p->player_money = (int32)p->money64;
- }
-}
-
void GetNameOfOwner(Owner owner, TileIndex tile)
{
SetDParam(2, owner);
@@ -474,7 +461,7 @@
p->name_1 = STR_SV_UNNAMED;
p->is_active = true;
- p->money64 = p->player_money = p->current_loan = 100000;
+ p->player_money = p->current_loan = 100000;
p->is_ai = is_ai;
p->ai.state = 5; // AIS_WANT_NEW_ROUTE
@@ -1135,8 +1122,8 @@
SLE_VAR(Player, face, SLE_UINT32),
/* money was changed to a 64 bit field in savegame version 1. */
- SLE_CONDVAR(Player, money64, SLE_VAR_I64 | SLE_FILE_I32, 0, 0),
- SLE_CONDVAR(Player, money64, SLE_INT64, 1, SL_MAX_VERSION),
+ SLE_CONDVAR(Player, player_money, SLE_VAR_I64 | SLE_FILE_I32, 0, 0),
+ SLE_CONDVAR(Player, player_money, SLE_INT64, 1, SL_MAX_VERSION),
SLE_VAR(Player, current_loan, SLE_INT32),
@@ -1318,7 +1305,6 @@
Player *p = GetPlayer((PlayerID)index);
SaveLoad_PLYR(p);
_player_colors[index] = p->player_color;
- UpdatePlayerMoney32(p);
/* This is needed so an AI is attached to a loaded AI */
if (p->is_ai && (!_networking || _network_server) && _ai.enabled)