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

@@ -13,7 +13,7 @@ template<class T>
class FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator<T> >
{
public:
FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) {}
FleeingMovementGenerator(ObjectGuid fright) : i_frightGUID(fright), i_nextCheckTime(0) {}
void DoInitialize(T*);
void DoFinalize(T*);
@@ -38,14 +38,14 @@ private:
float i_last_distance_from_caster;
float i_to_distance_from_caster;
float i_cur_angle;
uint64 i_frightGUID;
ObjectGuid i_frightGUID;
TimeTracker i_nextCheckTime;
};
class TimedFleeingMovementGenerator : public FleeingMovementGenerator<Creature>
{
public:
TimedFleeingMovementGenerator(uint64 fright, uint32 time) :
TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) :
FleeingMovementGenerator<Creature>(fright),
i_totalFleeTime(time) {}

View File

@@ -369,7 +369,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
// this is probably an error state, but we'll leave it
// and hopefully recover on the next Update
// we still need to copy our preffix
LOG_ERROR("server", "PathGenerator::BuildPolyPath: Path Build failed %u", _source->GetGUIDLow());
LOG_ERROR("server", "PathGenerator::BuildPolyPath: Path Build failed %s", _source->GetGUID().ToString().c_str());
}
// new path = prefix + suffix - overlap
@@ -470,7 +470,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
if (!_polyLength || dtStatusFailed(dtResult))
{
// only happens if we passed bad data to findPath(), or navmesh is messed up
LOG_ERROR("server", "PathGenerator::BuildPolyPath: %u Path Build failed: 0 length path", _source->GetGUIDLow());
LOG_ERROR("server", "PathGenerator::BuildPolyPath: %s Path Build failed: 0 length path", _source->GetGUID().ToString().c_str());
BuildShortcut();
_type = PATHFIND_NOPATH;
return;
@@ -479,7 +479,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
if (!_polyLength)
{
LOG_ERROR("server", "PathGenerator::BuildPolyPath: %u Path Build failed: 0 length path", _source->GetGUIDLow());
LOG_ERROR("server", "PathGenerator::BuildPolyPath: %s Path Build failed: 0 length path", _source->GetGUID().ToString().c_str());
BuildShortcut();
_type = PATHFIND_NOPATH;
return;
@@ -509,7 +509,7 @@ void PathGenerator::BuildPointPath(const float* startPoint, const float* endPoin
if (_useRaycast)
{
// _straightLine uses raycast and it currently doesn't support building a point path, only a 2-point path with start and hitpoint/end is returned
LOG_ERROR("server", "PathGenerator::BuildPointPath() called with _useRaycast for unit %u", _source->GetGUIDLow());
LOG_ERROR("server", "PathGenerator::BuildPointPath() called with _useRaycast for unit %s", _source->GetGUID().ToString().c_str());
BuildShortcut();
_type = PATHFIND_NOPATH;
return;
@@ -893,7 +893,8 @@ dtStatus PathGenerator::FindSmoothPath(float const* startPos, float const* endPo
npolys = FixupCorridor(polys, npolys, MAX_PATH_LENGTH, visited, nvisited);
if (dtStatusFailed(_navMeshQuery->getPolyHeight(polys[0], result, &result[1])))
LOG_DEBUG("maps", "PathGenerator::FindSmoothPath: Cannot find height at position X: %f Y: %f Z: %f for %u", result[2], result[0], result[1], _source->GetGUIDLow());
LOG_DEBUG("maps", "PathGenerator::FindSmoothPath: Cannot find height at position X: %f Y: %f Z: %f for %s",
result[2], result[0], result[1], _source->GetGUID().ToString().c_str());
result[1] += 0.5f;
dtVcopy(iterPos, result);

View File

@@ -202,7 +202,7 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
if (!_wanderDistance)
_wanderDistance = creature->GetWanderDistance();
_nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetWanderDistance() == _wanderDistance ? urand(1, 5000) : 0);
_nextMoveTime.Reset(creature->GetSpawnId() && creature->GetWanderDistance() == _wanderDistance ? urand(1, 5000) : 0);
_wanderDistance = std::max((creature->GetWanderDistance() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);
if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))

View File

@@ -222,7 +222,7 @@ void ChaseMovementGenerator<T>::MovementInform(T* owner)
// Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle
if (CreatureAI* AI = owner->ToCreature()->AI())
AI->MovementInform(CHASE_MOTION_TYPE, i_target.getTarget()->GetGUIDLow());
AI->MovementInform(CHASE_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter());
}
//-----------------------------------------------//
@@ -365,7 +365,7 @@ void FollowMovementGenerator<Creature>::_updateSpeed(Creature* owner)
{
// pet only sync speed with owner
/// Make sure we are not in the process of a map change (IsInWorld)
if (!IS_PLAYER_GUID(owner->GetOwnerGUID()) || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID())
if (!owner->GetOwnerGUID().IsPlayer() || !owner->IsInWorld() || !i_target.isValid() || i_target->GetGUID() != owner->GetOwnerGUID())
return;
owner->UpdateSpeed(MOVE_RUN, true);
@@ -402,7 +402,7 @@ void FollowMovementGenerator<T>::MovementInform(T* owner)
// Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle
if (CreatureAI* AI = owner->ToCreature()->AI())
AI->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUIDLow());
AI->MovementInform(FOLLOW_MOTION_TYPE, i_target.getTarget()->GetGUID().GetCounter());
}
//-----------------------------------------------//

View File

@@ -27,7 +27,8 @@ void WaypointMovementGenerator<Creature>::LoadPath(Creature* creature)
if (!i_path)
{
// No movement found for entry
LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature %s (Entry: %u GUID: %u) doesn't have waypoint path id: %u", creature->GetName().c_str(), creature->GetEntry(), creature->GetGUIDLow(), path_id);
LOG_ERROR("sql.sql", "WaypointMovementGenerator::LoadPath: creature %s (%s) doesn't have waypoint path id: %u",
creature->GetName().c_str(), creature->GetGUID().ToString().c_str(), path_id);
return;
}
@@ -65,7 +66,8 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for " UI64FMTD ".", i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID());
LOG_DEBUG("maps.script", "Creature movement start script %u at point %u for %s.",
i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID().ToString().c_str());
#endif
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, creature, nullptr);
@@ -363,7 +365,8 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
{
if (i_currentNode >= i_path.size())
{
LOG_INFO("misc", "TAXI NODE WAS GREATER THAN PATH SIZE, GUID: %u, POINTID: %u, NODESIZE: %lu, CURRENT: %u", player->GetGUIDLow(), pointId, i_path.size(), i_currentNode);
LOG_INFO("misc", "TAXI NODE WAS GREATER THAN PATH SIZE, %s, POINTID: %u, NODESIZE: %lu, CURRENT: %u",
player->GetGUID().ToString().c_str(), pointId, i_path.size(), i_currentNode);
player->CleanupAfterTaxiFlight();
return false;
}