All pastes #978586 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-09 17:56 UTC
rendered paste body
Index: src/game/GroupHandler.cpp
===================================================================
--- src/game/GroupHandler.cpp	(revision 5581)
+++ src/game/GroupHandler.cpp	(working copy)
@@ -802,18 +802,18 @@
     data << (uint16) player->GetPositionY();                // GROUP_UPDATE_FLAG_POSITION
 
     uint64 auramask = 0;
-    ByteBuffer buf;
+    size_t maskPos = data.wpos();
+    data << (uint64) auramask;                              // placeholder
     for(uint8 i = 0; i < MAX_AURAS; ++i)
     {
         if(uint32 aura = player->GetUInt32Value(UNIT_FIELD_AURA + i))
         {
             auramask |= (uint64(1) << i);
-            buf << (uint16) aura;
+            data << (uint16) aura;
             //buf << (uint8)  1;
         }
     }
-    data << (uint64) auramask;                              // GROUP_UPDATE_FLAG_AURAS
-    data.append(buf);
+    data.put<uint64>(maskPos,auramask);                     // GROUP_UPDATE_FLAG_AURAS
 
     if(pet)
     {
@@ -828,18 +828,18 @@
         data << (uint16) pet->GetMaxPower(petpowertype);    // GROUP_UPDATE_FLAG_PET_MAX_POWER
 
         uint64 petauramask = 0;
-        ByteBuffer petbuf;
+        size_t petMaskPos = data.wpos();
+        data << (uint64) petauramask;                       // placeholder
         for(uint8 i = 0; i < MAX_AURAS; ++i)
         {
             if(uint32 petaura = pet->GetUInt32Value(UNIT_FIELD_AURA + i))
             {
                 petauramask |= (uint64(1) << i);
-                petbuf << (uint16) petaura;
+                data << (uint16) petaura;
                 //petbuf << (uint8)  1;
             }
         }
-        data << (uint64) petauramask;                       // GROUP_UPDATE_FLAG_PET_AURAS
-        data.append(petbuf);
+        data.put<uint64>(petMaskPos,petauramask);           // GROUP_UPDATE_FLAG_PET_AURAS
     }
     else
     {
Index: src/game/SpellAuras.cpp
===================================================================
--- src/game/SpellAuras.cpp	(revision 5581)
+++ src/game/SpellAuras.cpp	(working copy)
@@ -862,27 +862,8 @@
                 SetAuraFlag(slot, true);
                 SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
 
-                if(m_target->GetTypeId() == TYPEID_PLAYER)
-                {
-                    if(((Player*)m_target)->GetGroup())
-                    {
-                        ((Player*)m_target)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
-                        ((Player*)m_target)->SetAuraUpdateMask(slot);
-                    }
-                }
-
-                if(m_target->GetTypeId() == TYPEID_UNIT && ((Creature*)m_target)->isPet())
-                {
-                    Pet *pet = ((Pet*)m_target);
-                    if(!pet->isControlled())
-                        return;
-                    Unit *owner = m_target->GetOwner();
-                    if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
-                    {
-                        ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
-                        pet->SetAuraUpdateMask(slot);
-                    }
-                }
+                // update to outofrnage group members
+                m_target->UpdateAuraForGroup(slot);
             }
 
             SetAuraSlot( slot );
@@ -965,26 +946,8 @@
         SetAuraFlag(slot, false);
         SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
 
-        if(m_target->GetTypeId() == TYPEID_PLAYER)
-        {
-            if(((Player*)m_target)->GetGroup())
-            {
-                ((Player*)m_target)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
-                ((Player*)m_target)->SetAuraUpdateMask(slot);
-            }
-        }
-        else if(m_target->GetTypeId() == TYPEID_UNIT && ((Creature*)m_target)->isPet())
-        {
-            Pet *pet = ((Pet*)m_target);
-            if(!pet->isControlled())
-                return;
-            Unit *owner = m_target->GetOwner();
-            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
-            {
-                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
-                pet->SetAuraUpdateMask(slot);
-            }
-        }
+        // update for group members
+        m_target->UpdateAuraForGroup(slot);
 
         if( IsSealSpell(GetId()) )
             m_target->ModifyAuraState(AURA_STATE_JUDGEMENT,false);
Index: src/game/Unit.cpp
===================================================================
--- src/game/Unit.cpp	(revision 5581)
+++ src/game/Unit.cpp	(working copy)
@@ -9854,3 +9854,29 @@
 
     return CastingTime;
 }
+
+void Unit::UpdateAuraForGroup(uint8 slot)
+{
+    if(GetTypeId() == TYPEID_PLAYER)
+    {
+        Player* player = (Player*)this;
+        if(player->GetGroup())
+        {
+            player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS);
+            player->SetAuraUpdateMask(slot);
+        }
+    }
+    else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
+    {
+        Pet *pet = ((Pet*)this);
+        if(pet->isControlled())
+        {
+            Unit *owner = GetOwner();
+            if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
+            {
+                ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS);
+                pet->SetAuraUpdateMask(slot);
+            }
+        }
+    }
+}
Index: src/game/Unit.h
===================================================================
--- src/game/Unit.h	(revision 5581)
+++ src/game/Unit.h	(working copy)
@@ -1085,6 +1085,9 @@
         void StartReactiveTimer( ReactiveType reactive ) { m_reactiveTimer[reactive] = REACTIVE_TIMER_START;}
         void UpdateReactives(uint32 p_time);
 
+        // group updates
+        void UpdateAuraForGroup(uint8 slot);
+
     protected:
         explicit Unit ( WorldObject *instantiator );