src/network/network_client.cpp
changeset 10792 95b6eb9fcc9e
parent 10784 c3c7b558b4f1
child 11156 cf146f346724
equal deleted inserted replaced
10791:0f3e94733e65 10792:95b6eb9fcc9e
     5 #ifdef ENABLE_NETWORK
     5 #ifdef ENABLE_NETWORK
     6 
     6 
     7 #include "../stdafx.h"
     7 #include "../stdafx.h"
     8 #include "../debug.h"
     8 #include "../debug.h"
     9 #include "../openttd.h"
     9 #include "../openttd.h"
    10 #include "network_data.h"
    10 #include "network_internal.h"
    11 #include "core/tcp.h"
    11 #include "core/tcp.h"
    12 #include "network_client.h"
    12 #include "network_client.h"
    13 #include "network_gamelist.h"
    13 #include "network_gamelist.h"
    14 #include "network_gui.h"
    14 #include "network_gui.h"
    15 #include "../saveload.h"
    15 #include "../saveload.h"
   936 	}
   936 	}
   937 
   937 
   938 	return res;
   938 	return res;
   939 }
   939 }
   940 
   940 
       
   941 void NetworkClientSendRcon(const char *password, const char *command)
       
   942 {
       
   943 	SEND_COMMAND(PACKET_CLIENT_RCON)(password, command);
       
   944 }
       
   945 
       
   946 void NetworkUpdatePlayerName()
       
   947 {
       
   948 	NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
       
   949 
       
   950 	if (ci == NULL) return;
       
   951 
       
   952 	/* Don't change the name if it is the same as the old name */
       
   953 	if (strcmp(ci->client_name, _settings_client.network.player_name) != 0) {
       
   954 		if (!_network_server) {
       
   955 			SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.player_name);
       
   956 		} else {
       
   957 			if (NetworkFindName(_settings_client.network.player_name)) {
       
   958 				NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.player_name);
       
   959 				ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
       
   960 				NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
       
   961 			}
       
   962 		}
       
   963 	}
       
   964 }
       
   965 
       
   966 void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const char *msg)
       
   967 {
       
   968 	SEND_COMMAND(PACKET_CLIENT_CHAT)(action, type, dest, msg);
       
   969 }
       
   970 
       
   971 void NetworkClientSetPassword()
       
   972 {
       
   973 	SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
       
   974 }
       
   975 
   941 #endif /* ENABLE_NETWORK */
   976 #endif /* ENABLE_NETWORK */