XPlor/libs/xassets/xaudiopacketaligned.cpp
njohnson 3d378b28c9 Fix: Improve data parsing
This commit updates the data parsing logic within the XAudioPacketAligned class. Specifically, it uses `ParseInt32` and `ParseInt8` instead of direct data stream reading, improving type safety and ensuring correct data handling during parsing.
2025-09-10 21:56:38 -04:00

52 lines
1.1 KiB
C++

#include "xaudiopacketaligned.h"
XAudioPacketAligned::XAudioPacketAligned()
: XAsset()
, mBuffer()
, mBufferSize(0)
, mLoopCount(0)
, aXmaLoop()
, mContext()
{
SetName("Audio Packet Aligned");
}
XAudioPacketAligned::~XAudioPacketAligned()
{
}
void XAudioPacketAligned::ParseData(XDataStream *aStream)
{
qint32 bufferPtr = aStream->ParseInt32(QString("%1 buffer ptr").arg(GetName()));
mBufferSize = aStream->ParseUInt32(QString("%1 buffer size").arg(GetName()));
mLoopCount = aStream->ParseUInt32(QString("%1 loop count").arg(GetName()));
for (int i = 0; i < 6; i++)
{
XAudioXmaLoopRegion loop;
loop.ParseData(aStream);
}
qint32 contextPtr = aStream->ParseInt32(QString("%1 context ptr").arg(GetName()));
if (bufferPtr)
{
aStream->readRawData(mBuffer.data(), mBufferSize);
}
if (contextPtr)
{
mContext = aStream->ParseInt8(QString("%1 context").arg(GetName()));
}
}
void XAudioPacketAligned::Clear()
{
mBuffer.clear();
mBufferSize = 0;
mLoopCount = 0;
aXmaLoop.clear();
mContext = '\0';
}