feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)

This commit is contained in:
UltraNix
2021-04-25 22:18:03 +02:00
committed by GitHub
parent 91081f4ad8
commit f4c226423d
568 changed files with 10655 additions and 11019 deletions

View File

@@ -31,13 +31,13 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
LOG_DEBUG("network", "WORLD: CMSG_AUTOSTORE_LOOT_ITEM");
#endif
Player* player = GetPlayer();
uint64 lguid = player->GetLootGUID();
ObjectGuid lguid = player->GetLootGUID();
Loot* loot = nullptr;
uint8 lootSlot = 0;
recvData >> lootSlot;
if (IS_GAMEOBJECT_GUID(lguid))
if (lguid.IsGameObject())
{
GameObject* go = player->GetMap()->GetGameObject(lguid);
// xinef: cheating protection
@@ -53,7 +53,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
loot = &go->loot;
}
else if (IS_ITEM_GUID(lguid))
else if (lguid.IsItem())
{
Item* pItem = player->GetItemByGuid(lguid);
@@ -65,7 +65,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
loot = &pItem->loot;
}
else if (IS_CORPSE_GUID(lguid))
else if (lguid.IsCorpse())
{
Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid);
if (!bones)
@@ -93,7 +93,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
player->StoreLootItem(lootSlot, loot);
// If player is removing the last LootItem, delete the empty container.
if (loot->isLooted() && IS_ITEM_GUID(lguid))
if (loot->isLooted() && lguid.IsItem())
DoLootRelease(lguid);
}
@@ -104,16 +104,16 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
#endif
Player* player = GetPlayer();
uint64 guid = player->GetLootGUID();
ObjectGuid guid = player->GetLootGUID();
if (!guid)
return;
Loot* loot = nullptr;
bool shareMoney = true;
switch (GUID_HIPART(guid))
switch (guid.GetHigh())
{
case HIGHGUID_GAMEOBJECT:
case HighGuid::GameObject:
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
@@ -123,7 +123,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
break;
}
case HIGHGUID_CORPSE: // remove insignia ONLY in BG
case HighGuid::Corpse: // remove insignia ONLY in BG
{
Corpse* bones = ObjectAccessor::GetCorpse(*player, guid);
@@ -135,7 +135,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
break;
}
case HIGHGUID_ITEM:
case HighGuid::Item:
{
if (Item* item = player->GetItemByGuid(guid))
{
@@ -144,8 +144,8 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
}
break;
}
case HIGHGUID_UNIT:
case HIGHGUID_VEHICLE:
case HighGuid::Unit:
case HighGuid::Vehicle:
{
Creature* creature = player->GetMap()->GetCreature(guid);
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
@@ -210,11 +210,11 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
loot->gold = 0;
// Delete the money loot record from the DB
if (loot->containerId > 0)
sLootItemStorage->RemoveStoredLootMoney(loot->containerId, loot);
if (loot->containerGUID)
sLootItemStorage->RemoveStoredLootMoney(loot->containerGUID, loot);
// Delete container if empty
if (loot->isLooted() && IS_ITEM_GUID(guid))
if (loot->isLooted() && guid.IsItem())
DoLootRelease(guid);
}
}
@@ -225,11 +225,11 @@ void WorldSession::HandleLootOpcode(WorldPacket& recvData)
LOG_DEBUG("network", "WORLD: CMSG_LOOT");
#endif
uint64 guid;
ObjectGuid guid;
recvData >> guid;
// Check possible cheat
if (!GetPlayer()->IsAlive() || !IS_CRE_OR_VEH_GUID(guid))
if (!GetPlayer()->IsAlive() || !guid.IsCreatureOrVehicle())
return;
GetPlayer()->SendLoot(guid, LOOT_CORPSE);
@@ -247,20 +247,20 @@ void WorldSession::HandleLootReleaseOpcode(WorldPacket& recvData)
// cheaters can modify lguid to prevent correct apply loot release code and re-loot
// use internal stored guid
uint64 guid;
ObjectGuid guid;
recvData >> guid;
if (uint64 lguid = GetPlayer()->GetLootGUID())
if (ObjectGuid lguid = GetPlayer()->GetLootGUID())
if (lguid == guid)
DoLootRelease(lguid);
}
void WorldSession::DoLootRelease(uint64 lguid)
void WorldSession::DoLootRelease(ObjectGuid lguid)
{
Player* player = GetPlayer();
Loot* loot;
player->SetLootGUID(0);
player->SetLootGUID(ObjectGuid::Empty);
player->SendLootRelease(lguid);
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
@@ -268,7 +268,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
if (!player->IsInWorld())
return;
if (IS_GAMEOBJECT_GUID(lguid))
if (lguid.IsGameObject())
{
GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
@@ -304,7 +304,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.eventId)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("spells.aura", "Chest ScriptStart id %u for GO %u", go->GetGOInfo()->chest.eventId, go->GetDBTableGUIDLow());
LOG_DEBUG("spells.aura", "Chest ScriptStart id %u for GO %u", go->GetGOInfo()->chest.eventId, go->GetSpawnId());
#endif
player->GetMap()->ScriptsStart(sEventScripts, go->GetGOInfo()->chest.eventId, player, go);
}
@@ -319,10 +319,10 @@ void WorldSession::DoLootRelease(uint64 lguid)
// if the round robin player release, reset it.
if (player->GetGUID() == loot->roundRobinPlayer)
loot->roundRobinPlayer = 0;
loot->roundRobinPlayer.Clear();
}
}
else if (IS_CORPSE_GUID(lguid)) // ONLY remove insignia at BG
else if (lguid.IsCorpse()) // ONLY remove insignia at BG
{
Corpse* corpse = ObjectAccessor::GetCorpse(*player, lguid);
if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
@@ -337,7 +337,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
corpse->RemoveFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE);
}
}
else if (IS_ITEM_GUID(lguid))
else if (lguid.IsItem())
{
Item* pItem = player->GetItemByGuid(lguid);
if (!pItem)
@@ -389,7 +389,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
// if the round robin player release, reset it.
if (player->GetGUID() == loot->roundRobinPlayer)
{
loot->roundRobinPlayer = 0;
loot->roundRobinPlayer.Clear();
if (Group* group = player->GetGroup())
group->SendLooter(creature, nullptr);
@@ -406,7 +406,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
{
uint8 slotid;
uint64 lootguid, target_playerguid;
ObjectGuid lootguid, target_playerguid;
recvData >> lootguid >> slotid >> target_playerguid;
@@ -416,7 +416,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
return;
}
Player* target = ObjectAccessor::GetPlayer(*_player, MAKE_NEW_GUID(target_playerguid, 0, HIGHGUID_PLAYER));
Player* target = ObjectAccessor::GetPlayer(*_player, target_playerguid);
if (!target)
{
_player->SendLootError(lootguid, LOOT_ERROR_PLAYER_NOT_FOUND);
@@ -442,7 +442,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
Loot* loot = nullptr;
if (IS_CRE_OR_VEH_GUID(GetPlayer()->GetLootGUID()))
if (GetPlayer()->GetLootGUID().IsCreatureOrVehicle())
{
Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid);
if (!creature)
@@ -450,7 +450,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recvData)
loot = &creature->loot;
}
else if (IS_GAMEOBJECT_GUID(GetPlayer()->GetLootGUID()))
else if (GetPlayer()->GetLootGUID().IsGameObject())
{
GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);
if (!pGO)