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

@@ -68,16 +68,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -137,7 +132,7 @@ public:
Map* map = player->GetMap();
GameObject* object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject();
uint32 guidLow = sObjectMgr->GenerateRecycledLowGuid(HIGHGUID_GAMEOBJECT);
ObjectGuid::LowType guidLow = map->GenerateLowGuid<HighGuid::GameObject>();
if (!object->Create(guidLow, objectInfo->entry, map, player->GetPhaseMaskForSpawn(), x, y, z, o, G3D::Quat(), 0, GO_STATE_READY))
{
@@ -270,7 +265,8 @@ public:
bool found = false;
float x, y, z, o;
uint32 guidLow, id, phase;
ObjectGuid::LowType guidLow;
uint32 id, phase;
uint16 mapId;
uint32 poolId;
@@ -304,7 +300,7 @@ public:
return false;
}
GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(guidLow, id, HIGHGUID_GAMEOBJECT));
GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid::Create<HighGuid::GameObject>(id, guidLow));
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase);
@@ -330,16 +326,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -347,13 +338,13 @@ public:
return false;
}
uint64 ownerGuid = object->GetOwnerGUID();
ObjectGuid ownerGuid = object->GetOwnerGUID();
if (ownerGuid)
{
Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid);
if (!owner || !IS_PLAYER_GUID(ownerGuid))
if (!owner || !ownerGuid.IsPlayer())
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(ownerGuid), object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), object->GetSpawnId());
handler->SetSentErrorMessage(true);
return false;
}
@@ -365,7 +356,7 @@ public:
object->Delete();
object->DeleteFromDB();
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId());
return true;
}
@@ -378,16 +369,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -423,7 +409,7 @@ public:
object->SaveToDB();
object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow(), oz, oy, ox);
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId(), oz, oy, ox);
return true;
}
@@ -436,16 +422,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -488,7 +469,7 @@ public:
object->SaveToDB();
object->Refresh();
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetGUIDLow(), object->GetGOInfo()->name.c_str(), object->GetGUIDLow());
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId());
return true;
}
@@ -501,16 +482,11 @@ public:
if (!id)
return false;
uint32 guidLow = atoi(id);
ObjectGuid::LowType guidLow = atoi(id);
if (!guidLow)
return false;
GameObject* object = nullptr;
// by DB guid
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
@@ -556,7 +532,7 @@ public:
do
{
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
ObjectGuid::LowType guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
@@ -647,8 +623,7 @@ public:
if (guidLow > 0)
{
if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow))
object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id);
object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
}
else
object = handler->GetSession()->GetPlayer()->FindNearestGameObject(-guidLow, 30.0f);