diff --git a/sql/mangos.sql b/sql/mangos.sql index 3ab9a3d00..7f855ad9f 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -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'; -- diff --git a/sql/updates/10749_01_mangos_mangos_string.sql b/sql/updates/10749_01_mangos_mangos_string.sql new file mode 100644 index 000000000..b54c66aae --- /dev/null +++ b/sql/updates/10749_01_mangos_mangos_string.sql @@ -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); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 380fd0f07..916ed42de 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -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 diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 6a693e8fe..2b63fb842 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -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(); diff --git a/src/game/GameObject.h b/src/game/GameObject.h index d27af3952..4c795d1d8 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -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) diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 1873c4abd..27bbe8d9d 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -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; } diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 04908a83c..cb17832f6 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -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; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index c99732a47..ccb3924f5 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -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(); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0e099727d..74838d3a6 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 5ed7520d4..60cbd62b5 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -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); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f3df984d4..6e37aa755 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 40360e220..5e9698130 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10748" + #define REVISION_NR "10749" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 8fffd8680..a03b306ce 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -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__