From 792dfbb243bcbeee644bd096b7bd925a1e5c1e74 Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 11 Jul 2006 20:16:55 +0000 Subject: - Fixed clif_parse not checking for func_parse before sending data to the connected clients. This in turn required various code-rewrites in: - duel related messaging functions (added clif targets DUEL/DUEL_WOS). - intif whisper to gm function - day/night timers - Rewrote the parse_console function to stop allocating/deallocating memory on every call. - Modified chrif_charselectreq to receive the player's ip among the data. - Added function clif_disp_message, which is the same as clif_disp_onlyself, except you can specify the targets (it sends a guild-chat packet) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7617 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/map.c | 55 +++++++++++++++---------------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index d1859327e..253ffe9bf 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1693,11 +1693,10 @@ int map_quit(struct map_session_data *sd) { } if(sd->fd) { //Player will be free'd on save-ack. [Skotlex] - if (session[sd->fd] && session[sd->fd]->session_data == sd) + if (session[sd->fd]) session[sd->fd]->session_data = NULL; sd->fd = 0; } - return 0; } @@ -3195,54 +3194,38 @@ static int char_ip_set = 0; *------------------------------------------ */ int parse_console(char *buf) { - char *type,*command,*map, *buf2; + char type[64],command[64],map[64], buf2[72]; int x = 0, y = 0; int m, n; - struct map_session_data *sd; - - sd = (struct map_session_data*)aCalloc(sizeof(struct map_session_data), 1); - - sd->fd = 0; - strcpy( sd->status.name , "console"); + struct map_session_data sd; - type = (char *)aCallocA(64,1); - command = (char *)aCallocA(64,1); - map = (char *)aCallocA(64,1); - buf2 = (char *)aCallocA(72,1); + memset(&sd, 0, sizeof(struct map_session_data)); + 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 ) n = sscanf(buf,"%[^\n]",type); if ( n == 5 ) { - if (x <= 0) { - x = rand() % 399 + 1; - sd->bl.x = x; - } else { - sd->bl.x = x; - } - - if (y <= 0) { - y = rand() % 399 + 1; - sd->bl.y = y; - } else { - sd->bl.y = y; - } - m = map_mapname2mapid(map); - if ( m >= 0 ) - sd->bl.m = m; - else { + if ( m < 0 ) { ShowWarning("Console: Unknown map\n"); - goto end; + return 0; } + sd.bl.m = m; + map_search_freecell(&sd.bl, m, &sd.bl.x, &sd.bl.y, -1, -1, 0); + if (x > 0) + sd.bl.x = x; + + if (y > 0) + sd.bl.y = 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 ) { sprintf(buf2,"console: %s",command); - if( is_atcommand(sd->fd,sd,buf2,99) == AtCommand_None ) + if( is_atcommand(sd.fd,&sd,buf2,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 ) { @@ -3259,14 +3242,6 @@ int parse_console(char *buf) { printf("server:shutdown\n"); } - end: - aFree(buf); - aFree(type); - aFree(command); - aFree(map); - aFree(buf2); - aFree(sd); - return 0; } -- cgit v1.2.3-60-g2f50