mirror of
https://github.com/mangosfour/server.git
synced 2025-12-24 19:37:07 +00:00
[10671] Convert some Unit owner/etc guids to ObjectGuid way.
This commit is contained in:
parent
92d98b9fb2
commit
a32d68febd
18 changed files with 154 additions and 149 deletions
|
|
@ -191,7 +191,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
|
|||
|
||||
m_charmInfo->SetPetNumber(pet_number, IsPermanentPetFor(owner));
|
||||
|
||||
SetOwnerGUID(owner->GetGUID());
|
||||
SetOwnerGuid(owner->GetObjectGuid());
|
||||
SetDisplayId(fields[3].GetUInt32());
|
||||
SetNativeDisplayId(fields[3].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_PETEXPERIENCE, fields[5].GetUInt32());
|
||||
SetCreatorGUID(owner->GetGUID());
|
||||
SetCreatorGuid(owner->GetObjectGuid());
|
||||
|
||||
m_charmInfo->SetReactState(ReactStates(fields[6].GetUInt8()));
|
||||
|
||||
|
|
@ -352,7 +352,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
|||
return;
|
||||
|
||||
// not save not player pets
|
||||
if(!IS_PLAYER_GUID(GetOwnerGUID()))
|
||||
if (!GetOwnerGuid().IsPlayer())
|
||||
return;
|
||||
|
||||
Player* pOwner = (Player*)GetOwner();
|
||||
|
|
@ -385,29 +385,29 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
|||
_SaveSpellCooldowns();
|
||||
_SaveAuras();
|
||||
|
||||
uint32 owner = GUID_LOPART(GetOwnerGUID());
|
||||
uint32 ownerLow = GetOwnerGuid().GetCounter();
|
||||
std::string name = m_name;
|
||||
CharacterDatabase.escape_string(name);
|
||||
CharacterDatabase.BeginTransaction();
|
||||
// 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)
|
||||
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'",
|
||||
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
|
||||
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')",
|
||||
owner,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT);
|
||||
ownerLow, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
|
||||
// save pet
|
||||
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) "
|
||||
<< "VALUES ("
|
||||
<< m_charmInfo->GetPetNumber() << ", "
|
||||
<< GetEntry() << ", "
|
||||
<< owner << ", "
|
||||
<< ownerLow << ", "
|
||||
<< GetNativeDisplayId() << ", "
|
||||
<< getLevel() << ", "
|
||||
<< GetUInt32Value(UNIT_FIELD_PETEXPERIENCE) << ", "
|
||||
|
|
@ -503,22 +503,22 @@ void Pet::Update(uint32 diff)
|
|||
{
|
||||
// unsummon pet that lost owner
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_duration > 0)
|
||||
if (m_duration > 0)
|
||||
{
|
||||
if(m_duration > (int32)diff)
|
||||
m_duration -= (int32)diff;
|
||||
|
|
@ -675,7 +675,7 @@ void Pet::Remove(PetSaveMode mode, bool returnreagent)
|
|||
}
|
||||
|
||||
// only if current pet in slot
|
||||
if(owner->GetPetGUID()==GetGUID())
|
||||
if (owner->GetPetGuid() == GetObjectGuid())
|
||||
owner->SetPet(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue