Browse Source

- unit_remove_map will reset attackable-time, canact and canwalk delays.
- Added a timer in clif.c so that walk requests that are done while your cannot move duration will be delayed and processed afterwards (as long as the walk delay remaining is less than 2000 ms)


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6329 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 năm trước cách đây
mục cha
commit
a5e5db6539
3 tập tin đã thay đổi với 37 bổ sung6 xóa
  1. 6 1
      Changelog-Trunk.txt
  2. 30 5
      src/map/clif.c
  3. 1 0
      src/map/unit.c

+ 6 - 1
Changelog-Trunk.txt

@@ -3,7 +3,12 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 2006/04/27
-	- Some changes in the slave skill conditions. All their skills are
+	* unit_remove_map will reset attackable-time, canact and canwalk delays.
+	  [Skotlex]
+	* Added a timer in clif.c so that walk requests that are done while your
+	  cannot move duration will be delayed and processed afterwards (as long as
+	  the walk delay remaining is less than 2000 ms) [Skotlex]
+	* Some changes in the slave skill conditions. All their skills are
 	  triggered at a 10% chance now. [Skotlex]
 	* Changed in the behaviour of wedding skills, they should be getting all
 	  the land-skill checks now. [Skotlex]

+ 30 - 5
src/map/clif.c

@@ -8194,6 +8194,24 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
 	clif_servertick(sd);
 }
 
+static int clif_walktoxy_timer(int tid, unsigned int tick, int id, int data)
+{
+	struct map_session_data *sd;
+	short x,y;
+
+	if (!session[id] || (sd = session[id]->session_data) == NULL)
+		return 0;
+	
+	if (!unit_can_move(&sd->bl))
+		return 0;
+
+	x = data>>16;
+	y = data&0xffff;
+
+	unit_walktoxy(&sd->bl, x, y, 0);
+	return 1;
+}
+
 /*==========================================
  *
  *------------------------------------------
@@ -8201,6 +8219,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) {
 void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
 	int x, y;
 	int cmd;
+	unsigned int tick;
 	RFIFOHEAD(fd);
 
 	if (pc_isdead(sd)) {
@@ -8215,8 +8234,6 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
 		return;
 
 	pc_stop_attack(sd);
-	if (!unit_can_move(&sd->bl))
-		return;
 
 	if (sd->invincible_timer != -1)
 		pc_delinvincibletimer(sd);
@@ -8228,9 +8245,17 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) {
 		(RFIFOB(fd,packet_db[sd->packet_ver][cmd].pos[0] + 2) >> 4);
 	//Set last idle time... [Skotlex]
 	sd->idletime = last_tick;
-
+	
+	tick = gettick();
+	if (DIFF_TICK(sd->ud.canmove_tick, tick) > 0 &&
+		DIFF_TICK(sd->ud.canmove_tick, tick) < 2000)
+  	{	// Delay walking command. [Skotlex]
+		add_timer(sd->ud.canmove_tick+1, clif_walktoxy_timer, fd, (x<<16)|y);
+		return;
+	}
+	if (!unit_can_move(&sd->bl))
+		return;
 	unit_walktoxy(&sd->bl, x, y, 0);
-
 }
 
 /*==========================================
@@ -11625,7 +11650,7 @@ int do_init_clif(void) {
 	add_timer_func_list(clif_clearchar_delay_sub, "clif_clearchar_delay_sub");
 	add_timer_func_list(clif_delayquit, "clif_delayquit");
 	add_timer_func_list(clif_nighttimer, "clif_nighttimer");
-
+	add_timer_func_list(clif_walktoxy_timer, "clif_walktoxy_timer");
 	return 0;
 }
 

+ 1 - 0
src/map/unit.c

@@ -1474,6 +1474,7 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
 		unit_stop_attack(bl);
 	if (ud->skilltimer != -1)
 		unit_skillcastcancel(bl,0);
+	ud->attackabletime = ud->canmove_tick = ud->canact_tick = gettick();
 	clif_clearchar_area(bl,clrtype);
 	
 	if (clrtype == 1) //Death. Remove all status changes.