Merge branch 'refactor/revert-stl-loops': bucles for explícits en lloc de std::ranges::* on aplica

This commit is contained in:
2026-05-26 13:50:46 +02:00
6 changed files with 48 additions and 25 deletions
+6 -3
View File
@@ -3,7 +3,6 @@
#pragma once #pragma once
#include <algorithm>
#include <array> #include <array>
namespace Defaults::Rendering { namespace Defaults::Rendering {
@@ -35,8 +34,12 @@ namespace Defaults::Rendering {
constexpr int RENDER_HEIGHT_DEFAULT = 720; constexpr int RENDER_HEIGHT_DEFAULT = 720;
constexpr auto isValidRenderResolution(int w, int h) -> bool { constexpr auto isValidRenderResolution(int w, int h) -> bool {
return std::ranges::any_of(RESOLUTION_PRESETS, for (const auto& preset : RESOLUTION_PRESETS) {
[w, h](const ResolutionPreset& preset) { return preset.w == w && preset.h == h; }); if (preset.w == w && preset.h == h) {
return true;
}
}
return false;
} }
} // namespace Defaults::Rendering } // namespace Defaults::Rendering
+6 -4
View File
@@ -3,7 +3,6 @@
#include "core/input/define_inputs.hpp" #include "core/input/define_inputs.hpp"
#include <algorithm>
#include <format> #include <format>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -154,9 +153,12 @@ namespace System {
} }
auto DefineInputs::isInUse(int code) const -> bool { auto DefineInputs::isInUse(int code) const -> bool {
return std::ranges::any_of(sequence_, [code](const Step& s) { for (const auto& s : sequence_) {
return s.captured == code; if (s.captured == code) {
}); return true;
}
}
return false;
} }
void DefineInputs::captureAndAdvance(int code) { void DefineInputs::captureAndAdvance(int code) {
+13 -7
View File
@@ -2,7 +2,6 @@
#include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode #include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode
#include <algorithm> // Para std::ranges::any_of
#include <iostream> // Para basic_ostream, operator<<, cout, cerr #include <iostream> // Para basic_ostream, operator<<, cout, cerr
#include <memory> // Para shared_ptr, __shared_ptr_access, allocator, operator==, make_shared #include <memory> // Para shared_ptr, __shared_ptr_access, allocator, operator==, make_shared
#include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator #include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator
@@ -166,9 +165,12 @@ auto Input::checkAnyButton(bool repeat) -> bool {
// Comprueba si algún player (P1 o P2) presionó alguna acción de una lista // Comprueba si algún player (P1 o P2) presionó alguna acción de una lista
auto Input::checkAnyPlayerAction(const std::span<const InputAction>& actions, bool repeat) -> bool { auto Input::checkAnyPlayerAction(const std::span<const InputAction>& actions, bool repeat) -> bool {
return std::ranges::any_of(actions, [this, repeat](const InputAction& action) { for (const auto& action : actions) {
return checkActionPlayer1(action, repeat) || checkActionPlayer2(action, repeat); if (checkActionPlayer1(action, repeat) || checkActionPlayer2(action, repeat)) {
}); return true;
}
}
return false;
} }
// Comprueba si hay algun mando conectado // Comprueba si hay algun mando conectado
@@ -441,9 +443,13 @@ auto Input::addGamepad(int device_index) -> std::string {
} }
auto Input::removeGamepad(SDL_JoystickID id) -> std::string { auto Input::removeGamepad(SDL_JoystickID id) -> std::string {
auto it = std::ranges::find_if(gamepads_, [id](const std::shared_ptr<Gamepad>& gamepad) { auto it = gamepads_.end();
return gamepad->instance_id == id; for (auto i = gamepads_.begin(); i != gamepads_.end(); ++i) {
}); if ((*i)->instance_id == id) {
it = i;
break;
}
}
if (it != gamepads_.end()) { if (it != gamepads_.end()) {
std::string name = (*it)->name; std::string name = (*it)->name;
+5 -3
View File
@@ -3,7 +3,6 @@
#include "core/physics/physics_world.hpp" #include "core/physics/physics_world.hpp"
#include <algorithm>
#include <cmath> #include <cmath>
#include "core/physics/rigid_body.hpp" #include "core/physics/rigid_body.hpp"
@@ -14,9 +13,12 @@ namespace Physics {
if (body == nullptr) { if (body == nullptr) {
return; return;
} }
if (std::ranges::find(bodies_, body) == bodies_.end()) { for (const auto* b : bodies_) {
bodies_.push_back(body); if (b == body) {
return;
}
} }
bodies_.push_back(body);
} }
void PhysicsWorld::removeBody(RigidBody* body) { void PhysicsWorld::removeBody(RigidBody* body) {
+6 -4
View File
@@ -3,7 +3,6 @@
#pragma once #pragma once
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <vector> #include <vector>
@@ -56,9 +55,12 @@ namespace StageSystem {
if (stage_id == 0 || waves.empty()) { if (stage_id == 0 || waves.empty()) {
return false; return false;
} }
return std::ranges::all_of(waves, [](const WaveConfig& w) { for (const auto& w : waves) {
return w.next.isValid() && !w.spawn.empty(); if (!w.next.isValid() || w.spawn.empty()) {
}); return false;
}
}
return true;
} }
}; };
+12 -4
View File
@@ -225,13 +225,21 @@ namespace Title {
} }
auto ShipAnimator::isVisible() const -> bool { auto ShipAnimator::isVisible() const -> bool {
return std::ranges::any_of(ships_, for (const auto& s : ships_) {
[](const TitleShip& s) { return s.visible; }); if (s.visible) {
return true;
}
}
return false;
} }
auto ShipAnimator::isAnimationComplete() const -> bool { auto ShipAnimator::isAnimationComplete() const -> bool {
return std::ranges::all_of(ships_, for (const auto& s : ships_) {
[](const TitleShip& s) { return !s.visible; }); if (s.visible) {
return false;
}
}
return true;
} }
void ShipAnimator::updateEntering(TitleShip& ship, float delta_time) { void ShipAnimator::updateEntering(TitleShip& ship, float delta_time) {