Acabat amb cppcheck
Arreglades les herencies de les classes Sprite
This commit is contained in:
@@ -56,13 +56,13 @@ Texture::~Texture()
|
||||
// Carga una imagen desde un fichero
|
||||
bool Texture::loadFromFile(const std::string &path)
|
||||
{
|
||||
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
|
||||
int req_format = STBI_rgb_alpha;
|
||||
int width, height, orig_format;
|
||||
unsigned char *data = stbi_load(path.c_str(), &width, &height, &orig_format, req_format);
|
||||
if (!data)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
|
||||
std::cout << "Loading image failed: " << stbi_failure_reason() << std::endl;
|
||||
#endif
|
||||
exit(1);
|
||||
@@ -70,6 +70,7 @@ bool Texture::loadFromFile(const std::string &path)
|
||||
else
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
const std::string file_name = path.substr(path.find_last_of("\\/") + 1);
|
||||
std::cout << "Image loaded: " << file_name << std::endl;
|
||||
#endif
|
||||
}
|
||||
@@ -96,7 +97,7 @@ bool Texture::loadFromFile(const std::string &path)
|
||||
SDL_Texture *newTexture = nullptr;
|
||||
|
||||
// Carga la imagen desde una ruta específica
|
||||
auto loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom(static_cast<void*>(data), width, height, depth, pitch, pixel_format);
|
||||
auto loadedSurface = SDL_CreateRGBSurfaceWithFormatFrom(static_cast<void *>(data), width, height, depth, pitch, pixel_format);
|
||||
if (loadedSurface == nullptr)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
@@ -137,9 +138,9 @@ bool Texture::createBlank(int width, int height, SDL_PixelFormatEnum format, SDL
|
||||
texture_ = SDL_CreateTexture(renderer_, format, access, width, height);
|
||||
if (!texture_)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Unable to create blank texture! SDL Error: " << SDL_GetError() << std::endl;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -312,7 +313,7 @@ void Texture::flipSurface()
|
||||
// Vuelca los datos
|
||||
Uint32 *pixels;
|
||||
int pitch;
|
||||
SDL_LockTexture(texture_, nullptr, reinterpret_cast<void**>(&pixels), &pitch);
|
||||
SDL_LockTexture(texture_, nullptr, reinterpret_cast<void **>(&pixels), &pitch);
|
||||
for (int i = 0; i < width_ * height_; ++i)
|
||||
{
|
||||
pixels[i] = palettes_[paletteIndex_][surface_->data[i]];
|
||||
@@ -344,7 +345,7 @@ std::vector<Uint32> Texture::loadPal(const std::string &file_name)
|
||||
fread(buffer, size, 1, f);
|
||||
fclose(f);
|
||||
|
||||
auto pal = LoadPalette(buffer);
|
||||
const auto pal = LoadPalette(buffer);
|
||||
if (!pal)
|
||||
{
|
||||
return palette;
|
||||
@@ -361,9 +362,9 @@ std::vector<Uint32> Texture::loadPal(const std::string &file_name)
|
||||
}
|
||||
|
||||
// Añade una paleta a la lista
|
||||
void Texture::addPalette(std::string path)
|
||||
void Texture::addPalette(const std::string &path)
|
||||
{
|
||||
palettes_.push_back(loadPal(path.c_str()));
|
||||
palettes_.push_back(loadPal(path));
|
||||
setPaletteColor((int)palettes_.size() - 1, 0, 0x00000000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user