Core/Auras: Corrected SPELL_AURA_CLONE_CASTER and mirror image opcode handling, will no longer rely on incorrectly used creator guid

This commit is contained in:
Shauren
2011-07-31 16:43:54 +02:00
parent 0afc3cf110
commit 8753a18263
2 changed files with 25 additions and 21 deletions
@@ -31,6 +31,7 @@
#include "CreatureAI.h" #include "CreatureAI.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "GameObjectAI.h" #include "GameObjectAI.h"
#include "SpellAuraEffects.h"
void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets) void WorldSession::HandleClientCastFlags(WorldPacket& recvPacket, uint8 castFlags, SpellCastTargets& targets)
{ {
@@ -574,32 +575,36 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket & recv_data)
recv_data >> guid; recv_data >> guid;
// Get unit for which data is needed by client // Get unit for which data is needed by client
Unit *unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)NULL); Unit* unit = ObjectAccessor::GetObjectInWorld(guid, (Unit*)NULL);
if (!unit) if (!unit)
return; return;
// Get creator of the unit if (!unit->HasAuraType(SPELL_AURA_CLONE_CASTER))
Unit *creator = ObjectAccessor::GetObjectInWorld(unit->GetCreatorGUID(), (Unit*)NULL); return;
// Get creator of the unit (SPELL_AURA_CLONE_CASTER does not stack)
Unit* creator = unit->GetAuraEffectsByType(SPELL_AURA_CLONE_CASTER).front()->GetCaster();
if (!creator) if (!creator)
return; return;
WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68); WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
data << uint64(guid); data << uint64(guid);
data << uint32(creator->GetDisplayId()); data << uint32(creator->GetDisplayId());
data << uint8(creator->getRace());
data << uint8(creator->getGender());
data << uint8(creator->getClass());
if (creator->GetTypeId() == TYPEID_PLAYER) if (creator->GetTypeId() == TYPEID_PLAYER)
{ {
Player* pCreator = creator->ToPlayer(); Player* player = creator->ToPlayer();
data << uint8(pCreator->getRace()); data << uint8(player->GetByteValue(PLAYER_BYTES, 0)); // skin
data << uint8(pCreator->getGender()); data << uint8(player->GetByteValue(PLAYER_BYTES, 1)); // face
data << uint8(pCreator->getClass()); data << uint8(player->GetByteValue(PLAYER_BYTES, 2)); // hair
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 0)); // skin data << uint8(player->GetByteValue(PLAYER_BYTES, 3)); // haircolor
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 1)); // face data << uint8(player->GetByteValue(PLAYER_BYTES_2, 0)); // facialhair
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 2)); // hair data << uint32(player->GetGuildId()); // unk
data << uint8(pCreator->GetByteValue(PLAYER_BYTES, 3)); // haircolor
data << uint8(pCreator->GetByteValue(PLAYER_BYTES_2, 0)); // facialhair
data << uint32(pCreator->GetGuildId()); // unk
static const EquipmentSlots ItemSlots[] = static EquipmentSlots const itemSlots[] =
{ {
EQUIPMENT_SLOT_HEAD, EQUIPMENT_SLOT_HEAD,
EQUIPMENT_SLOT_SHOULDERS, EQUIPMENT_SLOT_SHOULDERS,
@@ -616,13 +621,13 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket & recv_data)
}; };
// Display items in visible slots // Display items in visible slots
for (EquipmentSlots const* itr = &ItemSlots[0]; *itr != EQUIPMENT_SLOT_END; ++itr) for (EquipmentSlots const* itr = &itemSlots[0]; *itr != EQUIPMENT_SLOT_END; ++itr)
{ {
if (*itr == EQUIPMENT_SLOT_HEAD && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) if (*itr == EQUIPMENT_SLOT_HEAD && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM))
data << uint32(0); data << uint32(0);
else if (*itr == EQUIPMENT_SLOT_BACK && pCreator->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)) else if (*itr == EQUIPMENT_SLOT_BACK && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK))
data << uint32(0); data << uint32(0);
else if (Item const *item = pCreator->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr)) else if (Item const *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, *itr))
data << uint32(item->GetTemplate()->DisplayInfoID); data << uint32(item->GetTemplate()->DisplayInfoID);
else else
data << uint32(0); data << uint32(0);
@@ -631,7 +636,7 @@ void WorldSession::HandleMirrorImageDataRequest(WorldPacket & recv_data)
else else
{ {
// Skip player data for creatures // Skip player data for creatures
data << uint32(0); data << uint8(0);
data << uint32(0); data << uint32(0);
data << uint32(0); data << uint32(0);
data << uint32(0); data << uint32(0);
@@ -2398,15 +2398,14 @@ void AuraEffect::HandleAuraCloneCaster(AuraApplication const* aurApp, uint8 mode
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster == target) if (!caster || caster == target)
return; return;
// What must be cloned? at least display and scale // What must be cloned? at least display and scale
target->SetDisplayId(caster->GetDisplayId()); target->SetDisplayId(caster->GetDisplayId());
target->SetCreatorGUID(caster->GetGUID());
//target->SetFloatValue(OBJECT_FIELD_SCALE_X, caster->GetFloatValue(OBJECT_FIELD_SCALE_X)); // we need retail info about how scaling is handled (aura maybe?) //target->SetFloatValue(OBJECT_FIELD_SCALE_X, caster->GetFloatValue(OBJECT_FIELD_SCALE_X)); // we need retail info about how scaling is handled (aura maybe?)
target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE); target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
} }
else else
{ {
target->SetCreatorGUID(0);
target->SetDisplayId(target->GetNativeDisplayId()); target->SetDisplayId(target->GetNativeDisplayId());
target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE); target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
} }