From 2ee73b50b8dae28f53acabcb5b7c0e3f02139db2 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 18 Jun 2007 21:44:47 +0000 Subject: (svn r10208) -Codechange: replace int32 with Money where appropriate. --- src/players.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/players.cpp') diff --git a/src/players.cpp b/src/players.cpp index efc6056db..f099008ec 100644 --- a/src/players.cpp +++ b/src/players.cpp @@ -188,22 +188,30 @@ bool CheckPlayerHasMoney(CommandCost cost) static void SubtractMoneyFromAnyPlayer(Player *p, CommandCost cost) { - p->player_money -= cost.GetCost(); + CommandCost tmp((int32)p->player_money); + tmp.AddCost(-cost.GetCost()); + p->player_money = tmp.GetCost(); - p->yearly_expenses[0][_yearly_expenses_type] += cost.GetCost(); + tmp = CommandCost((int32)p->yearly_expenses[0][_yearly_expenses_type]); + tmp.AddCost(cost); + p->yearly_expenses[0][_yearly_expenses_type] = tmp.GetCost(); if (HASBIT(1 << EXPENSES_TRAIN_INC | 1 << EXPENSES_ROADVEH_INC | 1 << EXPENSES_AIRCRAFT_INC | 1 << EXPENSES_SHIP_INC, _yearly_expenses_type)) { - p->cur_economy.income -= cost.GetCost(); + tmp = CommandCost(p->cur_economy.income); + tmp.AddCost(-cost.GetCost()); + p->cur_economy.income = tmp.GetCost(); } else if (HASBIT(1 << EXPENSES_TRAIN_RUN | 1 << EXPENSES_ROADVEH_RUN | 1 << EXPENSES_AIRCRAFT_RUN | 1 << EXPENSES_SHIP_RUN | 1 << EXPENSES_PROPERTY | 1 << EXPENSES_LOAN_INT, _yearly_expenses_type)) { - p->cur_economy.expenses -= cost.GetCost(); + tmp = CommandCost(p->cur_economy.expenses); + tmp.AddCost(-cost.GetCost()); + p->cur_economy.expenses = tmp.GetCost(); } InvalidatePlayerWindows(p); @@ -220,7 +228,7 @@ void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cst) { Player *p = GetPlayer(player); byte m = p->player_money_fraction; - int32 cost = cst.GetCost(); + Money cost = cst.GetCost(); p->player_money_fraction = m - (byte)cost; cost >>= 8; -- cgit v1.2.3-70-g09d2