[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,37 +367,41 @@ void PoolGroup<Creature>::Spawn1Object(PoolObject* obj, bool instantly)
{ {
sObjectMgr.AddCreatureToGrid(obj->guid, data); sObjectMgr.AddCreatureToGrid(obj->guid, data);
// Spawn if necessary (loaded grids only) MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
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) // temporary limit pool system full power work to continents
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) if (mapEntry && !mapEntry->Instanceable())
{ {
Creature* pCreature = new Creature; // Spawn if necessary (loaded grids only)
//DEBUG_LOG("Spawning creature %u",obj->guid); Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid));
if (!pCreature->LoadFromDB(obj->guid, map))
// We use spawn coords to spawn
if (map && map->IsLoaded(data->posX, data->posY))
{ {
delete pCreature; Creature* pCreature = new Creature;
return; //DEBUG_LOG("Spawning creature %u",obj->guid);
} if (!pCreature->LoadFromDB(obj->guid, map))
else
{
// if new spawn replaces a just despawned creature, not instantly spawn but set respawn timer
if(!instantly)
{ {
pCreature->SetRespawnTime( pCreature->GetRespawnDelay() ); delete pCreature;
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY) || pCreature->IsWorldBoss()) return;
pCreature->SaveRespawnTime(); }
else
{
// if new spawn replaces a just despawned creature, not instantly spawn but set respawn timer
if(!instantly)
{
pCreature->SetRespawnTime( pCreature->GetRespawnDelay() );
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY) || pCreature->IsWorldBoss())
pCreature->SaveRespawnTime();
}
map->Add(pCreature);
} }
map->Add(pCreature);
} }
} // for not loaded grid just update respawn time (avoid work for instances until implemented support)
// for not loaded grid just update respawn time (avoid work for instances until implemented support) else if(!instantly)
else if(!map->Instanceable() && !instantly) {
{ sObjectMgr.SaveCreatureRespawnTime(obj->guid, 0 /*map->GetInstanceId()*/, time(NULL) + data->spawntimesecs);
sObjectMgr.SaveCreatureRespawnTime(obj->guid,map->GetInstanceId(),time(NULL) + data->spawntimesecs); }
} }
} }
} }
@ -409,44 +413,47 @@ void PoolGroup<GameObject>::Spawn1Object(PoolObject* obj, bool instantly)
if (GameObjectData const* data = sObjectMgr.GetGOData(obj->guid)) if (GameObjectData const* data = sObjectMgr.GetGOData(obj->guid))
{ {
sObjectMgr.AddGameobjectToGrid(obj->guid, data); 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 MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
// (avoid work for instances until implemented support)
if (!map->Instanceable() && map->IsLoaded(data->posX, data->posY)) // temporary limit pool system full power work to continents
if (mapEntry && !mapEntry->Instanceable())
{ {
GameObject* pGameobject = new GameObject; // Spawn if necessary (loaded grids only)
//DEBUG_LOG("Spawning gameobject %u", obj->guid); Map* map = const_cast<Map*>(sMapMgr.FindMap(data->mapid));
if (!pGameobject->LoadFromDB(obj->guid, map))
// We use spawn coords to spawn
if (map && map->IsLoaded(data->posX, data->posY))
{ {
delete pGameobject; GameObject* pGameobject = new GameObject;
return; //DEBUG_LOG("Spawning gameobject %u", obj->guid);
} if (!pGameobject->LoadFromDB(obj->guid, map))
else
{
if (pGameobject->isSpawnedByDefault())
{ {
// if new spawn replaces a just despawned object, not instantly spawn but set respawn timer delete pGameobject;
if(!instantly) return;
}
else
{
if (pGameobject->isSpawnedByDefault())
{ {
pGameobject->SetRespawnTime( pGameobject->GetRespawnDelay() ); // if new spawn replaces a just despawned object, not instantly spawn but set respawn timer
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY)) if(!instantly)
pGameobject->SaveRespawnTime(); {
pGameobject->SetRespawnTime( pGameobject->GetRespawnDelay() );
if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATLY))
pGameobject->SaveRespawnTime();
}
map->Add(pGameobject);
} }
map->Add(pGameobject);
} }
} }
} // for not loaded grid just update respawn time (avoid work for instances until implemented support)
// for not loaded grid just update respawn time (avoid work for instances until implemented support) else if(!instantly)
else if(!map->Instanceable() && !instantly) {
{ // for spawned by default object only
// for spawned by default object only if (data->spawntimesecs >= 0)
if (data->spawntimesecs >= 0) sObjectMgr.SaveGORespawnTime(obj->guid, 0 /*map->GetInstanceId()*/, time(NULL) + data->spawntimesecs);
sObjectMgr.SaveGORespawnTime(obj->guid,map->GetInstanceId(),time(NULL) + data->spawntimesecs); }
} }
} }
} }

View file

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