void PoolGroup<GameObject>::ReSpawn1Object(MapPersistentState& mapState, PoolObject* obj) { if (GameObjectData const* data = sObjectMgr.GetGOData(obj->guid)) { // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) if (Map* dataMap = dataMapState->GetMap()) if (GameObject* pGameobject = dataMap->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, obj->guid))) pGameobject->GetMap()->Add(pGameobject); } }
void PoolGroup<Creature>::ReSpawn1Object(MapPersistentState& mapState, PoolObject* obj) { if (CreatureData const* data = sObjectMgr.GetCreatureData(obj->guid)) { // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) if (Map* dataMap = dataMapState->GetMap()) if (Creature* pCreature = dataMap->GetCreature(data->GetObjectGuid(obj->guid))) pCreature->GetMap()->Add(pCreature); } }
void PoolGroup<GameObject>::Despawn1Object(MapPersistentState& mapState, uint32 guid) { if (GameObjectData const* data = sObjectMgr.GetGOData(guid)) { // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) { dataMapState->RemoveGameobjectFromGrid(guid, data); if (Map* dataMap = dataMapState->GetMap()) if (GameObject* pGameobject = dataMap->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, guid))) pGameobject->AddObjectToRemoveList(); } } }
void PoolGroup<Creature>::Despawn1Object(MapPersistentState& mapState, uint32 guid) { if (CreatureData const* data = sObjectMgr.GetCreatureData(guid)) { // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) { dataMapState->RemoveCreatureFromGrid(guid, data); if (Map* dataMap = dataMapState->GetMap()) if (Creature* pCreature = dataMap->GetCreature(data->GetObjectGuid(guid))) pCreature->AddObjectToRemoveList(); } } }
void PoolGroup<GameObject>::Spawn1Object(MapPersistentState& mapState, PoolObject* obj, bool instantly) { if (GameObjectData const* data = sObjectMgr.GetGOData(obj->guid)) { MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid); // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) { dataMapState->AddGameobjectToGrid(obj->guid, data); Map* dataMap = dataMapState->GetMap(); // We use spawn coords to spawn if (dataMap && dataMap->IsLoaded(data->posX, data->posY)) { GameObject* pGameobject = new GameObject; //DEBUG_LOG("Spawning gameobject %u", obj->guid); if (!pGameobject->LoadFromDB(obj->guid, dataMap)) { delete pGameobject; return; } else { if (pGameobject->isSpawnedByDefault()) { // if new spawn replaces a just despawned object, not instantly spawn but set respawn timer if(!instantly) { pGameobject->SetRespawnTime( pGameobject->GetRespawnDelay() ); if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) pGameobject->SaveRespawnTime(); } dataMap->Add(pGameobject); } } } // for not loaded grid just update respawn time (avoid work for instances until implemented support) else if(!instantly) { // for spawned by default object only if (data->spawntimesecs >= 0) dataMapState->SaveGORespawnTime(obj->guid, time(NULL) + data->spawntimesecs); } } } }
void PoolGroup<Creature>::Spawn1Object(MapPersistentState& mapState, PoolObject* obj, bool instantly) { if (CreatureData const* data = sObjectMgr.GetCreatureData(obj->guid)) { MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid); // for non-instanceable maps pool spawn can be at different map from provided mapState if (MapPersistentState* dataMapState = mapState.GetMapId() == data->mapid ? &mapState : sMapPersistentStateMgr.GetPersistentState(data->mapid, 0)) { dataMapState->AddCreatureToGrid(obj->guid, data); Map* dataMap = dataMapState->GetMap(); // We use spawn coords to spawn if (dataMap && dataMap->IsLoaded(data->posX, data->posY)) { Creature* pCreature = new Creature; //DEBUG_LOG("Spawning creature %u",obj->guid); if (!pCreature->LoadFromDB(obj->guid, dataMap)) { delete pCreature; return; } 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_IMMEDIATELY) || pCreature->IsWorldBoss()) pCreature->SaveRespawnTime(); } dataMap->Add(pCreature); } } // for not loaded grid just update respawn time (avoid work for instances until implemented support) else if(!instantly) { dataMapState->SaveCreatureRespawnTime(obj->guid, time(NULL) + data->spawntimesecs); } } } }