treball en curs: correccions de tidy

This commit is contained in:
2026-05-16 17:19:40 +02:00
parent 3421f34a84
commit ee2dd0bc2c
30 changed files with 1220 additions and 1479 deletions
+35 -61
View File
@@ -26,24 +26,24 @@ auto Asset::get() -> Asset * {
// Constructor
Asset::Asset(const std::string &executablePath)
: executablePath(executablePath.substr(0, executablePath.find_last_of("\\/"))) {
: executable_path_(executablePath.substr(0, executablePath.find_last_of("\\/"))) {
}
// Añade un elemento a la lista
void Asset::add(const std::string &file, enum AssetType type, bool required, bool absolute) {
void Asset::add(const std::string &file, Type type, bool required, bool absolute) {
Item temp;
temp.file = absolute ? file : executablePath + file;
temp.file = absolute ? file : executable_path_ + file;
temp.type = type;
temp.required = required;
fileList.push_back(temp);
file_list_.push_back(temp);
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
longestName = SDL_max(longestName, filename.size());
longest_name_ = SDL_max(longest_name_, filename.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 : fileList) {
for (const auto &f : file_list_) {
const size_t lastIndex = f.file.find_last_of('/') + 1;
const std::string file = f.file.substr(lastIndex);
@@ -52,7 +52,7 @@ auto Asset::get(const std::string &text) -> std::string {
}
}
if (verbose) {
if (verbose_) {
std::cout << "Warning: file " << text.c_str() << " not found" << '\n';
}
return "";
@@ -62,32 +62,34 @@ auto Asset::get(const std::string &text) -> std::string {
auto Asset::check() -> bool {
bool success = true;
if (verbose) {
if (verbose_) {
std::cout << "\n** Checking files" << '\n';
std::cout << "Executable path is: " << executablePath << '\n';
std::cout << "Sample filepath: " << fileList.back().file << '\n';
std::cout << "Executable path is: " << executable_path_ << '\n';
std::cout << "Sample filepath: " << file_list_.back().file << '\n';
}
// Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < t_maxAssetType; ++type) {
for (int i = 0; i < static_cast<int>(Type::COUNT); ++i) {
const Type TYPE = static_cast<Type>(i);
// Comprueba si hay ficheros de ese tipo
bool any = false;
for (const auto &f : fileList) {
if ((f.required) && (f.type == type)) {
for (const auto &f : file_list_) {
if (f.required && f.type == TYPE) {
any = true;
}
}
// Si hay ficheros de ese tipo, comprueba si existen
if (any) {
if (verbose) {
std::cout << "\n>> " << getTypeName(type).c_str() << " FILES" << '\n';
if (verbose_) {
std::cout << "\n>> " << getTypeName(TYPE).c_str() << " FILES" << '\n';
}
for (const auto &f : fileList) {
if ((f.required) && (f.type == type)) {
for (const auto &f : file_list_) {
if (f.required && f.type == TYPE) {
success &= checkFile(f.file);
}
}
@@ -95,7 +97,7 @@ auto Asset::check() -> bool {
}
// Resultado
if (verbose) {
if (verbose_) {
if (success) {
std::cout << "\n** All files OK.\n"
<< '\n';
@@ -130,10 +132,10 @@ auto Asset::checkFile(const std::string &path) const -> bool {
}
}
if (verbose) {
if (verbose_) {
std::cout.setf(std::ios::left, std::ios::adjustfield);
std::cout << "Checking file: ";
std::cout.width(longestName + 2);
std::cout.width(longest_name_ + 2);
std::cout.fill('.');
std::cout << filename + " ";
std::cout << " [" + result + "]" << '\n';
@@ -143,51 +145,23 @@ auto Asset::checkFile(const std::string &path) const -> bool {
}
// Devuelve el nombre del tipo de recurso
auto Asset::getTypeName(int type) -> std::string {
auto Asset::getTypeName(Type type) -> std::string {
switch (type) {
case t_bitmap:
return "BITMAP";
break;
case t_music:
return "MUSIC";
break;
case t_sound:
return "SOUND";
break;
case t_font:
return "FONT";
break;
case t_lang:
return "LANG";
break;
case t_data:
return "DATA";
break;
case t_room:
return "ROOM";
break;
case t_enemy:
return "ENEMY";
break;
case t_item:
return "ITEM";
break;
default:
return "ERROR";
break;
case Type::BITMAP: return "BITMAP";
case Type::MUSIC: return "MUSIC";
case Type::SOUND: return "SOUND";
case Type::FONT: return "FONT";
case Type::LANG: return "LANG";
case Type::DATA: return "DATA";
case Type::ROOM: return "ROOM";
case Type::ENEMY: return "ENEMY";
case Type::ITEM: return "ITEM";
case Type::COUNT:
default: return "ERROR";
}
}
// Establece si ha de mostrar texto por pantalla
void Asset::setVerbose(bool value) {
verbose = value;
verbose_ = value;
}