From aa9a39e07f9263bcf39f0ce39ade9d945de351f9 Mon Sep 17 00:00:00 2001 From: Efymer <79163132+Efymer@users.noreply.github.com> Date: Tue, 14 Sep 2021 17:08:49 +0200 Subject: [PATCH] feat(Core/debug): Add commad to debug lfg (#6638) * feat(Core/debug): Add commad to debug lfg * Update LFGMgr.h * Update rev_1624914323095978900.sql * Code review fixes Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> --- .../pending_db_world/rev_1624914323095978900.sql | 10 ++++++++++ src/server/game/DungeonFinding/LFGMgr.cpp | 16 +++++++++++++--- src/server/game/DungeonFinding/LFGMgr.h | 5 +++++ src/server/game/DungeonFinding/LFGQueue.cpp | 4 ++-- src/server/game/Miscellaneous/Language.h | 5 ++++- src/server/scripts/Commands/cs_debug.cpp | 7 +++++++ 6 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1624914323095978900.sql diff --git a/data/sql/updates/pending_db_world/rev_1624914323095978900.sql b/data/sql/updates/pending_db_world/rev_1624914323095978900.sql new file mode 100644 index 000000000..7657fdd16 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1624914323095978900.sql @@ -0,0 +1,10 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1624914323095978900'); + +DELETE FROM `acore_string` WHERE `entry` IN (30096, 30097); +INSERT INTO `acore_string` (`entry`, `content_default`) VALUES + (30096, 'LFG is set to 1 player queue for debugging.'), + (30097, 'LFG is set to normal queue.'); + +DELETE FROM `command` WHERE `name` = 'debug lfg'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES + ('debug lfg', 3, 'Syntax: .debug lfg\r\nToggle debug mode for lfg. In debug mode GM can start lfg queue with one player.'); diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 4bf81bf70..9ce415f32 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -27,7 +27,7 @@ namespace lfg { - LFGMgr::LFGMgr(): m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)) + LFGMgr::LFGMgr(): m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)), m_Testing(false) { new LFGPlayerScript(); new LFGGroupScript(); @@ -768,6 +768,12 @@ namespace lfg }*/ } + void LFGMgr::ToggleTesting() + { + m_Testing = !m_Testing; + sWorld->SendWorldText(m_Testing ? LANG_DEBUG_LFG_ON : LANG_DEBUG_LFG_OFF); + } + /** Leaves Dungeon System. Player/Group is removed from queue, rolechecks, proposals or votekicks. Player or group needs to be not nullptr and using Dungeon System @@ -1645,7 +1651,11 @@ namespace lfg if ((randomDungeon || selectedRandomLfgDungeon(player->GetGUID())) && !player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN)) { randomDungeon = true; - player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player); + // if player is debugging, don't add dungeon cooldown + if (!m_Testing) + { + player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player); + } } if (player->GetMapId() == uint32(dungeon->map)) @@ -1723,7 +1733,7 @@ namespace lfg if (itPlayers->second.accept != LFG_ANSWER_AGREE) // No answer (-1) or not accepted (0) allAnswered = false; - if (!allAnswered) + if (!m_Testing && !allAnswered) { for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it) SendLfgUpdateProposal(it->first, proposal); diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h index 7b289bd07..5c99a9f78 100644 --- a/src/server/game/DungeonFinding/LFGMgr.h +++ b/src/server/game/DungeonFinding/LFGMgr.h @@ -551,6 +551,10 @@ namespace lfg static bool HasIgnore(ObjectGuid guid1, ObjectGuid guid2); /// Sends queue status to player static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const& data); + // debug lfg command + void ToggleTesting(); + /// For 1 player queue testing + [[nodiscard]] bool IsTesting() const { return m_Testing; } void SetDungeon(ObjectGuid guid, uint32 dungeon); @@ -604,6 +608,7 @@ namespace lfg LfgPlayerBootContainer BootsStore; ///< Current player kicks LfgPlayerDataContainer PlayersStore; ///< Player data LfgGroupDataContainer GroupsStore; ///< Group data + bool m_Testing; }; } // namespace lfg diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index e81768ad1..158df87e7 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -288,7 +288,7 @@ namespace lfg return LFG_INCOMPATIBLES_MULTIPLE_LFG_GROUPS; // Group with less that MAXGROUPSIZE members always compatible - if (check.size() == 1 && numPlayers < MAXGROUPSIZE) + if (!sLFGMgr->IsTesting() && check.size() == 1 && numPlayers < MAXGROUPSIZE) { LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front()); LfgRolesMap roles = itQueue->second.roles; @@ -385,7 +385,7 @@ namespace lfg } // Enough players? - if (numPlayers != MAXGROUPSIZE) + if (!sLFGMgr->IsTesting() && numPlayers != MAXGROUPSIZE) { strGuids.addRoles(proposalRoles); for (uint8 i = 0; i < 5 && check.guids[i]; ++i) diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 1bca91600..704e7e93b 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1355,8 +1355,11 @@ enum AcoreStrings LANG_BG_READY_CHECK_ERROR = 30084, LANG_DEBUG_BG_CONF = 30085, - LANG_DEBUG_ARENA_CONF = 30086 + LANG_DEBUG_ARENA_CONF = 30086, // 30087-30095 reserved for passive anticheat + + LANG_DEBUG_LFG_ON = 30096, + LANG_DEBUG_LFG_OFF = 30097 }; #endif diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index a448f4d2a..18f225fa3 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -75,6 +75,7 @@ public: { "update", SEC_ADMINISTRATOR, false, &HandleDebugUpdateCommand, "" }, { "itemexpire", SEC_ADMINISTRATOR, false, &HandleDebugItemExpireCommand, "" }, { "areatriggers", SEC_ADMINISTRATOR, false, &HandleDebugAreaTriggersCommand, "" }, + { "lfg", SEC_ADMINISTRATOR, false, &HandleDebugDungeonFinderCommand, "" }, { "los", SEC_ADMINISTRATOR, false, &HandleDebugLoSCommand, "" }, { "moveflags", SEC_ADMINISTRATOR, false, &HandleDebugMoveflagsCommand, "" }, { "unitstate", SEC_ADMINISTRATOR, false, &HandleDebugUnitStateCommand, "" } @@ -805,6 +806,12 @@ public: return true; } + static bool HandleDebugDungeonFinderCommand(ChatHandler* /*handler*/, char const* /*args*/) + { + sLFGMgr->ToggleTesting(); + return true; + } + static bool HandleDebugBattlegroundCommand(ChatHandler* /*handler*/, char const* /*args*/) { sBattlegroundMgr->ToggleTesting();