mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-15 21:45:12 +00:00
fix(Core/Battlefield): Erase invite by real team on war accept and add queue list command (#25056)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -442,7 +442,7 @@ void Battlefield::PlayerAcceptInviteToWar(Player* player)
|
||||
{
|
||||
player->GetSession()->SendBfEntered(m_BattleId);
|
||||
m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
|
||||
m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
|
||||
m_InvitedPlayers[player->GetTeamId(true)].erase(player->GetGUID());
|
||||
|
||||
if (player->isAFK())
|
||||
player->ToggleAFK();
|
||||
|
||||
@@ -361,6 +361,14 @@ public:
|
||||
// Returns the maximum players allowed per team
|
||||
uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayer; }
|
||||
|
||||
/// Returns the set of players waiting in the pre-battle queue (per team, read-only).
|
||||
GuidUnorderedSet const& GetPlayersQueueSet(TeamId teamId) const { return m_PlayersInQueue[teamId]; }
|
||||
/// Returns the map of players invited to join the active war, value is invite expiry
|
||||
/// timestamp (per team, read-only).
|
||||
PlayerTimerMap const& GetInvitedPlayersMap(TeamId teamId) const { return m_InvitedPlayers[teamId]; }
|
||||
/// Returns the set of players actively fighting in the war (per team, read-only).
|
||||
GuidUnorderedSet const& GetPlayersInWarSet(TeamId teamId) const { return m_PlayersInWar[teamId]; }
|
||||
|
||||
void DoPlaySoundToAll(uint32 SoundID);
|
||||
|
||||
void InvitePlayerToQueue(Player* player);
|
||||
|
||||
@@ -1194,7 +1194,15 @@ enum AcoreStrings
|
||||
|
||||
LANG_RESETALL_HONOR = 5118,
|
||||
LANG_RESETALL_ARENA = 5119,
|
||||
// Room for more strings 5120-9999
|
||||
|
||||
// Battlefield queue display (.bf queue)
|
||||
LANG_BF_QUEUE_HDR_WAR = 5120,
|
||||
LANG_BF_QUEUE_HDR_WAIT = 5121,
|
||||
LANG_BF_QUEUE_TEAM_HDR = 5122,
|
||||
LANG_BF_QUEUE_PLAYER_QUEUE = 5123,
|
||||
LANG_BF_QUEUE_PLAYER_INVITED = 5124,
|
||||
LANG_BF_QUEUE_PLAYER_WAR = 5125,
|
||||
// Room for more strings 5126-9999
|
||||
|
||||
// Level requirement notifications
|
||||
LANG_SAY_REQ = 6604,
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include "Chat.h"
|
||||
#include "CommandScript.h"
|
||||
#include "Language.h"
|
||||
#include "GameTime.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
@@ -35,7 +38,8 @@ public:
|
||||
{ "stop", HandleBattlefieldEnd, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "switch", HandleBattlefieldSwitch, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "timer", HandleBattlefieldTimer, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::Yes }
|
||||
{ "enable", HandleBattlefieldEnable, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "queue", HandleBattlefieldQueue, SEC_GAMEMASTER, Console::Yes }
|
||||
};
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
@@ -167,6 +171,63 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleBattlefieldQueue(ChatHandler* handler, uint32 battleId)
|
||||
{
|
||||
Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
|
||||
|
||||
if (!bf)
|
||||
{
|
||||
handler->SendErrorMessage(LANG_BF_NOT_FOUND, battleId);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(bf->IsWarTime() ? LANG_BF_QUEUE_HDR_WAR : LANG_BF_QUEUE_HDR_WAIT,
|
||||
battleId, bf->GetTimer() / IN_MILLISECONDS);
|
||||
|
||||
static char const* teamNames[PVP_TEAMS_COUNT] = { "Alliance", "Horde" };
|
||||
|
||||
std::string offlineSuffix = handler->GetAcoreString(LANG_OFFLINE);
|
||||
|
||||
auto nameOf = [offlineSuffix](ObjectGuid guid) -> std::string
|
||||
{
|
||||
if (Player* p = ObjectAccessor::FindPlayer(guid))
|
||||
return p->GetName();
|
||||
return std::to_string(guid.GetCounter()) + offlineSuffix;
|
||||
};
|
||||
|
||||
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
||||
{
|
||||
TeamId team = TeamId(i);
|
||||
|
||||
GuidUnorderedSet const& inQueue = bf->GetPlayersQueueSet(team);
|
||||
PlayerTimerMap const& invited = bf->GetInvitedPlayersMap(team);
|
||||
GuidUnorderedSet const& inWar = bf->GetPlayersInWarSet(team);
|
||||
|
||||
handler->PSendSysMessage(LANG_BF_QUEUE_TEAM_HDR,
|
||||
teamNames[i],
|
||||
static_cast<uint32>(inQueue.size()),
|
||||
static_cast<uint32>(invited.size()),
|
||||
static_cast<uint32>(inWar.size()));
|
||||
|
||||
for (ObjectGuid const& guid : inQueue)
|
||||
handler->PSendSysMessage(LANG_BF_QUEUE_PLAYER_QUEUE, nameOf(guid));
|
||||
|
||||
SystemTimePoint now = GameTime::GetSystemTime();
|
||||
for (auto const& [guid, expiry] : invited)
|
||||
{
|
||||
SystemTimePoint expiryPoint = std::chrono::system_clock::from_time_t(expiry);
|
||||
int32 secsLeft = std::max(int32(0), static_cast<int32>(
|
||||
std::chrono::duration_cast<Seconds>(expiryPoint - now).count()));
|
||||
handler->PSendSysMessage(LANG_BF_QUEUE_PLAYER_INVITED, nameOf(guid), secsLeft);
|
||||
}
|
||||
|
||||
for (ObjectGuid const& guid : inWar)
|
||||
handler->PSendSysMessage(LANG_BF_QUEUE_PLAYER_WAR, nameOf(guid));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_bf_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user