Simplify and cleanup Transport system. Author: Vladimir.
--HG-- branch : trunk
This commit is contained in:
@@ -19362,30 +19362,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)
|
||||
{
|
||||
TaxiPathNode const& node = nodeList[i];
|
||||
TaxiPathNode 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)
|
||||
{
|
||||
|
||||
@@ -205,22 +205,22 @@ struct keyFrame
|
||||
|
||||
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||
{
|
||||
TransportPath path;
|
||||
objmgr.GetTransportPathNodes(pathid, path);
|
||||
|
||||
if (path.Empty())
|
||||
if (pathid >= sTaxiPathNodesByPath.size())
|
||||
return false;
|
||||
|
||||
TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid];
|
||||
|
||||
std::vector<keyFrame> keyFrames;
|
||||
int mapChange = 0;
|
||||
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 ((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);
|
||||
mapids.insert(k.mapid);
|
||||
}
|
||||
|
||||
@@ -27,35 +27,6 @@
|
||||
#include <set>
|
||||
#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
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user