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

@@ -239,7 +239,7 @@ public:
return false;
SellResult msg = SellResult(atoi(args));
handler->GetSession()->GetPlayer()->SendSellError(msg, 0, 0, 0);
handler->GetSession()->GetPlayer()->SendSellError(msg, 0, ObjectGuid::Empty, 0);
return true;
}
@@ -365,11 +365,11 @@ public:
}
else if (type == "appitsguid")
{
data.append(unit->GetPackGUID());
data << unit->GetPackGUID();
}
else if (type == "appmyguid")
{
data.append(player->GetPackGUID());
data << player->GetPackGUID();
}
else if (type == "appgoguid")
{
@@ -381,7 +381,7 @@ public:
ifs.close();
return false;
}
data.append(obj->GetPackGUID());
data << obj->GetPackGUID();
}
else if (type == "goguid")
{
@@ -393,15 +393,15 @@ public:
ifs.close();
return false;
}
data << uint64(obj->GetGUID());
data << obj->GetGUID();
}
else if (type == "myguid")
{
data << uint64(player->GetGUID());
data << player->GetGUID();
}
else if (type == "itsguid")
{
data << uint64(unit->GetGUID());
data << unit->GetGUID();
}
else if (type == "itspos")
{
@@ -503,7 +503,8 @@ public:
if (!target)
return false;
handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s", target->GetName().c_str(), target->GetGUIDLow(), target->GetDBTableGUIDLow(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
handler->PSendSysMessage("Loot recipient for creature %s (%s, SpawnId %u) is %s",
target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
return true;
}
@@ -560,10 +561,12 @@ public:
for (uint8 j = 0; j < bag->GetBagSize(); ++j)
if (Item* item2 = bag->GetItemByPos(j))
if (item2->GetState() == state)
handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()));
handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s",
item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str());
}
else if (item->GetState() == state)
handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()));
handler->PSendSysMessage("bag: 255 slot: %d %s, owner: %s",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str());
}
}
}
@@ -597,7 +600,7 @@ public:
break;
}
handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUIDLow(), st.c_str());
handler->PSendSysMessage("bag: %d slot: %d %s - state: %s", bagSlot, item->GetSlot(), item->GetGUID().ToString().c_str(), st.c_str());
}
if (updateQueue.empty())
handler->PSendSysMessage("The player's updatequeue is empty");
@@ -618,21 +621,23 @@ public:
if (item->GetSlot() != i)
{
handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot());
handler->PSendSysMessage("Item with slot %d %s has an incorrect slot value: %d", i, item->GetGUID().ToString().c_str(), item->GetSlot());
error = true;
continue;
}
if (item->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("The item with slot %d and itemguid %d does have non-matching owner guid (%d) and player guid (%d) !", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) does have non-matching owner (%s) and player (%sd) !",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
if (Bag* container = item->GetContainer())
{
handler->PSendSysMessage("The item with slot %d and guid %d has a container (slot: %d, guid: %d) but shouldn't!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) has a container (slot: %d, %s) but shouldn't!",
item->GetSlot(), item->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -642,28 +647,32 @@ public:
uint16 qp = item->GetQueuePos();
if (qp > updateQueue.size())
{
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp);
handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) larger than the update queue size! ",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] == nullptr)
{
handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to nullptr in the queue!", item->GetSlot(), item->GetGUIDLow(), qp);
handler->PSendSysMessage("The item with slot %d (%s) has its queuepos (%d) pointing to nullptr in the queue!",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] != item)
{
handler->PSendSysMessage("The item with slot %d and guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
handler->PSendSysMessage("The item with slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)",
item->GetSlot(), item->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
error = true;
continue;
}
}
else if (item->GetState() != ITEM_UNCHANGED)
{
handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState());
handler->PSendSysMessage("The item with slot %d (%s) is not in queue but should be (state: %d)!",
item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetState());
error = true;
continue;
}
@@ -678,14 +687,16 @@ public:
if (item2->GetSlot() != j)
{
handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot());
handler->PSendSysMessage("The item in bag %d and slot %d (%s) has an incorrect slot value: %d",
bag->GetSlot(), j, item2->GetGUID().ToString().c_str(), item2->GetSlot());
error = true;
continue;
}
if (item2->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("The item in bag %d at slot %d and with itemguid %d, the owner's guid (%d) and the player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d and with item %s, the owner (%s) and the player (%s) don't match!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -693,14 +704,16 @@ public:
Bag* container = item2->GetContainer();
if (!container)
{
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has no container!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str());
error = true;
continue;
}
if (container != bag)
{
handler->PSendSysMessage("The item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a different container(slot %d %s)!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -710,28 +723,32 @@ public:
uint16 qp = item2->GetQueuePos();
if (qp > updateQueue.size())
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) larger than the update queue size! ",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] == nullptr)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to nullptr in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to nullptr in the queue!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp);
error = true;
continue;
}
if (updateQueue[qp] != item2)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, %s)",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().ToString().c_str());
error = true;
continue;
}
}
else if (item2->GetState() != ITEM_UNCHANGED)
{
handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState());
handler->PSendSysMessage("The item in bag %d at slot %d (%s) is not in queue but should be (state: %d)!",
bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetState());
error = true;
continue;
}
@@ -747,14 +764,15 @@ public:
if (item->GetOwnerGUID() != player->GetGUID())
{
handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the owner's guid (%d) and the player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the owner (%s) and the player (%s) don't match!",
i, item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
error = true;
continue;
}
if (item->GetQueuePos() != i)
{
handler->PSendSysMessage("queue(" SZFMTD "): For the item with guid %d, the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): For the item (%s), the queuepos doesn't match it's position in the queue!", i, item->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -766,14 +784,16 @@ public:
if (test == nullptr)
{
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have any item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, the player doesn't have any item at that position!",
i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str());
error = true;
continue;
}
if (test != item)
{
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item with guid %d are incorrect, an item which guid is %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow());
handler->PSendSysMessage("queue(" SZFMTD "): The bag(%d) and slot(%d) values for the item (%s) are incorrect, an item (%s) is there instead!",
i, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str());
error = true;
continue;
}
@@ -806,7 +826,7 @@ public:
ThreatContainer::StorageType const& threatList = target->getThreatManager().getThreatList();
ThreatContainer::StorageType::const_iterator itr;
uint32 count = 0;
handler->PSendSysMessage("Threat list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage("Threat list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
for (itr = threatList.begin(); itr != threatList.end(); ++itr)
{
Unit* unit = (*itr)->getTarget();
@@ -815,7 +835,7 @@ public:
handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->getThreat());
continue;
}
handler->PSendSysMessage(" %u. %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat());
handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat());
}
ThreatContainer::StorageType const& threatList2 = target->getThreatManager().getOfflineThreatList();
for (itr = threatList2.begin(); itr != threatList2.end(); ++itr)
@@ -826,7 +846,7 @@ public:
handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->getThreat());
continue;
}
handler->PSendSysMessage(" %u. [offline] %s (guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUIDLow(), (*itr)->getThreat());
handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat());
}
handler->SendSysMessage("End of threat list.");
@@ -840,11 +860,12 @@ public:
target = handler->GetSession()->GetPlayer();
HostileReference* ref = target->getHostileRefManager().getFirst();
uint32 count = 0;
handler->PSendSysMessage("Hostil reference list of %s (guid %u)", target->GetName().c_str(), target->GetGUIDLow());
handler->PSendSysMessage("Hostil reference list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str());
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
handler->PSendSysMessage(" %u. %s %s (guid %u) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), unit->GetName().c_str(), unit->GetGUIDLow(), ref->getThreat());
handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"),
unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->getThreat());
else
handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->getThreat());
ref = ref->next();
@@ -942,7 +963,7 @@ public:
Map* map = handler->GetSession()->GetPlayer()->GetMap();
if (!v->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o))
if (!v->Create(map->GenerateLowGuid<HighGuid::Vehicle>(), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, id, x, y, z, o))
{
delete v;
return false;
@@ -984,10 +1005,10 @@ public:
if (!e || !f)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
uint32 index = (uint32)atoi(f);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1014,11 +1035,11 @@ public:
if (!e || !f || !g)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
uint32 index = (uint32)atoi(f);
uint32 value = (uint32)atoi(g);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1040,9 +1061,9 @@ public:
if (!e)
return false;
uint32 guid = (uint32)atoi(e);
ObjectGuid::LowType guid = (uint32)atoi(e);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM));
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
if (!i)
return false;
@@ -1128,12 +1149,12 @@ public:
return false;
}
uint64 guid = target->GetGUID();
ObjectGuid guid = target->GetGUID();
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount());
return false;
}
@@ -1145,13 +1166,13 @@ public:
{
uint32 value = (uint32)atoi(y);
target->SetUInt32Value(opcode, value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, guid.GetCounter(), opcode, value);
}
else
{
float value = (float)atof(y);
target->SetFloatValue(opcode, value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.GetCounter(), opcode, value);
}
return true;
@@ -1176,12 +1197,12 @@ public:
return false;
}
uint64 guid = target->GetGUID();
ObjectGuid guid = target->GetGUID();
uint32 opcode = (uint32)atoi(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, GUID_LOPART(guid), target->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.GetCounter(), target->GetValuesCount());
return false;
}
@@ -1192,12 +1213,12 @@ public:
if (isInt32)
{
uint32 value = target->GetUInt32Value(opcode);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_GET_UINT_FIELD, guid.GetCounter(), opcode, value);
}
else
{
float value = target->GetFloatValue(opcode);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), opcode, value);
handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, guid.GetCounter(), opcode, value);
}
return true;
@@ -1219,7 +1240,7 @@ public:
if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUIDLow(), handler->GetSession()->GetPlayer()->GetValuesCount());
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUID().GetCounter(), handler->GetSession()->GetPlayer()->GetValuesCount());
return false;
}
@@ -1269,13 +1290,13 @@ public:
{
value = unit->GetUInt32Value(updateIndex);
handler->PSendSysMessage(LANG_UPDATE, unit->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE, unit->GetGUID().GetCounter(), updateIndex, value);
return true;
}
value = atoi(val);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUIDLow(), updateIndex, value);
handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUID().GetCounter(), updateIndex, value);
unit->SetUInt32Value(updateIndex, value);