[10749] Convert Gameobject owner to objectguid use.

This commit is contained in:
VladimirMangos 2010-11-19 20:53:04 +03:00
parent f5cf98e9f4
commit 6154cb3b43
13 changed files with 40 additions and 32 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_10746_01_mangos_mangos_string` bit(1) default NULL
`required_10749_01_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--

View file

@ -0,0 +1,6 @@
ALTER TABLE db_version CHANGE COLUMN required_10746_01_mangos_mangos_string required_10749_01_mangos_mangos_string bit;
DELETE FROM mangos_string WHERE entry IN (274);
INSERT INTO mangos_string VALUES
(274,'Game Object (GUID: %u) has references in not found owner %s GO list, can\'t be deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);

View file

@ -122,6 +122,7 @@ pkgdata_DATA = \
10743_01_mangos_spell_chain.sql \
10743_02_mangos_spell_bonus_data.sql \
10746_01_mangos_mangos_string.sql \
10749_01_mangos_mangos_string.sql \
README
## Additional files to include when running 'make dist'
@ -224,4 +225,5 @@ EXTRA_DIST = \
10743_01_mangos_spell_chain.sql \
10743_02_mangos_spell_bonus_data.sql \
10746_01_mangos_mangos_string.sql \
10749_01_mangos_mangos_string.sql \
README

View file

@ -77,7 +77,7 @@ void GameObject::RemoveFromWorld()
if(IsInWorld())
{
// Remove GO from owner
ObjectGuid owner_guid = GetOwnerGUID();
ObjectGuid owner_guid = GetOwnerGuid();
if (!owner_guid.IsEmpty())
{
if (Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid))
@ -392,7 +392,7 @@ void GameObject::Update(uint32 /*p_time*/)
//any return here in case battleground traps
}
if (GetOwnerGUID())
if (!GetOwnerGuid().IsEmpty())
{
if (Unit* owner = GetOwner())
owner->RemoveGameObject(this, false);
@ -667,7 +667,7 @@ bool GameObject::IsTransport() const
Unit* GameObject::GetOwner() const
{
return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
return ObjectAccessor::GetUnit(*this, GetOwnerGuid());
}
void GameObject::SaveRespawnTime()
@ -819,9 +819,9 @@ void GameObject::SummonLinkedTrapIfAny()
linkedGO->SetRespawnTime(GetRespawnDelay());
linkedGO->SetSpellId(GetSpellId());
if (GetOwnerGUID())
if (!GetOwnerGuid().IsEmpty())
{
linkedGO->SetOwnerGUID(GetOwnerGUID());
linkedGO->SetOwnerGuid(GetOwnerGuid());
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, GetUInt32Value(GAMEOBJECT_LEVEL));
}
@ -1152,7 +1152,7 @@ void GameObject::Use(Unit* user)
Player* player = (Player*)user;
if (player->GetGUID() != GetOwnerGUID())
if (player->GetObjectGuid() != GetOwnerGuid())
return;
switch(getLootState())
@ -1184,7 +1184,7 @@ void GameObject::Use(Unit* user)
{
// prevent removing GO at spell cancel
player->RemoveGameObject(this,false);
SetOwnerGUID(player->GetGUID());
SetOwnerGuid(player->GetObjectGuid());
//fish catched
player->UpdateFishingSkill();

View file

@ -611,12 +611,12 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool LoadFromDB(uint32 guid, Map *map);
void DeleteFromDB();
void SetOwnerGUID(uint64 owner)
void SetOwnerGuid(ObjectGuid ownerGuid)
{
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
SetGuidValue(OBJECT_FIELD_CREATED_BY, ownerGuid);
}
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
Unit* GetOwner() const;
void SetSpellId(uint32 id)

View file

@ -906,13 +906,13 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args)
return false;
}
uint64 owner_guid = obj->GetOwnerGUID();
if (owner_guid)
ObjectGuid ownerGuid = obj->GetOwnerGuid();
if (!ownerGuid.IsEmpty())
{
Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid);
if (!owner || !IS_PLAYER_GUID(owner_guid))
Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(), ownerGuid);
if (!owner || !ownerGuid.IsPlayer())
{
PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, obj->GetGUIDLow(), ownerGuid.GetString().c_str());
SetSentErrorMessage(true);
return false;
}

View file

@ -49,7 +49,7 @@ void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
GameObject *go = player->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
{
player->SendLootRelease(lguid);
return;
@ -192,7 +192,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
GameObject *pGameObject = GetPlayer()->GetMap()->GetGameObject(guid);
// not check distance for GO in case owned GO (fishing bobber case, for example)
if( pGameObject && (pGameObject->GetOwnerGUID()==_player->GetGUID() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) )
if( pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) )
pLoot = &pGameObject->loot;
break;
@ -319,7 +319,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
GameObject *go = GetPlayer()->GetMap()->GetGameObject(lguid);
// not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)))
return;
loot = &go->loot;

View file

@ -2073,7 +2073,7 @@ bool WorldObject::IsControlledByPlayer() const
switch (GetTypeId())
{
case TYPEID_GAMEOBJECT:
return IS_PLAYER_GUID(((GameObject*)this)->GetOwnerGUID());
return ((GameObject*)this)->GetOwnerGuid().IsPlayer();
case TYPEID_UNIT:
case TYPEID_PLAYER:
return ((Unit*)this)->IsCharmerOrOwnerPlayerOrPlayerItself();

View file

@ -7853,7 +7853,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
// not check distance for GO in case owned GO (fishing bobber case, for example)
// And permit out of range GO with no owner in case fishing hole
if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING || go->GetOwnerGUID() != GetGUID()) && !go->IsWithinDistInMap(this,INTERACTION_DISTANCE)))
if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING || go->GetOwnerGuid() != GetObjectGuid()) && !go->IsWithinDistInMap(this,INTERACTION_DISTANCE)))
{
SendLootRelease(guid);
return;

View file

@ -935,7 +935,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
}
pGameObj->SetRespawnTime(creatureTarget->GetRespawnTime()-time(NULL));
pGameObj->SetOwnerGUID(m_caster->GetGUID() );
pGameObj->SetOwnerGuid(m_caster->GetObjectGuid() );
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
pGameObj->SetSpellId(m_spellInfo->Id);
@ -7889,7 +7889,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx)
pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0);
pGameObj->SetOwnerGUID(m_caster->GetGUID());
pGameObj->SetOwnerGuid(m_caster->GetObjectGuid());
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel());
pGameObj->SetSpellId(m_spellInfo->Id);

View file

@ -3470,7 +3470,7 @@ void Unit::_UpdateSpells( uint32 time )
//(*i)->Update( difftime );
if( !(*ite1)->isSpawned() )
{
(*ite1)->SetOwnerGUID(0);
(*ite1)->SetOwnerGuid(ObjectGuid());
(*ite1)->SetRespawnTime(0);
(*ite1)->Delete();
dnext1 = m_gameObj.erase(ite1);
@ -4980,9 +4980,9 @@ GameObject* Unit::GetGameObject(uint32 spellId) const
void Unit::AddGameObject(GameObject* gameObj)
{
MANGOS_ASSERT(gameObj && gameObj->GetOwnerGUID()==0);
MANGOS_ASSERT(gameObj && gameObj->GetOwnerGuid().IsEmpty());
m_gameObj.push_back(gameObj);
gameObj->SetOwnerGUID(GetGUID());
gameObj->SetOwnerGuid(GetObjectGuid());
if ( GetTypeId()==TYPEID_PLAYER && gameObj->GetSpellId() )
{
@ -4996,9 +4996,9 @@ void Unit::AddGameObject(GameObject* gameObj)
void Unit::RemoveGameObject(GameObject* gameObj, bool del)
{
MANGOS_ASSERT(gameObj && gameObj->GetOwnerGUID()==GetGUID());
MANGOS_ASSERT(gameObj && gameObj->GetOwnerGuid() == GetObjectGuid());
gameObj->SetOwnerGUID(0);
gameObj->SetOwnerGuid(ObjectGuid());
// GO created by some spell
if (uint32 spellid = gameObj->GetSpellId())
@ -5034,7 +5034,7 @@ void Unit::RemoveGameObject(uint32 spellid, bool del)
next = i;
if(spellid == 0 || (*i)->GetSpellId() == spellid)
{
(*i)->SetOwnerGUID(0);
(*i)->SetOwnerGuid(ObjectGuid());
if(del)
{
(*i)->SetRespawnTime(0);
@ -5053,7 +5053,7 @@ void Unit::RemoveAllGameObjects()
// remove references to unit
for(GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end();)
{
(*i)->SetOwnerGUID(0);
(*i)->SetOwnerGuid(ObjectGuid());
(*i)->SetRespawnTime(0);
(*i)->Delete();
i = m_gameObj.erase(i);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10748"
#define REVISION_NR "10749"
#endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10664_01_characters_arena_team_stats"
#define REVISION_DB_MANGOS "required_10746_01_mangos_mangos_string"
#define REVISION_DB_MANGOS "required_10749_01_mangos_mangos_string"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__