Revert "refactor(Core/Movement): Naming convention" (#14100)

Revert "refactor(Core/Movement): Naming convention (#13989)"

This reverts commit d2f440c3e8.
This commit is contained in:
Skjalf
2022-12-10 23:53:09 -03:00
committed by GitHub
parent 35e4b935b8
commit 19fa22ba92
19 changed files with 148 additions and 149 deletions

View File

@@ -54,9 +54,9 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
float new_z = unit->GetMapHeight(wanderX, wanderY, z);
if (new_z <= INVALID_HEIGHT || std::fabs(z - new_z) > 3.0f) // pussywizard
{
_waypoints[idx][0] = idx > 0 ? _waypoints[idx - 1][0] : x;
_waypoints[idx][1] = idx > 0 ? _waypoints[idx - 1][1] : y;
_waypoints[idx][2] = idx > 0 ? _waypoints[idx - 1][2] : z;
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx - 1][0] : x;
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx - 1][1] : y;
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx - 1][2] : z;
continue;
}
else if (unit->IsWithinLOS(wanderX, wanderY, z))
@@ -66,32 +66,32 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
{
//! Cannot use coordinates outside our InhabitType. Use the current or previous position.
_waypoints[idx][0] = idx > 0 ? _waypoints[idx - 1][0] : x;
_waypoints[idx][1] = idx > 0 ? _waypoints[idx - 1][1] : y;
_waypoints[idx][2] = idx > 0 ? _waypoints[idx - 1][2] : z;
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx - 1][0] : x;
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx - 1][1] : y;
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx - 1][2] : z;
continue;
}
}
else
{
//! Trying to access path outside line of sight. Skip this by using the current or previous position.
_waypoints[idx][0] = idx > 0 ? _waypoints[idx - 1][0] : x;
_waypoints[idx][1] = idx > 0 ? _waypoints[idx - 1][1] : y;
_waypoints[idx][2] = idx > 0 ? _waypoints[idx - 1][2] : z;
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx - 1][0] : x;
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx - 1][1] : y;
i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx - 1][2] : z;
continue;
}
//unit->UpdateAllowedPositionZ(wanderX, wanderY, z);
//! Positions are fine - apply them to this waypoint
_waypoints[idx][0] = wanderX;
_waypoints[idx][1] = wanderY;
_waypoints[idx][2] = new_z;
i_waypoints[idx][0] = wanderX;
i_waypoints[idx][1] = wanderY;
i_waypoints[idx][2] = new_z;
}
// Xinef: Call movement immediately to broadcast movement packet
// Xinef: Initial timer is set to 1 so update with 1
_nextMove = urand(1, MAX_CONF_WAYPOINTS);
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
DoUpdate(unit, 1);
unit->SetUnitFlag(UNIT_FLAG_CONFUSED);
@@ -127,30 +127,30 @@ bool ConfusedMovementGenerator<T>::DoUpdate(T* unit, uint32 diff)
return true;
}
if (_nextMoveTime.Passed())
if (i_nextMoveTime.Passed())
{
// currently moving, update location
unit->AddUnitState(UNIT_STATE_CONFUSED_MOVE);
if (unit->movespline->Finalized())
{
_nextMove = urand(1, MAX_CONF_WAYPOINTS);
_nextMoveTime.Reset(urand(600, 1200)); // Guessed
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
i_nextMoveTime.Reset(urand(600, 1200)); // Guessed
}
}
else
{
// waiting for next move
_nextMoveTime.Update(diff);
if (_nextMoveTime.Passed())
i_nextMoveTime.Update(diff);
if (i_nextMoveTime.Passed())
{
// start moving
unit->AddUnitState(UNIT_STATE_CONFUSED_MOVE);
ASSERT(_nextMove <= MAX_CONF_WAYPOINTS);
float x = _waypoints[_nextMove][0];
float y = _waypoints[_nextMove][1];
float z = _waypoints[_nextMove][2];
ASSERT(i_nextMove <= MAX_CONF_WAYPOINTS);
float x = i_waypoints[i_nextMove][0];
float y = i_waypoints[i_nextMove][1];
float z = i_waypoints[i_nextMove][2];
Movement::MoveSplineInit init(unit);
init.MoveTo(x, y, z, true);
init.Launch();

View File

@@ -27,7 +27,7 @@ template<class T>
class ConfusedMovementGenerator : public MovementGeneratorMedium< T, ConfusedMovementGenerator<T> >
{
public:
explicit ConfusedMovementGenerator() : _nextMoveTime(1) {}
explicit ConfusedMovementGenerator() : i_nextMoveTime(1) {}
void DoInitialize(T*);
void DoFinalize(T*);
@@ -37,8 +37,8 @@ public:
MovementGeneratorType GetMovementGeneratorType() { return CONFUSED_MOTION_TYPE; }
private:
void _InitSpecific(T*, bool&, bool&);
TimeTracker _nextMoveTime;
float _waypoints[MAX_CONF_WAYPOINTS + 1][3];
uint32 _nextMove;
TimeTracker i_nextMoveTime;
float i_waypoints[MAX_CONF_WAYPOINTS + 1][3];
uint32 i_nextMove;
};
#endif

View File

@@ -22,7 +22,6 @@
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "Player.h"
#include "Unit.h"
#include "World.h"
template<class T>
@@ -32,13 +31,13 @@ void EscortMovementGenerator<T>::DoInitialize(T* unit)
unit->StopMoving();
unit->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
_recalculateSpeed = false;
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
if (_precomputedPath.size() == 2) // xinef: simple case, just call move to
init.MoveTo(_precomputedPath[1].x, _precomputedPath[1].y, _precomputedPath[1].z, true);
else if (_precomputedPath.size())
init.MovebyPath(_precomputedPath);
if (m_precomputedPath.size() == 2) // xinef: simple case, just call move to
init.MoveTo(m_precomputedPath[1].x, m_precomputedPath[1].y, m_precomputedPath[1].z, true);
else if (m_precomputedPath.size())
init.MovebyPath(m_precomputedPath);
init.Launch();
@@ -61,26 +60,26 @@ bool EscortMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/)
bool arrived = unit->movespline->Finalized();
if (_recalculateSpeed && !arrived)
if (i_recalculateSpeed && !arrived)
{
_recalculateSpeed = false;
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
// xinef: speed changed during path execution, calculate remaining path and launch it once more
if (_precomputedPath.size())
if (m_precomputedPath.size())
{
uint32 offset = std::min(uint32(unit->movespline->_currentSplineIdx()), uint32(_precomputedPath.size()));
Movement::PointsArray::iterator offsetItr = _precomputedPath.begin();
uint32 offset = std::min(uint32(unit->movespline->_currentSplineIdx()), uint32(m_precomputedPath.size()));
Movement::PointsArray::iterator offsetItr = m_precomputedPath.begin();
std::advance(offsetItr, offset);
_precomputedPath.erase(_precomputedPath.begin(), offsetItr);
m_precomputedPath.erase(m_precomputedPath.begin(), offsetItr);
// restore 0 element (current position)
_precomputedPath.insert(_precomputedPath.begin(), G3D::Vector3(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()));
m_precomputedPath.insert(m_precomputedPath.begin(), G3D::Vector3(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()));
if (_precomputedPath.size() > 2)
init.MovebyPath(_precomputedPath);
else if (_precomputedPath.size() == 2)
init.MoveTo(_precomputedPath[1].x, _precomputedPath[1].y, _precomputedPath[1].z, true);
if (m_precomputedPath.size() > 2)
init.MovebyPath(m_precomputedPath);
else if (m_precomputedPath.size() == 2)
init.MoveTo(m_precomputedPath[1].x, m_precomputedPath[1].y, m_precomputedPath[1].z, true);
}
init.Launch();

View File

@@ -24,10 +24,10 @@ template<class T>
class EscortMovementGenerator : public MovementGeneratorMedium< T, EscortMovementGenerator<T> >
{
public:
EscortMovementGenerator(Movement::PointsArray* _path = nullptr) : _recalculateSpeed(false)
EscortMovementGenerator(Movement::PointsArray* _path = nullptr) : i_recalculateSpeed(false)
{
if (_path)
_precomputedPath = *_path;
m_precomputedPath = *_path;
}
void DoInitialize(T*);
@@ -35,15 +35,15 @@ public:
void DoReset(T*);
bool DoUpdate(T*, uint32);
void unitSpeedChanged() { _recalculateSpeed = true; }
void unitSpeedChanged() { i_recalculateSpeed = true; }
MovementGeneratorType GetMovementGeneratorType() { return ESCORT_MOTION_TYPE; }
uint32 GetSplineId() const { return _splineId; }
private:
bool _recalculateSpeed;
Movement::PointsArray _precomputedPath;
bool i_recalculateSpeed;
Movement::PointsArray m_precomputedPath;
uint32 _splineId;
};

View File

@@ -30,7 +30,7 @@ void HomeMovementGenerator<Creature>::DoInitialize(Creature* owner)
void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
{
owner->ClearUnitState(UNIT_STATE_EVADE);
if (_arrived)
if (arrived)
{
// Xinef: npc run by default
//owner->SetWalk(true);
@@ -68,15 +68,15 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
init.SetWalk(false);
init.Launch();
_arrived = false;
arrived = false;
owner->ClearUnitState(uint32(UNIT_STATE_ALL_STATE & ~(UNIT_STATE_POSSESSED | UNIT_STATE_EVADE | UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_NO_ENVIRONMENT_UPD)));
}
bool HomeMovementGenerator<Creature>::DoUpdate(Creature* owner, const uint32 /*time_diff*/)
{
_arrived = owner->movespline->Finalized();
if (_arrived)
arrived = owner->movespline->Finalized();
if (arrived)
return false;
if (i_recalculateTravel)

View File

@@ -29,7 +29,7 @@ template <>
class HomeMovementGenerator<Creature> : public MovementGeneratorMedium< Creature, HomeMovementGenerator<Creature> >
{
public:
HomeMovementGenerator() : _arrived(false), i_recalculateTravel(false) {}
HomeMovementGenerator() : arrived(false), i_recalculateTravel(false) {}
~HomeMovementGenerator() {}
void DoInitialize(Creature*);
@@ -41,7 +41,7 @@ public:
private:
void _setTargetLocation(Creature*);
bool _arrived : 1;
bool arrived : 1;
bool i_recalculateTravel : 1;
};
#endif

View File

@@ -99,10 +99,10 @@ void DistractMovementGenerator::Finalize(Unit* owner)
bool DistractMovementGenerator::Update(Unit* owner, uint32 time_diff)
{
if (owner->IsInCombat() || time_diff > _timer)
if (owner->IsInCombat() || time_diff > m_timer)
return false;
_timer -= time_diff;
m_timer -= time_diff;
return true;
}

View File

@@ -49,7 +49,7 @@ private:
class DistractMovementGenerator : public MovementGenerator
{
public:
explicit DistractMovementGenerator(uint32 timer) : _timer(timer) {}
explicit DistractMovementGenerator(uint32 timer) : m_timer(timer) {}
void Initialize(Unit*) override;
void Finalize(Unit*) override;
@@ -58,7 +58,7 @@ public:
MovementGeneratorType GetMovementGeneratorType() override { return DISTRACT_MOTION_TYPE; }
private:
uint32 _timer;
uint32 m_timer;
};
class AssistanceDistractMovementGenerator : public DistractMovementGenerator

View File

@@ -33,7 +33,7 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
{
// the next line is to ensure that a new spline is created in DoUpdate() once the unit is no longer rooted/stunned
// todo: rename this flag to something more appropriate since it is set to true even without speed change now.
_recalculateSpeed = true;
i_recalculateSpeed = true;
return;
}
@@ -46,48 +46,48 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
unit->AddUnitState(UNIT_STATE_CHARGING);
}
_recalculateSpeed = false;
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
if (_precomputedPath.size() > 2) // pussywizard: for charge
init.MovebyPath(_precomputedPath);
if (m_precomputedPath.size() > 2) // pussywizard: for charge
init.MovebyPath(m_precomputedPath);
else if (_generatePath)
{
PathGenerator path(unit);
bool result = path.CalculatePath(_x, _y, _z, _forceDestination);
bool result = path.CalculatePath(i_x, i_y, i_z, _forceDestination);
if (result && !(path.GetPathType() & PATHFIND_NOPATH) && path.GetPath().size() > 2)
{
_precomputedPath = path.GetPath();
init.MovebyPath(_precomputedPath);
m_precomputedPath = path.GetPath();
init.MovebyPath(m_precomputedPath);
}
else
{
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), _x) && G3D::fuzzyEq(unit->GetPositionY(), _y))
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
_x += 0.2f * cos(unit->GetOrientation());
_y += 0.2f * std::sin(unit->GetOrientation());
i_x += 0.2f * cos(unit->GetOrientation());
i_y += 0.2f * std::sin(unit->GetOrientation());
}
init.MoveTo(_x, _y, _z, true);
init.MoveTo(i_x, i_y, i_z, true);
}
}
else
{
// Xinef: fix strange client visual bug, moving on z coordinate only switches orientation by 180 degrees (visual only)
if (G3D::fuzzyEq(unit->GetPositionX(), _x) && G3D::fuzzyEq(unit->GetPositionY(), _y))
if (G3D::fuzzyEq(unit->GetPositionX(), i_x) && G3D::fuzzyEq(unit->GetPositionY(), i_y))
{
_x += 0.2f * cos(unit->GetOrientation());
_y += 0.2f * std::sin(unit->GetOrientation());
i_x += 0.2f * cos(unit->GetOrientation());
i_y += 0.2f * std::sin(unit->GetOrientation());
}
init.MoveTo(_x, _y, _z, true);
init.MoveTo(i_x, i_y, i_z, true);
}
if (speed > 0.0f)
init.SetVelocity(speed);
if (_orientation > 0.0f)
if (i_orientation > 0.0f)
{
init.SetFacing(_orientation);
init.SetFacing(i_orientation);
}
init.Launch();
@@ -117,35 +117,35 @@ bool PointMovementGenerator<T>::DoUpdate(T* unit, uint32 /*diff*/)
unit->AddUnitState(UNIT_STATE_ROAMING_MOVE);
if (id != EVENT_CHARGE_PREPATH && _recalculateSpeed && !unit->movespline->Finalized())
if (id != EVENT_CHARGE_PREPATH && i_recalculateSpeed && !unit->movespline->Finalized())
{
_recalculateSpeed = false;
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
// xinef: speed changed during path execution, calculate remaining path and launch it once more
if (_precomputedPath.size())
if (m_precomputedPath.size())
{
uint32 offset = std::min(uint32(unit->movespline->_currentSplineIdx()), uint32(_precomputedPath.size()));
Movement::PointsArray::iterator offsetItr = _precomputedPath.begin();
uint32 offset = std::min(uint32(unit->movespline->_currentSplineIdx()), uint32(m_precomputedPath.size()));
Movement::PointsArray::iterator offsetItr = m_precomputedPath.begin();
std::advance(offsetItr, offset);
_precomputedPath.erase(_precomputedPath.begin(), offsetItr);
m_precomputedPath.erase(m_precomputedPath.begin(), offsetItr);
// restore 0 element (current position)
_precomputedPath.insert(_precomputedPath.begin(), G3D::Vector3(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()));
m_precomputedPath.insert(m_precomputedPath.begin(), G3D::Vector3(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()));
if (_precomputedPath.size() > 2)
init.MovebyPath(_precomputedPath);
else if (_precomputedPath.size() == 2)
init.MoveTo(_precomputedPath[1].x, _precomputedPath[1].y, _precomputedPath[1].z, true);
if (m_precomputedPath.size() > 2)
init.MovebyPath(m_precomputedPath);
else if (m_precomputedPath.size() == 2)
init.MoveTo(m_precomputedPath[1].x, m_precomputedPath[1].y, m_precomputedPath[1].z, true);
}
else
init.MoveTo(_x, _y, _z, true);
init.MoveTo(i_x, i_y, i_z, true);
if (speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
init.SetVelocity(speed);
if (_orientation > 0.0f)
if (i_orientation > 0.0f)
{
init.SetFacing(_orientation);
init.SetFacing(i_orientation);
}
init.Launch();
@@ -247,5 +247,5 @@ void EffectMovementGenerator::Finalize(Unit* unit)
//}
if (unit->ToCreature()->AI())
unit->ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, _Id);
unit->ToCreature()->AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id);
}

View File

@@ -27,11 +27,11 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
public:
PointMovementGenerator(uint32 _id, float _x, float _y, float _z, float _speed = 0.0f, float orientation = 0.0f, const Movement::PointsArray* _path = nullptr,
bool generatePath = false, bool forceDestination = false, ObjectGuid chargeTargetGUID = ObjectGuid::Empty)
: id(_id), _x(_x), _y(_y), _z(_z), speed(_speed), _orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination),
: id(_id), i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination),
_chargeTargetGUID(chargeTargetGUID)
{
if (_path)
_precomputedPath = *_path;
m_precomputedPath = *_path;
}
void DoInitialize(T*);
@@ -41,18 +41,18 @@ public:
void MovementInform(T*);
void unitSpeedChanged() { _recalculateSpeed = true; }
void unitSpeedChanged() { i_recalculateSpeed = true; }
MovementGeneratorType GetMovementGeneratorType() { return POINT_MOTION_TYPE; }
bool GetDestination(float& x, float& y, float& z) const { x = _x; y = _y; z = _z; return true; }
bool GetDestination(float& x, float& y, float& z) const { x = i_x; y = i_y; z = i_z; return true; }
private:
uint32 id;
float _x, _y, _z;
float i_x, i_y, i_z;
float speed;
float _orientation;
bool _recalculateSpeed;
Movement::PointsArray _precomputedPath;
float i_orientation;
bool i_recalculateSpeed;
Movement::PointsArray m_precomputedPath;
bool _generatePath;
bool _forceDestination;
ObjectGuid _chargeTargetGUID;
@@ -72,14 +72,14 @@ public:
class EffectMovementGenerator : public MovementGenerator
{
public:
explicit EffectMovementGenerator(uint32 Id) : _Id(Id) {}
explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {}
void Initialize(Unit*) override {}
void Finalize(Unit*) override;
void Reset(Unit*) override {}
bool Update(Unit*, uint32) override;
MovementGeneratorType GetMovementGeneratorType() override { return EFFECT_MOTION_TYPE; }
private:
uint32 _Id;
uint32 m_Id;
};
#endif

View File

@@ -36,7 +36,7 @@ RandomMovementGenerator<Creature>::~RandomMovementGenerator()
}
template<>
void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* creature)
void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
{
if (creature->_moveState != MAP_OBJECT_CELL_MOVE_NONE)
return;
@@ -292,7 +292,7 @@ bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint3
{
_nextMoveTime.Update(diff);
if (_nextMoveTime.Passed())
SetRandomLocation(creature);
_setRandomLocation(creature);
}
return true;
}

View File

@@ -49,7 +49,7 @@ public:
}
~RandomMovementGenerator();
void SetRandomLocation(T*);
void _setRandomLocation(T*);
void DoInitialize(T*);
void DoFinalize(T*);
void DoReset(T*);

View File

@@ -75,22 +75,22 @@ void WaypointMovementGenerator<Creature>::OnArrived(Creature* creature)
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
m_isArrivalDone = true;
if (i_path->at(_currentNode)->event_id && urand(0, 99) < i_path->at(_currentNode)->event_chance)
if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
{
LOG_DEBUG("maps.script", "Creature movement start script {} at point {} for {}.",
i_path->at(_currentNode)->event_id, _currentNode, creature->GetGUID().ToString());
i_path->at(i_currentNode)->event_id, i_currentNode, creature->GetGUID().ToString());
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(_currentNode)->event_id, creature, nullptr);
creature->GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, creature, nullptr);
}
// Inform script
MovementInform(creature);
creature->UpdateWaypointID(_currentNode);
creature->UpdateWaypointID(i_currentNode);
if (i_path->at(_currentNode)->delay)
if (i_path->at(i_currentNode)->delay)
{
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
Stop(i_path->at(_currentNode)->delay);
Stop(i_path->at(i_currentNode)->delay);
}
}
@@ -111,11 +111,11 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
if (m_isArrivalDone)
{
// Xinef: not true... update this at every waypoint!
//if ((_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
//if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
float x = i_path->at(_currentNode)->x;
float y = i_path->at(_currentNode)->y;
float z = i_path->at(_currentNode)->z;
float x = i_path->at(i_currentNode)->x;
float y = i_path->at(i_currentNode)->y;
float z = i_path->at(i_currentNode)->z;
float o = creature->GetOrientation();
if (!transportPath)
@@ -136,14 +136,14 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
}
// Xinef: moved the upper IF here
if ((_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
if ((i_currentNode == i_path->size() - 1) && !repeating) // If that's our last waypoint
{
creature->AI()->PathEndReached(path_id);
creature->GetMotionMaster()->Initialize();
return false;
}
_currentNode = (_currentNode + 1) % i_path->size();
i_currentNode = (i_currentNode + 1) % i_path->size();
}
// xinef: do not initialize motion if we got stunned in movementinform
@@ -152,7 +152,7 @@ bool WaypointMovementGenerator<Creature>::StartMove(Creature* creature)
return true;
}
WaypointData const* node = i_path->at(_currentNode);
WaypointData const* node = i_path->at(i_currentNode);
m_isArrivalDone = false;
@@ -238,7 +238,7 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
bool finished = creature->movespline->Finalized();
// xinef: code to detect pre-empetively if we should start movement to next waypoint
// xinef: do not start pre-empetive movement if current node has delay or we are ending waypoint movement
//if (!finished && !i_path->at(_currentNode)->delay && ((_currentNode != i_path->size() - 1) || repeating))
//if (!finished && !i_path->at(i_currentNode)->delay && ((i_currentNode != i_path->size() - 1) || repeating))
// finished = (creature->movespline->_Spline().length(creature->movespline->_currentSplineIdx() + 1) - creature->movespline->timePassed()) < 200;
if (finished)
@@ -254,13 +254,13 @@ bool WaypointMovementGenerator<Creature>::DoUpdate(Creature* creature, uint32 di
void WaypointMovementGenerator<Creature>::MovementInform(Creature* creature)
{
if (creature->AI())
creature->AI()->MovementInform(WAYPOINT_MOTION_TYPE, _currentNode);
creature->AI()->MovementInform(WAYPOINT_MOTION_TYPE, i_currentNode);
if (Unit* owner = creature->GetCharmerOrOwner())
{
if (UnitAI* AI = owner->GetAI())
{
AI->SummonMovementInform(creature, WAYPOINT_MOTION_TYPE, _currentNode);
AI->SummonMovementInform(creature, WAYPOINT_MOTION_TYPE, i_currentNode);
}
}
}
@@ -269,13 +269,13 @@ void WaypointMovementGenerator<Creature>::MovementInform(Creature* creature)
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{
if (_currentNode >= i_path.size())
if (i_currentNode >= i_path.size())
{
return i_path.size();
}
uint32 curMapId = i_path[_currentNode]->mapid;
for (uint32 i = _currentNode; i < i_path.size(); ++i)
uint32 curMapId = i_path[i_currentNode]->mapid;
for (uint32 i = i_currentNode; i < i_path.size(); ++i)
{
if (i_path[i]->mapid != curMapId)
{
@@ -401,15 +401,15 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
{
// skipping the first spline path point because it's our starting point and not a taxi path point
uint32 pointId = player->movespline->currentPathIdx() <= 0 ? 0 : player->movespline->currentPathIdx() - 1;
if (pointId > _currentNode && _currentNode < i_path.size() - 1)
if (pointId > i_currentNode && i_currentNode < i_path.size() - 1)
{
bool departureEvent = true;
do
{
ASSERT(_currentNode < i_path.size(), "Point Id: {}\n{}", pointId, player->GetGUID().ToString().c_str());
ASSERT(i_currentNode < i_path.size(), "Point Id: {}\n{}", pointId, player->GetGUID().ToString().c_str());
DoEventIfAny(player, i_path[_currentNode], departureEvent);
while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= _currentNode)
DoEventIfAny(player, i_path[i_currentNode], departureEvent);
while (!_pointsForPathSwitch.empty() && _pointsForPathSwitch.front().PathIndex <= i_currentNode)
{
_pointsForPathSwitch.pop_front();
player->m_taxi.NextTaxiDestination();
@@ -420,37 +420,37 @@ bool FlightPathMovementGenerator::DoUpdate(Player* player, uint32 /*diff*/)
}
}
if (pointId == _currentNode)
if (pointId == i_currentNode)
{
break;
}
if (_currentNode == _preloadTargetNode)
if (i_currentNode == _preloadTargetNode)
{
PreloadEndGrid();
}
_currentNode += departureEvent ? 1 : 0;
i_currentNode += departureEvent ? 1 : 0;
departureEvent = !departureEvent;
} while (_currentNode < i_path.size() - 1);
} while (i_currentNode < i_path.size() - 1);
}
return _currentNode < (i_path.size() - 1);
return i_currentNode < (i_path.size() - 1);
}
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
{
if (i_path.empty() || _currentNode >= i_path.size())
if (i_path.empty() || i_currentNode >= i_path.size())
{
return;
}
uint32 map0 = i_path[_currentNode]->mapid;
for (size_t i = _currentNode + 1; i < i_path.size(); ++i)
uint32 map0 = i_path[i_currentNode]->mapid;
for (size_t i = i_currentNode + 1; i < i_path.size(); ++i)
{
if (i_path[i]->mapid != map0)
{
_currentNode = i;
i_currentNode = i;
return;
}
}
@@ -467,7 +467,7 @@ void FlightPathMovementGenerator::DoEventIfAny(Player* player, TaxiPathNodeEntry
bool FlightPathMovementGenerator::GetResetPos(Player*, float& x, float& y, float& z)
{
TaxiPathNodeEntry const* node = i_path[_currentNode];
TaxiPathNodeEntry const* node = i_path[i_currentNode];
x = node->x;
y = node->y;
z = node->z;

View File

@@ -35,15 +35,15 @@ template<class T, class P>
class PathMovementBase
{
public:
PathMovementBase() : i_path(), _currentNode(0) {}
PathMovementBase(P path) : i_path(path), _currentNode(0) {}
PathMovementBase() : i_path(), i_currentNode(0) {}
PathMovementBase(P path) : i_path(path), i_currentNode(0) {}
virtual ~PathMovementBase() {};
uint32 GetCurrentNode() const { return _currentNode; }
uint32 GetCurrentNode() const { return i_currentNode; }
protected:
P i_path;
uint32 _currentNode;
uint32 i_currentNode;
};
template<class T>
@@ -104,7 +104,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig
public:
explicit FlightPathMovementGenerator(uint32 startNode = 0)
{
_currentNode = startNode;
i_currentNode = startNode;
_endGridX = 0.0f;
_endGridY = 0.0f;
_endMapId = 0;
@@ -119,9 +119,9 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, Flig
TaxiPathNodeList const& GetPath() { return i_path; }
uint32 GetPathAtMapEnd() const;
bool HasArrived() const { return (_currentNode >= i_path.size()); }
bool HasArrived() const { return (i_currentNode >= i_path.size()); }
void SetCurrentNodeAfterTeleport();
void SkipCurrentNode() { ++_currentNode; }
void SkipCurrentNode() { ++i_currentNode; }
void DoEventIfAny(Player* player, TaxiPathNodeEntry const* node, bool departure);
bool GetResetPos(Player*, float& x, float& y, float& z);