From cdc8b0cd97da2762b8c97565b19ca2e58d10526b Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Sun, 21 Apr 2024 23:52:20 +0200 Subject: [PATCH] Fixed build --- Sources/nCine/Audio/AudioLoaderWav.cpp | 4 +-- Sources/nCine/Graphics/TextureLoaderPkm.cpp | 35 +++++++++------------ Sources/nCine/Graphics/TextureLoaderQoi.cpp | 2 +- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/Sources/nCine/Audio/AudioLoaderWav.cpp b/Sources/nCine/Audio/AudioLoaderWav.cpp index 2b825ca9..f058ec2e 100644 --- a/Sources/nCine/Audio/AudioLoaderWav.cpp +++ b/Sources/nCine/Audio/AudioLoaderWav.cpp @@ -16,8 +16,8 @@ namespace nCine WavHeader header; fileHandle_->Read(&header, sizeof(WavHeader)); - RETURN_ASSERT_MSG(strncmp(header.chunkId, "RIFF", 4) == 0 && strncmp(header.format, "WAVE", 4) == 0, "Invalid a WAV file"); - RETURN_ASSERT_MSG(strncmp(header.subchunk1Id, "fmt ", 4) == 0, "Invalid WAV file"); + RETURN_ASSERT_MSG(strncmp(header.chunkId, "RIFF", 4) == 0 && strncmp(header.format, "WAVE", 4) == 0, "Invalid WAV signature"); + RETURN_ASSERT_MSG(strncmp(header.subchunk1Id, "fmt ", 4) == 0, "Invalid WAV signature"); RETURN_ASSERT_MSG(Stream::Uint16FromLE(header.audioFormat) == 1, "Data is not in PCM format"); bytesPerSample_ = Stream::Uint16FromLE(header.bitsPerSample) / 8; diff --git a/Sources/nCine/Graphics/TextureLoaderPkm.cpp b/Sources/nCine/Graphics/TextureLoaderPkm.cpp index 484080c0..554fda7a 100644 --- a/Sources/nCine/Graphics/TextureLoaderPkm.cpp +++ b/Sources/nCine/Graphics/TextureLoaderPkm.cpp @@ -11,31 +11,24 @@ namespace nCine TextureLoaderPkm::TextureLoaderPkm(std::unique_ptr fileHandle) : ITextureLoader(std::move(fileHandle)) { - RETURN_ASSERT_MSG(fileHandle_->IsValid(), "File \"%s\" cannot be opened", fileHandle_->GetPath().data()); + RETURN_ASSERT(fileHandle_->IsValid()); PkmHeader header; - // PKM header is 16 bytes long - fileHandle_->Read(&header, 16); + fileHandle_->Read(&header, 16); // PKM header is 16 bytes long // Checking for the header presence - if (Stream::Uint32FromBE(header.magicId) == 0x504B4D20) // "PKM 10" - { - if (Stream::Uint16FromBE(header.version) != 0x3130) { // "10" - RETURN_MSG("PKM version not supported: 0x%04x", header.version); - } - if (Stream::Uint16FromBE(header.dataType) != 0) { - RETURN_MSG("PKM data type not supported: 0x%04x", header.dataType); - } - - headerSize_ = 16; - width_ = Stream::Uint16FromBE(header.width); - height_ = Stream::Uint16FromBE(header.height); - - const int extWidth = Stream::Uint16FromBE(header.extendedWidth); - const int extHeight = Stream::Uint16FromBE(header.extendedHeight); - - LOGI("Header found: w:%d h:%d, xw:%d xh:%d", width_, height_, extWidth, extHeight); - } + RETURN_ASSERT_MSG(Stream::Uint32FromBE(header.magicId) == 0x504B4D20 /* "PKM 10" */, "Invalid PKM signature"); + RETURN_ASSERT_MSG(Stream::Uint16FromBE(header.version) == 0x3130 /* "10" */, "PKM version not supported: 0x%04x", header.version); + RETURN_ASSERT_MSG(Stream::Uint16FromBE(header.dataType) == 0, "PKM data type not supported: 0x%04x", header.dataType); + + headerSize_ = 16; + width_ = Stream::Uint16FromBE(header.width); + height_ = Stream::Uint16FromBE(header.height); + + const int extWidth = Stream::Uint16FromBE(header.extendedWidth); + const int extHeight = Stream::Uint16FromBE(header.extendedHeight); + + LOGI("Header found: w:%d h:%d, xw:%d xh:%d", width_, height_, extWidth, extHeight); loadPixels(GL_ETC1_RGB8_OES); hasLoaded_ = true; diff --git a/Sources/nCine/Graphics/TextureLoaderQoi.cpp b/Sources/nCine/Graphics/TextureLoaderQoi.cpp index 7b3aac6d..b8ce178f 100644 --- a/Sources/nCine/Graphics/TextureLoaderQoi.cpp +++ b/Sources/nCine/Graphics/TextureLoaderQoi.cpp @@ -14,7 +14,7 @@ namespace nCine TextureLoaderQoi::TextureLoaderQoi(std::unique_ptr fileHandle) : ITextureLoader(std::move(fileHandle)) { - RETURN_ASSERT_MSG(fileHandle_->IsValid(), "File \"%s\" cannot be opened", fileHandle_->GetPath().data()); + RETURN_ASSERT(fileHandle_->IsValid()); auto fileSize = fileHandle_->GetSize(); if (fileSize < QOI_HEADER_SIZE || fileSize > 64 * 1024 * 1024) {