linter
This commit is contained in:
@@ -19,8 +19,9 @@ Checks:
|
|||||||
- -modernize-avoid-c-arrays,-warnings-as-errors
|
- -modernize-avoid-c-arrays,-warnings-as-errors
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
# Solo incluir archivos de tu código fuente
|
# Solo incluir archivos de tu código fuente (external tiene su propio .clang-tidy)
|
||||||
HeaderFilterRegex: '^source/(sections|ui)/.*'
|
# Excluye jail_audio.hpp del análisis
|
||||||
|
HeaderFilterRegex: '^source/(?!core/audio/jail_audio\.hpp).*'
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
|
|||||||
@@ -171,3 +171,67 @@ endif()
|
|||||||
|
|
||||||
# Especificar la ubicación del ejecutable
|
# Especificar la ubicación del ejecutable
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# --- 5. STATIC ANALYSIS TARGETS ---
|
||||||
|
|
||||||
|
# Buscar herramientas de análisis estático
|
||||||
|
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
|
||||||
|
find_program(CLANG_FORMAT_EXE NAMES clang-format)
|
||||||
|
|
||||||
|
# Recopilar todos los archivos fuente para formateo
|
||||||
|
file(GLOB_RECURSE ALL_SOURCE_FILES
|
||||||
|
"${CMAKE_SOURCE_DIR}/source/*.cpp"
|
||||||
|
"${CMAKE_SOURCE_DIR}/source/*.hpp"
|
||||||
|
"${CMAKE_SOURCE_DIR}/source/*.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Excluir directorio external del análisis
|
||||||
|
list(FILTER ALL_SOURCE_FILES EXCLUDE REGEX ".*/external/.*")
|
||||||
|
|
||||||
|
# Para clang-tidy, también excluir jail_audio.hpp
|
||||||
|
set(CLANG_TIDY_SOURCES ${ALL_SOURCE_FILES})
|
||||||
|
list(FILTER CLANG_TIDY_SOURCES EXCLUDE REGEX ".*jail_audio\\.hpp$")
|
||||||
|
|
||||||
|
# Targets de clang-tidy
|
||||||
|
if(CLANG_TIDY_EXE)
|
||||||
|
add_custom_target(tidy
|
||||||
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
-p ${CMAKE_BINARY_DIR}
|
||||||
|
${CLANG_TIDY_SOURCES}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Running clang-tidy..."
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(tidy-fix
|
||||||
|
COMMAND ${CLANG_TIDY_EXE}
|
||||||
|
-p ${CMAKE_BINARY_DIR}
|
||||||
|
--fix
|
||||||
|
${CLANG_TIDY_SOURCES}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Running clang-tidy with fixes..."
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "clang-tidy no encontrado - targets 'tidy' y 'tidy-fix' no disponibles")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Targets de clang-format
|
||||||
|
if(CLANG_FORMAT_EXE)
|
||||||
|
add_custom_target(format
|
||||||
|
COMMAND ${CLANG_FORMAT_EXE}
|
||||||
|
-i
|
||||||
|
${ALL_SOURCE_FILES}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Running clang-format..."
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(format-check
|
||||||
|
COMMAND ${CLANG_FORMAT_EXE}
|
||||||
|
--dry-run
|
||||||
|
--Werror
|
||||||
|
${ALL_SOURCE_FILES}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Checking clang-format..."
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "clang-format no encontrado - targets 'format' y 'format-check' no disponibles")
|
||||||
|
endif()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Audio {
|
|||||||
// --- Tipos anidados ---
|
// --- Tipos anidados ---
|
||||||
struct Music {
|
struct Music {
|
||||||
MusicState state{MusicState::STOPPED}; // Estado actual de la música
|
MusicState state{MusicState::STOPPED}; // Estado actual de la música
|
||||||
std::string name{}; // Última pista de música reproducida
|
std::string name; // Última pista de música reproducida
|
||||||
bool loop{false}; // Indica si se reproduce en bucle
|
bool loop{false}; // Indica si se reproduce en bucle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ void Cache::loadSounds() {
|
|||||||
sound = JA_LoadSound(l.c_str());
|
sound = JA_LoadSound(l.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
sounds_.emplace_back(SoundResource{name, sound});
|
sounds_.emplace_back(SoundResource{.name = name, .sound = sound});
|
||||||
printWithDots("Sound : ", name, "[ LOADED ]");
|
printWithDots("Sound : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ void Cache::loadMusics() {
|
|||||||
music = JA_LoadMusic(l.c_str());
|
music = JA_LoadMusic(l.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
musics_.emplace_back(MusicResource{name, music});
|
musics_.emplace_back(MusicResource{.name = name, .music = music});
|
||||||
printWithDots("Music : ", name, "[ LOADED ]");
|
printWithDots("Music : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress(1);
|
updateLoadingProgress(1);
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ void Cache::loadSurfaces() {
|
|||||||
|
|
||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
surfaces_.emplace_back(SurfaceResource{name, std::make_shared<Surface>(l)});
|
surfaces_.emplace_back(SurfaceResource{.name = name, .surface = std::make_shared<Surface>(l)});
|
||||||
surfaces_.back().surface->setTransparentColor(0);
|
surfaces_.back().surface->setTransparentColor(0);
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ void Cache::loadPalettes() {
|
|||||||
|
|
||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
palettes_.emplace_back(ResourcePalette{name, readPalFile(l)});
|
palettes_.emplace_back(ResourcePalette{.name = name, .palette = readPalFile(l)});
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ void Cache::loadTextFiles() {
|
|||||||
|
|
||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
text_files_.emplace_back(TextFileResource{name, Text::loadTextFile(l)});
|
text_files_.emplace_back(TextFileResource{.name = name, .text_file = Text::loadTextFile(l)});
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ void Cache::loadAnimations() {
|
|||||||
// Cargar bytes del archivo YAML sin parsear (carga lazy)
|
// Cargar bytes del archivo YAML sin parsear (carga lazy)
|
||||||
auto yaml_bytes = Helper::loadFile(l);
|
auto yaml_bytes = Helper::loadFile(l);
|
||||||
|
|
||||||
animations_.emplace_back(AnimationResource{name, yaml_bytes});
|
animations_.emplace_back(AnimationResource{.name = name, .yaml_data = yaml_bytes});
|
||||||
printWithDots("Animation : ", name, "[ LOADED ]");
|
printWithDots("Animation : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
@@ -305,7 +305,7 @@ void Cache::loadRooms() {
|
|||||||
|
|
||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
rooms_.emplace_back(RoomResource{name, std::make_shared<Room::Data>(Room::loadYAML(l))});
|
rooms_.emplace_back(RoomResource{.name = name, .room = std::make_shared<Room::Data>(Room::loadYAML(l))});
|
||||||
printWithDots("Room : ", name, "[ LOADED ]");
|
printWithDots("Room : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
}
|
}
|
||||||
@@ -313,22 +313,22 @@ void Cache::loadRooms() {
|
|||||||
|
|
||||||
void Cache::createText() {
|
void Cache::createText() {
|
||||||
struct ResourceInfo {
|
struct ResourceInfo {
|
||||||
std::string key{}; // Identificador del recurso
|
std::string key; // Identificador del recurso
|
||||||
std::string texture_file{}; // Nombre del archivo de textura
|
std::string texture_file; // Nombre del archivo de textura
|
||||||
std::string text_file{}; // Nombre del archivo de texto
|
std::string text_file; // Nombre del archivo de texto
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "\n>> CREATING TEXT_OBJECTS" << '\n';
|
std::cout << "\n>> CREATING TEXT_OBJECTS" << '\n';
|
||||||
|
|
||||||
std::vector<ResourceInfo> resources = {
|
std::vector<ResourceInfo> resources = {
|
||||||
{"aseprite", "aseprite.gif", "aseprite.txt"},
|
{.key = "aseprite", .texture_file = "aseprite.gif", .text_file = "aseprite.txt"},
|
||||||
{"gauntlet", "gauntlet.gif", "gauntlet.txt"},
|
{.key = "gauntlet", .texture_file = "gauntlet.gif", .text_file = "gauntlet.txt"},
|
||||||
{"smb2", "smb2.gif", "smb2.txt"},
|
{.key = "smb2", .texture_file = "smb2.gif", .text_file = "smb2.txt"},
|
||||||
{"subatomic", "subatomic.gif", "subatomic.txt"},
|
{.key = "subatomic", .texture_file = "subatomic.gif", .text_file = "subatomic.txt"},
|
||||||
{"8bithud", "8bithud.gif", "8bithud.txt"}};
|
{.key = "8bithud", .texture_file = "8bithud.gif", .text_file = "8bithud.txt"}};
|
||||||
|
|
||||||
for (const auto& res_info : resources) {
|
for (const auto& res_info : resources) {
|
||||||
texts_.emplace_back(TextResource{res_info.key, std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
|
texts_.emplace_back(TextResource{.name = res_info.key, .text = std::make_shared<Text>(getSurface(res_info.texture_file), getTextFile(res_info.text_file))});
|
||||||
printWithDots("Text : ", res_info.key, "[ DONE ]");
|
printWithDots("Text : ", res_info.key, "[ DONE ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ void Cache::calculateTotal() {
|
|||||||
total += list.size();
|
total += list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
count_ = ResourceCount{total, 0};
|
count_ = ResourceCount{.total = total, .loaded = 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muestra el progreso de carga
|
// Muestra el progreso de carga
|
||||||
|
|||||||
@@ -74,17 +74,17 @@ class Cache {
|
|||||||
static Cache* cache;
|
static Cache* cache;
|
||||||
|
|
||||||
// Variables miembro
|
// Variables miembro
|
||||||
std::vector<SoundResource> sounds_{}; // Vector con los sonidos
|
std::vector<SoundResource> sounds_; // Vector con los sonidos
|
||||||
std::vector<MusicResource> musics_{}; // Vector con las musicas
|
std::vector<MusicResource> musics_; // Vector con las musicas
|
||||||
std::vector<SurfaceResource> surfaces_{}; // Vector con las surfaces
|
std::vector<SurfaceResource> surfaces_; // Vector con las surfaces
|
||||||
std::vector<ResourcePalette> palettes_{}; // Vector con las paletas
|
std::vector<ResourcePalette> palettes_; // Vector con las paletas
|
||||||
std::vector<TextFileResource> text_files_{}; // Vector con los ficheros de texto
|
std::vector<TextFileResource> text_files_; // Vector con los ficheros de texto
|
||||||
std::vector<TextResource> texts_{}; // Vector con los objetos de texto
|
std::vector<TextResource> texts_; // Vector con los objetos de texto
|
||||||
std::vector<AnimationResource> animations_{}; // Vector con las animaciones
|
std::vector<AnimationResource> animations_; // Vector con las animaciones
|
||||||
std::vector<RoomResource> rooms_{}; // Vector con las habitaciones
|
std::vector<RoomResource> rooms_; // Vector con las habitaciones
|
||||||
|
|
||||||
ResourceCount count_{}; // Contador de recursos
|
ResourceCount count_{}; // Contador de recursos
|
||||||
std::shared_ptr<Text> loading_text_{}; // Texto para la pantalla de carga
|
std::shared_ptr<Text> loading_text_; // Texto para la pantalla de carga
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Resource
|
} // namespace Resource
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ void List::loadFromString(const std::string& config_content, const std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extraer campos
|
// Extraer campos
|
||||||
std::string type_str = asset["type"].get_value<std::string>();
|
auto type_str = asset["type"].get_value<std::string>();
|
||||||
std::string path = asset["path"].get_value<std::string>();
|
auto path = asset["path"].get_value<std::string>();
|
||||||
|
|
||||||
// Valores por defecto
|
// Valores por defecto
|
||||||
bool required = true;
|
bool required = true;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Resource {
|
|||||||
|
|
||||||
// Entry metadata for each resource in the pack
|
// Entry metadata for each resource in the pack
|
||||||
struct ResourceEntry {
|
struct ResourceEntry {
|
||||||
std::string filename{}; // Relative path within pack
|
std::string filename; // Relative path within pack
|
||||||
uint64_t offset{0}; // Byte offset in data block
|
uint64_t offset{0}; // Byte offset in data block
|
||||||
uint64_t size{0}; // Size in bytes
|
uint64_t size{0}; // Size in bytes
|
||||||
uint32_t checksum{0}; // CRC32 checksum for verification
|
uint32_t checksum{0}; // CRC32 checksum for verification
|
||||||
@@ -60,8 +60,8 @@ class Pack {
|
|||||||
|
|
||||||
static auto readFile(const std::string& filepath) -> std::vector<uint8_t>; // File I/O
|
static auto readFile(const std::string& filepath) -> std::vector<uint8_t>; // File I/O
|
||||||
|
|
||||||
std::unordered_map<std::string, ResourceEntry> resources_{}; // Member variables
|
std::unordered_map<std::string, ResourceEntry> resources_; // Member variables
|
||||||
std::vector<uint8_t> data_{}; // Encrypted data block
|
std::vector<uint8_t> data_; // Encrypted data block
|
||||||
bool loaded_{false};
|
bool loaded_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,48 +15,48 @@ struct JA_Sound_t;
|
|||||||
|
|
||||||
// Estructura para almacenar ficheros de sonido y su nombre
|
// Estructura para almacenar ficheros de sonido y su nombre
|
||||||
struct SoundResource {
|
struct SoundResource {
|
||||||
std::string name{}; // Nombre del sonido
|
std::string name; // Nombre del sonido
|
||||||
JA_Sound_t* sound{nullptr}; // Objeto con el sonido
|
JA_Sound_t* sound{nullptr}; // Objeto con el sonido
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar ficheros musicales y su nombre
|
// Estructura para almacenar ficheros musicales y su nombre
|
||||||
struct MusicResource {
|
struct MusicResource {
|
||||||
std::string name{}; // Nombre de la musica
|
std::string name; // Nombre de la musica
|
||||||
JA_Music_t* music{nullptr}; // Objeto con la música
|
JA_Music_t* music{nullptr}; // Objeto con la música
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar objetos Surface y su nombre
|
// Estructura para almacenar objetos Surface y su nombre
|
||||||
struct SurfaceResource {
|
struct SurfaceResource {
|
||||||
std::string name{}; // Nombre de la surface
|
std::string name; // Nombre de la surface
|
||||||
std::shared_ptr<Surface> surface{}; // Objeto con la surface
|
std::shared_ptr<Surface> surface; // Objeto con la surface
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar objetos Palette y su nombre
|
// Estructura para almacenar objetos Palette y su nombre
|
||||||
struct ResourcePalette {
|
struct ResourcePalette {
|
||||||
std::string name{}; // Nombre de la surface
|
std::string name; // Nombre de la surface
|
||||||
Palette palette{}; // Paleta
|
Palette palette{}; // Paleta
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar ficheros TextFile y su nombre
|
// Estructura para almacenar ficheros TextFile y su nombre
|
||||||
struct TextFileResource {
|
struct TextFileResource {
|
||||||
std::string name{}; // Nombre del fichero
|
std::string name; // Nombre del fichero
|
||||||
std::shared_ptr<Text::File> text_file{}; // Objeto con los descriptores de la fuente de texto
|
std::shared_ptr<Text::File> text_file; // Objeto con los descriptores de la fuente de texto
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar objetos Text y su nombre
|
// Estructura para almacenar objetos Text y su nombre
|
||||||
struct TextResource {
|
struct TextResource {
|
||||||
std::string name{}; // Nombre del objeto
|
std::string name; // Nombre del objeto
|
||||||
std::shared_ptr<Text> text{}; // Objeto
|
std::shared_ptr<Text> text; // Objeto
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar ficheros animaciones y su nombre
|
// Estructura para almacenar ficheros animaciones y su nombre
|
||||||
struct AnimationResource {
|
struct AnimationResource {
|
||||||
std::string name{}; // Nombre del fichero
|
std::string name; // Nombre del fichero
|
||||||
std::vector<uint8_t> yaml_data{}; // Bytes del archivo YAML sin parsear
|
std::vector<uint8_t> yaml_data; // Bytes del archivo YAML sin parsear
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar habitaciones y su nombre
|
// Estructura para almacenar habitaciones y su nombre
|
||||||
struct RoomResource {
|
struct RoomResource {
|
||||||
std::string name{}; // Nombre de la habitación
|
std::string name; // Nombre de la habitación
|
||||||
std::shared_ptr<Room::Data> room{}; // Habitación
|
std::shared_ptr<Room::Data> room; // Habitación
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user