mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-20 20:23:03 +02:00
Quick workaround for xbrz terrain animations bug
This commit is contained in:
parent
7cc9aeaa41
commit
19e6a83c19
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "../renderSDL/SDL_Extensions.h"
|
#include "../renderSDL/SDL_Extensions.h"
|
||||||
|
|
||||||
|
#include "../lib/ExceptionsCommon.h"
|
||||||
#include "../lib/filesystem/Filesystem.h"
|
#include "../lib/filesystem/Filesystem.h"
|
||||||
#include "../lib/vcmi_endian.h"
|
#include "../lib/vcmi_endian.h"
|
||||||
|
|
||||||
@ -112,40 +113,47 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(const ImagePath & path)
|
|||||||
|
|
||||||
SDL_Surface * ret=nullptr;
|
SDL_Surface * ret=nullptr;
|
||||||
|
|
||||||
auto readFile = CResourceHandler::get()->load(path)->readAll();
|
try {
|
||||||
|
auto readFile = CResourceHandler::get()->load(path)->readAll();
|
||||||
|
|
||||||
if (isPCX(readFile.first.get()))
|
if (isPCX(readFile.first.get()))
|
||||||
{//H3-style PCX
|
{//H3-style PCX
|
||||||
ret = loadH3PCX(readFile.first.get(), readFile.second);
|
ret = loadH3PCX(readFile.first.get(), readFile.second);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
|
||||||
logGlobal->error("Failed to open %s as H3 PCX!", path.getOriginalName());
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ //loading via SDL_Image
|
|
||||||
ret = IMG_Load_RW(
|
|
||||||
//create SDL_RW with our data (will be deleted by SDL)
|
|
||||||
SDL_RWFromConstMem((void*)readFile.first.get(), (int)readFile.second),
|
|
||||||
1); // mark it for auto-deleting
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
if (ret->format->palette)
|
|
||||||
{
|
{
|
||||||
// set correct value for alpha\unused channel
|
logGlobal->error("Failed to open %s as H3 PCX!", path.getOriginalName());
|
||||||
// NOTE: might be unnecessary with SDL2
|
return nullptr;
|
||||||
for (int i=0; i < ret->format->palette->ncolors; i++)
|
|
||||||
ret->format->palette->colors[i].a = SDL_ALPHA_OPAQUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ //loading via SDL_Image
|
||||||
logGlobal->error("Failed to open %s via SDL_Image", path.getOriginalName());
|
ret = IMG_Load_RW(
|
||||||
logGlobal->error("Reason: %s", IMG_GetError());
|
//create SDL_RW with our data (will be deleted by SDL)
|
||||||
return nullptr;
|
SDL_RWFromConstMem((void*)readFile.first.get(), (int)readFile.second),
|
||||||
|
1); // mark it for auto-deleting
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
if (ret->format->palette)
|
||||||
|
{
|
||||||
|
// set correct value for alpha\unused channel
|
||||||
|
// NOTE: might be unnecessary with SDL2
|
||||||
|
for (int i=0; i < ret->format->palette->ncolors; i++)
|
||||||
|
ret->format->palette->colors[i].a = SDL_ALPHA_OPAQUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logGlobal->error("Failed to open %s via SDL_Image", path.getOriginalName());
|
||||||
|
logGlobal->error("Reason: %s", IMG_GetError());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (const DataLoadingException & e)
|
||||||
|
{
|
||||||
|
logGlobal->error("%s", e.what());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// When modifying anything here please check two use cases:
|
// When modifying anything here please check two use cases:
|
||||||
// 1) Vampire mansion in Necropolis (not 1st color is transparent)
|
// 1) Vampire mansion in Necropolis (not 1st color is transparent)
|
||||||
|
Loading…
Reference in New Issue
Block a user