Pasaeta de cppcheck, ale

This commit is contained in:
2024-10-22 09:24:19 +02:00
parent 1d0c2e01a5
commit 5df85e1b1a
28 changed files with 164 additions and 194 deletions
+13 -16
View File
@@ -13,16 +13,16 @@ void ManageHiScoreTable::clear()
table_.clear();
// Añade 10 entradas predefinidas
table_.push_back({"Bry", 1000000});
table_.push_back({"Usufondo", 500000});
table_.push_back({"G.Lucas", 100000});
table_.push_back({"P.Delgat", 50000});
table_.push_back({"P.Arrabalera", 10000});
table_.push_back({"Pelechano", 5000});
table_.push_back({"Sahuquillo", 1000});
table_.push_back({"Bacteriol", 500});
table_.push_back({"Pepe", 200});
table_.push_back({"Rosita", 100});
table_.push_back(HiScoreEntry("Bry", 1000000));
table_.push_back(HiScoreEntry("Usufondo", 500000));
table_.push_back(HiScoreEntry("G.Lucas", 100000));
table_.push_back(HiScoreEntry("P.Delgat", 50000));
table_.push_back(HiScoreEntry("P.Arrabalera", 10000));
table_.push_back(HiScoreEntry("Pelechano", 5000));
table_.push_back(HiScoreEntry("Sahuquillo", 1000));
table_.push_back(HiScoreEntry("Bacteriol", 500));
table_.push_back(HiScoreEntry("Pepe", 200));
table_.push_back(HiScoreEntry("Rosita", 100));
}
// Añade un elemento a la tabla
@@ -61,8 +61,7 @@ bool ManageHiScoreTable::loadFromFile(const std::string &file_path)
if (file)
{
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
std::cout << "Reading file: " << file_name << std::endl;
std::cout << "Reading file: " << getFileName(file_path) << std::endl;
for (auto &entry : table_)
{
@@ -105,7 +104,6 @@ bool ManageHiScoreTable::loadFromFile(const std::string &file_path)
// Guarda la tabla en un fichero
bool ManageHiScoreTable::saveToFile(const std::string &file_path)
{
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
auto success = true;
auto file = SDL_RWFromFile(file_path.c_str(), "w+b");
@@ -120,13 +118,12 @@ bool ManageHiScoreTable::saveToFile(const std::string &file_path)
SDL_RWwrite(file, table_.at(i).name.c_str(), nameSize, 1);
}
std::cout << "Writing file: " << file_name.c_str() << std::endl;
// Cierra el fichero
std::cout << "Writing file: " << getFileName(file_path).c_str() << std::endl;
SDL_RWclose(file);
}
else
{
std::cout << "Error: Unable to save " << file_name.c_str() << " file! " << SDL_GetError() << std::endl;
std::cout << "Error: Unable to save " << getFileName(file_path).c_str() << " file! " << SDL_GetError() << std::endl;
}
return success;
}