console_cmds.c
changeset 222 b88456001397
parent 220 dc1710f96b39
child 228 f65dec6727d9
equal deleted inserted replaced
221:124a804562a5 222:b88456001397
    37 		return false;
    37 		return false;
    38 		}
    38 		}
    39 	return true;
    39 	return true;
    40 }
    40 }
    41 
    41 
       
    42 #if 0 /* Not used atm */
    42 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
    43 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetwork)
    43 {
    44 {
    44 	if (_networking) {
    45 	if (_networking) {
    45 		IConsoleError("this variable is forbidden in multiplayer");
    46 		IConsoleError("this variable is forbidden in multiplayer");
    46 		return false;
    47 		return false;
    47 		}
    48 		}
    48 	return true;
    49 	return true;
    49 }
    50 }
       
    51 #endif
    50 
    52 
    51 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
    53 DEF_CONSOLE_VAR_HOOK(ConVarHookNoNetClient)
    52 {
    54 {
    53 	if (!_networking_server) {
    55 	if (!_networking_server) {
    54 		IConsoleError("this variable only makes sense for a network server");
    56 		IConsoleError("this variable only makes sense for a network server");
   105 
   107 
   106 	b = argv[1];
   108 	b = argv[1];
   107 	rport = _network_server_port;
   109 	rport = _network_server_port;
   108 	c = 0;
   110 	c = 0;
   109 	ip = b;
   111 	ip = b;
   110 	
   112 
   111 	while (b[c] != 0) {
   113 	while (b[c] != 0) {
   112 		if (((char)b[c]) == '#') {
   114 		if (((char)b[c]) == '#') {
   113 			player = &b[c+1];
   115 			player = &b[c+1];
   114 			b[c] = 0;
   116 			b[c] = 0;
   115 			}
   117 			}
   199 		if (item->_malloc) IConsolePrintF(_iconsole_color_default,"variable_malloc: internal allocated"); else IConsolePrintF(_iconsole_color_default, "variable_malloc: external allocated");
   201 		if (item->_malloc) IConsolePrintF(_iconsole_color_default,"variable_malloc: internal allocated"); else IConsolePrintF(_iconsole_color_default, "variable_malloc: external allocated");
   200 		}
   202 		}
   201 	return NULL;
   203 	return NULL;
   202 }
   204 }
   203 
   205 
   204 DEF_CONSOLE_CMD(ConDebugLevel) 
   206 DEF_CONSOLE_CMD(ConDebugLevel)
   205 {
   207 {
   206 	if (argc<2) return NULL;
   208 	if (argc<2) return NULL;
   207 	SetDebugString(argv[1]);
   209 	SetDebugString(argv[1]);
   208 	return NULL;
   210 	return NULL;
   209 }
   211 }
   210 
   212 
   211 DEF_CONSOLE_CMD(ConExit) 
   213 DEF_CONSOLE_CMD(ConExit)
   212 {
   214 {
   213 	_exit_game = true;
   215 	_exit_game = true;
   214 	return NULL;
   216 	return NULL;
   215 }
   217 }
   216 
   218 
   217 DEF_CONSOLE_CMD(ConHelp) 
   219 DEF_CONSOLE_CMD(ConHelp)
   218 {
   220 {
   219 	IConsolePrint(13	," -- console help -- ");
   221 	IConsolePrint(13	," -- console help -- ");
   220 	IConsolePrint(1		," variables: [command to list them: list_vars]");
   222 	IConsolePrint(1		," variables: [command to list them: list_vars]");
   221 	IConsolePrint(1		," *temp_string = \"my little \"");
   223 	IConsolePrint(1		," *temp_string = \"my little \"");
   222 	IConsolePrint(1		,"");
   224 	IConsolePrint(1		,"");
   237 	result = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
   239 	result = IConsoleVarAlloc(ICONSOLE_VAR_UINT16);
   238 	IConsoleVarSetValue(result,rand());
   240 	IConsoleVarSetValue(result,rand());
   239 	return result;
   241 	return result;
   240 }
   242 }
   241 
   243 
   242 DEF_CONSOLE_CMD(ConListCommands) 
   244 DEF_CONSOLE_CMD(ConListCommands)
   243 {
   245 {
   244 	_iconsole_cmd * item;
   246 	_iconsole_cmd * item;
   245 	int l = 0;
   247 	int l = 0;
   246 
   248 
   247 	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
   249 	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
   262 		}
   264 		}
   263 
   265 
   264 	return NULL;
   266 	return NULL;
   265 }
   267 }
   266 
   268 
   267 DEF_CONSOLE_CMD(ConListVariables) 
   269 DEF_CONSOLE_CMD(ConListVariables)
   268 {
   270 {
   269 	_iconsole_var * item;
   271 	_iconsole_var * item;
   270 	int l = 0;
   272 	int l = 0;
   271 
   273 
   272 	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
   274 	if (argv[1]!=NULL) l = strlen((char *) argv[1]);
   273 
   275 
   274 	item = _iconsole_vars;
   276 	item = _iconsole_vars;
   275 	while (item != NULL) {
   277 	while (item != NULL) {
   276 		if (argv[1]!=NULL) {
   278 		if (argv[1]!=NULL) {
   277 
   279 
   278 			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
   280 			if (memcmp(item->name, argv[1],l)==0)
   279 					IConsolePrintF(_iconsole_color_default,"%s",item->name);
   281 					IConsolePrintF(_iconsole_color_default,"%s",item->name);
   280 
   282 
   281 			} else {
   283 			} else {
   282 
   284 
   283 			IConsolePrintF(_iconsole_color_default,"%s",item->name);
   285 			IConsolePrintF(_iconsole_color_default,"%s",item->name);
   298 
   300 
   299 	item = _iconsole_vars;
   301 	item = _iconsole_vars;
   300 	while (item != NULL) {
   302 	while (item != NULL) {
   301 		if (argv[1]!=NULL) {
   303 		if (argv[1]!=NULL) {
   302 
   304 
   303 			if (memcmp((void *) item->name, (void *) argv[1],l)==0)
   305 			if (memcmp(item->name, argv[1],l)==0)
   304 					IConsoleVarDump(item,NULL);
   306 					IConsoleVarDump(item,NULL);
   305 
   307 
   306 			} else {
   308 			} else {
   307 
   309 
   308 			IConsoleVarDump(item,NULL);
   310 			IConsoleVarDump(item,NULL);
   317 #ifdef _DEBUG
   319 #ifdef _DEBUG
   318 /* ****************************************** */
   320 /* ****************************************** */
   319 /*  debug commands and variables */
   321 /*  debug commands and variables */
   320 /* ****************************************** */
   322 /* ****************************************** */
   321 
   323 
   322 void IConsoleDebugLibRegister() 
   324 void IConsoleDebugLibRegister()
   323 {
   325 {
   324 	IConsoleVarMemRegister("temp_bool",ICONSOLE_VAR_BOOLEAN);
   326 	IConsoleVarMemRegister("temp_bool",ICONSOLE_VAR_BOOLEAN);
   325 	IConsoleVarMemRegister("temp_int16",ICONSOLE_VAR_INT16);
   327 	IConsoleVarMemRegister("temp_int16",ICONSOLE_VAR_INT16);
   326 	IConsoleVarMemRegister("temp_int32",ICONSOLE_VAR_INT32);
   328 	IConsoleVarMemRegister("temp_int32",ICONSOLE_VAR_INT32);
   327 	IConsoleVarMemRegister("temp_pointer",ICONSOLE_VAR_POINTER);
   329 	IConsoleVarMemRegister("temp_pointer",ICONSOLE_VAR_POINTER);
   344 	extern byte _stdlib_developer;
   346 	extern byte _stdlib_developer;
   345 	extern bool _stdlib_con_developer;
   347 	extern bool _stdlib_con_developer;
   346 
   348 
   347 #ifdef _DEBUG
   349 #ifdef _DEBUG
   348 	IConsoleDebugLibRegister();
   350 	IConsoleDebugLibRegister();
       
   351 #else
       
   352 	(void)ConResetTile; // Silence warning, this is only used in _DEBUG
   349 #endif
   353 #endif
   350 
   354 
   351 	// functions [please add them alphabeticaly]
   355 	// functions [please add them alphabeticaly]
   352 #ifdef ENABLE_NETWORK
   356 #ifdef ENABLE_NETWORK
   353 	IConsoleCmdRegister("connect",ConNetworkConnect);
   357 	IConsoleCmdRegister("connect",ConNetworkConnect);