mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/Packets: converted SMSG_BATTLEFIELD_LIST to packet class and handle remaining fields
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "BattlegroundIC.h"
|
||||
#include "BattlegroundTP.h"
|
||||
#include "BattlegroundBFG.h"
|
||||
#include "BattlegroundPackets.h"
|
||||
#include "Common.h"
|
||||
#include "Containers.h"
|
||||
#include "Chat.h"
|
||||
@@ -865,74 +866,45 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u battlegrounds in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, bool hideWindow /*= true*/)
|
||||
void BattlegroundMgr::SendBattlegroundList(ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId);
|
||||
if (!bgTemplate)
|
||||
return;
|
||||
|
||||
uint32 winnerConquest = (player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_CONQUEST_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_CONQUEST_FIRST)) / CURRENCY_PRECISION;
|
||||
uint32 winnerHonor = (player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_FIRST)) / CURRENCY_PRECISION;
|
||||
uint32 loserHonor = (!player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST)) / CURRENCY_PRECISION;
|
||||
uint32 loserHonor = (player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST)) / CURRENCY_PRECISION;
|
||||
|
||||
data->Initialize(SMSG_BATTLEFIELD_LIST);
|
||||
*data << uint32(winnerConquest) // Winner Conquest Reward or Random Winner Conquest Reward
|
||||
<< uint32(winnerConquest) // Winner Conquest Reward or Random Winner Conquest Reward
|
||||
<< uint32(loserHonor) // Loser Honor Reward or Random Loser Honor Reward
|
||||
<< uint32(bgTypeId) // battleground id
|
||||
<< uint32(loserHonor) // Loser Honor Reward or Random Loser Honor Reward
|
||||
<< uint32(winnerHonor) // Winner Honor Reward or Random Winner Honor Reward
|
||||
<< uint32(winnerHonor) // Winner Honor Reward or Random Winner Honor Reward
|
||||
<< uint8(bgTemplate->MaxLevel) // max level
|
||||
<< uint8(bgTemplate->MinLevel); // min level
|
||||
|
||||
data->WriteBit(guid[0]);
|
||||
data->WriteBit(guid[1]);
|
||||
data->WriteBit(guid[7]);
|
||||
data->WriteBit(0); // unk
|
||||
data->WriteBit(0); // unk
|
||||
|
||||
size_t count_pos = data->bitwpos();
|
||||
data->WriteBits(0, 24); // placeholder
|
||||
|
||||
data->WriteBit(guid[6]);
|
||||
data->WriteBit(guid[4]);
|
||||
data->WriteBit(guid[2]);
|
||||
data->WriteBit(guid[3]);
|
||||
data->WriteBit(0); // unk
|
||||
data->WriteBit(guid[5]);
|
||||
data->WriteBit(hideWindow); // hide battleground list window
|
||||
|
||||
data->FlushBits();
|
||||
|
||||
data->WriteByteSeq(guid[6]);
|
||||
data->WriteByteSeq(guid[1]);
|
||||
data->WriteByteSeq(guid[7]);
|
||||
data->WriteByteSeq(guid[5]);
|
||||
WorldPackets::Battleground::BattlefieldList battlefieldList;
|
||||
battlefieldList.ConquestBonusRandom = winnerConquest;
|
||||
battlefieldList.ConquestBonusHoliday = winnerConquest;
|
||||
battlefieldList.HonorBonusRandomWin = winnerHonor;
|
||||
battlefieldList.HonorBonusHolidayWin = winnerHonor;
|
||||
battlefieldList.HonorBonusRandomLoss = loserHonor;
|
||||
battlefieldList.HonorBonusHolidayLoss = loserHonor;
|
||||
battlefieldList.BattlemasterGuid = guid;
|
||||
battlefieldList.BattlemasterListID = bgTypeId;
|
||||
battlefieldList.MinLevel = bgTemplate->MinLevel;
|
||||
battlefieldList.MaxLevel = bgTemplate->MaxLevel;
|
||||
battlefieldList.PvpAnywhere = guid.IsEmpty();
|
||||
battlefieldList.IsRandomBG = bgTypeId == BATTLEGROUND_RB;
|
||||
battlefieldList.HasRandomWinToday = player->GetRandomWinner();
|
||||
|
||||
BattlegroundDataContainer::iterator it = bgDataStore.find(bgTypeId);
|
||||
if (it != bgDataStore.end())
|
||||
{
|
||||
|
||||
PvPDifficultyEntry const* bracketEntry = sDBCManager.GetBattlegroundBracketByLevel(it->second.m_Battlegrounds.begin()->second->GetMapId(), player->getLevel());
|
||||
if (bracketEntry)
|
||||
{
|
||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
BattlegroundClientIdsContainer& clientIds = it->second.m_ClientBattlegroundIds[bracketId];
|
||||
for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end(); ++itr)
|
||||
*data << uint32(*itr);
|
||||
|
||||
data->PutBits(count_pos, clientIds.size(), 24); // bg instance count
|
||||
battlefieldList.Battlefields.push_back(uint32(*itr));
|
||||
}
|
||||
}
|
||||
|
||||
data->WriteByteSeq(guid[0]);
|
||||
data->WriteByteSeq(guid[2]);
|
||||
data->WriteByteSeq(guid[4]);
|
||||
data->WriteByteSeq(guid[3]);
|
||||
player->SendDirectMessage(battlefieldList.Write());
|
||||
}
|
||||
|
||||
void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId)
|
||||
|
||||
@@ -68,11 +68,11 @@ class TC_GAME_API BattlegroundMgr
|
||||
/* Packet Building */
|
||||
void BuildPlayerJoinedBattlegroundPacket(WorldPacket* data, ObjectGuid guid);
|
||||
void BuildPlayerLeftBattlegroundPacket(WorldPacket* data, ObjectGuid guid);
|
||||
void BuildBattlegroundListPacket(WorldPacket* data, ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId, bool hideWindow = true);
|
||||
void BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result);
|
||||
void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value);
|
||||
void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType);
|
||||
void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, ObjectGuid guid);
|
||||
void SendBattlegroundList(ObjectGuid guid, Player* player, BattlegroundTypeId bgTypeId);
|
||||
|
||||
/* Battlegrounds */
|
||||
Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId);
|
||||
|
||||
@@ -765,8 +765,8 @@ struct BattlemasterListEntry
|
||||
char* Name; // 11
|
||||
uint32 MaxGroupSize; // 12 maxGroupSize, used for checking if queue as group
|
||||
uint32 HolidayWorldState; // 13 new 3.1
|
||||
uint32 Minlevel; // 14, min level (sync with PvPDifficulty.dbc content)
|
||||
uint32 Maxlevel; // 15, max level (sync with PvPDifficulty.dbc content)
|
||||
uint32 MinLevel; // 14, min level (sync with PvPDifficulty.dbc content)
|
||||
uint32 MaxLevel; // 15, max level (sync with PvPDifficulty.dbc content)
|
||||
//uint32 RatedPlayers; // 16 4.0.1
|
||||
//uint32 MinPlayers; // 17 - 4.0.6.13596
|
||||
//uint32 MaxPlayers; // 18 4.0.1
|
||||
|
||||
@@ -14129,7 +14129,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
|
||||
return;
|
||||
}
|
||||
|
||||
GetSession()->SendBattleGroundList(guid, bgTypeId);
|
||||
sBattlegroundMgr->SendBattlegroundList(source->GetGUID(), this, BattlegroundTypeId(bgTypeId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,14 +66,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
SendBattleGroundList(guid, bgTypeId);
|
||||
}
|
||||
|
||||
void WorldSession::SendBattleGroundList(ObjectGuid guid, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildBattlegroundListPacket(&data, guid, _player, bgTypeId, false);
|
||||
SendPacket(&data);
|
||||
sBattlegroundMgr->SendBattlegroundList(guid, _player, bgTypeId);
|
||||
}
|
||||
|
||||
void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
|
||||
@@ -400,9 +393,7 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildBattlegroundListPacket(&data, ObjectGuid::Empty, _player, BattlegroundTypeId(bgTypeId));
|
||||
SendPacket(&data);
|
||||
sBattlegroundMgr->SendBattlegroundList(ObjectGuid::Empty, _player, BattlegroundTypeId(bgTypeId));
|
||||
}
|
||||
|
||||
void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
|
||||
|
||||
@@ -61,3 +61,50 @@ WorldPacket const* WorldPackets::Battleground::BattlefieldRatedInfo::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Battleground::BattlefieldList::Write()
|
||||
{
|
||||
_worldPacket << int32(ConquestBonusHoliday);
|
||||
_worldPacket << int32(ConquestBonusRandom);
|
||||
|
||||
_worldPacket << int32(HonorBonusHolidayLoss);
|
||||
_worldPacket << int32(BattlemasterListID);
|
||||
_worldPacket << int32(HonorBonusRandomLoss);
|
||||
|
||||
_worldPacket << int32(HonorBonusRandomWin);
|
||||
_worldPacket << int32(HonorBonusHolidayWin);
|
||||
_worldPacket << uint8(MaxLevel);
|
||||
_worldPacket << uint8(MinLevel);
|
||||
|
||||
_worldPacket.WriteBit(BattlemasterGuid[0]);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[1]);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[7]);
|
||||
|
||||
_worldPacket.WriteBit(HasHolidayWinToday);
|
||||
_worldPacket.WriteBit(HasRandomWinToday);
|
||||
_worldPacket.WriteBits(Battlefields.size(), 24);
|
||||
|
||||
_worldPacket.WriteBit(BattlemasterGuid[6]);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[4]);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[2]);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[3]);
|
||||
_worldPacket.WriteBit(IsRandomBG);
|
||||
_worldPacket.WriteBit(BattlemasterGuid[5]);
|
||||
_worldPacket.WriteBit(PvpAnywhere);
|
||||
_worldPacket.FlushBits();
|
||||
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[6]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[1]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[7]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[5]);
|
||||
|
||||
for (int32 battlefield : Battlefields)
|
||||
_worldPacket << int32(battlefield);
|
||||
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[0]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[2]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[4]);
|
||||
_worldPacket.WriteByteSeq(BattlemasterGuid[3]);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,32 @@ namespace WorldPackets
|
||||
int32 PurseQuantity = 0;
|
||||
int8 Unk = 0; // Same value as in cmsg
|
||||
};
|
||||
|
||||
class BattlefieldList final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
BattlefieldList() : ServerPacket(SMSG_BATTLEFIELD_LIST, 35) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid BattlemasterGuid;
|
||||
int32 BattlemasterListID = 0;
|
||||
int32 ConquestBonusRandom = 0;
|
||||
int32 ConquestBonusHoliday = 0;
|
||||
int32 HonorBonusRandomWin = 0;
|
||||
int32 HonorBonusRandomLoss = 0;
|
||||
int32 HonorBonusHolidayWin = 0;
|
||||
int32 HonorBonusHolidayLoss = 0;
|
||||
int32 HonorLossBonus = 0;
|
||||
int32 HonorWinBonus = 0;
|
||||
uint8 MinLevel = 0;
|
||||
uint8 MaxLevel = 0;
|
||||
std::vector<int32> Battlefields;
|
||||
bool PvpAnywhere = false;
|
||||
bool IsRandomBG = false;
|
||||
bool HasRandomWinToday = false;
|
||||
bool HasHolidayWinToday = false;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -486,8 +486,6 @@ class TC_GAME_API WorldSession
|
||||
|
||||
void SendAttackStop(Unit const* enemy);
|
||||
|
||||
void SendBattleGroundList(ObjectGuid guid, BattlegroundTypeId bgTypeId = BATTLEGROUND_RB);
|
||||
|
||||
void SendTradeStatus(TradeStatusInfo const& status);
|
||||
void SendUpdateTrade(bool trader_data = true);
|
||||
void SendCancelTrade();
|
||||
|
||||
Reference in New Issue
Block a user