Skip to content

Instantly share code, notes, and snippets.

@Langerz82
Created January 2, 2019 10:25
Show Gist options
  • Save Langerz82/6f9d5f769b0ca9adc823838c5766309e to your computer and use it in GitHub Desktop.
Save Langerz82/6f9d5f769b0ca9adc823838c5766309e to your computer and use it in GitHub Desktop.
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 30f7a56daf..96006ffa38 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -810,6 +810,27 @@ void Battleground::EndBattleground(uint32 winner)
player->SendDirectMessage(&data);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, player->GetMapId());
}
+
+ Player* aPlayer = _GetPlayerForTeam(ALLIANCE, m_Players.begin(), "EndBattleground");
+ if (aPlayer)
+ {
+ GroupQueueInfo* gInfo = nullptr;
+ sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).GetPlayerGroupInfoData(aPlayer->GetGUID(), gInfo);
+ LastChallenged* lc = new LastChallenged();
+ lc->GroupInfo = gInfo;
+ lc->LastBattledTime = GameTime::GetGameTimeMS();
+ gInfo->LastChallenged.push_back(lc);
+ }
+ Player* hPlayer = _GetPlayerForTeam(HORDE, m_Players.begin(), "EndBattleground");
+ if (hPlayer)
+ {
+ GroupQueueInfo* gInfo = nullptr;
+ sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).GetPlayerGroupInfoData(hPlayer->GetGUID(), gInfo);
+ LastChallenged* lc = new LastChallenged();
+ lc->GroupInfo = gInfo;
+ lc->LastBattledTime = GameTime::GetGameTimeMS();
+ gInfo->LastChallenged.push_back(lc);
+ }
}
uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index c2db3fb193..1787785cf2 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -912,6 +912,27 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
}
else if (!front1 && !front2)
return; //queues are empty
+
+ if (front1)
+ {
+ if (front1->LastChallenged.size())
+ {
+ for (std::vector<LastChallenged*>::iterator lc = front1->LastChallenged.end(); lc != front1->LastChallenged.begin(); --lc)
+ {
+ if (front2 == (*lc)->GroupInfo)
+ {
+ if ((*lc)->LastBattledTime + 120000 > GameTime::GetGameTimeMS())
+ {
+ return;
+ }
+ else
+ {
+ front1->LastChallenged.erase(lc);
+ }
+ }
+ }
+ }
+ }
}
//set rating range
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
index aca955780a..c30dc9e778 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.h
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
@@ -38,6 +38,12 @@ struct PlayerQueueInfo // stores informatio
GroupQueueInfo* GroupInfo; // pointer to the associated groupqueueinfo
};
+struct LastChallenged
+{
+ GroupQueueInfo* GroupInfo;
+ uint32 LastBattledTime;
+};
+
struct GroupQueueInfo // stores information about the group in queue (also used when joined as solo!)
{
std::map<ObjectGuid, PlayerQueueInfo*> Players; // player queue info map
@@ -53,6 +59,7 @@ struct GroupQueueInfo // stores informatio
uint32 ArenaMatchmakerRating; // if rated match, inited to the rating of the team
uint32 OpponentsTeamRating; // for rated arena matches
uint32 OpponentsMatchmakerRating; // for rated arena matches
+ std::vector<LastChallenged*> LastChallenged;
};
enum BattlegroundQueueGroupTypes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment