viewing paste ra_unittimer.diff | Diff

Posted on the
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
Index: src/map/mercenary.c
===================================================================
--- src/map/mercenary.c (revision 17348)
+++ src/map/mercenary.c (working copy)
@@ -321,6 +321,7 @@
        map_addiddb(&md->bl);
        status_calc_mercenary(md,1);
        md->contract_timer = INVALID_TIMER;
+       md->masterteleport_timer = INVALID_TIMER;
        merc_contract_init(md);
    }
    else
@@ -473,7 +474,7 @@
        ShowError("read_mercenary_skilldb : Class %d not found in mercenary_db for skill entry.\n", class_);
        return false;
    }
-   
+
    skill_id = atoi(str[1]);
    if( skill_id < MC_SKILLBASE || skill_id >= MC_SKILLBASE + MAX_MERCSKILL )
    {
@@ -502,7 +503,7 @@
 {
    read_mercenarydb();
    read_mercenary_skilldb();
-   
+
    //add_timer_func_list(mercenary_contract, "mercenary_contract");
    return 0;
 }
Index: src/map/unit.c
===================================================================
--- src/map/unit.c  (revision 17348)
+++ src/map/unit.c  (working copy)
@@ -140,22 +140,15 @@
    struct block_list *bl = map_id2bl(id);
    int *mast_tid = unit_get_masterteleport_timer(bl);
 
-   if(tid == INVALID_TIMER)
+   if(tid == INVALID_TIMER || mast_tid == NULL)
        return 0;
-   else if(*mast_tid && *mast_tid != tid)
+   else if(*mast_tid != tid)
        return 0;
    else {
        TBL_PC *msd = unit_get_master(bl);
-       switch(data){
-       case BL_HOM:
-       case BL_ELEM:
-       case BL_PET :
-       case BL_MER :
-           if(msd && *mast_tid != INVALID_TIMER && !check_distance_bl(&msd->bl, bl, MAX_MER_DISTANCE)){
-               *mast_tid = INVALID_TIMER;
-               unit_warp(bl, msd->bl.id, msd->bl.x, msd->bl.y, CLR_TELEPORT );
-           }
-           break;
+       if(msd && !check_distance_bl(&msd->bl, bl, data)){
+           *mast_tid = INVALID_TIMER;
+           unit_warp(bl, msd->bl.id, msd->bl.x, msd->bl.y, CLR_TELEPORT );
        }
    }
    return 0;
@@ -163,19 +156,19 @@
 
 int unit_check_start_teleport_timer(struct block_list *sbl){
    TBL_PC *msd = unit_get_master(sbl);
-   int max_dist=AREA_SIZE;
+   int max_dist=0;
    switch(sbl->type){
-       //case BL_HOM: max_dist = MAX_HOM_DISTANCE; break;
+       case BL_HOM: max_dist = AREA_SIZE; break;
        case BL_ELEM: max_dist = MAX_ELEDISTANCE; break;
-       //case BL_PET : max_dist = MAX_PET_DISTANCE; break;
+       case BL_PET : max_dist = AREA_SIZE; break;
        case BL_MER : max_dist = MAX_MER_DISTANCE; break;
    }
-   if(msd){ //if there is a master
+   if(msd && max_dist){ //if there is a master and it's a valid type
        int *msd_tid = unit_get_masterteleport_timer(sbl);
-
+       if(msd_tid == NULL) return 0;
        if (!check_distance_bl(&msd->bl, sbl, max_dist)) {
            if(*msd_tid == INVALID_TIMER || *msd_tid == 0)
-               *msd_tid = add_timer(gettick()+3000,unit_teleport_timer,sbl->id,BL_MER);
+               *msd_tid = add_timer(gettick()+3000,unit_teleport_timer,sbl->id,max_dist);
        }
        else {
            if(*msd_tid && *msd_tid != INVALID_TIMER)
Index: src/map/pet.c
===================================================================
--- src/map/pet.c   (revision 17348)
+++ src/map/pet.c   (working copy)
@@ -382,6 +382,7 @@
    if( interval <= 0 )
        interval = 1;
    pd->pet_hungry_timer = add_timer(gettick() + interval, pet_hungry, sd->bl.id, 0);
+   pd->masterteleport_timer = INVALID_TIMER;
    return 0;
 }
 
Index: src/map/homunculus.c
===================================================================
--- src/map/homunculus.c    (revision 17348)
+++ src/map/homunculus.c    (working copy)
@@ -798,6 +798,7 @@
    status_calc_homunculus(hd,1);
 
    hd->hungry_timer = INVALID_TIMER;
+   hd->masterteleport_timer = INVALID_TIMER;
    return 0;
 }
 
Index: src/map/elemental.c
===================================================================
--- src/map/elemental.c (revision 17348)
+++ src/map/elemental.c (working copy)
@@ -261,6 +261,7 @@
        status_calc_elemental(ed,1);
        ed->last_spdrain_time = ed->last_thinktime = gettick();
        ed->summon_timer = INVALID_TIMER;
+       ed->masterteleport_timer = INVALID_TIMER;
        elemental_summon_init(ed);
    } else {
        memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental));
 
 
 
 
Viewed 1311 times, submitted by lighta.