MichalZr6 10 months ago
parent
commit
f4a15a198b

+ 1 - 2
client/render/CDefFile.cpp

@@ -38,8 +38,7 @@ enum class DefType : uint32_t
 
 CDefFile::CDefFile(const AnimationPath & Name):
 	data(nullptr),
-	palette(nullptr),
-	fileName(Name.getName())
+	palette(nullptr)
 {
 	data = CResourceHandler::get()->load(Name)->readAll().first;
 

+ 0 - 2
client/render/CDefFile.h

@@ -43,8 +43,6 @@ public:
 	CDefFile(const AnimationPath & Name);
 	~CDefFile();
 
-	std::string fileName;
-
 	//load frame as SDL_Surface
 	void loadFrame(size_t frame, size_t group, IImageLoader &loader) const;
 	bool hasFrame(size_t frame, size_t group) const;

+ 1 - 1
client/renderSDL/RenderHandler.cpp

@@ -245,7 +245,7 @@ std::shared_ptr<const ISharedImage> RenderHandler::loadImageFromFileUncached(con
 		return std::make_shared<SDLImageShared>(*locator.image, locator.preScaledFactor);
 	}
 
-	if (locator.defFile)
+	if(locator.defFile)
 	{
 		auto defFile = getAnimationFile(*locator.defFile);
 		int preScaledFactor = locator.preScaledFactor;

+ 0 - 3
client/renderSDL/SDLImage.cpp

@@ -99,9 +99,6 @@ SDLImageShared::SDLImageShared(const CDefFile * data, size_t frame, size_t group
 	SDLImageLoader loader(this);
 	data->loadFrame(frame, group, loader);
 
-	if(surf == nullptr)
-		return;
-
 	savePalette();
 }
 

+ 1 - 16
client/renderSDL/SDLImage.h

@@ -11,7 +11,6 @@
 
 #include "../render/IImage.h"
 #include "../../lib/Point.h"
-#include <SDL_surface.h>
 
 VCMI_LIB_NAMESPACE_BEGIN
 class JsonNode;
@@ -25,7 +24,7 @@ struct SDL_Palette;
 /*
  * Wrapper around SDL_Surface
  */
-class SDLImageShared : public ISharedImage, public std::enable_shared_from_this<SDLImageShared>, boost::noncopyable
+class SDLImageShared final : public ISharedImage, public std::enable_shared_from_this<SDLImageShared>, boost::noncopyable
 {
 	//Surface without empty borders
 	SDL_Surface * surf;
@@ -67,20 +66,6 @@ public:
 	friend class SDLImageLoader;
 };
 
-class SDLEmptyImageShared : public SDLImageShared
-{
-public:
-	SDLEmptyImageShared() : SDLImageShared(createDefaultSurface().get()) {}
-
-private:
-	std::shared_ptr<SDL_Surface> createDefaultSurface()
-	{
-		auto surface = SDL_CreateRGBSurface(0, 32, 32, 32, 0, 0, 0, 0);
-		SDL_FillRect(surface, nullptr, SDL_MapRGB(surface->format, 255, 0, 0));
-		return std::shared_ptr<SDL_Surface>(surface, SDL_FreeSurface);
-	}
-};
-
 class SDLImageBase : public IImage, boost::noncopyable
 {
 protected:

+ 3 - 7
client/renderSDL/SDLImageLoader.cpp

@@ -38,7 +38,6 @@ void SDLImageLoader::init(Point SpriteSize, Point Margins, Point FullSize, SDL_C
 	SDL_FreePalette(p);
 
 	SDL_LockSurface(image->surf);
-
 	lineStart = position = (ui8*)image->surf->pixels;
 }
 
@@ -68,11 +67,8 @@ inline void SDLImageLoader::endLine()
 
 SDLImageLoader::~SDLImageLoader()
 {
-	if(image->surf)
-	{
-		SDL_UnlockSurface(image->surf);
-		SDL_SetColorKey(image->surf, SDL_TRUE, 0);
-		//TODO: RLE if compressed and bpp>1
-	}
+	SDL_UnlockSurface(image->surf);
+	SDL_SetColorKey(image->surf, SDL_TRUE, 0);
+	//TODO: RLE if compressed and bpp>1
 }