XPlor/libs/xassets/xpathdata.cpp

79 lines
1.9 KiB
C++
Raw Permalink Normal View History

2025-08-17 13:14:17 -04:00
#include "xpathdata.h"
XPathData::XPathData()
2025-09-10 21:58:26 -04:00
: XAsset()
{
SetName("Path Data");
2025-08-17 13:14:17 -04:00
}
2025-09-10 21:58:26 -04:00
void XPathData::ParseData(XDataStream *aStream) {
2025-08-17 13:14:17 -04:00
// Parse the PathData structure
if (GetPtr() == -1) {
2025-09-05 18:35:17 -04:00
*aStream >> mNodeCount;
2025-08-17 13:14:17 -04:00
// Clear existing data before parsing new data
mNodes.clear();
mBaseNodes.clear();
mChainNodeForNode.clear();
mNodeForChainNode.clear();
mPathVis.clear();
mNodeTrees.clear();
// Parse nodes
2025-09-07 12:36:08 -04:00
for (quint32 i = 0; i < mNodeCount; ++i) {
2025-08-17 13:14:17 -04:00
XPathNode node;
node.ParseData(aStream);
mNodes.append(node);
}
// Parse base nodes count and array
2025-09-07 12:36:08 -04:00
quint32 baseNodeCount;
2025-09-05 18:35:17 -04:00
*aStream >> baseNodeCount;
2025-09-07 12:36:08 -04:00
for (quint32 i = 0; i < baseNodeCount; ++i) {
2025-08-17 13:14:17 -04:00
XPathBaseNode baseNode;
baseNode.ParseData(aStream);
mBaseNodes.append(baseNode);
}
// Parse chain node count and arrays
2025-09-05 18:35:17 -04:00
*aStream >> mChainNodeCount;
2025-09-10 21:58:26 -04:00
for (quint32 i = 0; i < mChainNodeCount; i++)
2025-09-05 18:35:17 -04:00
{
unsigned short chainNode;
*aStream >> chainNode;
mChainNodeForNode << chainNode;
unsigned short node;
*aStream >> node;
mNodeForChainNode << node;
2025-08-17 13:14:17 -04:00
}
// Parse visBytes and pathVis
2025-09-05 18:35:17 -04:00
*aStream >> mVisBytes;
2025-08-17 13:14:17 -04:00
if (mVisBytes > 0) {
mPathVis.resize(mVisBytes);
2025-09-05 18:35:17 -04:00
aStream->readRawData(mPathVis.data(), mVisBytes);
2025-08-17 13:14:17 -04:00
}
// Parse nodeTreeCount and nodeTrees
2025-09-05 18:35:17 -04:00
aStream->readRawData((char*)&mNodeTreeCount, sizeof(int));
2025-08-17 13:14:17 -04:00
for (int i = 0; i < mNodeTreeCount; ++i) {
XPathNodeTree nodeTree;
nodeTree.ParseData(aStream);
mNodeTrees.append(nodeTree);
}
}
}
2025-09-07 12:36:08 -04:00
quint32 XPathData::GetNodeCount() const {
2025-08-17 13:14:17 -04:00
return mNodeCount;
}
2025-09-07 12:36:08 -04:00
void XPathData::SetNodeCount(quint32 count) {
2025-08-17 13:14:17 -04:00
mNodeCount = count;
}