diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index ecaec64e8..30863e55b 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -150,7 +150,7 @@ TaxiMask sOldContinentsNodesMask; TaxiPathSetBySource sTaxiPathSetBySource; DBCStorage 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 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 diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 5d9fae3ea..396877a45 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1846,19 +1846,7 @@ struct TaxiPathBySourceAndDestination typedef std::map TaxiPathSetForSource; typedef std::map 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 TaxiPathNodeList; +typedef std::vector TaxiPathNodeList; typedef std::vector TaxiPathNodesByPath; #define TaxiMaskSize 12 diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index fd0895a81..7954f5213 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -5231,31 +5231,11 @@ void ObjectMgr::GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vectorx; + 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; } } diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 25697dbec..cda993847 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -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& mapIds ); - void GetTransportPathNodes( uint32 path, TransportPath &pathnodes ); Quest const* GetQuestTemplate(uint32 quest_id) const { diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 49168816b..0c19cb074 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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; diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 164dbd27b..ca6f16c32 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -205,22 +205,22 @@ struct keyFrame bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) { - TransportPath path; - sObjectMgr.GetTransportPathNodes(pathid, path); - - if (path.Empty()) + if (pathid >= sTaxiPathNodesByPath.size()) return false; + TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid]; + std::vector 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); } diff --git a/src/game/Transports.h b/src/game/Transports.h index c2ecfec71..8925bd0e7 100644 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -25,35 +25,6 @@ #include #include -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(&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 i_nodes; -}; - class Transport : public GameObject { public: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index fa4e6401b..d3fb2fcc5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9807" + #define REVISION_NR "9808" #endif // __REVISION_NR_H__