Core/Object: Use updatefield flags extracted from client to determine whether to send or not a field value instead of sending all data to client for non-player objects

This commit is contained in:
Shauren committed 2012-07-22 14:20:26 +02:00
1 parent 395994c707
commit 1fd37ac61b
12 files changed
+1793 -179

No files matched your search

+29 -1
View File
@@ -56,6 +56,7 @@
#include "MoveSplineInit.h"
#include "MoveSpline.h"
#include "ConditionMgr.h"
#include "UpdateFieldFlags.h"
#include <math.h>
@@ -9658,6 +9659,31 @@ bool Unit::HasAuraState(AuraStateType flag, SpellInfo const* spellProto, Unit co
return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1));
}
void Unit::SetOwnerGUID(uint64 owner)
{
if (GetOwnerGUID() == owner)
return;
SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner);
if (!owner)
return;
// Update owner dependent fields
Player* player = ObjectAccessor::GetPlayer(*this, owner);
if (!player || !player->HaveAtClient(this)) // if player cannot see this unit yet, he will receive needed data with create object
return;
SetFieldNotifyFlag(UF_FLAG_OWNER);
UpdateData udata;
WorldPacket packet;
BuildValuesUpdateBlockForPlayer(&udata, player);
udata.BuildPacket(&packet);
player->SendDirectMessage(&packet);
RemoveFieldNotifyFlag(UF_FLAG_OWNER);
}
Unit* Unit::GetOwner() const
{
if (uint64 ownerid = GetOwnerGUID())
@@ -9743,12 +9769,14 @@ void Unit::SetMinion(Minion *minion, bool apply)
if (apply)
{
if (!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID()))
if (minion->GetOwnerGUID())
{
sLog->outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry());
return;
}
minion->SetOwnerGUID(GetGUID());
m_Controlled.insert(minion);
if (GetTypeId() == TYPEID_PLAYER)