neteja final tidy/cppcheck: const*, static, renames de constants

This commit is contained in:
2026-05-16 19:40:33 +02:00
parent 37cb3c782a
commit 479d9d941a
14 changed files with 272 additions and 337 deletions
+11 -11
View File
@@ -11,8 +11,8 @@
Asset *Asset::instance = nullptr;
// Singleton API
void Asset::init(const std::string &executablePath) {
Asset::instance = new Asset(executablePath);
void Asset::init(const std::string &executable_path) {
Asset::instance = new Asset(executable_path);
}
void Asset::destroy() {
@@ -25,8 +25,8 @@ auto Asset::get() -> Asset * {
}
// Constructor
Asset::Asset(const std::string &executablePath)
: executable_path_(executablePath.substr(0, executablePath.find_last_of("\\/"))) {
Asset::Asset(const std::string &executable_path)
: executable_path_(executable_path.substr(0, executable_path.find_last_of("\\/"))) {
}
// Añade un elemento a la lista
@@ -37,17 +37,17 @@ void Asset::add(const std::string &file, Type type, bool required, bool absolute
temp.required = required;
file_list_.push_back(temp);
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
longest_name_ = SDL_max(longest_name_, filename.size());
const std::string FILE_NAME = file.substr(file.find_last_of("\\/") + 1);
longest_name_ = SDL_max(longest_name_, FILE_NAME.size());
}
// Devuelve el fichero de un elemento de la lista a partir de una cadena
auto Asset::get(const std::string &text) -> std::string {
for (const auto &f : file_list_) {
const size_t lastIndex = f.file.find_last_of('/') + 1;
const std::string file = f.file.substr(lastIndex);
const size_t LAST_INDEX = f.file.find_last_of('/') + 1;
const std::string FILE_NAME = f.file.substr(LAST_INDEX);
if (file == text) {
if (FILE_NAME == text) {
return f.file;
}
}
@@ -116,7 +116,7 @@ auto Asset::checkFile(const std::string &path) const -> bool {
std::string result = "ERROR";
// Comprueba si existe el fichero (pack o filesystem)
const std::string filename = path.substr(path.find_last_of("\\/") + 1);
const std::string FILE_NAME = path.substr(path.find_last_of("\\/") + 1);
if (ResourceHelper::shouldUseResourcePack(path)) {
auto bytes = ResourceHelper::loadFile(path);
if (!bytes.empty()) {
@@ -137,7 +137,7 @@ auto Asset::checkFile(const std::string &path) const -> bool {
std::cout << "Checking file: ";
std::cout.width(longest_name_ + 2);
std::cout.fill('.');
std::cout << filename + " ";
std::cout << FILE_NAME + " ";
std::cout << " [" + result + "]" << '\n';
}