mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +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
|
|
@ -123,7 +123,7 @@ Unit(), i_AI(NULL),
|
|||
lootForPickPocketed(false), lootForBody(false), lootForSkin(false), m_groupLootTimer(0), m_groupLootId(0),
|
||||
m_lootMoney(0), m_lootGroupRecipientId(0),
|
||||
m_corpseDecayTimer(0), m_respawnTime(0), m_respawnDelay(25), m_corpseDelay(60), m_respawnradius(5.0f),
|
||||
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0),
|
||||
m_subtype(subtype), m_defaultMovementType(IDLE_MOTION_TYPE), m_equipmentId(0),
|
||||
m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false),
|
||||
m_regenHealth(true), m_AI_locked(false), m_isDeadByDefault(false), m_needNotify(false),
|
||||
m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
|
||||
|
|
@ -461,7 +461,7 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
|||
if(m_originalEntry != GetEntry())
|
||||
{
|
||||
// need preserver gameevent state
|
||||
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetDBTableGUIDLow());
|
||||
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(GetGUIDLow());
|
||||
UpdateEntry(m_originalEntry, TEAM_NONE, NULL, eventData);
|
||||
}
|
||||
|
||||
|
|
@ -496,9 +496,8 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
|||
if (m_corpseDecayTimer <= update_diff)
|
||||
{
|
||||
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
|
||||
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
|
||||
if (poolid)
|
||||
sPoolMgr.UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
|
||||
if (uint16 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetGUIDLow()))
|
||||
sPoolMgr.UpdatePool<Creature>(poolid, GetGUIDLow());
|
||||
|
||||
if (IsInWorld()) // can be despawned by update pool
|
||||
{
|
||||
|
|
@ -527,10 +526,8 @@ void Creature::Update(uint32 update_diff, uint32 diff)
|
|||
if (m_corpseDecayTimer <= update_diff)
|
||||
{
|
||||
// since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless
|
||||
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<Creature>(GetDBTableGUIDLow()) : 0;
|
||||
|
||||
if (poolid)
|
||||
sPoolMgr.UpdatePool<Creature>(poolid, GetDBTableGUIDLow());
|
||||
if (uint16 poolid = sPoolMgr.IsPartOfAPool<Creature>(GetGUIDLow()))
|
||||
sPoolMgr.UpdatePool<Creature>(poolid, GetGUIDLow());
|
||||
|
||||
if (IsInWorld()) // can be despawned by update pool
|
||||
{
|
||||
|
|
@ -1011,7 +1008,7 @@ void Creature::SaveToDB()
|
|||
{
|
||||
// this should only be used when the creature has already been loaded
|
||||
// preferably after adding to map, because mapid may not be valid otherwise
|
||||
CreatureData const *data = sObjectMgr.GetCreatureData(m_DBTableGuid);
|
||||
CreatureData const *data = sObjectMgr.GetCreatureData(GetGUIDLow());
|
||||
if(!data)
|
||||
{
|
||||
sLog.outError("Creature::SaveToDB failed, cannot get creature data!");
|
||||
|
|
@ -1024,9 +1021,7 @@ void Creature::SaveToDB()
|
|||
void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
||||
{
|
||||
// update in loaded data
|
||||
if (!m_DBTableGuid)
|
||||
m_DBTableGuid = GetGUIDLow();
|
||||
CreatureData& data = sObjectMgr.NewOrExistCreatureData(m_DBTableGuid);
|
||||
CreatureData& data = sObjectMgr.NewOrExistCreatureData(GetGUIDLow());
|
||||
|
||||
uint32 displayId = GetNativeDisplayId();
|
||||
|
||||
|
|
@ -1072,11 +1067,11 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
// updated in DB
|
||||
WorldDatabase.BeginTransaction();
|
||||
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", GetGUIDLow());
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << "INSERT INTO creature VALUES ("
|
||||
<< m_DBTableGuid << ","
|
||||
<< GetGUIDLow() << ","
|
||||
<< GetEntry() << ","
|
||||
<< mapid <<","
|
||||
<< uint32(spawnMask) << "," // cast to prevent save as symbol
|
||||
|
|
@ -1240,8 +1235,6 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
|
||||
GameEventCreatureData const* eventData = sGameEventMgr.GetCreatureUpdateDataForActiveEvent(guidlow);
|
||||
|
||||
m_DBTableGuid = guidlow;
|
||||
|
||||
// Creature can be loaded already in map if grid has been unloaded while creature walk to another grid
|
||||
if (map->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, guidlow)))
|
||||
return false;
|
||||
|
|
@ -1263,7 +1256,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
m_isDeadByDefault = data->is_dead;
|
||||
m_deathState = m_isDeadByDefault ? DEAD : ALIVE;
|
||||
|
||||
m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(m_DBTableGuid);
|
||||
m_respawnTime = map->GetPersistentState()->GetCreatureRespawnTime(GetGUIDLow());
|
||||
|
||||
if(m_respawnTime > time(NULL)) // not ready to respawn
|
||||
{
|
||||
|
|
@ -1279,11 +1272,11 @@ bool Creature::LoadFromDB(uint32 guidlow, Map *map)
|
|||
{
|
||||
m_respawnTime = 0;
|
||||
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), 0);
|
||||
}
|
||||
|
||||
uint32 curhealth = data->curhealth;
|
||||
if(curhealth)
|
||||
if (curhealth)
|
||||
{
|
||||
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank));
|
||||
if(curhealth < 1)
|
||||
|
|
@ -1361,24 +1354,24 @@ struct CreatureRespawnDeleteWorker
|
|||
|
||||
void Creature::DeleteFromDB()
|
||||
{
|
||||
if (!m_DBTableGuid)
|
||||
if (!HasStaticDBSpawnData())
|
||||
{
|
||||
DEBUG_LOG("Trying to delete not saved creature!");
|
||||
return;
|
||||
}
|
||||
|
||||
CreatureRespawnDeleteWorker worker (m_DBTableGuid);
|
||||
CreatureRespawnDeleteWorker worker (GetGUIDLow());
|
||||
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker);
|
||||
|
||||
sObjectMgr.DeleteCreatureData(m_DBTableGuid);
|
||||
sObjectMgr.DeleteCreatureData(GetGUIDLow());
|
||||
|
||||
WorldDatabase.BeginTransaction();
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", m_DBTableGuid);
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_addon WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_movement WHERE id=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM game_event_creature_data WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.PExecuteLog("DELETE FROM creature_battleground WHERE guid=%u", GetGUIDLow());
|
||||
WorldDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
|
|
@ -1526,8 +1519,8 @@ void Creature::Respawn()
|
|||
|
||||
if (IsDespawned())
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, 0);
|
||||
if (HasStaticDBSpawnData())
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), 0);
|
||||
m_respawnTime = time(NULL); // respawn at next tick
|
||||
}
|
||||
}
|
||||
|
|
@ -1822,13 +1815,13 @@ bool Creature::CanInitiateAttack()
|
|||
|
||||
void Creature::SaveRespawnTime()
|
||||
{
|
||||
if(IsPet() || !m_DBTableGuid)
|
||||
if(IsPet() || !HasStaticDBSpawnData())
|
||||
return;
|
||||
|
||||
if(m_respawnTime > time(NULL)) // dead (no corpse)
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, m_respawnTime);
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime);
|
||||
else if (m_corpseDecayTimer > 0) // dead (corpse)
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(m_DBTableGuid, time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS);
|
||||
GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS);
|
||||
}
|
||||
|
||||
bool Creature::IsOutOfThreatArea(Unit* pVictim) const
|
||||
|
|
@ -1861,11 +1854,8 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const
|
|||
|
||||
CreatureDataAddon const* Creature::GetCreatureAddon() const
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
{
|
||||
if(CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(m_DBTableGuid))
|
||||
return addon;
|
||||
}
|
||||
if (CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(GetGUIDLow()))
|
||||
return addon;
|
||||
|
||||
// dependent from difficulty mode entry
|
||||
return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry);
|
||||
|
|
@ -2115,20 +2105,17 @@ time_t Creature::GetRespawnTimeEx() const
|
|||
|
||||
void Creature::GetRespawnCoord( float &x, float &y, float &z, float* ori, float* dist ) const
|
||||
{
|
||||
if (m_DBTableGuid)
|
||||
if (CreatureData const* data = sObjectMgr.GetCreatureData(GetGUIDLow()))
|
||||
{
|
||||
if (CreatureData const* data = sObjectMgr.GetCreatureData(GetDBTableGUIDLow()))
|
||||
{
|
||||
x = data->posX;
|
||||
y = data->posY;
|
||||
z = data->posZ;
|
||||
if (ori)
|
||||
*ori = data->orientation;
|
||||
if (dist)
|
||||
*dist = GetRespawnRadius();
|
||||
x = data->posX;
|
||||
y = data->posY;
|
||||
z = data->posZ;
|
||||
if (ori)
|
||||
*ori = data->orientation;
|
||||
if (dist)
|
||||
*dist = GetRespawnRadius();
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
float orient;
|
||||
|
|
@ -2453,3 +2440,7 @@ void Creature::SpawnInMaps(uint32 db_guid, CreatureData const* data)
|
|||
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
|
||||
}
|
||||
|
||||
bool Creature::HasStaticDBSpawnData() const
|
||||
{
|
||||
return sObjectMgr.GetCreatureData(GetGUIDLow()) != NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue