Changeset - r26940:92b381a46f34
[Not reviewed]
master
0 5 0
Zachary - 23 months ago 2022-10-03 14:52:38
tysonzachary@ufl.edu
Add: maximum number of companies allowed to the client list
5 files changed with 21 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -2355,13 +2355,14 @@ STR_NETWORK_CLIENT_LIST_CHAT_COMPANY_TOO
 
STR_NETWORK_CLIENT_LIST_CHAT_SPECTATOR_TOOLTIP                  :{BLACK}Send a message to all spectators
 
STR_NETWORK_CLIENT_LIST_SPECTATORS                              :Spectators
 
STR_NETWORK_CLIENT_LIST_NEW_COMPANY                             :(New company)
 
STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP                     :{BLACK}Create a new company and join it
 
STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP                :{BLACK}This is you
 
STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP                :{BLACK}This is the host of the game
 
STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT                    :{BLACK}{NUM} client{P "" s} / {NUM} compan{P y ies}
 
STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT                    :{BLACK}{NUM} client{P "" s} - {NUM}/{NUM} compan{P y ies}
 
STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP            :{BLACK}The number of currently connected clients, number of companies and maximum number of companies allowed by the server administrator
 

	
 
# Matches ConnectionType
 
###length 5
 
STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_UNKNOWN          :{BLACK}Local
 
STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_ISOLATED         :{RED}Remote players can't connect
 
STR_NETWORK_CLIENT_LIST_SERVER_CONNECTION_TYPE_DIRECT           :{BLACK}Public
src/network/network_client.cpp
Show inline comments
 
@@ -1108,12 +1108,13 @@ NetworkRecvStatus ClientNetworkGameSocke
 
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(Packet *p)
 
{
 
	if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
 

	
 
	_network_server_max_companies = p->Recv_uint8();
 
	_network_server_name = p->Recv_string(NETWORK_NAME_LENGTH);
 
	SetWindowClassesDirty(WC_CLIENT_LIST);
 

	
 
	return NETWORK_RECV_STATUS_OKAY;
 
}
 

	
 
NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet *p)
 
{
 
@@ -1317,13 +1318,22 @@ bool NetworkClientPreferTeamChat(const N
 
	}
 

	
 
	return false;
 
}
 

	
 
/**
 
 * Get the maximum number of companies that are allowed by the server.
 
 * @return The number of companies allowed.
 
 */
 
uint NetworkMaxCompaniesAllowed()
 
{
 
	return _network_server ? _settings_client.network.max_companies : _network_server_max_companies;
 
}
 

	
 
/**
 
 * Check if max_companies has been reached on the server (local check only).
 
 * @return true if the max value has been reached or exceeded, false otherwise.
 
 */
 
bool NetworkMaxCompaniesReached()
 
{
 
	return Company::GetNumItems() >= (_network_server ? _settings_client.network.max_companies : _network_server_max_companies);
 
	return Company::GetNumItems() >= NetworkMaxCompaniesAllowed();
 
}
src/network/network_func.h
Show inline comments
 
@@ -56,12 +56,13 @@ bool NetworkClientConnectGame(const std:
 
void NetworkClientJoinGame();
 
void NetworkClientRequestMove(CompanyID company, const std::string &pass = "");
 
void NetworkClientSendRcon(const std::string &password, const std::string &command);
 
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data = 0);
 
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
 
bool NetworkCompanyIsPassworded(CompanyID company_id);
 
uint NetworkMaxCompaniesAllowed();
 
bool NetworkMaxCompaniesReached();
 
void NetworkPrintClients();
 
void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode);
 

	
 
/*** Commands ran by the server ***/
 
void NetworkServerDailyLoop();
src/network/network_gui.cpp
Show inline comments
 
@@ -1349,13 +1349,13 @@ static const NWidgetPart _nested_client_
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_MATRIX, COLOUR_GREY, WID_CL_MATRIX), SetMinimalSize(180, 0), SetResize(1, 1), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_CL_SCROLLBAR),
 
			NWidget(WWT_PANEL, COLOUR_GREY),
 
				NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_CLIENT_COMPANY_COUNT), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetPadding(2, 1, 2, 1), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NULL),
 
				NWidget(WWT_TEXT, COLOUR_GREY, WID_CL_CLIENT_COMPANY_COUNT), SetFill(1, 0), SetMinimalTextLines(1, 0), SetResize(1, 0), SetPadding(2, 1, 2, 1), SetAlignment(SA_CENTER), SetDataTip(STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT, STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_CL_SCROLLBAR),
 
			NWidget(WWT_RESIZEBOX, COLOUR_GREY),
 
		EndContainer(),
 
@@ -1794,12 +1794,13 @@ public:
 
				break;
 
			}
 

	
 
			case WID_CL_CLIENT_COMPANY_COUNT:
 
				SetDParam(0, NetworkClientInfo::GetNumItems());
 
				SetDParam(1, Company::GetNumItems());
 
				SetDParam(2, NetworkMaxCompaniesAllowed());
 
				break;
 
		}
 
	}
 

	
 
	void OnClick(Point pt, int widget, int click_count) override
 
	{
src/settings_table.cpp
Show inline comments
 
@@ -474,10 +474,14 @@ static bool ReplaceAsteriskWithEmptyPass
 
}
 

	
 
/** Update the game info, and send it to the clients when we are running as a server. */
 
static void UpdateClientConfigValues()
 
{
 
	NetworkServerUpdateGameInfo();
 
	if (_network_server) NetworkServerSendConfigUpdate();
 

	
 
	if (_network_server) {
 
		NetworkServerSendConfigUpdate();
 
		SetWindowClassesDirty(WC_CLIENT_LIST);
 
	}
 
}
 

	
 
/* End - Callback Functions */
0 comments (0 inline, 0 general)