From d482193ceadb9bd189211e84ff289086244be26d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 22 Oct 2009 06:44:05 +0400 Subject: [PATCH] [8705] Move DynamicObject guid counting from global levle to map. This is first step in guid counting for map local object types at map level. Map local countin let 1) have more wide guid space and then more seldom have problems with guid counter overflow 2) possible implement (later) restart map at guid overflow without server shutdown. 3) let use static guids (not for DynamicOPbject that not stored in DB anyway) in instances instead dynamic allocated. --- src/game/Map.cpp | 26 ++++++++++++++++++++++++-- src/game/Map.h | 5 +++++ src/game/ObjectMgr.cpp | 8 -------- src/game/ObjectMgr.h | 2 -- src/game/SpellEffects.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 6 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 1959fb697..594f151ef 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -202,7 +202,8 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0), m_activeNonPlayersIter(m_activeNonPlayers.end()), i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this), - m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE) + m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), + m_hiDynObjectGuid(1) { for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) { @@ -3462,4 +3463,25 @@ void Map::SendObjectUpdates() iter->first->GetSession()->SendPacket(&packet); packet.clear(); // clean the string } -} \ No newline at end of file +} + +uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh) +{ + // TODO: for map local guid counters possible force reload map instead shutdown server at guid counter overflow + switch(guidhigh) + { + case HIGHGUID_DYNAMICOBJECT: + if (m_hiDynObjectGuid >= 0xFFFFFFFE) + { + sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); + World::StopNow(ERROR_EXIT_CODE); + } + return m_hiDynObjectGuid++; + default: + ASSERT(0); + } + + ASSERT(0); + return 0; +} + diff --git a/src/game/Map.h b/src/game/Map.h index 1a458bda8..88122ba31 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -444,6 +444,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj { i_objectsToClientUpdate.erase( obj ); } + + // DynObjects currently + uint32 GenerateLocalLowGuid(HighGuid guidhigh); private: void LoadMapAndVMap(int gx, int gy); void LoadVMap(int gx, int gy); @@ -526,6 +529,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj std::set i_objectsToRemove; std::multimap m_scriptSchedule; + uint32 m_hiDynObjectGuid; // Map local dynobject low guid counter + // Type specific code for add/remove to/from grid template void AddToGrid(T*, NGridType *, Cell const&); diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index d4a002855..d13b2146c 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -133,7 +133,6 @@ ObjectMgr::ObjectMgr() m_hiVehicleGuid = 1; m_hiItemGuid = 1; m_hiGoGuid = 1; - m_hiDoGuid = 1; m_hiCorpseGuid = 1; m_hiPetNumber = 1; m_ItemTextId = 1; @@ -5714,13 +5713,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh) World::StopNow(ERROR_EXIT_CODE); } return m_hiCorpseGuid++; - case HIGHGUID_DYNAMICOBJECT: - if(m_hiDoGuid>=0xFFFFFFFE) - { - sLog.outError("DynamicObject guid overflow!! Can't continue, shutting down server. "); - World::StopNow(ERROR_EXIT_CODE); - } - return m_hiDoGuid++; default: ASSERT(0); } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index b36394cb1..f34479ca6 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -24,7 +24,6 @@ #include "Bag.h" #include "Creature.h" #include "Player.h" -#include "DynamicObject.h" #include "GameObject.h" #include "Corpse.h" #include "QuestDef.h" @@ -792,7 +791,6 @@ class ObjectMgr uint32 m_hiVehicleGuid; uint32 m_hiItemGuid; uint32 m_hiGoGuid; - uint32 m_hiDoGuid; uint32 m_hiCorpseGuid; QuestMap mQuestTemplates; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 902153aa8..91922cafe 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2872,7 +2872,7 @@ void Spell::EffectPersistentAA(uint32 i) int32 duration = GetSpellDuration(m_spellInfo); DynamicObject* dynObj = new DynamicObject; - if (!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) + if (!dynObj->Create(m_caster->GetMap()->GenerateLocalLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius)) { delete dynObj; return; @@ -3679,7 +3679,7 @@ void Spell::EffectAddFarsight(uint32 i) DynamicObject* dynObj = new DynamicObject; // set radius to 0: spell not expected to work as persistent aura - if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, 0)) + if(!dynObj->Create(m_caster->GetMap()->GenerateLocalLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, 0)) { delete dynObj; return; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 9ffec8043..134c4e000 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8704" + #define REVISION_NR "8705" #endif // __REVISION_NR_H__