mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-20 12:09:32 +01:00
(svn r2303) - CodeChange (fix): when giving money to other players only allow transferring money that is above your loan. Eg you can't give away your loan.
- Langfix: 'goes down by' 'increases', vv for down in english.txt.
This commit is contained in:
parent
d19438f858
commit
0ff942f560
@ -1806,8 +1806,8 @@ STR_4838_IMPROVED_FARMING_METHODS :{BLACK}{BIGFONT
|
|||||||
STR_4839_PRODUCTION_DOWN_BY_50 :{BLACK}{BIGFONT}{TOWN} {STRING} production down by 50%
|
STR_4839_PRODUCTION_DOWN_BY_50 :{BLACK}{BIGFONT}{TOWN} {STRING} production down by 50%
|
||||||
STR_483A_INSECT_INFESTATION_CAUSES :{BLACK}{BIGFONT}Insect infestation causes havoc at {TOWN} {STRING}!{}Production down by 50%
|
STR_483A_INSECT_INFESTATION_CAUSES :{BLACK}{BIGFONT}Insect infestation causes havoc at {TOWN} {STRING}!{}Production down by 50%
|
||||||
STR_483B_CAN_ONLY_BE_POSITIONED :{WHITE}...can only be positioned near edges of map
|
STR_483B_CAN_ONLY_BE_POSITIONED :{WHITE}...can only be positioned near edges of map
|
||||||
STR_INDUSTRY_PROD_GOUP :{BLACK}{BIGFONT}{STRING} production at {TOWN} {STRING} goes up by {COMMA16}%!
|
STR_INDUSTRY_PROD_GOUP :{BLACK}{BIGFONT}{STRING} production at {TOWN} {STRING} increases {COMMA16}%!
|
||||||
STR_INDUSTRY_PROD_GODOWN :{BLACK}{BIGFONT}{STRING} production at {TOWN} {STRING} goes down by {COMMA16}%!
|
STR_INDUSTRY_PROD_GODOWN :{BLACK}{BIGFONT}{STRING} production at {TOWN} {STRING} decreases {COMMA16}%!
|
||||||
|
|
||||||
##id 0x5000
|
##id 0x5000
|
||||||
STR_5000_TRAIN_IN_TUNNEL :{WHITE}Train in tunnel
|
STR_5000_TRAIN_IN_TUNNEL :{WHITE}Train in tunnel
|
||||||
@ -2034,6 +2034,7 @@ STR_702C_CAN_T_BORROW_ANY_MORE_MONEY :{WHITE}Can't bo
|
|||||||
STR_702D_LOAN_ALREADY_REPAYED :{WHITE}...no loan to repay
|
STR_702D_LOAN_ALREADY_REPAYED :{WHITE}...no loan to repay
|
||||||
STR_702E_REQUIRED :{WHITE}...{CURRENCY} required
|
STR_702E_REQUIRED :{WHITE}...{CURRENCY} required
|
||||||
STR_702F_CAN_T_REPAY_LOAN :{WHITE}Can't repay loan...
|
STR_702F_CAN_T_REPAY_LOAN :{WHITE}Can't repay loan...
|
||||||
|
STR_INSUFFICIENT_FUNDS :{WHITE}Can't give away money that is loaned from the bank...
|
||||||
STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT :{BLACK}Select new face for manager
|
STR_7030_SELECT_NEW_FACE_FOR_PRESIDENT :{BLACK}Select new face for manager
|
||||||
STR_7031_CHANGE_THE_COMPANY_VEHICLE :{BLACK}Change the company vehicle livery
|
STR_7031_CHANGE_THE_COMPANY_VEHICLE :{BLACK}Change the company vehicle livery
|
||||||
STR_7032_CHANGE_THE_PRESIDENT_S :{BLACK}Change the manager's name
|
STR_7032_CHANGE_THE_PRESIDENT_S :{BLACK}Change the manager's name
|
||||||
|
33
main_gui.c
33
main_gui.c
@ -59,43 +59,41 @@ void HandleOnEditTextCancel(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleOnEditText(WindowEvent *e) {
|
void HandleOnEditText(WindowEvent *e)
|
||||||
|
{
|
||||||
const char *b = e->edittext.str;
|
const char *b = e->edittext.str;
|
||||||
int id;
|
int id;
|
||||||
memcpy(_decode_parameters, b, 32);
|
memcpy(_decode_parameters, b, 32);
|
||||||
|
|
||||||
id = _rename_id;
|
id = _rename_id;
|
||||||
|
|
||||||
switch(_rename_what) {
|
switch (_rename_what) {
|
||||||
case 0:
|
case 0: /* Rename a s sign, if string is empty, delete sign */
|
||||||
// for empty string send "remove sign" parameter
|
|
||||||
DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME));
|
DoCommandP(0, id, 0, NULL, CMD_RENAME_SIGN | CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1: /* Rename a waypoint */
|
||||||
if(*b == 0)
|
if (*b == 0) return;
|
||||||
return;
|
|
||||||
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
|
DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
|
||||||
break;
|
break;
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
case 2:
|
case 2: /* Speak to.. */
|
||||||
// Speak to..
|
|
||||||
if (!_network_server)
|
if (!_network_server)
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str);
|
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str);
|
||||||
else
|
else
|
||||||
NetworkServer_HandleChat(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str, NETWORK_SERVER_INDEX);
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT + (id & 0xFF), id & 0xFF, (id >> 8) & 0xFF, e->edittext.str, NETWORK_SERVER_INDEX);
|
||||||
break;
|
break;
|
||||||
case 3: {
|
case 3: { /* Give money, you can only give money in excess of loan */
|
||||||
// Give money
|
const Player *p = DEREF_PLAYER(_current_player);
|
||||||
int32 money = atoi(e->edittext.str) / GetCurrentCurrencyRate();
|
int32 money = min(p->money64 - p->current_loan, atoi(e->edittext.str) / GetCurrentCurrencyRate());
|
||||||
char msg[100];
|
char msg[20];
|
||||||
|
|
||||||
money = clamp(money, 0, 0xFFFFFF); // Clamp between 16 million and 0
|
money = clamp(money, 0, 20000000); // Clamp between 20 million and 0
|
||||||
|
|
||||||
// Give 'id' the money, and substract it from ourself
|
// Give 'id' the money, and substract it from ourself
|
||||||
if (!DoCommandP(0, money, id, NULL, CMD_GIVE_MONEY)) break;
|
if (!DoCommandP(0, money, id, NULL, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS))) break;
|
||||||
|
|
||||||
// Inform the player of this action
|
// Inform the player of this action
|
||||||
snprintf(msg, 100, "%d", money);
|
snprintf(msg, sizeof(msg), "%d", money);
|
||||||
|
|
||||||
if (!_network_server)
|
if (!_network_server)
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg);
|
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg);
|
||||||
@ -103,10 +101,9 @@ void HandleOnEditText(WindowEvent *e) {
|
|||||||
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg, NETWORK_SERVER_INDEX);
|
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg, NETWORK_SERVER_INDEX);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {// Game-Password and Company-Password
|
case 4: /* Game-Password and Company-Password */
|
||||||
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(id, e->edittext.str);
|
SEND_COMMAND(PACKET_CLIENT_PASSWORD)(id, e->edittext.str);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
misc_cmd.c
20
misc_cmd.c
@ -208,26 +208,34 @@ int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Transfer funds (money) from one player to another.
|
/** Transfer funds (money) from one player to another.
|
||||||
|
* To prevent abuse in multiplayer games you can only send money to other
|
||||||
|
* players if you have paid off your loan (either explicitely, or implicitely
|
||||||
|
* given the fact that you have more money than loan).
|
||||||
* @param x,y unused
|
* @param x,y unused
|
||||||
* @param p1 the amount of money to transfer; max 16.000.000
|
* @param p1 the amount of money to transfer; max 20.000.000
|
||||||
* @param p2 the player to transfer the money to
|
* @param p2 the player to transfer the money to
|
||||||
*/
|
*/
|
||||||
int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
|
const Player *p = DEREF_PLAYER(_current_player);
|
||||||
|
int32 amount = min((int32)p1, 20000000);
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_OTHER);
|
SET_EXPENSES_TYPE(EXPENSES_OTHER);
|
||||||
|
|
||||||
if (!_networking || (int32)p1 <= 0 || p2 >= MAX_PLAYERS) return CMD_ERROR;
|
/* You can only transfer funds that is in excess of your loan */
|
||||||
|
if (p->money64 - p->current_loan < amount || amount <= 0) return CMD_ERROR;
|
||||||
|
if (!_networking || p2 >= MAX_PLAYERS) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
/* Add money to player (cast to signed to prevent 'stealing' money) */
|
/* Add money to player */
|
||||||
PlayerID old_cp = _current_player;
|
PlayerID old_cp = _current_player;
|
||||||
_current_player = p2;
|
_current_player = p2;
|
||||||
SubtractMoneyFromPlayer(-(int32)p1);
|
SubtractMoneyFromPlayer(-amount);
|
||||||
_current_player = old_cp;
|
_current_player = old_cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subtract money from local-player (cast to signed to prevent 'stealing' money) */
|
/* Subtract money from local-player */
|
||||||
return (int32)p1;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Change difficulty level/settings (server-only).
|
/** Change difficulty level/settings (server-only).
|
||||||
|
Loading…
Reference in New Issue
Block a user