AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
PoolQuestReloadTest.cpp File Reference
#include "ObjectMgr.h"
#include "PoolMgr.h"
#include "QuestDef.h"
#include "gtest/gtest.h"

Go to the source code of this file.

Classes

class  PoolQuestReloadFixTest
 

Functions

 TEST_F (PoolQuestReloadFixTest, ReSpawnPoolQuestsRestoresQuestAfterReload)
 

Function Documentation

◆ TEST_F()

TEST_F ( PoolQuestReloadFixTest  ,
ReSpawnPoolQuestsRestoresQuestAfterReload   
)
270{
271 // 1. Spawn the quest onto the NPC (simulates normal startup)
272 PoolGroup<Quest> poolGroup;
273 PoolObject obj(TEST_QUEST_ID, 0.0f);
274 SpawnedPoolData spawns(nullptr);
275 poolGroup.Spawn1Object(spawns, &obj);
276
277 auto count = [&]() {
278 uint32 n = 0;
279 auto range = creatureQuestMap->equal_range(TEST_CREATURE_ID);
280 for (auto it = range.first; it != range.second; ++it)
281 if (it->second == TEST_QUEST_ID)
282 ++n;
283 return n;
284 };
285
286 ASSERT_EQ(count(), 1u) << "Quest should be on creature before reload";
287
288 // 2. Simulate reload: clear creature quest map and repopulate pool mapping
289 creatureQuestMap->clear();
290 sPoolMgr->mQuestCreatureRelation.clear();
291 sPoolMgr->mQuestCreatureRelation.insert(
292 PooledQuestRelation::value_type(TEST_QUEST_ID, TEST_CREATURE_ID));
293
294 ASSERT_EQ(count(), 0u) << "Quest should be gone after reload clears the map";
295
296 // 3. THE FIX: ReSpawnPoolQuests re-inserts active pool quests
297 sPoolMgr->ReSpawnPoolQuests();
298
299 EXPECT_EQ(count(), 1u)
300 << "ReSpawnPoolQuests should restore active pool quests after reload";
301}
std::uint32_t uint32
Definition Define.h:107
#define sPoolMgr
Definition PoolMgr.h:216
Definition PoolMgr.h:86
void Spawn1Object(SpawnedPoolData &spawns, PoolObject *obj)
Definition PoolMgr.h:52
Definition PoolMgr.h:38

References PoolGroup< T >::Spawn1Object(), and sPoolMgr.