mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 18:10:26 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -109,7 +109,7 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUIDLow()))
|
||||
if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S);
|
||||
return;
|
||||
@@ -233,7 +233,8 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
|
||||
|
||||
if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
|
||||
{
|
||||
LOG_ERROR("server", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
|
||||
LOG_ERROR("server", "HandleGroupAcceptOpcode: player %s (%s) tried to accept an invite to his own group",
|
||||
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID());
|
||||
Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID());
|
||||
|
||||
// Forming a new group, create it
|
||||
if (!group->IsCreated())
|
||||
@@ -281,7 +282,7 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket& /*recvData*/)
|
||||
return;
|
||||
|
||||
// Remember leader if online (group pointer will be invalid if group gets disbanded)
|
||||
Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID());
|
||||
Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID());
|
||||
|
||||
// uninvite, group can be deleted
|
||||
GetPlayer()->UninviteFromGroup();
|
||||
@@ -301,7 +302,7 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
|
||||
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_UNINVITE_GUID");
|
||||
#endif
|
||||
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
std::string reason, name;
|
||||
recvData >> guid;
|
||||
recvData >> reason;
|
||||
@@ -309,12 +310,13 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recvData)
|
||||
//can't uninvite yourself
|
||||
if (guid == GetPlayer()->GetGUID())
|
||||
{
|
||||
LOG_ERROR("server", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
|
||||
LOG_ERROR("server", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s (%s) tried to uninvite himself from the group.",
|
||||
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Xinef: name is properly filled in packets
|
||||
sObjectMgr->GetPlayerNameByGUID(guid, name);
|
||||
sObjectMgr->GetPlayerNameByGUID(guid.GetCounter(), name);
|
||||
|
||||
PartyResult res = GetPlayer()->CanUninviteFromGroup();
|
||||
if (res != ERR_PARTY_RESULT_OK)
|
||||
@@ -371,7 +373,8 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData)
|
||||
// can't uninvite yourself
|
||||
if (GetPlayer()->GetName() == membername)
|
||||
{
|
||||
LOG_ERROR("server", "WorldSession::HandleGroupUninviteOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
|
||||
LOG_ERROR("server", "WorldSession::HandleGroupUninviteOpcode: leader %s (%s) tried to uninvite himself from the group.",
|
||||
GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -386,7 +389,7 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recvData)
|
||||
if (!grp)
|
||||
return;
|
||||
|
||||
if (uint64 guid = grp->GetMemberGUID(membername))
|
||||
if (ObjectGuid guid = grp->GetMemberGUID(membername))
|
||||
{
|
||||
Player::RemoveFromGroup(grp, guid, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID());
|
||||
return;
|
||||
@@ -407,10 +410,10 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recvData)
|
||||
LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_SET_LEADER");
|
||||
#endif
|
||||
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
recvData >> guid;
|
||||
|
||||
Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);
|
||||
Player* player = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
Group* group = GetPlayer()->GetGroup();
|
||||
|
||||
if (!group || !player)
|
||||
@@ -456,7 +459,7 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData)
|
||||
#endif
|
||||
|
||||
uint32 lootMethod;
|
||||
uint64 lootMaster;
|
||||
ObjectGuid lootMaster;
|
||||
uint32 lootThreshold;
|
||||
recvData >> lootMethod >> lootMaster >> lootThreshold;
|
||||
|
||||
@@ -488,7 +491,7 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recvData)
|
||||
|
||||
void WorldSession::HandleLootRoll(WorldPacket& recvData)
|
||||
{
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
uint32 itemSlot;
|
||||
uint8 rollType;
|
||||
recvData >> guid; // guid of the item rolled
|
||||
@@ -530,7 +533,7 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recvData)
|
||||
|
||||
// everything's fine, do it
|
||||
WorldPacket data(MSG_MINIMAP_PING, (8 + 4 + 4));
|
||||
data << uint64(GetPlayer()->GetGUID());
|
||||
data << GetPlayer()->GetGUID();
|
||||
data << float(x);
|
||||
data << float(y);
|
||||
GetPlayer()->GetGroup()->BroadcastPacket(&data, true, -1, GetPlayer()->GetGUID());
|
||||
@@ -558,7 +561,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recvData)
|
||||
data << uint32(minimum);
|
||||
data << uint32(maximum);
|
||||
data << uint32(roll);
|
||||
data << uint64(GetPlayer()->GetGUID());
|
||||
data << GetPlayer()->GetGUID();
|
||||
if (GetPlayer()->GetGroup())
|
||||
GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
|
||||
else
|
||||
@@ -591,12 +594,12 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recvData)
|
||||
if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
|
||||
return;
|
||||
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
recvData >> guid;
|
||||
|
||||
if (IS_PLAYER_GUID(guid))
|
||||
if (guid.IsPlayer())
|
||||
{
|
||||
Player* target = ObjectAccessor::FindPlayerInOrOutOfWorld(guid);
|
||||
Player* target = ObjectAccessor::FindConnectedPlayer(guid);
|
||||
|
||||
if (!target || target->IsHostileTo(GetPlayer()))
|
||||
return;
|
||||
@@ -648,7 +651,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData)
|
||||
if (groupNr >= MAX_RAID_SUBGROUPS)
|
||||
return;
|
||||
|
||||
uint64 senderGuid = GetPlayer()->GetGUID();
|
||||
ObjectGuid senderGuid = GetPlayer()->GetGUID();
|
||||
if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid))
|
||||
return;
|
||||
|
||||
@@ -656,7 +659,7 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
|
||||
Player* movedPlayer = ObjectAccessor::FindPlayerByName(name, false);
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
if (movedPlayer)
|
||||
{
|
||||
guid = movedPlayer->GetGUID();
|
||||
@@ -683,7 +686,7 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recvData)
|
||||
if (!group->IsLeader(GetPlayer()->GetGUID()))
|
||||
return;
|
||||
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
bool apply;
|
||||
recvData >> guid;
|
||||
recvData >> apply;
|
||||
@@ -703,13 +706,13 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recvData)
|
||||
if (!group)
|
||||
return;
|
||||
|
||||
uint64 senderGuid = GetPlayer()->GetGUID();
|
||||
ObjectGuid senderGuid = GetPlayer()->GetGUID();
|
||||
if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid))
|
||||
return;
|
||||
|
||||
uint8 assignment;
|
||||
bool apply;
|
||||
uint64 guid;
|
||||
ObjectGuid guid;
|
||||
recvData >> assignment >> apply;
|
||||
recvData >> guid;
|
||||
|
||||
@@ -771,7 +774,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData)
|
||||
|
||||
// everything's fine, do it
|
||||
WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
|
||||
data << uint64(GetPlayer()->GetGUID());
|
||||
data << GetPlayer()->GetGUID();
|
||||
data << uint8(state);
|
||||
group->BroadcastReadyCheck(&data);
|
||||
}
|
||||
@@ -808,7 +811,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
|
||||
byteCount += GroupUpdateLength[i];
|
||||
|
||||
data->Initialize(SMSG_PARTY_MEMBER_STATS, 8 + 4 + byteCount);
|
||||
data->append(player->GetPackGUID());
|
||||
*data << player->GetPackGUID();
|
||||
*data << uint32(mask);
|
||||
|
||||
if (mask & GROUP_UPDATE_FLAG_STATUS)
|
||||
@@ -884,7 +887,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
|
||||
if (mask & GROUP_UPDATE_FLAG_PET_GUID)
|
||||
{
|
||||
if (pet)
|
||||
*data << (uint64) pet->GetGUID();
|
||||
*data << pet->GetGUID();
|
||||
else
|
||||
*data << (uint64) 0;
|
||||
}
|
||||
@@ -978,7 +981,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke
|
||||
void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
|
||||
{
|
||||
LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_PARTY_MEMBER_STATS");
|
||||
uint64 Guid;
|
||||
ObjectGuid Guid;
|
||||
recvData >> Guid;
|
||||
|
||||
Player* player = HashMapHolder<Player>::Find(Guid);
|
||||
@@ -986,7 +989,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
|
||||
{
|
||||
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 2);
|
||||
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
|
||||
data.appendPackGUID(Guid);
|
||||
data << Guid.WriteAsPacked();
|
||||
data << uint32(GROUP_UPDATE_FLAG_STATUS);
|
||||
data << uint16(MEMBER_STATUS_OFFLINE);
|
||||
SendPacket(&data);
|
||||
@@ -998,7 +1001,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
|
||||
|
||||
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4 + 2 + 2 + 2 + 1 + 2 * 6 + 8 + 1 + 8);
|
||||
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
|
||||
data.append(player->GetPackGUID());
|
||||
data << player->GetPackGUID();
|
||||
|
||||
uint32 updateFlags = GROUP_UPDATE_FLAG_STATUS | GROUP_UPDATE_FLAG_CUR_HP | GROUP_UPDATE_FLAG_MAX_HP
|
||||
| GROUP_UPDATE_FLAG_CUR_POWER | GROUP_UPDATE_FLAG_MAX_POWER | GROUP_UPDATE_FLAG_LEVEL
|
||||
@@ -1066,7 +1069,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recvData)
|
||||
data.put<uint64>(maskPos, auraMask); // GROUP_UPDATE_FLAG_AURAS
|
||||
|
||||
if (pet && (updateFlags & GROUP_UPDATE_FLAG_PET_GUID))
|
||||
data << uint64(pet->GetGUID());
|
||||
data << pet->GetGUID();
|
||||
|
||||
data << std::string(pet ? pet->GetName() : ""); // GROUP_UPDATE_FLAG_PET_NAME
|
||||
data << uint16(pet ? pet->GetDisplayId() : 0); // GROUP_UPDATE_FLAG_PET_MODEL_ID
|
||||
@@ -1167,7 +1170,7 @@ void WorldSession::HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data)
|
||||
// no player, cheating?
|
||||
if (!group->GetMemberGUID(playerName))
|
||||
{
|
||||
return uint64(0);
|
||||
return ObjectGuid::Empty;
|
||||
}
|
||||
|
||||
if (Player* player = ObjectAccessor::FindPlayerByName(playerName.c_str()))
|
||||
@@ -1176,19 +1179,19 @@ void WorldSession::HandleGroupSwapSubGroupOpcode(WorldPacket& recv_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uint64 guid = sObjectMgr->GetPlayerGUIDByName(playerName))
|
||||
if (ObjectGuid guid = sObjectMgr->GetPlayerGUIDByName(playerName))
|
||||
{
|
||||
return guid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return uint64(0); // no player - again, cheating?
|
||||
return ObjectGuid::Empty; // no player - again, cheating?
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
uint64 guid1 = getGuid(playerName1);
|
||||
uint64 guid2 = getGuid(playerName2);
|
||||
ObjectGuid guid1 = getGuid(playerName1);
|
||||
ObjectGuid guid2 = getGuid(playerName2);
|
||||
|
||||
if(!guid1 || !guid2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user