Map local guids 6.x -> 3.3.35:
Implemented: https://github.com/TrinityCore/TrinityCore/commit/ca83e14f8b141fab0a13e08f48fca6c1ace0c4c7 https://github.com/TrinityCore/TrinityCore/commit/ee1c1b97be4492ecabe8b15ea6323fc37e4eaa8c https://github.com/TrinityCore/TrinityCore/commit/18e4ab6911468b829b0fc768e532a770263c3717 https://github.com/TrinityCore/TrinityCore/commit/bf37446b3c2ed73b4d3aa9e227d3eff5c53b378b https://github.com/TrinityCore/TrinityCore/commit/cb854a2b7bb7bd96cf9c4d1daf3789f797bf4db8 * This adds separate (per map) guid sequences depending on object type * Ported map object container from cmangos/mangos-wotlk@a2d396e * Added type container visitor for TypeUnorderedMapContainer * Implemented helper function to erase unique pairs from multimap containers * Moved object storage of all objects except players and transports to map level * Added containers linking database spawn id with creature/gameobject in world * Renamed DBTableGuid to spawnId * Added a separate spawn id sequence generator for creatures and gameobjects - this will be used in db tables * Moved building SMSG_UPDATE_OBJECT - updatefields changes broadcast to map update * Added new function to return but not increment guid * Adjusted .debug loadcells to show low guid in map before/after load * Added debug messages for creature spawn/destroy, for map guid debugging * Store all Gameobjects and Creatures added to OutdoorPvP, so the callback script can be removed when OutdoorPvP instance is destroyed.
This commit is contained in:
1 parent
0427870585
commit
dcb7082277
158 files changed
+2264
-2051
No files matched your search
@@ -52,7 +52,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
|
||||
m_goInfo = NULL;
|
||||
m_goData = NULL;
|
||||
|
||||
m_DBTableGuid = 0;
|
||||
m_spawnId = 0;
|
||||
m_rotation = 0;
|
||||
|
||||
m_lootRecipientGroup = 0;
|
||||
@@ -115,7 +115,7 @@ void GameObject::RemoveFromOwner()
|
||||
|
||||
// This happens when a mage portal is despawned after the caster changes map (for example using the portal)
|
||||
TC_LOG_DEBUG("misc", "Removed GameObject (GUID: %u Entry: %u SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list",
|
||||
GetGUIDLow(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
|
||||
GetGUID().GetCounter(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
|
||||
SetOwnerGUID(ObjectGuid::Empty);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,9 @@ void GameObject::AddToWorld()
|
||||
if (m_zoneScript)
|
||||
m_zoneScript->OnGameObjectCreate(this);
|
||||
|
||||
sObjectAccessor->AddObject(this);
|
||||
GetMap()->GetObjectsStore().Insert<GameObject>(GetGUID(), this);
|
||||
if (m_spawnId)
|
||||
GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
|
||||
|
||||
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
|
||||
bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport());
|
||||
@@ -156,8 +158,12 @@ void GameObject::RemoveFromWorld()
|
||||
if (m_model)
|
||||
if (GetMap()->ContainsGameObjectModel(*m_model))
|
||||
GetMap()->RemoveGameObjectModel(*m_model);
|
||||
|
||||
WorldObject::RemoveFromWorld();
|
||||
sObjectAccessor->RemoveObject(this);
|
||||
|
||||
if (m_spawnId)
|
||||
Trinity::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
|
||||
GetMap()->GetObjectsStore().Remove<GameObject>(GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +206,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT)
|
||||
m_updateFlag = (m_updateFlag | UPDATEFLAG_TRANSPORT) & ~UPDATEFLAG_POSITION;
|
||||
|
||||
Object::_Create(guidlow, goinfo->entry, HIGHGUID_GAMEOBJECT);
|
||||
Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject);
|
||||
|
||||
m_goInfo = goinfo;
|
||||
|
||||
@@ -273,7 +279,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
|
||||
break;
|
||||
}
|
||||
|
||||
if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(guidlow))
|
||||
if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId()))
|
||||
{
|
||||
if (addon->InvisibilityValue)
|
||||
{
|
||||
@@ -390,7 +396,7 @@ void GameObject::Update(uint32 diff)
|
||||
time_t now = time(NULL);
|
||||
if (m_respawnTime <= now) // timer expired
|
||||
{
|
||||
ObjectGuid dbtableHighGuid(HIGHGUID_GAMEOBJECT, GetEntry(), m_DBTableGuid);
|
||||
ObjectGuid dbtableHighGuid(HighGuid::GameObject, GetEntry(), m_spawnId);
|
||||
time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
|
||||
if (linkedRespawntime) // Can't respawn, the master is dead
|
||||
{
|
||||
@@ -446,9 +452,9 @@ void GameObject::Update(uint32 diff)
|
||||
}
|
||||
|
||||
// Respawn timer
|
||||
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
|
||||
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
|
||||
else
|
||||
GetMap()->AddToMap(this);
|
||||
}
|
||||
@@ -686,9 +692,9 @@ void GameObject::Delete()
|
||||
SetGoState(GO_STATE_READY);
|
||||
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
|
||||
|
||||
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
|
||||
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
|
||||
else
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
@@ -737,7 +743,7 @@ void GameObject::SaveToDB()
|
||||
{
|
||||
// this should only be used when the gameobject has already been loaded
|
||||
// preferably after adding to map, because mapid may not be valid otherwise
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid);
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId);
|
||||
if (!data)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "GameObject::SaveToDB failed, cannot get gameobject data!");
|
||||
@@ -754,10 +760,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
if (!goI)
|
||||
return;
|
||||
|
||||
if (!m_DBTableGuid)
|
||||
m_DBTableGuid = GetGUIDLow();
|
||||
if (!m_spawnId)
|
||||
m_spawnId = sObjectMgr->GenerateGameObjectSpawnId();
|
||||
|
||||
// update in loaded data (changing data only in this place)
|
||||
GameObjectData& data = sObjectMgr->NewGOData(m_DBTableGuid);
|
||||
GameObjectData& data = sObjectMgr->NewGOData(m_spawnId);
|
||||
|
||||
// data->guid = guid must not be updated at save
|
||||
data.id = GetEntry();
|
||||
@@ -783,11 +790,11 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
uint8 index = 0;
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
|
||||
stmt->setUInt32(0, m_DBTableGuid);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
|
||||
stmt->setUInt32(index++, m_DBTableGuid);
|
||||
stmt->setUInt32(index++, m_spawnId);
|
||||
stmt->setUInt32(index++, GetEntry());
|
||||
stmt->setUInt16(index++, uint16(mapid));
|
||||
stmt->setUInt8(index++, spawnMask);
|
||||
@@ -808,13 +815,13 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
|
||||
bool GameObject::LoadGameObjectFromDB(uint32 spawnId, Map* map, bool addToMap)
|
||||
{
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(guid);
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(spawnId);
|
||||
|
||||
if (!data)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", guid);
|
||||
TC_LOG_ERROR("sql.sql", "Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", spawnId);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -835,10 +842,8 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
|
||||
GOState go_state = data->go_state;
|
||||
uint32 artKit = data->artKit;
|
||||
|
||||
m_DBTableGuid = guid;
|
||||
if (map->GetInstanceId() != 0) guid = sObjectMgr->GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
|
||||
m_spawnId = spawnId;
|
||||
if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
|
||||
return false;
|
||||
|
||||
if (data->spawntimesecs >= 0)
|
||||
@@ -854,13 +859,13 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
|
||||
else
|
||||
{
|
||||
m_respawnDelayTime = data->spawntimesecs;
|
||||
m_respawnTime = GetMap()->GetGORespawnTime(m_DBTableGuid);
|
||||
m_respawnTime = GetMap()->GetGORespawnTime(m_spawnId);
|
||||
|
||||
// ready to respawn
|
||||
if (m_respawnTime && m_respawnTime <= time(NULL))
|
||||
{
|
||||
m_respawnTime = 0;
|
||||
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
|
||||
GetMap()->RemoveGORespawnTime(m_spawnId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -881,18 +886,18 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
|
||||
|
||||
void GameObject::DeleteFromDB()
|
||||
{
|
||||
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
|
||||
sObjectMgr->DeleteGOData(m_DBTableGuid);
|
||||
GetMap()->RemoveGORespawnTime(m_spawnId);
|
||||
sObjectMgr->DeleteGOData(m_spawnId);
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
|
||||
|
||||
stmt->setUInt32(0, m_DBTableGuid);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
|
||||
|
||||
stmt->setUInt32(0, m_DBTableGuid);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
@@ -960,7 +965,7 @@ Unit* GameObject::GetOwner() const
|
||||
void GameObject::SaveRespawnTime()
|
||||
{
|
||||
if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
|
||||
GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
|
||||
GetMap()->SaveGORespawnTime(m_spawnId, m_respawnTime);
|
||||
}
|
||||
|
||||
bool GameObject::IsNeverVisible() const
|
||||
@@ -1017,7 +1022,7 @@ void GameObject::Respawn()
|
||||
if (m_spawnedByDefault && m_respawnTime > 0)
|
||||
{
|
||||
m_respawnTime = time(NULL);
|
||||
GetMap()->RemoveGORespawnTime(m_DBTableGuid);
|
||||
GetMap()->RemoveGORespawnTime(m_spawnId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1142,7 +1147,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
|
||||
void GameObject::SetGoArtKit(uint8 kit)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
|
||||
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid));
|
||||
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_spawnId));
|
||||
if (data)
|
||||
data->artKit = kit;
|
||||
}
|
||||
@@ -1335,7 +1340,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
if (info->goober.eventId)
|
||||
{
|
||||
TC_LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
|
||||
TC_LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetSpawnId());
|
||||
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
|
||||
EventInform(info->goober.eventId, user);
|
||||
}
|
||||
@@ -1741,7 +1746,7 @@ void GameObject::Use(Unit* user)
|
||||
default:
|
||||
if (GetGoType() >= MAX_GAMEOBJECT_TYPE)
|
||||
TC_LOG_ERROR("misc", "GameObject::Use(): unit (type: %u, guid: %u, name: %s) tries to use object (guid: %u, entry: %u, name: %s) of unknown type (%u)",
|
||||
user->GetTypeId(), user->GetGUIDLow(), user->GetName().c_str(), GetGUIDLow(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType());
|
||||
user->GetTypeId(), user->GetGUID().GetCounter(), user->GetName().c_str(), GetGUID().GetCounter(), GetEntry(), GetGOInfo()->name.c_str(), GetGoType());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2273,9 +2278,9 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
|
||||
|
||||
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
if (m_spawnId)
|
||||
{
|
||||
if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow()))
|
||||
if (GameObjectData const* data = sObjectMgr->GetGOData(GetSpawnId()))
|
||||
{
|
||||
x = data->posX;
|
||||
y = data->posY;
|
||||
|
||||
Reference in new issue
Block a user