feat(Core/Battlegrounds) Reworked enhanced bg system for modules (#2521)

This commit is contained in:
Shard
2020-01-19 17:09:02 +01:00
committed by Francesco Borzì
parent bb42c7c5eb
commit eadcb1a782
6 changed files with 659 additions and 602 deletions
@@ -268,7 +268,9 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
}
*data << uint32(itr2->second->DamageDone); // damage done
*data << uint32(itr2->second->HealingDone); // healing done
switch (bg->GetBgTypeID()) // battleground specific things
BattlegroundTypeId bgTypeId = bg->GetBgTypeID();
switch (bgTypeId) // battleground specific things
{
case BATTLEGROUND_RB:
switch (bg->GetMapId())
@@ -305,7 +307,10 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
default:
*data << uint32(0);
if (BattlegroundMgr::getBgFromMap.find(bg->GetMapId()) != BattlegroundMgr::getBgFromMap.end())
BattlegroundMgr::getBgFromMap[bg->GetMapId()](data, itr2);
else
*data << uint32(0);
break;
}
break;
@@ -350,13 +355,16 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
*data << uint32(0);
break;
default:
*data << uint32(0);
if (BattlegroundMgr::getBgFromTypeID.find(bgTypeId) != BattlegroundMgr::getBgFromTypeID.end())
BattlegroundMgr::getBgFromTypeID[bgTypeId](data, itr2, bg);
else
*data << uint32(0);
break;
}
// should never happen
if (++scoreCount >= bg->GetMaxPlayersPerTeam()*2 && itr != bg->GetPlayerScoresEnd())
{
sLog->outMisc("Battleground %u scoreboard has more entries (%u) than allowed players in this bg (%u)", bg->GetBgTypeID(), bg->GetPlayerScoresSize(), bg->GetMaxPlayersPerTeam()*2);
sLog->outMisc("Battleground %u scoreboard has more entries (%u) than allowed players in this bg (%u)", bgTypeId, bg->GetPlayerScoresSize(), bg->GetMaxPlayersPerTeam()*2);
break;
}
}
@@ -1091,3 +1099,22 @@ std::unordered_map<int, bgRef> BattlegroundMgr::bgTypeToTemplate = {
{ BATTLEGROUND_RB, [](Battleground *bg_t) -> Battleground*{ return new Battleground(*bg_t); }, },
{ BATTLEGROUND_AA, [](Battleground *bg_t) -> Battleground*{ return new Battleground(*bg_t); }, },
};
std::unordered_map<int, bgMapRef> BattlegroundMgr::getBgFromMap = {};
std::unordered_map<int, bgTypeRef> BattlegroundMgr::getBgFromTypeID = {
{
BATTLEGROUND_RB,
[](WorldPacket* data, Battleground::BattlegroundScoreMap::const_iterator itr2, Battleground* bg)
{
if (BattlegroundMgr::getBgFromMap.find(bg->GetMapId()) == BattlegroundMgr::getBgFromMap.end()) // this should not happen
{
*data << uint32(0);
}
else
{
BattlegroundMgr::getBgFromMap[bg->GetMapId()](data, itr2);
}
}
}
};