Skip to content

Commit

Permalink
@autopilot fix lag issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SeravySensei committed Jun 24, 2019
1 parent 253c255 commit 8ea67eb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/map/homunculus.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/map/homunculus.hpp
Expand Up @@ -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]
};
Expand Down
10 changes: 8 additions & 2 deletions src/map/path.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/map/unit.cpp
Expand Up @@ -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");

}

Expand Down

0 comments on commit 8ea67eb

Please sign in to comment.