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

View File

@@ -1,4 +1,5 @@
#include "utils.h"
#include <filesystem>
#include <iostream>
#include <string>
#include <algorithm> // for min, clamp, find_if_not, transform
@@ -12,16 +13,16 @@ struct JA_Sound_t; // lines 8-8
Overrides overrides = Overrides();
// Colores
const Color bg_color = {0x27, 0x27, 0x36};
const Color no_color = {0xFF, 0xFF, 0xFF};
const Color shdw_txt_color = {0x43, 0x43, 0x4F};
const Color separator_color = {0x0D, 0x1A, 0x2B};
const Color scoreboard_easy_color = {0x4B, 0x69, 0x2F};
const Color scoreboard_normal_color = {0x2E, 0x3F, 0x47};
const Color scoreboard_hard_color = {0x76, 0x42, 0x8A};
const Color flash_color = {0xFF, 0xFF, 0xFF};
const Color fade_color = {0x27, 0x27, 0x36};
const Color orange_color = {0xFF, 0x7A, 0x00};
const Color bg_color = Color(0x27, 0x27, 0x36);
const Color no_color = Color(0xFF, 0xFF, 0xFF);
const Color shdw_txt_color = Color(0x43, 0x43, 0x4F);
const Color separator_color = Color(0x0D, 0x1A, 0x2B);
const Color scoreboard_easy_color = Color(0x4B, 0x69, 0x2F);
const Color scoreboard_normal_color = Color(0x2E, 0x3F, 0x47);
const Color scoreboard_hard_color = Color(0x76, 0x42, 0x8A);
const Color flash_color = Color(0xFF, 0xFF, 0xFF);
const Color fade_color = Color(0x27, 0x27, 0x36);
const Color orange_color = Color(0xFF, 0x7A, 0x00);
// Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2)
@@ -220,8 +221,7 @@ DemoData loadDemoDataFromFile(const std::string &file_path)
}
else
{
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
printWithDots("DemoData : ", file_name, "[ LOADED ]");
printWithDots("DemoData : ", getFileName(file_path), "[ LOADED ]");
// Lee todos los datos del fichero y los deja en el destino
for (int i = 0; i < TOTAL_DEMO_DATA; ++i)
@@ -243,7 +243,6 @@ DemoData loadDemoDataFromFile(const std::string &file_path)
bool saveDemoFile(const std::string &file_path, const DemoData &dd)
{
auto success = true;
const std::string file_name = file_path.substr(file_path.find_last_of("\\/") + 1);
auto file = SDL_RWFromFile(file_path.c_str(), "w+b");
if (file)
@@ -253,24 +252,30 @@ bool saveDemoFile(const std::string &file_path, const DemoData &dd)
{
if (SDL_RWwrite(file, &data, sizeof(DemoKeys), 1) != 1)
{
std::cerr << "Error al escribir el fichero " << file_name << std::endl;
std::cerr << "Error al escribir el fichero " << getFileName(file_path) << std::endl;
success = false;
break;
}
}
if (success)
{
std::cout << "Writing file " << file_name.c_str() << std::endl;
std::cout << "Writing file " << getFileName(file_path).c_str() << std::endl;
}
// Cierra el fichero
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;
success = false;
}
return success;
}
#endif // RECORDING
#endif // RECORDING
// Obtiene el nombre de un fichero a partir de una ruta
std::string getFileName(const std::string &path)
{
return std::filesystem::path(path).filename().string();
}