viewing paste Unknown #8361 | 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
diff --git a/src/map/clif.c b/src/map/clif.c
index c73f3d8..0c793c8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -2804,7 +2804,8 @@ void clif_updatestatus(struct map_session_data *sd,int type)
        case SP_HP:
                WFIFOL(fd,4)=sd->battle_status.hp;
                // TODO: Won't these overwrite the current packet?
-               clif_hpmeter(sd);
+               if( map[sd->bl.m].hpmeter_visible )
+                       clif_hpmeter(sd);
                if( !battle_config.party_hp_mode && sd->status.party_id )
                        clif_party_hp(sd);
                if( sd->bg_id )
@@ -9397,6 +9398,11 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
                        clif_broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF);
                }
 
+               if( pc_has_permission(sd,PC_PERM_VIEW_HPMETER) ) {
+                       map[sd->bl.m].hpmeter_visible++;
+                       sd->state.hpmeter_visible = 1;
+               }
+
                map_iwall_get(sd); // Updates Walls Info on this Map to Client
                status_calc_pc(sd, false); // Some conditions are map-dependent so we must recalculate
                sd->state.changemap = false;
diff --git a/src/map/map.h b/src/map/map.h
index 462fed8..420b7e8 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -638,6 +638,9 @@ struct map_data {
 
        /* rAthena Local Chat */
        struct Channel *channel;
+      
+       /* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */
+       unsigned short hpmeter_visible;
 };
 
 /// Stores information about a remote map (for multi-mapserver setups).
diff --git a/src/map/pc.h b/src/map/pc.h
index 6f9f4f9..68c7887 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -192,6 +192,7 @@ struct map_session_data {
                unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
                unsigned int warping : 1;//states whether you're in the middle of a warp processing
                unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
+               unsigned int hpmeter_visible : 1;
        } state;
        struct {
                unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
diff --git a/src/map/unit.c b/src/map/unit.c
index 281c9e6..be77cbf 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -2227,6 +2227,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
                        {// decrement the number of active pvp players on the map
                                --map[bl->m].users_pvp;
                        }
+                       if( sd->state.hpmeter_visible ) {
+                               map[bl->m].hpmeter_visible--;
+                               sd->state.hpmeter_visible = 0;
+                       }
                        sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS]
                        sd->debug_file = file;
                        sd->debug_line = line;
 
Viewed 280 times, submitted by unknown.