Simplify and cleanup Transport system. Author: Vladimir.
--HG-- branch : trunk
This commit is contained in:
@@ -506,8 +506,7 @@ void LoadDBCStores(const std::string& dataPath)
|
|||||||
// fill data
|
// fill data
|
||||||
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
|
for (uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++i)
|
||||||
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
|
if (TaxiPathNodeEntry const* entry = sTaxiPathNodeStore.LookupEntry(i))
|
||||||
sTaxiPathNodesByPath[entry->path][entry->index] = TaxiPathNode(entry->mapid,entry->x,entry->y,entry->z,entry->actionFlag,entry->delay);
|
sTaxiPathNodesByPath[entry->path][entry->index] = entry;
|
||||||
sTaxiPathNodeStore.Clear();
|
|
||||||
|
|
||||||
// Initialize global taxinodes mask
|
// Initialize global taxinodes mask
|
||||||
// include existed nodes that have at least single not spell base (scripted) path
|
// include existed nodes that have at least single not spell base (scripted) path
|
||||||
|
|||||||
@@ -1911,19 +1911,7 @@ struct TaxiPathBySourceAndDestination
|
|||||||
typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
|
typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
|
||||||
typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
|
typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
|
||||||
|
|
||||||
struct TaxiPathNode
|
typedef std::vector<TaxiPathNodeEntry const*> TaxiPathNodeList;
|
||||||
{
|
|
||||||
TaxiPathNode() : mapid(0), x(0),y(0),z(0),actionFlag(0),delay(0) {}
|
|
||||||
TaxiPathNode(uint32 _mapid, float _x, float _y, float _z, uint32 _actionFlag, uint32 _delay) : mapid(_mapid), x(_x),y(_y),z(_z),actionFlag(_actionFlag),delay(_delay) {}
|
|
||||||
|
|
||||||
uint32 mapid;
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
uint32 actionFlag;
|
|
||||||
uint32 delay;
|
|
||||||
};
|
|
||||||
typedef std::vector<TaxiPathNode> TaxiPathNodeList;
|
|
||||||
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
|
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
|
||||||
|
|
||||||
#define TaxiMaskSize 12
|
#define TaxiMaskSize 12
|
||||||
|
|||||||
@@ -19362,30 +19362,30 @@ void Player::ContinueTaxiFlight()
|
|||||||
|
|
||||||
float distPrev = MAP_SIZE*MAP_SIZE;
|
float distPrev = MAP_SIZE*MAP_SIZE;
|
||||||
float distNext =
|
float distNext =
|
||||||
(nodeList[0].x-GetPositionX())*(nodeList[0].x-GetPositionX())+
|
(nodeList[0]->x-GetPositionX())*(nodeList[0]->x-GetPositionX())+
|
||||||
(nodeList[0].y-GetPositionY())*(nodeList[0].y-GetPositionY())+
|
(nodeList[0]->y-GetPositionY())*(nodeList[0]->y-GetPositionY())+
|
||||||
(nodeList[0].z-GetPositionZ())*(nodeList[0].z-GetPositionZ());
|
(nodeList[0]->z-GetPositionZ())*(nodeList[0]->z-GetPositionZ());
|
||||||
|
|
||||||
for (uint32 i = 1; i < nodeList.size(); ++i)
|
for (uint32 i = 1; i < nodeList.size(); ++i)
|
||||||
{
|
{
|
||||||
TaxiPathNode const& node = nodeList[i];
|
TaxiPathNodeEntry const* node = nodeList[i];
|
||||||
TaxiPathNode const& prevNode = nodeList[i-1];
|
TaxiPathNodeEntry const* prevNode = nodeList[i-1];
|
||||||
|
|
||||||
// skip nodes at another map
|
// skip nodes at another map
|
||||||
if (node.mapid != GetMapId())
|
if (node->mapid != GetMapId())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
distPrev = distNext;
|
distPrev = distNext;
|
||||||
|
|
||||||
distNext =
|
distNext =
|
||||||
(node.x-GetPositionX())*(node.x-GetPositionX())+
|
(node->x-GetPositionX())*(node->x-GetPositionX())+
|
||||||
(node.y-GetPositionY())*(node.y-GetPositionY())+
|
(node->y-GetPositionY())*(node->y-GetPositionY())+
|
||||||
(node.z-GetPositionZ())*(node.z-GetPositionZ());
|
(node->z-GetPositionZ())*(node->z-GetPositionZ());
|
||||||
|
|
||||||
float distNodes =
|
float distNodes =
|
||||||
(node.x-prevNode.x)*(node.x-prevNode.x)+
|
(node->x-prevNode->x)*(node->x-prevNode->x)+
|
||||||
(node.y-prevNode.y)*(node.y-prevNode.y)+
|
(node->y-prevNode->y)*(node->y-prevNode->y)+
|
||||||
(node.z-prevNode.z)*(node.z-prevNode.z);
|
(node->z-prevNode->z)*(node->z-prevNode->z);
|
||||||
|
|
||||||
if (distNext + distPrev < distNodes)
|
if (distNext + distPrev < distNodes)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -205,22 +205,22 @@ struct keyFrame
|
|||||||
|
|
||||||
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||||
{
|
{
|
||||||
TransportPath path;
|
if (pathid >= sTaxiPathNodesByPath.size())
|
||||||
objmgr.GetTransportPathNodes(pathid, path);
|
|
||||||
|
|
||||||
if (path.Empty())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid];
|
||||||
|
|
||||||
std::vector<keyFrame> keyFrames;
|
std::vector<keyFrame> keyFrames;
|
||||||
int mapChange = 0;
|
int mapChange = 0;
|
||||||
mapids.clear();
|
mapids.clear();
|
||||||
for (size_t i = 1; i < path.Size() - 1; ++i)
|
for (size_t i = 1; i < path.size() - 1; ++i)
|
||||||
{
|
{
|
||||||
if (mapChange == 0)
|
if (mapChange == 0)
|
||||||
{
|
{
|
||||||
if ((path[i].mapid == path[i+1].mapid))
|
TaxiPathNodeEntry const* node_i = path[i];
|
||||||
|
if (node_i->mapid == path[i+1]->mapid)
|
||||||
{
|
{
|
||||||
keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[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);
|
keyFrames.push_back(k);
|
||||||
mapids.insert(k.mapid);
|
mapids.insert(k.mapid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,35 +27,6 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class TransportPath
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct PathNode
|
|
||||||
{
|
|
||||||
uint32 mapid;
|
|
||||||
float x,y,z;
|
|
||||||
uint32 actionFlag;
|
|
||||||
uint32 delay;
|
|
||||||
};
|
|
||||||
|
|
||||||
void SetLength(const unsigned int sz)
|
|
||||||
{
|
|
||||||
i_nodes.resize(sz);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Size(void) const { return i_nodes.size(); }
|
|
||||||
bool Empty(void) const { return i_nodes.empty(); }
|
|
||||||
void Resize(unsigned int sz) { i_nodes.resize(sz); }
|
|
||||||
void Clear(void) { i_nodes.clear(); }
|
|
||||||
PathNode* GetNodes(void) { return static_cast<PathNode *>(&i_nodes[0]); }
|
|
||||||
|
|
||||||
PathNode& operator[](const unsigned int idx) { return i_nodes[idx]; }
|
|
||||||
const PathNode& operator()(const unsigned int idx) const { return i_nodes[idx]; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<PathNode> i_nodes;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Transport : public GameObject
|
class Transport : public GameObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -5494,31 +5494,10 @@ void ObjectMgr::GetTaxiPathNodes(uint32 path, Path &pathnodes, std::vector<uint3
|
|||||||
|
|
||||||
for (size_t i = 0; i < nodeList.size(); ++i)
|
for (size_t i = 0; i < nodeList.size(); ++i)
|
||||||
{
|
{
|
||||||
pathnodes[ i ].x = nodeList[i].x;
|
pathnodes[i].x = nodeList[i]->x;
|
||||||
pathnodes[ i ].y = nodeList[i].y;
|
pathnodes[i].y = nodeList[i]->y;
|
||||||
pathnodes[ i ].z = nodeList[i].z;
|
pathnodes[i].z = nodeList[i]->z;
|
||||||
|
mapIds[i] = nodeList[i]->mapid;
|
||||||
mapIds[i] = nodeList[i].mapid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectMgr::GetTransportPathNodes(uint32 path, TransportPath &pathnodes)
|
|
||||||
{
|
|
||||||
if (path >= sTaxiPathNodesByPath.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path];
|
|
||||||
|
|
||||||
pathnodes.Resize(nodeList.size());
|
|
||||||
|
|
||||||
for (size_t i = 0; i < nodeList.size(); ++i)
|
|
||||||
{
|
|
||||||
pathnodes[ i ].mapid = nodeList[i].mapid;
|
|
||||||
pathnodes[ i ].x = nodeList[i].x;
|
|
||||||
pathnodes[ i ].y = nodeList[i].y;
|
|
||||||
pathnodes[ i ].z = nodeList[i].z;
|
|
||||||
pathnodes[ i ].actionFlag = nodeList[i].actionFlag;
|
|
||||||
pathnodes[ i ].delay = nodeList[i].delay;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -474,7 +474,6 @@ class ObjectMgr
|
|||||||
void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost);
|
void GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uint32 &cost);
|
||||||
uint32 GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team = false);
|
uint32 GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team = false);
|
||||||
void GetTaxiPathNodes(uint32 path, Path &pathnodes, std::vector<uint32>& mapIds);
|
void GetTaxiPathNodes(uint32 path, Path &pathnodes, std::vector<uint32>& mapIds);
|
||||||
void GetTransportPathNodes(uint32 path, TransportPath &pathnodes);
|
|
||||||
|
|
||||||
Quest const* GetQuestTemplate(uint32 quest_id) const
|
Quest const* GetQuestTemplate(uint32 quest_id) const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user