viewing paste Unknown #5949 | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -112,6 +112,14 @@
    return 1;
 }
 
+int unit_teleport_timer(int tid, unsigned int tick, int id, intptr_t data){
+   TBL_MER *mrd = map_id2mc(id);
+   if (mrd->masterteleport_timer != INVALID_TIMER && !check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE)){
+       mrd->masterteleport_timer = 0;
+       unit_warp( mrd->bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
+   }
+}
+
 static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
 {
    int i;
@@ -183,17 +191,15 @@
        } else
            sd->areanpc_id=0;
 
-       if( sd->md && !check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE) )
-       {
-           // mercenary should be warped after being 3 seconds too far from the master [greenbox]
-           if (sd->md->masterteleport_timer == 0)
-           {
-               sd->md->masterteleport_timer = gettick();
+       if( sd->md){
+           if (!check_distance_bl(&sd->bl, &sd->md->bl, MAX_MER_DISTANCE)) {
+               if(sd->md->masterteleport_timer == INVALID_TIMER)
+                   sd->md->masterteleport_timer = add_timer(gettick()+3000,unit_teleport_timer,sd->md->bl.id,MAX_MER_DISTANCE);
            }
-           else if (DIFF_TICK(gettick(), sd->md->masterteleport_timer) > 3000)
-           {
-               sd->md->masterteleport_timer = 0;
-               unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
+           else {
+               if(sd->md->masterteleport_timer != INVALID_TIMER)
+                   delete_timer(sd->md->masterteleport_timer,unit_teleport_timer);
+               sd->md->masterteleport_timer = INVALID_TIMER; //cancel recall
            }
        }
        else if( sd->md )
@@ -224,24 +230,16 @@
    }
    else if( mrd && mrd->master )
    {
-       if (!check_distance_bl(&mrd->master->bl, bl, MAX_MER_DISTANCE))
-       {
-           // mercenary should be warped after being 3 seconds too far from the master [greenbox]
-           if (mrd->masterteleport_timer == 0)
-           {
-               mrd->masterteleport_timer = gettick();
+       if (!check_distance_bl(&mrd->master->bl, bl, MAX_MER_DISTANCE)) {
+               if(sd->md->masterteleport_timer == INVALID_TIMER)
+                   sd->md->masterteleport_timer = add_timer(gettick()+3000,unit_teleport_timer,mrd->bl.id,MAX_MER_DISTANCE);
            }
-           else if (DIFF_TICK(gettick(), mrd->masterteleport_timer) > 3000)
-           {
-               mrd->masterteleport_timer = 0;
-               unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
+       else {
+           if(mrd->masterteleport_timer != INVALID_TIMER)
+               delete_timer(mrd->masterteleport_timer,unit_teleport_timer);
+           mrd->masterteleport_timer = INVALID_TIMER; //cancel recall
            }
        }
-       else
-       {
-           mrd->masterteleport_timer = 0;
-       }
-   }
 
    if(tid == INVALID_TIMER) //A directly invoked timer is from battle_stop_walking, therefore the rest is irrelevant.
        return 0;
Viewed 1051 times, submitted by lighta.