Merge branch 'send_money_company' into jgrpp
This commit is contained in:
@@ -47,9 +47,6 @@
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
static int _rename_id = 1;
|
||||
static int _rename_what = -1;
|
||||
|
||||
void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
|
||||
{
|
||||
#ifdef ENABLE_NETWORK
|
||||
@@ -60,36 +57,20 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
|
||||
SetDParam(0, p2);
|
||||
GetString(msg, STR_COMPANY_NAME, lastof(msg));
|
||||
|
||||
/*
|
||||
* bits 31-16: source company
|
||||
* bits 15-0: target company
|
||||
*/
|
||||
uint64 auxdata = (p2 & 0xFFFF) | (((uint64) _local_company) << 16);
|
||||
|
||||
if (!_network_server) {
|
||||
NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, p1);
|
||||
NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_BROADCAST_SS, p2, msg, NetworkTextMessageData(p1, auxdata));
|
||||
} else {
|
||||
NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, CLIENT_ID_SERVER, p1);
|
||||
NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_BROADCAST_SS, p2, msg, CLIENT_ID_SERVER, NetworkTextMessageData(p1, auxdata));
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
|
||||
void HandleOnEditText(const char *str)
|
||||
{
|
||||
switch (_rename_what) {
|
||||
#ifdef ENABLE_NETWORK
|
||||
case 3: { // Give money, you can only give money in excess of loan
|
||||
const Company *c = Company::GetIfValid(_local_company);
|
||||
if (c == NULL) break;
|
||||
Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
|
||||
|
||||
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
|
||||
|
||||
/* Give 'id' the money, and subtract it from ourself */
|
||||
DoCommandP(0, money_c, _rename_id, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_INSUFFICIENT_FUNDS), CcGiveMoney, str);
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
_rename_id = _rename_what = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* This code is shared for the majority of the pushbuttons.
|
||||
* Handles e.g. the pressing of a button (to build things), playing of click sound and sets certain parameters
|
||||
@@ -123,16 +104,6 @@ void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1,
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NETWORK
|
||||
void ShowNetworkGiveMoneyWindow(CompanyID company)
|
||||
{
|
||||
_rename_id = company;
|
||||
_rename_what = 3;
|
||||
ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, NULL, CS_NUMERAL, QSF_NONE);
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
||||
|
||||
/**
|
||||
* Zooms a viewport in a window in or out.
|
||||
* @param how Zooming direction.
|
||||
|
Reference in New Issue
Block a user