Jump to content

[Simple request] BG leave function


Recommended Posts

Posted

Hi! I have a simple question: what is the portion of code used when a player right-click the BG query icon and press "leave queue" ? What the MANGoS will do? I'm sure it is in battleground.cpp or in battlegroundmgr.cpp but i cant find exactly where..

I have to use this function when a player enter in a battleground, forcing him to leave other queues. In thi way, it will be impossible to switch from a bg to another one..

I've added this for now, and it works, but it seems that the queue slot is not free..

Index: src\\game\\BattleGroundHandler.cpp
===================================================================
--- src\\game\\BattleGroundHandler.cpp    (Original)
+++ src\\game\\BattleGroundHandler.cpp    (Mine)
@@ -459,6 +459,17 @@
                sBattleGroundMgr.SendToBattleGround(_player, instanceId);
                // add only in HandleMoveWorldPortAck()
                // bg->AddPlayer(_player,team);
+                for(int qId = 1; qId <= 7; ++qId)
+                {
+                    if(bgQueueTypeId != qId)
+                    {
+                        queueSlot = _player->GetBattleGroundQueueIndex(qId);
+                        _player->RemoveBattleGroundQueueId(qId);
+                        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player->GetTeam(), queueSlot, STATUS_NONE, 0, 0);
+                        sBattleGroundMgr.m_BattleGroundQueues[qId].RemovePlayer(_player->GetGUID(), true);
+                        SendPacket(&data);
+                    }
+                }
                sLog.outDebug("Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.",_player->GetName(),_player->GetGUIDLow(),bg->GetInstanceID(),bg->GetTypeID(),bgQueueTypeId);
                break;
            case 0:                                         // leave queue

What I've forgotten?

Posted

ok i think that i've resolved, if someone is interessed in this, it should be:

Index: src\\game\\BattleGroundHandler.cpp
===================================================================
--- src\\game\\BattleGroundHandler.cpp    (Original)
+++ src\\game\\BattleGroundHandler.cpp    (Mine)
@@ -459,6 +459,17 @@
                sBattleGroundMgr.SendToBattleGround(_player, instanceId);
                // add only in HandleMoveWorldPortAck()
                // bg->AddPlayer(_player,team);
+                for(int qId = 1; qId <= 7; ++qId)
+                {
+                    if(bgQueueTypeId != qId)
+                    {
+                        queueSlot = _player->GetBattleGroundQueueIndex(qId);
+                        _player->RemoveBattleGroundQueueId(qId);
+                        sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player->GetTeam(), queueSlot, STATUS_NONE, 0, 0);
+                        sBattleGroundMgr.m_BattleGroundQueues[qId].RemovePlayer(_player->GetGUID(), false);
+                        SendPacket(&data);
+                    }
+                }
                sLog.outDebug("Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.",_player->GetName(),_player->GetGUIDLow(),bg->GetInstanceID(),bg->GetTypeID(),bgQueueTypeId);
                break;
            case 0:                                         // leave queue

error was in true/false boolean in sBattleGroundMgr.m_BattleGroundQueues[qId].RemovePlayer(_player->GetGUID(), false); line.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use