summaryrefslogtreecommitdiff
path: root/src/map/unit.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-03 07:48:38 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-03 07:48:38 +0000
commitc70e4ff87c88500a1608a9af714e372f0d99f313 (patch)
tree2699c1773f73035748653218697e88d0e58f3b87 /src/map/unit.c
parente613ccec54b8ef64eb3e807b5097611cb53c199c (diff)
downloadhercules-c70e4ff87c88500a1608a9af714e372f0d99f313.tar.gz
hercules-c70e4ff87c88500a1608a9af714e372f0d99f313.tar.bz2
hercules-c70e4ff87c88500a1608a9af714e372f0d99f313.tar.xz
hercules-c70e4ff87c88500a1608a9af714e372f0d99f313.zip
- 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
Diffstat (limited to 'src/map/unit.c')
-rw-r--r--src/map/unit.c30
1 files changed, 25 insertions, 5 deletions
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;
}