mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Battlefield: some codestyle changes
This commit is contained in:
@@ -16,125 +16,130 @@
|
||||
*/
|
||||
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "Zones/BattlefieldWG.h"
|
||||
#include "BattlefieldWG.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
|
||||
BattlefieldMgr::BattlefieldMgr()
|
||||
{
|
||||
m_UpdateTimer = 0;
|
||||
//TC_LOG_DEBUG("bg.battlefield", "Instantiating BattlefieldMgr");
|
||||
_updateTimer = 0;
|
||||
}
|
||||
|
||||
BattlefieldMgr::~BattlefieldMgr()
|
||||
{
|
||||
//TC_LOG_DEBUG("bg.battlefield", "Deleting BattlefieldMgr");
|
||||
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
||||
for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
|
||||
delete *itr;
|
||||
|
||||
_battlefieldMap.clear();
|
||||
}
|
||||
|
||||
void BattlefieldMgr::InitBattlefield()
|
||||
{
|
||||
Battlefield* pBf = new BattlefieldWG;
|
||||
Battlefield* wg = new BattlefieldWG();
|
||||
// respawn, init variables
|
||||
if (!pBf->SetupBattlefield())
|
||||
if (!wg->SetupBattlefield())
|
||||
{
|
||||
TC_LOG_INFO("misc", "Battlefield : Wintergrasp init failed.");
|
||||
delete pBf;
|
||||
TC_LOG_INFO("bg.battlefield", "Battlefield: Wintergrasp init failed.");
|
||||
delete wg;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BattlefieldSet.push_back(pBf);
|
||||
TC_LOG_INFO("misc", "Battlefield : Wintergrasp successfully initiated.");
|
||||
_battlefieldSet.push_back(wg);
|
||||
TC_LOG_INFO("bg.battlefield", "Battlefield: Wintergrasp successfully initiated.");
|
||||
}
|
||||
|
||||
/* For Cataclysm: Tol Barad
|
||||
pBf = new BattlefieldTB;
|
||||
// respawn, init variables
|
||||
if (!pBf->SetupBattlefield())
|
||||
{
|
||||
TC_LOG_DEBUG("bg.battlefield", "Battlefield : Tol Barad init failed.");
|
||||
delete pBf;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BattlefieldSet.push_back(pBf);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Battlefield : Tol Barad successfully initiated.");
|
||||
} */
|
||||
/*
|
||||
For Cataclysm: Tol Barad
|
||||
Battlefield* tb = new BattlefieldTB;
|
||||
// respawn, init variables
|
||||
if (!tb->SetupBattlefield())
|
||||
{
|
||||
TC_LOG_DEBUG("bg.battlefield", "Battlefield: Tol Barad init failed.");
|
||||
delete tb;
|
||||
}
|
||||
else
|
||||
{
|
||||
_battlefieldSet.push_back(tb);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Battlefield: Tol Barad successfully initiated.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void BattlefieldMgr::AddZone(uint32 zoneid, Battlefield *handle)
|
||||
void BattlefieldMgr::AddZone(uint32 zoneId, Battlefield* bf)
|
||||
{
|
||||
m_BattlefieldMap[zoneid] = handle;
|
||||
_battlefieldMap[zoneId] = bf;
|
||||
}
|
||||
|
||||
void BattlefieldMgr::HandlePlayerEnterZone(Player* player, uint32 zoneid)
|
||||
void BattlefieldMgr::HandlePlayerEnterZone(Player* player, uint32 zoneId)
|
||||
{
|
||||
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
||||
if (itr == m_BattlefieldMap.end())
|
||||
BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
|
||||
if (itr == _battlefieldMap.end())
|
||||
return;
|
||||
|
||||
Battlefield* bf = itr->second;
|
||||
if (bf->HasPlayer(player) || !bf->IsEnabled())
|
||||
if (!bf->IsEnabled() || bf->HasPlayer(player))
|
||||
return;
|
||||
|
||||
bf->HandlePlayerEnterZone(player, zoneid);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Player %u entered outdoorpvp id %u", player->GetGUIDLow(), bf->GetTypeId());
|
||||
bf->HandlePlayerEnterZone(player, zoneId);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Player %u entered battlefield id %u", player->GetGUIDLow(), bf->GetTypeId());
|
||||
}
|
||||
|
||||
void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneid)
|
||||
void BattlefieldMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId)
|
||||
{
|
||||
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
||||
if (itr == m_BattlefieldMap.end())
|
||||
BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
|
||||
if (itr == _battlefieldMap.end())
|
||||
return;
|
||||
|
||||
// teleport: remove once in removefromworld, once in updatezone
|
||||
if (!itr->second->HasPlayer(player))
|
||||
return;
|
||||
itr->second->HandlePlayerLeaveZone(player, zoneid);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Player %u left outdoorpvp id %u", player->GetGUIDLow(), itr->second->GetTypeId());
|
||||
|
||||
itr->second->HandlePlayerLeaveZone(player, zoneId);
|
||||
TC_LOG_DEBUG("bg.battlefield", "Player %u left battlefield id %u", player->GetGUIDLow(), itr->second->GetTypeId());
|
||||
}
|
||||
|
||||
Battlefield *BattlefieldMgr::GetBattlefieldToZoneId(uint32 zoneid)
|
||||
Battlefield* BattlefieldMgr::GetBattlefieldToZoneId(uint32 zoneId)
|
||||
{
|
||||
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneid);
|
||||
if (itr == m_BattlefieldMap.end())
|
||||
BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
|
||||
if (itr == _battlefieldMap.end())
|
||||
{
|
||||
// no handle for this zone, return
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!itr->second->IsEnabled())
|
||||
return NULL;
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
Battlefield *BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleid)
|
||||
Battlefield* BattlefieldMgr::GetBattlefieldByBattleId(uint32 battleId)
|
||||
{
|
||||
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
||||
for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetBattleId() == battleid)
|
||||
return (*itr);
|
||||
if ((*itr)->GetBattleId() == battleId)
|
||||
return *itr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZoneScript* BattlefieldMgr::GetZoneScript(uint32 zoneId)
|
||||
{
|
||||
BattlefieldMap::iterator itr = _battlefieldMap.find(zoneId);
|
||||
if (itr != _battlefieldMap.end())
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void BattlefieldMgr::Update(uint32 diff)
|
||||
{
|
||||
m_UpdateTimer += diff;
|
||||
if (m_UpdateTimer > BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL)
|
||||
_updateTimer += diff;
|
||||
if (_updateTimer > BATTLEFIELD_OBJECTIVE_UPDATE_INTERVAL)
|
||||
{
|
||||
for (BattlefieldSet::iterator itr = m_BattlefieldSet.begin(); itr != m_BattlefieldSet.end(); ++itr)
|
||||
for (BattlefieldSet::iterator itr = _battlefieldSet.begin(); itr != _battlefieldSet.end(); ++itr)
|
||||
if ((*itr)->IsEnabled())
|
||||
(*itr)->Update(m_UpdateTimer);
|
||||
m_UpdateTimer = 0;
|
||||
(*itr)->Update(_updateTimer);
|
||||
_updateTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ZoneScript* BattlefieldMgr::GetZoneScript(uint32 zoneId)
|
||||
{
|
||||
BattlefieldMap::iterator itr = m_BattlefieldMap.find(zoneId);
|
||||
if (itr != m_BattlefieldMap.end())
|
||||
return itr->second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -19,60 +19,51 @@
|
||||
#define BATTLEFIELD_MGR_H_
|
||||
|
||||
#include "Battlefield.h"
|
||||
#include "ace/Singleton.h"
|
||||
#include <ace/Singleton.h>
|
||||
|
||||
class Player;
|
||||
class GameObject;
|
||||
class Creature;
|
||||
class ZoneScript;
|
||||
struct GossipMenuItems;
|
||||
|
||||
// class to handle player enter / leave / areatrigger / GO use events
|
||||
class BattlefieldMgr
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
BattlefieldMgr();
|
||||
// dtor
|
||||
~BattlefieldMgr();
|
||||
public:
|
||||
// ctor
|
||||
BattlefieldMgr();
|
||||
// dtor
|
||||
~BattlefieldMgr();
|
||||
|
||||
// create battlefield events
|
||||
void InitBattlefield();
|
||||
// called when a player enters an battlefield area
|
||||
void HandlePlayerEnterZone(Player* player, uint32 areaflag);
|
||||
// called when player leaves an battlefield area
|
||||
void HandlePlayerLeaveZone(Player* player, uint32 areaflag);
|
||||
// called when player resurrects
|
||||
void HandlePlayerResurrects(Player* player, uint32 areaflag);
|
||||
// return assigned battlefield
|
||||
Battlefield* GetBattlefieldToZoneId(uint32 zoneid);
|
||||
Battlefield* GetBattlefieldByBattleId(uint32 battleid);
|
||||
// create battlefield events
|
||||
void InitBattlefield();
|
||||
|
||||
ZoneScript* GetZoneScript(uint32 zoneId);
|
||||
// called when a player enters an battlefield area
|
||||
void HandlePlayerEnterZone(Player* player, uint32 zoneId);
|
||||
// called when player leaves an battlefield area
|
||||
void HandlePlayerLeaveZone(Player* player, uint32 zoneId);
|
||||
|
||||
void AddZone(uint32 zoneid, Battlefield * handle);
|
||||
// return assigned battlefield
|
||||
Battlefield* GetBattlefieldToZoneId(uint32 zoneId);
|
||||
Battlefield* GetBattlefieldByBattleId(uint32 battleId);
|
||||
|
||||
void Update(uint32 diff);
|
||||
ZoneScript* GetZoneScript(uint32 zoneId);
|
||||
|
||||
void HandleGossipOption(Player* player, uint64 guid, uint32 gossipid);
|
||||
void AddZone(uint32 zoneId, Battlefield* bf);
|
||||
|
||||
bool CanTalkTo(Player* player, Creature* creature, GossipMenuItems gso);
|
||||
void Update(uint32 diff);
|
||||
|
||||
void HandleDropFlag(Player* player, uint32 spellId);
|
||||
|
||||
typedef std::vector < Battlefield * >BattlefieldSet;
|
||||
typedef std::map < uint32 /* zoneid */, Battlefield * >BattlefieldMap;
|
||||
private:
|
||||
// contains all initiated battlefield events
|
||||
// used when initing / cleaning up
|
||||
BattlefieldSet m_BattlefieldSet;
|
||||
// maps the zone ids to an battlefield event
|
||||
// used in player event handling
|
||||
BattlefieldMap m_BattlefieldMap;
|
||||
// update interval
|
||||
uint32 m_UpdateTimer;
|
||||
private:
|
||||
typedef std::vector<Battlefield*> BattlefieldSet;
|
||||
typedef std::map<uint32 /*zoneId*/, Battlefield*> BattlefieldMap;
|
||||
// contains all initiated battlefield events
|
||||
// used when initing / cleaning up
|
||||
BattlefieldSet _battlefieldSet;
|
||||
// maps the zone ids to an battlefield event
|
||||
// used in player event handling
|
||||
BattlefieldMap _battlefieldMap;
|
||||
// update interval
|
||||
uint32 _updateTimer;
|
||||
};
|
||||
|
||||
#define sBattlefieldMgr ACE_Singleton<BattlefieldMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
#endif
|
||||
#endif // BATTLEFIELD_MGR_H_
|
||||
|
||||
@@ -30,14 +30,6 @@
|
||||
#include "Vehicle.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
enum WGVehicles
|
||||
{
|
||||
NPC_WG_SEIGE_ENGINE_ALLIANCE = 28312,
|
||||
NPC_WG_SEIGE_ENGINE_HORDE = 32627,
|
||||
NPC_WG_DEMOLISHER = 28094,
|
||||
NPC_WG_CATAPULT = 27881
|
||||
};
|
||||
|
||||
BattlefieldWG::~BattlefieldWG()
|
||||
{
|
||||
for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
|
||||
@@ -192,7 +184,7 @@ bool BattlefieldWG::SetupBattlefield()
|
||||
if (GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o))
|
||||
{
|
||||
DefenderPortalList.insert(go->GetGUID());
|
||||
go->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]);
|
||||
go->SetFaction(WintergraspFaction[GetDefenderTeam()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +214,7 @@ void BattlefieldWG::OnBattleStart()
|
||||
if (GameObject* relic = SpawnGameObject(GO_WINTERGRASP_TITAN_S_RELIC, 5440.0f, 2840.8f, 430.43f, 0))
|
||||
{
|
||||
// Update faction of relic, only attacker can click on
|
||||
relic->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetAttackerTeam()]);
|
||||
relic->SetFaction(WintergraspFaction[GetAttackerTeam()]);
|
||||
// Set in use (not allow to click on before last door is broken)
|
||||
relic->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
m_titansRelicGUID = relic->GetGUID();
|
||||
@@ -360,7 +352,7 @@ void BattlefieldWG::OnBattleEnd(bool endByTimer)
|
||||
// Update portal defender faction
|
||||
for (GuidSet::const_iterator itr = DefenderPortalList.begin(); itr != DefenderPortalList.end(); ++itr)
|
||||
if (GameObject* portal = GetGameObject(*itr))
|
||||
portal->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[GetDefenderTeam()]);
|
||||
portal->SetFaction(WintergraspFaction[GetDefenderTeam()]);
|
||||
|
||||
// Saving data
|
||||
for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
|
||||
@@ -813,6 +805,9 @@ uint32 BattlefieldWG::GetData(uint32 data) const
|
||||
// Graveyards and Workshops are controlled by the same team.
|
||||
if (BfGraveyard const* graveyard = GetGraveyardById(GetSpiritGraveyardId(data)))
|
||||
return graveyard->GetControlTeamId();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Battlefield::GetData(data);
|
||||
|
||||
@@ -1133,7 +1133,7 @@ struct BfWGGameObjectBuilding
|
||||
m_WG->SendUpdateWorldState(m_WorldState, m_State);
|
||||
}
|
||||
UpdateCreatureAndGo();
|
||||
build->SetUInt32Value(GAMEOBJECT_FACTION, WintergraspFaction[m_Team]);
|
||||
build->SetFaction(WintergraspFaction[m_Team]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -816,6 +816,9 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
|
||||
void SetDisplayId(uint32 displayid);
|
||||
uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
|
||||
|
||||
uint32 GetFaction() const { return GetUInt32Value(GAMEOBJECT_FACTION); }
|
||||
void SetFaction(uint32 faction) { SetUInt32Value(GAMEOBJECT_FACTION, faction); }
|
||||
|
||||
GameObjectModel* m_model;
|
||||
void GetRespawnPosition(float &x, float &y, float &z, float* ori = NULL) const;
|
||||
|
||||
|
||||
@@ -15,136 +15,173 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
|
||||
//This send to player windows for invite player to join the war
|
||||
//Param1:(BattleId) the BattleId of Bf
|
||||
//Param2:(ZoneId) the zone where the battle is (4197 for wg)
|
||||
//Param3:(time) Time in second that the player have for accept
|
||||
void WorldSession::SendBfInvitePlayerToWar(uint32 BattleId, uint32 ZoneId, uint32 p_time)
|
||||
/**
|
||||
* @fn void WorldSession::SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 acceptTime)
|
||||
*
|
||||
* @brief This send to player windows for invite player to join the war.
|
||||
*
|
||||
* @param battleId The BattleId of Bf
|
||||
* @param zoneId The zone where the battle is (4197 for wg)
|
||||
* @param acceptTime Time in second that the player have for accept
|
||||
*/
|
||||
void WorldSession::SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 acceptTime)
|
||||
{
|
||||
//Send packet
|
||||
WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTRY_INVITE, 12);
|
||||
data << uint32(BattleId);
|
||||
data << uint32(ZoneId);
|
||||
data << uint32((time(NULL) + p_time));
|
||||
|
||||
//Sending the packet to player
|
||||
data << uint32(battleId);
|
||||
data << uint32(zoneId);
|
||||
data << uint32(time(NULL) + acceptTime);
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
//This send invitation to player to join the queue
|
||||
//Param1:(BattleId) the BattleId of Bf
|
||||
void WorldSession::SendBfInvitePlayerToQueue(uint32 BattleId)
|
||||
/**
|
||||
* @fn void WorldSession::SendBfInvitePlayerToQueue(uint32 battleId)
|
||||
*
|
||||
* @brief This send invitation to player to join the queue.
|
||||
*
|
||||
* @param battleId The BattleId of Bf
|
||||
*/
|
||||
void WorldSession::SendBfInvitePlayerToQueue(uint32 battleId)
|
||||
{
|
||||
WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_INVITE, 5);
|
||||
|
||||
data << uint32(BattleId);
|
||||
data << uint8(1); //warmup ? used ?
|
||||
|
||||
//Sending packet to player
|
||||
data << uint32(battleId);
|
||||
data << uint8(1); // warmup ? used ?
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
//This send packet for inform player that he join queue
|
||||
//Param1:(BattleId) the BattleId of Bf
|
||||
//Param2:(ZoneId) the zone where the battle is (4197 for wg)
|
||||
//Param3:(CanQueue) if able to queue
|
||||
//Param4:(Full) on log in is full
|
||||
void WorldSession::SendBfQueueInviteResponse(uint32 BattleId, uint32 ZoneId, bool CanQueue, bool Full)
|
||||
/**
|
||||
* @fn void WorldSession::SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue, bool full)
|
||||
*
|
||||
* @brief This send packet for inform player that he join queue.
|
||||
*
|
||||
* @param battleId The BattleId of Bf
|
||||
* @param zoneId The zone where the battle is (4197 for wg)
|
||||
* @param canQueue if able to queue
|
||||
* @param full on log in is full
|
||||
*/
|
||||
void WorldSession::SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue, bool full)
|
||||
{
|
||||
WorldPacket data(SMSG_BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE, 11);
|
||||
data << uint32(BattleId);
|
||||
data << uint32(ZoneId);
|
||||
data << uint8((CanQueue ? 1 : 0)); //Accepted //0 you cannot queue wg //1 you are queued
|
||||
data << uint8((Full ? 0 : 1)); //Logging In //0 wg full //1 queue for upcoming
|
||||
data << uint8(1); //Warmup
|
||||
data << uint32(battleId);
|
||||
data << uint32(zoneId);
|
||||
data << uint8(canQueue ? 1 : 0); // Accepted // 0 you cannot queue wg // 1 you are queued
|
||||
data << uint8(full ? 0 : 1); // Logging In // 0 wg full // 1 queue for upcoming
|
||||
data << uint8(1); // Warmup
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
//This is call when player accept to join war
|
||||
//Param1:(BattleId) the BattleId of Bf
|
||||
void WorldSession::SendBfEntered(uint32 BattleId)
|
||||
/**
|
||||
* @fn void WorldSession::SendBfEntered(uint32 battleId)
|
||||
*
|
||||
* @brief This is call when player accept to join war.
|
||||
*
|
||||
* @param battleId The BattleId of Bf
|
||||
*/
|
||||
void WorldSession::SendBfEntered(uint32 battleId)
|
||||
{
|
||||
// m_PlayerInWar[player->GetTeamId()].insert(player->GetGUID());
|
||||
WorldPacket data(SMSG_BATTLEFIELD_MGR_ENTERED, 7);
|
||||
data << uint32(BattleId);
|
||||
data << uint8(1); //unk
|
||||
data << uint8(1); //unk
|
||||
data << uint8(_player->isAFK() ? 1 : 0); //Clear AFK
|
||||
data << uint32(battleId);
|
||||
data << uint8(1); // unk
|
||||
data << uint8(1); // unk
|
||||
data << uint8(_player->isAFK() ? 1 : 0); // Clear AFK
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason)
|
||||
/**
|
||||
* @fn void WorldSession::SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason)
|
||||
*
|
||||
* @brief This is call when player leave battlefield zone.
|
||||
*
|
||||
* @param battleId The BattleId of Bf
|
||||
* @param reason Reason why player left battlefield
|
||||
*/
|
||||
void WorldSession::SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason /*= BF_LEAVE_REASON_EXITED*/)
|
||||
{
|
||||
WorldPacket data(SMSG_BATTLEFIELD_MGR_EJECTED, 7);
|
||||
data << uint32(BattleId);
|
||||
data << uint8(reason);//byte Reason
|
||||
data << uint8(2);//byte BattleStatus
|
||||
data << uint8(0);//bool Relocated
|
||||
data << uint32(battleId);
|
||||
data << uint8(reason); // byte Reason
|
||||
data << uint8(2); // byte BattleStatus
|
||||
data << uint8(0); // bool Relocated
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
//Send by client when he click on accept for queue
|
||||
void WorldSession::HandleBfQueueInviteResponse(WorldPacket & recvData)
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData)
|
||||
*
|
||||
* @brief Send by client when he click on accept for queue.
|
||||
*/
|
||||
void WorldSession::HandleBfQueueInviteResponse(WorldPacket& recvData)
|
||||
{
|
||||
uint32 BattleId;
|
||||
uint8 Accepted;
|
||||
uint32 battleId;
|
||||
uint8 accepted;
|
||||
|
||||
recvData >> BattleId >> Accepted;
|
||||
TC_LOG_DEBUG("misc", "HandleQueueInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
||||
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||
if (!Bf)
|
||||
recvData >> battleId >> accepted;
|
||||
|
||||
TC_LOG_DEBUG("misc", "HandleBfQueueInviteResponse: BattleID:%u Accepted:%u", battleId, accepted);
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
if (Accepted)
|
||||
{
|
||||
Bf->PlayerAcceptInviteToQueue(_player);
|
||||
}
|
||||
if (accepted)
|
||||
bf->PlayerAcceptInviteToQueue(_player);
|
||||
}
|
||||
|
||||
//Send by client on clicking in accept or refuse of invitation windows for join game
|
||||
void WorldSession::HandleBfEntryInviteResponse(WorldPacket & recvData)
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData)
|
||||
*
|
||||
* @brief Send by client on clicking in accept or refuse of invitation windows for join game.
|
||||
*/
|
||||
void WorldSession::HandleBfEntryInviteResponse(WorldPacket& recvData)
|
||||
{
|
||||
uint32 BattleId;
|
||||
uint8 Accepted;
|
||||
uint32 battleId;
|
||||
uint8 accepted;
|
||||
|
||||
recvData >> BattleId >> Accepted;
|
||||
TC_LOG_DEBUG("misc", "HandleBattlefieldInviteResponse: BattleID:%u Accepted:%u", BattleId, Accepted);
|
||||
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||
if (!Bf)
|
||||
recvData >> battleId >> accepted;
|
||||
|
||||
TC_LOG_DEBUG("misc", "HandleBfEntryInviteResponse: battleId: %u, accepted: %u", battleId, accepted);
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
//If player accept invitation
|
||||
if (Accepted)
|
||||
// If player accept invitation
|
||||
if (accepted)
|
||||
{
|
||||
Bf->PlayerAcceptInviteToWar(_player);
|
||||
bf->PlayerAcceptInviteToWar(_player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_player->GetZoneId() == Bf->GetZoneId())
|
||||
Bf->KickPlayerFromBattlefield(_player->GetGUID());
|
||||
if (_player->GetZoneId() == bf->GetZoneId())
|
||||
bf->KickPlayerFromBattlefield(_player->GetGUID());
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleBfExitRequest(WorldPacket & recvData)
|
||||
/**
|
||||
* @fn void WorldSession::HandleBfExitRequest(WorldPacket& recvData)
|
||||
*
|
||||
* @brief Send by client when exited battlefield
|
||||
*/
|
||||
void WorldSession::HandleBfExitRequest(WorldPacket& recvData)
|
||||
{
|
||||
uint32 BattleId;
|
||||
uint32 battleId;
|
||||
|
||||
recvData >> BattleId;
|
||||
TC_LOG_DEBUG("misc", "HandleBfExitRequest: BattleID:%u ", BattleId);
|
||||
Battlefield* Bf = sBattlefieldMgr->GetBattlefieldByBattleId(BattleId);
|
||||
if (!Bf)
|
||||
recvData >> battleId;
|
||||
|
||||
TC_LOG_DEBUG("misc", "HandleBfExitRequest: battleId: %u ", battleId);
|
||||
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||
if (!bf)
|
||||
return;
|
||||
|
||||
Bf->AskToLeaveQueue(_player);
|
||||
bf->AskToLeaveQueue(_player);
|
||||
}
|
||||
|
||||
@@ -757,6 +757,16 @@ class WorldSession
|
||||
void HandleBattlemasterJoinArena(WorldPacket& recvData);
|
||||
void HandleReportPvPAFK(WorldPacket& recvData);
|
||||
|
||||
// Battlefield
|
||||
void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time);
|
||||
void SendBfInvitePlayerToQueue(uint32 battleId);
|
||||
void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue = true, bool full = false);
|
||||
void SendBfEntered(uint32 battleId);
|
||||
void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
|
||||
void HandleBfQueueInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfEntryInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfExitRequest(WorldPacket& recvData);
|
||||
|
||||
void HandleWardenDataOpcode(WorldPacket& recvData);
|
||||
void HandleWorldTeleportOpcode(WorldPacket& recvData);
|
||||
void HandleMinimapPingOpcode(WorldPacket& recvData);
|
||||
@@ -773,16 +783,6 @@ class WorldSession
|
||||
void HandleHearthAndResurrect(WorldPacket& recvData);
|
||||
void HandleInstanceLockResponse(WorldPacket& recvPacket);
|
||||
|
||||
// Battlefield
|
||||
void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time);
|
||||
void SendBfInvitePlayerToQueue(uint32 battleId);
|
||||
void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue = true, bool full = false);
|
||||
void SendBfEntered(uint32 battleId);
|
||||
void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason = BF_LEAVE_REASON_EXITED);
|
||||
void HandleBfQueueInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfEntryInviteResponse(WorldPacket& recvData);
|
||||
void HandleBfExitRequest(WorldPacket& recvData);
|
||||
|
||||
// Looking for Dungeon/Raid
|
||||
void HandleLfgSetCommentOpcode(WorldPacket& recvData);
|
||||
void HandleLfgPlayerLockInfoRequestOpcode(WorldPacket& recvData);
|
||||
|
||||
Reference in New Issue
Block a user