diff options
Diffstat (limited to 'src/map/map.c')
-rw-r--r-- | src/map/map.c | 176 |
1 files changed, 84 insertions, 92 deletions
diff --git a/src/map/map.c b/src/map/map.c index b052cd7bc..e3cada963 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -393,19 +393,11 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) //TODO: Perhaps some outs of bounds checking should be placed here? if (bl->type&BL_CHAR) { skill_unit_move(bl,tick,2); - sc = status_get_sc(bl); - if (sc && sc->count) { - if (sc->data[SC_CLOSECONFINE]) - status_change_end(bl, SC_CLOSECONFINE, -1); - if (sc->data[SC_CLOSECONFINE2]) - status_change_end(bl, SC_CLOSECONFINE2, -1); -// if (sc->data[SC_BLADESTOP]) //Won't stop when you are knocked away, go figure... -// status_change_end(bl, SC_BLADESTOP, -1); - if (sc->data[SC_TATAMIGAESHI]) - status_change_end(bl, SC_TATAMIGAESHI, -1); - if (sc->data[SC_MAGICROD]) - status_change_end(bl, SC_MAGICROD, -1); - } + status_change_end(bl, SC_CLOSECONFINE, INVALID_TIMER); + status_change_end(bl, SC_CLOSECONFINE2, INVALID_TIMER); +// status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure... + status_change_end(bl, SC_TATAMIGAESHI, INVALID_TIMER); + status_change_end(bl, SC_MAGICROD, INVALID_TIMER); } else if (bl->type == BL_NPC) npc_unsetcells((TBL_NPC*)bl); @@ -423,6 +415,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick) if (bl->type&BL_CHAR) { skill_unit_move(bl,tick,3); + sc = status_get_sc(bl); if (sc) { if (sc->count) { if (sc->data[SC_CLOAKING]) @@ -1566,7 +1559,7 @@ int map_quit(struct map_session_data *sd) return 0; } - if (sd->npc_timer_id != -1) //Cancel the event timer. + if (sd->npc_timer_id != INVALID_TIMER) //Cancel the event timer. npc_timerevent_quit(sd); if (sd->npc_id) @@ -1580,64 +1573,40 @@ int map_quit(struct map_session_data *sd) if( sd->sc.count ) { //Status that are not saved... - if(sd->sc.data[SC_BOSSMAPINFO]) - status_change_end(&sd->bl,SC_BOSSMAPINFO,-1); - if(sd->sc.data[SC_AUTOTRADE]) - status_change_end(&sd->bl,SC_AUTOTRADE,-1); - if(sd->sc.data[SC_SPURT]) - status_change_end(&sd->bl,SC_SPURT,-1); - if(sd->sc.data[SC_BERSERK]) - status_change_end(&sd->bl,SC_BERSERK,-1); - if(sd->sc.data[SC_TRICKDEAD]) - status_change_end(&sd->bl,SC_TRICKDEAD,-1); - if(sd->sc.data[SC_GUILDAURA]) - status_change_end(&sd->bl,SC_GUILDAURA,-1); + status_change_end(&sd->bl, SC_BOSSMAPINFO, INVALID_TIMER); + status_change_end(&sd->bl, SC_AUTOTRADE, INVALID_TIMER); + status_change_end(&sd->bl, SC_SPURT, INVALID_TIMER); + status_change_end(&sd->bl, SC_BERSERK, INVALID_TIMER); + status_change_end(&sd->bl, SC_TRICKDEAD, INVALID_TIMER); + status_change_end(&sd->bl, SC_GUILDAURA, INVALID_TIMER); if(sd->sc.data[SC_ENDURE] && sd->sc.data[SC_ENDURE]->val4) - status_change_end(&sd->bl,SC_ENDURE,-1); //No need to save infinite endure. - if(sd->sc.data[SC_WEIGHT50]) - status_change_end(&sd->bl,SC_WEIGHT50,-1); - if(sd->sc.data[SC_WEIGHT90]) - status_change_end(&sd->bl,SC_WEIGHT90,-1); + status_change_end(&sd->bl, SC_ENDURE, INVALID_TIMER); //No need to save infinite endure. + status_change_end(&sd->bl, SC_WEIGHT50, INVALID_TIMER); + status_change_end(&sd->bl, SC_WEIGHT90, INVALID_TIMER); if (battle_config.debuff_on_logout&1) { - if(sd->sc.data[SC_ORCISH]) - status_change_end(&sd->bl,SC_ORCISH,-1); - if(sd->sc.data[SC_STRIPWEAPON]) - status_change_end(&sd->bl,SC_STRIPWEAPON,-1); - if(sd->sc.data[SC_STRIPARMOR]) - status_change_end(&sd->bl,SC_STRIPARMOR,-1); - if(sd->sc.data[SC_STRIPSHIELD]) - status_change_end(&sd->bl,SC_STRIPSHIELD,-1); - if(sd->sc.data[SC_STRIPHELM]) - status_change_end(&sd->bl,SC_STRIPHELM,-1); - if(sd->sc.data[SC_EXTREMITYFIST]) - status_change_end(&sd->bl,SC_EXTREMITYFIST,-1); - if(sd->sc.data[SC_EXPLOSIONSPIRITS]) - status_change_end(&sd->bl,SC_EXPLOSIONSPIRITS,-1); + status_change_end(&sd->bl, SC_ORCISH, INVALID_TIMER); + status_change_end(&sd->bl, SC_STRIPWEAPON, INVALID_TIMER); + status_change_end(&sd->bl, SC_STRIPARMOR, INVALID_TIMER); + status_change_end(&sd->bl, SC_STRIPSHIELD, INVALID_TIMER); + status_change_end(&sd->bl, SC_STRIPHELM, INVALID_TIMER); + status_change_end(&sd->bl, SC_EXTREMITYFIST, INVALID_TIMER); + status_change_end(&sd->bl, SC_EXPLOSIONSPIRITS, INVALID_TIMER); if(sd->sc.data[SC_REGENERATION] && sd->sc.data[SC_REGENERATION]->val4) - status_change_end(&sd->bl,SC_REGENERATION,-1); + status_change_end(&sd->bl, SC_REGENERATION, INVALID_TIMER); //TO-DO Probably there are way more NPC_type negative status that are removed - if(sd->sc.data[SC_CHANGEUNDEAD]) - status_change_end(&sd->bl,SC_CHANGEUNDEAD,-1); + status_change_end(&sd->bl, SC_CHANGEUNDEAD, INVALID_TIMER); // Both these statuses are removed on logout. [L0ne_W0lf] - if(sd->sc.data[SC_SLOWCAST]) - status_change_end(&sd->bl,SC_SLOWCAST,-1); - if(sd->sc.data[SC_CRITICALWOUND]) - status_change_end(&sd->bl,SC_CRITICALWOUND,-1); + status_change_end(&sd->bl, SC_SLOWCAST, INVALID_TIMER); + status_change_end(&sd->bl, SC_CRITICALWOUND, INVALID_TIMER); } if (battle_config.debuff_on_logout&2) { - if(sd->sc.data[SC_MAXIMIZEPOWER]) - status_change_end(&sd->bl,SC_MAXIMIZEPOWER,-1); - if(sd->sc.data[SC_MAXOVERTHRUST]) - status_change_end(&sd->bl,SC_MAXOVERTHRUST,-1); - if(sd->sc.data[SC_STEELBODY]) - status_change_end(&sd->bl,SC_STEELBODY,-1); - if(sd->sc.data[SC_PRESERVE]) - status_change_end(&sd->bl,SC_PRESERVE,-1); - if(sd->sc.data[SC_KAAHI]) - status_change_end(&sd->bl,SC_KAAHI,-1); - if(sd->sc.data[SC_SPIRIT]) - status_change_end(&sd->bl,SC_SPIRIT,-1); + status_change_end(&sd->bl, SC_MAXIMIZEPOWER, INVALID_TIMER); + status_change_end(&sd->bl, SC_MAXOVERTHRUST, INVALID_TIMER); + status_change_end(&sd->bl, SC_STEELBODY, INVALID_TIMER); + status_change_end(&sd->bl, SC_PRESERVE, INVALID_TIMER); + status_change_end(&sd->bl, SC_KAAHI, INVALID_TIMER); + status_change_end(&sd->bl, SC_SPIRIT, INVALID_TIMER); } } @@ -2109,7 +2078,7 @@ int map_addmobtolist(unsigned short m, struct spawn_data *spawn) void map_spawnmobs(int m) { int i, k=0; - if (map[m].mob_delete_timer != -1) + if (map[m].mob_delete_timer != INVALID_TIMER) { //Mobs have not been removed yet [Skotlex] delete_timer(map[m].mob_delete_timer, map_removemobs_timer); map[m].mob_delete_timer = INVALID_TIMER; @@ -2184,7 +2153,7 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr data) void map_removemobs(int m) { - if (map[m].mob_delete_timer != -1) // should never happen + if (map[m].mob_delete_timer != INVALID_TIMER) // should never happen return; //Mobs are already scheduled for removal map[m].mob_delete_timer = add_timer(gettick()+battle_config.mob_remove_delay, map_removemobs_timer, m, 0); @@ -2804,8 +2773,16 @@ void map_flags_init(void) for( i = 0; i < map_num; i++ ) { + // mapflags memset(&map[i].flag, 0, sizeof(map[i].flag)); + // additional mapflag data + map[i].zone = 0; // restricted mapflag zone + map[i].nocommand = 0; // nocommand mapflag level + map[i].bexp = 100; // per map base exp multiplicator + map[i].jexp = 100; // per map job exp multiplicator + + // adjustments if( battle_config.pk_mode ) map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris] } @@ -2975,11 +2952,7 @@ int map_readallmaps (void) map[i].bxs = (map[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; map[i].bys = (map[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; - - // default experience multiplicators - map[i].jexp = 100; - map[i].bexp = 100; - + size = map[i].bxs * map[i].bys * sizeof(struct block_list*); map[i].block = (struct block_list**)aCalloc(size, 1); map[i].block_mob = (struct block_list**)aCalloc(size, 1); @@ -3012,7 +2985,7 @@ static int char_ip_set = 0; /*========================================== * Console Command Parser [Wizputer] *------------------------------------------*/ -int parse_console(char* buf) +int parse_console(const char* buf) { char type[64]; char command[64]; @@ -3026,14 +2999,20 @@ int parse_console(char* buf) 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 = sscanf(buf, "%63[^:]:%63[^:]:%63s %d %d[^\n]", type, command, map, &x, &y) ) < 5 ) + { + if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ) + { + n = sscanf(buf, "%63[^\n]", type); + } + } - if( n == 5 ) { + if( n == 5 ) + { m = map_mapname2mapid(map); - if( m < 0 ){ - ShowWarning("Console: Unknown map\n"); + if( m < 0 ) + { + ShowWarning("Console: Unknown map.\n"); return 0; } sd.bl.m = m; @@ -3042,32 +3021,40 @@ int parse_console(char* buf) sd.bl.x = x; if( y > 0 ) sd.bl.y = y; - } else { + } + else + { map[0] = '\0'; - if( n < 2 ) command[0] = '\0'; - if( n < 1 ) type[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); + ShowNotice("Type of command: '%s' || Command: '%s' || Map: '%s' Coords: %d %d\n", type, command, map, x, y); - if( n == 5 && strcmpi("admin",type) == 0 ){ - if( !is_atcommand(sd.fd,&sd,command,0) ) + if( n == 5 && strcmpi("admin",type) == 0 ) + { + if( !is_atcommand(sd.fd, &sd, command, 0) ) ShowInfo("Console: not atcommand\n"); - } else if( n == 2 && strcmpi("server",type) == 0 ){ - 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 ){ - ShowNotice("To use GM commands:\n"); - ShowInfo("admin:<gm command>:<map of \"gm\"> <x> <y>\n"); + } + else if( strcmpi("help", type) == 0 ) + { + ShowInfo("To use GM commands:\n"); + ShowInfo(" admin:<gm command>:<map of \"gm\"> <x> <y>\n"); ShowInfo("You can use any GM command that doesn't require the GM.\n"); ShowInfo("No using @item or @warp however you can use @charwarp\n"); ShowInfo("The <map of \"gm\"> <x> <y> is for commands that need coords of the GM\n"); ShowInfo("IE: @spawn\n"); ShowInfo("To shutdown the server:\n"); - ShowInfo("server:shutdown\n"); + ShowInfo(" server:shutdown\n"); } return 0; @@ -3412,9 +3399,14 @@ void do_final(void) ShowStatus("Terminating...\n"); + // remove all objects on maps for (i = 0; i < map_num; i++) + { + ShowStatus("Cleaning up maps [%d/%d]: %s..."CL_CLL"\r", i+1, map_num, map[i].name); if (map[i].m >= 0) map_foreachinmap(cleanup_sub, i, BL_ALL); + } + ShowStatus("Cleaned up %d maps."CL_CLL"\n", map_num); //Scan any remaining players (between maps?) to kick them out. [Skotlex] iter = mapit_getallusers(); |