[Sync] Some minor project sync

This commit is contained in:
Antz 2017-01-09 21:35:12 +00:00 committed by Antz
parent 7332173b6e
commit 461923f632
35 changed files with 3690 additions and 1585 deletions

View file

@ -130,7 +130,7 @@ class Grid
*/
bool AddGridObject(SPECIFIC_OBJECT* obj)
{
if (obj->isActiveObject())
if (obj->IsActiveObject())
{ m_activeGridObjects.insert(obj); }
return i_container.template insert<SPECIFIC_OBJECT>(obj);
@ -145,7 +145,7 @@ class Grid
*/
bool RemoveGridObject(SPECIFIC_OBJECT* obj)
{
if (obj->isActiveObject())
if (obj->IsActiveObject())
{ m_activeGridObjects.erase(obj); }
return i_container.template remove<SPECIFIC_OBJECT>(obj);

View file

@ -64,20 +64,9 @@ typedef ACE_SHLIB_HANDLE MANGOS_LIBRARY_HANDLE;
# define MANGOS_EXPORT __declspec(dllexport)
# define MANGOS_IMPORT __cdecl
#else // PLATFORM != PLATFORM_WINDOWS
# include <dlfcn.h>
typedef void* MANGOS_LIBRARY_HANDLE;
# define MANGOS_LOAD_LIBRARY(libname) dlopen(libname, RTLD_LAZY)
# define MANGOS_CLOSE_LIBRARY(hlib) dlclose(hlib)
# define MANGOS_GET_PROC_ADDR(hlib, name) dlsym(hlib, name)
# define MANGOS_EXPORT export
# if PLATFORM == PLATFORM_APPLE
# define MANGOS_SCRIPT_SUFFIX ".dylib"
# else
# define MANGOS_SCRIPT_SUFFIX ".so"
# endif
# define MANGOS_SCRIPT_PREFIX "lib"
# if defined(__APPLE_CC__) && defined(BIG_ENDIAN) // TODO:: more work to do with byte order. Have to be rechecked after boost integration.
# if (defined (__ppc__) || defined (__powerpc__))
# if defined(__APPLE_CC__) && defined(BIG_ENDIAN)
# if (defined(__ppc__) || defined(__powerpc__))
# define MANGOS_IMPORT __attribute__ ((longcall))
# else
# define MANGOS_IMPORT

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -35,6 +35,9 @@
#include "MapManager.h"
#include "DBCStores.h" // TODO REMOVE this when graveyard handling for pvp is updated
/// <summary>
/// Initializes a new instance of the <see cref="BattleGroundAB"/> class.
/// </summary>
BattleGroundAB::BattleGroundAB()
{
m_StartMessageIds[BG_STARTING_EVENT_FIRST] = 0;
@ -43,10 +46,17 @@ BattleGroundAB::BattleGroundAB()
m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_AB_HAS_BEGUN;
}
/// <summary>
/// Finalizes an instance of the <see cref="BattleGroundAB"/> class.
/// </summary>
BattleGroundAB::~BattleGroundAB()
{
}
/// <summary>
/// Updates the specified diff.
/// </summary>
/// <param name="diff">The diff.</param>
void BattleGroundAB::Update(uint32 diff)
{
BattleGround::Update(diff);
@ -61,7 +71,7 @@ void BattleGroundAB::Update(uint32 diff)
if (m_BannerTimers[node].timer)
{
if (m_BannerTimers[node].timer > diff)
m_BannerTimers[node].timer -= diff;
{ m_BannerTimers[node].timer -= diff; }
else
{
m_BannerTimers[node].timer = 0;
@ -73,7 +83,7 @@ void BattleGroundAB::Update(uint32 diff)
if (m_NodeTimers[node])
{
if (m_NodeTimers[node] > diff)
m_NodeTimers[node] -= diff;
{ m_NodeTimers[node] -= diff; }
else
{
m_NodeTimers[node] = 0;
@ -102,7 +112,7 @@ void BattleGroundAB::Update(uint32 diff)
for (uint8 team = 0; team < PVP_TEAM_COUNT; ++team)
if (m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED)
++team_points[team];
{ ++team_points[team]; }
}
// Accumulate points
@ -110,7 +120,7 @@ void BattleGroundAB::Update(uint32 diff)
{
int points = team_points[team];
if (!points)
continue;
{ continue; }
m_lastTick[team] += diff;
if (m_lastTick[team] > BG_AB_TickIntervals[points])
{
@ -131,19 +141,19 @@ void BattleGroundAB::Update(uint32 diff)
if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE)
{
if (team == TEAM_INDEX_ALLIANCE)
SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
{ SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); }
else
SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
{ SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); }
PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY);
m_IsInformedNearVictory = true;
}
if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE)
m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE;
{ m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; }
if (team == TEAM_INDEX_ALLIANCE)
UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]);
{ UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); }
if (team == TEAM_INDEX_HORDE)
UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]);
{ UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); }
// update achievement flags
// we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources
@ -156,12 +166,15 @@ void BattleGroundAB::Update(uint32 diff)
// Test win condition
if (m_TeamScores[TEAM_INDEX_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
EndBattleGround(ALLIANCE);
{ EndBattleGround(ALLIANCE); }
if (m_TeamScores[TEAM_INDEX_HORDE] >= BG_AB_MAX_TEAM_SCORE)
EndBattleGround(HORDE);
{ EndBattleGround(HORDE); }
}
}
/// <summary>
/// Startings the event open doors.
/// </summary>
void BattleGroundAB::StartingEventOpenDoors()
{
OpenDoorEvent(BG_EVENT_DOOR);
@ -170,6 +183,10 @@ void BattleGroundAB::StartingEventOpenDoors()
StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, AB_EVENT_START_BATTLE);
}
/// <summary>
/// Adds the player.
/// </summary>
/// <param name="plr">The PLR.</param>
void BattleGroundAB::AddPlayer(Player* plr)
{
BattleGround::AddPlayer(plr);
@ -179,25 +196,35 @@ void BattleGroundAB::AddPlayer(Player* plr)
m_PlayerScores[plr->GetObjectGuid()] = sc;
}
/// <summary>
/// Removes the player.
/// </summary>
/// <param name="">The .</param>
/// <param name="">The .</param>
void BattleGroundAB::RemovePlayer(Player * /*plr*/, ObjectGuid /*guid*/)
{
}
/// <summary>
/// Handles the area trigger.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="trigger">The trigger.</param>
bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
{
switch (trigger)
{
case 3948: // Arathi Basin Alliance Exit.
if (source->GetTeam() != ALLIANCE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE);
{ source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); }
else
source->LeaveBattleground();
{ source->LeaveBattleground(); }
break;
case 3949: // Arathi Basin Horde Exit.
if (source->GetTeam() != HORDE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE);
{ source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); }
else
source->LeaveBattleground();
{ source->LeaveBattleground(); }
break;
default:
return false;
@ -205,8 +232,13 @@ bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger)
return true;
}
/* type: 0-neutral, 1-contested, 3-occupied
teamIndex: 0-ally, 1-horde */
/// <summary>
/// Creates the banner.
/// </summary>
/// <param name="node">The node.</param>
/// <param name="type">The type. 0-neutral, 1-contested, 3-occupied</param>
/// <param name="teamIndex">Index of the team. 0-ally, 1-horde</param>
/// <param name="delay">The delay.</param>
void BattleGroundAB::_CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay)
{
// Just put it into the queue
@ -221,11 +253,16 @@ void BattleGroundAB::_CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool
// cause the node-type is in the generic form
// please see in the headerfile for the ids
if (type != BG_AB_NODE_TYPE_NEUTRAL)
type += teamIndex;
{ type += teamIndex; }
SpawnEvent(node, type, true); // will automaticly despawn other events
}
/// <summary>
/// _s the get node name id.
/// </summary>
/// <param name="node">The node.</param>
/// <returns></returns>
int32 BattleGroundAB::_GetNodeNameId(uint8 node)
{
switch (node)
@ -241,26 +278,31 @@ int32 BattleGroundAB::_GetNodeNameId(uint8 node)
return 0;
}
/// <summary>
/// Fills the initial world states.
/// </summary>
/// <param name="data">The data.</param>
/// <param name="count">The count.</param>
void BattleGroundAB::FillInitialWorldStates(WorldPacket& data, uint32& count)
{
const uint8 plusArray[] = {0, 2, 3, 0, 1};
// Node icons
for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node)
FillInitialWorldState(data, count, BG_AB_OP_NODEICONS[node], m_Nodes[node] == 0);
{ FillInitialWorldState(data, count, BG_AB_OP_NODEICONS[node], m_Nodes[node] == 0); }
// Node occupied states
for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node)
for (uint8 i = 1; i < BG_AB_NODES_MAX; ++i)
FillInitialWorldState(data, count, BG_AB_OP_NODESTATES[node] + plusArray[i], m_Nodes[node] == i);
{ FillInitialWorldState(data, count, BG_AB_OP_NODESTATES[node] + plusArray[i], m_Nodes[node] == i); }
// How many bases each team owns
uint8 ally = 0, horde = 0;
for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node)
if (m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_OCCUPIED)
++ally;
{ ++ally; }
else if (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
++horde;
{ ++horde; }
FillInitialWorldState(data, count, BG_AB_OP_OCCUPIED_BASES_ALLY, ally);
FillInitialWorldState(data, count, BG_AB_OP_OCCUPIED_BASES_HORDE, horde);
@ -275,15 +317,19 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data, uint32& count)
FillInitialWorldState(data, count, 0x745, 0x2); // 37 1861 unk
}
/// <summary>
/// _s the send node update.
/// </summary>
/// <param name="node">The node.</param>
void BattleGroundAB::_SendNodeUpdate(uint8 node)
{
// Send node owner state update to refresh map icons on client
const uint8 plusArray[] = {0, 2, 3, 0, 1};
if (m_prevNodes[node])
UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], WORLD_STATE_REMOVE);
{ UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], WORLD_STATE_REMOVE); }
else
UpdateWorldState(BG_AB_OP_NODEICONS[node], WORLD_STATE_REMOVE);
{ UpdateWorldState(BG_AB_OP_NODEICONS[node], WORLD_STATE_REMOVE); }
UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_Nodes[node]], WORLD_STATE_ADD);
@ -291,44 +337,54 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node)
uint8 ally = 0, horde = 0;
for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i)
if (m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED)
++ally;
{ ++ally; }
else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
++horde;
{ ++horde; }
UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_ALLY, ally);
UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_HORDE, horde);
}
/// <summary>
/// _s the node occupied.
/// </summary>
/// <param name="node">The node.</param>
/// <param name="team">The team.</param>
void BattleGroundAB::_NodeOccupied(uint8 node, Team team)
{
uint8 capturedNodes = 0;
for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i)
{
if (m_Nodes[node] == GetTeamIndexByTeamId(team) + BG_AB_NODE_TYPE_OCCUPIED && !m_NodeTimers[i])
++capturedNodes;
{ ++capturedNodes; }
}
if (capturedNodes >= 5)
CastSpellOnTeam(SPELL_AB_QUEST_REWARD_5_BASES, team);
{ CastSpellOnTeam(SPELL_AB_QUEST_REWARD_5_BASES, team); }
if (capturedNodes >= 4)
CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team);
{ CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team); }
}
/* Invoked if a player used a banner as a gameobject */
/// <summary>
/// Events the player clicked on flag.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="target_obj">The target_obj.</param>
void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
if (event >= BG_AB_NODES_MAX) // not a node
return;
{ return; }
BG_AB_Nodes node = BG_AB_Nodes(event);
PvpTeamIndex teamIndex = GetTeamIndexByTeamId(source->GetTeam());
// Check if player really could use this banner, not cheated
if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node] % 2))
return;
{ return; }
source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
uint32 sound = 0;
@ -347,9 +403,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target
m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
if (teamIndex == 0)
SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_ALLY);
{ SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_ALLY); }
else
SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE);
{ SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE); }
sound = BG_AB_SOUND_NODE_CLAIMED;
}
@ -368,9 +424,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target
m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
if (teamIndex == TEAM_INDEX_ALLIANCE)
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); }
else
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); }
}
// If contested, change back to occupied
else
@ -385,9 +441,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target
_NodeOccupied(node, (teamIndex == TEAM_INDEX_ALLIANCE) ? ALLIANCE : HORDE);
if (teamIndex == TEAM_INDEX_ALLIANCE)
SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); }
else
SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); }
}
sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
}
@ -403,9 +459,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target
m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
if (teamIndex == TEAM_INDEX_ALLIANCE)
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); }
else
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); }
sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
}
@ -414,13 +470,16 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target
if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED)
{
if (teamIndex == TEAM_INDEX_ALLIANCE)
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node)); }
else
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node));
{ SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); }
}
PlaySoundToAll(sound);
}
/// <summary>
/// Resets this instance.
/// </summary>
void BattleGroundAB::Reset()
{
// call parent's class reset
@ -452,6 +511,10 @@ void BattleGroundAB::Reset()
}
}
/// <summary>
/// Ends the battle ground.
/// </summary>
/// <param name="winner">The winner.</param>
void BattleGroundAB::EndBattleGround(Team winner)
{
// win reward
@ -466,6 +529,11 @@ void BattleGroundAB::EndBattleGround(Team winner)
BattleGround::EndBattleGround(winner);
}
/// <summary>
/// Gets the closest grave yard.
/// </summary>
/// <param name="player">The player.</param>
/// <returns></returns>
WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
{
PvpTeamIndex teamIndex = GetTeamIndexByTeamId(player->GetTeam());
@ -474,7 +542,7 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
std::vector<uint8> nodes;
for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i)
if (m_Nodes[i] == teamIndex + 3)
nodes.push_back(i);
{ nodes.push_back(i); }
WorldSafeLocsEntry const* good_entry = NULL;
// If so, select the closest node to place ghost on
@ -488,7 +556,7 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
{
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[nodes[i]]);
if (!entry)
continue;
{ continue; }
float dist = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y);
if (mindist > dist)
{
@ -500,16 +568,22 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
}
// If not, place ghost on starting location
if (!good_entry)
good_entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[teamIndex + 5]);
{ good_entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[teamIndex + 5]); }
return good_entry;
}
/// <summary>
/// Updates the player score.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="type">The type.</param>
/// <param name="value">The value.</param>
void BattleGroundAB::UpdatePlayerScore(Player* source, uint32 type, uint32 value)
{
BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid());
if (itr == m_PlayerScores.end()) // player not found...
return;
{ return; }
switch (type)
{
@ -535,17 +609,20 @@ bool BattleGroundAB::IsAllNodesControlledByTeam(Team team) const
return true;
}
/// <summary>
/// Gets the premature finish winning team.
/// </summary>
Team BattleGroundAB::GetPrematureWinner()
{
int32 hordeScore = m_TeamScores[TEAM_INDEX_HORDE];
int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
if (hordeScore > allianceScore)
return HORDE;
{ return HORDE; }
if (allianceScore > hordeScore)
return ALLIANCE;
{ return ALLIANCE; }
// If the values are equal, fall back to number of players on each team
return BattleGround::GetPrematureWinner();
}

View file

@ -21,12 +21,17 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef __BATTLEGROUNDAB_H
#define __BATTLEGROUNDAB_H
#ifndef MANGOS_H_BATTLEGROUNDAB
#define MANGOS_H_BATTLEGROUNDAB
#include "Common.h"
#include "BattleGround.h"
/**
* @brief
*
*/
enum BG_AB_WorldStates
{
BG_AB_OP_OCCUPIED_BASES_HORDE = 1778,
@ -65,19 +70,27 @@ enum BG_AB_WorldStates
*/
};
const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787};
const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787}; /**< TODO */
const uint32 BG_AB_OP_NODEICONS[5] = {1842, 1846, 1845, 1844, 1843};
const uint32 BG_AB_OP_NODEICONS[5] = {1842, 1846, 1845, 1844, 1843}; /**< TODO */
/* node events */
// node-events are just event1=BG_AB_Nodes, event2=BG_AB_NodeStatus
// so we don't need to define the constants here :)
/**
* @brief
*
*/
enum BG_AB_Timers
{
BG_AB_FLAG_CAPTURING_TIME = 60000,
BG_AB_FLAG_CAPTURING_TIME = 60000
};
/**
* @brief
*
*/
enum BG_AB_Score
{
BG_AB_WARNING_NEAR_VICTORY_SCORE = 1400,
@ -85,6 +98,10 @@ enum BG_AB_Score
};
/* do NOT change the order, else wrong behaviour */
/**
* @brief
*
*/
enum BG_AB_Nodes
{
BG_AB_NODE_STABLES = 0,
@ -97,6 +114,10 @@ enum BG_AB_Nodes
#define BG_AB_NODES_MAX 5
/**
* @brief
*
*/
enum BG_AB_NodeStatus
{
BG_AB_NODE_TYPE_NEUTRAL = 0,
@ -108,6 +129,10 @@ enum BG_AB_NodeStatus
BG_AB_NODE_STATUS_HORDE_OCCUPIED = 4
};
/**
* @brief
*
*/
enum BG_AB_Sounds
{
BG_AB_SOUND_NODE_CLAIMED = 8192,
@ -125,14 +150,14 @@ enum BG_AB_Sounds
#define AB_EVENT_START_BATTLE 9158
// Tick intervals and given points: case 0,1,2,3,4,5 captured nodes
const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000};
const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30};
const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000}; /**< TODO */
const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30}; /**< TODO */
// WorldSafeLocs ids for 5 nodes, and for ally, and horde starting location
const uint32 BG_AB_GraveyardIds[7] = {895, 894, 893, 897, 896, 898, 899};
const uint32 BG_AB_GraveyardIds[7] = {895, 894, 893, 897, 896, 898, 899}; /**< TODO */
// x, y, z, o
const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] =
const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] = /**< TODO */
{
{1185.71f, 1185.24f, -56.36f, 2.56f}, // stables
{990.75f, 1008.18f, -42.60f, 2.43f}, // blacksmith
@ -141,66 +166,185 @@ const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] =
{1146.62f, 816.94f, -98.49f, 6.14f} // gold mine
};
/**
* @brief
*
*/
struct BG_AB_BannerTimer
{
uint32 timer;
uint8 type;
uint8 teamIndex;
uint32 timer; /**< TODO */
uint8 type; /**< TODO */
uint8 teamIndex; /**< TODO */
};
/**
* @brief
*
*/
class BattleGroundABScore : public BattleGroundScore
{
public:
/**
* @brief
*
*/
BattleGroundABScore(): BasesAssaulted(0), BasesDefended(0) {};
/**
* @brief
*
*/
virtual ~BattleGroundABScore() {};
uint32 GetAttr1() const { return BasesAssaulted; }
uint32 GetAttr2() const { return BasesDefended; }
uint32 BasesAssaulted;
uint32 BasesDefended;
uint32 BasesAssaulted; /**< TODO */
uint32 BasesDefended; /**< TODO */
};
/**
* @brief
*
*/
class BattleGroundAB : public BattleGround
{
friend class BattleGroundMgr;
public:
/**
* @brief
*
*/
BattleGroundAB();
/**
* @brief
*
*/
~BattleGroundAB();
/**
* @brief
*
* @param diff
*/
void Update(uint32 diff) override;
/**
* @brief
*
* @param plr
*/
void AddPlayer(Player* plr) override;
/**
* @brief
*
*/
virtual void StartingEventOpenDoors() override;
/**
* @brief
*
* @param plr
* @param guid
*/
void RemovePlayer(Player* plr, ObjectGuid guid) override;
/**
* @brief
*
* @param source
* @param trigger
*/
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
/**
* @brief
*
*/
virtual void Reset() override;
/**
* @brief
*
* @param winner
*/
void EndBattleGround(Team winner) override;
/**
* @brief
*
* @param player
* @return const WorldSafeLocsEntry
*/
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
/* Scorekeeping */
/**
* @brief
*
* @param source
* @param type
* @param value
*/
virtual void UpdatePlayerScore(Player* source, uint32 type, uint32 value) override;
/**
* @brief
*
* @param data
* @param count
*/
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/* Nodes occupying */
/**
* @brief
*
* @param source
* @param target_obj
*/
virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
/* achievement req. */
bool IsAllNodesControlledByTeam(Team team) const override;
bool IsTeamScores500Disadvantage(Team team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
/* Premature finish */
/**
* @brief
*
*/
virtual Team GetPrematureWinner() override;
private:
/* Gameobject spawning/despawning */
/**
* @brief
*
* @param node
* @param type
* @param teamIndex
* @param delay
*/
void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
void _DelBanner(uint8 node, uint8 type, uint8 teamIndex);
/**
* @brief
*
* @param node
*/
void _SendNodeUpdate(uint8 node);
/* Creature spawning/despawning */
// TODO: working, scripted peons spawning
/**
* @brief
*
* @param node
* @param team
*/
void _NodeOccupied(uint8 node, Team team);
/**
* @brief
*
* @param node
* @return int32
*/
int32 _GetNodeNameId(uint8 node);
/* Nodes info:
@ -209,16 +353,16 @@ class BattleGroundAB : public BattleGround
2: horde contested
3: ally occupied
4: horde occupied */
uint8 m_Nodes[BG_AB_NODES_MAX];
uint8 m_prevNodes[BG_AB_NODES_MAX]; // used for performant wordlstate-updating
BG_AB_BannerTimer m_BannerTimers[BG_AB_NODES_MAX];
uint32 m_NodeTimers[BG_AB_NODES_MAX];
uint32 m_lastTick[PVP_TEAM_COUNT];
uint32 m_honorScoreTicks[PVP_TEAM_COUNT];
uint32 m_ReputationScoreTics[PVP_TEAM_COUNT];
bool m_IsInformedNearVictory;
uint32 m_honorTicks;
uint32 m_ReputationTics;
uint8 m_Nodes[BG_AB_NODES_MAX]; /**< TODO */
uint8 m_prevNodes[BG_AB_NODES_MAX]; /**< used for performant wordlstate-updating */
BG_AB_BannerTimer m_BannerTimers[BG_AB_NODES_MAX]; /**< TODO */
uint32 m_NodeTimers[BG_AB_NODES_MAX]; /**< TODO */
uint32 m_lastTick[PVP_TEAM_COUNT]; /**< TODO */
uint32 m_honorScoreTicks[PVP_TEAM_COUNT]; /**< TODO */
uint32 m_ReputationScoreTics[PVP_TEAM_COUNT]; /**< TODO */
bool m_IsInformedNearVictory; /**< TODO */
uint32 m_honorTicks; /**< TODO */
uint32 m_ReputationTics; /**< TODO */
// need for achievements
bool m_TeamScores500Disadvantage[PVP_TEAM_COUNT];
};

View file

@ -43,7 +43,7 @@ BattleGroundAV::BattleGroundAV(): m_HonorMapComplete(0), m_RepTowerDestruction(0
void BattleGroundAV::HandleKillPlayer(Player* player, Player* killer)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
BattleGround::HandleKillPlayer(player, killer);
UpdateScore(GetTeamIndexByTeamId(player->GetTeam()), -1);
@ -53,10 +53,10 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer)
{
DEBUG_LOG("BattleGroundAV: HandleKillUnit %i", creature->GetEntry());
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
uint8 event1 = (sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow())).event1;
if (event1 == BG_EVENT_NONE)
return;
{ return; }
switch (event1)
{
case BG_AV_BOSS_A:
@ -75,7 +75,7 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer)
break;
case BG_AV_CAPTAIN_A:
if (IsActiveEvent(BG_AV_NodeEventCaptainDead_A, 0))
return;
{ return; }
RewardReputationToTeam(BG_AV_FACTION_H, m_RepCaptain, HORDE);
RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), HORDE);
UpdateScore(TEAM_INDEX_ALLIANCE, (-1) * BG_AV_RES_CAPTAIN);
@ -84,7 +84,7 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer)
break;
case BG_AV_CAPTAIN_H:
if (IsActiveEvent(BG_AV_NodeEventCaptainDead_H, 0))
return;
{ return; }
RewardReputationToTeam(BG_AV_FACTION_A, m_RepCaptain, ALLIANCE);
RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), ALLIANCE);
UpdateScore(TEAM_INDEX_HORDE, (-1) * BG_AV_RES_CAPTAIN);
@ -103,7 +103,7 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer)
void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
BattleGroundAVTeamIndex teamIdx = GetAVTeamIndexByTeamId(player->GetTeam());
MANGOS_ASSERT(teamIdx != BG_AV_TEAM_NEUTRAL);
@ -123,7 +123,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
DEBUG_LOG("BattleGroundAV: Quest %i completed starting with unit upgrading..", questid);
for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i)
if (m_Nodes[i].Owner == teamIdx && m_Nodes[i].State == POINT_CONTROLLED)
PopulateNode(i);
{ PopulateNode(i); }
}
break;
case BG_AV_QUEST_A_COMMANDER1:
@ -131,21 +131,21 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
m_Team_QuestStatus[teamIdx][1]++;
reputation = 1;
if (m_Team_QuestStatus[teamIdx][1] == 120)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); }
break;
case BG_AV_QUEST_A_COMMANDER2:
case BG_AV_QUEST_H_COMMANDER2:
m_Team_QuestStatus[teamIdx][2]++;
reputation = 2;
if (m_Team_QuestStatus[teamIdx][2] == 60)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); }
break;
case BG_AV_QUEST_A_COMMANDER3:
case BG_AV_QUEST_H_COMMANDER3:
m_Team_QuestStatus[teamIdx][3]++;
reputation = 5;
if (m_Team_QuestStatus[teamIdx][1] == 30)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); }
break;
case BG_AV_QUEST_A_BOSS1:
case BG_AV_QUEST_H_BOSS1:
@ -156,7 +156,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
m_Team_QuestStatus[teamIdx][4]++;
reputation += 1;
if (m_Team_QuestStatus[teamIdx][4] >= 200)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); }
break;
case BG_AV_QUEST_A_NEAR_MINE:
case BG_AV_QUEST_H_NEAR_MINE:
@ -166,7 +166,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[teamIdx][6] == 7)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); }
}
break;
case BG_AV_QUEST_A_OTHER_MINE:
@ -177,7 +177,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[teamIdx][5] == 20)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); }
}
break;
case BG_AV_QUEST_A_RIDER_HIDE:
@ -188,7 +188,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[teamIdx][8] == 25)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); }
}
break;
case BG_AV_QUEST_A_RIDER_TAME:
@ -199,7 +199,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
{
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid);
if (m_Team_QuestStatus[teamIdx][7] == 25)
DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid);
{ DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); }
}
break;
default:
@ -208,7 +208,7 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player)
break;
}
if (reputation)
RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam());
{ RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam()); }
}
void BattleGroundAV::UpdateScore(PvpTeamIndex teamIdx, int32 points)
@ -241,7 +241,7 @@ void BattleGroundAV::Update(uint32 diff)
BattleGround::Update(diff);
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
// add points from mine owning, and look if the neutral team can reclaim the mine
for (uint8 mine = 0; mine < BG_AV_MAX_MINES; ++mine)
@ -256,9 +256,9 @@ void BattleGroundAV::Update(uint32 diff)
}
if (m_Mine_Reclaim_Timer[mine] > diff)
m_Mine_Reclaim_Timer[mine] -= diff;
{ m_Mine_Reclaim_Timer[mine] -= diff; }
else
ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL);
{ ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL); }
}
}
@ -268,9 +268,9 @@ void BattleGroundAV::Update(uint32 diff)
if (m_Nodes[i].State == POINT_ASSAULTED)
{
if (m_Nodes[i].Timer > diff)
m_Nodes[i].Timer -= diff;
{ m_Nodes[i].Timer -= diff; }
else
EventPlayerDestroyedPoint(i);
{ EventPlayerDestroyedPoint(i); }
}
}
}
@ -303,20 +303,20 @@ void BattleGroundAV::EndBattleGround(Team winner)
for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i)
if (m_Nodes[i].State == POINT_CONTROLLED)
if (m_Nodes[i].TotalOwner == BG_AV_TEAM_ALLIANCE)
++tower_survived[TEAM_INDEX_ALLIANCE];
{ ++tower_survived[TEAM_INDEX_ALLIANCE]; }
for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i)
if (m_Nodes[i].State == POINT_CONTROLLED)
if (m_Nodes[i].TotalOwner == BG_AV_TEAM_HORDE)
++tower_survived[TEAM_INDEX_HORDE];
{ ++tower_survived[TEAM_INDEX_HORDE]; }
// graves all controlled
for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i)
if (m_Nodes[i].State == POINT_CONTROLLED && m_Nodes[i].Owner != BG_AV_TEAM_NEUTRAL)
++graves_owned[m_Nodes[i].Owner];
{ ++graves_owned[m_Nodes[i].Owner]; }
for (uint8 i = 0; i < BG_AV_MAX_MINES; ++i)
if (m_Mine_Owner[i] != BG_AV_TEAM_NEUTRAL)
++mines_owned[m_Mine_Owner[i]];
{ ++mines_owned[m_Mine_Owner[i]]; }
// now we have the values give the honor/reputation to the teams:
Team team[PVP_TEAM_COUNT] = { ALLIANCE, HORDE };
@ -330,9 +330,9 @@ void BattleGroundAV::EndBattleGround(Team winner)
}
DEBUG_LOG("BattleGroundAV: EndbattleGround: bgteam: %u towers:%u honor:%u rep:%u", i, tower_survived[i], GetBonusHonorFromKill(tower_survived[i] * BG_AV_KILL_SURVIVING_TOWER), tower_survived[i] * BG_AV_REP_SURVIVING_TOWER);
if (graves_owned[i])
RewardReputationToTeam(faction[i], graves_owned[i] * m_RepOwnedGrave, team[i]);
{ RewardReputationToTeam(faction[i], graves_owned[i] * m_RepOwnedGrave, team[i]); }
if (mines_owned[i])
RewardReputationToTeam(faction[i], mines_owned[i] * m_RepOwnedMine, team[i]);
{ RewardReputationToTeam(faction[i], mines_owned[i] * m_RepOwnedMine, team[i]); }
// captain survived?:
if (!IsActiveEvent(BG_AV_NodeEventCaptainDead_A + GetTeamIndexByTeamId(team[i]), 0))
{
@ -358,15 +358,15 @@ bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger)
case 95:
case 2608:
if (source->GetTeam() != ALLIANCE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE);
{ source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); }
else
source->LeaveBattleground();
{ source->LeaveBattleground(); }
break;
case 2606:
if (source->GetTeam() != HORDE)
source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE);
{ source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); }
else
source->LeaveBattleground();
{ source->LeaveBattleground(); }
break;
default:
return false;
@ -378,7 +378,7 @@ void BattleGroundAV::UpdatePlayerScore(Player* source, uint32 type, uint32 value
{
BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid());
if (itr == m_PlayerScores.end()) // player not found...
return;
{ return; }
switch (type)
{
@ -441,7 +441,7 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx
// TODO changing the owner should result in setting respawntime to infinite for current creatures (they should fight the new ones), spawning new mine owners creatures and changing the chest - objects so that the current owning team can use them
MANGOS_ASSERT(mine == BG_AV_NORTH_MINE || mine == BG_AV_SOUTH_MINE);
if (m_Mine_Owner[mine] == teamIdx)
return;
{ return; }
m_Mine_PrevOwner[mine] = m_Mine_Owner[mine];
m_Mine_Owner[mine] = teamIdx;
@ -464,9 +464,9 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx
bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId, Team team)
{
if (GOId == BG_AV_OBJECTID_MINE_N)
return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetAVTeamIndexByTeamId(team));
{ return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetAVTeamIndexByTeamId(team)); }
if (GOId == BG_AV_OBJECTID_MINE_S)
return (m_Mine_Owner[BG_AV_SOUTH_MINE] == GetAVTeamIndexByTeamId(team));
{ return (m_Mine_Owner[BG_AV_SOUTH_MINE] == GetAVTeamIndexByTeamId(team)); }
return true; // cause it's no mine'object it is ok if this is true
}
@ -479,18 +479,18 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node)
{
uint32 graveDefenderType;
if (m_Team_QuestStatus[teamIdx][0] < 500)
graveDefenderType = 0;
{ graveDefenderType = 0; }
else if (m_Team_QuestStatus[teamIdx][0] < 1000)
graveDefenderType = 1;
{ graveDefenderType = 1; }
else if (m_Team_QuestStatus[teamIdx][0] < 1500)
graveDefenderType = 2;
{ graveDefenderType = 2; }
else
graveDefenderType = 3;
{ graveDefenderType = 3; }
if (m_Nodes[node].State == POINT_CONTROLLED) // we can spawn the current owner event
SpawnEvent(BG_AV_NODES_MAX + node, teamIdx * BG_AV_MAX_GRAVETYPES + graveDefenderType, true);
{ SpawnEvent(BG_AV_NODES_MAX + node, teamIdx * BG_AV_MAX_GRAVETYPES + graveDefenderType, true); }
else // we despawn the event from the prevowner
SpawnEvent(BG_AV_NODES_MAX + node, m_Nodes[node].PrevOwner * BG_AV_MAX_GRAVETYPES + graveDefenderType, false);
{ SpawnEvent(BG_AV_NODES_MAX + node, m_Nodes[node].PrevOwner * BG_AV_MAX_GRAVETYPES + graveDefenderType, false); }
}
SpawnEvent(node, (teamIdx * BG_AV_MAX_STATES) + m_Nodes[node].State, true);
}
@ -499,11 +499,11 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node)
void BattleGroundAV::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
DEBUG_LOG("BattleGroundAV: using gameobject %i", target_obj->GetEntry());
uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1;
if (event >= BG_AV_NODES_MAX) // not a node
return;
{ return; }
BG_AV_Nodes node = BG_AV_Nodes(event);
switch ((sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event2 % BG_AV_MAX_STATES)
{
@ -525,7 +525,7 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node)
PvpTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam());
if (m_Nodes[node].Owner == BattleGroundAVTeamIndex(teamIdx) || m_Nodes[node].State != POINT_ASSAULTED)
return;
{ return; }
if (m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL) // initial snowfall capture
{
// until snowfall doesn't belong to anyone it is better handled in assault - code (best would be to have a special function
@ -571,7 +571,7 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node)
PvpTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam());
DEBUG_LOG("BattleGroundAV: player assaults node %i", node);
if (m_Nodes[node].Owner == BattleGroundAVTeamIndex(teamIdx) || BattleGroundAVTeamIndex(teamIdx) == m_Nodes[node].TotalOwner)
return;
{ return; }
AssaultNode(node, teamIdx); // update nodeinfo variables
UpdateNodeWorldState(node); // send mapicon
@ -612,7 +612,7 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count)
}
if (m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_TEAM_NEUTRAL) // cause neutral teams aren't handled generic
FillInitialWorldState(data, count, AV_SNOWFALL_N, WORLD_STATE_ADD);
{ FillInitialWorldState(data, count, AV_SNOWFALL_N, WORLD_STATE_ADD); }
FillInitialWorldState(data, count, BG_AV_Alliance_Score, m_TeamScores[TEAM_INDEX_ALLIANCE]);
FillInitialWorldState(data, count, BG_AV_Horde_Score, m_TeamScores[TEAM_INDEX_HORDE]);
@ -629,20 +629,20 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count)
FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_Owner[BG_AV_NORTH_MINE]], WORLD_STATE_ADD);
if (m_Mine_Owner[BG_AV_NORTH_MINE] != m_Mine_PrevOwner[BG_AV_NORTH_MINE])
FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_PrevOwner[BG_AV_NORTH_MINE]], WORLD_STATE_REMOVE);
{ FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_PrevOwner[BG_AV_NORTH_MINE]], WORLD_STATE_REMOVE); }
FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_Owner[BG_AV_SOUTH_MINE]], WORLD_STATE_ADD);
if (m_Mine_Owner[BG_AV_SOUTH_MINE] != m_Mine_PrevOwner[BG_AV_SOUTH_MINE])
FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_PrevOwner[BG_AV_SOUTH_MINE]], WORLD_STATE_REMOVE);
{ FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_PrevOwner[BG_AV_SOUTH_MINE]], WORLD_STATE_REMOVE); }
}
void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node)
{
UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State, m_Nodes[node].Owner)], WORLD_STATE_ADD);
if (m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL) // currently only snowfall is supported as neutral node
UpdateWorldState(AV_SNOWFALL_N, WORLD_STATE_REMOVE);
{ UpdateWorldState(AV_SNOWFALL_N, WORLD_STATE_REMOVE); }
else
UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState, m_Nodes[node].PrevOwner)], WORLD_STATE_REMOVE);
{ UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState, m_Nodes[node].PrevOwner)], WORLD_STATE_REMOVE); }
}
void BattleGroundAV::SendMineWorldStates(uint32 mine)
@ -651,7 +651,7 @@ void BattleGroundAV::SendMineWorldStates(uint32 mine)
UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_Owner[mine]], WORLD_STATE_ADD);
if (m_Mine_Owner[mine] != m_Mine_PrevOwner[mine])
UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_PrevOwner[mine]], WORLD_STATE_REMOVE);
{ UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_PrevOwner[mine]], WORLD_STATE_REMOVE); }
}
WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr)
@ -667,10 +667,10 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr)
for (uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i)
{
if (m_Nodes[i].Owner != teamIdx || m_Nodes[i].State != POINT_CONTROLLED)
continue;
{ continue; }
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i]);
if (!entry)
continue;
{ continue; }
float dist = (entry->x - x) * (entry->x - x) + (entry->y - y) * (entry->y - y);
if (mindist > dist)
{
@ -681,7 +681,7 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr)
}
// If not, place ghost in the starting-cave
if (!good_entry)
good_entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[teamIdx + 7]);
{ good_entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[teamIdx + 7]); }
return good_entry;
}
@ -746,7 +746,7 @@ void BattleGroundAV::InitNode(BG_AV_Nodes node, BattleGroundAVTeamIndex teamIdx,
m_Nodes[node].Tower = tower;
m_ActiveEvents[node] = teamIdx * BG_AV_MAX_STATES + m_Nodes[node].State;
if (IsGrave(node)) // grave-creatures are special cause of a quest
m_ActiveEvents[node + BG_AV_NODES_MAX] = teamIdx * BG_AV_MAX_GRAVETYPES;
{ m_ActiveEvents[node + BG_AV_NODES_MAX] = teamIdx * BG_AV_MAX_GRAVETYPES; }
}
void BattleGroundAV::DefendNode(BG_AV_Nodes node, PvpTeamIndex teamIdx)
@ -779,7 +779,7 @@ void BattleGroundAV::Reset()
for (uint8 i = 0; i < PVP_TEAM_COUNT; ++i)
{
for (uint8 j = 0; j < 9; ++j) // 9 quests getting tracked
m_Team_QuestStatus[i][j] = 0;
{ m_Team_QuestStatus[i][j] = 0; }
m_TeamScores[i] = BG_AV_SCORE_INITIAL_POINTS;
m_IsInformedNearLose[i] = false;
m_ActiveEvents[BG_AV_NodeEventCaptainDead_A + i] = BG_EVENT_NONE;
@ -800,17 +800,17 @@ void BattleGroundAV::Reset()
m_ActiveEvents[BG_AV_BOSS_A] = 0;
m_ActiveEvents[BG_AV_BOSS_H] = 0;
for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // towers
m_ActiveEvents[BG_AV_MARSHAL_A_SOUTH + i - BG_AV_NODES_DUNBALDAR_SOUTH] = 0;
{ m_ActiveEvents[BG_AV_MARSHAL_A_SOUTH + i - BG_AV_NODES_DUNBALDAR_SOUTH] = 0; }
for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_STONEHEART_GRAVE; ++i) // alliance graves
InitNode(i, BG_AV_TEAM_ALLIANCE, false);
{ InitNode(i, BG_AV_TEAM_ALLIANCE, false); }
for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) // alliance towers
InitNode(i, BG_AV_TEAM_ALLIANCE, true);
{ InitNode(i, BG_AV_TEAM_ALLIANCE, true); }
for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_GRAVE; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) // horde graves
InitNode(i, BG_AV_TEAM_HORDE, false);
{ InitNode(i, BG_AV_TEAM_HORDE, false); }
for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) // horde towers
InitNode(i, BG_AV_TEAM_HORDE, true);
{ InitNode(i, BG_AV_TEAM_HORDE, true); }
InitNode(BG_AV_NODES_SNOWFALL_GRAVE, BG_AV_TEAM_NEUTRAL, false); // give snowfall neutral owner
}
@ -821,9 +821,9 @@ Team BattleGroundAV::GetPrematureWinner()
int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
if (hordeScore > allianceScore)
return HORDE;
{ return HORDE; }
if (allianceScore > hordeScore)
return ALLIANCE;
{ return ALLIANCE; }
// If the values are equal, fall back to number of players on each team
return BattleGround::GetPrematureWinner();

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef __BATTLEGROUNDAV_H
#define __BATTLEGROUNDAV_H
#ifndef MANGOS_H_BATTLEGROUNDAV
#define MANGOS_H_BATTLEGROUNDAV
#include "Common.h"
#include "BattleGround.h"
@ -75,6 +75,10 @@
#define BG_AV_REP_OWNED_MINE_HOLIDAY 36
#define BG_AV_EVENT_START_BATTLE 9166
/**
* @brief
*
*/
enum BG_AV_Sounds
{
BG_AV_SOUND_NEAR_LOSE = 8456, // not confirmed yet
@ -86,9 +90,13 @@ enum BG_AV_Sounds
BG_AV_SOUND_BOTH_TOWER_DEFEND = 8192,
BG_AV_SOUND_ALLIANCE_CAPTAIN = 8232, // gets called when someone attacks them and at the beginning after 3min + rand(x) * 10sec (maybe buff)
BG_AV_SOUND_HORDE_CAPTAIN = 8333,
BG_AV_SOUND_HORDE_CAPTAIN = 8333
};
/**
* @brief
*
*/
enum BG_AV_OTHER_VALUES
{
BG_AV_NORTH_MINE = 0,
@ -96,17 +104,25 @@ enum BG_AV_OTHER_VALUES
BG_AV_MINE_TICK_TIMER = 45000,
BG_AV_MINE_RECLAIM_TIMER = 1200000, // TODO: get the right value.. this is currently 20 minutes
BG_AV_FACTION_A = 730,
BG_AV_FACTION_H = 729,
BG_AV_FACTION_H = 729
};
#define BG_AV_MAX_MINES 2
/**
* @brief
*
*/
enum BG_AV_ObjectIds
{
// mine supplies
BG_AV_OBJECTID_MINE_N = 178785,
BG_AV_OBJECTID_MINE_S = 178784,
BG_AV_OBJECTID_MINE_S = 178784
};
/**
* @brief
*
*/
enum BG_AV_Nodes
{
BG_AV_NODES_FIRSTAID_STATION = 0,
@ -124,7 +140,7 @@ enum BG_AV_Nodes
BG_AV_NODES_TOWER_POINT = 12,
BG_AV_NODES_FROSTWOLF_ETOWER = 13,
BG_AV_NODES_FROSTWOLF_WTOWER = 14,
BG_AV_NODES_ERROR = 255,
BG_AV_NODES_ERROR = 255
};
#define BG_AV_NODES_MAX 15
@ -166,6 +182,10 @@ enum BG_AV_Nodes
#define BG_AV_NodeEventCaptainDead_A 63
#define BG_AV_NodeEventCaptainDead_H 64
/**
* @brief
*
*/
enum BG_AV_Graveyards
{
BG_AV_GRAVE_STORM_AID = 751,
@ -179,7 +199,7 @@ enum BG_AV_Graveyards
BG_AV_GRAVE_MAIN_HORDE = 610
};
const uint32 BG_AV_GraveyardIds[9] =
const uint32 BG_AV_GraveyardIds[9] = /**< TODO */
{
BG_AV_GRAVE_STORM_AID,
BG_AV_GRAVE_STORM_GRAVE,
@ -192,6 +212,10 @@ const uint32 BG_AV_GraveyardIds[9] =
BG_AV_GRAVE_MAIN_HORDE
};
/**
* @brief
*
*/
enum BG_AV_States
{
POINT_ASSAULTED = 0,
@ -199,18 +223,26 @@ enum BG_AV_States
};
#define BG_AV_MAX_STATES 2
/**
* @brief
*
*/
enum BG_AV_WorldStates
{
BG_AV_Alliance_Score = 3127,
BG_AV_Horde_Score = 3128,
BG_AV_SHOW_H_SCORE = 3133,
BG_AV_SHOW_A_SCORE = 3134,
AV_SNOWFALL_N = 1966,
AV_SNOWFALL_N = 1966
};
// special version with more wide values range that PvpTeamIndex
// BattleGroundAVTeamIndex <- PvpTeamIndex cast safe
// BattleGroundAVTeamIndex -> PvpTeamIndex cast safe and array with PVP_TEAM_COUNT elements must checked != BG_AV_TEAM_NEUTRAL before used
/**
* @brief special version with more wide values range that BattleGroundTeamIndex
*
* BattleGroundAVTeamIndex <- BattleGroundTeamIndex cast safe
* BattleGroundAVTeamIndex -> BattleGroundTeamIndex cast safe and array with BG_TEAMS_COUNT elements must checked != BG_AV_TEAM_NEUTRAL before used
*
*/
enum BattleGroundAVTeamIndex
{
BG_AV_TEAM_ALLIANCE = TEAM_INDEX_ALLIANCE,
@ -220,15 +252,13 @@ enum BattleGroundAVTeamIndex
#define BG_AV_TEAMS_COUNT 3
// alliance_control horde_control neutral_control
const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] =
const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] = /**< alliance_control horde_control neutral_control */
{
{1358, 1359, 1360},
{1355, 1356, 1357}
};
// alliance_control alliance_assault h_control h_assault
const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] =
const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] = /**< alliance_control alliance_assault h_control h_assault */
{
// Stormpike first aid station
{1326, 1325, 1328, 1327},
@ -262,8 +292,11 @@ const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] =
{1387, 1365, 1392, 1382},
};
// through the armorscap-quest 4 different gravedefender exist
#define BG_AV_MAX_GRAVETYPES 4
/**
* @brief through the armorscap-quest 4 different gravedefender exist
*
*/
enum BG_AV_QuestIds
{
BG_AV_QUEST_A_SCRAPS1 = 7223, // first quest
@ -290,26 +323,48 @@ enum BG_AV_QuestIds
BG_AV_QUEST_H_RIDER_TAME = 7001
};
/**
* @brief
*
*/
struct BG_AV_NodeInfo
{
BattleGroundAVTeamIndex TotalOwner;
BattleGroundAVTeamIndex Owner;
BattleGroundAVTeamIndex PrevOwner;
BG_AV_States State;
BG_AV_States PrevState;
uint32 Timer;
bool Tower;
BattleGroundAVTeamIndex TotalOwner; /**< TODO */
BattleGroundAVTeamIndex Owner; /**< TODO */
BattleGroundAVTeamIndex PrevOwner; /**< TODO */
BG_AV_States State; /**< TODO */
BG_AV_States PrevState; /**< TODO */
uint32 Timer; /**< TODO */
bool Tower; /**< TODO */
};
/**
* @brief
*
* @param i
* @return BG_AV_Nodes &operator
*/
inline BG_AV_Nodes& operator++(BG_AV_Nodes& i)
{
return i = BG_AV_Nodes(i + 1);
}
/**
* @brief
*
*/
class BattleGroundAVScore : public BattleGroundScore
{
public:
/**
* @brief
*
*/
BattleGroundAVScore() : GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), TowersDefended(0), SecondaryObjectives(0) {};
/**
* @brief
*
*/
virtual ~BattleGroundAVScore() {};
uint32 GetAttr1() const { return GraveyardsAssaulted; }
@ -318,95 +373,284 @@ class BattleGroundAVScore : public BattleGroundScore
uint32 GetAttr4() const { return TowersDefended; }
uint32 GetAttr5() const { return SecondaryObjectives; }
uint32 GraveyardsAssaulted;
uint32 GraveyardsDefended;
uint32 TowersAssaulted;
uint32 TowersDefended;
uint32 SecondaryObjectives;
uint32 GraveyardsAssaulted; /**< TODO */
uint32 GraveyardsDefended; /**< TODO */
uint32 TowersAssaulted; /**< TODO */
uint32 TowersDefended; /**< TODO */
uint32 SecondaryObjectives; /**< TODO */
};
/**
* @brief
*
*/
class BattleGroundAV : public BattleGround
{
friend class BattleGroundMgr;
public:
/**
* @brief
*
*/
BattleGroundAV();
/**
* @brief
*
* @param diff
*/
void Update(uint32 diff) override;
/* inherited from BattlegroundClass */
/**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override;
/**
* @brief
*
*/
virtual void StartingEventOpenDoors() override;
// world states
/**
* @brief world states
*
* @param data
* @param count
*/
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/**
* @brief
*
* @param source
* @param trigger
*/
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
/**
* @brief
*
*/
virtual void Reset() override;
/*general stuff*/
/**
* @brief
*
* @param teamIdx
* @param points
*/
void UpdateScore(PvpTeamIndex teamIdx, int32 points);
/**
* @brief
*
* @param source
* @param type
* @param value
*/
void UpdatePlayerScore(Player* source, uint32 type, uint32 value) override;
/*handle stuff*/ // these are functions which get called from extern scripts
/**
* @brief
*
* @param source
* @param target_obj
*/
virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
/**
* @brief
*
* @param player
* @param killer
*/
void HandleKillPlayer(Player* player, Player* killer) override;
/**
* @brief
*
* @param creature
* @param killer
*/
void HandleKillUnit(Creature* creature, Player* killer) override;
/**
* @brief
*
* @param questid
* @param player
*/
void HandleQuestComplete(uint32 questid, Player* player);
/**
* @brief
*
* @param GOId
* @param team
* @return bool
*/
bool PlayerCanDoMineQuest(int32 GOId, Team team);
/**
* @brief
*
* @param winner
*/
void EndBattleGround(Team winner) override;
/**
* @brief
*
* @param plr
* @return const WorldSafeLocsEntry
*/
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* plr) override;
static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(Team team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(team)); }
/**
* @brief
*
* @return Team
*/
virtual Team GetPrematureWinner() override;
/**
* @brief
*
* @param team
* @return BattleGroundAVTeamIndex
*/
static BattleGroundAVTeamIndex GetAVTeamIndexByTeamId(Team team) { return BattleGroundAVTeamIndex(GetTeamIndexByTeamId(team)); }
private:
/* Nodes occupying */
/**
* @brief
*
* @param player
* @param node
*/
void EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node);
/**
* @brief
*
* @param player
* @param node
*/
void EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node);
/**
* @brief
*
* @param node
*/
void EventPlayerDestroyedPoint(BG_AV_Nodes node);
/**
* @brief
*
* @param node
* @param teamIdx
*/
void AssaultNode(BG_AV_Nodes node, PvpTeamIndex teamIdx);
/**
* @brief
*
* @param node
*/
void DestroyNode(BG_AV_Nodes node);
/**
* @brief
*
* @param node
* @param teamIdx
* @param tower
*/
void InitNode(BG_AV_Nodes node, BattleGroundAVTeamIndex teamIdx, bool tower);
/**
* @brief
*
* @param node
* @param teamIdx
*/
void DefendNode(BG_AV_Nodes node, PvpTeamIndex teamIdx);
/**
* @brief
*
* @param node
*/
void PopulateNode(BG_AV_Nodes node);
/**
* @brief
*
* @param node
* @return uint32
*/
uint32 GetNodeName(BG_AV_Nodes node) const;
/**
* @brief
*
* @param node
* @return bool
*/
bool IsTower(BG_AV_Nodes node) const { return (node == BG_AV_NODES_ERROR) ? false : m_Nodes[node].Tower; }
/**
* @brief
*
* @param node
* @return bool
*/
bool IsGrave(BG_AV_Nodes node) const { return (node == BG_AV_NODES_ERROR) ? false : !m_Nodes[node].Tower; }
/*mine*/
/**
* @brief
*
* @param mine
* @param teamIdx
*/
void ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx);
/*worldstates*/
/**
* @brief
*
* @param state
* @param teamIdx
* @return uint8
*/
uint8 GetWorldStateType(uint8 state, BattleGroundAVTeamIndex teamIdx) const { return teamIdx * BG_AV_MAX_STATES + state; }
/**
* @brief
*
* @param mine
*/
void SendMineWorldStates(uint32 mine);
/**
* @brief
*
* @param node
*/
void UpdateNodeWorldState(BG_AV_Nodes node);
/*variables */
uint32 m_Team_QuestStatus[PVP_TEAM_COUNT][9]; // [x][y] x=team y=questcounter
uint32 m_Team_QuestStatus[PVP_TEAM_COUNT][9]; /**< [x][y] x=team y=questcounter */
BG_AV_NodeInfo m_Nodes[BG_AV_NODES_MAX];
BG_AV_NodeInfo m_Nodes[BG_AV_NODES_MAX]; /**< TODO */
// only for worldstates needed
BattleGroundAVTeamIndex m_Mine_Owner[BG_AV_MAX_MINES];
BattleGroundAVTeamIndex m_Mine_PrevOwner[BG_AV_MAX_MINES];
int32 m_Mine_Timer[BG_AV_MAX_MINES];
uint32 m_Mine_Reclaim_Timer[BG_AV_MAX_MINES];
BattleGroundAVTeamIndex m_Mine_Owner[BG_AV_MAX_MINES]; /**< TODO */
BattleGroundAVTeamIndex m_Mine_PrevOwner[BG_AV_MAX_MINES]; /**< TODO */
int32 m_Mine_Timer[BG_AV_MAX_MINES]; /**< TODO */
uint32 m_Mine_Reclaim_Timer[BG_AV_MAX_MINES]; /**< TODO */
bool m_IsInformedNearLose[PVP_TEAM_COUNT];
bool m_IsInformedNearLose[PVP_TEAM_COUNT]; /**< TODO */
uint32 m_HonorMapComplete;
uint32 m_RepTowerDestruction;
uint32 m_RepCaptain;
uint32 m_RepBoss;
uint32 m_RepOwnedGrave;
uint32 m_RepOwnedMine;
uint32 m_RepSurviveCaptain;
uint32 m_RepSurviveTower;
uint32 m_HonorMapComplete; /**< TODO */
uint32 m_RepTowerDestruction; /**< TODO */
uint32 m_RepCaptain; /**< TODO */
uint32 m_RepBoss; /**< TODO */
uint32 m_RepOwnedGrave; /**< TODO */
uint32 m_RepOwnedMine; /**< TODO */
uint32 m_RepSurviveCaptain; /**< TODO */
uint32 m_RepSurviveTower; /**< TODO */
};
#endif

View file

@ -51,10 +51,10 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data)
Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid);
if (!pCreature)
return;
{ return; }
if (!pCreature->IsBattleMaster()) // it's not battlemaster
return;
{ return; }
// Stop the npc if moving
pCreature->StopMoving();
@ -118,7 +118,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
// get bg instance or bg template if instance not found
BattleGround* bg = NULL;
if (instanceId)
bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId);
{ bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId); }
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
@ -147,17 +147,17 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
// check if already in queue
if (_player->GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
{ return; }
// check if has free queue slots
if (!_player->HasFreeBattleGroundQueueId())
return;
{ return; }
}
else
{
grp = _player->GetGroup();
// no group found, error
if (!grp)
return;
{ return; }
if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return;
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
@ -187,10 +187,9 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
{ continue; } // this should never happen
// add to queue
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId);
uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue
// send status packet (in queue)
WorldPacket data;
@ -216,14 +215,14 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
sBattleGroundMgr.ScheduleQueueUpdate(0, ARENA_TYPE_NONE, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/)
{
// empty opcode
DEBUG_LOG("WORLD: Received opcode CMSG_BATTLEGROUND_PLAYER_POSITIONS");
BattleGround* bg = _player->GetBattleGround();
if (!bg) // can't be received if player not in battleground
return;
{ return; }
Player* flagCarrierA = NULL;
Player* flagCarrierH = NULL;
@ -282,13 +281,13 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket& /*recv_d
SendPacket(&data);
}
void WorldSession::HandlePVPLogDataOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/)
{
DEBUG_LOG("WORLD: Received opcode CMSG_PVP_LOG_DATA");
BattleGround* bg = _player->GetBattleGround();
if (!bg)
return;
{ return; }
// arena finish version will send in BattleGround::EndBattleGround directly
if (bg->isArena())
@ -381,7 +380,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data)
// bg template might and must be used in case of leaving queue, when instance is not created yet
if (!bg && action == 0)
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
{ bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); }
if (!bg)
{
sLog.outError("BattlegroundHandler: bg_template not found for instance id %u type id %u.", ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
@ -422,7 +421,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data)
{
case 1: // port to battleground
if (!_player->IsInvitedForBattleGroundQueueType(bgQueueTypeId))
return; // cheating?
{ return; } // cheating?
if (!_player->InBattleGround())
_player->SetBattleGroundEntryPoint();
@ -447,7 +446,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data)
// this is still needed here if battleground "jumping" shouldn't add deserter debuff
// also this is required to prevent stuck at old battleground after SetBattleGroundId set to new
if (BattleGround* currentBg = _player->GetBattleGround())
currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true);
{ currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true); }
// set the destination instance id
_player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId);
@ -494,15 +493,15 @@ void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recv_data)
if (_player->IsInCombat())
if (BattleGround* bg = _player->GetBattleGround())
if (bg->GetStatus() != STATUS_WAIT_LEAVE)
return;
{ return; }
_player->LeaveBattleground();
}
void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/)
{
// empty opcode
DEBUG_LOG("WORLD: CMSG_BATTLEFIELD_STATUS");
DEBUG_LOG("WORLD: Battleground status");
WorldPacket data;
// we must update all queues here
@ -511,14 +510,14 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/)
{
BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i);
if (!bgQueueTypeId)
continue;
{ continue; }
BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId);
ArenaType arenaType = BattleGroundMgr::BGArenaType(bgQueueTypeId);
if (bgTypeId == _player->GetBattleGroundTypeId())
{
bg = _player->GetBattleGround();
// i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
// i can not check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
// so i must use bg pointer to get that information
if (bg && bg->GetArenaType() == arenaType)
{
@ -534,12 +533,12 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/)
BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId];
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetObjectGuid(), &ginfo))
continue;
{ continue; }
if (ginfo.IsInvitedToBGInstanceGUID)
{
bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
if (!bg)
continue;
{ continue; }
uint32 remainingTime = WorldTimer::getMSTimeDiff(WorldTimer::getMSTime(), ginfo.RemoveInviteTime);
// send status invited to BattleGround
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player, i, STATUS_WAIT_JOIN, remainingTime, 0, arenaType);
@ -549,7 +548,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/)
{
bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bg)
continue;
{ continue; }
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
@ -570,17 +569,17 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data)
BattleGround* bg = _player->GetBattleGround();
if (!bg)
return;
{ return; }
ObjectGuid guid;
recv_data >> guid;
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
{ return; }
if (!unit->IsSpiritService()) // it's not spirit service
return;
{ return; }
unit->SendAreaSpiritHealerQueryOpcode(GetPlayer());
}
@ -591,17 +590,17 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data)
BattleGround* bg = _player->GetBattleGround();
if (!bg)
return;
{ return; }
ObjectGuid guid;
recv_data >> guid;
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit)
return;
{ return; }
if (!unit->IsSpiritService()) // it's not spirit service
return;
{ return; }
sScriptMgr.OnGossipHello(GetPlayer(), unit);
}

View file

@ -69,7 +69,7 @@ BattleGroundQueue::BattleGroundQueue()
m_SumOfWaitTimes[i][j] = 0;
m_WaitTimeLastPlayer[i][j] = 0;
for (uint8 k = 0; k < COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; ++k)
m_WaitTimes[i][j][k] = 0;
{ m_WaitTimes[i][j][k] = 0; }
}
}
}
@ -82,7 +82,7 @@ BattleGroundQueue::~BattleGroundQueue()
for (uint8 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j)
{
for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr != m_QueuedGroups[i][j].end(); ++itr)
delete(*itr);
{ delete(*itr); }
m_QueuedGroups[i][j].clear();
}
}
@ -116,7 +116,7 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size)
found = true;
}
else if (!found && (*itr)->Players.size() >= (*groupToKick)->Players.size())
groupToKick = itr;
{ groupToKick = itr; }
}
// if pool is empty, do nothing
if (GetPlayerCount())
@ -127,7 +127,7 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size)
PlayerCount -= ginfo->Players.size();
// return false if we kicked smaller group or there are enough players in selection pool
if (ginfo->Players.size() <= size + 1)
return false;
{ return false; }
}
return true;
}
@ -147,7 +147,7 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo* ginfo, uint32 de
return true;
}
if (PlayerCount < desiredCount)
return true;
{ return true; }
return false;
}
@ -178,10 +178,10 @@ GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGr
// compute index (if group is premade or joined a rated match) to queues
uint32 index = 0;
if (!isRated && !isPremade)
index += PVP_TEAM_COUNT; // BG_QUEUE_PREMADE_* -> BG_QUEUE_NORMAL_*
{ index += PVP_TEAM_COUNT; } // BG_QUEUE_PREMADE_* -> BG_QUEUE_NORMAL_*
if (ginfo->GroupTeam == HORDE)
++index; // BG_QUEUE_*_ALLIANCE -> BG_QUEUE_*_HORDE
{ ++index; } // BG_QUEUE_*_ALLIANCE -> BG_QUEUE_*_HORDE
DEBUG_LOG("Adding Group to BattleGroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
@ -202,7 +202,7 @@ GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGr
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
{ continue; } // this should never happen
PlayerQueueInfo& pl_info = m_QueuedPlayers[member->GetObjectGuid()];
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
@ -235,10 +235,10 @@ GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGr
GroupsQueueType::const_iterator itr;
for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
if (!(*itr)->IsInvitedToBGInstanceGUID)
qAlliance += (*itr)->Players.size();
{ qAlliance += (*itr)->Players.size(); }
for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
if (!(*itr)->IsInvitedToBGInstanceGUID)
qHorde += (*itr)->Players.size();
{ qHorde += (*itr)->Players.size(); }
// Show queue status to player only (when joining queue)
if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN) == 1)
@ -303,10 +303,10 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleG
}
// check if there is enought values(we always add values > 0)
if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1])
return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME);
{ return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME); }
else
// if there aren't enough values return 0 - not available
return 0;
{ return 0; }
}
// remove player from queue and from group info, if group info is empty then remove it too
@ -355,7 +355,7 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
// player can't be in queue without group, but just in case
if (bracket_id == -1)
{
sLog.outError("BattleGroundQueue: ERROR Cannot find groupinfo for %s", guid.GetString().c_str());
sLog.outError("BattleGroundQueue: ERROR Can not find groupinfo for %s", guid.GetString().c_str());
return;
}
DEBUG_LOG("BattleGroundQueue: Removing %s, from bracket_id %u", guid.GetString().c_str(), (uint32)bracket_id);
@ -368,14 +368,14 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
// remove player queue info from group queue info
GroupQueueInfoPlayers::iterator pitr = group->Players.find(guid);
if (pitr != group->Players.end())
group->Players.erase(pitr);
{ group->Players.erase(pitr); }
// if invited to bg, and should decrease invited count, then do it
if (decreaseInvitedCount && group->IsInvitedToBGInstanceGUID)
{
BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId);
if (bg)
bg->DecreaseInvitedCount(group->GroupTeam);
{ bg->DecreaseInvitedCount(group->GroupTeam); }
}
// remove player queue info
@ -445,7 +445,7 @@ bool BattleGroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo*
// ACE_Guard<ACE_Recursive_Thread_Mutex> g(m_Lock);
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(guid);
if (qItr == m_QueuedPlayers.end())
return false;
{ return false; }
*ginfo = *(qItr->second.GroupInfo);
return true;
}
@ -454,7 +454,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg,
{
// set side if needed
if (side)
ginfo->GroupTeam = side;
{ ginfo->GroupTeam = side; }
if (!ginfo->IsInvitedToBGInstanceGUID)
{
@ -478,7 +478,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg,
Player* plr = sObjectMgr.GetPlayer(itr->first);
// if offline, skip him, this should not happen - player is removed from queue when he logs out
if (!plr)
continue;
{ continue; }
// invite the player
PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id);
@ -530,17 +530,17 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId
// index to queue which group is current
uint32 aliIndex = 0;
for (; aliIndex < aliCount && m_SelectionPools[TEAM_INDEX_ALLIANCE].AddGroup((*Ali_itr), aliFree); ++aliIndex)
++Ali_itr;
{ ++Ali_itr; }
// the same thing for horde
GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin();
uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();
uint32 hordeIndex = 0;
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_INDEX_HORDE].AddGroup((*Horde_itr), hordeFree); ++hordeIndex)
++Horde_itr;
{ ++Horde_itr; }
// if ofc like BG queue invitation is set in config, then we are happy
if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) == 0)
return;
{ return; }
/*
if we reached this code, then we have to solve NP - complete problem called Subset sum problem
@ -562,13 +562,13 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId
if (m_SelectionPools[TEAM_INDEX_ALLIANCE].KickGroup(diffHorde - diffAli))
{
for (; aliIndex < aliCount && m_SelectionPools[TEAM_INDEX_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0); ++aliIndex)
++Ali_itr;
{ ++Ali_itr; }
}
// if ali selection is already empty, then kick horde group, but if there are less horde than ali in bg - break;
if (!m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount())
{
if (aliFree <= diffHorde + 1)
break;
{ break; }
m_SelectionPools[TEAM_INDEX_HORDE].KickGroup(diffHorde - diffAli);
}
}
@ -578,12 +578,12 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId
if (m_SelectionPools[TEAM_INDEX_HORDE].KickGroup(diffAli - diffHorde))
{
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_INDEX_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0); ++hordeIndex)
++Horde_itr;
{ ++Horde_itr; }
}
if (!m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount())
{
if (hordeFree <= diffAli + 1)
break;
{ break; }
m_SelectionPools[TEAM_INDEX_ALLIANCE].KickGroup(diffAli - diffHorde);
}
}
@ -606,10 +606,10 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint
GroupsQueueType::const_iterator ali_group, horde_group;
for (ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group)
if (!(*ali_group)->IsInvitedToBGInstanceGUID)
break;
{ break; }
for (horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group)
if (!(*horde_group)->IsInvitedToBGInstanceGUID)
break;
{ break; }
if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end())
{
@ -624,7 +624,7 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint
{
// if itr can join BG and player count is less that maxPlayers, then add group to selectionpool
if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers))
break;
{ break; }
}
}
// premade selection pools are set
@ -666,16 +666,16 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround
{
m_SelectionPools[i].AddGroup(*(itr_team[i]), maxPlayers);
if (m_SelectionPools[i].GetPlayerCount() >= minPlayers)
break;
{ break; }
}
}
}
// try to invite same number of players - this cycle may cause longer wait time even if there are enough players in queue, but we want ballanced bg
uint32 j = TEAM_INDEX_ALLIANCE;
if (m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount())
j = TEAM_INDEX_HORDE;
{ j = TEAM_INDEX_HORDE; }
if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) != 0
&& m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() >= minPlayers)
&& m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() >= minPlayers)
{
// we will try to invite more groups to team with less players indexed by j
++(itr_team[j]); // this will not cause a crash, because for cycle above reached break;
@ -683,15 +683,15 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround
{
if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID)
if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % PVP_TEAM_COUNT].GetPlayerCount()))
break;
{ break; }
}
// do not allow to start bg with more than 2 players more on 1 faction
if (abs((int32)(m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() - m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount())) > 2)
return false;
{ return false; }
}
// allow 1v0 if debug bg
if (sBattleGroundMgr.isTesting() && bg_template->isBattleGround() && (m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount()))
return true;
{ return true; }
// return true if there are enough players in selection pools - enable to work .debug bg command correctly
return m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() >= minPlayers;
}
@ -765,10 +765,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
// ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_Lock);
// if no players in queue - do nothing
if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
return;
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
{ return; }
// battleground with free slot for player should be always in the beggining of the queue
// maybe it would be better to create bgfreeslotqueue for each bracket_id
@ -779,7 +779,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
++next;
// DO NOT allow queue manager to invite new player to arena
if ((*itr)->isBattleGround() && (*itr)->GetTypeID() == bgTypeId && (*itr)->GetBracketId() == bracket_id &&
(*itr)->GetStatus() > STATUS_WAIT_QUEUE && (*itr)->GetStatus() < STATUS_WAIT_LEAVE)
(*itr)->GetStatus() > STATUS_WAIT_QUEUE && (*itr)->GetStatus() < STATUS_WAIT_LEAVE)
{
BattleGround* bg = *itr; // we have to store battleground pointer here, because when battleground is full, it is removed from free queue (not yet implemented!!)
// and iterator is invalid
@ -793,9 +793,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
// now everything is set, invite players
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_INDEX_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_INDEX_ALLIANCE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg, (*citr)->GroupTeam);
{ InviteGroupToBG((*citr), bg, (*citr)->GroupTeam); }
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_INDEX_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_INDEX_HORDE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg, (*citr)->GroupTeam);
{ InviteGroupToBG((*citr), bg, (*citr)->GroupTeam); }
if (!bg->HasFreeSlots())
{
@ -825,7 +825,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam();
uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam();
if (sBattleGroundMgr.isTesting())
MinPlayersPerTeam = 1;
{ MinPlayersPerTeam = 1; }
if (bg_template->isArena())
{
if (sBattleGroundMgr.isArenaTesting())
@ -868,13 +868,13 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
BattleGround* bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, ARENA_TYPE_NONE, false);
if (!bg2)
{
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
sLog.outError("BattleGroundQueue::Update - Can not create battleground: %u", bgTypeId);
return;
}
// invite those selection pools
for (uint8 i = 0; i < PVP_TEAM_COUNT; ++i)
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_INDEX_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_INDEX_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam);
{ InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); }
// start bg
bg2->StartBattleGround();
// clear structures
@ -894,14 +894,14 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI
BattleGround* bg2 = sBattleGroundMgr.CreateNewBattleGround(bgTypeId, bracketEntry, arenaType, false);
if (!bg2)
{
sLog.outError("BattleGroundQueue::Update - Cannot create battleground: %u", bgTypeId);
sLog.outError("BattleGroundQueue::Update - Can not create battleground: %u", bgTypeId);
return;
}
// invite those selection pools
for (uint8 i = 0; i < PVP_TEAM_COUNT; ++i)
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_INDEX_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_INDEX_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam);
{ InviteGroupToBG((*citr), bg2, (*citr)->GroupTeam); }
// start bg
bg2->StartBattleGround();
}
@ -1051,12 +1051,12 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Player* plr = sObjectMgr.GetPlayer(m_PlayerGuid);
// player logged off (we should do nothing, he is correctly removed from queue in another procedure)
if (!plr)
return true;
{ return true; }
BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
// if battleground ended and its instance deleted - do nothing
if (!bg)
return true;
{ return true; }
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType());
uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId);
@ -1094,7 +1094,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Player* plr = sObjectMgr.GetPlayer(m_PlayerGuid);
if (!plr)
// player logged off (we should do nothing, he is correctly removed from queue in another procedure)
return true;
{ return true; }
BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
// battleground can be deleted already when we are removing queue info
@ -1137,9 +1137,7 @@ void BGQueueRemoveEvent::Abort(uint64 /*e_time*/)
BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTesting(false)
{
for (uint8 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i)
{
m_BattleGrounds[i].clear();
}
{ m_BattleGrounds[i].clear(); }
m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER);
m_Testing = false;
}
@ -1239,7 +1237,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket* data, BattleGro
data->WriteGuidBytes<0, 4>(playerGuid);
break;
}
case STATUS_WAIT_QUEUE:
case STATUS_WAIT_QUEUE: // status_in_queue
{
data->Initialize(SMSG_BATTLEFIELD_STATUS_QUEUED);
@ -1285,7 +1283,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket* data, BattleGro
data->WriteGuidBytes<4>(playerGuid);
break;
}
case STATUS_WAIT_JOIN:
case STATUS_WAIT_JOIN: // status_invite
{
data->Initialize(SMSG_BATTLEFIELD_STATUS_NEEDCONFIRMATION, 44);
@ -1672,7 +1670,7 @@ BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 insta
// SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id
BattleGround* bg = GetBattleGroundTemplate(bgTypeId);
if (!bg)
return NULL;
{ return NULL; }
if (bg->isArena())
return GetBattleGround(instanceId, bgTypeId);
@ -1680,7 +1678,7 @@ BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 insta
for (BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr)
{
if (itr->second->GetClientInstanceID() == instanceId)
return itr->second;
{ return itr->second; }
}
return NULL;
}
@ -1695,7 +1693,7 @@ BattleGround* BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTy
{
itr = m_BattleGrounds[i].find(InstanceID);
if (itr != m_BattleGrounds[i].end())
return itr->second;
{ return itr->second; }
}
return NULL;
}
@ -1725,7 +1723,7 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI
for (ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();)
{
if ((++lastId) != *itr) // if there is a gap between the ids, we will break..
break;
{ break; }
lastId = *itr;
}
ids.insert(lastId + 1);
@ -1973,7 +1971,7 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
// sLog.outDetail("Creating battleground %s, %u-%u", bl->name[sWorld.GetDBClang()], MinLvl, MaxLvl);
if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, bl->minLevel, bl->maxLevel, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3]))
continue;
{ continue; }
++count;
}
@ -2062,7 +2060,7 @@ void BattleGroundMgr::DistributeArenaPoints()
void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId)
{
if (!plr)
return;
{ return; }
BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
@ -2119,7 +2117,7 @@ void BattleGroundMgr::SendToBattleGround(Player* pl, uint32 instanceId, BattleGr
float x, y, z, O;
Team team = pl->GetBGTeam();
if (team == 0)
team = pl->GetTeam();
{ team = pl->GetTeam(); }
bg->GetTeamStartLoc(team, x, y, z, O);
DETAIL_LOG("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O);
@ -2239,9 +2237,9 @@ void BattleGroundMgr::ToggleTesting()
{
m_Testing = !m_Testing;
if (m_Testing)
sWorld.SendWorldText(LANG_DEBUG_BG_ON);
{ sWorld.SendWorldText(LANG_DEBUG_BG_ON); }
else
sWorld.SendWorldText(LANG_DEBUG_BG_OFF);
{ sWorld.SendWorldText(LANG_DEBUG_BG_OFF); }
}
void BattleGroundMgr::ToggleArenaTesting()
@ -2268,7 +2266,7 @@ void BattleGroundMgr::ScheduleQueueUpdate(uint32 arenaRating, ArenaType arenaTyp
}
}
if (!found)
m_QueueUpdateScheduler.push_back(schedule_id);
{ m_QueueUpdateScheduler.push_back(schedule_id); }
}
uint32 BattleGroundMgr::GetMaxRatingDifference() const
@ -2302,9 +2300,8 @@ void BattleGroundMgr::LoadBattleMastersEntry()
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded 0 battlemaster entries - table is empty!");
sLog.outString();
return;
}
@ -2331,8 +2328,8 @@ void BattleGroundMgr::LoadBattleMastersEntry()
delete result;
sLog.outString();
sLog.outString(">> Loaded %u battlemaster entries", count);
sLog.outString();
}
HolidayIds BattleGroundMgr::BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId)
@ -2420,9 +2417,8 @@ void BattleGroundMgr::LoadBattleEventIndexes()
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outErrorDb(">> Loaded 0 battleground eventindexes.");
sLog.outString();
return;
}
@ -2433,7 +2429,7 @@ void BattleGroundMgr::LoadBattleEventIndexes()
bar.step();
Field* fields = result->Fetch();
if (fields[2].GetUInt8() == BG_EVENT_NONE || fields[3].GetUInt8() == BG_EVENT_NONE)
continue; // we don't need to add those to the eventmap
{ continue; } // we don't need to add those to the eventmap
bool gameobject = (fields[0].GetUInt8() == 1);
uint32 dbTableGuidLow = fields[1].GetUInt32();
@ -2473,15 +2469,15 @@ void BattleGroundMgr::LoadBattleEventIndexes()
}
if (gameobject)
m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events;
{ m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events; }
else
m_CreatureBattleEventIndexMap[dbTableGuidLow] = events;
{ m_CreatureBattleEventIndexMap[dbTableGuidLow] = events; }
++count;
}
while (result->NextRow());
sLog.outString();
sLog.outString(">> Loaded %u battleground eventindexes", count);
sLog.outString();
delete result;
}

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef __BATTLEGROUNDMGR_H
#define __BATTLEGROUNDMGR_H
#ifndef MANGOS_H_BATTLEGROUNDMGR
#define MANGOS_H_BATTLEGROUNDMGR
#include "Common.h"
#include "Policies/Singleton.h"
@ -35,42 +35,77 @@
#include <mutex>
/**
* @brief
*
*/
typedef std::map<uint32, BattleGround*> BattleGroundSet;
// this container can't be deque, because deque doesn't like removing the last element - if you remove it, it invalidates next iterator and crash appears
/**
* @brief this container can't be deque, because deque doesn't like removing the last element - if you remove it, it invalidates next iterator and crash appears
*
*/
typedef std::list<BattleGround*> BGFreeSlotQueueType;
/**
* @brief
*
*/
typedef UNORDERED_MAP<uint32, BattleGroundTypeId> BattleMastersMap;
/**
* @brief
*
*/
typedef UNORDERED_MAP<uint32, BattleGroundEventIdx> CreatureBattleEventIndexesMap;
/**
* @brief
*
*/
typedef UNORDERED_MAP<uint32, BattleGroundEventIdx> GameObjectBattleEventIndexesMap;
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
#define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10
struct GroupQueueInfo; // type predefinition
struct PlayerQueueInfo // stores information for players in queue
/**
* @brief stores information for players in queue
*
*/
struct PlayerQueueInfo
{
uint32 LastOnlineTime; // for tracking and removing offline players from queue after 5 minutes
GroupQueueInfo* GroupInfo; // pointer to the associated groupqueueinfo
uint32 LastOnlineTime; /**< for tracking and removing offline players from queue after 5 minutes */
GroupQueueInfo* GroupInfo; /**< pointer to the associated groupqueueinfo */
};
/**
* @brief
*
*/
typedef std::map<ObjectGuid, PlayerQueueInfo*> GroupQueueInfoPlayers;
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
/**
* @brief stores information about the group in queue (also used when joined as solo!)
*
*/
struct GroupQueueInfo
{
GroupQueueInfoPlayers Players; // player queue info map
Team GroupTeam; // Player team (ALLIANCE/HORDE)
BattleGroundTypeId BgTypeId; // battleground type id
GroupQueueInfoPlayers Players; /**< player queue info map */
Team GroupTeam; /**< Player team (ALLIANCE/HORDE) */
BattleGroundTypeId BgTypeId; /**< battleground type id */
bool IsRated; // rated
ArenaType arenaType; // 2v2, 3v3, 5v5 or 0 when BG
uint32 ArenaTeamId; // team id if rated match
uint32 JoinTime; // time when group was added
uint32 RemoveInviteTime; // time when we will remove invite for players in group
uint32 IsInvitedToBGInstanceGUID; // was invited to certain BG
uint32 JoinTime; /**< time when group was added */
uint32 RemoveInviteTime; /**< time when we will remove invite for players in group */
uint32 IsInvitedToBGInstanceGUID; /**< was invited to certain BG */
uint32 ArenaTeamRating; // if rated match, inited to the rating of the team
uint32 OpponentsTeamRating; // for rated arena matches
};
/**
* @brief
*
*/
enum BattleGroundQueueGroupTypes
{
BG_QUEUE_PREMADE_ALLIANCE = 0,
@ -81,33 +116,99 @@ enum BattleGroundQueueGroupTypes
#define BG_QUEUE_GROUP_TYPES_COUNT 4
class BattleGround;
/**
* @brief
*
*/
class BattleGroundQueue
{
public:
/**
* @brief
*
*/
BattleGroundQueue();
/**
* @brief
*
*/
~BattleGroundQueue();
void Update(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, ArenaType arenaType = ARENA_TYPE_NONE, bool isRated = false, uint32 minRating = 0);
/**
* @brief
*
* @param bg
* @param bracket_id
*/
void FillPlayersToBG(BattleGround* bg, BattleGroundBracketId bracket_id);
/**
* @brief
*
* @param bracket_id
* @param MinPlayersPerTeam
* @param MaxPlayersPerTeam
* @return bool
*/
bool CheckPremadeMatch(BattleGroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
bool CheckNormalMatch(BattleGround* bg_template, BattleGroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
bool CheckSkirmishForSameFaction(BattleGroundBracketId bracket_id, uint32 minPlayersPerTeam);
GroupQueueInfo* AddGroup(Player* leader, Group* group, BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 ArenaTeamId = 0);
/**
* @brief
*
* @param guid
* @param decreaseInvitedCount
*/
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount);
/**
* @brief
*
* @param pl_guid
* @param bgInstanceGuid
* @param removeTime
* @return bool
*/
bool IsPlayerInvited(ObjectGuid pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime);
/**
* @brief
*
* @param guid
* @param ginfo
* @return bool
*/
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo);
/**
* @brief
*
* @param ginfo
* @param bracket_id
*/
void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id);
/**
* @brief
*
* @param ginfo
* @param bracket_id
* @return uint32
*/
uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id);
private:
// mutex that should not allow changing private data, nor allowing to update Queue during private data change.
ACE_Recursive_Thread_Mutex m_Lock;
ACE_Recursive_Thread_Mutex m_Lock; /**< mutex that should not allow changing private data, nor allowing to update Queue during private data change. */
/**
* @brief
*
*/
typedef std::map<ObjectGuid, PlayerQueueInfo> QueuedPlayersMap;
QueuedPlayersMap m_QueuedPlayers;
QueuedPlayersMap m_QueuedPlayers; /**< TODO */
// we need constant add to begin and constant remove / add from the end, therefore deque suits our problem well
/**
* @brief we need constant add to begin and constant remove / add from the end, therefore deque suits our problem well
*
*/
typedef std::list<GroupQueueInfo*> GroupsQueueType;
/*
@ -119,35 +220,72 @@ class BattleGroundQueue
BG_QUEUE_NORMAL_ALLIANCE is used for normal (or small) alliance groups or non-rated arena matches
BG_QUEUE_NORMAL_HORDE is used for normal (or small) horde groups or non-rated arena matches
*/
GroupsQueueType m_QueuedGroups[MAX_BATTLEGROUND_BRACKETS][BG_QUEUE_GROUP_TYPES_COUNT];
GroupsQueueType m_QueuedGroups[MAX_BATTLEGROUND_BRACKETS][BG_QUEUE_GROUP_TYPES_COUNT]; /**< TODO */
// class to select and invite groups to bg
/**
* @brief class to select and invite groups to bg
*
*/
class SelectionPool
{
public:
/**
* @brief
*
* Constructor
*/
SelectionPool() : PlayerCount(0) {}
/**
* @brief
*
*/
void Init();
/**
* @brief
*
* @param ginfo
* @param desiredCount
* @return bool
*/
bool AddGroup(GroupQueueInfo* ginfo, uint32 desiredCount);
/**
* @brief
*
* @param size
* @return bool
*/
bool KickGroup(uint32 size);
/**
* @brief
*
* @return uint32
*/
uint32 GetPlayerCount() const {return PlayerCount;}
GroupsQueueType SelectedGroups;
GroupsQueueType SelectedGroups; /**< TODO */
private:
uint32 PlayerCount;
uint32 PlayerCount; /**< TODO */
};
// one selection pool for horde, other one for alliance
SelectionPool m_SelectionPools[PVP_TEAM_COUNT];
SelectionPool m_SelectionPools[PVP_TEAM_COUNT]; /**< one selection pool for horde, other one for alliance */
/**
* @brief
*
* @param ginfo
* @param bg
* @param side
* @return bool
*/
bool InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, Team side);
uint32 m_WaitTimes[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME];
uint32 m_WaitTimeLastPlayer[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS];
uint32 m_SumOfWaitTimes[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS];
uint32 m_WaitTimes[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME]; /**< TODO */
uint32 m_WaitTimeLastPlayer[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS]; /**< TODO */
uint32 m_SumOfWaitTimes[PVP_TEAM_COUNT][MAX_BATTLEGROUND_BRACKETS]; /**< TODO */
};
/*
This class is used to invite player to BG again, when minute lasts from his first invitation
it is capable to solve all possibilities
*/
/**
* @brief This class is used to invite player to BG again, when minute lasts from his first invitation it is capable to solve all possibilities
*
*/
class BGQueueInviteEvent : public BasicEvent
{
public:
@ -155,87 +293,247 @@ class BGQueueInviteEvent : public BasicEvent
m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime)
{
};
/**
* @brief
*
*/
virtual ~BGQueueInviteEvent() {};
/**
* @brief
*
* @param e_time
* @param p_time
* @return bool
*/
virtual bool Execute(uint64 e_time, uint32 p_time) override;
/**
* @brief
*
* @param e_time
*/
virtual void Abort(uint64 e_time) override;
private:
ObjectGuid m_PlayerGuid;
uint32 m_BgInstanceGUID;
BattleGroundTypeId m_BgTypeId;
ObjectGuid m_PlayerGuid; /**< TODO */
uint32 m_BgInstanceGUID; /**< TODO */
BattleGroundTypeId m_BgTypeId; /**< TODO */
ArenaType m_ArenaType;
uint32 m_RemoveTime;
uint32 m_RemoveTime; /**< TODO */
};
/*
This class is used to remove player from BG queue after 1 minute 20 seconds from first invitation
We must store removeInvite time in case player left queue and joined and is invited again
We must store bgQueueTypeId, because battleground can be deleted already, when player entered it
*/
/**
* @brief This class is used to remove player from BG queue after 1 minute 20 seconds from first invitation
*
* We must store removeInvite time in case player left queue and joined and is invited again
* We must store bgQueueTypeId, because battleground can be deleted already, when player entered it
*
*/
class BGQueueRemoveEvent : public BasicEvent
{
public:
/**
* @brief
*
* @param plGuid
* @param bgInstanceGUID
* @param BgTypeId
* @param bgQueueTypeId
* @param removeTime
*/
BGQueueRemoveEvent(ObjectGuid plGuid, uint32 bgInstanceGUID, BattleGroundTypeId BgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 removeTime)
: m_PlayerGuid(plGuid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId)
{}
/**
* @brief
*
*/
virtual ~BGQueueRemoveEvent() {}
/**
* @brief
*
* @param e_time
* @param p_time
* @return bool
*/
virtual bool Execute(uint64 e_time, uint32 p_time) override;
/**
* @brief
*
* @param e_time
*/
virtual void Abort(uint64 e_time) override;
private:
ObjectGuid m_PlayerGuid;
uint32 m_BgInstanceGUID;
uint32 m_RemoveTime;
BattleGroundTypeId m_BgTypeId;
BattleGroundQueueTypeId m_BgQueueTypeId;
ObjectGuid m_PlayerGuid; /**< TODO */
uint32 m_BgInstanceGUID; /**< TODO */
uint32 m_RemoveTime; /**< TODO */
BattleGroundTypeId m_BgTypeId; /**< TODO */
BattleGroundQueueTypeId m_BgQueueTypeId; /**< TODO */
};
/**
* @brief
*
*/
class BattleGroundMgr
{
public:
/* Construction */
/**
* @brief Construction
*
*/
BattleGroundMgr();
/**
* @brief
*
*/
~BattleGroundMgr();
/**
* @brief
*
* @param diff
*/
void Update(uint32 diff);
/* Packet Building */
/**
* @brief
*
* @param data
* @param plr
*/
void BuildPlayerJoinedBattleGroundPacket(WorldPacket* data, Player* plr);
/**
* @brief
*
* @param data
* @param guid
*/
void BuildPlayerLeftBattleGroundPacket(WorldPacket* data, ObjectGuid guid);
/**
* @brief
*
* @param data
* @param guid
* @param plr
* @param bgTypeId
*/
void BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId);
/**
* @brief
*
* @param data
* @param field
* @param value
*/
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
/**
* @brief
*
* @param data
* @param bg
*/
void BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg);
void BuildBattleGroundStatusPacket(WorldPacket* data, BattleGround* bg, Player* player, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype);
void BuildBattleGroundStatusFailedPacket(WorldPacket* data, BattleGround* bg, Player* player, uint8 QueueSlot, GroupJoinBattlegroundResult result);
/**
* @brief
*
* @param data
* @param soundid
*/
void BuildPlaySoundPacket(WorldPacket* data, uint32 soundid);
/* Battlegrounds */
/**
* @brief
*
* @param instanceId
* @param bgTypeId
* @return BattleGround
*/
BattleGround* GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId);
/**
* @brief
*
* @param InstanceID
* @param bgTypeId
* @return BattleGround
*/
BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); // there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
/**
* @brief
*
* @param bgTypeId
* @return BattleGround
*/
BattleGround* GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
BattleGround* CreateNewBattleGround(BattleGroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, ArenaType arenaType, bool isRated);
uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char const* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO);
/**
* @brief
*
* @param InstanceID
* @param bgTypeId
* @param BG
*/
void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
/**
* @brief
*
* @param instanceID
* @param bgTypeId
*/
void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
/**
* @brief
*
* @param bgTypeId
* @param bracket_id
* @return uint32
*/
uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
/**
* @brief
*
* @param bgTypeId
* @param bracket_id
* @param clientInstanceID
*/
void DeleteClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, uint32 clientInstanceID)
{
m_ClientBattleGroundIds[bgTypeId][bracket_id].erase(clientInstanceID);
}
/**
* @brief
*
*/
void CreateInitialBattleGrounds();
/**
* @brief
*
*/
void DeleteAllBattleGrounds();
/**
* @brief
*
* @param pl
* @param InstanceID
* @param bgTypeId
*/
void SendToBattleGround(Player* pl, uint32 InstanceID, BattleGroundTypeId bgTypeId);
/* Battleground queues */
// these queues are instantiated when creating BattlegroundMrg
BattleGroundQueue m_BattleGroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; // public, because we need to access them in BG handler code
BattleGroundQueue m_BattleGroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES]; /**< public, because we need to access them in BG handler code */
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
BGFreeSlotQueueType BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID]; /**< TODO */
void ScheduleQueueUpdate(uint32 arenaRating, ArenaType arenaType, BattleGroundQueueTypeId bgQueueTypeId, BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id);
uint32 GetMaxRatingDifference() const;
@ -245,61 +543,125 @@ class BattleGroundMgr
void InitAutomaticArenaPointDistribution();
// void DistributeArenaPoints(); // there does not appear to be a way to do this in Three
void ToggleArenaTesting();
/**
* @brief
*
*/
void ToggleTesting();
/**
* @brief
*
*/
void LoadBattleMastersEntry();
/**
* @brief
*
* @param entry
* @return BattleGroundTypeId
*/
BattleGroundTypeId GetBattleMasterBG(uint32 entry) const
{
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
if (itr != mBattleMastersMap.end())
return itr->second;
{ return itr->second; }
return BATTLEGROUND_TYPE_NONE;
}
/**
* @brief
*
*/
void LoadBattleEventIndexes();
/**
* @brief
*
* @param dbTableGuidLow
* @return const BattleGroundEventIdx
*/
const BattleGroundEventIdx GetCreatureEventIndex(uint32 dbTableGuidLow) const
{
CreatureBattleEventIndexesMap::const_iterator itr = m_CreatureBattleEventIndexMap.find(dbTableGuidLow);
if (itr != m_CreatureBattleEventIndexMap.end())
return itr->second;
{ return itr->second; }
return m_CreatureBattleEventIndexMap.find(-1)->second;
}
/**
* @brief
*
* @param dbTableGuidLow
* @return const BattleGroundEventIdx
*/
const BattleGroundEventIdx GetGameObjectEventIndex(uint32 dbTableGuidLow) const
{
GameObjectBattleEventIndexesMap::const_iterator itr = m_GameObjectBattleEventIndexMap.find(dbTableGuidLow);
if (itr != m_GameObjectBattleEventIndexMap.end())
return itr->second;
{ return itr->second; }
return m_GameObjectBattleEventIndexMap.find(-1)->second;
}
bool isArenaTesting() const { return m_ArenaTesting; }
/**
* @brief
*
* @return bool
*/
bool isTesting() const { return m_Testing; }
static bool IsArenaType(BattleGroundTypeId bgTypeId);
static bool IsBattleGroundType(BattleGroundTypeId bgTypeId) { return !IsArenaType(bgTypeId); }
static BattleGroundQueueTypeId BGQueueTypeId(BattleGroundTypeId bgTypeId, ArenaType arenaType);
/**
* @brief
*
* @param bgQueueTypeId
* @return BattleGroundTypeId
*/
static BattleGroundTypeId BGTemplateId(BattleGroundQueueTypeId bgQueueTypeId);
static ArenaType BGArenaType(BattleGroundQueueTypeId bgQueueTypeId);
/**
* @brief
*
* @param bgTypeId
* @return HolidayIds
*/
static HolidayIds BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId);
/**
* @brief
*
* @param holiday
* @return BattleGroundTypeId
*/
static BattleGroundTypeId WeekendHolidayIdToBGType(HolidayIds holiday);
/**
* @brief
*
* @param bgTypeId
* @return bool
*/
static bool IsBGWeekend(BattleGroundTypeId bgTypeId);
private:
ACE_Thread_Mutex SchedulerLock;
BattleMastersMap mBattleMastersMap;
CreatureBattleEventIndexesMap m_CreatureBattleEventIndexMap;
GameObjectBattleEventIndexesMap m_GameObjectBattleEventIndexMap;
ACE_Thread_Mutex SchedulerLock; /**< TODO */
BattleMastersMap mBattleMastersMap; /**< TODO */
CreatureBattleEventIndexesMap m_CreatureBattleEventIndexMap; /**< TODO */
GameObjectBattleEventIndexesMap m_GameObjectBattleEventIndexMap; /**< TODO */
/* Battlegrounds */
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID]; /**< TODO */
std::vector<uint64> m_QueueUpdateScheduler;
/**
* @brief
*
*/
typedef std::set<uint32> ClientBattleGroundIdSet;
ClientBattleGroundIdSet m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; // the instanceids just visible for the client
ClientBattleGroundIdSet m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; /**< the instanceids just visible for the client */
uint32 m_NextRatingDiscardUpdate;
time_t m_NextAutoDistributionTime;
uint32 m_AutoDistributionTimeChecker;
bool m_ArenaTesting;
bool m_Testing;
bool m_Testing; /**< TODO */
};
#define sBattleGroundMgr MaNGOS::Singleton<BattleGroundMgr>::Instance()

View file

@ -164,21 +164,21 @@ void BattleGroundWS::RespawnFlag(Team team, bool captured)
void BattleGroundWS::RespawnDroppedFlag(Team team)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
RespawnFlag(team, false);
if (team == ALLIANCE)
SendMessageToAll(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL);
{ SendMessageToAll(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); }
else
SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL);
{ SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); }
PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED);
GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid(team));
if (obj)
obj->Delete();
{ obj->Delete(); }
else
sLog.outError("Unknown dropped flag bg: %s", GetDroppedFlagGuid(team).GetString().c_str());
{ sLog.outError("Unknown dropped flag bg: %s", GetDroppedFlagGuid(team).GetString().c_str()); }
ClearDroppedFlagGuid(team);
}
@ -186,7 +186,7 @@ void BattleGroundWS::RespawnDroppedFlag(Team team)
void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
m_LastCapturedFlagTeam = source->GetTeam();
@ -194,28 +194,28 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedUp())
return;
{ return; }
ClearHordeFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// horde flag in base (but not respawned yet)
m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Horde Flag from Player
source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
if (m_TeamScores[TEAM_INDEX_ALLIANCE] < BG_WS_MAX_TEAM_SCORE)
m_TeamScores[TEAM_INDEX_ALLIANCE] += 1;
{ m_TeamScores[TEAM_INDEX_ALLIANCE] += 1; }
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
}
else
{
if (!IsAllianceFlagPickedUp())
return;
{ return; }
ClearAllianceFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// alliance flag in base (but not respawned yet)
m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
// Drop Alliance Flag from Player
source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
if (m_TeamScores[TEAM_INDEX_HORDE] < BG_WS_MAX_TEAM_SCORE)
m_TeamScores[TEAM_INDEX_HORDE] += 1;
{ m_TeamScores[TEAM_INDEX_HORDE] += 1; }
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
RewardReputationToTeam(889, m_ReputationCapture, HORDE);
}
@ -227,9 +227,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
SpawnEvent(WS_EVENT_FLAG_H, 0, false);
if (source->GetTeam() == ALLIANCE)
SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source);
{ SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); }
else
SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source);
{ SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source); }
UpdateFlagState(source->GetTeam(), 1); // flag state none
UpdateTeamScore(source->GetTeam());
@ -238,9 +238,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source)
Team winner = TEAM_NONE;
if (m_TeamScores[TEAM_INDEX_ALLIANCE] == BG_WS_MAX_TEAM_SCORE)
winner = ALLIANCE;
{ winner = ALLIANCE; }
else if (m_TeamScores[TEAM_INDEX_HORDE] == BG_WS_MAX_TEAM_SCORE)
winner = HORDE;
{ winner = HORDE; }
if (winner)
{
@ -266,7 +266,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedUp())
return;
{ return; }
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
{
ClearHordeFlagCarrier();
@ -276,7 +276,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
else
{
if (!IsAllianceFlagPickedUp())
return;
{ return; }
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
{
ClearAllianceFlagCarrier();
@ -291,7 +291,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
if (source->GetTeam() == ALLIANCE)
{
if (!IsHordeFlagPickedUp())
return;
{ return; }
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
{
ClearHordeFlagCarrier();
@ -304,7 +304,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
else
{
if (!IsAllianceFlagPickedUp())
return;
{ return; }
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
{
ClearAllianceFlagCarrier();
@ -338,7 +338,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source)
void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
int32 message_id = 0;
ChatMsg type;
@ -347,7 +347,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
// alliance flag picked up from base
if (source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE
&& event == WS_EVENT_FLAG_A)
&& event == WS_EVENT_FLAG_A)
{
message_id = LANG_BG_WS_PICKEDUP_AF;
type = CHAT_MSG_BG_SYSTEM_HORDE;
@ -363,7 +363,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
// horde flag picked up from base
if (source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE
&& event == WS_EVENT_FLAG_H)
&& event == WS_EVENT_FLAG_H)
{
message_id = LANG_BG_WS_PICKEDUP_HF;
type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
@ -434,7 +434,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target
}
if (!message_id)
return;
{ return; }
SendMessageToAll(message_id, type, source);
source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
@ -452,7 +452,7 @@ void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid)
RespawnFlag(ALLIANCE, false);
}
else
EventPlayerDroppedFlag(plr);
{ EventPlayerDroppedFlag(plr); }
}
if (IsHordeFlagPickedUp() && m_flagCarrierHorde == guid)
{
@ -463,16 +463,16 @@ void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid)
RespawnFlag(HORDE, false);
}
else
EventPlayerDroppedFlag(plr);
{ EventPlayerDroppedFlag(plr); }
}
}
void BattleGroundWS::UpdateFlagState(Team team, uint32 value)
{
if (team == ALLIANCE)
UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value);
{ UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value); }
else
UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value);
{ UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value); }
}
void BattleGroundWS::UpdateTeamScore(Team team)
@ -487,19 +487,19 @@ bool BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger)
{
// this is wrong way to implement these things. On official it done by gameobject spell cast.
if (GetStatus() != STATUS_IN_PROGRESS)
return false;
{ return false; }
switch (trigger)
{
case 3646: // Alliance Flag spawn
if (m_FlagState[TEAM_INDEX_HORDE] && !m_FlagState[TEAM_INDEX_ALLIANCE])
if (GetHordeFlagCarrierGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
{ EventPlayerCapturedFlag(source); }
break;
case 3647: // Horde Flag spawn
if (m_FlagState[TEAM_INDEX_ALLIANCE] && !m_FlagState[TEAM_INDEX_HORDE])
if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid())
EventPlayerCapturedFlag(source);
{ EventPlayerCapturedFlag(source); }
break;
default:
return false;
@ -553,7 +553,7 @@ void BattleGroundWS::EndBattleGround(Team winner)
void BattleGroundWS::HandleKillPlayer(Player* player, Player* killer)
{
if (GetStatus() != STATUS_IN_PROGRESS)
return;
{ return; }
EventPlayerDroppedFlag(player);
@ -564,7 +564,7 @@ void BattleGroundWS::UpdatePlayerScore(Player* source, uint32 type, uint32 value
{
BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid());
if (itr == m_PlayerScores.end()) // player not found
return;
{ return; }
switch (type)
{
@ -590,16 +590,16 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player)
if (player->GetTeam() == ALLIANCE)
{
if (GetStatus() == STATUS_IN_PROGRESS)
return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE);
{ return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE); }
else
return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE);
{ return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE); }
}
else
{
if (GetStatus() == STATUS_IN_PROGRESS)
return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE);
{ return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE); }
else
return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE);
{ return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE); }
}
}
@ -609,30 +609,30 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count)
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[TEAM_INDEX_HORDE]);
if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, -1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, -1); }
else if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 1); }
else
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 0);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 0); }
if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, -1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, -1); }
else if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 1); }
else
FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 0);
{ FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 0); }
FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_MAX, BG_WS_MAX_TEAM_SCORE);
if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 2);
{ FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 2); }
else
FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 1); }
if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 2);
{ FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 2); }
else
FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1);
{ FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); }
FillInitialWorldState(data, count, BG_WS_TIME_ENABLED, WORLD_STATE_ADD);
FillInitialWorldState(data, count, BG_WS_TIME_REMAINING, GetRemainingTimeInMinutes());
@ -644,9 +644,9 @@ Team BattleGroundWS::GetPrematureWinner()
int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
if (hordeScore > allianceScore)
return HORDE;
{ return HORDE; }
if (allianceScore > hordeScore)
return ALLIANCE;
{ return ALLIANCE; }
// If the values are equal, fall back to number of players on each team
return BattleGround::GetPrematureWinner();

View file

@ -22,8 +22,8 @@
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/
#ifndef __BATTLEGROUNDWS_H
#define __BATTLEGROUNDWS_H
#ifndef MANGOS_H_BATTLEGROUNDWS
#define MANGOS_H_BATTLEGROUNDWS
#include "BattleGround.h"
@ -33,6 +33,10 @@
#define BG_WS_TIME_LIMIT (25*MINUTE*IN_MILLISECONDS)
#define BG_WS_EVENT_START_BATTLE 8563
/**
* @brief
*
*/
enum BG_WS_Sound
{
BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE = 8173,
@ -44,6 +48,10 @@ enum BG_WS_Sound
BG_WS_SOUND_FLAGS_RESPAWNED = 8232
};
/**
* @brief
*
*/
enum BG_WS_SpellId
{
BG_WS_SPELL_WARSONG_FLAG = 23333,
@ -52,11 +60,15 @@ enum BG_WS_SpellId
BG_WS_SPELL_SILVERWING_FLAG_DROPPED = 23336
};
/**
* @brief
*
*/
enum BG_WS_WorldStates
{
BG_WS_FLAG_UNK_ALLIANCE = 1545,
BG_WS_FLAG_UNK_HORDE = 1546,
// FLAG_UNK = 1547,
// BG_FLAG_UNK = 1547,
BG_WS_FLAG_CAPTURES_ALLIANCE = 1581,
BG_WS_FLAG_CAPTURES_HORDE = 1582,
BG_WS_FLAG_CAPTURES_MAX = 1601,
@ -66,6 +78,10 @@ enum BG_WS_WorldStates
BG_WS_TIME_REMAINING = 4248
};
/**
* @brief
*
*/
enum BG_WS_FlagState
{
BG_WS_FLAG_STATE_ON_BASE = 0,
@ -74,6 +90,10 @@ enum BG_WS_FlagState
BG_WS_FLAG_STATE_ON_GROUND = 3
};
/**
* @brief
*
*/
enum BG_WS_Graveyards
{
WS_GRAVEYARD_FLAGROOM_ALLIANCE = 769,
@ -82,19 +102,35 @@ enum BG_WS_Graveyards
WS_GRAVEYARD_MAIN_HORDE = 772
};
/**
* @brief
*
*/
class BattleGroundWGScore : public BattleGroundScore
{
public:
/**
* @brief
*
*/
BattleGroundWGScore() : FlagCaptures(0), FlagReturns(0) {};
/**
* @brief
*
*/
virtual ~BattleGroundWGScore() {};
uint32 GetAttr1() const { return FlagCaptures; }
uint32 GetAttr2() const { return FlagReturns; }
uint32 FlagCaptures;
uint32 FlagReturns;
uint32 FlagCaptures; /**< TODO */
uint32 FlagReturns; /**< TODO */
};
/**
* @brief
*
*/
enum BG_WS_Events
{
WS_EVENT_FLAG_A = 0,
@ -103,71 +139,238 @@ enum BG_WS_Events
WS_EVENT_SPIRITGUIDES_SPAWN = 2
};
/**
* @brief
*
*/
class BattleGroundWS : public BattleGround
{
friend class BattleGroundMgr;
public:
/* Construction */
/**
* @brief Construction
*
*/
BattleGroundWS();
/**
* @brief
*
* @param diff
*/
void Update(uint32 diff) override;
/* inherited from BattlegroundClass */
/**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override;
/**
* @brief
*
*/
virtual void StartingEventOpenDoors() override;
/* BG Flags */
/**
* @brief BG Flags
*
* @return ObjectGuid
*/
ObjectGuid GetAllianceFlagCarrierGuid() const { return m_flagCarrierAlliance; }
/**
* @brief
*
* @return ObjectGuid
*/
ObjectGuid GetHordeFlagCarrierGuid() const { return m_flagCarrierHorde; }
/**
* @brief
*
* @param guid
*/
void SetAllianceFlagCarrier(ObjectGuid guid) { m_flagCarrierAlliance = guid; }
/**
* @brief
*
* @param guid
*/
void SetHordeFlagCarrier(ObjectGuid guid) { m_flagCarrierHorde = guid; }
/**
* @brief
*
*/
void ClearAllianceFlagCarrier() { m_flagCarrierAlliance.Clear(); }
/**
* @brief
*
*/
void ClearHordeFlagCarrier() { m_flagCarrierHorde.Clear(); }
/**
* @brief
*
* @return bool
*/
bool IsAllianceFlagPickedUp() const { return !m_flagCarrierAlliance.IsEmpty(); }
/**
* @brief
*
* @return bool
*/
bool IsHordeFlagPickedUp() const { return !m_flagCarrierHorde.IsEmpty(); }
/**
* @brief
*
* @param team
* @param captured
*/
void RespawnFlag(Team team, bool captured);
/**
* @brief
*
* @param team
*/
void RespawnDroppedFlag(Team team);
/**
* @brief
*
* @param team
* @return uint8
*/
uint8 GetFlagState(Team team) { return m_FlagState[GetTeamIndexByTeamId(team)]; }
/* Battleground Events */
/**
* @brief Battleground Events
*
* @param source
*/
virtual void EventPlayerDroppedFlag(Player* source) override;
/**
* @brief
*
* @param source
* @param target_obj
*/
virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
/**
* @brief
*
* @param source
*/
virtual void EventPlayerCapturedFlag(Player* source) override;
/**
* @brief
*
* @param plr
* @param guid
*/
void RemovePlayer(Player* plr, ObjectGuid guid) override;
/**
* @brief
*
* @param source
* @param trigger
*/
bool HandleAreaTrigger(Player* source, uint32 trigger) override;
/**
* @brief
*
* @param player
* @param killer
*/
void HandleKillPlayer(Player* player, Player* killer) override;
/**
* @brief
*
*/
virtual void Reset() override;
/**
* @brief
*
* @param winner
*/
void EndBattleGround(Team winner) override;
/**
* @brief
*
* @param player
* @return const WorldSafeLocsEntry
*/
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer - 1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; }
/**
* @brief
*
* @param team
* @param value
*/
void UpdateFlagState(Team team, uint32 value);
/**
* @brief
*
* @param team
*/
void UpdateTeamScore(Team team);
/**
* @brief
*
* @param source
* @param type
* @param value
*/
void UpdatePlayerScore(Player* source, uint32 type, uint32 value) override;
/**
* @brief
*
* @param guid
* @param team
*/
void SetDroppedFlagGuid(ObjectGuid guid, Team team) { m_DroppedFlagGuid[GetTeamIndexByTeamId(team)] = guid;}
/**
* @brief
*
* @param team
*/
void ClearDroppedFlagGuid(Team team) { m_DroppedFlagGuid[GetTeamIndexByTeamId(team)].Clear();}
/**
* @brief
*
* @param team
* @return const ObjectGuid
*/
ObjectGuid const& GetDroppedFlagGuid(Team team) const { return m_DroppedFlagGuid[GetTeamIndexByTeamId(team)];}
/**
* @brief
*
* @param data
* @param count
*/
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/**
* @brief
*
*/
virtual Team GetPrematureWinner() override;
private:
ObjectGuid m_flagCarrierAlliance;
ObjectGuid m_flagCarrierHorde;
ObjectGuid m_flagCarrierAlliance; /**< TODO */
ObjectGuid m_flagCarrierHorde; /**< TODO */
ObjectGuid m_DroppedFlagGuid[PVP_TEAM_COUNT];
uint8 m_FlagState[PVP_TEAM_COUNT];
int32 m_FlagsTimer[PVP_TEAM_COUNT];
int32 m_FlagsDropTimer[PVP_TEAM_COUNT];
ObjectGuid m_DroppedFlagGuid[PVP_TEAM_COUNT]; /**< TODO */
uint8 m_FlagState[PVP_TEAM_COUNT]; /**< TODO */
int32 m_FlagsTimer[PVP_TEAM_COUNT]; /**< TODO */
int32 m_FlagsDropTimer[PVP_TEAM_COUNT]; /**< TODO */
uint32 m_ReputationCapture;
uint32 m_HonorWinKills;
uint32 m_HonorEndKills;
uint32 m_ReputationCapture; /**< TODO */
uint32 m_HonorWinKills; /**< TODO */
uint32 m_HonorEndKills; /**< TODO */
uint32 m_EndTimer;
Team m_LastCapturedFlagTeam;
};

View file

@ -178,8 +178,8 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
Player* player = itr->second;
AccountTypes security = player->GetSession()->GetSecurity();
if ((player->isGameMaster() || (security > SEC_PLAYER && security <= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_GM_LIST))) &&
(!m_session || player->IsVisibleGloballyFor(m_session->GetPlayer())))
names.push_back(std::make_pair<std::string, bool>(GetNameLink(player), player->isAcceptWhispers()));
(!m_session || player->IsVisibleGloballyFor(m_session->GetPlayer())))
{ names.push_back(std::make_pair<std::string, bool>(GetNameLink(player), player->isAcceptWhispers())); }
}
}
@ -190,10 +190,10 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/)
char const* accepts = GetMangosString(LANG_GM_ACCEPTS_WHISPER);
char const* not_accept = GetMangosString(LANG_GM_NO_WHISPER);
for (std::list<std::pair< std::string, bool> >::const_iterator iter = names.begin(); iter != names.end(); ++iter)
PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept);
{ PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept); }
}
else
SendSysMessage(LANG_GMS_NOT_LOGGED);
{ SendSysMessage(LANG_GMS_NOT_LOGGED); }
return true;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -41,28 +41,28 @@
bool ChatHandler::HandleDebugSendSpellFailCommand(char* args)
{
if (!*args)
return false;
{ return false; }
uint32 failnum;
if (!ExtractUInt32(&args, failnum) || failnum > 255)
return false;
{ return false; }
uint32 failarg1;
if (!ExtractOptUInt32(&args, failarg1, 0))
return false;
{ return false; }
uint32 failarg2;
if (!ExtractOptUInt32(&args, failarg2, 0))
return false;
{ return false; }
WorldPacket data(SMSG_CAST_FAILED, 5);
data << uint8(0);
data << uint32(133);
data << uint8(failnum);
if (failarg1 || failarg2)
data << uint32(failarg1);
{ data << uint32(failarg1); }
if (failarg2)
data << uint32(failarg2);
{ data << uint32(failarg2); }
m_session->SendPacket(&data);
@ -81,11 +81,11 @@ bool ChatHandler::HandleDebugSendPoiCommand(char* args)
uint32 icon;
if (!ExtractUInt32(&args, icon))
return false;
{ return false; }
uint32 flags;
if (!ExtractUInt32(&args, flags))
return false;
{ return false; }
DETAIL_LOG("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon, flags);
pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI");
@ -95,7 +95,7 @@ bool ChatHandler::HandleDebugSendPoiCommand(char* args)
bool ChatHandler::HandleDebugSendEquipErrorCommand(char* args)
{
if (!*args)
return false;
{ return false; }
uint8 msg = atoi(args);
m_session->GetPlayer()->SendEquipError(InventoryResult(msg), NULL, NULL);
@ -105,7 +105,7 @@ bool ChatHandler::HandleDebugSendEquipErrorCommand(char* args)
bool ChatHandler::HandleDebugSendSellErrorCommand(char* args)
{
if (!*args)
return false;
{ return false; }
uint8 msg = atoi(args);
m_session->GetPlayer()->SendSellError(SellResult(msg), 0, ObjectGuid(), 0);
@ -115,7 +115,7 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(char* args)
bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args)
{
if (!*args)
return false;
{ return false; }
uint8 msg = atoi(args);
m_session->GetPlayer()->SendBuyError(BuyResult(msg), 0, 0, 0);
@ -126,11 +126,11 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
{
Unit* unit = getSelectedUnit();
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
unit = m_session->GetPlayer();
{ unit = m_session->GetPlayer(); }
std::ifstream stream("opcode.txt");
if (!stream.is_open())
return false;
{ return false; }
uint32 opcode = 0;
if (!(stream >> opcode))
@ -145,7 +145,7 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
while (stream >> type)
{
if (type.empty())
break;
{ break; }
if (type == "uint8")
{
@ -209,11 +209,11 @@ bool ChatHandler::HandleDebugUpdateWorldStateCommand(char* args)
{
uint32 world;
if (!ExtractUInt32(&args, world))
return false;
{ return false; }
uint32 state;
if (!ExtractUInt32(&args, state))
return false;
{ return false; }
m_session->GetPlayer()->SendUpdateWorldState(world, state);
return true;
@ -225,7 +225,7 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(char* args)
// #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column)
uint32 dwId;
if (!ExtractUInt32(&args, dwId))
return false;
{ return false; }
if (!sCinematicSequencesStore.LookupEntry(dwId))
{
@ -264,7 +264,7 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args)
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
uint32 dwSoundId;
if (!ExtractUInt32(&args, dwSoundId))
return false;
{ return false; }
if (!sSoundEntriesStore.LookupEntry(dwSoundId))
{
@ -282,9 +282,9 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args)
}
if (m_session->GetPlayer()->GetSelectionGuid())
unit->PlayDistanceSound(dwSoundId, m_session->GetPlayer());
{ unit->PlayDistanceSound(dwSoundId, m_session->GetPlayer()); }
else
unit->PlayDirectSound(dwSoundId, m_session->GetPlayer());
{ unit->PlayDirectSound(dwSoundId, m_session->GetPlayer()); }
PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
return true;
@ -297,7 +297,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args)
uint32 code;
if (!ExtractUInt32(&args, code) || code > 255)
return false;
{ return false; }
WorldPacket data(SMSG_CHANNEL_NOTIFY, (1 + 10));
data << uint8(code); // notify type
@ -315,7 +315,7 @@ bool ChatHandler::HandleDebugSendChatMsgCommand(char* args)
uint32 type;
if (!ExtractUInt32(&args, type) || type > 255)
return false;
{ return false; }
WorldPacket data;
ChatHandler::BuildChatPacket(data, ChatMsg(type), msg, LANG_UNIVERSAL, CHAT_TAG_NONE, m_session->GetPlayer()->GetObjectGuid(), m_session->GetPlayerName());
@ -327,7 +327,7 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(char* args)
{
uint32 msg;
if (!ExtractUInt32(&args, msg))
return false;
{ return false; }
m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), msg);
return true;
@ -337,17 +337,17 @@ bool ChatHandler::HandleDebugGetLootRecipientCommand(char* /*args*/)
{
Creature* target = getSelectedCreature();
if (!target)
return false;
{ return false; }
if (!target->HasLootRecipient())
SendSysMessage("loot recipient: no loot recipient");
{ SendSysMessage("loot recipient: no loot recipient"); }
else if (Player* recipient = target->GetLootRecipient())
PSendSysMessage("loot recipient: %s with raw data %s from group %u",
recipient->GetGuidStr().c_str(),
target->GetLootRecipientGuid().GetString().c_str(),
target->GetLootGroupRecipientId());
else
SendSysMessage("loot recipient: offline ");
{ SendSysMessage("loot recipient: offline "); }
return true;
}
@ -362,7 +362,7 @@ bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(char* args)
bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
{
if (!*args)
return false;
{ return false; }
ItemUpdateState state = ITEM_UNCHANGED;
bool list_queue = false, check_all = false;
@ -390,14 +390,14 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
state_str = "removed";
}
else if (strncmp(args, "queue", strlen(args)) == 0)
list_queue = true;
{ list_queue = true; }
else if (strncmp(args, "all", strlen(args)) == 0)
check_all = true;
{ check_all = true; }
else
return false;
{ return false; }
Player* player = getSelectedPlayer();
if (!player) player = m_session->GetPlayer();
if (!player) { player = m_session->GetPlayer(); }
if (!list_queue && !check_all)
{
@ -406,10 +406,10 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue;
{ continue; }
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue;
if (!item) { continue; }
if (!item->IsBag())
{
if (item->GetState() == state)
@ -433,11 +433,11 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
if (list_queue)
{
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue();
std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (size_t i = 0; i < updateQueue.size(); ++i)
{
Item* item = updateQueue[i];
if (!item) continue;
if (!item) { continue; }
Bag* container = item->GetContainer();
uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0);
@ -455,20 +455,20 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
item->GetGuidStr().c_str(), bag_slot, item->GetSlot(), st.c_str());
}
if (updateQueue.empty())
PSendSysMessage("updatequeue empty");
{ PSendSysMessage("updatequeue empty"); }
}
if (check_all)
{
bool error = false;
std::vector<Item*> &updateQueue = player->GetItemUpdateQueue();
std::vector<Item*>& updateQueue = player->GetItemUpdateQueue();
for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i)
{
if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END)
continue;
{ continue; }
Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
if (!item) continue;
if (!item) { continue; }
if (item->GetSlot() != i)
{
@ -531,7 +531,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{
Item* item2 = bag->GetItemByPos(j);
if (!item2) continue;
if (!item2) { continue; }
if (item2->GetSlot() != j)
{
@ -602,7 +602,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
for (size_t i = 0; i < updateQueue.size(); ++i)
{
Item* item = updateQueue[i];
if (!item) continue;
if (!item) { continue; }
if (item->GetOwnerGuid() != player->GetObjectGuid())
{
@ -619,7 +619,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
error = true; continue;
}
if (item->GetState() == ITEM_REMOVED) continue;
if (item->GetState() == ITEM_REMOVED) { continue; }
Item* test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot());
if (test == NULL)
@ -638,7 +638,7 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args)
}
}
if (!error)
SendSysMessage("All OK!");
{ SendSysMessage("All OK!"); }
}
return true;
@ -702,7 +702,7 @@ bool ChatHandler::HandleDebugAnimCommand(char* args)
{
uint32 emote_id;
if (!ExtractUInt32(&args, emote_id))
return false;
{ return false; }
m_session->GetPlayer()->HandleEmoteCommand(emote_id);
return true;
@ -712,7 +712,7 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(char* args)
{
int32 state;
if (!ExtractInt32(&args, state))
return false;
{ return false; }
Unit* unit = getSelectedUnit();
if (!unit)
@ -726,7 +726,7 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(char* args)
{
// reset all states
for (int i = 1; i <= 32; ++i)
unit->ModifyAuraState(AuraState(i), false);
{ unit->ModifyAuraState(AuraState(i), false); }
return true;
}
@ -747,23 +747,23 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS
uint32 base; // 0 -> float
if (!typeStr)
base = 10;
{ base = 10; }
else if (strncmp(typeStr, "int", strlen(typeStr)) == 0)
base = 10;
{ base = 10; }
else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0)
base = 16;
{ base = 16; }
else if (strncmp(typeStr, "bit", strlen(typeStr)) == 0)
base = 2;
{ base = 2; }
else if (strncmp(typeStr, "float", strlen(typeStr)) == 0)
base = 0;
{ base = 0; }
else
return false;
{ return false; }
if (base)
{
uint32 iValue;
if (!ExtractUInt32Base(&valStr, iValue, base))
return false;
{ return false; }
DEBUG_LOG(GetMangosString(LANG_SET_UINT), guid.GetString().c_str(), field, iValue);
target->SetUInt32Value(field , iValue);
@ -773,7 +773,7 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS
{
float fValue;
if (!ExtractFloat(&valStr, fValue))
return false;
{ return false; }
DEBUG_LOG(GetMangosString(LANG_SET_FLOAT), guid.GetString().c_str(), field, fValue);
target->SetFloatValue(field , fValue);
@ -787,23 +787,23 @@ bool ChatHandler::HandleDebugSetItemValueCommand(char* args)
{
uint32 guid;
if (!ExtractUInt32(&args, guid))
return false;
{ return false; }
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractOptNotLastArg(&args);
if (!typeStr)
return false;
{ return false; }
char* valStr = ExtractLiteralArg(&args);
if (!valStr)
return false;
{ return false; }
Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid));
if (!item)
return false;
{ return false; }
return HandleSetValueHelper(item, field, typeStr, valStr);
}
@ -820,15 +820,15 @@ bool ChatHandler::HandleDebugSetValueCommand(char* args)
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractOptNotLastArg(&args);
if (!typeStr)
return false;
{ return false; }
char* valStr = ExtractLiteralArg(&args);
if (!valStr)
return false;
{ return false; }
return HandleSetValueHelper(target, field, typeStr, valStr);
}
@ -845,17 +845,17 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS
uint32 base; // 0 -> float
if (!typeStr)
base = 10;
{ base = 10; }
else if (strncmp(typeStr, "int", strlen(typeStr)) == 0)
base = 10;
{ base = 10; }
else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0)
base = 16;
{ base = 16; }
else if (strncmp(typeStr, "bit", strlen(typeStr)) == 0)
base = 2;
{ base = 2; }
else if (strncmp(typeStr, "float", strlen(typeStr)) == 0)
base = 0;
{ base = 0; }
else
return false;
{ return false; }
if (base)
{
@ -870,7 +870,7 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS
res.reserve(1 + 32 + 1);
res = iValue & (1 << (32 - 1)) ? "0" : " ";
for (int i = 32; i > 0; --i)
res += iValue & (1 << (i - 1)) ? "1" : "0";
{ res += iValue & (1 << (i - 1)) ? "1" : "0"; }
DEBUG_LOG(GetMangosString(LANG_GET_BITSTR), guid.GetString().c_str(), field, res.c_str());
PSendSysMessage(LANG_GET_BITSTR_FIELD, guid.GetString().c_str(), field, res.c_str());
break;
@ -899,19 +899,19 @@ bool ChatHandler::HandleDebugGetItemValueCommand(char* args)
{
uint32 guid;
if (!ExtractUInt32(&args, guid))
return false;
{ return false; }
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractLiteralArg(&args);
if (!typeStr && *args) // optional arg but check format fail case
return false;
{ return false; }
Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid));
if (!item)
return false;
{ return false; }
return HandleGetValueHelper(item, field, typeStr);
}
@ -928,11 +928,11 @@ bool ChatHandler::HandleDebugGetValueCommand(char* args)
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractLiteralArg(&args);
if (!typeStr && *args) // optional arg but check format fail case
return false;
{ return false; }
return HandleGetValueHelper(target, field, typeStr);
}
@ -950,23 +950,23 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char*
uint32 type; // 0 -> float 1 -> int add 2-> bit or 3 -> bit and 4 -> bit and not
if (strncmp(typeStr, "int", strlen(typeStr)) == 0)
type = 1;
{ type = 1; }
else if (strncmp(typeStr, "float", strlen(typeStr)) == 0)
type = 0;
{ type = 0; }
else if (strncmp(typeStr, "|=", strlen("|=") + 1) == 0) // exactly copy
type = 2;
{ type = 2; }
else if (strncmp(typeStr, "&=", strlen("&=") + 1) == 0) // exactly copy
type = 3;
{ type = 3; }
else if (strncmp(typeStr, "&=~", strlen("&=~") + 1) == 0) // exactly copy
type = 4;
{ type = 4; }
else
return false;
{ return false; }
if (type)
{
uint32 iValue;
if (!ExtractUInt32Base(&valStr, iValue, type == 1 ? 10 : 16))
return false;
{ return false; }
uint32 value = target->GetUInt32Value(field);
const char* guidString = guid.GetString().c_str();
@ -1002,7 +1002,7 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char*
{
float fValue;
if (!ExtractFloat(&valStr, fValue))
return false;
{ return false; }
float value = target->GetFloatValue(field);
@ -1021,23 +1021,23 @@ bool ChatHandler::HandleDebugModItemValueCommand(char* args)
{
uint32 guid;
if (!ExtractUInt32(&args, guid))
return false;
{ return false; }
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractLiteralArg(&args);
if (!typeStr)
return false;
{ return false; }
char* valStr = ExtractLiteralArg(&args);
if (!valStr)
return false;
{ return false; }
Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid));
if (!item)
return false;
{ return false; }
return HandlerDebugModValueHelper(item, field, typeStr, valStr);
}
@ -1054,15 +1054,15 @@ bool ChatHandler::HandleDebugModValueCommand(char* args)
uint32 field;
if (!ExtractUInt32(&args, field))
return false;
{ return false; }
char* typeStr = ExtractLiteralArg(&args);
if (!typeStr && *args) // optional arg but check format fail case
return false;
{ return false; }
char* valStr = ExtractLiteralArg(&args);
if (!valStr)
return false;
{ return false; }
return HandlerDebugModValueHelper(target, field, typeStr, valStr);
}
@ -1071,11 +1071,11 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args)
{
uint32 spellid = ExtractSpellIdFromLink(&args);
if (!spellid)
return false;
{ return false; }
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid);
if (!spellEntry)
return false;
{ return false; }
SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellid);
@ -1128,27 +1128,27 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args)
{
char* typeStr = ExtractLiteralArg(&args);
if (!typeStr)
return false;
{ return false; }
Opcodes opcode;
if (strncmp(typeStr, "flat", strlen(typeStr)) == 0)
opcode = SMSG_SET_FLAT_SPELL_MODIFIER;
{ opcode = SMSG_SET_FLAT_SPELL_MODIFIER; }
else if (strncmp(typeStr, "pct", strlen(typeStr)) == 0)
opcode = SMSG_SET_PCT_SPELL_MODIFIER;
{ opcode = SMSG_SET_PCT_SPELL_MODIFIER; }
else
return false;
{ return false; }
uint32 effidx;
if (!ExtractUInt32(&args, effidx) || effidx >= 64 + 32)
return false;
{ return false; }
uint32 spellmodop;
if (!ExtractUInt32(&args, spellmodop) || spellmodop >= MAX_SPELLMOD)
return false;
{ return false; }
int32 value;
if (!ExtractInt32(&args, value))
return false;
{ return false; }
Player* chr = getSelectedPlayer();
if (chr == NULL)
@ -1160,7 +1160,7 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args)
// check online security
if (HasLowerSecurity(chr))
return false;
{ return false; }
PSendSysMessage(LANG_YOU_CHANGE_SPELLMODS, opcode == SMSG_SET_FLAT_SPELL_MODIFIER ? "flat" : "pct",
spellmodop, value, effidx, GetNameLink(chr).c_str());

View file

@ -396,7 +396,7 @@ void FlightPathMovementGenerator::Finalize(Player& player)
if (player.m_taxi.empty())
{
player.getHostileRefManager().setOnlineOfflineState(true);
player.GetHostileRefManager().setOnlineOfflineState(true);
if (player.pvpInfo.inHostileArea)
player.CastSpell(&player, 2479, true);
@ -416,7 +416,7 @@ void FlightPathMovementGenerator::Interrupt(Player& player)
void FlightPathMovementGenerator::Reset(Player& player)
{
player.getHostileRefManager().setOnlineOfflineState(false);
player.GetHostileRefManager().setOnlineOfflineState(false);
player.addUnitState(UNIT_STAT_TAXI_FLIGHT);
player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
player.SetClientControl(&player, 0);

View file

@ -79,12 +79,12 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
// detach and deregister from active objects if there are no more reasons to be active
m_source->GetViewPoint().Detach(this);
if (!m_source->isActiveObject())
if (!m_source->IsActiveObject())
m_source->GetMap()->RemoveFromActive(m_source);
m_source = obj;
if (!m_source->isActiveObject())
if (!m_source->IsActiveObject())
m_source->GetMap()->AddToActive(m_source);
m_source->GetViewPoint().Attach(this);

View file

@ -77,7 +77,7 @@ class Camera
public:
GridReference<Camera>& GetGridRef() { return m_gridRef; }
bool isActiveObject() const { return false; }
bool IsActiveObject() const { return false; }
private:
GridReference<Camera> m_gridRef;
};

View file

@ -1110,7 +1110,7 @@ WorldObject::WorldObject() :
m_transportInfo(NULL),
m_currMap(NULL),
m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_isActiveObject(false)
m_IsActiveObject(false)
{
}
@ -2159,17 +2159,17 @@ bool WorldObject::PrintCoordinatesError(float x, float y, float z, char const* d
void WorldObject::SetActiveObjectState(bool active)
{
if (m_isActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never
if (m_IsActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never
{ return; }
if (IsInWorld() && !isType(TYPEMASK_PLAYER))
// player's update implemented in a different from other active worldobject's way
// it's considired to use generic way in future
{
if (isActiveObject() && !active)
if (IsActiveObject() && !active)
{ GetMap()->RemoveFromActive(this); }
else if (!isActiveObject() && active)
else if (!IsActiveObject() && active)
{ GetMap()->AddToActive(this); }
}
m_isActiveObject = active;
m_IsActiveObject = active;
}

View file

@ -658,7 +658,7 @@ class WorldObject : public Object
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false, bool setRun = false);
GameObject* SummonGameObject(uint32 id, float x, float y, float z, float angle, uint32 despwtime);
bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); }
bool IsActiveObject() const { return m_IsActiveObject || m_viewPoint.hasViewers(); }
void SetActiveObjectState(bool active);
ViewPoint& GetViewPoint() { return m_viewPoint; }
@ -696,7 +696,7 @@ class WorldObject : public Object
Position m_position;
ViewPoint m_viewPoint;
WorldUpdateCounter m_updateTracker;
bool m_isActiveObject;
bool m_IsActiveObject;
};
#endif

View file

@ -2390,7 +2390,7 @@ void Player::SetInWater(bool apply)
// remove auras that need water/land
RemoveAurasWithInterruptFlags(apply ? AURA_INTERRUPT_FLAG_NOT_ABOVEWATER : AURA_INTERRUPT_FLAG_NOT_UNDERWATER);
getHostileRefManager().updateThreatTables();
GetHostileRefManager().updateThreatTables();
}
struct SetGameMasterOnHelper
@ -2399,7 +2399,7 @@ struct SetGameMasterOnHelper
void operator()(Unit* unit) const
{
unit->setFaction(35);
unit->getHostileRefManager().setOnlineOfflineState(false);
unit->GetHostileRefManager().setOnlineOfflineState(false);
}
};
@ -2409,7 +2409,7 @@ struct SetGameMasterOffHelper
void operator()(Unit* unit) const
{
unit->setFaction(faction);
unit->getHostileRefManager().setOnlineOfflineState(true);
unit->GetHostileRefManager().setOnlineOfflineState(true);
}
uint32 faction;
};
@ -2427,7 +2427,7 @@ void Player::SetGameMaster(bool on)
SetFFAPvP(false);
ResetContestedPvP();
getHostileRefManager().setOnlineOfflineState(false);
GetHostileRefManager().setOnlineOfflineState(false);
CombatStopWithPets();
SetPhaseMask(PHASEMASK_ANYWHERE, false); // see and visible in all phases
@ -2458,7 +2458,7 @@ void Player::SetGameMaster(bool on)
// restore FFA PvP area state, remove not allowed for GM mounts
UpdateArea(m_areaUpdateId);
getHostileRefManager().setOnlineOfflineState(true);
GetHostileRefManager().setOnlineOfflineState(true);
}
m_camera.UpdateVisibilityForOwner();

View file

@ -1108,7 +1108,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
// stop combat
DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageAttackStop");
pVictim->CombatStop();
pVictim->getHostileRefManager().deleteReferences();
pVictim->GetHostileRefManager().deleteReferences();
/*
* Actions for the killer
@ -10592,9 +10592,9 @@ void Unit::CleanupsBeforeDelete()
ClearComboPointHolders();
DeleteThreatList();
if (GetTypeId() == TYPEID_PLAYER)
getHostileRefManager().setOnlineOfflineState(false);
GetHostileRefManager().setOnlineOfflineState(false);
else
getHostileRefManager().deleteReferences();
GetHostileRefManager().deleteReferences();
RemoveAllAuras(AURA_REMOVE_BY_DELETE);
}
WorldObject::CleanupsBeforeDelete();
@ -11259,7 +11259,7 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid, uint32 /*spellID*/)
if (casterGuid == GetObjectGuid())
FinishSpell(CURRENT_GENERIC_SPELL, false);
InterruptNonMeleeSpells(true);
getHostileRefManager().deleteReferences();
GetHostileRefManager().deleteReferences();
}
else
{
@ -11912,7 +11912,7 @@ void Unit::StopAttackFaction(uint32 faction_id)
++itr;
}
getHostileRefManager().deleteReferencesForFaction(faction_id);
GetHostileRefManager().deleteReferencesForFaction(faction_id);
CallForAllControlledUnits(StopAttackFactionHelper(faction_id), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
}
@ -12425,7 +12425,7 @@ bool Unit::TakePossessOf(Unit* possessed)
possessed->CombatStop(true);
possessed->DeleteThreatList();
possessed->getHostileRefManager().deleteReferences();
possessed->GetHostileRefManager().deleteReferences();
if (possessedCreature)
{
@ -12490,7 +12490,7 @@ void Unit::ResetControlState(bool attackCharmer /*= true*/)
possessed->CombatStop(true);
possessed->DeleteThreatList();
possessed->getHostileRefManager().deleteReferences();
possessed->GetHostileRefManager().deleteReferences();
if (possessed->GetTypeId() == TYPEID_PLAYER)
{

View file

@ -3286,7 +3286,7 @@ class Unit : public WorldObject
ThreatManager const& GetThreatManager() const { return m_ThreatManager; }
void addHatedBy(HostileReference* pHostileReference) { m_HostileRefManager.insertFirst(pHostileReference); };
void removeHatedBy(HostileReference* /*pHostileReference*/) { /* nothing to do yet */ }
HostileRefManager& getHostileRefManager() { return m_HostileRefManager; }
HostileRefManager& GetHostileRefManager() { return m_HostileRefManager; }
SpellAuraHolder* GetVisibleAura(uint8 slot) const
{

View file

@ -437,9 +437,9 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho
if (threat > 0.0f)
{
if (float redirectedMod = pVictim->getHostileRefManager().GetThreatRedirectionMod())
if (float redirectedMod = pVictim->GetHostileRefManager().GetThreatRedirectionMod())
{
if (Unit* redirectedTarget = pVictim->getHostileRefManager().GetThreatRedirectionTarget())
if (Unit* redirectedTarget = pVictim->GetHostileRefManager().GetThreatRedirectionTarget())
{
if (redirectedTarget != getOwner() && redirectedTarget->IsAlive())
{

View file

@ -426,14 +426,14 @@ void WorldSession::LogoutPlayer(bool Save)
// FIXME: logout must be delayed in case lost connection with client in time of combat
if (_player->GetDeathTimer())
{
_player->getHostileRefManager().deleteReferences();
_player->GetHostileRefManager().deleteReferences();
_player->BuildPlayerRepop();
_player->RepopAtGraveyard();
}
else if (!_player->getAttackers().empty())
{
_player->CombatStop();
_player->getHostileRefManager().setOnlineOfflineState(false);
_player->GetHostileRefManager().setOnlineOfflineState(false);
_player->RemoveAllAurasOnDeath();
// build set of player who attack _player or who have pet attacking of _player

View file

@ -358,7 +358,7 @@ Map::Add(T* obj)
obj->SetMap(this);
Cell cell(p);
if (obj->isActiveObject())
if (obj->IsActiveObject())
{ EnsureGridLoadedAtEnter(cell); }
else
{ EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); }
@ -369,7 +369,7 @@ Map::Add(T* obj)
AddToGrid(obj, grid, cell);
obj->AddToWorld();
if (obj->isActiveObject())
if (obj->IsActiveObject())
{ AddToActive(obj); }
DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY());
@ -685,7 +685,7 @@ Map::Remove(T* obj, bool remove)
NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
MANGOS_ASSERT(grid != NULL);
if (obj->isActiveObject())
if (obj->IsActiveObject())
{ RemoveFromActive(obj); }
if (remove)
@ -776,7 +776,7 @@ bool Map::CreatureCellRelocation(Creature* c, const Cell& new_cell)
Cell const& old_cell = c->GetCurrentCell();
if (old_cell.DiffGrid(new_cell))
{
if (!c->isActiveObject() && !loaded(new_cell.gridPair()))
if (!c->IsActiveObject() && !loaded(new_cell.gridPair()))
{
DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
return false;

View file

@ -134,7 +134,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager<T>&
addUnitState(obj, cell);
obj->SetMap(map);
obj->AddToWorld();
if (obj->isActiveObject())
if (obj->IsActiveObject())
map->AddToActive(obj);
obj->GetViewPoint().Event_AddedToWorld(&grid);
@ -167,7 +167,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType
addUnitState(obj, cell);
obj->SetMap(map);
obj->AddToWorld();
if (obj->isActiveObject())
if (obj->IsActiveObject())
map->AddToActive(obj);
++count;

View file

@ -1194,7 +1194,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
int32 gain = caster->DealHeal(unitTarget, addhealth, m_spellInfo, crit, absorb);
if (real_caster)
unitTarget->getHostileRefManager().threatAssist(real_caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
unitTarget->GetHostileRefManager().threatAssist(real_caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
}
// Do damage and triggers
else if (m_damage)
@ -1392,7 +1392,7 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask)
if (unit->IsInCombat() && !m_spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_INITIAL_AGGRO))
{
realCaster->SetInCombatState(unit->GetCombatTimer() > 0);
unit->getHostileRefManager().threatAssist(realCaster, 0.0f, m_spellInfo);
unit->GetHostileRefManager().threatAssist(realCaster, 0.0f, m_spellInfo);
}
}
}
@ -5054,7 +5054,7 @@ void Spell::HandleThreatSpells()
// positive spells distribute threat among all units that are in combat with target, like healing
if (positive)
{
target->getHostileRefManager().threatAssist(m_caster /*real_caster ??*/, threat, m_spellInfo);
target->GetHostileRefManager().threatAssist(m_caster /*real_caster ??*/, threat, m_spellInfo);
}
// for negative spells threat gets distributed among affected targets
else

View file

@ -2786,7 +2786,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
case 59628: // Tricks of the Trade, triggered buff
{
if (Unit* pCaster = GetCaster())
pCaster->getHostileRefManager().ResetThreatRedirection();
pCaster->GetHostileRefManager().ResetThreatRedirection();
return;
}
case 36730: // Flame Strike
@ -3375,7 +3375,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
{
// used for direct in code aura removes and spell proc event charges expire
if (m_removeMode != AURA_REMOVE_BY_DEFAULT)
target->getHostileRefManager().ResetThreatRedirection();
target->GetHostileRefManager().ResetThreatRedirection();
}
return;
}
@ -3393,7 +3393,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
{
// used for direct in code aura removes and spell proc event charges expire
if (m_removeMode != AURA_REMOVE_BY_DEFAULT)
target->getHostileRefManager().ResetThreatRedirection();
target->GetHostileRefManager().ResetThreatRedirection();
}
return;
}
@ -4393,7 +4393,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
target->CombatStop(true);
target->DeleteThreatList();
target->getHostileRefManager().deleteReferences();
target->GetHostileRefManager().deleteReferences();
if (target->GetTypeId() == TYPEID_UNIT)
{
@ -4470,7 +4470,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
target->CombatStop(true);
target->DeleteThreatList();
target->getHostileRefManager().deleteReferences();
target->GetHostileRefManager().deleteReferences();
if (target->GetTypeId() == TYPEID_UNIT)
{
@ -4999,7 +4999,7 @@ void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount);
target->getHostileRefManager().threatAssist(caster, threatMod, GetSpellProto());
target->GetHostileRefManager().threatAssist(caster, threatMod, GetSpellProto());
}
void Aura::HandleModTaunt(bool apply, bool Real)
@ -5358,7 +5358,7 @@ void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
target->CastSpell(caster, 59665, true);
}
else
target->getHostileRefManager().ResetThreatRedirection();
target->GetHostileRefManager().ResetThreatRedirection();
break;
default:
break;
@ -7520,7 +7520,7 @@ void Aura::PeriodicTick()
// Health Leech effects do not generate healing aggro
if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_LEECH)
break;
pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
pCaster->GetHostileRefManager().threatAssist(pCaster, gain * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_PERIODIC_HEAL:
@ -7596,7 +7596,7 @@ void Aura::PeriodicTick()
if (BattleGround* bg = ((Player*)pCaster)->GetBattleGround())
bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
target->GetHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
// apply damage part to caster if needed (ex. health funnel)
if (target != pCaster && spellProto->SpellVisual[0] == 163)
@ -7767,7 +7767,7 @@ void Aura::PeriodicTick()
int32 gain = target->ModifyPower(power, pdamage);
if (Unit* pCaster = GetCaster())
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
target->GetHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_OBS_MOD_MANA:
@ -7793,7 +7793,7 @@ void Aura::PeriodicTick()
int32 gain = target->ModifyPower(POWER_MANA, pdamage);
if (Unit* pCaster = GetCaster())
target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
target->GetHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_POWER_BURN_MANA:
@ -7855,7 +7855,7 @@ void Aura::PeriodicTick()
int32 gain = target->ModifyHealth(m_modifier.m_amount);
if (Unit* caster = GetCaster())
target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
target->GetHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto);
break;
}
case SPELL_AURA_MOD_POWER_REGEN:

View file

@ -4843,7 +4843,7 @@ void Spell::EffectHealPct(SpellEffectEntry const* /*effect*/)
unitTarget->CalculateHealAbsorb(addhealth, &absorb);
int32 gain = caster->DealHeal(unitTarget, addhealth - absorb, m_spellInfo, false, absorb);
unitTarget->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
unitTarget->GetHostileRefManager().threatAssist(caster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(m_spellInfo), m_spellInfo);
}
}
@ -10129,7 +10129,7 @@ void Spell::EffectSanctuary(SpellEffectEntry const* /*effect*/)
// unitTarget->CombatStop();
unitTarget->CombatStop();
unitTarget->getHostileRefManager().deleteReferences(); // stop all fighting
unitTarget->GetHostileRefManager().deleteReferences(); // stop all fighting
// Vanish allows to remove all threat and cast regular stealth so other spells can be used
if (m_spellInfo->IsFitToFamily(SPELLFAMILY_ROGUE, UI64LIT(0x0000000000000800)))
@ -11812,7 +11812,7 @@ void Spell::EffectRedirectThreat(SpellEffectEntry const* effect)
if (Aura* glyph = unitTarget->GetDummyAura(63326)) // Glyph of Vigilance
damage += glyph->GetModifier()->m_amount;
m_caster->getHostileRefManager().SetThreatRedirection(unitTarget->GetObjectGuid(), uint32(damage));
m_caster->GetHostileRefManager().SetThreatRedirection(unitTarget->GetObjectGuid(), uint32(damage));
}
void Spell::EffectTeachTaxiNode(SpellEffectEntry const* effect)

View file

@ -1800,7 +1800,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura
case 57934:
{
triggered_spell_id = 57933; // Tricks of the Trade, increased damage buff
target = getHostileRefManager().GetThreatRedirectionTarget();
target = GetHostileRefManager().GetThreatRedirectionTarget();
if (!target)
return SPELL_AURA_PROC_FAILED;

View file

@ -56,7 +56,7 @@ namespace LuaGameObject
*/
int IsActive(Eluna* /*E*/, lua_State* L, GameObject* go)
{
Eluna::Push(L, go->isActiveObject());
Eluna::Push(L, go->IsActiveObject());
return 1;
}