From d4aa4c70a7ec51781109d27c9a7041e0a37d488f Mon Sep 17 00:00:00 2001 From: Playtester Date: Sat, 28 Feb 2015 15:41:18 +0100 Subject: [PATCH] Walkpath loop fix (fixes #198) - Move requests one cell west will now be ignored if the target cell is occupied - You can now set official_cell_stack_limit to 0 to completely disable it including the limitation above --- conf/battle/misc.conf | 1 + src/map/battle.c | 2 +- src/map/clif.c | 9 +++++++-- src/map/mob.c | 3 ++- src/map/unit.c | 3 ++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/conf/battle/misc.conf b/conf/battle/misc.conf index dab6d85c38..061de2a412 100644 --- a/conf/battle/misc.conf +++ b/conf/battle/misc.conf @@ -92,6 +92,7 @@ duel_only_on_same_map: no // Official - Only affects the walking routines of characters, including monsters. // If a unit stops walking and is on a cell with more than stack limit // characters on it, it will walk to the closest free cell. +// Set to 0 for no cell stacking checks and free movement. // Custom - This variation will make every full cell to be considered a wall. // NOTE: For the custom setting to take effect you have to use a server compiled // with Cell Stack Limit support (see src/map/map.h) diff --git a/src/map/battle.c b/src/map/battle.c index 06400f4706..2aa2c6d04e 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7704,7 +7704,7 @@ static const struct _battle_data { { "bone_drop", &battle_config.bone_drop, 0, 0, 2, }, { "buyer_name", &battle_config.buyer_name, 1, 0, 1, }, { "skill_wall_check", &battle_config.skill_wall_check, 1, 0, 1, }, - { "official_cell_stack_limit", &battle_config.official_cell_stack_limit, 1, 1, 255, }, + { "official_cell_stack_limit", &battle_config.official_cell_stack_limit, 1, 0, 255, }, { "custom_cell_stack_limit", &battle_config.custom_cell_stack_limit, 1, 1, 255, }, { "dancing_weaponswitch_fix", &battle_config.dancing_weaponswitch_fix, 1, 0, 1, }, diff --git a/src/map/clif.c b/src/map/clif.c index 1afd7a475a..e67352dda9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -10074,6 +10074,13 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH]) return; + RFIFOPOS(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0], &x, &y, NULL); + + //A move command one cell west is only valid if the target cell is free + if(battle_config.official_cell_stack_limit > 0 + && sd->bl.x == x+1 && sd->bl.y == y && map_count_oncell(sd->bl.m, x, y, BL_CHAR|BL_NPC, 1)) + return; + // Cloaking wall check is actually updated when you click to process next movement // not when you move each cell. This is official behaviour. if (sd->sc.data[SC_CLOAKING]) @@ -10081,8 +10088,6 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) pc_delinvincibletimer(sd); - RFIFOPOS(fd, packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0], &x, &y, NULL); - //Set last idle time... [Skotlex] if (battle_config.idletime_option&IDLE_WALK) sd->idletime = last_tick; diff --git a/src/map/mob.c b/src/map/mob.c index c889c0f180..2dd27db1e3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1334,7 +1334,8 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick) md->ud.target_to = 0; unit_set_target(&md->ud, 0); } - if(map_count_oncell(md->bl.m, md->bl.x, md->bl.y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) { + if(battle_config.official_cell_stack_limit > 0 + && map_count_oncell(md->bl.m, md->bl.x, md->bl.y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) { unit_walktoxy(&md->bl, md->bl.x, md->bl.y, 8); } diff --git a/src/map/unit.c b/src/map/unit.c index 8c985a95cd..c22e40038c 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -520,7 +520,8 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data ud->to_x = bl->x; ud->to_y = bl->y; - if(map_count_oncell(bl->m, x, y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) { + if(battle_config.official_cell_stack_limit > 0 + && map_count_oncell(bl->m, x, y, BL_CHAR|BL_NPC, 1) > battle_config.official_cell_stack_limit) { //Walked on occupied cell, call unit_walktoxy again if(ud->steptimer != INVALID_TIMER) { //Execute step timer on next step instead