mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9808] Simplify TaxiPathNodes data use, specially for transport case.
This commit is contained in:
parent
de3192b2f5
commit
4910add486
8 changed files with 29 additions and 92 deletions
|
|
@ -150,7 +150,7 @@ TaxiMask sOldContinentsNodesMask;
|
|||
TaxiPathSetBySource sTaxiPathSetBySource;
|
||||
DBCStorage <TaxiPathEntry> sTaxiPathStore(TaxiPathEntryfmt);
|
||||
|
||||
// DBC used only for initialization sTaxiPathNodeStore at startup.
|
||||
// DBC store data but sTaxiPathNodesByPath used for fast access to entries (it's not owner pointed data).
|
||||
TaxiPathNodesByPath sTaxiPathNodesByPath;
|
||||
static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt);
|
||||
|
||||
|
|
@ -547,11 +547,10 @@ void LoadDBCStores(const std::string& dataPath)
|
|||
sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used
|
||||
for(uint32 i = 1; i < sTaxiPathNodesByPath.size(); ++i)
|
||||
sTaxiPathNodesByPath[i].resize(pathLength[i]);
|
||||
// fill data
|
||||
// fill data (pointers to sTaxiPathNodeStore elements
|
||||
for(uint32 i = 1; i < sTaxiPathNodeStore.GetNumRows(); ++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);
|
||||
sTaxiPathNodeStore.Clear();
|
||||
sTaxiPathNodesByPath[entry->path][entry->index] = entry;
|
||||
|
||||
// Initialize global taxinodes mask
|
||||
// include existed nodes that have at least single not spell base (scripted) path
|
||||
|
|
|
|||
|
|
@ -1846,19 +1846,7 @@ struct TaxiPathBySourceAndDestination
|
|||
typedef std::map<uint32,TaxiPathBySourceAndDestination> TaxiPathSetForSource;
|
||||
typedef std::map<uint32,TaxiPathSetForSource> TaxiPathSetBySource;
|
||||
|
||||
struct TaxiPathNode
|
||||
{
|
||||
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<TaxiPathNodeEntry const*> TaxiPathNodeList;
|
||||
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
|
||||
|
||||
#define TaxiMaskSize 12
|
||||
|
|
|
|||
|
|
@ -5231,31 +5231,11 @@ void ObjectMgr::GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector<uint
|
|||
|
||||
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;
|
||||
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::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;
|
||||
mapIds[i] = nodeList[i]->mapid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -500,7 +500,6 @@ class ObjectMgr
|
|||
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 );
|
||||
void GetTransportPathNodes( uint32 path, TransportPath &pathnodes );
|
||||
|
||||
Quest const* GetQuestTemplate(uint32 quest_id) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18209,32 +18209,32 @@ 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)
|
||||
if (distNext + distPrev < distNodes)
|
||||
{
|
||||
startNode = i;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -205,22 +205,22 @@ struct keyFrame
|
|||
|
||||
bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||
{
|
||||
TransportPath path;
|
||||
sObjectMgr.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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,35 +25,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:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9807"
|
||||
#define REVISION_NR "9808"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue