diff options
author | Patric Stout <truebrain@openttd.org> | 2021-01-05 18:06:48 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-01-05 21:56:24 +0100 |
commit | 62cdadb58207b28dfdf1ab4ceb46278c2561f079 (patch) | |
tree | d6e8308cf106daf372ad673d87169f075d3c3a86 /src/main_gui.cpp | |
parent | d6e15d4943936a89d275354ee59d0e3b7c6a2018 (diff) | |
download | openttd-62cdadb58207b28dfdf1ab4ceb46278c2561f079.tar.xz |
Change: move "give money" from client-list to company window
This is a much better location for this button, as you send
money from one company to another company, not from player
to player.
This is based on work done by JGRPP in:
https://github.com/JGRennison/OpenTTD-patches/commit/f82054339124cc6b89c5f4f9dac2d9da62f0108b
and surrounding commits, which took the work from estys:
https://www.tt-forums.net/viewtopic.php?p=1183311#p1183311
We did modify it to fix several bugs and clean up the code while
here anyway.
The callback was removed, as it meant a modified client could
prevent anyone from seeing money was transfered. The message
is now generated in the command itself, making that impossible.
Diffstat (limited to 'src/main_gui.cpp')
-rw-r--r-- | src/main_gui.cpp | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/main_gui.cpp b/src/main_gui.cpp index f99cceaf1..a1d37d0f1 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -48,45 +48,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, uint32 cmd) -{ - if (result.Failed() || !_settings_game.economy.give_money) return; - - /* Inform the company of the action of one of its clients (controllers). */ - char msg[64]; - SetDParam(0, p2); - GetString(msg, STR_COMPANY_NAME, lastof(msg)); - - if (!_network_server) { - NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, p1); - } else { - NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, CLIENT_ID_SERVER, p1); - } -} - -void HandleOnEditText(const char *str) -{ - switch (_rename_what) { - case 3: { // Give money, you can only give money in excess of loan - const Company *c = Company::GetIfValid(_local_company); - if (c == nullptr) break; - Money money = min(c->money - c->current_loan, (Money)(strtoull(str, nullptr, 10) / _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; - } - 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 @@ -120,14 +81,6 @@ void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); } -void ShowNetworkGiveMoneyWindow(CompanyID company) -{ - _rename_id = company; - _rename_what = 3; - ShowQueryString(STR_EMPTY, STR_NETWORK_GIVE_MONEY_CAPTION, 30, nullptr, CS_NUMERAL, QSF_NONE); -} - - /** * Zooms a viewport in a window in or out. * @param how Zooming direction. |