src/settings.cpp
changeset 9428 1ba05b499957
parent 9426 a77c8a4abcf5
child 9447 d5d0e9d2c1ee
equal deleted inserted replaced
9427:af652de004a0 9428:1ba05b499957
    23 #include "openttd.h"
    23 #include "openttd.h"
    24 #include "currency.h"
    24 #include "currency.h"
    25 #include "screenshot.h"
    25 #include "screenshot.h"
    26 #include "variables.h"
    26 #include "variables.h"
    27 #include "network/network.h"
    27 #include "network/network.h"
    28 #include "network/network_data.h"
    28 #include "network/network_func.h"
    29 #include "network/network_client.h"
       
    30 #include "network/network_server.h"
       
    31 #include "network/network_udp.h"
       
    32 #include "settings_internal.h"
    29 #include "settings_internal.h"
    33 #include "command_func.h"
    30 #include "command_func.h"
    34 #include "console_func.h"
    31 #include "console_func.h"
    35 #include "saveload.h"
    32 #include "saveload.h"
    36 #include "npf.h"
    33 #include "npf.h"
  1444 	return 0;
  1441 	return 0;
  1445 }
  1442 }
  1446 
  1443 
  1447 static int32 UpdatePlayerName(int32 p1)
  1444 static int32 UpdatePlayerName(int32 p1)
  1448 {
  1445 {
  1449 	NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
  1446 	NetworkUpdatePlayerName();
  1450 
       
  1451 	if (ci == NULL) return 0;
       
  1452 
       
  1453 	/* Don't change the name if it is the same as the old name */
       
  1454 	if (strcmp(ci->client_name, _settings_client.network.player_name) != 0) {
       
  1455 		if (!_network_server) {
       
  1456 			SEND_COMMAND(PACKET_CLIENT_SET_NAME)(_settings_client.network.player_name);
       
  1457 		} else {
       
  1458 			if (NetworkFindName(_settings_client.network.player_name)) {
       
  1459 				NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.player_name);
       
  1460 				ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
       
  1461 				NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
       
  1462 			}
       
  1463 		}
       
  1464 	}
       
  1465 
       
  1466 	return 0;
  1447 	return 0;
  1467 }
  1448 }
  1468 
  1449 
  1469 static int32 UpdateServerName(int32 p1)
  1450 static int32 UpdateServerName(int32 p1)
  1470 {
  1451 {