Use original taxipath data in taxi flight movement generator. Author: Vladimir

+ Cleanup

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-23 00:57:16 +02:00
parent 1daa1c09f9
commit d50cb473cb
14 changed files with 169 additions and 161 deletions
+1 -1
View File
@@ -506,7 +506,7 @@ void LoadDBCStores(const std::string& dataPath)
// fill data
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
sTaxiPathNodesByPath[entry->path][entry->index] = entry;
sTaxiPathNodesByPath[entry->path].set(entry->index, entry);
// Initialize global taxinodes mask
// include existed nodes that have at least single not spell base (scripted) path
+11 -1
View File
@@ -21,8 +21,10 @@
#ifndef TRINITY_DBCSTRUCTURE_H
#define TRINITY_DBCSTRUCTURE_H
#include "Common.h"
#include "DBCEnums.h"
#include "Define.h"
#include "Path.h"
#include "Util.h"
#include <map>
@@ -1911,7 +1913,15 @@ struct TaxiPathBySourceAndDestination
typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
typedef std::vector<TaxiPathNodeEntry const*> TaxiPathNodeList;
struct TaxiPathNodePtr
{
TaxiPathNodePtr() : i_ptr(NULL) {}
TaxiPathNodePtr(TaxiPathNodeEntry const* ptr) : i_ptr(ptr) {}
TaxiPathNodeEntry const* i_ptr;
operator TaxiPathNodeEntry const& () const { return *i_ptr; }
};
typedef Path<TaxiPathNodePtr,TaxiPathNodeEntry const> TaxiPathNodeList;
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
#define TaxiMaskSize 12
+14 -10
View File
@@ -295,7 +295,11 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
{
//WPAssert(this->ToPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE);
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(const_cast<Player*>(this->ToPlayer())->GetMotionMaster()->top());
Player *player = const_cast<Object*>(this)->ToPlayer();
if (!player)
return;
FlightPathMovementGenerator *fmg = (FlightPathMovementGenerator*)(player->GetMotionMaster()->top());
uint32 flags3 = MOVEFLAG_GLIDE;
@@ -320,10 +324,10 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
}
}
Path &path = fmg->GetPath();
TaxiPathNodeList& path = const_cast<TaxiPathNodeList&>(fmg->GetPath());
float x, y, z;
this->ToPlayer()->GetPosition(x, y, z);
player->GetPosition(x, y, z);
uint32 inflighttime = uint32(path.GetPassedLength(fmg->GetCurrentNode(), x, y, z) * 32);
uint32 traveltime = uint32(path.GetTotalLength() * 32);
@@ -338,21 +342,21 @@ void Object::_BuildMovementUpdate(ByteBuffer * data, uint16 flags) const
*data << uint32(0); // added in 3.1
uint32 poscount = uint32(path.Size());
uint32 poscount = uint32(path.size());
*data << uint32(poscount); // points count
for (uint32 i = 0; i < poscount; ++i)
{
*data << path.GetNodes()[i].x;
*data << path.GetNodes()[i].y;
*data << path.GetNodes()[i].z;
*data << float(path[i].x);
*data << float(path[i].y);
*data << float(path[i].z);
}
*data << uint8(0); // added in 3.0.8
*data << path.GetNodes()[poscount-1].x;
*data << path.GetNodes()[poscount-1].y;
*data << path.GetNodes()[poscount-1].z;
*data << float(path[poscount-1].x);
*data << float(path[poscount-1].y);
*data << float(path[poscount-1].z);
}
}
else
+12 -12
View File
@@ -19363,30 +19363,30 @@ void Player::ContinueTaxiFlight()
float distPrev = MAP_SIZE*MAP_SIZE;
float distNext =
(nodeList[0]->x-GetPositionX())*(nodeList[0]->x-GetPositionX())+
(nodeList[0]->y-GetPositionY())*(nodeList[0]->y-GetPositionY())+
(nodeList[0]->z-GetPositionZ())*(nodeList[0]->z-GetPositionZ());
(nodeList[0].x-GetPositionX())*(nodeList[0].x-GetPositionX())+
(nodeList[0].y-GetPositionY())*(nodeList[0].y-GetPositionY())+
(nodeList[0].z-GetPositionZ())*(nodeList[0].z-GetPositionZ());
for (uint32 i = 1; i < nodeList.size(); ++i)
{
TaxiPathNodeEntry const* node = nodeList[i];
TaxiPathNodeEntry const* prevNode = nodeList[i-1];
TaxiPathNodeEntry const& node = nodeList[i];
TaxiPathNodeEntry const& prevNode = nodeList[i-1];
// skip nodes at another map
if (node->mapid != GetMapId())
if (node.mapid != GetMapId())
continue;
distPrev = distNext;
distNext =
(node->x-GetPositionX())*(node->x-GetPositionX())+
(node->y-GetPositionY())*(node->y-GetPositionY())+
(node->z-GetPositionZ())*(node->z-GetPositionZ());
(node.x-GetPositionX())*(node.x-GetPositionX())+
(node.y-GetPositionY())*(node.y-GetPositionY())+
(node.z-GetPositionZ())*(node.z-GetPositionZ());
float distNodes =
(node->x-prevNode->x)*(node->x-prevNode->x)+
(node->y-prevNode->y)*(node->y-prevNode->y)+
(node->z-prevNode->z)*(node->z-prevNode->z);
(node.x-prevNode.x)*(node.x-prevNode.x)+
(node.y-prevNode.y)*(node.y-prevNode.y)+
(node.z-prevNode.z)*(node.z-prevNode.z);
if (distNext + distPrev < distNodes)
{
@@ -217,10 +217,10 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
{
if (mapChange == 0)
{
TaxiPathNodeEntry const* node_i = path[i];
if (node_i->mapid == path[i+1]->mapid)
TaxiPathNodeEntry const& node_i = path[i];
if (node_i.mapid == path[i+1].mapid)
{
keyFrame k(node_i->x, node_i->y, node_i->z, node_i->mapid, node_i->actionFlag, node_i->delay);
keyFrame k(node_i.x, node_i.y, node_i.z, node_i.mapid, node_i.actionFlag, node_i.delay);
keyFrames.push_back(k);
mapids.insert(k.mapid);
}
-23
View File
@@ -435,29 +435,6 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M
SendMessageToSet(&data, true);
}*/
void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end)
{
uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32);
uint32 pathSize = end - start;
WorldPacket data(SMSG_MONSTER_MOVE, (GetPackGUID().size()+1+4+4+4+4+1+4+4+4+pathSize*4*3));
data.append(GetPackGUID());
data << uint8(0);
data << GetPositionX();
data << GetPositionY();
data << GetPositionZ();
data << uint32(getMSTime());
data << uint8(0);
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight())? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK);
data << uint32(traveltime);
data << uint32(pathSize);
data.append((char*)path.GetNodes(start), pathSize * 4 * 3);
SendMessageToSet(&data, true);
//MONSTER_MOVE_SPLINE_FLY
addUnitState(UNIT_STAT_MOVE);
}
void Unit::SendMonsterMoveTransport(Unit *vehicleOwner)
{
WorldPacket data(SMSG_MONSTER_MOVE_TRANSPORT, GetPackGUID().size()+vehicleOwner->GetPackGUID().size());
+32 -2
View File
@@ -34,6 +34,9 @@
#include "EventProcessor.h"
#include "MotionMaster.h"
#include "DBCStructure.h"
#include "Path.h"
#include "WorldPacket.h"
#include "Timer.h"
#include <list>
#define WORLD_TRIGGER 12999
@@ -324,7 +327,6 @@ class DynamicObject;
class GameObject;
class Item;
class Pet;
class Path;
class PetAura;
class Minion;
class Guardian;
@@ -1436,12 +1438,14 @@ class Unit : public WorldObject
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 Time, Player* player = NULL);
void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 MoveFlags, uint32 time, float speedZ, Player *player = NULL);
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
void SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end);
void SendMonsterMoveTransport(Unit *vehicleOwner);
void SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTime = 0, Player* player = NULL);
void SendMonsterMoveWithSpeedToCurrentDestination(Player* player = NULL);
void SendMovementFlagUpdate();
template<typename PathElem, typename PathNode>
void SendMonsterMoveByPath(Path<PathElem,PathNode> const& path, uint32 start, uint32 end);
void SendChangeCurrentVictimOpcode(HostileReference* pHostileReference);
void SendClearThreatListOpcode();
void SendRemoveFromThreatListOpcode(HostileReference* pHostileReference);
@@ -2116,4 +2120,30 @@ namespace Trinity
};
}
template<typename Elem, typename Node>
inline void Unit::SendMonsterMoveByPath(Path<Elem,Node> const& path, uint32 start, uint32 end)
{
uint32 traveltime = uint32(path.GetTotalLength(start, end) * 32);
uint32 pathSize = end - start;
WorldPacket data(SMSG_MONSTER_MOVE, (GetPackGUID().size()+1+4+4+4+4+1+4+4+4+pathSize*4*3));
data.append(GetPackGUID());
data << uint8(0);
data << GetPositionX();
data << GetPositionY();
data << GetPositionZ();
data << uint32(getMSTime());
data << uint8(0);
data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight()) ? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK);
data << uint32(traveltime);
data << uint32(pathSize);
for (uint32 i = start; i < end; ++i)
{
data << float(path[i].x);
data << float(path[i].y);
data << float(path[i].z);
}
SendMessageToSet(&data, true);
}
#endif
-19
View File
@@ -5482,25 +5482,6 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt
return mount_id;
}
void ObjectMgr::GetTaxiPathNodes(uint32 path, Path &pathnodes, std::vector<uint32>& mapIds)
{
if (path >= sTaxiPathNodesByPath.size())
return;
TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path];
pathnodes.Resize(nodeList.size());
mapIds.resize(nodeList.size());
for (size_t i = 0; i < nodeList.size(); ++i)
{
pathnodes[i].x = nodeList[i]->x;
pathnodes[i].y = nodeList[i]->y;
pathnodes[i].z = nodeList[i]->z;
mapIds[i] = nodeList[i]->mapid;
}
}
void ObjectMgr::LoadGraveyardZones()
{
mGraveYardMap.clear(); // need for reload case
-4
View File
@@ -30,7 +30,6 @@
#include "GameObject.h"
#include "Corpse.h"
#include "QuestDef.h"
#include "Path.h"
#include "ItemPrototype.h"
#include "NPCHandler.h"
#include "DatabaseEnv.h"
@@ -60,8 +59,6 @@ extern SQLStorage sInstanceTemplate;
class Group;
class Guild;
class ArenaTeam;
class Path;
class TransportPath;
class Item;
struct GameTele
@@ -473,7 +470,6 @@ class ObjectMgr
uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, uint32 team);
void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost);
uint32 GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team = false);
void GetTaxiPathNodes(uint32 path, Path &pathnodes, std::vector<uint32>& mapIds);
Quest const* GetQuestTemplate(uint32 quest_id) const
{
+11 -3
View File
@@ -440,9 +440,17 @@ MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (i_owner->GetTypeId() == TYPEID_PLAYER)
{
DEBUG_LOG("Player (GUID: %u) taxi to (Path %u node %u)", i_owner->GetGUIDLow(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(path,pathnode);
Mutate(mgen, MOTION_SLOT_CONTROLLED);
if (path < sTaxiPathNodesByPath.size())
{
DEBUG_LOG("%s taxi to (Path %u node %u)", i_owner->GetName(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path],pathnode);
Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
{
sLog.outError("%s attempt taxi to (not existed Path %u node %u)",
i_owner->GetName(), path, pathnode);
}
}
else
{
@@ -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
+33 -34
View File
@@ -24,65 +24,64 @@
#include "Common.h"
#include <vector>
struct SimplePathNode
{
float x, y, z;
};
template<typename PathElem, typename PathNode = PathElem>
class Path
{
public:
struct PathNode
{
float x,y,z;
};
size_t size() const { return i_nodes.size(); }
bool empty() const { return i_nodes.empty(); }
void resize(unsigned int sz) { i_nodes.resize(sz); }
void clear() { i_nodes.clear(); }
void erase(uint32 idx) { i_nodes.erase(i_nodes.begin()+idx); }
void SetLength(const unsigned int sz)
{
i_nodes.resize(sz);
}
unsigned int Size() const { return i_nodes.size(); }
bool Empty() const { return i_nodes.empty(); }
void Resize(unsigned int sz) { i_nodes.resize(sz); }
void Clear(void) { i_nodes.clear(); }
PathNode const* GetNodes(uint32 start = 0) const { return &i_nodes[start]; }
float GetTotalLength() const { return GetTotalLength(0,Size()); }
float GetTotalLength(uint32 start, uint32 end) const
{
float len = 0, xd, yd, zd;
for (unsigned int idx=start+1; idx < end; ++idx)
float len = 0.0f;
for (uint32 idx=start+1; idx < end; ++idx)
{
xd = i_nodes[ idx ].x - i_nodes[ idx-1 ].x;
yd = i_nodes[ idx ].y - i_nodes[ idx-1 ].y;
zd = i_nodes[ idx ].z - i_nodes[ idx-1 ].z;
PathNode const& node = i_nodes[idx];
PathNode const& prev = i_nodes[idx-1];
float xd = node.x - prev.x;
float yd = node.y - prev.y;
float zd = node.z - prev.z;
len += sqrtf(xd*xd + yd*yd + zd*zd);
}
return len;
}
float GetTotalLength() const { return GetTotalLength(0,size()); }
float GetPassedLength(uint32 curnode, float x, float y, float z)
{
float len = 0, xd, yd, zd;
for (unsigned int idx=1; idx < curnode; ++idx)
{
xd = i_nodes[ idx ].x - i_nodes[ idx-1 ].x;
yd = i_nodes[ idx ].y - i_nodes[ idx-1 ].y;
zd = i_nodes[ idx ].z - i_nodes[ idx-1 ].z;
len += sqrtf(xd*xd + yd*yd + zd*zd);
}
float len = GetTotalLength(0,curnode);
if (curnode > 0)
{
xd = x - i_nodes[curnode-1].x;
yd = y - i_nodes[curnode-1].y;
zd = z - i_nodes[curnode-1].z;
PathNode const& node = i_nodes[curnode-1];
float xd = x - node.x;
float yd = y - node.y;
float zd = z - node.z;
len += sqrtf(xd*xd + yd*yd + zd*zd);
}
return len;
}
PathNode& operator[](const unsigned int idx) { return i_nodes[idx]; }
const PathNode& operator()(const unsigned int idx) const { return i_nodes[idx]; }
PathNode& operator[](size_t idx) { return i_nodes[idx]; }
PathNode const& operator[](size_t idx) const { return i_nodes[idx]; }
void set(size_t idx, PathElem elem) { i_nodes[idx] = elem; }
protected:
std::vector<PathNode> i_nodes;
std::vector<PathElem> i_nodes;
};
typedef Path<SimplePathNode> SimplePath;
#endif
@@ -222,7 +222,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data)
FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
flight->SetCurrentNodeAfterTeleport();
Path::PathNode const& node = flight->GetPath()[flight->GetCurrentNode()];
TaxiPathNodeEntry const& node = flight->GetPath()[flight->GetCurrentNode()];
flight->SkipCurrentNode();
GetPlayer()->TeleportTo(curDestNode->map_id,node.x,node.y,node.z,GetPlayer()->GetOrientation());
@@ -259,6 +259,8 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data)
GetPlayer()->m_taxi.ClearTaxiDestinations(); // clear problematic path and next
return;
}
else
GetPlayer()->m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
GetPlayer()->CleanupAfterTaxiFlight();
GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ());