Changeset - r26940:92b381a46f34
[Not reviewed]
master
0 5 0
Zachary - 2 years 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
 
@@ -2358,7 +2358,8 @@ STR_NETWORK_CLIENT_LIST_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
src/network/network_client.cpp
Show inline comments
 
@@ -1111,6 +1111,7 @@ NetworkRecvStatus ClientNetworkGameSocke
 

	
 
	_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;
 
}
 
@@ -1320,10 +1321,19 @@ bool NetworkClientPreferTeamChat(const N
 
}
 

	
 
/**
 
 * 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
 
@@ -59,6 +59,7 @@ void NetworkClientSendRcon(const std::st
 
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);
src/network/network_gui.cpp
Show inline comments
 
@@ -1352,7 +1352,7 @@ static const NWidgetPart _nested_client_
 
		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),
 
@@ -1797,6 +1797,7 @@ public:
 
			case WID_CL_CLIENT_COMPANY_COUNT:
 
				SetDParam(0, NetworkClientInfo::GetNumItems());
 
				SetDParam(1, Company::GetNumItems());
 
				SetDParam(2, NetworkMaxCompaniesAllowed());
 
				break;
 
		}
 
	}
src/settings_table.cpp
Show inline comments
 
@@ -477,7 +477,11 @@ static bool ReplaceAsteriskWithEmptyPass
 
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)