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:
f820543391
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.
This commit is contained in:

committed by
Patric Stout

parent
d6e15d4943
commit
62cdadb582
@@ -245,7 +245,7 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send,
|
||||
break;
|
||||
case NETWORK_ACTION_LEAVE: strid = STR_NETWORK_MESSAGE_CLIENT_LEFT; break;
|
||||
case NETWORK_ACTION_NAME_CHANGE: strid = STR_NETWORK_MESSAGE_NAME_CHANGE; break;
|
||||
case NETWORK_ACTION_GIVE_MONEY: strid = self_send ? STR_NETWORK_MESSAGE_GAVE_MONEY_AWAY : STR_NETWORK_MESSAGE_GIVE_MONEY; break;
|
||||
case NETWORK_ACTION_GIVE_MONEY: strid = STR_NETWORK_MESSAGE_GIVE_MONEY; break;
|
||||
case NETWORK_ACTION_CHAT_COMPANY: strid = self_send ? STR_NETWORK_CHAT_TO_COMPANY : STR_NETWORK_CHAT_COMPANY; break;
|
||||
case NETWORK_ACTION_CHAT_CLIENT: strid = self_send ? STR_NETWORK_CHAT_TO_CLIENT : STR_NETWORK_CHAT_CLIENT; break;
|
||||
case NETWORK_ACTION_KICKED: strid = STR_NETWORK_MESSAGE_KICKED; break;
|
||||
|
@@ -1000,11 +1000,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p)
|
||||
ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
|
||||
break;
|
||||
|
||||
/* For speaking to company or giving money, we need the company-name */
|
||||
case NETWORK_ACTION_GIVE_MONEY:
|
||||
if (!Company::IsValidID(ci_to->client_playas)) return NETWORK_RECV_STATUS_OKAY;
|
||||
FALLTHROUGH;
|
||||
|
||||
/* For speaking to company, we need the company-name */
|
||||
case NETWORK_ACTION_CHAT_COMPANY: {
|
||||
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
|
||||
SetDParam(0, ci_to->client_playas);
|
||||
|
@@ -39,7 +39,7 @@ static CommandCallback * const _callback_table[] = {
|
||||
/* 0x11 */ CcTerraform,
|
||||
/* 0x12 */ CcAI,
|
||||
/* 0x13 */ CcCloneVehicle,
|
||||
/* 0x14 */ CcGiveMoney,
|
||||
/* 0x14 */ nullptr,
|
||||
/* 0x15 */ CcCreateGroup,
|
||||
/* 0x16 */ CcFoundRandomTown,
|
||||
/* 0x17 */ CcRoadStop,
|
||||
|
@@ -1632,8 +1632,7 @@ NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company)
|
||||
}
|
||||
|
||||
/* The window below gives information about the connected clients
|
||||
* and also makes able to give money to them, kick them (if server)
|
||||
* and stuff like that. */
|
||||
* and also makes able to kick them (if server) and stuff like that. */
|
||||
|
||||
extern void DrawCompanyIcon(CompanyID cid, int x, int y);
|
||||
|
||||
@@ -1665,11 +1664,6 @@ static void ClientList_Ban(const NetworkClientInfo *ci)
|
||||
NetworkServerKickOrBanIP(ci->client_id, true, nullptr);
|
||||
}
|
||||
|
||||
static void ClientList_GiveMoney(const NetworkClientInfo *ci)
|
||||
{
|
||||
ShowNetworkGiveMoneyWindow(ci->client_playas);
|
||||
}
|
||||
|
||||
static void ClientList_SpeakToClient(const NetworkClientInfo *ci)
|
||||
{
|
||||
ShowNetworkChatQueryWindow(DESTTYPE_CLIENT, ci->client_id);
|
||||
@@ -1726,13 +1720,6 @@ struct NetworkClientListPopupWindow : Window {
|
||||
}
|
||||
this->AddAction(STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, &ClientList_SpeakToAll);
|
||||
|
||||
if (_network_own_client_id != ci->client_id) {
|
||||
/* We are no spectator and the company we want to give money to is no spectator and money gifts are allowed. */
|
||||
if (Company::IsValidID(_local_company) && Company::IsValidID(ci->client_playas) && _settings_game.economy.give_money) {
|
||||
this->AddAction(STR_NETWORK_CLIENTLIST_GIVE_MONEY, &ClientList_GiveMoney);
|
||||
}
|
||||
}
|
||||
|
||||
/* A server can kick clients (but not himself). */
|
||||
if (_network_server && _network_own_client_id != ci->client_id) {
|
||||
this->AddAction(STR_NETWORK_CLIENTLIST_KICK, &ClientList_Kick);
|
||||
|
@@ -16,7 +16,6 @@
|
||||
#include "network_type.h"
|
||||
|
||||
void ShowNetworkNeedPassword(NetworkPasswordType npt);
|
||||
void ShowNetworkGiveMoneyWindow(CompanyID company);
|
||||
void ShowNetworkChatQueryWindow(DestType type, int dest);
|
||||
void ShowJoinStatusWindow();
|
||||
void ShowNetworkGameWindow();
|
||||
|
@@ -1382,9 +1382,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p)
|
||||
|
||||
NetworkClientInfo *ci = this->GetInfo();
|
||||
switch (action) {
|
||||
case NETWORK_ACTION_GIVE_MONEY:
|
||||
if (!Company::IsValidID(ci->client_playas)) break;
|
||||
FALLTHROUGH;
|
||||
case NETWORK_ACTION_CHAT:
|
||||
case NETWORK_ACTION_CHAT_CLIENT:
|
||||
case NETWORK_ACTION_CHAT_COMPANY:
|
||||
|
Reference in New Issue
Block a user