Mercurial > hg > openttd
comparison src/main_gui.cpp @ 7505:6690e0a3bb53 draft
(svn r11020) -Fix [FS#1174]: One could not give money when (s)he had too much money or rather: when casting the amount of money to an int32 becomes negative.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 31 Aug 2007 17:38:29 +0000 |
parents | a430b752ee98 |
children | f5b39ff47e0e |
comparison
equal
deleted
inserted
replaced
7504:9361748d367b | 7505:6690e0a3bb53 |
---|---|
88 DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); | 88 DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME)); |
89 break; | 89 break; |
90 #ifdef ENABLE_NETWORK | 90 #ifdef ENABLE_NETWORK |
91 case 3: { // Give money, you can only give money in excess of loan | 91 case 3: { // Give money, you can only give money in excess of loan |
92 const Player *p = GetPlayer(_current_player); | 92 const Player *p = GetPlayer(_current_player); |
93 Money money = min(p->player_money - p->current_loan, atoi(str) / _currency->rate); | 93 Money money = min(p->player_money - p->current_loan, (Money)(atoi(str) / _currency->rate)); |
94 | 94 |
95 uint32 money_c = clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0 | 95 uint32 money_c = clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0 |
96 | 96 |
97 /* Give 'id' the money, and substract it from ourself */ | 97 /* Give 'id' the money, and substract it from ourself */ |
98 DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS)); | 98 DoCommandP(0, money_c, id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS)); |