[11310] Make .npc add/.gobject add commands work safe.

Reserve at server startup some guods follow last used in static DB spawns guid
for creatures/gameobjects for use in .npc add/.gobject add commands.
This allow safe select guids not used in all map copies. Guids for temporary spawns
used from range frollow after reserved guids range.

This also let select new static spawns guids (added in game chat command) near to already used static guids.
So it let avoid gaps in static guids lists.

Amount reserved guids set in new GuidReserveSize.* config options.
This commit is contained in:
VladimirMangos 2011-04-03 21:15:24 +04:00
parent c93256e477
commit b92ebd994f
12 changed files with 76 additions and 18 deletions

View file

@ -1086,7 +1086,15 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args)
Map *map = chr->GetMap();
GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT);
// used guids from specially reserved range (can be 0 if no free values)
uint32 db_lowGUID = sObjectMgr.GenerateStaticGameobjectLowGuid();
if (!db_lowGUID)
{
SendSysMessage(LANG_NO_FREE_STATIC_GUID_FOR_SPAWN);
SetSentErrorMessage(true);
return false;
}
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, GO_ANIMPROGRESS_DEFAULT, GO_STATE_READY))
{
@ -1556,7 +1564,16 @@ bool ChatHandler::HandleNpcAddCommand(char* args)
Creature* pCreature = new Creature;
if (!pCreature->Create(map->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, id))
// used guids from specially reserved range (can be 0 if no free values)
uint32 lowguid = sObjectMgr.GenerateStaticCreatureLowGuid();
if (!lowguid)
{
SendSysMessage(LANG_NO_FREE_STATIC_GUID_FOR_SPAWN);
SetSentErrorMessage(true);
return false;
}
if (!pCreature->Create(lowguid, pos, id))
{
delete pCreature;
return false;