Core/Units: fixed power update

(yes you are now alive ingame)
This commit is contained in:
Rat committed 2011-11-27 19:09:47 +01:00
1 parent a28b5c3a95
commit d977ed01e7
3 files changed
+35 -10

No files matched your search

+31 -8
View File
@@ -13608,22 +13608,45 @@ void Unit::SetMaxHealth(uint32 val)
SetHealth(val);
}
void Unit::SetPower(Powers power, int32 val)
uint32 Unit::GetPowerIndexByClass(uint32 powerId, uint32 classId) const
{
if (GetPower(power) == val)
return;
ChrClassesEntry const* m_class = sChrClassesStore.LookupEntry(classId);
int32 maxPower = (int32)GetMaxPower(power);
ASSERT(m_class && "Class not found");
uint32 index = 0;
for (uint32 i = 0; i <= sChrPowerTypesStore.GetNumRows(); i++)
{
ChrPowerTypesEntry const* cEntry = sChrPowerTypesStore.LookupEntry(i);
if (!cEntry)
continue;
if (classId != cEntry->classId)
continue;
if (powerId == cEntry->power)
return index;
index++;
}
return 0;
};
void Unit::SetPower(Powers power, uint32 val)
{
uint32 maxPower = GetMaxPower(power);
if (maxPower < val)
val = maxPower;
SetStatInt32Value(UNIT_FIELD_POWER1 + power, val);
SetStatInt32Value(UNIT_FIELD_POWER1 + GetPowerIndexByClass(power, getClass()), val);
WorldPacket data(SMSG_POWER_UPDATE);
data.append(GetPackGUID());
data << int32(1); // Unk
data << uint8(power);
data << int32(val);
data << uint32(1);//unk
data << uint8(GetPowerIndexByClass(power, getClass()));
data << uint32(val);
SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER ? true : false);
// group update