From fc0440ff8900aeb71af7ce3bc6d44464e0cca727 Mon Sep 17 00:00:00 2001 From: numzero Date: Sat, 8 Apr 2023 01:23:20 +0300 Subject: [PATCH] Drop IImageLoader::loadImages as only IImageLoader::loadImage is usable --- include/IImageLoader.h | 11 ------ source/Irrlicht/CNullDriver.cpp | 68 +++++++++++---------------------- 2 files changed, 22 insertions(+), 57 deletions(-) diff --git a/include/IImageLoader.h b/include/IImageLoader.h index 13eef97..61552af 100644 --- a/include/IImageLoader.h +++ b/include/IImageLoader.h @@ -45,17 +45,6 @@ public: /** \param file File handle to check. \return Pointer to newly created image, or 0 upon error. */ virtual IImage* loadImage(io::IReadFile* file) const = 0; - - //! Creates a multiple surfaces from the file eg. whole cube map. - /** \param file File handle to check. - \param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored. - \return Array of pointers to newly created images. */ - virtual core::array loadImages(io::IReadFile* file, E_TEXTURE_TYPE* type) const - { - core::array image; - - return image; - } }; diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index a02431c..d3b7280 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1196,57 +1196,33 @@ core::array CNullDriver::createImagesFromFile(io::IReadFile* file, E_TE core::array imageArray; - if (file) - { - s32 i; + if (!file) + return imageArray; - // try to load file based on file extension - for (i = SurfaceLoader.size() - 1; i >= 0; --i) - { - if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) - { - // reset file position which might have changed due to previous loadImage calls - file->seek(0); - imageArray = SurfaceLoader[i]->loadImages(file, type); + // try to load file based on file extension + for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { + if (!SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) + continue; - if (imageArray.size() == 0) - { - file->seek(0); - IImage* image = SurfaceLoader[i]->loadImage(file); - - if (image) - imageArray.push_back(image); - } - - if (imageArray.size() > 0) - return imageArray; - } + file->seek(0); // reset file position which might have changed due to previous loadImage calls + if (IImage *image = SurfaceLoader[i]->loadImage(file)) { + imageArray.push_back(image); + return imageArray; } + } - // try to load file based on what is in it - for (i = SurfaceLoader.size() - 1; i >= 0; --i) - { - // dito - file->seek(0); - if (SurfaceLoader[i]->isALoadableFileFormat(file) - && !SurfaceLoader[i]->isALoadableFileExtension(file->getFileName()) // extension was tried above already - ) - { - file->seek(0); - imageArray = SurfaceLoader[i]->loadImages(file, type); + // try to load file based on what is in it + for (int i = SurfaceLoader.size() - 1; i >= 0; --i) { + if (SurfaceLoader[i]->isALoadableFileExtension(file->getFileName())) + continue; // extension was tried above already + file->seek(0); // dito + if (!SurfaceLoader[i]->isALoadableFileFormat(file)) + continue; - if (imageArray.size() == 0) - { - file->seek(0); - IImage* image = SurfaceLoader[i]->loadImage(file); - - if (image) - imageArray.push_back(image); - } - - if (imageArray.size() > 0) - return imageArray; - } + file->seek(0); + if (IImage *image = SurfaceLoader[i]->loadImage(file)) { + imageArray.push_back(image); + return imageArray; } }