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:
@@ -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