console_cmds.c
changeset 665 c96dc0b4ef98
parent 664 e26a60b19408
child 666 8330fb03b6e1
equal deleted inserted replaced
664:e26a60b19408 665:c96dc0b4ef98
   600 			IConsolePrintF(_iconsole_color_error, "You are not the server");
   600 			IConsolePrintF(_iconsole_color_error, "You are not the server");
   601 			return NULL;
   601 			return NULL;
   602 		}
   602 		}
   603 		if (argc == 3) {
   603 		if (argc == 3) {
   604 			// Change server password
   604 			// Change server password
   605 			if (strncmp(argv[2], "*", 20) == 0) {
   605 			if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
   606 				_network_game_info.server_password[0] = '\0';
   606 				_network_game_info.server_password[0] = '\0';
   607 				_network_game_info.use_password = 0;
   607 				_network_game_info.use_password = 0;
   608 			} else {
   608 			} else {
   609 				strncpy(_network_game_info.server_password, argv[2], 20);
   609 				strncpy(_network_game_info.server_password, argv[2], sizeof(_network_game_info.server_password));
   610 				_network_game_info.use_password = 1;
   610 				_network_game_info.use_password = 1;
   611 			}
   611 			}
   612 			IConsolePrintF(_iconsole_color_warning, "Game-password changed to '%s'", _network_game_info.server_password);
   612 			IConsolePrintF(_iconsole_color_warning, "Game-password changed to '%s'", _network_game_info.server_password);
   613 		} else {
   613 		} else {
   614 			IConsolePrintF(_iconsole_color_default, "Current game-password is set to '%s'", _network_game_info.server_password);
   614 			IConsolePrintF(_iconsole_color_default, "Current game-password is set to '%s'", _network_game_info.server_password);
   626 		if (_local_player >= MAX_PLAYERS) {
   626 		if (_local_player >= MAX_PLAYERS) {
   627 			IConsolePrintF(_iconsole_color_default, "You have to own a company to make use of this command.");
   627 			IConsolePrintF(_iconsole_color_default, "You have to own a company to make use of this command.");
   628 			return NULL;
   628 			return NULL;
   629 		}
   629 		}
   630 		if (argc == 3) {
   630 		if (argc == 3) {
   631 			if (strncmp(argv[2], "*", 20) == 0) {
   631 			if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
   632 				_network_player_info[_local_player].password[0] = '\0';
   632 				_network_player_info[_local_player].password[0] = '\0';
   633 			} else {
   633 			} else {
   634 				strncpy(_network_player_info[_local_player].password, argv[2], 20);
   634 				strncpy(_network_player_info[_local_player].password, argv[2], sizeof(_network_player_info[_local_player].password));
   635 			}
   635 			}
   636 			if (!_network_server)
   636 			if (!_network_server)
   637 				SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
   637 				SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
   638 			IConsolePrintF(_iconsole_color_warning, "Company protected with '%s'", _network_player_info[_local_player].password);
   638 			IConsolePrintF(_iconsole_color_warning, "Company protected with '%s'", _network_player_info[_local_player].password);
   639 		} else {
   639 		} else {
   658 			if (!_network_server)
   658 			if (!_network_server)
   659 				SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[2]);
   659 				SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[2]);
   660 			else {
   660 			else {
   661 				if (NetworkFindName(argv[2])) {
   661 				if (NetworkFindName(argv[2])) {
   662 					NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, ci->client_name, argv[2]);
   662 					NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, ci->client_name, argv[2]);
   663 					ttd_strlcpy(ci->client_name, argv[2], 40);
   663 					ttd_strlcpy(ci->client_name, argv[2], sizeof(ci->client_name));
   664 					NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
   664 					NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
   665 				}
   665 				}
   666 			}
   666 			}
   667 			/* Also keep track of the new name on the client itself */
   667 			/* Also keep track of the new name on the client itself */
   668 			ttd_strlcpy(_network_player_name, argv[2], 40);
   668 			ttd_strlcpy(_network_player_name, argv[2], sizeof(_network_player_name));
   669 		} else {
   669 		} else {
   670 			IConsolePrint(_iconsole_color_default, "With 'set name' you can change your network-player name.");
   670 			IConsolePrint(_iconsole_color_default, "With 'set name' you can change your network-player name.");
   671 			IConsolePrint(_iconsole_color_warning, "Usage: set name \"<name>\".");
   671 			IConsolePrint(_iconsole_color_warning, "Usage: set name \"<name>\".");
   672 		}
   672 		}
   673 		return NULL;
   673 		return NULL;
   678 		if (!_network_server) {
   678 		if (!_network_server) {
   679 			IConsolePrintF(_iconsole_color_error, "You are not the server");
   679 			IConsolePrintF(_iconsole_color_error, "You are not the server");
   680 			return NULL;
   680 			return NULL;
   681 		}
   681 		}
   682 		if (argc == 3) {
   682 		if (argc == 3) {
   683 			strncpy(_network_server_name, argv[2], 40);
   683 			strncpy(_network_server_name, argv[2], sizeof(_network_server_name));
   684 			IConsolePrintF(_iconsole_color_warning, "Server-name changed to '%s'", _network_server_name);
   684 			IConsolePrintF(_iconsole_color_warning, "Server-name changed to '%s'", _network_server_name);
   685 			ttd_strlcpy(_network_game_info.server_name, _network_server_name, 40);
   685 			ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));
   686 		} else {
   686 		} else {
   687 			IConsolePrintF(_iconsole_color_default, "Current server-name is '%s'", _network_server_name);
   687 			IConsolePrintF(_iconsole_color_default, "Current server-name is '%s'", _network_server_name);
   688 			IConsolePrint(_iconsole_color_warning, "Usage: set server_name \"<GameName>\".");
   688 			IConsolePrint(_iconsole_color_warning, "Usage: set server_name \"<GameName>\".");
   689 		}
   689 		}
   690 		return NULL;
   690 		return NULL;