mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[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:
parent
c93256e477
commit
b92ebd994f
12 changed files with 76 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue