(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.

This commit is contained in:
rubidium 2007-06-21 14:32:27 +00:00
parent 06fded123a
commit f806b46cc9
25 changed files with 94 additions and 82 deletions

View File

@ -132,7 +132,7 @@ static void AiStateVehLoop(Player *p)
p->ai.state_counter = 0;
}
static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag, TileIndex tile)
static EngineID AiChooseTrainToBuild(RailType railtype, Money money, byte flag, TileIndex tile)
{
EngineID best_veh_index = INVALID_ENGINE;
byte best_veh_score = 0;
@ -161,7 +161,7 @@ static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag,
return best_veh_index;
}
static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex tile)
static EngineID AiChooseRoadVehToBuild(CargoID cargo, Money money, TileIndex tile)
{
EngineID best_veh_index = INVALID_ENGINE;
int32 best_veh_rating = 0;
@ -199,10 +199,10 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex til
return best_veh_index;
}
static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
static EngineID AiChooseAircraftToBuild(Money money, byte flag)
{
EngineID best_veh_index = INVALID_ENGINE;
int32 best_veh_cost = 0;
Money best_veh_cost = 0;
EngineID i;
for (i = AIRCRAFT_ENGINES_INDEX; i != AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
@ -225,9 +225,9 @@ static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
return best_veh_index;
}
static int32 AiGetBasePrice(const Player* p)
static Money AiGetBasePrice(const Player* p)
{
int32 base = _price.station_value;
Money base = _price.station_value;
// adjust base price when more expensive vehicles are available
switch (p->ai.railtype_to_use) {
@ -242,7 +242,7 @@ static int32 AiGetBasePrice(const Player* p)
}
#if 0
static EngineID AiChooseShipToBuild(byte cargo, int32 money)
static EngineID AiChooseShipToBuild(byte cargo, Money money)
{
// XXX: not done
return INVALID_ENGINE;
@ -251,13 +251,13 @@ static EngineID AiChooseShipToBuild(byte cargo, int32 money)
static EngineID AiChooseRoadVehToReplaceWith(const Player* p, const Vehicle* v)
{
int32 avail_money = p->player_money + v->value;
Money avail_money = p->player_money + v->value;
return AiChooseRoadVehToBuild(v->cargo_type, avail_money, v->tile);
}
static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
{
int32 avail_money = p->player_money + v->value;
Money avail_money = p->player_money + v->value;
return AiChooseAircraftToBuild(
avail_money, AircraftVehInfo(v->engine_type)->subtype & AIR_CTOL
);
@ -265,7 +265,7 @@ static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
{
int32 avail_money = p->player_money + v->value;
Money avail_money = p->player_money + v->value;
const Vehicle* u = v;
int num = 0;
@ -3901,7 +3901,7 @@ static void AiHandleTakeover(Player *p)
static void AiAdjustLoan(const Player* p)
{
int32 base = AiGetBasePrice(p);
Money base = AiGetBasePrice(p);
if (p->player_money > base * 1400) {
// Decrease loan

View File

@ -97,7 +97,6 @@ static void AiNew_State_Nothing(Player *p)
// - Build HQ
static void AiNew_State_WakeUp(Player *p)
{
int32 money;
int c;
assert(p->ainew.state == AI_STATE_WAKE_UP);
// First, check if we have a HQ
@ -111,7 +110,7 @@ static void AiNew_State_WakeUp(Player *p)
return;
}
money = p->player_money - AI_MINIMUM_MONEY;
Money money = p->player_money - AI_MINIMUM_MONEY;
// Let's pick an action!
if (p->ainew.action == AI_ACTION_NONE) {

View File

@ -347,7 +347,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->subtype = (avi->subtype & AIR_CTOL ? AIR_AIRCRAFT : AIR_HELICOPTER);
v->UpdateDeltaXY(INVALID_DIR);
v->value = (uint32)value.GetCost();
v->value = value.GetCost();
u->subtype = AIR_SHADOW;
u->UpdateDeltaXY(INVALID_DIR);

View File

@ -124,7 +124,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type)
* @param flags is the flags to use when calling DoCommand(). Mainly DC_EXEC counts
* @return value is cost of the replacement or CMD_ERROR
*/
static CommandCost ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost)
{
CommandCost cost;
CommandCost sell_value;

View File

@ -22,7 +22,7 @@ static struct BridgeData {
TileIndex end_tile;
byte type;
byte indexes[MAX_BRIDGES];
int32 costs[MAX_BRIDGES];
Money costs[MAX_BRIDGES];
} _bridgedata;
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)

View File

@ -206,9 +206,9 @@ static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b)
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
int va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int r = va - vb;
Money va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
Money vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int r = ClampToI32(va - vb);
return _internal_sort_order ? -r : r;
}
@ -224,9 +224,9 @@ static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *
* Because of this, the return value have to be reversed as well and we return b - a instead of a - b.
* Another thing is that both power and running costs should be doubled for multiheaded engines.
* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */
int va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power);
int vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power);
int r = vb - va;
Money va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power);
Money vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power);
int r = ClampToI32(vb - va);
return _internal_sort_order ? -r : r;
}

View File

@ -418,10 +418,10 @@ error:
return res;
}
int32 GetAvailableMoneyForCommand()
Money GetAvailableMoneyForCommand()
{
PlayerID pid = _current_player;
if (!IsValidPlayer(pid)) return 0x7FFFFFFF; // max int
if (!IsValidPlayer(pid)) return INT64_MAX;
return GetPlayer(pid)->player_money;
}
@ -568,7 +568,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (IsLocalPlayer() && _game_mode != GM_EDITOR) {
if (res2.GetCost() != 0) ShowCostOrIncomeAnimation(x, y, GetSlopeZ(x, y), res2.GetCost());
if (_additional_cash_required) {
if (_additional_cash_required != 0) {
SetDParam(0, _additional_cash_required);
ShowErrorMessage(STR_0003_NOT_ENOUGH_CASH_REQUIRES, error_part1, x, y);
if (res2.GetCost() == 0) goto callb_err;

View File

@ -212,6 +212,6 @@ extern const char* _cmd_text; ///< Text, which gets sent with a command
bool IsValidCommand(uint cmd);
byte GetCommandFlags(uint cmd);
int32 GetAvailableMoneyForCommand();
Money GetAvailableMoneyForCommand();
#endif /* COMMAND_H */

View File

@ -112,7 +112,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Count vehicles */
{
Vehicle *v;
int32 min_profit = 0;
Money min_profit = 0;
bool min_profit_first = true;
uint num = 0;
@ -135,7 +135,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
_score_part[owner][SCORE_VEHICLES] = num;
/* Don't allow negative min_profit to show */
if (min_profit > 0)
_score_part[owner][SCORE_MIN_PROFIT] = min_profit;
_score_part[owner][SCORE_MIN_PROFIT] = ClampToI32(min_profit);
}
/* Count stations */
@ -163,9 +163,9 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
} while (++pee,--numec);
if (min_income > 0)
_score_part[owner][SCORE_MIN_INCOME] = min_income;
_score_part[owner][SCORE_MIN_INCOME] = ClampToI32(min_income);
_score_part[owner][SCORE_MAX_INCOME] = max_income;
_score_part[owner][SCORE_MAX_INCOME] = ClampToI32(max_income);
}
}
@ -196,15 +196,14 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
/* Generate score for player money */
{
int32 money = p->player_money;
if (money > 0) {
_score_part[owner][SCORE_MONEY] = money;
if (p->player_money > 0) {
_score_part[owner][SCORE_MONEY] = ClampToI32(p->player_money);
}
}
/* Generate score for loan */
{
_score_part[owner][SCORE_LOAN] = _score_info[SCORE_LOAN].needed - p->current_loan;
_score_part[owner][SCORE_LOAN] = ClampToI32(_score_info[SCORE_LOAN].needed - p->current_loan);
}
/* Now we calculate the score for each item.. */
@ -438,7 +437,6 @@ static void ChangeNetworkOwner(PlayerID current_player, PlayerID new_player)
static void PlayersCheckBankrupt(Player *p)
{
PlayerID owner;
int64 val;
/* If the player has money again, it does not go bankrupt */
if (p->player_money >= 0) {
@ -466,7 +464,7 @@ static void PlayersCheckBankrupt(Player *p)
/* Check if the company has any value.. if not, declare it bankrupt
* right now */
val = CalculateCompanyValue(p);
Money val = CalculateCompanyValue(p);
if (val > 0) {
p->bankrupt_value = val;
p->bankrupt_asked = 1 << owner; // Don't ask the owner
@ -1319,11 +1317,11 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
return false;
}
static int32 DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit)
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit)
{
bool subsidised;
Station *s_from, *s_to;
int32 profit;
Money profit;
assert(num_pieces > 0);
@ -1511,7 +1509,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
bool anything_loaded = false;
uint32 cargo_not_full = 0;
uint32 cargo_full = 0;
int total_cargo_feeder_share = 0; // the feeder cash amount for the goods being loaded/unloaded in this load step
Money total_cargo_feeder_share = 0; // the feeder cash amount for the goods being loaded/unloaded in this load step
v->cur_speed = 0;
@ -1603,7 +1601,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
/* if last speed is 0, we treat that as if no vehicle has ever visited the station. */
ge->days_since_pickup = 0;
ge->last_speed = min(t, 255);
ge->last_age = _cur_year - v->build_year;
ge->last_age = _cur_year - u->build_year;
/* If there's goods waiting at the station, and the vehicle
* has capacity for it, load it on the vehicle. */
@ -1643,7 +1641,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
* ge->unload_pending holds the amount that has been credited, but has not yet been unloaded.
*/
int cargoshare = cap * 10000 / (ge->waiting_acceptance + ge->unload_pending);
int feeder_profit_share = ge->feeder_profit * cargoshare / 10000;
Money feeder_profit_share = ge->feeder_profit * cargoshare / 10000;
v->cargo_count += cap;
ge->waiting_acceptance -= cap;

View File

@ -410,7 +410,9 @@ void ChangeWorkingDirectory(const char *exe)
void DetermineBasePaths(const char *exe)
{
char tmp[MAX_PATH];
#ifdef WITH_PERSONAL_DIR
#if defined(__MORPHOS__) || defined(__AMIGA__) || !defined(WITH_PERSONAL_DIR)
_searchpaths[SP_PERSONAL_DIR] = NULL;
#else
const char *homedir = getenv("HOME");
if (homedir == NULL) {
@ -422,14 +424,16 @@ void DetermineBasePaths(const char *exe)
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
#else
_searchpaths[SP_PERSONAL_DIR] = NULL;
#endif
_searchpaths[SP_SHARED_DIR] = NULL;
#if defined(__MORPHOS__) || defined(__AMIGA__)
_searchpaths[SP_WORKING_DIR] = NULL;
#else
getcwd(tmp, MAX_PATH);
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_WORKING_DIR] = strdup(tmp);
#endif
/* Change the working directory to that one of the executable */
ChangeWorkingDirectory((char*)exe);
@ -437,9 +441,13 @@ void DetermineBasePaths(const char *exe)
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_BINARY_DIR] = strdup(tmp);
#if defined(__MORPHOS__) || defined(__AMIGA__)
_searchpaths[SP_INSTALLATION_DIR] = NULL;
#else
snprintf(tmp, MAX_PATH, "%s", GLOBAL_DATA_DIR);
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_INSTALLATION_DIR] = strdup(tmp);
#endif
#ifdef WITH_COCOA
extern void cocoaSetApplicationBundleDir();
cocoaSetApplicationBundleDir();

View File

@ -139,8 +139,8 @@ void DrawSprite(SpriteID img, SpriteID pal, int x, int y);
bool EnsureNoVehicle(TileIndex tile);
bool EnsureNoVehicleOnGround(TileIndex tile);
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost);
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost);
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost);
bool CheckIfAuthorityAllows(TileIndex tile);
Town *ClosestTownFromTile(TileIndex tile, uint threshold);

View File

@ -105,7 +105,7 @@ void ShowPlayerStations(PlayerID player);
void ShowPlayerFinances(PlayerID player);
void ShowPlayerCompany(PlayerID player);
void ShowEstimatedCostOrIncome(int32 cost, int x, int y);
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
void DrawStationCoverageAreaText(int sx, int sy, uint mask,int rad);

View File

@ -51,6 +51,14 @@ static inline uint clampu(uint a, uint min, uint max)
return a;
}
/* Gracefully reduce a signed 64-bit int to signed 32-bit -- no bogusly truncating the sign bit */
static inline int32 ClampToI32(int64 a)
{
if (a <= (int32)0x80000000) return 0x80000000;
if (a >= (int32)0x7FFFFFFF) return 0x7FFFFFFF;
return (int32)a;
}
static inline int32 BIGMULSS(int32 a, int32 b, int shift)
{
return (int32)((int64)a * (int64)b >> shift);

View File

@ -94,10 +94,10 @@ void HandleOnEditText(const char *str)
const Player *p = GetPlayer(_current_player);
Money money = min(p->player_money - p->current_loan, atoi(str) / _currency->rate);
money = clamp(money, 0, 20000000); // Clamp between 20 million and 0
uint32 money_c = clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
/* Give 'id' the money, and substract it from ourself */
DoCommandP(0, money, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS));
} break;
#endif /* ENABLE_NETWORK */
default: NOT_REACHED();

View File

@ -104,7 +104,7 @@ static void Place_LandInfo(TileIndex tile)
t = ClosestTownFromTile(tile, _patches.dist_local_authority);
old_money = p->player_money;
p->player_money = 0x7fffffff;
p->player_money = INT64_MAX;
costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
p->player_money = old_money;
@ -610,7 +610,7 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
}
void ShowEstimatedCostOrIncome(int32 cost, int x, int y)
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
{
StringID msg = STR_0805_ESTIMATED_COST;
@ -622,7 +622,7 @@ void ShowEstimatedCostOrIncome(int32 cost, int x, int y)
ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
}
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost)
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
{
StringID msg;
Point pt = RemapCoords(x,y,z);
@ -636,7 +636,7 @@ void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost)
AddTextEffect(msg, pt.x, pt.y, 0x250);
}
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost)
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
{
Point pt = RemapCoords(x,y,z);

View File

@ -44,9 +44,9 @@ struct NetworkPlayerInfo {
char company_name[NETWORK_NAME_LENGTH]; // Company name
char password[NETWORK_PASSWORD_LENGTH]; // The password for the player
Year inaugurated_year; // What year the company started in
int64 company_value; // The company value
int64 money; // The amount of money the company has
int64 income; // How much did the company earned last year
Money company_value; // The company value
Money money; // The amount of money the company has
Money income; // How much did the company earned last year
uint16 performance; // What was his performance last month?
bool use_password; // Is there a password
uint16 num_vehicle[NETWORK_VEHICLE_TYPES]; // How many vehicles are there of this type?

View File

@ -727,19 +727,19 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
case 0x4F: return GB(v->reliability, 8, 8);
case 0x50: return v->reliability_spd_dec;
case 0x51: return GB(v->reliability_spd_dec, 8, 8);
case 0x52: return v->profit_this_year;
case 0x53: return GB(v->profit_this_year, 8, 24);
case 0x54: return GB(v->profit_this_year, 16, 16);
case 0x55: return GB(v->profit_this_year, 24, 8);
case 0x56: return v->profit_last_year;
case 0x57: return GB(v->profit_last_year, 8, 24);
case 0x58: return GB(v->profit_last_year, 16, 16);
case 0x59: return GB(v->profit_last_year, 24, 8);
case 0x52: return ClampToI32(v->profit_this_year);
case 0x53: return GB(ClampToI32(v->profit_this_year), 8, 24);
case 0x54: return GB(ClampToI32(v->profit_this_year), 16, 16);
case 0x55: return GB(ClampToI32(v->profit_this_year), 24, 8);
case 0x56: return ClampToI32(v->profit_last_year);
case 0x57: return GB(ClampToI32(v->profit_last_year), 8, 24);
case 0x58: return GB(ClampToI32(v->profit_last_year), 16, 16);
case 0x59: return GB(ClampToI32(v->profit_last_year), 24, 8);
case 0x5A: return v->next == NULL ? INVALID_VEHICLE : v->next->index;
case 0x5C: return v->value;
case 0x5D: return GB(v->value, 8, 24);
case 0x5E: return GB(v->value, 16, 16);
case 0x5F: return GB(v->value, 24, 8);
case 0x5C: return ClampToI32(v->value);
case 0x5D: return GB(ClampToI32(v->value), 8, 24);
case 0x5E: return GB(ClampToI32(v->value), 16, 16);
case 0x5F: return GB(ClampToI32(v->value), 24, 8);
case 0x60: return v->string_id;
case 0x61: return GB(v->string_id, 8, 8);
case 0x72: return v->cargo_subtype;

View File

@ -116,7 +116,7 @@ struct PlayerAiNew {
CargoID cargo;
byte tbt; ///< train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
int new_cost;
Money new_cost;
byte action;

View File

@ -31,8 +31,8 @@ static void DoShowPlayerFinances(PlayerID player, bool show_small, bool show_sti
static void DrawPlayerEconomyStats(const Player *p, byte mode)
{
int x, y, i, j, year;
const int64 (*tbl)[13];
int64 sum, cost;
const Money (*tbl)[13];
Money sum, cost;
StringID str;
if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status

View File

@ -974,7 +974,7 @@ extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bo
CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CommandCost ret, cost;
int32 money;
Money money;
int ex;
int ey;
int sx, sy, x, y;

View File

@ -131,14 +131,14 @@ static int CDECL StationWaitingSorter(const void *a, const void *b)
{
const Station* st1 = *(const Station**)a;
const Station* st2 = *(const Station**)b;
int sum1 = 0, sum2 = 0;
Money sum1 = 0, sum2 = 0;
for (CargoID j = 0; j < NUM_CARGO; j++) {
if (st1->goods[j].waiting_acceptance & 0xfff) sum1 += GetTransportedGoodsIncome(st1->goods[j].waiting_acceptance & 0xfff, 20, 50, j);
if (st2->goods[j].waiting_acceptance & 0xfff) sum2 += GetTransportedGoodsIncome(st2->goods[j].waiting_acceptance & 0xfff, 20, 50, j);
}
return (_internal_sort_order & 1) ? sum2 - sum1 : sum1 - sum2;
return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2);
}
/**

View File

@ -41,7 +41,7 @@ extern const byte _town_action_costs[8];
*/
uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
{
int32 avail, ref;
Money avail, ref;
int num = 0;
uint avail_buttons = 0x7F; // by default all buttons except bribe are enabled.
uint buttons = 0;

View File

@ -1248,7 +1248,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
IsTrainEngine(v)) ? v->u.rail.other_multiheaded_part : NULL;
if (rear != NULL) {
cost.AddCost(-(int64)rear->value);
cost.AddCost(-rear->value);
if (flags & DC_EXEC) {
UnlinkWagon(rear, first);
DeleteDepotHighlightOfVehicle(rear);

View File

@ -286,7 +286,7 @@ VARDEF uint32 _news_display_opt;
VARDEF bool _news_ticker_sound;
VARDEF StringID _error_message;
VARDEF int32 _additional_cash_required;
VARDEF Money _additional_cash_required;
VARDEF uint32 _decode_parameters[20];

View File

@ -589,7 +589,7 @@ static int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
{
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
int r = va->profit_this_year - vb->profit_this_year;
int r = ClampToI32(va->profit_this_year - vb->profit_this_year);
VEHICLEUNITNUMBERSORTER(r, va, vb);
@ -600,7 +600,7 @@ static int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
{
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
int r = va->profit_last_year - vb->profit_last_year;
int r = ClampToI32(va->profit_last_year - vb->profit_last_year);
VEHICLEUNITNUMBERSORTER(r, va, vb);
@ -687,13 +687,12 @@ static int CDECL VehicleValueSorter(const void *a, const void *b)
const Vehicle* va = *(const Vehicle**)a;
const Vehicle* vb = *(const Vehicle**)b;
const Vehicle *u;
int valuea = 0, valueb = 0;
int r;
Money valuea = 0, valueb = 0;
for (u = va; u != NULL; u = u->next) valuea += u->value;
for (u = vb; u != NULL; u = u->next) valueb += u->value;
r = valuea - valueb;
int r = ClampToI32(valuea - valueb);
VEHICLEUNITNUMBERSORTER(r, va, vb);