azerothcore / mod-solo-lfg

Solo LFG Module for use on AzerothCore 3.3.5a
https://azerothcore.org
MIT License
40 stars 38 forks source link

solo-lfg incompatible with AzerothCore 4.0 #26

Closed Artanisx closed 1 year ago

Artanisx commented 3 years ago

Unfortunately, latest AC build breaks the lfg-solo.patch.

error: patch failed: src/server/game/DungeonFinding/LFGQueue.cpp:285
error: src/server/game/DungeonFinding/LFGQueue.cpp: patch does not apply

The underlying code for LFGQueue.cpp doesn't look like it's changed aside from a minor line change, however I'm unfamiliar with how git patches work so I'm currently unable to propose a way to make this patch work with the updated core.

Hopefully someone can help :)

SgtShaw commented 3 years ago

Copy the following code into your lfg-solo.patch file. This should fix the issue.

diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 307a453d3..69507e79f 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -37,8 +37,7 @@

 namespace lfg
 {
-
-    LFGMgr::LFGMgr(): m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)), m_Testing(false)
+    LFGMgr::LFGMgr(): m_lfgProposalId(1), m_options(sWorld->getIntConfig(CONFIG_LFG_OPTIONSMASK)), m_isSoloLFG(false), m_Testing(false)
     {
         new LFGPlayerScript();
         new LFGGroupScript();
@@ -1790,8 +1789,7 @@ namespace lfg
         for (LfgProposalPlayerContainer::const_iterator itPlayers = proposal.players.begin(); itPlayers != proposal.players.end(); ++itPlayers)
             if (itPlayers->second.accept != LFG_ANSWER_AGREE)   // No answer (-1) or not accepted (0)
                 allAnswered = false;
-
-        if (!m_Testing && !allAnswered)
+        if (!sLFGMgr->IsSoloLFG() && !allAnswered)
         {
             for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
                 SendLfgUpdateProposal(it->first, proposal);
@@ -2763,5 +2761,8 @@ namespace lfg
         }
         return randomDungeons;
     }
-
+    void LFGMgr::ToggleSoloLFG()
+    {
+        m_isSoloLFG = !m_isSoloLFG;
+    }
 } // namespace lfg
diff --git a/src/server/game/DungeonFinding/LFGMgr.h b/src/server/game/DungeonFinding/LFGMgr.h
index 96773f24c..7498b0da5 100644
--- a/src/server/game/DungeonFinding/LFGMgr.h
+++ b/src/server/game/DungeonFinding/LFGMgr.h
@@ -553,6 +553,10 @@ namespace lfg
         void RBPacketAppendPlayer(const RBInternalInfo& info, ByteBuffer& buffer);
         void RBPacketBuildDifference(WorldPacket& differencePacket, uint32 dungeonId, uint32 deletedCounter, ByteBuffer& buffer_deleted, uint32 groupCounter, ByteBuffer& buffer_groups, uint32 playerCounter, ByteBuffer& buffer_players);
         void RBPacketBuildFull(WorldPacket& fullPacket, uint32 dungeonId, RBInternalInfoMap& infoMap);
+        /// Toggle LFG in debug mode
+        void ToggleSoloLFG();
+        /// Check if debug mode
+        bool IsSoloLFG() const { return m_isSoloLFG; }

         // LfgQueue
         /// Get last lfg state (NONE, DUNGEON or FINISHED_DUNGEON)
@@ -616,6 +620,7 @@ namespace lfg
         uint32 lastProposalId;                             ///< pussywizard, store it here because of splitting LFGMgr update into tasks
         uint32 m_raidBrowserUpdateTimer[2];                ///< pussywizard
         uint32 m_raidBrowserLastUpdatedDungeonId[2];       ///< pussywizard: for 2 factions
+        bool m_isSoloLFG;                                  ///< solo lfg

         LfgQueueContainer QueuesStore;                     ///< Queues
         LfgCachedDungeonContainer CachedDungeonMapStore;   ///< Stores all dungeons by groupType
diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp
index 8f47db421..d2d1b9e66 100644
--- a/src/server/game/DungeonFinding/LFGQueue.cpp
+++ b/src/server/game/DungeonFinding/LFGQueue.cpp
@@ -289,7 +289,7 @@ namespace lfg
             return LFG_INCOMPATIBLES_MULTIPLE_LFG_GROUPS;

         // Group with less that MAXGROUPSIZE members always compatible
-        if (!sLFGMgr->IsTesting() && check.size() == 1 && numPlayers < MAXGROUPSIZE)
+        if (!sLFGMgr->IsSoloLFG() && numPlayers != MAXGROUPSIZE) // solo lfg
         {
             LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front());
             LfgRolesMap roles = itQueue->second.roles;
@@ -386,7 +386,7 @@ namespace lfg
         }

         // Enough players?
-        if (!sLFGMgr->IsTesting() && numPlayers != MAXGROUPSIZE)
+        if (!sLFGMgr->IsSoloLFG() && numPlayers != MAXGROUPSIZE) // solo lfg
         {
             strGuids.addRoles(proposalRoles);
             for (uint8 i = 0; i < 5 && check.guids[i]; ++i)
Artanisx commented 3 years ago

I will try, thank you very much :)

foley64 commented 2 years ago

The code should be paste at the beginning or the end? Or must replace all the code ? Because I try this fix but it did not work for me.

pangolp commented 1 year ago

The module was recently updated, so it should be compatible with the latest version of the emulator. If the problem persists, please do not hesitate to re-create an issue, completing the data and providing all the necessary information so that we can solve the problem. Thank you.