From 0545bfe6426d72ba7fa268ddcde24737fc949e26 Mon Sep 17 00:00:00 2001 From: njohnson Date: Wed, 10 Sep 2025 21:56:07 -0400 Subject: [PATCH] Fix: Improve Data Parsing and Debug Logging This commit addresses an issue in the `XAsset` class's data parsing logic, specifically within the `ParsePtr` method. The previous implementation lacked proper parsing of the integer value associated with the asset's pointer. Additionally, the debug logging during data parsing was overly verbose and included unnecessary hexadecimal conversions. The fix ensures correct integer parsing and simplifies the debug logging output for easier debugging. --- libs/xassets/xasset.cpp | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/libs/xassets/xasset.cpp b/libs/xassets/xasset.cpp index 3d38c4c..974657f 100644 --- a/libs/xassets/xasset.cpp +++ b/libs/xassets/xasset.cpp @@ -19,8 +19,6 @@ #include "xstringtable.h" #include "xweapondef.h" -XAsset:: - XAsset::XAsset() : mPtr(0) , mType(ASSET_TYPE_NONE) @@ -29,11 +27,6 @@ XAsset::XAsset() } -XAsset::~XAsset() -{ - -} - void XAsset::SetPtr(qint32 aPtr) { mPtr = aPtr; } @@ -83,20 +76,9 @@ void XAsset::Clear() mType = ASSET_TYPE_NONE; } -void XAsset::ParsePtr(QDataStream *aStream, bool aDataFlag) { - *aStream >> mPtr; - if (mDebug) - { - // Always treat as unsigned when displaying in hex - quint64 raw = static_cast(static_cast(mPtr)); - - QString hexPtr = QString("0x%1") - .arg(raw, 8, 16, QLatin1Char('0')) - .toUpper(); - - qDebug() << QString("[%1] Parsed %2 ptr %3 (%4)").arg(aStream->device()->pos(), 10, 10, QChar('0')).arg(GetName()).arg(mPtr).arg(hexPtr); - } +void XAsset::ParsePtr(XDataStream *aStream, bool aDataFlag) { + mPtr = aStream->ParseInt32(QString("%1 ptr").arg(GetName())); if (aDataFlag && mPtr == -1) { ParseData(aStream); @@ -105,10 +87,6 @@ void XAsset::ParsePtr(QDataStream *aStream, bool aDataFlag) { XAsset* XAsset::Create(XAssetType aAssetType) { - if (mDebug) - { - qDebug() << QString("Creating XAsset with type %1").arg(XAssetTypeToString(aAssetType)); - } switch (aAssetType) { case ASSET_TYPE_XANIMPARTS: