diff options
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/map/map.c b/src/map/map.c index f17b05e02..6d1bb490d 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3247,44 +3247,54 @@ static int char_ip_set = 0; * Console Command Parser [Wizputer] *------------------------------------------ */ -int parse_console(char *buf) { - char type[64],command[64],map[64]; - int x = 0, y = 0; - int m, n; +int parse_console(char* buf) +{ + char type[64]; + char command[64]; + char map[64]; + int x = 0; + int y = 0; + int m; + int n; struct map_session_data sd; memset(&sd, 0, sizeof(struct map_session_data)); - strcpy( sd.status.name , "console"); + strcpy(sd.status.name, "console"); - if ( ( n = sscanf(buf, "%[^:]:%[^:]:%99s %d %d[^\n]", type , command , map , &x , &y )) < 5 ) - if ( ( n = sscanf(buf, "%[^:]:%[^\n]", type , command )) < 2 ) + if( (n=sscanf(buf, "%[^:]:%[^:]:%99s %d %d[^\n]",type,command,map,&x,&y)) < 5 ) + if( (n=sscanf(buf, "%[^:]:%[^\n]",type,command)) < 2 ) n = sscanf(buf,"%[^\n]",type); - if ( n == 5 ) { + if( n == 5 ) { m = map_mapname2mapid(map); - if ( m < 0 ) { + if( m < 0 ){ ShowWarning("Console: Unknown map\n"); return 0; } sd.bl.m = m; map_search_freecell(&sd.bl, m, &sd.bl.x, &sd.bl.y, -1, -1, 0); - if (x > 0) + if( x > 0 ) sd.bl.x = x; - - if (y > 0) + if( y > 0 ) sd.bl.y = y; + } else { + map[0] = '\0'; + if( n < 2 ) command[0] = '\0'; + if( n < 1 ) type[0] = '\0'; } - ShowInfo("Type of command: %s || Command: %s || Map: %s Coords: %d %d\n",type,command,map,x,y); + ShowInfo("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y); - if ( strcmpi("admin",type) == 0 && n == 5 ) { + if( n == 5 && strcmpi("admin",type) == 0 ){ if( is_atcommand_sub(sd.fd,&sd,command,99) == AtCommand_None ) printf("Console: not atcommand\n"); - } else if ( strcmpi("server",type) == 0 && n == 2 ) { - if ( strcmpi("shutdown", command) == 0 || strcmpi("exit",command) == 0 || strcmpi("quit",command) == 0 ) { + } else if( n == 2 && strcmpi("server",type) == 0 ){ + if( strcmpi("shutdown",command) == 0 || + strcmpi("exit",command) == 0 || + strcmpi("quit",command) == 0 ){ runflag = 0; } - } else if ( strcmpi("help",type) == 0 ) { + } else if( strcmpi("help",type) == 0 ){ ShowNotice("To use GM commands:\n"); printf("admin:<gm command>:<map of \"gm\"> <x> <y>\n"); printf("You can use any GM command that doesn't require the GM.\n"); |