Skip to content
Permalink
Browse files

Core/Opcodes: Implement CMSG_GROUP_SWAP_SUB_GROUP

Closes #1635

Co-Authored-By: Crypticaz <crypticaz@users.noreply.github.com>
  • Loading branch information...
AbraKabastard and Crypticaz committed May 22, 2019
1 parent 14a7882 commit 3bae650e8b291a90f838eb391579a1737eb95616
Showing with 46 additions and 1 deletion.
  1. +44 −0 src/game/GroupHandler.cpp
  2. +1 −1 src/game/Opcodes.cpp
  3. +1 −0 src/game/WorldSession.h
@@ -963,3 +963,47 @@ void WorldSession::HandleGroupPassOnLootOpcode(WorldPacket& recv_data)
GetPlayer()->SetPassOnGroupLoot(passOnLoot);
}

void WorldSession::HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data)
{
std::string playerName1, playerName2;

recv_data >> playerName1;
recv_data >> playerName2;

Player* player = GetPlayer();

Group* group = player->GetGroup();
if (!group || !group->isRaidGroup())
return;

ObjectGuid const& guid = player->GetObjectGUID();
if (!group->IsLeader(guid) && !group->IsAssistant(guid))
return;

auto getMemberSlotInfo = [&group](std::string const& playerName, uint8& subgroup, ObjectGuid& guid)
{
auto slots = group->GetMemberSlots();
for (auto i = slots.begin(); i != slots.end(); ++i)
{
if ((*i).guid && (*i).name == playerName)
{
subgroup = (*i).group;
guid = (*i).guid;
return true;
}
}
return false;
};

ObjectGuid guid1, guid2;
uint8 subgroup1, subgroup2;

if (!getMemberSlotInfo(playerName1, subgroup1, guid1) || !getMemberSlotInfo(playerName2, subgroup2, guid2))
return;

if (subgroup1 == subgroup2)
return;

group->ChangeMembersGroup(guid1, subgroup2);
group->ChangeMembersGroup(guid2, subgroup1);
}
@@ -661,7 +661,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x27D*/ { "CMSG_ENABLE_DAMAGE_LOG", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x27E*/ { "CMSG_GROUP_CHANGE_SUB_GROUP", STATUS_LOGGEDIN, &WorldSession::HandleGroupChangeSubGroupOpcode },
/*0x27F*/ { "CMSG_REQUEST_PARTY_MEMBER_STATS", STATUS_LOGGEDIN, &WorldSession::HandleRequestPartyMemberStatsOpcode},
/*0x280*/ { "CMSG_GROUP_SWAP_SUB_GROUP", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x280*/ { "CMSG_GROUP_SWAP_SUB_GROUP", STATUS_LOGGEDIN, &WorldSession::HandleGroupSwapSubGroupOpcode },
/*0x281*/ { "CMSG_RESET_FACTION_CHEAT", STATUS_NEVER, &WorldSession::Handle_NULL },
/*0x282*/ { "CMSG_AUTOSTORE_BANK_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleAutoStoreBankItemOpcode },
/*0x283*/ { "CMSG_AUTOBANK_ITEM", STATUS_LOGGEDIN, &WorldSession::HandleAutoBankItemOpcode },
@@ -410,6 +410,7 @@ class WorldSession
void HandleLootMethodOpcode(WorldPacket& recvPacket);
void HandleLootRoll(WorldPacket& recv_data);
void HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data);
void HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data);
void HandleRaidIconTargetOpcode(WorldPacket& recv_data);
void HandleRaidReadyCheckOpcode(WorldPacket& recv_data);
void HandleRaidReadyCheckFinishOpcode(WorldPacket& recv_data);

0 comments on commit 3bae650

Please sign in to comment.
You can’t perform that action at this time.