AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
BattlegroundICWorldStatesTest Class Reference
Inheritance diagram for BattlegroundICWorldStatesTest:

Protected Types

using NodeStates = std::array< ICNodeState, MAX_NODE_TYPES >
 
using GateStates = std::array< bool, MAX_FORTRESS_GATES_SPAWNS >
 
using WorldStates = std::map< int32, int32 >
 

Protected Member Functions

void SetUp () override
 
void TearDown () override
 

Static Protected Member Functions

static void SetMatchState (BattlegroundIC &bg, NodeStates const &nodes, GateStates const &gates)
 
static WorldStates ReadSnapshot (BattlegroundIC &bg)
 
static void ExpectSnapshot (BattlegroundIC &bg, WorldStates const &states, NodeStates const &nodes, GateStates const &gates)
 

Protected Attributes

std::unique_ptr< IWorld > _previousWorld
 

Static Protected Attributes

static constexpr NodeStates InitialNodes
 

Detailed Description

Member Typedef Documentation

◆ GateStates

◆ NodeStates

◆ WorldStates

Member Function Documentation

◆ ExpectSnapshot()

static void BattlegroundICWorldStatesTest::ExpectSnapshot ( BattlegroundIC &  bg,
WorldStates const &  states,
NodeStates const &  nodes,
GateStates const &  gates 
)
inlinestaticprotected
78 {
79 auto expectState = [&](uint32 id, int32 expected)
80 {
81 auto itr = states.find(id);
82 ASSERT_NE(itr, states.end()) << "Missing world state " << id;
83 EXPECT_EQ(itr->second, expected) << "World state " << id;
84 };
85
90
91 for (uint8 i = 0; i < MAX_NODE_TYPES; ++i)
92 for (uint8 state = NODE_STATE_UNCONTROLLED; state <= NODE_STATE_CONTROLLED_H; ++state)
93 expectState(nodePointInitial[i].worldStates[state], state == nodes[i]);
94
95 for (uint8 i = 0; i < MAX_FORTRESS_GATES_SPAWNS; ++i)
96 {
98 expectState(bg.GetWorldStateFromGateEntry(entry, false), !gates[i]);
99 expectState(bg.GetWorldStateFromGateEntry(entry, true), gates[i]);
100 }
101 }
@ MAX_NODE_TYPES
Definition BattlegroundIC.h:769
@ MAX_FORTRESS_GATES_SPAWNS
Definition BattlegroundIC.h:457
#define MAX_REINFORCEMENTS
Definition BattlegroundIC.h:191
const ICGo BG_IC_ObjSpawnlocs[MAX_NORMAL_GAMEOBJECTS_SPAWNS]
Definition BattlegroundIC.h:611
const ICNodePoint nodePointInitial[MAX_NODE_TYPES]
Definition BattlegroundIC.h:841
@ NODE_STATE_CONTROLLED_H
Definition BattlegroundIC.h:778
@ NODE_STATE_UNCONTROLLED
Definition BattlegroundIC.h:774
std::int32_t int32
Definition Define.h:103
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
@ WORLD_STATE_BATTLEGROUND_IC_ALLIANCE_REINFORCEMENT
Definition WorldStateDefines.h:251
@ WORLD_STATE_BATTLEGROUND_IC_HORDE_REINFORCEMENT
Definition WorldStateDefines.h:252
@ WORLD_STATE_BATTLEGROUND_IC_ALLIANCE_REINFORCEMENT_SET
Definition WorldStateDefines.h:249
@ WORLD_STATE_BATTLEGROUND_IC_HORDE_REINFORCEMENT_SET
Definition WorldStateDefines.h:250
uint32 GetWorldStateFromGateEntry(uint32 id, bool open)
Definition BattlegroundIC.h:982
uint32 entry
Definition BattlegroundIC.h:571

References BG_IC_ObjSpawnlocs, ICGo::entry, BattlegroundIC::GetWorldStateFromGateEntry(), MAX_FORTRESS_GATES_SPAWNS, MAX_NODE_TYPES, MAX_REINFORCEMENTS, NODE_STATE_CONTROLLED_H, NODE_STATE_UNCONTROLLED, nodePointInitial, WORLD_STATE_BATTLEGROUND_IC_ALLIANCE_REINFORCEMENT, WORLD_STATE_BATTLEGROUND_IC_ALLIANCE_REINFORCEMENT_SET, WORLD_STATE_BATTLEGROUND_IC_HORDE_REINFORCEMENT, and WORLD_STATE_BATTLEGROUND_IC_HORDE_REINFORCEMENT_SET.

◆ ReadSnapshot()

static WorldStates BattlegroundICWorldStatesTest::ReadSnapshot ( BattlegroundIC &  bg)
inlinestaticprotected
63 {
65 bg.FillInitialWorldStates(packet);
66
67 WorldStates states;
68 for (auto const& state : packet.Worldstates)
69 EXPECT_TRUE(states.emplace(state.VariableID, state.Value).second)
70 << "Duplicate world state " << state.VariableID;
71
72 EXPECT_EQ(states.size(), 4u + MAX_FORTRESS_GATES_SPAWNS * 2u + MAX_NODE_TYPES * 5u);
73 return states;
74 }
std::map< int32, int32 > WorldStates
Definition BattlegroundICWorldStatesTest.cpp:34
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
Definition BattlegroundIC.cpp:386
Definition WorldStatePackets.h:28

References BattlegroundIC::FillInitialWorldStates(), MAX_FORTRESS_GATES_SPAWNS, MAX_NODE_TYPES, and WorldPackets::WorldState::InitWorldStates::Worldstates.

◆ SetMatchState()

static void BattlegroundICWorldStatesTest::SetMatchState ( BattlegroundIC &  bg,
NodeStates const &  nodes,
GateStates const &  gates 
)
inlinestaticprotected
53 {
54 for (uint8 i = 0; i < MAX_NODE_TYPES; ++i)
55 bg.nodePoint[i].nodeState = nodes[i];
56
57 for (uint8 i = 0; i < MAX_FORTRESS_GATES_SPAWNS; ++i)
60 }
@ BG_IC_GATE_DESTROYED
Definition BattlegroundIC.h:743
@ BG_IC_GATE_OK
Definition BattlegroundIC.h:741
BG_IC_GateState GateStatus[6]
Definition BattlegroundIC.h:944
uint32 GetGateIDFromEntry(uint32 id)
Definition BattlegroundIC.h:955
ICNodePoint nodePoint[7]
Definition BattlegroundIC.h:945
ICNodeState nodeState
Definition BattlegroundIC.h:838

References BG_IC_GATE_DESTROYED, BG_IC_GATE_OK, BG_IC_ObjSpawnlocs, ICGo::entry, BattlegroundIC::GateStatus, BattlegroundIC::GetGateIDFromEntry(), MAX_FORTRESS_GATES_SPAWNS, MAX_NODE_TYPES, BattlegroundIC::nodePoint, and ICNodePoint::nodeState.

◆ SetUp()

void BattlegroundICWorldStatesTest::SetUp ( )
inlineoverrideprotected
41 {
43 _previousWorld = std::move(sWorld);
44 sWorld = std::make_unique<::testing::NiceMock<WorldMock>>();
45 }
@ ALLBATTLEGROUNDHOOK_END
Definition AllBattlegroundScript.h:47
std::unique_ptr< IWorld > _previousWorld
Definition BattlegroundICWorldStatesTest.cpp:103
static void InitEnabledHooksIfNeeded(uint16 totalAvailableHooks)
Definition ScriptMgr.h:793
#define sWorld
Definition World.h:337

References _previousWorld, ALLBATTLEGROUNDHOOK_END, ScriptRegistry< TScript >::InitEnabledHooksIfNeeded(), and sWorld.

◆ TearDown()

void BattlegroundICWorldStatesTest::TearDown ( )
inlineoverrideprotected
48 {
49 sWorld = std::move(_previousWorld);
50 }

References _previousWorld, and sWorld.

Member Data Documentation

◆ _previousWorld

std::unique_ptr<IWorld> BattlegroundICWorldStatesTest::_previousWorld
protected

Referenced by SetUp(), and TearDown().

◆ InitialNodes


The documentation for this class was generated from the following file: