Changeset - r10460:5fba179e6ffa
[Not reviewed]
master
0 3 0
rubidium - 16 years ago 2008-12-22 21:15:02
rubidium@openttd.org
(svn r14715) -Codechange: move some network code from the main gui file into one of the the network files.
3 files changed with 20 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/main_gui.cpp
Show inline comments
 
@@ -314,28 +314,15 @@ struct MainWindow : Window
 
				break;
 

	
 
#ifdef ENABLE_NETWORK
 
			case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
 
				if (_networking) {
 
					const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_id);
 
					bool teamchat = false;
 

	
 
					if (cio == NULL) break;
 

	
 
					/* Only companies actually playing can speak to team. Eg spectators cannot */
 
					if (_settings_client.gui.prefer_teamchat && IsValidCompanyID(cio->client_playas)) {
 
						const NetworkClientInfo *ci;
 
						FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
							if (ci->client_playas == cio->client_playas && ci != cio) {
 
								teamchat = true;
 
								break;
 
							}
 
						}
 
					}
 

	
 
					ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
 
					ShowNetworkChatQueryWindow(NetworkClientPreferTeamChat(cio) ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
 
				}
 
				break;
 

	
 
			case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all clients
 
				if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
 
				break;
src/network/network_client.cpp
Show inline comments
 
@@ -953,7 +953,25 @@ void NetworkClientSendChat(NetworkAction
 

	
 
void NetworkClientSetPassword(const char *password)
 
{
 
	SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(password);
 
}
 

	
 
/**
 
 * Tell whether the client has team members where he/she can chat to.
 
 * @param cio client to check members of.
 
 * @return true if there is at least one team member.
 
 */
 
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio)
 
{
 
	/* Only companies actually playing can speak to team. Eg spectators cannot */
 
	if (!_settings_client.gui.prefer_teamchat || !IsValidCompanyID(cio->client_playas)) return false;
 

	
 
	const NetworkClientInfo *ci;
 
	FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
 
		if (ci->client_playas == cio->client_playas && ci != cio) return true;
 
	}
 

	
 
	return false;
 
}
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_func.h
Show inline comments
 
@@ -38,12 +38,13 @@ void NetworkPopulateCompanyStats(Network
 

	
 
void NetworkUpdateClientInfo(ClientID client_id);
 
bool NetworkClientConnectGame(const char *host, uint16 port);
 
void NetworkClientSendRcon(const char *password, const char *command);
 
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg);
 
void NetworkClientSetPassword(const char *password);
 
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
 

	
 
/*** Commands ran by the server ***/
 
void NetworkServerMonthlyLoop();
 
void NetworkServerYearlyLoop();
 
void NetworkServerChangeOwner(Owner current_owner, Owner new_owner);
 
void NetworkServerShowStatusToConsole();
0 comments (0 inline, 0 general)