Continue arreglant cosetes amb cppcheck
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include "asset.h"
|
||||
#include "utils.h"
|
||||
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_RWops
|
||||
#include <SDL2/SDL_stdinc.h> // for SDL_max
|
||||
#include <stddef.h> // for size_t
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_RWops
|
||||
#include <SDL2/SDL_stdinc.h> // para SDL_max
|
||||
#include <stddef.h> // para size_t
|
||||
#include <iostream> // para basic_ostream, operator<<, cout, endl
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <algorithm> // Para std::find_if
|
||||
|
||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||
Asset *Asset::asset_ = nullptr;
|
||||
@@ -38,16 +39,21 @@ void Asset::add(const std::string &file, AssetType type, bool required, bool abs
|
||||
// Devuelve la ruta completa a un fichero a partir de una cadena
|
||||
std::string Asset::get(const std::string &text) const
|
||||
{
|
||||
for (const auto &f : file_list_)
|
||||
{
|
||||
if (getFileName(f.file) == text)
|
||||
{
|
||||
return f.file;
|
||||
}
|
||||
}
|
||||
auto it = std::find_if(file_list_.begin(), file_list_.end(),
|
||||
[&text, this](const auto &f)
|
||||
{
|
||||
return getFileName(f.file) == text;
|
||||
});
|
||||
|
||||
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
|
||||
return "";
|
||||
if (it != file_list_.end())
|
||||
{
|
||||
return it->file;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: file " << text << " not found" << std::endl;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba que existen todos los elementos
|
||||
|
||||
Reference in New Issue
Block a user