Core/MovementGenerator: Add more details to asserts

Implement GetDebugInfo in MovementGenerator, PathMovementBase, FlightPathMovementGenerator, WaypointMovementGenerator.
Add an additional assert in FlightPathMovementGenerator::DoEventIfAny(), the input node must not be null
This commit is contained in:
jackpoz
2019-05-30 19:00:32 +02:00
parent 88c6c61b95
commit 9da8123959
7 changed files with 61 additions and 0 deletions

View File

@@ -26,6 +26,17 @@
MovementGenerator::~MovementGenerator() { }
std::string MovementGenerator::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Mode: " << std::to_string(Mode)
<< " Priority: " << std::to_string(Priority)
<< " Flags: " << Flags
<< " BaseUniteState: " << BaseUnitState;
return sstr.str();
}
IdleMovementFactory::IdleMovementFactory() : MovementGeneratorCreator(IDLE_MOTION_TYPE) { }
MovementGenerator* IdleMovementFactory::Create(Unit* /*object*/) const

View File

@@ -74,6 +74,8 @@ class TC_GAME_API MovementGenerator
bool HasFlag(uint16 const flag) const { return (Flags & flag) != 0; }
void RemoveFlag(uint16 const flag) { Flags &= ~flag; }
virtual std::string GetDebugInfo() const;
uint8 Mode;
uint8 Priority;
uint16 Flags;

View File

@@ -235,6 +235,8 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
void FlightPathMovementGenerator::DoEventIfAny(Player* owner, TaxiPathNodeEntry const* node, bool departure)
{
ASSERT(node);
if (uint32 eventid = departure ? node->DepartureEventID : node->ArrivalEventID)
{
TC_LOG_DEBUG("maps.script", "FlightPathMovementGenerator::DoEventIfAny: taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node->NodeIndex, node->PathID, owner->GetName().c_str());
@@ -273,3 +275,27 @@ void FlightPathMovementGenerator::PreloadEndGrid()
else
TC_LOG_DEBUG("movement.flightpath", "FlightPathMovementGenerator::PreloadEndGrid: unable to determine map to preload flightmaster grid");
}
uint32 FlightPathMovementGenerator::GetPathId(size_t index) const
{
if (index >= _path.size())
return 0;
return _path[index]->PathID;
}
std::string FlightPathMovementGenerator::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< PathMovementBase::GetDebugInfo() << "\n"
<< MovementGeneratorMedium::GetDebugInfo() << "\n"
<< "Start Path Id: " << GetPathId(0)
<< " Path Size: " << _path.size()
<< " HasArrived: " << HasArrived()
<< " End Grid X: " << _endGridX
<< " End Grid Y: " << _endGridY
<< " End Map Id: " << _endMapId
<< " Preloaded Target Node: " << _preloadTargetNode;
return sstr.str();
}

View File

@@ -46,6 +46,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, Fligh
TaxiPathNodeList const& GetPath() { return _path; }
uint32 GetPathAtMapEnd() const;
bool HasArrived() const { return _currentNode >= _path.size(); }
uint32 GetPathId(size_t index) const;
void LoadPath(Player* owner); // called from MotionMaster
void SetCurrentNodeAfterTeleport();
@@ -54,6 +55,8 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, Fligh
void InitEndGridInfo();
void PreloadEndGrid();
std::string GetDebugInfo() const override;
private:
float _endGridX; //! X coord of last node location
float _endGridY; //! Y coord of last node location

View File

@@ -19,6 +19,7 @@
#define PathMovementBase_h__
#include "Define.h"
#include <sstream>
template<class Entity, class BasePath>
class PathMovementBase
@@ -29,6 +30,14 @@ class PathMovementBase
uint32 GetCurrentNode() const { return _currentNode; }
virtual std::string GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Current Node: " << GetCurrentNode();
return sstr.str();
};
protected:
BasePath _path;
uint32 _currentNode;

View File

@@ -390,3 +390,11 @@ bool WaypointMovementGenerator<Creature>::ComputeNextNode()
_currentNode = (_currentNode + 1) % _path->nodes.size();
return true;
}
std::string WaypointMovementGenerator<Creature>::GetDebugInfo() const
{
std::stringstream sstr;
sstr << PathMovementBase::GetDebugInfo() << "\n"
<< MovementGeneratorMedium::GetDebugInfo();
return sstr.str();
}

View File

@@ -51,6 +51,8 @@ class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium<Creat
void DoDeactivate(Creature*);
void DoFinalize(Creature*, bool, bool);
std::string GetDebugInfo() const override;
private:
void MovementInform(Creature*);
void OnArrived(Creature*);