*Only set guardian's ownerguid in setpet.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-25 10:12:15 -06:00
parent d76578219f
commit d2e0ed5f57
5 changed files with 20 additions and 12 deletions
@@ -111,7 +111,6 @@ struct TRINITY_DLL_DECL boss_vexallusAI : public ScriptedAI
summoned->GetMotionMaster()->MoveFollow(temp,0,0);
//spells are SUMMON_TYPE_GUARDIAN, so using setOwner should be ok
summoned->SetOwnerGUID(m_creature->GetGUID());
summoned->CastSpell(summoned,SPELL_ENERGY_BOLT,false,0,0,m_creature->GetGUID());
}
-1
View File
@@ -1815,7 +1815,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
return NULL;
}
pet->SetOwnerGUID(GetGUID());
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
+2 -2
View File
@@ -179,7 +179,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
else
m_charmInfo->SetPetNumber(pet_number, false);
SetOwnerGUID(owner->GetGUID());
owner->SetPet(this, true);
SetDisplayId(fields[3].GetUInt32());
SetNativeDisplayId(fields[3].GetUInt32());
uint32 petlevel = fields[4].GetUInt32();
@@ -313,7 +314,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
_LoadSpells();
_LoadSpellCooldowns();
owner->SetPet(this, true); // in DB stored only full controlled creature
sLog.outDebug("New Pet has guid %u", GetGUIDLow());
if(owner->GetTypeId() == TYPEID_PLAYER)
-1
View File
@@ -243,7 +243,6 @@ void Guardian::InitSummon(uint32 duration)
SetReactState(REACT_AGGRESSIVE);
SetOwnerGUID(m_owner->GetGUID());
SetCreatorGUID(m_owner->GetGUID());
setFaction(m_owner->getFaction());
m_owner->SetPet(this, true);
+18 -7
View File
@@ -8319,6 +8319,11 @@ void Unit::SetPet(Creature* pet, bool apply)
{
if(apply)
{
if(!pet->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGuid())
{
sLog.outCrash("Pet %u is summoned by %u but it already has a owner", pet->GetEntry(), GetEntry());
return;
}
AddUInt64Value(UNIT_FIELD_SUMMON, pet->GetGUID());
m_Controlled.insert(pet);
@@ -8329,16 +8334,23 @@ void Unit::SetPet(Creature* pet, bool apply)
}
else
{
SetUInt64Value(UNIT_FIELD_SUMMON, 0);
if(!pet->RemoveUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGuid())
{
sLog.outCrash("Pet %u is unsummoned by %u but it has another owner", pet->GetEntry(), GetEntry());
return;
}
m_Controlled.erase(pet);
//Check if there is other pet (guardian actually)
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
if(RemoveUInt64Value(UNIT_FIELD_SUMMON, pet->GetGUID()))
{
if((*itr)->GetOwnerGUID() == GetGUID())
//Check if there is other pet (guardian actually)
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
{
AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID());
break;
if((*itr)->GetOwnerGUID() == GetGUID())
{
AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID());
break;
}
}
}
}
@@ -12479,7 +12491,6 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
return NULL;
}
pet->SetOwnerGUID(GetGUID());
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);