Fix: Corrected loop conditions in IPAK loading

This commit fixes a potential off-by-one error in the IPAK loading logic. The loop conditions in the `LoadFile_IPAK` function were incorrect, leading to incorrect handling of data chunks. The loop conditions have been corrected to ensure that all data chunks are processed correctly.
This commit is contained in:
njohnson 2025-09-10 21:54:53 -04:00
parent 87bbe47e7e
commit b8c7bdb1ba

View File

@ -789,7 +789,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
QVector<IPAKIndexEntry> entries = QVector<IPAKIndexEntry>();
QVector<IPAKSection> sections = QVector<IPAKSection>(header.sectionCount);
for (uint i = 0; i < header.sectionCount; i++) {
for (quint32 i = 0; i < header.sectionCount; i++) {
IPAKSection currentSection;
stream >> currentSection;
sections << currentSection;
@ -811,7 +811,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
<< " - Count: " << chunkHeader.count << "\n"
<< " - Offset: " << chunkHeader.offset;
for (uint j = 0; j < 31; j++) {
for (quint32 j = 0; j < 31; j++) {
IPAKDataChunkCommand command;
stream >> command;
if (!command.size) { continue; }
@ -821,7 +821,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
<< " - Compressed: " << command.compressed;
}
for (uint j = 0; j < chunkHeader.count; j++) {
for (quint32 j = 0; j < chunkHeader.count; j++) {
auto command = chunkHeader.commands[j];
qDebug() << "Reading from " << stream.device()->pos();
@ -846,7 +846,7 @@ int MainWindow::LoadFile_IPAK(const QString aFilePath) {
stream.skipRawData(sizeof(quint32) * (31 - chunkHeader.count));
qDebug() << stream.device()->pos();
} else if (sectionType == "Index") {
for (uint j = 0; j < currentSection.itemCount; j++) {
for (quint32 j = 0; j < currentSection.itemCount; j++) {
IPAKIndexEntry entry;
stream >> entry;