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:
@@ -137,7 +137,7 @@ public:
|
||||
path_number = strtok((char*)args, " ");
|
||||
|
||||
uint32 pathid = 0;
|
||||
uint32 guidLow = 0;
|
||||
ObjectGuid::LowType guidLow = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
// Did player provide a path_id?
|
||||
@@ -166,7 +166,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
guidLow = target->GetDBTableGUIDLow();
|
||||
guidLow = target->GetSpawnId();
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID);
|
||||
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 guildLow = target->GetDBTableGUIDLow();
|
||||
uint32 guildLow = target->GetSpawnId();
|
||||
|
||||
if (target->GetCreatureAddon())
|
||||
{
|
||||
@@ -566,7 +566,6 @@ public:
|
||||
// -> variable lowguid is filled with the GUID of the NPC
|
||||
uint32 pathid = 0;
|
||||
uint32 point = 0;
|
||||
uint32 wpGuid = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
if (!target || target->GetEntry() != VISUAL_WAYPOINT)
|
||||
@@ -576,18 +575,18 @@ public:
|
||||
}
|
||||
|
||||
// The visual waypoint
|
||||
wpGuid = target->GetGUIDLow();
|
||||
ObjectGuid::LowType wpSpawnId = target->GetSpawnId();
|
||||
|
||||
// User did select a visual waypoint?
|
||||
|
||||
// Check the creature
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
|
||||
stmt->setUInt32(0, wpGuid);
|
||||
stmt->setUInt32(0, wpSpawnId);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, wpSpawnId);
|
||||
// Select waypoint number from database
|
||||
// Since we compare float values, we have to deal with
|
||||
// some difficulties.
|
||||
@@ -607,7 +606,7 @@ public:
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpSpawnId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -634,8 +633,8 @@ public:
|
||||
{
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
|
||||
|
||||
if (wpGuid != 0)
|
||||
if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)))
|
||||
if (wpSpawnId != 0)
|
||||
if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(target->GetGUID()))
|
||||
{
|
||||
wpCreature->CombatStop();
|
||||
wpCreature->DeleteFromDB();
|
||||
@@ -670,9 +669,9 @@ public:
|
||||
// What to do:
|
||||
// Move the visual spawnpoint
|
||||
// Respawn the owner of the waypoints
|
||||
if (wpGuid != 0)
|
||||
if (wpSpawnId != 0)
|
||||
{
|
||||
if (Creature* wpCreature = map->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)))
|
||||
if (Creature* wpCreature = map->GetCreature(target->GetGUID()))
|
||||
{
|
||||
wpCreature->CombatStop();
|
||||
wpCreature->DeleteFromDB();
|
||||
@@ -680,7 +679,7 @@ public:
|
||||
}
|
||||
// re-create
|
||||
Creature* wpCreature2 = new Creature;
|
||||
if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||
if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
@@ -691,7 +690,7 @@ public:
|
||||
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
//TODO: Should we first use "Create" then use "LoadFromDB"?
|
||||
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map))
|
||||
if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map, true, false, true))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
@@ -795,7 +794,7 @@ public:
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
|
||||
|
||||
stmt->setUInt32(0, target->GetGUIDLow());
|
||||
stmt->setUInt32(0, target->GetSpawnId());
|
||||
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
@@ -857,7 +856,7 @@ public:
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
uint32 wpguid = fields[0].GetUInt32();
|
||||
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid));
|
||||
|
||||
if (!creature)
|
||||
{
|
||||
@@ -901,7 +900,7 @@ public:
|
||||
float o = chr->GetOrientation();
|
||||
|
||||
Creature* wpCreature = new Creature;
|
||||
if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete wpCreature;
|
||||
@@ -911,7 +910,7 @@ public:
|
||||
// Set "wpguid" column to the visual waypoint
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
|
||||
|
||||
stmt->setInt32(0, int32(wpCreature->GetGUIDLow()));
|
||||
stmt->setInt32(0, int32(wpCreature->GetSpawnId()));
|
||||
stmt->setUInt32(1, pathid);
|
||||
stmt->setUInt32(2, point);
|
||||
|
||||
@@ -919,7 +918,7 @@ public:
|
||||
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetDBTableGUIDLow(), map))
|
||||
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map, true, false, true))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete wpCreature;
|
||||
@@ -964,7 +963,7 @@ public:
|
||||
Map* map = chr->GetMap();
|
||||
|
||||
Creature* creature = new Creature;
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete creature;
|
||||
@@ -972,7 +971,7 @@ public:
|
||||
}
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
|
||||
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete creature;
|
||||
@@ -1013,7 +1012,7 @@ public:
|
||||
Map* map = chr->GetMap();
|
||||
|
||||
Creature* creature = new Creature;
|
||||
if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
delete creature;
|
||||
@@ -1021,7 +1020,7 @@ public:
|
||||
}
|
||||
|
||||
creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
if (!creature->LoadCreatureFromDB(creature->GetDBTableGUIDLow(), map))
|
||||
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, false, true))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
delete creature;
|
||||
@@ -1053,8 +1052,8 @@ public:
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid));
|
||||
if (!creature)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
|
||||
|
||||
Reference in New Issue
Block a user