mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Make access to ObjectMgr´s creature and gobject respawntime storage threadsafe.
(TODO: Maybe this should be stored on map level instead) Fixes issue #3006 Fixes issue #3071 --HG-- branch : trunk
This commit is contained in:
@@ -7229,7 +7229,12 @@ void ObjectMgr::LoadNPCSpellClickSpells()
|
||||
|
||||
void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
// This function can be Called from various map threads concurrently
|
||||
{
|
||||
ACE_GUARD(ACE_Thread_Mutex, guard, m_CreatureRespawnTimesMtx);
|
||||
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if (t)
|
||||
WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ('%u', '" UI64FMTD "', '%u')", loguid, uint64(t), instance);
|
||||
@@ -7247,7 +7252,12 @@ void ObjectMgr::DeleteCreatureData(uint32 guid)
|
||||
|
||||
void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
{
|
||||
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
// This function can be called from different map threads concurrently
|
||||
{
|
||||
ACE_GUARD(ACE_Thread_Mutex, guard, m_CreatureRespawnTimesMtx);
|
||||
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE guid = '%u' AND instance = '%u'", loguid, instance);
|
||||
if (t)
|
||||
WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ('%u', '" UI64FMTD "', '%u')", loguid, uint64(t), instance);
|
||||
@@ -7255,26 +7265,31 @@ void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
|
||||
|
||||
void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
|
||||
{
|
||||
// This function can be called from different map threads concurrently
|
||||
RespawnTimes::iterator next;
|
||||
|
||||
for (RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
ACE_GUARD(ACE_Thread_Mutex, guard, m_GORespawnTimesMtx);
|
||||
for (RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
|
||||
if (GUID_HIPART(itr->first) == instance)
|
||||
mGORespawnTimes.erase(itr);
|
||||
if (GUID_HIPART(itr->first) == instance)
|
||||
mGORespawnTimes.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
for (RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
ACE_GUARD(ACE_Thread_Mutex, guard, m_CreatureRespawnTimesMtx);
|
||||
for (RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
|
||||
if (GUID_HIPART(itr->first) == instance)
|
||||
mCreatureRespawnTimes.erase(itr);
|
||||
if (GUID_HIPART(itr->first) == instance)
|
||||
mCreatureRespawnTimes.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance);
|
||||
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance);
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,9 @@ class ObjectMgr
|
||||
GossipMenuItemsLocaleMap mGossipMenuItemsLocaleMap;
|
||||
PointOfInterestLocaleMap mPointOfInterestLocaleMap;
|
||||
RespawnTimes mCreatureRespawnTimes;
|
||||
ACE_Thread_Mutex m_CreatureRespawnTimesMtx;
|
||||
RespawnTimes mGORespawnTimes;
|
||||
ACE_Thread_Mutex m_GORespawnTimesMtx;
|
||||
|
||||
CacheNpcTextIdMap m_mCacheNpcTextIdMap;
|
||||
CacheVendorItemMap m_mCacheVendorItemMap;
|
||||
|
||||
Reference in New Issue
Block a user