viewing paste Unknown #6400 | 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 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
Index: conf/channels.conf
===================================================================
--- conf/channels.conf  (revision 17383)
+++ conf/channels.conf  (working copy)
@@ -25,8 +25,8 @@
        /* Add as many colors as you'd like. */
    }
 
-   /* Allow users to create their own (private) channels through @channels command? */
-   /* (must also allow players to use @channels in groups.conf) */
+   /* Allow users to create their own (private) channels through @channel command? */
+   /* (must also allow players to use @channel in groups.conf) */
    allow_user_channel_creation: true
 
    /* "map_local_channel" is an instanced channel unique to each map. */
Index: src/map/buyingstore.c
===================================================================
--- src/map/buyingstore.c   (revision 17383)
+++ src/map/buyingstore.c   (working copy)
@@ -41,7 +41,7 @@
 /// Returns unique buying store id
 static unsigned int buyingstore_getuid(void)
 {
-   return buyingstore_nextid++;
+   return ++buyingstore_nextid;
 }
 
 
Index: src/map/clif.c
===================================================================
--- src/map/clif.c  (revision 17383)
+++ src/map/clif.c  (working copy)
@@ -9611,6 +9611,7 @@
        (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
    {
        set_eof(fd);
+       pc_damage_log_clear(sd,0);
        clif_disconnect_ack(sd, 0);
    } else {
        clif_disconnect_ack(sd, 1);
@@ -9980,6 +9981,7 @@
        if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] &&
            (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) )
        {   //Send to char-server for character selection.
+           pc_damage_log_clear(sd,0);
            chrif_charselectreq(sd, session[fd]->client_addr);
        } else {
            clif_disconnect_ack(sd, 1);
Index: src/map/map.c
===================================================================
--- src/map/map.c   (revision 17383)
+++ src/map/map.c   (working copy)
@@ -1724,6 +1724,7 @@
        }
    }
 
+   pc_damage_log_clear(sd,0);
    party_booking_delete(sd); // Party Booking [Spiria]
    pc_makesavestatus(sd);
    pc_clean_skilltree(sd);
Index: src/map/mob.c
===================================================================
--- src/map/mob.c   (revision 17383)
+++ src/map/mob.c   (working copy)
@@ -2019,6 +2019,9 @@
            if(md->dmglog[i].id==0) {   //Store data in first empty slot.
                md->dmglog[i].id  = char_id;
                md->dmglog[i].flag= flag;
+
+               if(md->db->mexp)
+                   pc_damage_log_add(map_charid2sd(char_id),md->bl.id);
                break;
            }
            if(md->dmglog[i].dmg<mindmg && i)
@@ -2033,6 +2036,9 @@
            md->dmglog[minpos].id  = char_id;
            md->dmglog[minpos].flag= flag;
            md->dmglog[minpos].dmg = damage;
+
+           if(md->db->mexp)
+               pc_damage_log_add(map_charid2sd(char_id),md->bl.id);
        }
    }
    return;
@@ -2160,6 +2166,8 @@
            case MDLF_HOMUN:  dmgbltypes|= BL_HOM; break;
            case MDLF_PET:    dmgbltypes|= BL_PET; break;
        }
+       if( md->db->mexp )
+           pc_damage_log_clear(tsd,md->bl.id);
    }
 
    // determines, if the monster was killed by homunculus' damage only
Index: src/map/pc.c
===================================================================
--- src/map/pc.c    (revision 17383)
+++ src/map/pc.c    (working copy)
@@ -9962,6 +9962,64 @@
    return;
 }
 
+void pc_clear_log_damage_sub(int char_id, struct mob_data *md)
+{
+   int i;
+   ARR_FIND(0,DAMAGELOG_SIZE,i,md->dmglog[i].id == char_id);
+   if( i < DAMAGELOG_SIZE )
+   {
+       md->dmglog[i].id=0;
+       md->dmglog[i].dmg=0;
+       md->dmglog[i].flag=0;
+   }
+}
+
+void pc_damage_log_add(struct map_session_data *sd, int id)
+{
+   int i = 0;
+
+   if( !sd )
+       return;
+
+   for(i = 0; i < DAMAGELOG_SIZE_PC && sd->dmglog[i].id != id; i++)
+       if( !sd->dmglog[i].id )
+       {
+           sd->dmglog[i].id = id;
+           break;
+       }
+   return;
+}
+
+void pc_damage_log_clear(struct map_session_data *sd, int id)
+{
+   int i;
+   struct mob_data *md = NULL;
+   if( !sd )
+       return;
+
+   if( !id )
+   {
+       for(i = 0; i < DAMAGELOG_SIZE_PC; i++)  // track every id
+       {
+           if( !sd->dmglog[i].id ) //skip the empty value
+               continue;
+
+           if( (md = map_id2md(sd->dmglog[i].id)) )
+               pc_clear_log_damage_sub(sd->status.char_id,md);
+       }
+       memset(sd->dmglog,0,sizeof(sd->dmglog));    // clear all
+   }
+   else
+   {
+       if( (md = map_id2md(id)) )
+           pc_clear_log_damage_sub(sd->status.char_id,md);
+
+       ARR_FIND(0,DAMAGELOG_SIZE_PC,i,sd->dmglog[i].id == id); // find the id position
+       if( i < DAMAGELOG_SIZE_PC )
+           sd->dmglog[i].id = 0;
+   }
+}
+
 /*==========================================
  * pc Init/Terminate
  *------------------------------------------*/
Index: src/map/pc.h
===================================================================
--- src/map/pc.h    (revision 17383)
+++ src/map/pc.h    (working copy)
@@ -23,6 +23,7 @@
 #define MAX_PC_BONUS 10
 #define MAX_PC_SKILL_REQUIRE 5
 #define MAX_PC_FEELHATE 3
+#define DAMAGELOG_SIZE_PC 100  // Any idea for this value?
 
 //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
 //where the arrows are equipped)
@@ -515,6 +516,10 @@
    const char* delunit_prevfile;
    int delunit_prevline;
 
+   struct {
+       int id;
+   } dmglog[DAMAGELOG_SIZE_PC];
+
 };
 
 //Update this max as necessary. 55 is the value needed for Super Baby currently
@@ -965,6 +970,9 @@
 
 void pc_baselevelchanged(struct map_session_data *sd);
 
+void pc_damage_log_add(struct map_session_data *sd, int id);
+void pc_damage_log_clear(struct map_session_data *sd, int id);
+
 #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
 int pc_level_penalty_mod(struct map_session_data *sd, int mob_level, uint32 mob_race, uint32 mob_mode, int type);
 #endif
Index: src/map/unit.c
===================================================================
--- src/map/unit.c  (revision 17383)
+++ src/map/unit.c  (working copy)
@@ -1421,6 +1421,9 @@
    } else
        skill_castend_id(ud->skilltimer,tick,src->id,0);
 
+   if( sd )
+       sd->canlog_tick = gettick();
+
    return 1;
 }
 
@@ -1554,6 +1557,9 @@
        ud->skilltimer = INVALID_TIMER;
        skill_castend_pos(ud->skilltimer,tick,src->id,0);
    }
+
+   if( sd )
+       sd->canlog_tick = gettick();
    return 1;
 }
 
@@ -1920,6 +1926,9 @@
    if(ud->state.attack_continue)
        ud->attacktimer = add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
 
+   if( sd )
+       sd->canlog_tick = gettick();
+
    return 1;
 }
 
Index: src/map/vending.c
===================================================================
--- src/map/vending.c   (revision 17383)
+++ src/map/vending.c   (working copy)
@@ -29,7 +29,7 @@
 /// Returns an unique vending shop id.
 static int vending_getuid(void)
 {
-   return vending_nextid++;
+   return ++vending_nextid;
 }
 
 /*==========================================
 
Viewed 764 times, submitted by cydh_r.