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

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