[10898] Fix for pool system problems after map rewrite.

This commit is contained in:
VladimirMangos 2010-12-20 23:10:53 +03:00
parent 1d84a8de1d
commit ca095e27a8
2 changed files with 63 additions and 56 deletions

View file

@ -367,13 +367,16 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj, bool instantly)
{
sObjectMgr.AddCreatureToGrid(obj->guid, data);
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
// temporary limit pool system full power work to continents
if (mapEntry && !mapEntry->Instanceable())
{
// Spawn if necessary (loaded grids only)
Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid));
if(!map)
return;
// We use spawn coords to spawn (avoid work for instances until implemented support)
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
// We use spawn coords to spawn
if (map && map->IsLoaded(data->posX, data->posY))
{
Creature* pCreature = new Creature;
//DEBUG_LOG("Spawning creature %u",obj->guid);
@ -395,9 +398,10 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj, bool instantly)
}
}
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
else if(!map->Instanceable() && !instantly)
else if(!instantly)
{
sObjectMgr.SaveCreatureRespawnTime(obj->guid,map->GetInstanceId(),time(NULL) + data->spawntimesecs);
sObjectMgr.SaveCreatureRespawnTime(obj->guid, 0 /*map->GetInstanceId()*/, time(NULL) + data->spawntimesecs);
}
}
}
}
@ -409,15 +413,17 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj, bool instantly)
if (GameObjectData const* data = sObjectMgr.GetGOData(obj->guid))
{
sObjectMgr.AddGameobjectToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existing
Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid));
if(!map)
return;
// We use current coords to unspawn, not spawn coords since creature can have changed grid
// (avoid work for instances until implemented support)
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY))
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
// temporary limit pool system full power work to continents
if (mapEntry && !mapEntry->Instanceable())
{
// Spawn if necessary (loaded grids only)
Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid));
// We use spawn coords to spawn
if (map && map->IsLoaded(data->posX, data->posY))
{
GameObject* pGameobject = new GameObject;
//DEBUG_LOG("Spawning gameobject %u", obj->guid);
@ -442,11 +448,12 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj, bool instantly)
}
}
// for not loaded grid just update respawn time (avoid work for instances until implemented support)
else if(!map->Instanceable() && !instantly)
else if(!instantly)
{
// for spawned by default object only
if (data->spawntimesecs >= 0)
sObjectMgr.SaveGORespawnTime(obj->guid,map->GetInstanceId(),time(NULL) + data->spawntimesecs);
sObjectMgr.SaveGORespawnTime(obj->guid, 0 /*map->GetInstanceId()*/, time(NULL) + data->spawntimesecs);
}
}
}
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10897"
#define REVISION_NR "10898"
#endif // __REVISION_NR_H__