[10671] Convert some Unit owner/etc guids to ObjectGuid way.

This commit is contained in:
VladimirMangos 2010-11-01 12:11:23 +03:00
parent 92d98b9fb2
commit a32d68febd
18 changed files with 154 additions and 149 deletions

View file

@ -595,7 +595,7 @@ void Creature::RegenerateMana()
uint32 addvalue = 0; uint32 addvalue = 0;
// Combat and any controlled creature // Combat and any controlled creature
if (isInCombat() || GetCharmerOrOwnerGUID()) if (isInCombat() || !GetCharmerOrOwnerGuid().IsEmpty())
{ {
if(!IsUnderLastManaUseEffect()) if(!IsUnderLastManaUseEffect())
{ {
@ -625,7 +625,7 @@ void Creature::RegenerateHealth()
uint32 addvalue = 0; uint32 addvalue = 0;
// Not only pet, but any controlled creature // Not only pet, but any controlled creature
if(GetCharmerOrOwnerGUID()) if (!GetCharmerOrOwnerGuid().IsEmpty())
{ {
float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH); float HealthIncreaseRate = sWorld.getConfig(CONFIG_FLOAT_RATE_HEALTH);
float Spirit = GetStat(STAT_SPIRIT); float Spirit = GetStat(STAT_SPIRIT);
@ -1734,7 +1734,7 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /
return false; return false;
// only free creature // only free creature
if (GetCharmerOrOwnerGUID()) if (!GetCharmerOrOwnerGuid().IsEmpty())
return false; return false;
// only from same creature faction // only from same creature faction

View file

@ -91,7 +91,7 @@ namespace FactorySelector
MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance());
MANGOS_ASSERT( creature->GetCreatureInfo() != NULL ); MANGOS_ASSERT( creature->GetCreatureInfo() != NULL );
MovementGeneratorCreator const * mv_factory = mv_registry.GetRegistryItem( MovementGeneratorCreator const * mv_factory = mv_registry.GetRegistryItem(
IS_PLAYER_GUID(creature->GetOwnerGUID()) ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType()); creature->GetOwnerGuid().IsPlayer() ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType());
/* if( mv_factory == NULL ) /* if( mv_factory == NULL )
{ {

View file

@ -2174,7 +2174,7 @@ bool ChatHandler::HandleNpcTameCommand(char* /*args*/)
Player *player = m_session->GetPlayer (); Player *player = m_session->GetPlayer ();
if (player->GetPetGUID()) if (!player->GetPetGuid().IsEmpty())
{ {
SendSysMessage(LANG_YOU_ALREADY_HAVE_PET); SendSysMessage(LANG_YOU_ALREADY_HAVE_PET);
SetSentErrorMessage(true); SetSentErrorMessage(true);

View file

@ -232,12 +232,12 @@ void MotionMaster::MoveTargetedHome()
Clear(false); Clear(false);
if (m_owner->GetTypeId() == TYPEID_UNIT && !((Creature*)m_owner)->GetCharmerOrOwnerGUID()) if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGuid().IsEmpty())
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetObjectGuid().GetString().c_str()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetObjectGuid().GetString().c_str());
Mutate(new HomeMovementGenerator<Creature>()); Mutate(new HomeMovementGenerator<Creature>());
} }
else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGUID()) else if (m_owner->GetTypeId() == TYPEID_UNIT && !((Creature*)m_owner)->GetCharmerOrOwnerGuid().IsEmpty())
{ {
if (Unit *target = ((Creature*)m_owner)->GetCharmerOrOwner()) if (Unit *target = ((Creature*)m_owner)->GetCharmerOrOwner())
{ {

View file

@ -386,9 +386,9 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket &recv_data)
recv_data >> guid.ReadAsPacked(); recv_data >> guid.ReadAsPacked();
recv_data >> mi; recv_data >> mi;
uint64 vehicleGUID = _player->GetCharmGUID(); ObjectGuid vehicleGUID = _player->GetCharmGuid();
if(!vehicleGUID) // something wrong here... if (vehicleGUID.IsEmpty()) // something wrong here...
return; return;
_player->m_movementInfo = mi; _player->m_movementInfo = mi;

View file

@ -139,7 +139,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c
updatetype = UPDATETYPE_CREATE_OBJECT2; updatetype = UPDATETYPE_CREATE_OBJECT2;
// UPDATETYPE_CREATE_OBJECT2 for pets... // UPDATETYPE_CREATE_OBJECT2 for pets...
if(target->GetPetGUID() == GetGUID()) if (target->GetPetGuid() == GetObjectGuid())
updatetype = UPDATETYPE_CREATE_OBJECT2; updatetype = UPDATETYPE_CREATE_OBJECT2;
// UPDATETYPE_CREATE_OBJECT2 for some gameobject types... // UPDATETYPE_CREATE_OBJECT2 for some gameobject types...

View file

@ -191,7 +191,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
m_charmInfo->SetPetNumber(pet_number, IsPermanentPetFor(owner)); m_charmInfo->SetPetNumber(pet_number, IsPermanentPetFor(owner));
SetOwnerGUID(owner->GetGUID()); SetOwnerGuid(owner->GetObjectGuid());
SetDisplayId(fields[3].GetUInt32()); SetDisplayId(fields[3].GetUInt32());
SetNativeDisplayId(fields[3].GetUInt32()); SetNativeDisplayId(fields[3].GetUInt32());
uint32 petlevel = fields[4].GetUInt32(); uint32 petlevel = fields[4].GetUInt32();
@ -234,7 +234,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL)));
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32()); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32());
SetCreatorGUID(owner->GetGUID()); SetCreatorGuid(owner->GetObjectGuid());
m_charmInfo->SetReactState(ReactStates(fields[6].GetUInt8())); m_charmInfo->SetReactState(ReactStates(fields[6].GetUInt8()));
@ -352,7 +352,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
return; return;
// not save not player pets // not save not player pets
if(!IS_PLAYER_GUID(GetOwnerGUID())) if (!GetOwnerGuid().IsPlayer())
return; return;
Player* pOwner = (Player*)GetOwner(); Player* pOwner = (Player*)GetOwner();
@ -385,29 +385,29 @@ void Pet::SavePetToDB(PetSaveMode mode)
_SaveSpellCooldowns(); _SaveSpellCooldowns();
_SaveAuras(); _SaveAuras();
uint32 owner = GUID_LOPART(GetOwnerGUID()); uint32 ownerLow = GetOwnerGuid().GetCounter();
std::string name = m_name; std::string name = m_name;
CharacterDatabase.escape_string(name); CharacterDatabase.escape_string(name);
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
// remove current data // remove current data
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", owner,m_charmInfo->GetPetNumber() ); CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLow, m_charmInfo->GetPetNumber());
// prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT) // prevent duplicate using slot (except PET_SAVE_NOT_IN_SLOT)
if (mode <= PET_SAVE_LAST_STABLE_SLOT) if (mode <= PET_SAVE_LAST_STABLE_SLOT)
CharacterDatabase.PExecute("UPDATE character_pet SET slot = '%u' WHERE owner = '%u' AND slot = '%u'", CharacterDatabase.PExecute("UPDATE character_pet SET slot = '%u' WHERE owner = '%u' AND slot = '%u'",
PET_SAVE_NOT_IN_SLOT, owner, uint32(mode) ); PET_SAVE_NOT_IN_SLOT, ownerLow, uint32(mode) );
// prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
if (getPetType()==HUNTER_PET && (mode==PET_SAVE_AS_CURRENT||mode > PET_SAVE_LAST_STABLE_SLOT)) if (getPetType()==HUNTER_PET && (mode==PET_SAVE_AS_CURRENT||mode > PET_SAVE_LAST_STABLE_SLOT))
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u')", CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u')",
owner,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); ownerLow, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
// save pet // save pet
std::ostringstream ss; std::ostringstream ss;
ss << "INSERT INTO character_pet ( id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) " ss << "INSERT INTO character_pet ( id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType) "
<< "VALUES (" << "VALUES ("
<< m_charmInfo->GetPetNumber() << ", " << m_charmInfo->GetPetNumber() << ", "
<< GetEntry() << ", " << GetEntry() << ", "
<< owner << ", " << ownerLow << ", "
<< GetNativeDisplayId() << ", " << GetNativeDisplayId() << ", "
<< getLevel() << ", " << getLevel() << ", "
<< GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ", " << GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ", "
@ -503,7 +503,7 @@ void Pet::Update(uint32 diff)
{ {
// unsummon pet that lost owner // unsummon pet that lost owner
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if(!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (owner->GetCharmGUID() && (owner->GetCharmGUID() != GetGUID()))) || (isControlled() && !owner->GetPetGUID())) if (!owner || (!IsWithinDistInMap(owner, GetMap()->GetVisibilityDistance()) && (!owner->GetCharmGuid().IsEmpty() && (owner->GetCharmGuid() != GetObjectGuid()))) || (isControlled() && owner->GetPetGuid().IsEmpty()))
{ {
Remove(PET_SAVE_NOT_IN_SLOT, true); Remove(PET_SAVE_NOT_IN_SLOT, true);
return; return;
@ -511,7 +511,7 @@ void Pet::Update(uint32 diff)
if (isControlled()) if (isControlled())
{ {
if( owner->GetPetGUID() != GetGUID() ) if (owner->GetPetGuid() != GetObjectGuid())
{ {
Remove(getPetType()==HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT); Remove(getPetType()==HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT);
return; return;
@ -675,7 +675,7 @@ void Pet::Remove(PetSaveMode mode, bool returnreagent)
} }
// only if current pet in slot // only if current pet in slot
if(owner->GetPetGUID()==GetGUID()) if (owner->GetPetGuid() == GetObjectGuid())
owner->SetPet(0); owner->SetPet(0);
} }

View file

@ -51,7 +51,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
return; return;
} }
if (GetPlayer()->GetGUID() != pet->GetCharmerOrOwnerGUID()) if (GetPlayer()->GetObjectGuid() != pet->GetCharmerOrOwnerGuid())
{ {
sLog.outError("HandlePetAction: %s isn't controlled by %s.", petGuid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); sLog.outError("HandlePetAction: %s isn't controlled by %s.", petGuid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str());
return; return;
@ -286,7 +286,7 @@ void WorldSession::HandlePetStopAttack(WorldPacket& recv_data)
return; return;
} }
if (GetPlayer()->GetGUID() != pet->GetCharmerOrOwnerGUID()) if (GetPlayer()->GetObjectGuid() != pet->GetCharmerOrOwnerGuid())
{ {
sLog.outError("HandlePetStopAttack: %s isn't charm/pet of %s.", petGuid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); sLog.outError("HandlePetStopAttack: %s isn't charm/pet of %s.", petGuid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str());
return; return;
@ -475,7 +475,7 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
// check it! // check it!
if( !pet || pet->getPetType() != HUNTER_PET || if( !pet || pet->getPetType() != HUNTER_PET ||
!pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ||
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() ) pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo() )
return; return;
PetNameInvalidReason res = ObjectMgr::CheckPetName(name); PetNameInvalidReason res = ObjectMgr::CheckPetName(name);
@ -546,7 +546,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
{ {
if (pet->IsPet()) if (pet->IsPet())
{ {
if(pet->GetGUID() == _player->GetPetGUID()) if (pet->GetObjectGuid() == _player->GetPetGuid())
{ {
uint32 feelty = pet->GetPower(POWER_HAPPINESS); uint32 feelty = pet->GetPower(POWER_HAPPINESS);
pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0); pet->SetPower(POWER_HAPPINESS ,(feelty-50000) > 0 ?(feelty-50000) : 0);
@ -554,7 +554,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
_player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED); _player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED);
} }
else if(pet->GetGUID() == _player->GetCharmGUID()) else if (pet->GetObjectGuid() == _player->GetCharmGuid())
{ {
_player->Uncharm(); _player->Uncharm();
} }
@ -597,7 +597,7 @@ void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
recvPacket >> guid >> spellid >> state; recvPacket >> guid >> spellid >> state;
Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid); Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid);
if (!pet || (guid.GetRawValue() != _player->GetPetGUID() && guid.GetRawValue() != _player->GetCharmGUID())) if (!pet || (guid != _player->GetPetGuid() && guid != _player->GetCharmGuid()))
{ {
sLog.outError("HandlePetSpellAutocastOpcode. %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); sLog.outError("HandlePetSpellAutocastOpcode. %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str());
return; return;
@ -638,7 +638,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid); Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid);
if (!pet || (guid.GetRawValue() != _player->GetPetGUID() && guid.GetRawValue() != _player->GetCharmGUID())) if (!pet || (guid != _player->GetPetGuid() && guid != _player->GetCharmGuid()))
{ {
sLog.outError("HandlePetCastSpellOpcode: %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); sLog.outError("HandlePetCastSpellOpcode: %s isn't pet of %s .", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str());
return; return;

View file

@ -1464,7 +1464,7 @@ void Player::Update( uint32 p_time )
SendUpdateToOutOfRangeGroupMembers(); SendUpdateToOutOfRangeGroupMembers();
Pet* pet = GetPet(); Pet* pet = GetPet();
if(pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID()))) if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (!GetCharmGuid().IsEmpty() && (pet->GetObjectGuid() != GetCharmGuid())))
{ {
RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true);
} }
@ -2261,7 +2261,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
return NULL; return NULL;
// not allow interaction under control, but allow with own pets // not allow interaction under control, but allow with own pets
if (unit->GetCharmerGUID()) if (!unit->GetCharmerGuid().IsEmpty())
return NULL; return NULL;
// not enemy // not enemy
@ -6906,12 +6906,12 @@ void Player::DuelComplete(DuelCompleteType type)
// cleanup combo points // cleanup combo points
if (GetComboTargetGuid() == duel->opponent->GetObjectGuid()) if (GetComboTargetGuid() == duel->opponent->GetObjectGuid())
ClearComboPoints(); ClearComboPoints();
else if (GetComboTargetGuid().GetRawValue() == duel->opponent->GetPetGUID()) else if (GetComboTargetGuid() == duel->opponent->GetPetGuid())
ClearComboPoints(); ClearComboPoints();
if (duel->opponent->GetComboTargetGuid() == GetObjectGuid()) if (duel->opponent->GetComboTargetGuid() == GetObjectGuid())
duel->opponent->ClearComboPoints(); duel->opponent->ClearComboPoints();
else if (duel->opponent->GetComboTargetGuid().GetRawValue() == GetPetGUID()) else if (duel->opponent->GetComboTargetGuid() == GetPetGuid())
duel->opponent->ClearComboPoints(); duel->opponent->ClearComboPoints();
//cleanups //cleanups
@ -15392,9 +15392,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetCharm(NULL); SetCharm(NULL);
SetPet(NULL); SetPet(NULL);
SetTargetGuid(ObjectGuid()); SetTargetGuid(ObjectGuid());
SetCharmerGUID(0); SetCharmerGuid(ObjectGuid());
SetOwnerGUID(0); SetOwnerGuid(ObjectGuid());
SetCreatorGUID(0); SetCreatorGuid(ObjectGuid());
// reset some aura modifiers before aura apply // reset some aura modifiers before aura apply
@ -17738,7 +17738,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if (!pet) if (!pet)
pet = GetPet(); pet = GetPet();
if (!pet || pet->GetOwnerGUID() != GetGUID()) if (!pet || pet->GetOwnerGuid() != GetObjectGuid())
return; return;
// not save secondary permanent pet as current // not save secondary permanent pet as current
@ -17780,7 +17780,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
RemoveGuardian(pet); RemoveGuardian(pet);
break; break;
default: default:
if (GetPetGUID() == pet->GetGUID()) if (GetPetGuid() == pet->GetObjectGuid())
SetPet(NULL); SetPet(NULL);
break; break;
} }
@ -17965,13 +17965,13 @@ void Player::PetSpellInitialize()
void Player::SendPetGUIDs() void Player::SendPetGUIDs()
{ {
if(!GetPetGUID()) if (GetPetGuid().IsEmpty())
return; return;
// Later this function might get modified for multiple guids // Later this function might get modified for multiple guids
WorldPacket data(SMSG_PET_GUIDS, 12); WorldPacket data(SMSG_PET_GUIDS, 12);
data << uint32(1); // count data << uint32(1); // count
data << uint64(GetPetGUID()); data << ObjectGuid(GetPetGuid());
GetSession()->SendPacket(&data); GetSession()->SendPacket(&data);
} }
@ -19435,7 +19435,7 @@ inline void BeforeVisibilityDestroy(T* /*t*/, Player* /*p*/)
template<> template<>
inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p) inline void BeforeVisibilityDestroy<Creature>(Creature* t, Player* p)
{ {
if (p->GetPetGUID()==t->GetGUID() && ((Creature*)t)->IsPet()) if (p->GetPetGuid() == t->GetObjectGuid() && ((Creature*)t)->IsPet())
((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true); ((Pet*)t)->Remove(PET_SAVE_NOT_IN_SLOT, true);
} }
@ -20970,7 +20970,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
if(!veSeat) if(!veSeat)
return; return;
vehicle->SetCharmerGUID(GetGUID()); vehicle->SetCharmerGuid(GetObjectGuid());
vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); vehicle->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); vehicle->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
vehicle->setFaction(getFaction()); vehicle->setFaction(getFaction());
@ -21022,7 +21022,7 @@ void Player::EnterVehicle(Vehicle *vehicle)
void Player::ExitVehicle(Vehicle *vehicle) void Player::ExitVehicle(Vehicle *vehicle)
{ {
vehicle->SetCharmerGUID(0); vehicle->SetCharmerGuid(ObjectGuid());
vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); vehicle->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); vehicle->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H); vehicle->setFaction((GetTeam() == ALLIANCE) ? vehicle->GetCreatureInfo()->faction_A : vehicle->GetCreatureInfo()->faction_H);
@ -21782,7 +21782,7 @@ void Player::ResummonPetTemporaryUnSummonedIfAny()
if (IsPetNeedBeTemporaryUnsummoned()) if (IsPetNeedBeTemporaryUnsummoned())
return; return;
if(GetPetGUID()) if (!GetPetGuid().IsEmpty())
return; return;
Pet* NewPet = new Pet; Pet* NewPet = new Pet;

View file

@ -1152,7 +1152,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
// Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells // Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells
if (m_spellInfo->speed > 0.0f && if (m_spellInfo->speed > 0.0f &&
unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) &&
unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) unit->GetCharmerOrOwnerGuid() != m_caster->GetObjectGuid())
{ {
realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); realCaster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE);
ResetEffectDamageAndHeal(); ResetEffectDamageAndHeal();
@ -2026,7 +2026,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
{ {
if( targetOwner->GetTypeId() == TYPEID_PLAYER && if( targetOwner->GetTypeId() == TYPEID_PLAYER &&
target->GetTypeId() == TYPEID_UNIT && (((Creature*)target)->IsPet()) && target->GetTypeId() == TYPEID_UNIT && (((Creature*)target)->IsPet()) &&
target->GetOwnerGUID() == targetOwner->GetGUID() && target->GetOwnerGuid() == targetOwner->GetObjectGuid() &&
pGroup->IsMember(((Player*)targetOwner)->GetObjectGuid())) pGroup->IsMember(((Player*)targetOwner)->GetObjectGuid()))
{ {
targetUnitMap.push_back(target); targetUnitMap.push_back(target);
@ -4473,7 +4473,7 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
// TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result. // TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result.
// check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc // check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc
if (!explicit_target_mode && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID()) if (!explicit_target_mode && m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->GetCharmerOrOwnerGuid().IsEmpty())
{ {
// check correctness positive/negative cast target (pet cast real check and cheating check) // check correctness positive/negative cast target (pet cast real check and cheating check)
if(IsPositiveSpell(m_spellInfo->Id)) if(IsPositiveSpell(m_spellInfo->Id))
@ -4768,7 +4768,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (target->GetCreatureType() != CREATURE_TYPE_UNDEAD) if (target->GetCreatureType() != CREATURE_TYPE_UNDEAD)
return SPELL_FAILED_BAD_IMPLICIT_TARGETS; return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
// owned // owned
if (target->GetOwnerGUID() != m_caster->GetGUID()) if (target->GetOwnerGuid() != m_caster->GetObjectGuid())
return SPELL_FAILED_BAD_IMPLICIT_TARGETS; return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
float dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
@ -4862,7 +4862,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_DONT_REPORT; return SPELL_FAILED_DONT_REPORT;
} }
if(plrCaster->GetPetGUID() || plrCaster->GetCharmGUID()) if (!plrCaster->GetPetGuid().IsEmpty() || !plrCaster->GetCharmGuid().IsEmpty())
{ {
plrCaster->SendPetTameFailure(PETTAME_ANOTHERSUMMONACTIVE); plrCaster->SendPetTameFailure(PETTAME_ANOTHERSUMMONACTIVE);
return SPELL_FAILED_DONT_REPORT; return SPELL_FAILED_DONT_REPORT;
@ -5066,10 +5066,10 @@ SpellCastResult Spell::CheckCast(bool strict)
{ {
if(summon_prop->Group == SUMMON_PROP_GROUP_PETS) if(summon_prop->Group == SUMMON_PROP_GROUP_PETS)
{ {
if(m_caster->GetPetGUID()) if (!m_caster->GetPetGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_SUMMON; return SPELL_FAILED_ALREADY_HAVE_SUMMON;
if(m_caster->GetCharmGUID()) if (!m_caster->GetCharmGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_CHARM; return SPELL_FAILED_ALREADY_HAVE_CHARM;
} }
} }
@ -5078,7 +5078,7 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
case SPELL_EFFECT_SUMMON_PET: case SPELL_EFFECT_SUMMON_PET:
{ {
if(m_caster->GetPetGUID()) //let warlock do a replacement summon if (!m_caster->GetPetGuid().IsEmpty()) //let warlock do a replacement summon
{ {
Pet* pet = ((Player*)m_caster)->GetPet(); Pet* pet = ((Player*)m_caster)->GetPet();
@ -5092,7 +5092,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_ALREADY_HAVE_SUMMON; return SPELL_FAILED_ALREADY_HAVE_SUMMON;
} }
if(m_caster->GetCharmGUID()) if (!m_caster->GetCharmGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_CHARM; return SPELL_FAILED_ALREADY_HAVE_CHARM;
break; break;
@ -5180,19 +5180,19 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_targets.getUnitTarget() == m_caster) if (m_targets.getUnitTarget() == m_caster)
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if(m_caster->GetPetGUID()) if (!m_caster->GetPetGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_SUMMON; return SPELL_FAILED_ALREADY_HAVE_SUMMON;
if(m_caster->GetCharmGUID()) if (!m_caster->GetCharmGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_CHARM; return SPELL_FAILED_ALREADY_HAVE_CHARM;
if(m_caster->GetCharmerGUID()) if (!m_caster->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
if (!m_targets.getUnitTarget()) if (!m_targets.getUnitTarget())
return SPELL_FAILED_BAD_IMPLICIT_TARGETS; return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
if(m_targets.getUnitTarget()->GetCharmerGUID()) if (!m_targets.getUnitTarget()->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget()))
@ -5205,19 +5205,19 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_targets.getUnitTarget() == m_caster) if (m_targets.getUnitTarget() == m_caster)
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if(m_caster->GetPetGUID()) if (!m_caster->GetPetGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_SUMMON; return SPELL_FAILED_ALREADY_HAVE_SUMMON;
if(m_caster->GetCharmGUID()) if (!m_caster->GetCharmGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_CHARM; return SPELL_FAILED_ALREADY_HAVE_CHARM;
if(m_caster->GetCharmerGUID()) if (!m_caster->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
if (!m_targets.getUnitTarget()) if (!m_targets.getUnitTarget())
return SPELL_FAILED_BAD_IMPLICIT_TARGETS; return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
if(m_targets.getUnitTarget()->GetCharmerGUID()) if (!m_targets.getUnitTarget()->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget()))
@ -5230,17 +5230,17 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (m_caster->GetTypeId() != TYPEID_PLAYER)
return SPELL_FAILED_UNKNOWN; return SPELL_FAILED_UNKNOWN;
if(m_caster->GetCharmGUID()) if (!m_caster->GetCharmGuid().IsEmpty())
return SPELL_FAILED_ALREADY_HAVE_CHARM; return SPELL_FAILED_ALREADY_HAVE_CHARM;
if(m_caster->GetCharmerGUID()) if (!m_caster->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
Pet* pet = m_caster->GetPet(); Pet* pet = m_caster->GetPet();
if (!pet) if (!pet)
return SPELL_FAILED_NO_PET; return SPELL_FAILED_NO_PET;
if(pet->GetCharmerGUID()) if (!pet->GetCharmerGuid().IsEmpty())
return SPELL_FAILED_CHARMED; return SPELL_FAILED_CHARMED;
break; break;
@ -6332,7 +6332,7 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff )
// Check targets for not_selectable unit flag and remove // Check targets for not_selectable unit flag and remove
// A player can cast spells on his pet (or other controlled unit) though in any state // A player can cast spells on his pet (or other controlled unit) though in any state
if (target != m_caster && target->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) if (target != m_caster && target->GetCharmerOrOwnerGuid() != m_caster->GetObjectGuid())
{ {
// any unattackable target skipped // any unattackable target skipped
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))

View file

@ -814,7 +814,7 @@ void AreaAura::Update(uint32 diff)
else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
{ {
// not check group if target == owner or target == pet // not check group if target == owner or target == pet
if (caster->GetCharmerOrOwnerGUID() != target->GetGUID() && caster->GetGUID() != target->GetCharmerOrOwnerGUID()) if (caster->GetCharmerOrOwnerGuid() != target->GetObjectGuid() && caster->GetObjectGuid() != target->GetCharmerOrOwnerGuid())
{ {
Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself(); Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
@ -832,7 +832,7 @@ void AreaAura::Update(uint32 diff)
else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me! else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
{ {
// not check group if target == owner or target == pet // not check group if target == owner or target == pet
if (caster->GetCharmerOrOwnerGUID() != target->GetGUID() && caster->GetGUID() != target->GetCharmerOrOwnerGUID()) if (caster->GetCharmerOrOwnerGuid() != target->GetObjectGuid() && caster->GetObjectGuid() != target->GetCharmerOrOwnerGuid())
{ {
Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself(); Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
@ -849,7 +849,7 @@ void AreaAura::Update(uint32 diff)
} }
else if (m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER) else if (m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER)
{ {
if( target->GetGUID() != caster->GetCharmerOrOwnerGUID() ) if (target->GetObjectGuid() != caster->GetCharmerOrOwnerGuid())
target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGUID()); target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGUID());
} }
} }
@ -3425,7 +3425,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
target->addUnitState(UNIT_STAT_CONTROLLED); target->addUnitState(UNIT_STAT_CONTROLLED);
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
target->SetCharmerGUID(p_caster->GetGUID()); target->SetCharmerGuid(p_caster->GetObjectGuid());
target->setFaction(p_caster->getFaction()); target->setFaction(p_caster->getFaction());
// target should became visible at SetView call(if not visible before): // target should became visible at SetView call(if not visible before):
@ -3484,7 +3484,7 @@ void Aura::HandleModPossess(bool apply, bool Real)
target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
target->SetCharmerGUID(0); target->SetCharmerGuid(ObjectGuid());
if(target->GetTypeId() == TYPEID_PLAYER) if(target->GetTypeId() == TYPEID_PLAYER)
{ {
@ -3603,13 +3603,13 @@ void Aura::HandleModCharm(bool apply, bool Real)
if( apply ) if( apply )
{ {
if (target->GetCharmerGUID()) if (!target->GetCharmerGuid().IsEmpty())
{ {
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM); target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS); target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
} }
target->SetCharmerGUID(GetCasterGUID()); target->SetCharmerGuid(GetCasterGuid());
target->setFaction(caster->getFaction()); target->setFaction(caster->getFaction());
target->CastStop(target == caster ? GetId() : 0); target->CastStop(target == caster ? GetId() : 0);
caster->SetCharm(target); caster->SetCharm(target);
@ -3654,7 +3654,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
} }
else else
{ {
target->SetCharmerGUID(0); target->SetCharmerGuid(ObjectGuid());
if(target->GetTypeId() == TYPEID_PLAYER) if(target->GetTypeId() == TYPEID_PLAYER)
((Player*)target)->setFactionForRace(target->getRace()); ((Player*)target)->setFactionForRace(target->getRace());

View file

@ -4092,7 +4092,7 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
void Spell::DoSummon(SpellEffectIndex eff_idx) void Spell::DoSummon(SpellEffectIndex eff_idx)
{ {
if (m_caster->GetPetGUID()) if (!m_caster->GetPetGuid().IsEmpty())
return; return;
if (!unitTarget) if (!unitTarget)
@ -4162,7 +4162,7 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
if (duration > 0) if (duration > 0)
spawnCreature->SetDuration(duration); spawnCreature->SetDuration(duration);
spawnCreature->SetOwnerGUID(m_caster->GetGUID()); spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
spawnCreature->setPowerType(POWER_MANA); spawnCreature->setPowerType(POWER_MANA);
spawnCreature->setFaction(m_caster->getFaction()); spawnCreature->setFaction(m_caster->getFaction());
@ -4172,7 +4172,7 @@ void Spell::DoSummon(SpellEffectIndex eff_idx)
spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); spawnCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
spawnCreature->SetCreatorGUID(m_caster->GetGUID()); spawnCreature->SetCreatorGuid(m_caster->GetObjectGuid());
spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
spawnCreature->InitStatsForLevel(level, m_caster); spawnCreature->InitStatsForLevel(level, m_caster);
@ -4511,7 +4511,7 @@ void Spell::DoSummonWild(SpellEffectIndex eff_idx, uint32 forceFaction)
if(Creature *summon = m_caster->SummonCreature(creature_entry, px, py, pz, m_caster->GetOrientation(), summonType, duration)) if(Creature *summon = m_caster->SummonCreature(creature_entry, px, py, pz, m_caster->GetOrientation(), summonType, duration))
{ {
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
summon->SetCreatorGUID(m_caster->GetGUID()); summon->SetCreatorGuid(m_caster->GetObjectGuid());
if(forceFaction) if(forceFaction)
summon->setFaction(forceFaction); summon->setFaction(forceFaction);
@ -4601,14 +4601,14 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
if (duration > 0) if (duration > 0)
spawnCreature->SetDuration(duration); spawnCreature->SetDuration(duration);
spawnCreature->SetOwnerGUID(m_caster->GetGUID()); spawnCreature->SetOwnerGuid(m_caster->GetObjectGuid());
spawnCreature->setPowerType(POWER_MANA); spawnCreature->setPowerType(POWER_MANA);
spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, spawnCreature->GetCreatureInfo()->npcflag); spawnCreature->SetUInt32Value(UNIT_NPC_FLAGS, spawnCreature->GetCreatureInfo()->npcflag);
spawnCreature->setFaction(forceFaction ? forceFaction : m_caster->getFaction()); spawnCreature->setFaction(forceFaction ? forceFaction : m_caster->getFaction());
spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_FLAGS, 0);
spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0); spawnCreature->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
spawnCreature->SetCreatorGUID(m_caster->GetGUID()); spawnCreature->SetCreatorGuid(m_caster->GetObjectGuid());
spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
spawnCreature->InitStatsForLevel(level, m_caster); spawnCreature->InitStatsForLevel(level, m_caster);
@ -5034,8 +5034,8 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE); NewSummon->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
} }
NewSummon->SetOwnerGUID(m_caster->GetGUID()); NewSummon->SetOwnerGuid(m_caster->GetObjectGuid());
NewSummon->SetCreatorGUID(m_caster->GetGUID()); NewSummon->SetCreatorGuid(m_caster->GetObjectGuid());
NewSummon->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); NewSummon->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
NewSummon->setFaction(faction); NewSummon->setFaction(faction);
NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048); NewSummon->SetUInt32Value(UNIT_FIELD_BYTES_0, 2048);
@ -7516,8 +7516,8 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction)
return; return;
} }
critter->SetOwnerGUID(m_caster->GetGUID()); critter->SetOwnerGuid(m_caster->GetObjectGuid());
critter->SetCreatorGUID(m_caster->GetGUID()); critter->SetCreatorGuid(m_caster->GetObjectGuid());
critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); critter->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
critter->setFaction(forceFaction ? forceFaction : m_caster->getFaction()); critter->setFaction(forceFaction ? forceFaction : m_caster->getFaction());

View file

@ -509,7 +509,7 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
return; return;
} }
if (guid.GetRawValue() != GetPlayer()->GetPetGUID() && guid.GetRawValue() != GetPlayer()->GetCharmGUID()) if (guid != GetPlayer()->GetPetGuid() && guid != GetPlayer()->GetCharmGuid())
{ {
sLog.outError("HandlePetCancelAura. %s isn't pet of %s", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str()); sLog.outError("HandlePetCancelAura. %s isn't pet of %s", guid.GetString().c_str(), GetPlayer()->GetObjectGuid().GetString().c_str());
return; return;

View file

@ -257,7 +257,7 @@ template<>
void FollowMovementGenerator<Creature>::_updateSpeed(Creature &u) void FollowMovementGenerator<Creature>::_updateSpeed(Creature &u)
{ {
// pet only sync speed with owner // pet only sync speed with owner
if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetGUID() != u.GetOwnerGUID()) if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid())
return; return;
u.UpdateSpeed(MOVE_RUN,true); u.UpdateSpeed(MOVE_RUN,true);

View file

@ -115,18 +115,18 @@ void Totem::UnSummon()
void Totem::SetOwner(Unit* owner) void Totem::SetOwner(Unit* owner)
{ {
SetCreatorGUID(owner->GetGUID()); SetCreatorGuid(owner->GetObjectGuid());
SetOwnerGUID(owner->GetGUID()); SetOwnerGuid(owner->GetObjectGuid());
setFaction(owner->getFaction()); setFaction(owner->getFaction());
SetLevel(owner->getLevel()); SetLevel(owner->getLevel());
} }
Unit *Totem::GetOwner() Unit *Totem::GetOwner()
{ {
uint64 ownerid = GetOwnerGUID(); ObjectGuid ownerGuid = GetOwnerGuid();
if(!ownerid) if (ownerGuid.IsEmpty())
return NULL; return NULL;
return ObjectAccessor::GetUnit(*this, ownerid); return ObjectAccessor::GetUnit(*this, ownerGuid);
} }
void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto) void Totem::SetTypeBySummonSpell(SpellEntry const * spellProto)

View file

@ -600,7 +600,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1))
{ {
// prevent kill only if killed in duel and killed by opponent or opponent controlled creature // prevent kill only if killed in duel and killed by opponent or opponent controlled creature
if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID()) if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetObjectGuid() == GetOwnerGuid())
damage = health-1; damage = health-1;
duel_hasEnded = true; duel_hasEnded = true;
@ -1709,7 +1709,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
// If this is a creature and it attacks from behind it has a probability to daze it's victim // If this is a creature and it attacks from behind it has a probability to daze it's victim
if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) &&
GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGUID() && !pVictim->HasInArc(M_PI_F, this) ) GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->GetCharmerOrOwnerGuid().IsEmpty() && !pVictim->HasInArc(M_PI_F, this) )
{ {
// -probability is between 0% and 40% // -probability is between 0% and 40%
// 20% base chance // 20% base chance
@ -2695,7 +2695,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
// can be from by creature (if can) or from controlled player that considered as creature // can be from by creature (if can) or from controlled player that considered as creature
(GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() && (GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() &&
!(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH) || !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH) ||
GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGUID())) GetTypeId()==TYPEID_PLAYER && !GetCharmerOrOwnerGuid().IsEmpty()))
{ {
// when their weapon skill is 15 or more above victim's defense skill // when their weapon skill is 15 or more above victim's defense skill
tmp = victimDefenseSkill; tmp = victimDefenseSkill;
@ -5788,14 +5788,16 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
Unit *Unit::GetOwner() const Unit *Unit::GetOwner() const
{ {
if(uint64 ownerid = GetOwnerGUID()) ObjectGuid ownerid = GetOwnerGuid();
if (!ownerid.IsEmpty())
return ObjectAccessor::GetUnit(*this, ownerid); return ObjectAccessor::GetUnit(*this, ownerid);
return NULL; return NULL;
} }
Unit *Unit::GetCharmer() const Unit *Unit::GetCharmer() const
{ {
if(uint64 charmerid = GetCharmerGUID()) ObjectGuid charmerid = GetCharmerGuid();
if (!charmerid.IsEmpty())
return ObjectAccessor::GetUnit(*this, charmerid); return ObjectAccessor::GetUnit(*this, charmerid);
return NULL; return NULL;
} }
@ -5805,13 +5807,13 @@ bool Unit::IsCharmerOrOwnerPlayerOrPlayerItself() const
if (GetTypeId()==TYPEID_PLAYER) if (GetTypeId()==TYPEID_PLAYER)
return true; return true;
return IS_PLAYER_GUID(GetCharmerOrOwnerGUID()); return GetCharmerOrOwnerGuid().IsPlayer();
} }
Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself()
{ {
uint64 guid = GetCharmerOrOwnerGUID(); ObjectGuid guid = GetCharmerOrOwnerGuid();
if(IS_PLAYER_GUID(guid)) if (guid.IsPlayer())
return ObjectAccessor::FindPlayer(guid); return ObjectAccessor::FindPlayer(guid);
return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL;
@ -5819,12 +5821,13 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself()
Pet* Unit::GetPet() const Pet* Unit::GetPet() const
{ {
if(uint64 pet_guid = GetPetGUID()) ObjectGuid pet_guid = GetPetGuid();
if (!pet_guid.IsEmpty())
{ {
if(Pet* pet = GetMap()->GetPet(pet_guid)) if(Pet* pet = GetMap()->GetPet(pet_guid))
return pet; return pet;
sLog.outError("Unit::GetPet: Pet %u not exist.",GUID_LOPART(pet_guid)); sLog.outError("Unit::GetPet: %s not exist.", pet_guid.GetString().c_str());
const_cast<Unit*>(this)->SetPet(0); const_cast<Unit*>(this)->SetPet(0);
} }
@ -5838,12 +5841,13 @@ Pet* Unit::_GetPet(ObjectGuid guid) const
Unit* Unit::GetCharm() const Unit* Unit::GetCharm() const
{ {
if (uint64 charm_guid = GetCharmGUID()) ObjectGuid charm_guid = GetCharmGuid();
if (!charm_guid.IsEmpty())
{ {
if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid))
return pet; return pet;
sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid)); sLog.outError("Unit::GetCharm: Charmed %s not exist.", charm_guid.GetString().c_str());
const_cast<Unit*>(this)->SetCharm(NULL); const_cast<Unit*>(this)->SetCharm(NULL);
} }
@ -5871,7 +5875,7 @@ float Unit::GetCombatDistance( const Unit* target ) const
void Unit::SetPet(Pet* pet) void Unit::SetPet(Pet* pet)
{ {
SetPetGUID(pet ? pet->GetGUID() : 0); SetPetGuid(pet ? pet->GetObjectGuid() : ObjectGuid());
if(pet && GetTypeId() == TYPEID_PLAYER) if(pet && GetTypeId() == TYPEID_PLAYER)
((Player*)this)->SendPetGUIDs(); ((Player*)this)->SendPetGUIDs();
@ -5879,7 +5883,7 @@ void Unit::SetPet(Pet* pet)
void Unit::SetCharm(Unit* pet) void Unit::SetCharm(Unit* pet)
{ {
SetCharmGUID(pet ? pet->GetGUID() : 0); SetCharmGuid(pet ? pet->GetObjectGuid() : ObjectGuid());
} }
void Unit::AddGuardian( Pet* pet ) void Unit::AddGuardian( Pet* pet )
@ -7797,7 +7801,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
return false; return false;
} }
} }
else if(GetCharmerOrOwnerGUID()) // distance for show pet/charmed else if (!GetCharmerOrOwnerGuid().IsEmpty()) // distance for show pet/charmed
{ {
// Pet/charmed far than max visible distance for player or not in our map are not visible too // Pet/charmed far than max visible distance for player or not in our map are not visible too
if (!IsWithinDistInMap(viewPoint, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) if (!IsWithinDistInMap(viewPoint, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance))
@ -7811,7 +7815,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
} }
// always seen by owner // always seen by owner
if (GetCharmerOrOwnerGUID()==u->GetGUID()) if (GetCharmerOrOwnerGuid() == u->GetObjectGuid())
return true; return true;
// isInvisibleForAlive() those units can only be seen by dead or if other // isInvisibleForAlive() those units can only be seen by dead or if other
@ -8409,11 +8413,11 @@ bool Unit::CanHaveThreatList() const
return false; return false;
// pets can not have a threat list, unless they are controlled by a creature // pets can not have a threat list, unless they are controlled by a creature
if (creature->IsPet() && IS_PLAYER_GUID(((Pet const*)creature)->GetOwnerGUID())) if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer())
return false; return false;
// charmed units can not have a threat list if charmed by player // charmed units can not have a threat list if charmed by player
if (creature->isCharmed() && IS_PLAYER_GUID(creature->GetCharmerGUID())) if (creature->GetCharmerGuid().IsPlayer())
return false; return false;
return true; return true;
@ -10307,8 +10311,8 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
return NULL; return NULL;
} }
pet->SetOwnerGUID(GetGUID()); pet->SetOwnerGuid(GetObjectGuid());
pet->SetCreatorGUID(GetGUID()); pet->SetCreatorGuid(GetObjectGuid());
pet->setFaction(getFaction()); pet->setFaction(getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);

View file

@ -1219,7 +1219,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void clearUnitState(uint32 f) { m_state &= ~f; } void clearUnitState(uint32 f) { m_state &= ~f; }
bool CanFreeMove() const bool CanFreeMove() const
{ {
return !hasUnitState(UNIT_STAT_NO_FREE_MOVE) && GetOwnerGUID()==0; return !hasUnitState(UNIT_STAT_NO_FREE_MOVE) && GetOwnerGuid().IsEmpty();
} }
uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
@ -1479,29 +1479,30 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
DeathState getDeathState() { return m_deathState; }; DeathState getDeathState() { return m_deathState; };
virtual void SetDeathState(DeathState s); // overwritten in Creature/Player/Pet virtual void SetDeathState(DeathState s); // overwritten in Creature/Player/Pet
uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); } ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(UNIT_FIELD_SUMMONEDBY); }
void SetOwnerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_SUMMONEDBY, owner); } void SetOwnerGuid(ObjectGuid owner) { SetGuidValue(UNIT_FIELD_SUMMONEDBY, owner); }
uint64 GetCreatorGUID() const { return GetUInt64Value(UNIT_FIELD_CREATEDBY); } ObjectGuid const& GetCreatorGuid() const { return GetGuidValue(UNIT_FIELD_CREATEDBY); }
void SetCreatorGUID(uint64 creator) { SetUInt64Value(UNIT_FIELD_CREATEDBY, creator); } void SetCreatorGuid(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); }
uint64 GetPetGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMON); } ObjectGuid const& GetPetGuid() const { return GetGuidValue(UNIT_FIELD_SUMMON); }
void SetPetGUID(uint64 pet) { SetUInt64Value(UNIT_FIELD_SUMMON, pet); } void SetPetGuid(ObjectGuid pet) { SetGuidValue(UNIT_FIELD_SUMMON, pet); }
uint64 GetCharmerGUID() const { return GetUInt64Value(UNIT_FIELD_CHARMEDBY); } ObjectGuid const& GetCharmerGuid() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); }
void SetCharmerGUID(uint64 owner) { SetUInt64Value(UNIT_FIELD_CHARMEDBY, owner); } void SetCharmerGuid(ObjectGuid owner) { SetGuidValue(UNIT_FIELD_CHARMEDBY, owner); }
uint64 GetCharmGUID() const { return GetUInt64Value(UNIT_FIELD_CHARM); } ObjectGuid const& GetCharmGuid() const { return GetGuidValue(UNIT_FIELD_CHARM); }
void SetCharmGUID(uint64 charm) { SetUInt64Value(UNIT_FIELD_CHARM, charm); } void SetCharmGuid(ObjectGuid charm) { SetGuidValue(UNIT_FIELD_CHARM, charm); }
ObjectGuid const& GetTargetGuid() const { return GetGuidValue(UNIT_FIELD_TARGET); } ObjectGuid const& GetTargetGuid() const { return GetGuidValue(UNIT_FIELD_TARGET); }
void SetTargetGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_TARGET, targetGuid); } void SetTargetGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_TARGET, targetGuid); }
ObjectGuid const& GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); } ObjectGuid const& GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); }
void SetChannelObjectGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, targetGuid); } void SetChannelObjectGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, targetGuid); }
uint64 GetCharmerOrOwnerGUID() const { return GetCharmerGUID() ? GetCharmerGUID() : GetOwnerGUID(); } ObjectGuid const& GetCharmerOrOwnerGuid() const { return !GetCharmerGuid().IsEmpty() ? GetCharmerGuid() : GetOwnerGuid(); }
uint64 GetCharmerOrOwnerOrOwnGUID() const ObjectGuid const& GetCharmerOrOwnerOrOwnGuid() const
{ {
if(uint64 guid = GetCharmerOrOwnerGUID()) ObjectGuid const& guid = GetCharmerOrOwnerGuid();
if (!guid.IsEmpty())
return guid; return guid;
return GetGUID(); return GetObjectGuid();
} }
bool isCharmedOwnedByPlayerOrPlayer() const { return IS_PLAYER_GUID(GetCharmerOrOwnerOrOwnGUID()); } bool isCharmedOwnedByPlayerOrPlayer() const { return GetCharmerOrOwnerOrOwnGuid().IsPlayer(); }
Player* GetSpellModOwner(); Player* GetSpellModOwner();
@ -1510,7 +1511,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
Unit* GetCharmer() const; Unit* GetCharmer() const;
Unit* GetCharm() const; Unit* GetCharm() const;
void Uncharm(); void Uncharm();
Unit* GetCharmerOrOwner() const { return GetCharmerGUID() ? GetCharmer() : GetOwner(); } Unit* GetCharmerOrOwner() const { return !GetCharmerGuid().IsEmpty() ? GetCharmer() : GetOwner(); }
Unit* GetCharmerOrOwnerOrSelf() Unit* GetCharmerOrOwnerOrSelf()
{ {
if(Unit* u = GetCharmerOrOwner()) if(Unit* u = GetCharmerOrOwner())
@ -1530,7 +1531,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void RemoveGuardians(); void RemoveGuardians();
Pet* FindGuardianWithEntry(uint32 entry); Pet* FindGuardianWithEntry(uint32 entry);
bool isCharmed() const { return GetCharmerGUID() != 0; } bool isCharmed() const { return !GetCharmerGuid().IsEmpty(); }
CharmInfo* GetCharmInfo() { return m_charmInfo; } CharmInfo* GetCharmInfo() { return m_charmInfo; }
CharmInfo* InitCharmInfo(Unit* charm); CharmInfo* InitCharmInfo(Unit* charm);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10670" #define REVISION_NR "10671"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__