From c70e4ff87c88500a1608a9af714e372f0d99f313 Mon Sep 17 00:00:00 2001 From: skotlex Date: Sat, 3 Feb 2007 07:48:38 +0000 Subject: - Fixed the flag parameter not working on npcshopattach - Modified unit_walktoxy so it accepts flag &4. When used, this flag will delay the walk request if the character is unable to move because of the can't walk delay. This is used for player and homunculus walk requests. - Removed the delay walking code from clif.c as it's now handled by unit.c - Added a possible crash protection in clif_skillfail when the player is without a connection. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9782 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/unit.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/unit.c b/src/map/unit.c index 30c47de06..53296f61a 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -261,8 +261,21 @@ static int unit_walktoxy_timer(int tid,unsigned int tick,int id,int data) return 0; } -//Easy parameter: &1 -> 1/0 = easy/hard, &2 -> force walking. -int unit_walktoxy( struct block_list *bl, int x, int y, int easy) { +static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, int data) +{ + struct block_list *bl = map_id2bl(id); + + if (!bl || bl->prev == NULL) + return 0; + unit_walktoxy(bl, data>>16, data&0xffff, 0); + return 1; +} + +//flag parameter: +//&1 -> 1/0 = easy/hard +//&2 -> force walking +//&4 -> Delay walking if the reason you can't walk is the canwalk delay +int unit_walktoxy( struct block_list *bl, int x, int y, int flag) { struct unit_data *ud = NULL; struct status_change *sc = NULL; @@ -272,10 +285,17 @@ int unit_walktoxy( struct block_list *bl, int x, int y, int easy) { if( ud == NULL) return 0; - if(!(easy&2) && (!status_get_mode(bl)&MD_CANMOVE || !unit_can_move(bl))) + if (flag&4 && DIFF_TICK(ud->canmove_tick, gettick()) > 0 && + DIFF_TICK(ud->canmove_tick, gettick()) < 2000) + { // Delay walking command. [Skotlex] + add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); + return 1; + } + + if(!(flag&2) && (!status_get_mode(bl)&MD_CANMOVE || !unit_can_move(bl))) return 0; - ud->state.walk_easy = easy&1; + ud->state.walk_easy = flag&1; ud->target = 0; ud->to_x = x; ud->to_y = y; @@ -1905,7 +1925,7 @@ int do_init_unit(void) { add_timer_func_list(unit_attack_timer, "unit_attack_timer"); add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer"); add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub"); - + add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer"); return 0; } -- cgit v1.2.3-60-g2f50