neteja NOLINT identifier-naming i lambdes a metodes privats Game
This commit is contained in:
@@ -15,7 +15,7 @@ namespace GIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el diccionario LZW con los valores iniciales
|
// Inicializa el diccionario LZW con los valores iniciales
|
||||||
inline void initializeDictionary(std::vector<DictionaryEntry>& dictionary, int code_length, int& dictionary_ind) { // NOLINT(readability-identifier-naming)
|
inline void initializeDictionary(std::vector<DictionaryEntry>& dictionary, int code_length, int& dictionary_ind) {
|
||||||
int size = 1 << code_length;
|
int size = 1 << code_length;
|
||||||
dictionary.resize(1 << (code_length + 1));
|
dictionary.resize(1 << (code_length + 1));
|
||||||
for (dictionary_ind = 0; dictionary_ind < size; dictionary_ind++) {
|
for (dictionary_ind = 0; dictionary_ind < size; dictionary_ind++) {
|
||||||
@@ -55,7 +55,7 @@ namespace GIF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Agrega una nueva entrada al diccionario
|
// Agrega una nueva entrada al diccionario
|
||||||
inline void addDictionaryEntry(std::vector<DictionaryEntry>& dictionary, int& dictionary_ind, int& code_length, int prev, int code) { // NOLINT(readability-identifier-naming)
|
inline void addDictionaryEntry(std::vector<DictionaryEntry>& dictionary, int& dictionary_ind, int& code_length, int prev, int code) {
|
||||||
uint8_t first_byte;
|
uint8_t first_byte;
|
||||||
if (code == dictionary_ind) {
|
if (code == dictionary_ind) {
|
||||||
first_byte = findFirstByte(dictionary, prev);
|
first_byte = findFirstByte(dictionary, prev);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XOR encryption (symmetric - same function for encrypt/decrypt)
|
// XOR encryption (symmetric - same function for encrypt/decrypt)
|
||||||
void Pack::encryptData(std::vector<uint8_t>& data, const std::string& key) { // NOLINT(readability-identifier-naming)
|
void Pack::encryptData(std::vector<uint8_t>& data, const std::string& key) {
|
||||||
if (key.empty()) {
|
if (key.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ namespace Resource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pack::decryptData(std::vector<uint8_t>& data, const std::string& key) { // NOLINT(readability-identifier-naming)
|
void Pack::decryptData(std::vector<uint8_t>& data, const std::string& key) {
|
||||||
// XOR is symmetric
|
// XOR is symmetric
|
||||||
encryptData(data, key);
|
encryptData(data, key);
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ namespace Resource {
|
|||||||
// Add all files from a directory recursively
|
// Add all files from a directory recursively
|
||||||
auto Pack::addDirectory(const std::string& dir_path,
|
auto Pack::addDirectory(const std::string& dir_path,
|
||||||
const std::string& base_path) -> bool {
|
const std::string& base_path) -> bool {
|
||||||
namespace fs = std::filesystem; // NOLINT(readability-identifier-naming)
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) {
|
if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) {
|
||||||
std::cerr << "ResourcePack: Directory not found: " << dir_path << '\n';
|
std::cerr << "ResourcePack: Directory not found: " << dir_path << '\n';
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class MapEditor {
|
|||||||
[[nodiscard]] auto getSelectionType() const -> EntityType { return selection_.type; }
|
[[nodiscard]] auto getSelectionType() const -> EntityType { return selection_.type; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static MapEditor* instance_; // NOLINT(readability-identifier-naming) [SINGLETON] Objeto privado
|
static MapEditor* instance_;
|
||||||
|
|
||||||
MapEditor(); // Constructor
|
MapEditor(); // Constructor
|
||||||
~MapEditor(); // Destructor
|
~MapEditor(); // Destructor
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ DoorManager::DoorManager(std::string room_id, SolidActorManager* solid_actors)
|
|||||||
// Añade una puerta y la registra en el SolidActorManager. El bit
|
// Añade una puerta y la registra en el SolidActorManager. El bit
|
||||||
// BLOCKS_PLAYER del propio Door determina si bloquea al Player (se setea en
|
// BLOCKS_PLAYER del propio Door determina si bloquea al Player (se setea en
|
||||||
// el constructor si la puerta no arranca ya abierta desde el DoorTracker).
|
// el constructor si la puerta no arranca ya abierta desde el DoorTracker).
|
||||||
void DoorManager::addDoor(std::shared_ptr<Door> door) { // NOLINT(readability-identifier-naming)
|
void DoorManager::addDoor(std::shared_ptr<Door> door) {
|
||||||
solid_actors_->registerActor(door.get());
|
solid_actors_->registerActor(door.get());
|
||||||
doors_.push_back(std::move(door));
|
doors_.push_back(std::move(door));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "utils/utils.hpp" // Para checkCollision
|
#include "utils/utils.hpp" // Para checkCollision
|
||||||
|
|
||||||
// Añade un enemigo a la colección
|
// Añade un enemigo a la colección
|
||||||
void EnemyManager::addEnemy(std::shared_ptr<Enemy> enemy) { // NOLINT(readability-identifier-naming)
|
void EnemyManager::addEnemy(std::shared_ptr<Enemy> enemy) {
|
||||||
enemies_.push_back(std::move(enemy));
|
enemies_.push_back(std::move(enemy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ ItemManager::ItemManager(std::string room_id, std::shared_ptr<Scoreboard::Data>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un item a la colección
|
// Añade un item a la colección
|
||||||
void ItemManager::addItem(std::shared_ptr<Item> item) { // NOLINT(readability-identifier-naming)
|
void ItemManager::addItem(std::shared_ptr<Item> item) {
|
||||||
items_.push_back(std::move(item));
|
items_.push_back(std::move(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ KeyManager::KeyManager(std::string room_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade una llave a la colección
|
// Añade una llave a la colección
|
||||||
void KeyManager::addKey(std::shared_ptr<Key> key) { // NOLINT(readability-identifier-naming)
|
void KeyManager::addKey(std::shared_ptr<Key> key) {
|
||||||
keys_.push_back(std::move(key));
|
keys_.push_back(std::move(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-35
@@ -798,36 +798,41 @@ auto Game::getOrCreateRoom(const std::string& room_path) -> std::shared_ptr<Room
|
|||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Obtiene el collision tilemap de una room adyacente (nullptr si no existe)
|
||||||
|
auto Game::getAdjacentCollision(Room::Border border) -> const std::vector<int>* {
|
||||||
|
auto name = room_->getRoom(border);
|
||||||
|
if (name == "0") { return nullptr; }
|
||||||
|
return &getOrCreateRoom(name)->getCollisionTileMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene el collision tilemap de una room diagonal (A→B o C→D)
|
||||||
|
auto Game::getDiagCollision(Room::Border first, Room::Border second) -> const std::vector<int>* {
|
||||||
|
// Camino 1: room en dirección 'first', luego su adyacente en dirección 'second'
|
||||||
|
auto name1 = room_->getRoom(first);
|
||||||
|
if (name1 != "0") {
|
||||||
|
auto r = getOrCreateRoom(name1);
|
||||||
|
auto name2 = r->getRoom(second);
|
||||||
|
if (name2 != "0") { return &getOrCreateRoom(name2)->getCollisionTileMap(); }
|
||||||
|
}
|
||||||
|
// Camino 2: room en dirección 'second', luego su adyacente en dirección 'first'
|
||||||
|
auto name3 = room_->getRoom(second);
|
||||||
|
if (name3 != "0") {
|
||||||
|
auto r = getOrCreateRoom(name3);
|
||||||
|
auto name4 = r->getRoom(first);
|
||||||
|
if (name4 != "0") { return &getOrCreateRoom(name4)->getCollisionTileMap(); }
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SolidActorManager de la room adyacente (nullptr si no existe)
|
||||||
|
auto Game::getAdjacentSolidActors(Room::Border border) -> SolidActorManager* {
|
||||||
|
auto name = room_->getRoom(border);
|
||||||
|
if (name == "0") { return nullptr; }
|
||||||
|
return &getOrCreateRoom(name)->getSolidActors();
|
||||||
|
}
|
||||||
|
|
||||||
// Construye el tilemap extendido de la room actual con los bordes de las adyacentes
|
// Construye el tilemap extendido de la room actual con los bordes de las adyacentes
|
||||||
void Game::buildCollisionBorders() {
|
void Game::buildCollisionBorders() {
|
||||||
// NOLINTBEGIN(readability-identifier-naming) -- lambdas locales: se leen como llamadas a función, no son constantes.
|
|
||||||
// Helper: obtiene el collision tilemap de una room adyacente (nullptr si no existe)
|
|
||||||
auto getAdjacentCollision = [&](Room::Border b) -> const std::vector<int>* {
|
|
||||||
auto name = room_->getRoom(b);
|
|
||||||
if (name == "0") { return nullptr; }
|
|
||||||
return &getOrCreateRoom(name)->getCollisionTileMap();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper: obtiene el collision tilemap de una room diagonal (A→B o C→D)
|
|
||||||
auto getDiagCollision = [&](Room::Border first, Room::Border second) -> const std::vector<int>* {
|
|
||||||
// Camino 1: room en dirección 'first', luego su adyacente en dirección 'second'
|
|
||||||
auto name1 = room_->getRoom(first);
|
|
||||||
if (name1 != "0") {
|
|
||||||
auto r = getOrCreateRoom(name1);
|
|
||||||
auto name2 = r->getRoom(second);
|
|
||||||
if (name2 != "0") { return &getOrCreateRoom(name2)->getCollisionTileMap(); }
|
|
||||||
}
|
|
||||||
// Camino 2: room en dirección 'second', luego su adyacente en dirección 'first'
|
|
||||||
auto name3 = room_->getRoom(second);
|
|
||||||
if (name3 != "0") {
|
|
||||||
auto r = getOrCreateRoom(name3);
|
|
||||||
auto name4 = r->getRoom(first);
|
|
||||||
if (name4 != "0") { return &getOrCreateRoom(name4)->getCollisionTileMap(); }
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
};
|
|
||||||
// NOLINTEND(readability-identifier-naming)
|
|
||||||
|
|
||||||
CollisionMap::AdjacentData adj;
|
CollisionMap::AdjacentData adj;
|
||||||
adj.top = getAdjacentCollision(Room::Border::TOP);
|
adj.top = getAdjacentCollision(Room::Border::TOP);
|
||||||
adj.bottom = getAdjacentCollision(Room::Border::BOTTOM);
|
adj.bottom = getAdjacentCollision(Room::Border::BOTTOM);
|
||||||
@@ -845,13 +850,6 @@ void Game::buildCollisionBorders() {
|
|||||||
// que los sweeps del Player vean AABBs dinámicos (puertas, plataformas)
|
// que los sweeps del Player vean AABBs dinámicos (puertas, plataformas)
|
||||||
// de la room vecina cuando está cerca del borde, sin tener que esperar
|
// de la room vecina cuando está cerca del borde, sin tener que esperar
|
||||||
// a una transición completa de room.
|
// a una transición completa de room.
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming) -- lambda local: se lee como función, no es constante.
|
|
||||||
auto getAdjacentSolidActors = [&](Room::Border b) -> SolidActorManager* {
|
|
||||||
auto name = room_->getRoom(b);
|
|
||||||
if (name == "0") { return nullptr; }
|
|
||||||
return &getOrCreateRoom(name)->getSolidActors();
|
|
||||||
};
|
|
||||||
|
|
||||||
SolidActorManager::AdjacentActors sadj;
|
SolidActorManager::AdjacentActors sadj;
|
||||||
sadj.upper = getAdjacentSolidActors(Room::Border::TOP);
|
sadj.upper = getAdjacentSolidActors(Room::Border::TOP);
|
||||||
sadj.lower = getAdjacentSolidActors(Room::Border::BOTTOM);
|
sadj.lower = getAdjacentSolidActors(Room::Border::BOTTOM);
|
||||||
|
|||||||
+33
-30
@@ -57,36 +57,39 @@ class Game {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// --- Métodos ---
|
// --- Métodos ---
|
||||||
static void handleEvents(); // Comprueba los eventos de la cola
|
static void handleEvents(); // Comprueba los eventos de la cola
|
||||||
void transitionToState(State new_state); // Cambia al estado especificado y resetea los timers
|
void transitionToState(State new_state); // Cambia al estado especificado y resetea los timers
|
||||||
void updatePlaying(float delta_time); // Actualiza el juego en estado PLAYING
|
void updatePlaying(float delta_time); // Actualiza el juego en estado PLAYING
|
||||||
void updateBlackScreen(float delta_time); // Actualiza el juego en estado BLACK_SCREEN
|
void updateBlackScreen(float delta_time); // Actualiza el juego en estado BLACK_SCREEN
|
||||||
void updateGameOver(float delta_time); // Actualiza el juego en estado GAME_OVER
|
void updateGameOver(float delta_time); // Actualiza el juego en estado GAME_OVER
|
||||||
void updateFadeToEnding(float delta_time); // Actualiza el juego en estado FADE_TO_ENDING
|
void updateFadeToEnding(float delta_time); // Actualiza el juego en estado FADE_TO_ENDING
|
||||||
void updatePostFadeEnding(float delta_time); // Actualiza el juego en estado POST_FADE_ENDING
|
void updatePostFadeEnding(float delta_time); // Actualiza el juego en estado POST_FADE_ENDING
|
||||||
void renderPlaying(); // Renderiza el juego en estado PLAYING (directo a pantalla)
|
void renderPlaying(); // Renderiza el juego en estado PLAYING (directo a pantalla)
|
||||||
static void renderBlackScreen(); // Renderiza el juego en estado BLACK_SCREEN (pantalla negra)
|
static void renderBlackScreen(); // Renderiza el juego en estado BLACK_SCREEN (pantalla negra)
|
||||||
static void renderGameOver(); // Renderiza el juego en estado GAME_OVER (pantalla negra)
|
static void renderGameOver(); // Renderiza el juego en estado GAME_OVER (pantalla negra)
|
||||||
void renderFadeToEnding(); // Renderiza el juego en estado FADE_TO_ENDING (via backbuffer)
|
void renderFadeToEnding(); // Renderiza el juego en estado FADE_TO_ENDING (via backbuffer)
|
||||||
static void renderPostFadeEnding(); // Renderiza el juego en estado POST_FADE_ENDING (pantalla negra)
|
static void renderPostFadeEnding(); // Renderiza el juego en estado POST_FADE_ENDING (pantalla negra)
|
||||||
auto changeRoom(const std::string& room_path) -> bool; // Cambia de habitación
|
auto changeRoom(const std::string& room_path) -> bool; // Cambia de habitación
|
||||||
auto getOrCreateRoom(const std::string& room_path) -> std::shared_ptr<Room>; // Obtiene una habitación del caché o la crea
|
auto getOrCreateRoom(const std::string& room_path) -> std::shared_ptr<Room>; // Obtiene una habitación del caché o la crea
|
||||||
void buildCollisionBorders(); // Rellena el tilemap extendido de la room actual con bordes adyacentes
|
void buildCollisionBorders(); // Rellena el tilemap extendido de la room actual con bordes adyacentes
|
||||||
void updateAdjacentRooms(float delta_time); // Actualiza enemigos de las habitaciones adyacentes
|
auto getAdjacentCollision(Room::Border border) -> const std::vector<int>*; // Collision tilemap de la room adyacente o nullptr
|
||||||
void handleInput(); // Comprueba el teclado
|
auto getDiagCollision(Room::Border first, Room::Border second) -> const std::vector<int>*; // Collision tilemap de la room diagonal o nullptr
|
||||||
void checkPlayerIsOnBorder(); // Comprueba si el jugador esta en el borde de la pantalla y actua
|
auto getAdjacentSolidActors(Room::Border border) -> SolidActorManager*; // SolidActorManager de la room adyacente o nullptr
|
||||||
auto checkPlayerAndEnemies() -> bool; // Comprueba las colisiones del jugador con los enemigos
|
void updateAdjacentRooms(float delta_time); // Actualiza enemigos de las habitaciones adyacentes
|
||||||
void checkPlayerAndItems(); // Comprueba las colisiones del jugador con los objetos
|
void handleInput(); // Comprueba el teclado
|
||||||
void checkPlayerAndKeys(); // Comprueba las colisiones del jugador con las llaves
|
void checkPlayerIsOnBorder(); // Comprueba si el jugador esta en el borde de la pantalla y actua
|
||||||
void checkIfPlayerIsAlive(); // Comprueba si el jugador esta vivo
|
auto checkPlayerAndEnemies() -> bool; // Comprueba las colisiones del jugador con los enemigos
|
||||||
void killPlayer(); // Mata al jugador
|
void checkPlayerAndItems(); // Comprueba las colisiones del jugador con los objetos
|
||||||
void togglePause(); // Pone el juego en pausa
|
void checkPlayerAndKeys(); // Comprueba las colisiones del jugador con las llaves
|
||||||
void initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room); // Inicializa al jugador
|
void checkIfPlayerIsAlive(); // Comprueba si el jugador esta vivo
|
||||||
void endTransition(); // Finaliza la transición entre pantallas
|
void killPlayer(); // Mata al jugador
|
||||||
void keepMusicPlaying(); // Hace sonar la música (safety net, delega en updateMusicForRoom)
|
void togglePause(); // Pone el juego en pausa
|
||||||
void updateMusicForRoom(); // Sincroniza la música con la zona de la room actual
|
void initPlayer(const Player::SpawnData& spawn_point, std::shared_ptr<Room> room); // Inicializa al jugador
|
||||||
void demoInit(); // DEMO MODE: Inicializa las variables para el modo demo
|
void endTransition(); // Finaliza la transición entre pantallas
|
||||||
void demoCheckRoomChange(float delta_time); // DEMO MODE: Comprueba si se ha de cambiar de habitación
|
void keepMusicPlaying(); // Hace sonar la música (safety net, delega en updateMusicForRoom)
|
||||||
|
void updateMusicForRoom(); // Sincroniza la música con la zona de la room actual
|
||||||
|
void demoInit(); // DEMO MODE: Inicializa las variables para el modo demo
|
||||||
|
void demoCheckRoomChange(float delta_time); // DEMO MODE: Comprueba si se ha de cambiar de habitación
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static void renderDebugInfo(); // Pone la información de debug en pantalla
|
static void renderDebugInfo(); // Pone la información de debug en pantalla
|
||||||
void handleDebugEvents(const SDL_Event& event); // Comprueba los eventos
|
void handleDebugEvents(const SDL_Event& event); // Comprueba los eventos
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Color {
|
|||||||
* @param color Color del enum Cpc
|
* @param color Color del enum Cpc
|
||||||
* @return Índice de paleta (Uint8)
|
* @return Índice de paleta (Uint8)
|
||||||
*/
|
*/
|
||||||
static constexpr auto getIndex(Cpc color) -> Uint8 { // NOLINT(readability-identifier-naming)
|
static constexpr auto getIndex(Cpc color) -> Uint8 {
|
||||||
return static_cast<Uint8>(color);
|
return static_cast<Uint8>(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user