[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:
VladimirMangos 2011-02-14 06:04:06 +03:00
parent 654dac1e11
commit 04c21c95d3
20 changed files with 150 additions and 176 deletions

View file

@ -1456,7 +1456,7 @@ void BattleGround::DoorOpen(ObjectGuid guid)
void BattleGround::OnObjectDBLoad(Creature* creature) void BattleGround::OnObjectDBLoad(Creature* creature)
{ {
const BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(creature->GetDBTableGUIDLow()); const BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow());
if (eventId.event1 == BG_EVENT_NONE) if (eventId.event1 == BG_EVENT_NONE)
return; return;
m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].creatures.push_back(creature->GetObjectGuid()); m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].creatures.push_back(creature->GetObjectGuid());
@ -1474,7 +1474,7 @@ ObjectGuid BattleGround::GetSingleCreatureGuid(uint8 event1, uint8 event2)
void BattleGround::OnObjectDBLoad(GameObject* obj) void BattleGround::OnObjectDBLoad(GameObject* obj)
{ {
const BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(obj->GetDBTableGUIDLow()); const BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(obj->GetGUIDLow());
if (eventId.event1 == BG_EVENT_NONE) if (eventId.event1 == BG_EVENT_NONE)
return; return;
m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].gameobjects.push_back(obj->GetObjectGuid()); m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].gameobjects.push_back(obj->GetObjectGuid());

View file

@ -335,7 +335,7 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* target
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetDBTableGUIDLow())).event1; uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
if (event >= BG_AB_NODES_MAX) // not a node if (event >= BG_AB_NODES_MAX) // not a node
return; return;
BG_AB_Nodes node = BG_AB_Nodes(event); BG_AB_Nodes node = BG_AB_Nodes(event);

View file

@ -51,7 +51,7 @@ void BattleGroundAV::HandleKillUnit(Creature *creature, Player *killer)
DEBUG_LOG("BattleGroundAV: HandleKillUnit %i", creature->GetEntry()); DEBUG_LOG("BattleGroundAV: HandleKillUnit %i", creature->GetEntry());
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
uint8 event1 = (sBattleGroundMgr.GetCreatureEventIndex(creature->GetDBTableGUIDLow())).event1; uint8 event1 = (sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow())).event1;
if (event1 == BG_EVENT_NONE) if (event1 == BG_EVENT_NONE)
return; return;
switch(event1) switch(event1)
@ -514,11 +514,11 @@ void BattleGroundAV::EventPlayerClickedOnFlag(Player *source, GameObject* target
if (GetStatus() != STATUS_IN_PROGRESS) if (GetStatus() != STATUS_IN_PROGRESS)
return; return;
DEBUG_LOG("BattleGroundAV: using gameobject %i", target_obj->GetEntry()); DEBUG_LOG("BattleGroundAV: using gameobject %i", target_obj->GetEntry());
uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetDBTableGUIDLow())).event1; uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
if (event >= BG_AV_NODES_MAX) // not a node if (event >= BG_AV_NODES_MAX) // not a node
return; return;
BG_AV_Nodes node = BG_AV_Nodes(event); BG_AV_Nodes node = BG_AV_Nodes(event);
switch ((sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetDBTableGUIDLow())).event2 % BG_AV_MAX_STATES) switch ((sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event2 % BG_AV_MAX_STATES)
{ {
case POINT_CONTROLLED: case POINT_CONTROLLED:
EventPlayerAssaultsPoint(source, node); EventPlayerAssaultsPoint(source, node);

View file

@ -347,7 +347,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
int32 message_id = 0; int32 message_id = 0;
ChatMsg type; ChatMsg type;
uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetDBTableGUIDLow())).event1; uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
//alliance flag picked up from base //alliance flag picked up from base
if(Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE if(Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE

View file

@ -2703,23 +2703,14 @@ bool ChatHandler::ExtractUint32KeyFromLink(char** text, char const* linkType, ui
return ExtractUInt32(&arg, value); return ExtractUInt32(&arg, value);
} }
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry) GameObject* ChatHandler::GetGameObjectWithGuid(uint32 lowguid,uint32 entry)
{ {
if(!m_session) if (!m_session)
return NULL; return NULL;
Player* pl = m_session->GetPlayer(); Player* pl = m_session->GetPlayer();
GameObject* obj = pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid)); return pl->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, entry, lowguid));
if(!obj && sObjectMgr.GetGOData(lowguid)) // guid is DB guid of object
{
MaNGOS::GameObjectWithDbGUIDCheck go_check(*pl,lowguid);
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(obj,go_check);
Cell::VisitGridObjects(pl,checker, pl->GetMap()->GetVisibilityDistance());
}
return obj;
} }
enum SpellLinkType enum SpellLinkType

View file

@ -615,7 +615,7 @@ class ChatHandler
std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; } std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
std::string GetNameLink(Player* chr) const; std::string GetNameLink(Player* chr) const;
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); GameObject* GetGameObjectWithGuid(uint32 lowguid,uint32 entry);
// Utility methods for commands // Utility methods for commands
bool ShowAccountListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true); bool ShowAccountListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true);

View file

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

View file

@ -405,7 +405,8 @@ class MANGOS_DLL_SPEC Creature : public Unit
void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); void SelectLevel(const CreatureInfo *cinfo, float percentHealth = 100.0f, float percentMana = 100.0f);
void LoadEquipment(uint32 equip_entry, bool force=false); void LoadEquipment(uint32 equip_entry, bool force=false);
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } bool HasStaticDBSpawnData() const; // listed in `creature` table and have fixed in DB guid
char const* GetSubName() const { return GetCreatureInfo()->SubName; } char const* GetSubName() const { return GetCreatureInfo()->SubName; }
void Update(uint32 update_diff, uint32 time); // overwrite Unit::Update void Update(uint32 update_diff, uint32 time); // overwrite Unit::Update
@ -684,7 +685,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
void RegenerateHealth(); void RegenerateHealth();
MovementGeneratorType m_defaultMovementType; MovementGeneratorType m_defaultMovementType;
Cell m_currentCell; // store current cell where creature listed Cell m_currentCell; // store current cell where creature listed
uint32 m_DBTableGuid; ///< For new or temporary creatures is 0 for saved it is lowguid
uint32 m_equipmentId; uint32 m_equipmentId;
bool m_AlreadyCallAssistance; bool m_AlreadyCallAssistance;

View file

@ -56,7 +56,6 @@ GameObject::GameObject() : WorldObject()
m_cooldownTime = 0; m_cooldownTime = 0;
m_goInfo = NULL; m_goInfo = NULL;
m_DBTableGuid = 0;
m_rotation = 0; m_rotation = 0;
} }
@ -424,8 +423,8 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/)
SaveRespawnTime(); SaveRespawnTime();
// if part of pool, let pool system schedule new spawn instead of just scheduling respawn // if part of pool, let pool system schedule new spawn instead of just scheduling respawn
if (uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0) if (uint16 poolid = sPoolMgr.IsPartOfAPool<GameObject>(GetGUIDLow()))
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow()); sPoolMgr.UpdatePool<GameObject>(poolid, GetGUIDLow());
// can be not in world at pool despawn // can be not in world at pool despawn
if (IsInWorld()) if (IsInWorld())
@ -464,9 +463,8 @@ void GameObject::Delete()
SetGoState(GO_STATE_READY); SetGoState(GO_STATE_READY);
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
uint16 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0; if (uint16 poolid = sPoolMgr.IsPartOfAPool<GameObject>(GetGUIDLow()))
if (poolid) sPoolMgr.UpdatePool<GameObject>(poolid, GetGUIDLow());
sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
else else
AddObjectToRemoveList(); AddObjectToRemoveList();
} }
@ -488,7 +486,7 @@ void GameObject::SaveToDB()
{ {
// this should only be used when the gameobject has already been loaded // this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise // 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) if(!data)
{ {
sLog.outError("GameObject::SaveToDB failed, cannot get gameobject 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) if (!goI)
return; return;
if (!m_DBTableGuid)
m_DBTableGuid = GetGUIDLow();
// update in loaded data (changing data only in this place) // 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->guid = guid don't must be update at save
data.id = GetEntry(); data.id = GetEntry();
@ -530,7 +526,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
// updated in DB // updated in DB
std::ostringstream ss; std::ostringstream ss;
ss << "INSERT INTO gameobject VALUES ( " ss << "INSERT INTO gameobject VALUES ( "
<< m_DBTableGuid << ", " << GetGUIDLow() << ", "
<< GetEntry() << ", " << GetEntry() << ", "
<< mapid << ", " << mapid << ", "
<< uint32(spawnMask) << "," // cast to prevent save as symbol << uint32(spawnMask) << "," // cast to prevent save as symbol
@ -548,7 +544,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< uint32(GetGoState()) << ")"; << uint32(GetGoState()) << ")";
WorldDatabase.BeginTransaction(); 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.PExecuteLog("%s", ss.str().c_str());
WorldDatabase.CommitTransaction(); WorldDatabase.CommitTransaction();
} }
@ -579,8 +575,6 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
uint8 animprogress = data->animprogress; uint8 animprogress = data->animprogress;
GOState go_state = data->go_state; 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) ) if (!Create(guid,entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state) )
return false; return false;
@ -598,13 +592,13 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
m_spawnedByDefault = true; m_spawnedByDefault = true;
m_respawnDelayTime = data->spawntimesecs; m_respawnDelayTime = data->spawntimesecs;
m_respawnTime = map->GetPersistentState()->GetGORespawnTime(m_DBTableGuid); m_respawnTime = map->GetPersistentState()->GetGORespawnTime(GetGUIDLow());
// ready to respawn // ready to respawn
if (m_respawnTime && m_respawnTime <= time(NULL)) if (m_respawnTime && m_respawnTime <= time(NULL))
{ {
m_respawnTime = 0; m_respawnTime = 0;
map->GetPersistentState()->SaveGORespawnTime(m_DBTableGuid, 0); map->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), 0);
} }
} }
else else
@ -633,19 +627,19 @@ struct GameObjectRespawnDeleteWorker
void GameObject::DeleteFromDB() void GameObject::DeleteFromDB()
{ {
if (!m_DBTableGuid) if (!HasStaticDBSpawnData())
{ {
DEBUG_LOG("Trying to delete not saved gameobject!"); DEBUG_LOG("Trying to delete not saved gameobject!");
return; return;
} }
GameObjectRespawnDeleteWorker worker(m_DBTableGuid); GameObjectRespawnDeleteWorker worker(GetGUIDLow());
sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker); sMapPersistentStateMgr.DoForAllStatesWithMapId(GetMapId(), worker);
sObjectMgr.DeleteGOData(m_DBTableGuid); sObjectMgr.DeleteGOData(GetGUIDLow());
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", GetGUIDLow());
WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", GetGUIDLow());
WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM gameobject_battleground WHERE guid = '%u'", GetGUIDLow());
} }
GameObjectInfo const *GameObject::GetGOInfo() const GameObjectInfo const *GameObject::GetGOInfo() const
@ -694,7 +688,7 @@ Unit* GameObject::GetOwner() const
void GameObject::SaveRespawnTime() void GameObject::SaveRespawnTime()
{ {
if(m_respawnTime > time(NULL) && m_spawnedByDefault) 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 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) if(m_spawnedByDefault && m_respawnTime > 0)
{ {
m_respawnTime = time(NULL); 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(); UseDoorOrButton();
// activate script // activate script
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this); GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
return; return;
} }
case GAMEOBJECT_TYPE_BUTTON: // 1 case GAMEOBJECT_TYPE_BUTTON: // 1
@ -969,7 +963,7 @@ void GameObject::Use(Unit* user)
UseDoorOrButton(); UseDoorOrButton();
// activate script // activate script
GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this); GetMap()->ScriptsStart(sGameObjectScripts, GetGUIDLow(), spellCaster, this);
TriggerLinkedGameObject(user); TriggerLinkedGameObject(user);
return; return;
@ -997,7 +991,7 @@ void GameObject::Use(Unit* user)
// TODO: possible must be moved to loot release (in different from linked triggering) // TODO: possible must be moved to loot release (in different from linked triggering)
if (GetGOInfo()->chest.eventId) 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)) if (!sScriptMgr.OnProcessEvent(GetGOInfo()->chest.eventId, user, this, true))
GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this); GetMap()->ScriptsStart(sEventScripts, GetGOInfo()->chest.eventId, user, this);
@ -1118,7 +1112,7 @@ void GameObject::Use(Unit* user)
if (info->goober.eventId) 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)) if (!sScriptMgr.OnProcessEvent(info->goober.eventId, player, this, true))
GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this); 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); SpawnGameObjectInMapsWorker worker(db_guid, data);
sMapMgr.DoForAllMapsWithMapId(data->mapid, worker); sMapMgr.DoForAllMapsWithMapId(data->mapid, worker);
} }
bool GameObject::HasStaticDBSpawnData() const
{
return sObjectMgr.GetGOData(GetGUIDLow()) != NULL;
}

View file

@ -603,7 +603,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool IsTransport() const; bool IsTransport() const;
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } bool HasStaticDBSpawnData() const; // listed in `gameobject` table and have fixed in DB guid
void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f); void UpdateRotationFields(float rotation2 = 0.0f, float rotation3 = 0.0f);
@ -739,7 +739,6 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
ObjectGuid m_firstUser; // first GO user, in most used cases owner, but in some cases no, for example non-summoned multi-use GAMEOBJECT_TYPE_SUMMONING_RITUAL ObjectGuid m_firstUser; // first GO user, in most used cases owner, but in some cases no, for example non-summoned multi-use GAMEOBJECT_TYPE_SUMMONING_RITUAL
GuidsSet m_UniqueUsers; // all players who use item, some items activated after specific amount unique uses GuidsSet m_UniqueUsers; // all players who use item, some items activated after specific amount unique uses
uint32 m_DBTableGuid; ///< For new or temporary gameobjects is 0 for saved it is lowguid
GameObjectInfo const* m_goInfo; GameObjectInfo const* m_goInfo;
uint64 m_rotation; uint64 m_rotation;
private: private:

View file

@ -216,7 +216,7 @@ void MaNGOS::RespawnDo::operator()( Creature* u ) const
Map* map = u->GetMap(); Map* map = u->GetMap();
if (map->IsBattleGroundOrArena()) if (map->IsBattleGroundOrArena())
{ {
BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(u->GetDBTableGUIDLow()); BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(u->GetGUIDLow());
if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2)) if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2))
return; return;
} }
@ -230,7 +230,7 @@ void MaNGOS::RespawnDo::operator()( GameObject* u ) const
Map* map = u->GetMap(); Map* map = u->GetMap();
if (map->IsBattleGroundOrArena()) if (map->IsBattleGroundOrArena())
{ {
BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(u->GetDBTableGUIDLow()); BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(u->GetGUIDLow());
if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2)) if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2))
return; return;
} }

View file

@ -749,20 +749,6 @@ namespace MaNGOS
GameObjectEntryInPosRangeCheck(GameObjectEntryInPosRangeCheck const&); GameObjectEntryInPosRangeCheck(GameObjectEntryInPosRangeCheck const&);
}; };
class GameObjectWithDbGUIDCheck
{
public:
GameObjectWithDbGUIDCheck(WorldObject const& obj,uint32 db_guid) : i_obj(obj), i_db_guid(db_guid) {}
WorldObject const& GetFocusObject() const { return i_obj; }
bool operator()(GameObject const* go) const
{
return go->GetDBTableGUIDLow() == i_db_guid;
}
private:
WorldObject const& i_obj;
uint32 i_db_guid;
};
// Unit checks // Unit checks
class MostHPMissingInRangeCheck class MostHPMissingInRangeCheck

View file

@ -73,7 +73,7 @@ HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff
if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE) if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE)
{ {
// such a mob might need very exact spawning point, hence relocate to spawn-position // such a mob might need very exact spawning point, hence relocate to spawn-position
if (CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetDBTableGUIDLow())) if (CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetGUIDLow()))
{ {
owner.Relocate(data->posX, data->posY, data->posZ, data->orientation); owner.Relocate(data->posX, data->posY, data->posZ, data->orientation);
owner.SendHeartBeat(false); owner.SendHeartBeat(false);

View file

@ -877,7 +877,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args)
PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str());
ShowNpcOrGoSpawnInformation<GameObject>(target->GetDBTableGUIDLow()); ShowNpcOrGoSpawnInformation<GameObject>(target->GetGUIDLow());
} }
return true; return true;
} }
@ -897,7 +897,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args)
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); obj = GetGameObjectWithGuid(lowguid,go_data->id);
if (!obj) if (!obj)
{ {
@ -944,7 +944,7 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args)
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); obj = GetGameObjectWithGuid(lowguid,go_data->id);
if (!obj) if (!obj)
{ {
@ -988,7 +988,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args)
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); obj = GetGameObjectWithGuid(lowguid,go_data->id);
if (!obj) if (!obj)
{ {
@ -1133,7 +1133,7 @@ bool ChatHandler::HandleGameObjectPhaseCommand(char* args)
// by DB guid // by DB guid
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); obj = GetGameObjectWithGuid(lowguid,go_data->id);
if (!obj) if (!obj)
{ {
@ -1576,7 +1576,7 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
uint32 db_guid = pCreature->GetDBTableGUIDLow(); uint32 db_guid = pCreature->GetGUIDLow();
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
pCreature->LoadFromDB(db_guid, map); pCreature->LoadFromDB(db_guid, map);
@ -1844,7 +1844,7 @@ bool ChatHandler::HandleNpcMoveCommand(char* args)
pCreature = player->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid)); pCreature = player->GetMap()->GetCreature(ObjectGuid(HIGHGUID_UNIT, data->id, lowguid));
} }
else else
lowguid = pCreature->GetDBTableGUIDLow(); lowguid = pCreature->GetGUIDLow();
float x = m_session->GetPlayer()->GetPositionX(); float x = m_session->GetPlayer()->GetPositionX();
float y = m_session->GetPlayer()->GetPositionY(); float y = m_session->GetPlayer()->GetPositionY();
@ -1853,7 +1853,7 @@ bool ChatHandler::HandleNpcMoveCommand(char* args)
if (pCreature) if (pCreature)
{ {
if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetGUIDLow()))
{ {
const_cast<CreatureData*>(data)->posX = x; const_cast<CreatureData*>(data)->posX = x;
const_cast<CreatureData*>(data)->posY = y; const_cast<CreatureData*>(data)->posY = y;
@ -1903,7 +1903,7 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args)
pCreature = getSelectedCreature(); pCreature = getSelectedCreature();
if (!pCreature || pCreature->IsPet()) if (!pCreature || pCreature->IsPet())
return false; return false;
lowguid = pCreature->GetDBTableGUIDLow(); lowguid = pCreature->GetGUIDLow();
} }
else // case .setmovetype #creature_guid $move_type (with guid) else // case .setmovetype #creature_guid $move_type (with guid)
{ {
@ -2057,7 +2057,7 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args)
uint32 u_guidlow = 0; uint32 u_guidlow = 0;
if (pCreature) if (pCreature)
u_guidlow = pCreature->GetDBTableGUIDLow(); u_guidlow = pCreature->GetGUIDLow();
else else
return false; return false;
@ -2089,7 +2089,7 @@ bool ChatHandler::HandleNpcSpawnTimeCommand(char* args)
return false; return false;
} }
uint32 u_guidlow = pCreature->GetDBTableGUIDLow(); uint32 u_guidlow = pCreature->GetGUIDLow();
WorldDatabase.PExecuteLog("UPDATE creature SET spawntimesecs=%i WHERE guid=%u", stime, u_guidlow); WorldDatabase.PExecuteLog("UPDATE creature SET spawntimesecs=%i WHERE guid=%u", stime, u_guidlow);
pCreature->SetRespawnDelay(stime); pCreature->SetRespawnDelay(stime);
@ -2911,7 +2911,7 @@ bool ChatHandler::HandleWpAddCommand(char* args)
} }
else else
{ {
lowguid = target->GetDBTableGUIDLow(); lowguid = target->GetGUIDLow();
} }
} }
else else
@ -3201,7 +3201,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
{ {
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(), map); wpCreature->LoadFromDB(wpCreature->GetGUIDLow(), map);
map->Add(wpCreature); map->Add(wpCreature);
wpGuid = wpCreature->GetGUIDLow(); wpGuid = wpCreature->GetGUIDLow();
} }
@ -3321,7 +3321,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args)
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); wpCreature2->LoadFromDB(wpCreature2->GetGUIDLow(), map);
map->Add(wpCreature2); map->Add(wpCreature2);
//npcCreature->GetMap()->Add(wpCreature2); //npcCreature->GetMap()->Add(wpCreature2);
} }
@ -3470,7 +3470,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
} }
} }
uint32 lowguid = target->GetDBTableGUIDLow(); uint32 lowguid = target->GetGUIDLow();
std::string show = show_str; std::string show = show_str;
uint32 Maxpoint; uint32 Maxpoint;
@ -3632,7 +3632,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); wpCreature->LoadFromDB(wpCreature->GetGUIDLow(),map);
map->Add(wpCreature); map->Add(wpCreature);
//wpCreature->GetMap()->Add(wpCreature); //wpCreature->GetMap()->Add(wpCreature);
} while (result->NextRow()); } while (result->NextRow());
@ -3684,7 +3684,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
} }
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); pCreature->LoadFromDB(pCreature->GetGUIDLow(), map);
map->Add(pCreature); map->Add(pCreature);
//player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "First Waypoint"); //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "First Waypoint");
@ -3744,7 +3744,7 @@ bool ChatHandler::HandleWpShowCommand(char* args)
} }
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); pCreature->LoadFromDB(pCreature->GetGUIDLow(), map);
map->Add(pCreature); map->Add(pCreature);
//player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "Last Waypoint"); //player->PlayerTalkClass->SendPointOfInterest(x, y, 6, 6, 0, "Last Waypoint");
// Cleanup memory // Cleanup memory

View file

@ -4090,7 +4090,7 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/)
std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true);
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true);
PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); PSendSysMessage(LANG_NPCINFO_CHAR, target->GetGUIDLow(), faction, npcflags, Entry, displayid, nativeid);
PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction());
@ -4108,7 +4108,7 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/)
SendSysMessage(LANG_NPCINFO_TRAINER); SendSysMessage(LANG_NPCINFO_TRAINER);
} }
ShowNpcOrGoSpawnInformation<Creature>(target->GetDBTableGUIDLow()); ShowNpcOrGoSpawnInformation<Creature>(target->GetGUIDLow());
return true; return true;
} }

View file

@ -1183,7 +1183,7 @@ void Map::AddToActive( WorldObject* obj )
{ {
Creature* c= (Creature*)obj; Creature* c= (Creature*)obj;
if (!c->IsPet() && c->GetDBTableGUIDLow()) if (!c->IsPet() && c->HasStaticDBSpawnData())
{ {
float x,y,z; float x,y,z;
c->GetRespawnCoord(x,y,z); c->GetRespawnCoord(x,y,z);
@ -1218,7 +1218,7 @@ void Map::RemoveFromActive( WorldObject* obj )
{ {
Creature* c= (Creature*)obj; Creature* c= (Creature*)obj;
if(!c->IsPet() && c->GetDBTableGUIDLow()) if(!c->IsPet() && c->HasStaticDBSpawnData())
{ {
float x,y,z; float x,y,z;
c->GetRespawnCoord(x,y,z); c->GetRespawnCoord(x,y,z);
@ -2140,11 +2140,8 @@ void Map::ScriptsProcess()
} }
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
{ {
if (!step.script->respawnGo.goGuid) // gameobject not specified if (!step.script->respawnGo.goGuid) // checked at load
{
sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (script id %u) call for NULL gameobject.", step.script->id);
break; break;
}
if (!source) if (!source)
{ {
@ -2159,17 +2156,23 @@ void Map::ScriptsProcess()
} }
WorldObject* summoner = (WorldObject*)source; WorldObject* summoner = (WorldObject*)source;
if (!summoner->IsInWorld())
{
sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (script id %u) call for non-in-world WorldObject (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
break;
}
GameObject *go = NULL;
int32 time_to_despawn = step.script->respawnGo.despawnDelay < 5 ? 5 : step.script->respawnGo.despawnDelay; int32 time_to_despawn = step.script->respawnGo.despawnDelay < 5 ? 5 : step.script->respawnGo.despawnDelay;
MaNGOS::GameObjectWithDbGUIDCheck go_check(*summoner, step.script->respawnGo.goGuid); uint32 guidlow = step.script->respawnGo.goGuid;
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(go, go_check); GameObjectData const* goData = sObjectMgr.GetGOData(guidlow);
Cell::VisitGridObjects(summoner, checker, GetVisibilityDistance()); if (!goData)
break; // checked at load
GameObject *go = summoner->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, goData->id, guidlow));
if (!go) if (!go)
{ {
sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (script id %u) failed for gameobject(guid: %u).", step.script->id, step.script->respawnGo.goGuid); sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT (script id %u) failed for gameobject(guid: %u).", step.script->id, guidlow);
break; break;
} }
@ -2229,11 +2232,8 @@ void Map::ScriptsProcess()
} }
case SCRIPT_COMMAND_OPEN_DOOR: case SCRIPT_COMMAND_OPEN_DOOR:
{ {
if (!step.script->openDoor.goGuid) // door not specified if (!step.script->openDoor.goGuid) // checked at load
{
sLog.outError("SCRIPT_COMMAND_OPEN_DOOR (script id %u) call for NULL door.", step.script->id);
break; break;
}
if (!source) if (!source)
{ {
@ -2248,14 +2248,20 @@ void Map::ScriptsProcess()
} }
Unit* caster = (Unit*)source; Unit* caster = (Unit*)source;
if (!caster->IsInWorld())
{
sLog.outError("SCRIPT_COMMAND_OPEN_DOOR (script id %u) call for non-in-world unit (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
break;
}
GameObject *door = NULL;
int32 time_to_close = step.script->openDoor.resetDelay < 15 ? 15 : step.script->openDoor.resetDelay; int32 time_to_close = step.script->openDoor.resetDelay < 15 ? 15 : step.script->openDoor.resetDelay;
MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster, step.script->openDoor.goGuid); uint32 guidlow = step.script->openDoor.goGuid;
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(door, go_check); GameObjectData const* goData = sObjectMgr.GetGOData(guidlow);
Cell::VisitGridObjects(caster, checker, GetVisibilityDistance()); if (!goData) // checked at load
break;
GameObject *door = caster->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, goData->id, guidlow));
if (!door) if (!door)
{ {
sLog.outError("SCRIPT_COMMAND_OPEN_DOOR (script id %u) failed for gameobject(guid: %u).", step.script->id, step.script->openDoor.goGuid); sLog.outError("SCRIPT_COMMAND_OPEN_DOOR (script id %u) failed for gameobject(guid: %u).", step.script->id, step.script->openDoor.goGuid);
@ -2280,11 +2286,8 @@ void Map::ScriptsProcess()
} }
case SCRIPT_COMMAND_CLOSE_DOOR: case SCRIPT_COMMAND_CLOSE_DOOR:
{ {
if (!step.script->closeDoor.goGuid) // guid for door not specified if (!step.script->closeDoor.goGuid) // checked at load
{
sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR (script id %u) call for NULL door.", step.script->id);
break; break;
}
if (!source) if (!source)
{ {
@ -2299,17 +2302,23 @@ void Map::ScriptsProcess()
} }
Unit* caster = (Unit*)source; Unit* caster = (Unit*)source;
if (!caster->IsInWorld())
{
sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR (script id %u) call for non-in-world unit (TypeId: %u), skipping.", step.script->id, source->GetTypeId());
break;
}
GameObject *door = NULL;
int32 time_to_open = step.script->closeDoor.resetDelay < 15 ? 15 : step.script->closeDoor.resetDelay; int32 time_to_open = step.script->closeDoor.resetDelay < 15 ? 15 : step.script->closeDoor.resetDelay;
MaNGOS::GameObjectWithDbGUIDCheck go_check(*caster, step.script->closeDoor.goGuid); uint32 guidlow = step.script->closeDoor.goGuid;
MaNGOS::GameObjectSearcher<MaNGOS::GameObjectWithDbGUIDCheck> checker(door, go_check); GameObjectData const* goData = sObjectMgr.GetGOData(guidlow);
Cell::VisitGridObjects(caster, checker, GetVisibilityDistance()); if (!goData) // checked at load
break;
GameObject *door = caster->GetMap()->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, goData->id, guidlow));
if (!door) if (!door)
{ {
sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR (script id %u) failed for gameobject(guid: %u).", step.script->id, step.script->closeDoor.goGuid); sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR (script id %u) failed for gameobject(guid: %u).", step.script->id, guidlow);
break; break;
} }
if (door->GetGoType() != GAMEOBJECT_TYPE_DOOR) if (door->GetGoType() != GAMEOBJECT_TYPE_DOOR)

View file

@ -1931,7 +1931,6 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3
Object::_Create(guidlow, pet_number, HIGHGUID_PET); Object::_Create(guidlow, pet_number, HIGHGUID_PET);
m_DBTableGuid = guidlow;
m_originalEntry = Entry; m_originalEntry = Entry;
if(!InitEntry(Entry)) if(!InitEntry(Entry))

View file

@ -13147,10 +13147,10 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
uint32 Player::GetGossipTextId(WorldObject *pSource) uint32 Player::GetGossipTextId(WorldObject *pSource)
{ {
if (!pSource || pSource->GetTypeId() != TYPEID_UNIT || !((Creature*)pSource)->GetDBTableGUIDLow()) if (!pSource || pSource->GetTypeId() != TYPEID_UNIT)
return DEFAULT_GOSSIP_MESSAGE; return DEFAULT_GOSSIP_MESSAGE;
if (uint32 pos = sObjectMgr.GetNpcGossip(((Creature*)pSource)->GetDBTableGUIDLow())) if (uint32 pos = sObjectMgr.GetNpcGossip(((Creature*)pSource)->GetGUIDLow()))
return pos; return pos;
return DEFAULT_GOSSIP_MESSAGE; return DEFAULT_GOSSIP_MESSAGE;

View file

@ -46,9 +46,9 @@ alter table creature_movement add `wpguid` int(11) default '0';
//-----------------------------------------------// //-----------------------------------------------//
void WaypointMovementGenerator<Creature>::LoadPath(Creature &creature) void WaypointMovementGenerator<Creature>::LoadPath(Creature &creature)
{ {
DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for creature %u, %u", creature.GetGUIDLow(), creature.GetDBTableGUIDLow()); DETAIL_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "LoadPath: loading waypoint path for %s", creature.GetGuidStr().c_str());
i_path = sWaypointMgr.GetPath(creature.GetDBTableGUIDLow()); i_path = sWaypointMgr.GetPath(creature.GetGUIDLow());
// We may LoadPath() for several occasions: // We may LoadPath() for several occasions:
@ -70,7 +70,7 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature &creature)
if (!i_path) if (!i_path)
{ {
sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path", sLog.outErrorDb("WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path",
creature.GetName(), creature.GetEntry(), creature.GetDBTableGUIDLow()); creature.GetName(), creature.GetEntry(), creature.GetGUIDLow());
return; return;
} }
} }
@ -186,7 +186,7 @@ bool WaypointMovementGenerator<Creature>::Update(Creature &creature, const uint3
if (i_path->at(i_currentNode).script_id) if (i_path->at(i_currentNode).script_id)
{ {
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature movement start script %u at point %u for creature %u (entry %u).", i_path->at(i_currentNode).script_id, i_currentNode, creature.GetDBTableGUIDLow(), creature.GetEntry()); DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature movement start script %u at point %u for %s.", i_path->at(i_currentNode).script_id, i_currentNode, creature.GetGuidStr().c_str());
creature.GetMap()->ScriptsStart(sCreatureMovementScripts, i_path->at(i_currentNode).script_id, &creature, &creature); creature.GetMap()->ScriptsStart(sCreatureMovementScripts, i_path->at(i_currentNode).script_id, &creature, &creature);
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11158" #define REVISION_NR "11159"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__