diff --git a/src/map/homunculus.cpp b/src/map/homunculus.cpp index 1e80eb24a67..a7759e13814 100644 --- a/src/map/homunculus.cpp +++ b/src/map/homunculus.cpp @@ -920,6 +920,12 @@ int hom_hungry_timer_delete(struct homun_data *hd) delete_timer(hd->hungry_timer,hom_hungry); hd->hungry_timer = INVALID_TIMER; } + + if (hd->autopilottimer != INVALID_TIMER) { + delete_timer(hd->autopilottimer, unit_autopilot_homunculus_timer); + hd->autopilottimer = INVALID_TIMER; + } + return 1; } @@ -1048,7 +1054,7 @@ void hom_alloc(struct map_session_data *sd, struct s_homunculus *hom) hd->hungry_timer = INVALID_TIMER; hd->masterteleport_timer = INVALID_TIMER; - add_timer_interval(gettick() + 100, unit_autopilot_homunculus_timer, hd->bl.id, 0, 100); + hd->autopilottimer = INVALID_TIMER; } @@ -1060,6 +1066,10 @@ void hom_init_timers(struct homun_data * hd) { if (hd->hungry_timer == INVALID_TIMER) hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,hom_hungry,hd->master->bl.id,0); + + if (hd->autopilottimer == INVALID_TIMER) + hd->autopilottimer = add_timer_interval(gettick() + 100, unit_autopilot_homunculus_timer, hd->bl.id, 0, 100); + hd->regen.state.block = 0; //Restore HP/SP block. hd->masterteleport_timer = INVALID_TIMER; } @@ -1645,6 +1655,7 @@ void do_init_homunculus(void){ // Add homunc timer function to timer func list [Toms] add_timer_func_list(hom_hungry, "hom_hungry"); + add_timer_func_list(unit_autopilot_homunculus_timer, "unit_autopilot_homunculus_timer"); //Stock view data for homuncs memset(&hom_viewdb, 0, sizeof(hom_viewdb)); diff --git a/src/map/homunculus.hpp b/src/map/homunculus.hpp index 2136dd49faf..5961957b6ce 100644 --- a/src/map/homunculus.hpp +++ b/src/map/homunculus.hpp @@ -66,6 +66,7 @@ struct homun_data { int masterteleport_timer; struct map_session_data *master; //pointer back to its master int hungry_timer; //[orn] + int autopilottimer; unsigned int exp_next; char blockskill[MAX_SKILL]; // [orn] }; diff --git a/src/map/path.cpp b/src/map/path.cpp index a2e59ed5e26..fe44c3f23eb 100644 --- a/src/map/path.cpp +++ b/src/map/path.cpp @@ -397,8 +397,14 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x break; } - if (abs(x - x0) > maxdist) continue; - if (abs(y - y0) > maxdist) continue; + // Heuristic : stop processing if path can't possibly be shorter than maximum length allowed + int usedlength = abs(x - x0); + if (usedlength < abs(y - y0)) usedlength = abs(y - y0); + + int needlength = abs(x - x1); + if (needlength < abs(y - y1)) needlength = abs(y - y1); + + if (usedlength+needlength > maxdist) continue; if (y < ys && !map_getcellp(mapdata, x, y+1, cell)) allowed_dirs |= PATH_DIR_NORTH; if (y > 0 && !map_getcellp(mapdata, x, y-1, cell)) allowed_dirs |= PATH_DIR_SOUTH; diff --git a/src/map/unit.cpp b/src/map/unit.cpp index 8643ca77d42..5153a2caf37 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -8364,7 +8364,7 @@ void do_init_unit(void){ add_timer_func_list(unit_step_timer,"unit_step_timer"); add_timer_func_list(unit_autopilot_timer, "unit_autopilot_timer"); - add_timer_func_list(unit_autopilot_homunculus_timer, "unit_autopilot_homunculus_timer"); +// add_timer_func_list(unit_autopilot_homunculus_timer, "unit_autopilot_homunculus_timer"); }