console_cmds.c
changeset 543 e3b43338096b
parent 301 f30c8c628dc6
child 554 670b089d7772
equal deleted inserted replaced
542:2f35c4770b06 543:e3b43338096b
     3 #include "ttd.h"
     3 #include "ttd.h"
     4 #include "console.h"
     4 #include "console.h"
     5 #include "engine.h"
     5 #include "engine.h"
     6 #include "functions.h"
     6 #include "functions.h"
     7 #include "variables.h"
     7 #include "variables.h"
     8 
     8 #include "network_data.h"
     9 #if defined(WIN32)
     9 #include "network_client.h"
    10 #	define ENABLE_NETWORK
    10 #include "network_server.h"
    11 #endif
    11 #include "command.h"
    12 
    12 
    13 
    13 
    14 // ** scriptfile handling ** //
    14 // ** scriptfile handling ** //
    15 static FILE * _script_file;
    15 static FILE * _script_file;
    16 static bool _script_running;
    16 static bool _script_running;
    37 
    37 
    38 /* **************************** */
    38 /* **************************** */
    39 /* variable and command hooks   */
    39 /* variable and command hooks   */
    40 /* **************************** */
    40 /* **************************** */
    41 
    41 
       
    42 #ifdef ENABLE_NETWORK
       
    43 
    42 DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
    44 DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetwork)
    43 {
    45 {
    44 	if (_networking) {
    46 	if (_networking) {
    45 		IConsoleError("This command is forbidden in multiplayer.");
    47 		IConsoleError("This command is forbidden in multiplayer.");
    46 		return false;
    48 		return false;
    47 	}
    49 	}
    48 	return true;
    50 	return true;
    49 }
    51 }
    50 
    52 
    51 #if 0 /* Not used atm */
       
    52 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
       
    53 {
       
    54 	if (_networking) {
       
    55 		IConsoleError("This variable is forbidden in multiplayer.");
       
    56 		return false;
       
    57 	}
       
    58 	return true;
       
    59 }
       
    60 #endif
       
    61 
       
    62 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
    53 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
    63 {
    54 {
    64 	if (!_networking_server) {
    55 	if (!_network_server) {
    65 		IConsoleError("This variable only makes sense for a network server.");
    56 		IConsoleError("This variable only makes sense for a network server.");
    66 		return false;
    57 		return false;
    67 	}
    58 	}
    68 	return true;
    59 	return true;
    69 }
    60 }
       
    61 
       
    62 DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetClient)
       
    63 {
       
    64 	if (!_networking || !_network_server) {
       
    65 		IConsoleError("This command is only available for a network server.");
       
    66 		return false;
       
    67 	}
       
    68 	return true;
       
    69 }
       
    70 
       
    71 DEF_CONSOLE_CMD_HOOK(ConCmdHookNoNetServer)
       
    72 {
       
    73 	if (!_networking || _network_server) {
       
    74 		IConsoleError("You can not use this command for you are a network-server.");
       
    75 		return false;
       
    76 	}
       
    77 	return true;
       
    78 }
       
    79 
       
    80 DEF_CONSOLE_CMD_HOOK(ConCmdHookNeedNetwork)
       
    81 {
       
    82 	if (!_networking) {
       
    83 		IConsoleError("Not connected. Multiplayer only command.");
       
    84 		return false;
       
    85 	}
       
    86 	return true;
       
    87 }
       
    88 
       
    89 #endif /* ENABLE_NETWORK */
    70 
    90 
    71 /* **************************** */
    91 /* **************************** */
    72 /* reset commands               */
    92 /* reset commands               */
    73 /* **************************** */
    93 /* **************************** */
    74 
    94 
    98 	}
   118 	}
    99 
   119 
   100 	return 0;
   120 	return 0;
   101 }
   121 }
   102 
   122 
       
   123 
   103 // ********************************* //
   124 // ********************************* //
   104 // * Network Core Console Commands * //
   125 // * Network Core Console Commands * //
   105 // ********************************* //
   126 // ********************************* //
   106 #ifdef ENABLE_NETWORK
   127 #ifdef ENABLE_NETWORK
   107 
   128 
       
   129 DEF_CONSOLE_CMD(ConStatus)
       
   130 {
       
   131 	const char *status;
       
   132 	int lag;
       
   133 	const ClientState *cs;
       
   134 	const NetworkClientInfo *ci;
       
   135 	FOR_ALL_CLIENTS(cs) {
       
   136 		lag = NetworkCalculateLag(cs);
       
   137 		ci = DEREF_CLIENT_INFO(cs);
       
   138 
       
   139 		switch (cs->status) {
       
   140 			case STATUS_INACTIVE:
       
   141 				status = "inactive";
       
   142 				break;
       
   143 			case STATUS_AUTH:
       
   144 				status = "authorized";
       
   145 				break;
       
   146 			case STATUS_MAP:
       
   147 				status = "loading map";
       
   148 				break;
       
   149 			case STATUS_DONE_MAP:
       
   150 				status = "done map";
       
   151 				break;
       
   152 			case STATUS_PRE_ACTIVE:
       
   153 				status = "ready";
       
   154 				break;
       
   155 			case STATUS_ACTIVE:
       
   156 				status = "active";
       
   157 				break;
       
   158 			default:
       
   159 				status = "unknown";
       
   160 				break;
       
   161 		}
       
   162 		IConsolePrintF(8, "Client #%d/%s  status: %s  frame-lag: %d  play-as: %d",
       
   163 			cs->index, ci->client_name, status, lag, ci->client_playas);
       
   164 	}
       
   165 
       
   166 	return NULL;
       
   167 }
       
   168 
       
   169 DEF_CONSOLE_CMD(ConKick)
       
   170 {
       
   171 	NetworkClientInfo *ci;
       
   172 
       
   173 	if (argc == 2) {
       
   174 		uint32 index = atoi(argv[1]);
       
   175 		if (index == NETWORK_SERVER_INDEX) {
       
   176 			IConsolePrint(_iconsole_color_default, "Silly boy, you can not kick yourself!");
       
   177 			return NULL;
       
   178 		}
       
   179 		if (index == 0) {
       
   180 			IConsoleError("Invalid Client-ID");
       
   181 			return NULL;
       
   182 		}
       
   183 
       
   184 		ci = NetworkFindClientInfoFromIndex(index);
       
   185 
       
   186 		if (ci != NULL) {
       
   187 			SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
       
   188 			return NULL;
       
   189 		} else {
       
   190 			IConsoleError("Client-ID not found");
       
   191 			return NULL;
       
   192 		}
       
   193 	}
       
   194 
       
   195 	IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: kick <client-id>. For client-ids, see 'clients'.");
       
   196 
       
   197 	return NULL;
       
   198 }
       
   199 
       
   200 DEF_CONSOLE_CMD(ConNetworkClients)
       
   201 {
       
   202 	NetworkClientInfo *ci;
       
   203 	for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
       
   204 		if (ci->client_index != NETWORK_EMPTY_INDEX) {
       
   205 			IConsolePrintF(8,"Client #%d   name: %s  play-as: %d", ci->client_index, ci->client_name, ci->client_playas);
       
   206 		}
       
   207 	}
       
   208 
       
   209 	return NULL;
       
   210 }
       
   211 
   108 DEF_CONSOLE_CMD(ConNetworkConnect)
   212 DEF_CONSOLE_CMD(ConNetworkConnect)
   109 {
   213 {
   110 	char* ip;
   214 	char* ip;
   111 	const char *port = NULL;
   215 	const byte *port = NULL;
   112 	const char *player = NULL;
   216 	const byte *player = NULL;
   113 	uint16 rport;
   217 	uint16 rport;
   114 
   218 
   115 	if (argc<2) return NULL;
   219 	if (argc<2) return NULL;
   116 
   220 
       
   221 	if (_networking) {
       
   222 		// We are in network-mode, first close it!
       
   223 		NetworkDisconnect();
       
   224 	}
       
   225 
   117 	ip = argv[1];
   226 	ip = argv[1];
   118 	rport = _network_server_port;
   227 	rport = NETWORK_DEFAULT_PORT;
   119 
   228 
   120 	ParseConnectionString(&player, &port, ip);
   229 	ParseConnectionString(&player, &port, ip);
   121 
   230 
   122 	IConsolePrintF(_iconsole_color_default, "Connecting to %s...", ip);
   231 	IConsolePrintF(_iconsole_color_default, "Connecting to %s...", ip);
   123 	if (player!=NULL) {
   232 	if (player != NULL) {
   124 		_network_playas = atoi(player);
   233 		_network_playas = atoi(player);
   125 		IConsolePrintF(_iconsole_color_default, "    player-no: %s", player);
   234 		IConsolePrintF(_iconsole_color_default, "    player-no: %s", player);
   126 	}
   235 	}
   127 	if (port!=NULL) {
   236 	if (port != NULL) {
   128 		rport = atoi(port);
   237 		rport = atoi(port);
   129 		IConsolePrintF(_iconsole_color_default, "    port: %s", port);
   238 		IConsolePrintF(_iconsole_color_default, "    port: %s", port);
   130 	}
   239 	}
   131 
   240 
   132 	NetworkCoreConnectGame(ip, rport);
   241 	NetworkClientConnectGame(ip, rport);
   133 
   242 
   134 	return NULL;
   243 	return NULL;
   135 }
   244 }
   136 
   245 
   137 #endif
   246 #endif /* ENABLE_NETWORK */
   138 
   247 
   139 /* ******************************** */
   248 /* ******************************** */
   140 /*   script file console commands   */
   249 /*   script file console commands   */
   141 /* ******************************** */
   250 /* ******************************** */
   142 
   251 
   146 	bool doerror;
   255 	bool doerror;
   147 
   256 
   148 	if (argc<2) return NULL;
   257 	if (argc<2) return NULL;
   149 
   258 
   150 	doerror = true;
   259 	doerror = true;
   151 	_script_file = fopen(argv[1], "rb");
   260 	_script_file = fopen(argv[1], "r");
   152 
   261 
   153 	if (_script_file == NULL) {
   262 	if (_script_file == NULL) {
   154 		if (argc>2) if (atoi(argv[2])==0) doerror=false;
   263 		if (argc>2) if (atoi(argv[2])==0) doerror=false;
   155 		if (doerror) IConsoleError("script file not found");
   264 		if (doerror) IConsoleError("script file not found");
   156 		return NULL;
   265 		return NULL;
   157 		}
   266 		}
   158 
   267 
   159 	_script_running = true;
   268 	_script_running = true;
   160 
   269 
       
   270 	fgets(cmd, sizeof(cmd), _script_file);
   161 	while (!feof(_script_file) && _script_running) {
   271 	while (!feof(_script_file) && _script_running) {
       
   272 		strtok(cmd, "\r\n");
       
   273 		IConsoleCmdExec(cmd);
   162 		fgets(cmd, sizeof(cmd), _script_file);
   274 		fgets(cmd, sizeof(cmd), _script_file);
   163 		IConsoleCmdExec(cmd);
       
   164 	}
   275 	}
   165 
   276 
   166 	_script_running = false;
   277 	_script_running = false;
   167 	fclose(_script_file);
   278 	fclose(_script_file);
   168 	return NULL;
   279 	return NULL;
   204 
   315 
   205 DEF_CONSOLE_CMD(ConEchoC)
   316 DEF_CONSOLE_CMD(ConEchoC)
   206 {
   317 {
   207 	if (argc < 3) return NULL;
   318 	if (argc < 3) return NULL;
   208 	IConsolePrint(atoi(argv[1]), argv[2]);
   319 	IConsolePrint(atoi(argv[1]), argv[2]);
       
   320 	return NULL;
       
   321 }
       
   322 
       
   323 extern void SwitchMode(int new_mode);
       
   324 
       
   325 DEF_CONSOLE_CMD(ConNewGame)
       
   326 {
       
   327 	_docommand_recursive = 0;
       
   328 
       
   329 	_random_seeds[0][0] = Random();
       
   330 	_random_seeds[0][1] = InteractiveRandom();
       
   331 
       
   332 	SwitchMode(SM_NEWGAME);
   209 	return NULL;
   333 	return NULL;
   210 }
   334 }
   211 
   335 
   212 DEF_CONSOLE_CMD(ConPrintF)
   336 DEF_CONSOLE_CMD(ConPrintF)
   213 {
   337 {
   297 
   421 
   298 DEF_CONSOLE_CMD(ConHelp)
   422 DEF_CONSOLE_CMD(ConHelp)
   299 {
   423 {
   300 	IConsolePrint(13, " -- console help -- ");
   424 	IConsolePrint(13, " -- console help -- ");
   301 	IConsolePrint( 1, " variables: [command to list them: list_vars]");
   425 	IConsolePrint( 1, " variables: [command to list them: list_vars]");
   302 	IConsolePrint( 1, " *temp_string = \"my little \"");
   426 	IConsolePrint( 1, " temp_string = \"my little \"");
   303 	IConsolePrint( 1, "");
   427 	IConsolePrint( 1, "");
   304 	IConsolePrint( 1, " commands: [command to list them: list_cmds]");
   428 	IConsolePrint( 1, " commands: [command to list them: list_cmds]");
   305 	IConsolePrint( 1, " [command] [\"string argument with spaces\"] [argument 2] ...");
   429 	IConsolePrint( 1, " [command] [\"string argument with spaces\"] [argument 2] ...");
   306 	IConsolePrint( 1, " printf \"%s world\" *temp_string");
   430 	IConsolePrint( 1, " printf \"%s world\" temp_string");
   307 	IConsolePrint( 1, "");
   431 	IConsolePrint( 1, "");
   308 	IConsolePrint( 1, " command/variable returning a value into an variable:");
   432 	IConsolePrint( 1, " command/variable returning a value into an variable:");
   309 	IConsolePrint( 1, " *temp_uint16 << random");
   433 	IConsolePrint( 1, " temp_uint16 << random");
   310 	IConsolePrint( 1, " *temp_uint16 << *temp_uint16_2");
   434 	IConsolePrint( 1, " temp_uint16 << temp_uint16_2");
   311 	IConsolePrint( 1, "");
   435 	IConsolePrint( 1, "");
   312 	return NULL;
   436 	return NULL;
   313 }
   437 }
   314 
   438 
   315 DEF_CONSOLE_CMD(ConRandom)
   439 DEF_CONSOLE_CMD(ConRandom)
   359 		if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
   483 		if (argv[1] == NULL || strncmp(item->name, argv[1], l) == 0)
   360 			IConsoleVarDump(item, NULL);
   484 			IConsoleVarDump(item, NULL);
   361 
   485 
   362 	return NULL;
   486 	return NULL;
   363 }
   487 }
       
   488 
       
   489 #ifdef ENABLE_NETWORK
       
   490 
       
   491 DEF_CONSOLE_CMD(ConSay)
       
   492 {
       
   493 	if (argc == 2) {
       
   494 		if (!_network_server)
       
   495 			SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
       
   496 		else
       
   497 			NetworkServer_HandleChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], NETWORK_SERVER_INDEX);
       
   498 	} else
       
   499 		IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say \"<msg>\"");
       
   500 	return NULL;
       
   501 }
       
   502 
       
   503 DEF_CONSOLE_CMD(ConSayPlayer)
       
   504 {
       
   505 	if (argc == 3) {
       
   506 		if (atoi(argv[1]) < 1 || atoi(argv[1]) > MAX_PLAYERS) {
       
   507 			IConsolePrintF(_iconsole_color_default, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS);
       
   508 			return NULL;
       
   509 		}
       
   510 
       
   511 		if (!_network_server)
       
   512 			SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]);
       
   513 		else
       
   514 			NetworkServer_HandleChat(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
       
   515 	} else
       
   516 		IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say_player <playerno> \"<msg>\"");
       
   517 	return NULL;
       
   518 }
       
   519 
       
   520 DEF_CONSOLE_CMD(ConSayClient)
       
   521 {
       
   522 	if (argc == 3) {
       
   523 		if (!_network_server)
       
   524 			SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
       
   525 		else
       
   526 			NetworkServer_HandleChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
       
   527 	} else
       
   528 		IConsolePrint(_iconsole_color_default, "Unknown usage. Usage: say_client <clientno> \"<msg>\"");
       
   529 	return NULL;
       
   530 }
       
   531 
       
   532 DEF_CONSOLE_CMD(ConSetServerName) {
       
   533 	if (argc == 2) {
       
   534 		strncpy(_network_server_name, argv[1], 40);
       
   535 		IConsolePrintF(_iconsole_color_default, "Server-name changed to '%s'", _network_server_name);
       
   536 		ttd_strlcpy(_network_game_info.server_name, _network_server_name, 40);
       
   537 	} else if (argc == 1) {
       
   538 		IConsolePrintF(_iconsole_color_default, "Current server-name is '%s'", _network_server_name);
       
   539 		IConsolePrint(_iconsole_color_default, "  Usage: setservername \"<GameName>\".");
       
   540 	} else {
       
   541 		IConsolePrint(_iconsole_color_default, "Unknow usage. Usage: setservername \"<ServerName>\".");
       
   542 	}
       
   543 	return NULL;
       
   544 }
       
   545 
       
   546 DEF_CONSOLE_CMD(ConClientName) {
       
   547 	NetworkClientInfo *ci;
       
   548 	ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
       
   549 
       
   550 	if (argc == 2 && ci != NULL) {
       
   551 		if (!_network_server)
       
   552 			SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[1]);
       
   553 		else {
       
   554 			if (NetworkFindName(argv[1])) {
       
   555 				NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, ci->client_name, argv[1]);
       
   556 				ttd_strlcpy(ci->client_name, argv[1], 40);
       
   557 				NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
       
   558 			}
       
   559 		}
       
   560 	} else {
       
   561 		IConsolePrint(_iconsole_color_default, "With 'name' you can change your network-player name.");
       
   562 		IConsolePrint(_iconsole_color_default, "  Usage: name \"<name>\".");
       
   563 	}
       
   564 
       
   565 	return NULL;
       
   566 }
       
   567 
       
   568 DEF_CONSOLE_CMD(ConProtect) {
       
   569 	// Protect a company with a password
       
   570 	if (_local_player >= MAX_PLAYERS) {
       
   571 		IConsolePrintF(_iconsole_color_default, "You have to own a company to make use of this command.");
       
   572 		return NULL;
       
   573 	}
       
   574 	if (argc == 2) {
       
   575 		if (strncmp(argv[1], "*", 20) == 0) {
       
   576 			_network_player_info[_local_player].password[0] = '\0';
       
   577 		} else {
       
   578 			strncpy(_network_player_info[_local_player].password, argv[1], 20);
       
   579 		}
       
   580 		if (!_network_server)
       
   581 			SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
       
   582 		IConsolePrintF(_iconsole_color_default, "Company protected with '%s'", _network_player_info[_local_player].password);
       
   583 	} else {
       
   584 		IConsolePrint(_iconsole_color_default, "Protect sets a password on the company, so no-one without the correct password can join.");
       
   585 		IConsolePrint(_iconsole_color_default, "  Usage: protect \"<password>\".   Use * as <password> to set no password.");
       
   586 	}
       
   587 
       
   588 	return NULL;
       
   589 }
       
   590 
       
   591 DEF_CONSOLE_CMD(ConSetPassword) {
       
   592 	if (argc == 2) {
       
   593 		// Change server password
       
   594 		if (strncmp(argv[1], "*", 20) == 0) {
       
   595 			_network_game_info.server_password[0] = '\0';
       
   596 			_network_game_info.use_password = 0;
       
   597 		} else {
       
   598 			strncpy(_network_game_info.server_password, argv[1], 20);
       
   599 			_network_game_info.use_password = 1;
       
   600 		}
       
   601 		IConsolePrintF(_iconsole_color_default, "Game-password changed to '%s'", _network_game_info.server_password);
       
   602 	} else if (argc == 1) {
       
   603 		IConsolePrintF(_iconsole_color_default, "Current game-password is set to '%s'", _network_game_info.server_password);
       
   604 		IConsolePrint(_iconsole_color_default, "  Usage: setpassword \"<password>\".   Use * as <password> to set no password.");
       
   605 	} else {
       
   606 		IConsolePrint(_iconsole_color_default, "Unknow usage. Usage: setpassword \"<password>\".   Use * as <password> to set no password.");
       
   607 	}
       
   608 
       
   609 	return 0;
       
   610 }
       
   611 
       
   612 #endif /* ENABLE_NETWORK */
   364 
   613 
   365 #ifdef _DEBUG
   614 #ifdef _DEBUG
   366 /* ****************************************** */
   615 /* ****************************************** */
   367 /*  debug commands and variables */
   616 /*  debug commands and variables */
   368 /* ****************************************** */
   617 /* ****************************************** */
   388 
   637 
   389 /* ****************************************** */
   638 /* ****************************************** */
   390 /*  console command and variable registration */
   639 /*  console command and variable registration */
   391 /* ****************************************** */
   640 /* ****************************************** */
   392 
   641 
   393 void IConsoleStdLibRegister()
   642 void IConsoleStdLibRegister(void)
   394 {
   643 {
   395 	// stdlib
   644 	// stdlib
   396 	extern byte _stdlib_developer; /* XXX extern in .c */
   645 	extern byte _stdlib_developer; /* XXX extern in .c */
   397 
   646 
   398 #ifdef _DEBUG
   647 #ifdef _DEBUG
   400 #endif
   649 #endif
   401 
   650 
   402 	// functions [please add them alphabetically]
   651 	// functions [please add them alphabetically]
   403 #ifdef ENABLE_NETWORK
   652 #ifdef ENABLE_NETWORK
   404 	IConsoleCmdRegister("connect", ConNetworkConnect);
   653 	IConsoleCmdRegister("connect", ConNetworkConnect);
   405 	IConsoleCmdHook("connect", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetwork);
   654 	IConsoleCmdHook("connect", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetServer);
   406 #endif
   655 	IConsoleCmdRegister("clients", ConNetworkClients);
       
   656 #endif /* ENABLE_NETWORK */
   407 	IConsoleCmdRegister("debug_level",  ConDebugLevel);
   657 	IConsoleCmdRegister("debug_level",  ConDebugLevel);
   408 	IConsoleCmdRegister("dump_vars",    ConListDumpVariables);
   658 	IConsoleCmdRegister("dump_vars",    ConListDumpVariables);
   409 	IConsoleCmdRegister("echo",         ConEcho);
   659 	IConsoleCmdRegister("echo",         ConEcho);
   410 	IConsoleCmdRegister("echoc",        ConEchoC);
   660 	IConsoleCmdRegister("echoc",        ConEchoC);
   411 	IConsoleCmdRegister("exec",         ConExec);
   661 	IConsoleCmdRegister("exec",         ConExec);
   413 	IConsoleCmdRegister("help",         ConHelp);
   663 	IConsoleCmdRegister("help",         ConHelp);
   414 	IConsoleCmdRegister("info_cmd",     ConInfoCmd);
   664 	IConsoleCmdRegister("info_cmd",     ConInfoCmd);
   415 	IConsoleCmdRegister("info_var",     ConInfoVar);
   665 	IConsoleCmdRegister("info_var",     ConInfoVar);
   416 	IConsoleCmdRegister("list_cmds",    ConListCommands);
   666 	IConsoleCmdRegister("list_cmds",    ConListCommands);
   417 	IConsoleCmdRegister("list_vars",    ConListVariables);
   667 	IConsoleCmdRegister("list_vars",    ConListVariables);
       
   668 #ifdef ENABLE_NETWORK
       
   669 	IConsoleCmdRegister("kick",         ConKick);
       
   670 	IConsoleCmdHook("kick", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
       
   671 	IConsoleCmdRegister("protect", ConProtect);
       
   672 	IConsoleCmdRegister("name",         ConClientName);
       
   673 #endif
       
   674 	IConsoleCmdRegister("newgame",         ConNewGame);
   418 	IConsoleCmdRegister("printf",       ConPrintF);
   675 	IConsoleCmdRegister("printf",       ConPrintF);
   419 	IConsoleCmdRegister("printfc",      ConPrintFC);
   676 	IConsoleCmdRegister("printfc",      ConPrintFC);
   420 	IConsoleCmdRegister("quit",         ConExit);
   677 	IConsoleCmdRegister("quit",         ConExit);
   421 	IConsoleCmdRegister("random",       ConRandom);
   678 	IConsoleCmdRegister("random",       ConRandom);
   422 	IConsoleCmdRegister("resetengines", ConResetEngines);
   679 	IConsoleCmdRegister("resetengines", ConResetEngines);
       
   680 #ifdef ENABLE_NETWORK
   423 	IConsoleCmdHook("resetengines", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetwork);
   681 	IConsoleCmdHook("resetengines", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetwork);
       
   682 #endif /* ENABLE_NETWORK */
   424 	IConsoleCmdRegister("return",     ConReturn);
   683 	IConsoleCmdRegister("return",     ConReturn);
       
   684 #ifdef ENABLE_NETWORK
       
   685 	IConsoleCmdRegister("say",        ConSay);
       
   686 	IConsoleCmdHook("say", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
       
   687 	IConsoleCmdRegister("say_player", ConSayPlayer);
       
   688 	IConsoleCmdHook("say_player", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
       
   689 	IConsoleCmdRegister("say_client", ConSayClient);
       
   690 	IConsoleCmdHook("say_client", ICONSOLE_HOOK_ACCESS, ConCmdHookNeedNetwork);
       
   691 #endif /* ENABLE_NETWORK */
   425 	IConsoleCmdRegister("screenshot", ConScreenShot);
   692 	IConsoleCmdRegister("screenshot", ConScreenShot);
   426 	IConsoleCmdRegister("script",     ConScript);
   693 	IConsoleCmdRegister("script",     ConScript);
   427 	IConsoleCmdRegister("scrollto",   ConScrollToTile);
   694 	IConsoleCmdRegister("scrollto",   ConScrollToTile);
       
   695 #ifdef ENABLE_NETWORK
       
   696 	IConsoleCmdRegister("setservername", ConSetServerName);
       
   697 	IConsoleCmdHook("setservername", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
       
   698 	IConsoleCmdRegister("setpassword", ConSetPassword);
       
   699 	IConsoleCmdHook("setpassword", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
       
   700 	IConsoleCmdRegister("status",   ConStatus);
       
   701 	IConsoleCmdHook("status", ICONSOLE_HOOK_ACCESS, ConCmdHookNoNetClient);
       
   702 #endif /* ENABLE_NETWORK */
   428 
   703 
   429 	// variables [please add them alphabeticaly]
   704 	// variables [please add them alphabeticaly]
   430 	IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
   705 	IConsoleVarRegister("developer", &_stdlib_developer, ICONSOLE_VAR_BYTE);
   431 #ifdef ENABLE_NETWORK
   706 #ifdef ENABLE_NETWORK
   432 	IConsoleVarRegister("net_client_timeout", &_network_client_timeout, ICONSOLE_VAR_UINT16);
   707 	IConsoleVarRegister("net_frame_freq", &_network_frame_freq, ICONSOLE_VAR_UINT8);
   433 	IConsoleVarHook("*net_client_timeout", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
   708 	IConsoleVarHook("*net_frame_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
   434 	IConsoleVarRegister("net_ready_ahead", &_network_ready_ahead, ICONSOLE_VAR_UINT16);
       
   435 	IConsoleVarRegister("net_sync_freq", &_network_sync_freq, ICONSOLE_VAR_UINT16);
   709 	IConsoleVarRegister("net_sync_freq", &_network_sync_freq, ICONSOLE_VAR_UINT16);
   436 	IConsoleVarHook("*net_sync_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
   710 	IConsoleVarHook("*net_sync_freq", ICONSOLE_HOOK_ACCESS, ConVarHookNoNetClient);
   437 #endif
   711 #endif /* ENABLE_NETWORK */
   438 
   712 
   439 
   713 
   440 }
   714 }
   441 /* -------------------- don't cross this line --------------------- */
   715 /* -------------------- don't cross this line --------------------- */