Use original taxipath data in taxi flight movement generator. Author: Vladimir
+ Cleanup --HG-- branch : trunk
This commit is contained in:
@@ -229,24 +229,20 @@ template bool WaypointMovementGenerator<Player>::Update(Player &, const uint32 &
|
||||
template void WaypointMovementGenerator<Player>::MovementInform(Player &);
|
||||
|
||||
//----------------------------------------------------//
|
||||
void FlightPathMovementGenerator::LoadPath(Player &)
|
||||
{
|
||||
objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds);
|
||||
}
|
||||
|
||||
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
|
||||
{
|
||||
if (i_currentNode >= i_mapIds.size())
|
||||
return i_mapIds.size();
|
||||
if (i_currentNode >= i_path->size())
|
||||
return i_path->size();
|
||||
|
||||
uint32 curMapId = i_mapIds[i_currentNode];
|
||||
for (uint32 i = i_currentNode; i < i_mapIds.size(); ++i)
|
||||
uint32 curMapId = (*i_path)[i_currentNode].mapid;
|
||||
for (uint32 i = i_currentNode; i < i_path->size(); ++i)
|
||||
{
|
||||
if (i_mapIds[i] != curMapId)
|
||||
if ((*i_path)[i].mapid != curMapId)
|
||||
return i;
|
||||
}
|
||||
|
||||
return i_mapIds.size();
|
||||
return i_path->size();
|
||||
}
|
||||
|
||||
void FlightPathMovementGenerator::Initialize(Player &player)
|
||||
@@ -254,23 +250,12 @@ void FlightPathMovementGenerator::Initialize(Player &player)
|
||||
player.getHostileRefManager().setOnlineOfflineState(false);
|
||||
player.addUnitState(UNIT_STAT_IN_FLIGHT);
|
||||
player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||
LoadPath(player);
|
||||
Traveller<Player> traveller(player);
|
||||
// do not send movement, it was sent already
|
||||
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
|
||||
|
||||
i_destinationHolder.SetDestination(traveller, (*i_path)[i_currentNode].x, (*i_path)[i_currentNode].y, (*i_path)[i_currentNode].z, false);
|
||||
// For preloading end grid
|
||||
InitEndGridInfo();
|
||||
player.SendMonsterMoveByPath(GetPath(), GetCurrentNode(), GetPathAtMapEnd());
|
||||
|
||||
// Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will
|
||||
// be reinitialized for each flightmaster at the end of each spline (or stop) in the flight.
|
||||
|
||||
uint32 nodeCount = i_mapIds.size(); // Get the number of nodes in the path. i_path and i_mapIds are the
|
||||
// same size when loaded in ObjectMgr::GetTaxiPathNodes, called from LoadPath()
|
||||
|
||||
m_endMapId = i_mapIds[nodeCount -1]; // Get the map ID from the last node
|
||||
m_preloadTargetNode = nodeCount / 2; // Split the number of nodes in half to preload the flightmaster half-way through the flight
|
||||
m_endGridX = i_path[nodeCount -1].x; // Get the X position from the last node
|
||||
m_endGridY = i_path[nodeCount -1].y; // Get tye Y position from the last node
|
||||
}
|
||||
|
||||
void FlightPathMovementGenerator::Finalize(Player & player)
|
||||
@@ -280,6 +265,7 @@ void FlightPathMovementGenerator::Finalize(Player & player)
|
||||
float x, y, z;
|
||||
i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z);
|
||||
player.SetPosition(x, y, z, player.GetOrientation());
|
||||
|
||||
}
|
||||
|
||||
bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
|
||||
@@ -292,18 +278,18 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
|
||||
i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE);
|
||||
if (i_destinationHolder.HasArrived())
|
||||
{
|
||||
uint32 curMap = i_mapIds[i_currentNode];
|
||||
uint32 curMap = (*i_path)[i_currentNode].mapid;
|
||||
++i_currentNode;
|
||||
if (MovementInProgress())
|
||||
{
|
||||
DEBUG_LOG("loading node %u for player %s", i_currentNode, player.GetName());
|
||||
if (i_mapIds[i_currentNode] == curMap)
|
||||
if ((*i_path)[i_currentNode].mapid == curMap)
|
||||
{
|
||||
// do not send movement, it was sent already
|
||||
i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false);
|
||||
i_destinationHolder.SetDestination(traveller, (*i_path)[i_currentNode].x, (*i_path)[i_currentNode].y, (*i_path)[i_currentNode].z, false);
|
||||
}
|
||||
|
||||
// check if it's time to preload the flightmaster grid at path end
|
||||
|
||||
// check if it's time to preload the flightmaster grid at path end
|
||||
if (i_currentNode == m_preloadTargetNode)
|
||||
PreloadEndGrid();
|
||||
|
||||
@@ -324,13 +310,13 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
|
||||
|
||||
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
|
||||
{
|
||||
if (i_mapIds.empty())
|
||||
if (i_path->empty())
|
||||
return;
|
||||
|
||||
uint32 map0 = i_mapIds[0];
|
||||
for (size_t i = 1; i < i_mapIds.size(); ++i)
|
||||
uint32 map0 = (*i_path)[0].mapid;
|
||||
for (size_t i = 1; i < i_path->size(); ++i)
|
||||
{
|
||||
if (i_mapIds[i] != map0)
|
||||
if ((*i_path)[i].mapid != map0)
|
||||
{
|
||||
i_currentNode = i;
|
||||
return;
|
||||
@@ -338,6 +324,18 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
|
||||
}
|
||||
}
|
||||
|
||||
void FlightPathMovementGenerator::InitEndGridInfo()
|
||||
{
|
||||
// Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will
|
||||
// be reinitialized for each flightmaster at the end of each spline (or stop) in the flight.
|
||||
|
||||
uint32 nodeCount = (*i_path).size(); // Get the number of nodes in the path.
|
||||
m_endMapId = (*i_path)[nodeCount -1].mapid; // Get the map ID from the last node
|
||||
m_preloadTargetNode = nodeCount / 2; // Split the number of nodes in half to preload the flightmaster half-way through the flight
|
||||
m_endGridX = (*i_path)[nodeCount -1].x; // Get the X position from the last node
|
||||
m_endGridY = (*i_path)[nodeCount -1].y; // Get the Y position from the last node
|
||||
}
|
||||
|
||||
void FlightPathMovementGenerator::PreloadEndGrid()
|
||||
{
|
||||
// used to preload the final grid where the flightmaster is
|
||||
|
||||
@@ -42,18 +42,21 @@
|
||||
#define STOP_TIME_FOR_PLAYER 3 * MINUTE * IN_MILISECONDS // 3 Minutes
|
||||
#define TIMEDIFF_NEXT_WP 250
|
||||
|
||||
template<class T, class P = Path>
|
||||
template<class T, class P>
|
||||
class PathMovementBase
|
||||
{
|
||||
public:
|
||||
PathMovementBase() : i_currentNode(0) {}
|
||||
virtual ~PathMovementBase() {};
|
||||
|
||||
bool MovementInProgress(void) const { return i_currentNode < i_path.Size(); }
|
||||
bool MovementInProgress(void) const { return i_currentNode < i_path->size(); }
|
||||
|
||||
void LoadPath(T &);
|
||||
void ReloadPath(T &);
|
||||
uint32 GetCurrentNode() const { return i_currentNode; }
|
||||
|
||||
bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x,y,z); return true; }
|
||||
bool GetPosition(float& x, float& y, float& z) const { i_destinationHolder.GetLocationNowNoMicroMovement(x,y,z); return true; }
|
||||
|
||||
protected:
|
||||
uint32 i_currentNode;
|
||||
@@ -64,7 +67,7 @@ class PathMovementBase
|
||||
template<class T>
|
||||
|
||||
class WaypointMovementGenerator
|
||||
: public MovementGeneratorMedium< T, WaypointMovementGenerator<T> >, public PathMovementBase<T>
|
||||
: public MovementGeneratorMedium< T, WaypointMovementGenerator<T> >, public PathMovementBase<T, WaypointPath const*>
|
||||
{
|
||||
public:
|
||||
WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true) :
|
||||
@@ -93,28 +96,29 @@ class WaypointMovementGenerator
|
||||
*/
|
||||
class FlightPathMovementGenerator
|
||||
: public MovementGeneratorMedium< Player, FlightPathMovementGenerator >,
|
||||
public PathMovementBase<Player>
|
||||
public PathMovementBase<Player,TaxiPathNodeList const*>
|
||||
{
|
||||
uint32 i_pathId;
|
||||
std::vector<uint32> i_mapIds;
|
||||
public:
|
||||
explicit FlightPathMovementGenerator(uint32 id, uint32 startNode = 0) : i_pathId(id) { i_currentNode = startNode; }
|
||||
explicit FlightPathMovementGenerator(TaxiPathNodeList const& pathnodes, uint32 startNode = 0)
|
||||
{
|
||||
i_path = &pathnodes;
|
||||
i_currentNode = startNode;
|
||||
}
|
||||
void Initialize(Player &);
|
||||
void Reset(Player &u){};
|
||||
void Finalize(Player &);
|
||||
void Reset(Player &) {}
|
||||
bool Update(Player &, const uint32 &);
|
||||
MovementGeneratorType GetMovementGeneratorType() { return FLIGHT_MOTION_TYPE; }
|
||||
|
||||
void LoadPath(Player &);
|
||||
void ReloadPath(Player &) { /* don't reload flight path */ }
|
||||
|
||||
Path& GetPath() { return i_path; }
|
||||
TaxiPathNodeList const& GetPath() { return *i_path; }
|
||||
uint32 GetPathAtMapEnd() const;
|
||||
bool HasArrived() const { return (i_currentNode >= i_path.Size()); }
|
||||
bool HasArrived() const { return (i_currentNode >= i_path->size()); }
|
||||
void SetCurrentNodeAfterTeleport();
|
||||
void SkipCurrentNode() { ++i_currentNode; }
|
||||
bool GetDestination(float& x, float& y, float& z) const { i_destinationHolder.GetDestination(x,y,z); return true; }
|
||||
bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase<Player,TaxiPathNodeList const*>::GetDestination(x,y,z); }
|
||||
|
||||
void PreloadEndGrid();
|
||||
void InitEndGridInfo();
|
||||
private:
|
||||
// storage for preloading the flightmaster grid at end
|
||||
// before reaching final waypoint
|
||||
@@ -122,7 +126,6 @@ public PathMovementBase<Player>
|
||||
uint32 m_preloadTargetNode;
|
||||
float m_endGridX;
|
||||
float m_endGridY;
|
||||
void PreloadEndGrid();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user