mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11159] Remove now redundent GetDBTableGUIDLow support.
Now any creatures/gameobjects loaded base at DB data in non-instanceable/instanceable maps always have same guid as in DB data. * Also remove useless by same reasons MaNGOS::GameObjectWithDbGUIDCheck
This commit is contained in:
parent
654dac1e11
commit
04c21c95d3
20 changed files with 150 additions and 176 deletions
|
|
@ -56,7 +56,6 @@ GameObject::GameObject() : WorldObject()
|
|||
m_cooldownTime = 0;
|
||||
m_goInfo = NULL;
|
||||
|
||||
m_DBTableGuid = 0;
|
||||
m_rotation = 0;
|
||||
}
|
||||
|
||||
|
|
@ -424,8 +423,8 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/)
|
|||
SaveRespawnTime();
|
||||
|
||||
// if part of pool, let pool system schedule new spawn instead of just scheduling respawn
|
||||
if (uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0)
|
||||
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
if (uint16 poolid = sPoolMgr.IsPartOfAPool<GameObject>(GetGUIDLow()))
|
||||
sPoolMgr.UpdatePool<GameObject>(poolid, GetGUIDLow());
|
||||
|
||||
// can be not in world at pool despawn
|
||||
if (IsInWorld())
|
||||
|
|
@ -464,9 +463,8 @@ void GameObject::Delete()
|
|||
SetGoState(GO_STATE_READY);
|
||||
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
|
||||
|
||||
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
|
||||
if (uint16 poolid = sPoolMgr.IsPartOfAPool<GameObject>(GetGUIDLow()))
|
||||
sPoolMgr.UpdatePool<GameObject>(poolid, GetGUIDLow());
|
||||
else
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
|
|
@ -488,7 +486,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(GetGUIDLow());
|
||||
if(!data)
|
||||
{
|
||||
sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!");
|
||||
|
|
@ -505,10 +503,8 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
if (!goI)
|
||||
return;
|
||||
|
||||
if (!m_DBTableGuid)
|
||||
m_DBTableGuid = GetGUIDLow();
|
||||
// update in loaded data (changing data only in this place)
|
||||
GameObjectData& data = sObjectMgr.NewGOData(m_DBTableGuid);
|
||||
GameObjectData& data = sObjectMgr.NewGOData(GetGUIDLow());
|
||||
|
||||
// data->guid = guid don't must be update at save
|
||||
data.id = GetEntry();
|
||||
|
|
@ -530,7 +526,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
// updated in DB
|
||||
std::ostringstream ss;
|
||||
ss << "INSERT INTO gameobject VALUES ( "
|
||||
<< m_DBTableGuid << ", "
|
||||
<< GetGUIDLow() << ", "
|
||||
<< GetEntry() << ", "
|
||||
<< mapid << ", "
|
||||
<< uint32(spawnMask) << "," // cast to prevent save as symbol
|
||||
|
|
@ -548,7 +544,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
<< uint32(GetGoState()) << ")";
|
||||
|
||||
WorldDatabase.BeginTransaction();
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("%s", ss.str().c_str());
|
||||
WorldDatabase.CommitTransaction();
|
||||
}
|
||||
|
|
@ -579,8 +575,6 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
|
|||
uint8 animprogress = data->animprogress;
|
||||
GOState go_state = data->go_state;
|
||||
|
||||
m_DBTableGuid = guid;
|
||||
|
||||
if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state) )
|
||||
return false;
|
||||
|
||||
|
|
@ -598,13 +592,13 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
|
|||
m_spawnedByDefault = true;
|
||||
m_respawnDelayTime = data->spawntimesecs;
|
||||
|
||||
m_respawnTime = map->GetPersistentState()->GetGORespawnTime(m_DBTableGuid);
|
||||
m_respawnTime = map->GetPersistentState()->GetGORespawnTime(GetGUIDLow());
|
||||
|
||||
// ready to respawn
|
||||
if (m_respawnTime && m_respawnTime <= time(NULL))
|
||||
{
|
||||
m_respawnTime = 0;
|
||||
map->GetPersistentState()->SaveGORespawnTime(m_DBTableGuid, 0);
|
||||
map->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -633,19 +627,19 @@ struct GameObjectRespawnDeleteWorker
|
|||
|
||||
void GameObject::DeleteFromDB()
|
||||
{
|
||||
if (!m_DBTableGuid)
|
||||
if (!HasStaticDBSpawnData())
|
||||
{
|
||||
DEBUG_LOG("Trying to delete not saved gameobject!");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObjectRespawnDeleteWorker worker(m_DBTableGuid);
|
||||
GameObjectRespawnDeleteWorker worker(GetGUIDLow());
|
||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker);
|
||||
|
||||
sObjectMgr.DeleteGOData(m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", m_DBTableGuid);
|
||||
sObjectMgr.DeleteGOData(GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", GetGUIDLow());
|
||||
}
|
||||
|
||||
GameObjectInfo const *GameObject::GetGOInfo() const
|
||||
|
|
@ -694,7 +688,7 @@ Unit* GameObject::GetOwner() const
|
|||
void GameObject::SaveRespawnTime()
|
||||
{
|
||||
if(m_respawnTime > time(NULL) && m_spawnedByDefault)
|
||||
GetMap()->GetPersistentState()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
|
||||
GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), m_respawnTime);
|
||||
}
|
||||
|
||||
bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
|
||||
|
|
@ -737,7 +731,7 @@ void GameObject::Respawn()
|
|||
if(m_spawnedByDefault && m_respawnTime > 0)
|
||||
{
|
||||
m_respawnTime = time(NULL);
|
||||
GetMap()->GetPersistentState()->SaveGORespawnTime(m_DBTableGuid, 0);
|
||||
GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -960,7 +954,7 @@ void GameObject::Use(Unit* user)
|
|||
UseDoorOrButton();
|
||||
|
||||
// activate script
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
||||
return;
|
||||
}
|
||||
case GAMEOBJECT_TYPE_BUTTON: // 1
|
||||
|
|
@ -969,7 +963,7 @@ void GameObject::Use(Unit* user)
|
|||
UseDoorOrButton();
|
||||
|
||||
// activate script
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
|
||||
GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
|
||||
|
||||
TriggerLinkedGameObject(user);
|
||||
return;
|
||||
|
|
@ -997,7 +991,7 @@ void GameObject::Use(Unit* user)
|
|||
// TODO: possible must be moved to loot release (in different from linked triggering)
|
||||
if (GetGOInfo()->chest.eventId)
|
||||
{
|
||||
DEBUG_LOG("Chest ScriptStart id %u for GO %u", GetGOInfo()->chest.eventId, GetDBTableGUIDLow());
|
||||
DEBUG_LOG("Chest ScriptStart id %u for GO %u", GetGOInfo()->chest.eventId, GetGUIDLow());
|
||||
|
||||
if (!sScriptMgr.OnProcessEvent(GetGOInfo()->chest.eventId, user, this, true))
|
||||
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
|
||||
|
|
@ -1118,7 +1112,7 @@ void GameObject::Use(Unit* user)
|
|||
|
||||
if (info->goober.eventId)
|
||||
{
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetDBTableGUIDLow());
|
||||
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Goober ScriptStart id %u for GO entry %u (GUID %u).", info->goober.eventId, GetEntry(), GetGUIDLow());
|
||||
|
||||
if (!sScriptMgr.OnProcessEvent(info->goober.eventId, player, this, true))
|
||||
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
|
||||
|
|
@ -1755,3 +1749,8 @@ void GameObject::SpawnInMaps(uint32 db_guid, GameObjectData const* data)
|
|||
SpawnGameObjectInMapsWorker worker(db_guid, data);
|
||||
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
|
||||
}
|
||||
|
||||
bool GameObject::HasStaticDBSpawnData() const
|
||||
{
|
||||
return sObjectMgr.GetGOData(GetGUIDLow()) != NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue