mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[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.
This commit is contained in:
parent
ae9ae781fc
commit
d482193cea
6 changed files with 32 additions and 15 deletions
|
|
@ -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),
|
i_id(id), i_InstanceId(InstanceId), m_unloadTimer(0),
|
||||||
m_activeNonPlayersIter(m_activeNonPlayers.end()),
|
m_activeNonPlayersIter(m_activeNonPlayers.end()),
|
||||||
i_gridExpiry(expiry), m_parentMap(_parent ? _parent : this),
|
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)
|
for(unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
|
||||||
{
|
{
|
||||||
|
|
@ -3462,4 +3463,25 @@ void Map::SendObjectUpdates()
|
||||||
iter->first->GetSession()->SendPacket(&packet);
|
iter->first->GetSession()->SendPacket(&packet);
|
||||||
packet.clear(); // clean the string
|
packet.clear(); // clean the string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -444,6 +444,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
||||||
{
|
{
|
||||||
i_objectsToClientUpdate.erase( obj );
|
i_objectsToClientUpdate.erase( obj );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DynObjects currently
|
||||||
|
uint32 GenerateLocalLowGuid(HighGuid guidhigh);
|
||||||
private:
|
private:
|
||||||
void LoadMapAndVMap(int gx, int gy);
|
void LoadMapAndVMap(int gx, int gy);
|
||||||
void LoadVMap(int gx, int gy);
|
void LoadVMap(int gx, int gy);
|
||||||
|
|
@ -526,6 +529,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
|
||||||
std::set<WorldObject *> i_objectsToRemove;
|
std::set<WorldObject *> i_objectsToRemove;
|
||||||
std::multimap<time_t, ScriptAction> m_scriptSchedule;
|
std::multimap<time_t, ScriptAction> m_scriptSchedule;
|
||||||
|
|
||||||
|
uint32 m_hiDynObjectGuid; // Map local dynobject low guid counter
|
||||||
|
|
||||||
// Type specific code for add/remove to/from grid
|
// Type specific code for add/remove to/from grid
|
||||||
template<class T>
|
template<class T>
|
||||||
void AddToGrid(T*, NGridType *, Cell const&);
|
void AddToGrid(T*, NGridType *, Cell const&);
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,6 @@ ObjectMgr::ObjectMgr()
|
||||||
m_hiVehicleGuid = 1;
|
m_hiVehicleGuid = 1;
|
||||||
m_hiItemGuid = 1;
|
m_hiItemGuid = 1;
|
||||||
m_hiGoGuid = 1;
|
m_hiGoGuid = 1;
|
||||||
m_hiDoGuid = 1;
|
|
||||||
m_hiCorpseGuid = 1;
|
m_hiCorpseGuid = 1;
|
||||||
m_hiPetNumber = 1;
|
m_hiPetNumber = 1;
|
||||||
m_ItemTextId = 1;
|
m_ItemTextId = 1;
|
||||||
|
|
@ -5714,13 +5713,6 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
|
||||||
World::StopNow(ERROR_EXIT_CODE);
|
World::StopNow(ERROR_EXIT_CODE);
|
||||||
}
|
}
|
||||||
return m_hiCorpseGuid++;
|
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:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
#include "Bag.h"
|
#include "Bag.h"
|
||||||
#include "Creature.h"
|
#include "Creature.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "DynamicObject.h"
|
|
||||||
#include "GameObject.h"
|
#include "GameObject.h"
|
||||||
#include "Corpse.h"
|
#include "Corpse.h"
|
||||||
#include "QuestDef.h"
|
#include "QuestDef.h"
|
||||||
|
|
@ -792,7 +791,6 @@ class ObjectMgr
|
||||||
uint32 m_hiVehicleGuid;
|
uint32 m_hiVehicleGuid;
|
||||||
uint32 m_hiItemGuid;
|
uint32 m_hiItemGuid;
|
||||||
uint32 m_hiGoGuid;
|
uint32 m_hiGoGuid;
|
||||||
uint32 m_hiDoGuid;
|
|
||||||
uint32 m_hiCorpseGuid;
|
uint32 m_hiCorpseGuid;
|
||||||
|
|
||||||
QuestMap mQuestTemplates;
|
QuestMap mQuestTemplates;
|
||||||
|
|
|
||||||
|
|
@ -2872,7 +2872,7 @@ void Spell::EffectPersistentAA(uint32 i)
|
||||||
|
|
||||||
int32 duration = GetSpellDuration(m_spellInfo);
|
int32 duration = GetSpellDuration(m_spellInfo);
|
||||||
DynamicObject* dynObj = new DynamicObject;
|
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;
|
delete dynObj;
|
||||||
return;
|
return;
|
||||||
|
|
@ -3679,7 +3679,7 @@ void Spell::EffectAddFarsight(uint32 i)
|
||||||
DynamicObject* dynObj = new DynamicObject;
|
DynamicObject* dynObj = new DynamicObject;
|
||||||
|
|
||||||
// set radius to 0: spell not expected to work as persistent aura
|
// 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;
|
delete dynObj;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "8704"
|
#define REVISION_NR "8705"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue