diff --git a/src/hades_extensions/include/generation/dijkstra.hpp b/src/hades_extensions/include/generation/dijkstra.hpp index e12bb49d..cd4a8bb9 100644 --- a/src/hades_extensions/include/generation/dijkstra.hpp +++ b/src/hades_extensions/include/generation/dijkstra.hpp @@ -27,8 +27,7 @@ struct Connection { Position destination; }; -/// Calculate the shortest path in a grid from one pair to another using the A* -/// algorithm. +/// Calculate the shortest path in a grid from one pair to another using the A* algorithm. /// /// @details https://en.wikipedia.org/wiki/A%2A_search_algorithm /// @param grid - The 2D grid which represents the dungeon. @@ -38,8 +37,7 @@ struct Connection { /// @return A vector of positions mapping out the shortest path from start to end. auto calculate_astar_path(const Grid &grid, const Position &start, const Position &end) -> std::vector; -/// Get the furthest position from the start position in the grid using a -/// Dijkstra map. +/// Get the furthest position from the start position in the grid using a Dijkstra map. /// /// @param grid - The 2D grid which represents the dungeon. /// @param start - The start position for the algorithm. diff --git a/src/hades_extensions/include/generation/primitives.hpp b/src/hades_extensions/include/generation/primitives.hpp index 77da3640..19608dd1 100644 --- a/src/hades_extensions/include/generation/primitives.hpp +++ b/src/hades_extensions/include/generation/primitives.hpp @@ -185,7 +185,6 @@ struct Grid { /// Place a rect in the 2D grid. /// - /// @details It is the responsibility of the caller to ensure that the rect fits in the grid. /// @param rect - The rect to place in the 2D grid. void place_rect(const Rect &rect) const { for (int y{std::max(rect.top_left.y, 0)}; y < std::min(rect.bottom_right.y + 1, height); y++) { diff --git a/src/hades_extensions/src/ecs/steering.cpp b/src/hades_extensions/src/ecs/steering.cpp index 3a3cbb07..f62199c7 100644 --- a/src/hades_extensions/src/ecs/steering.cpp +++ b/src/hades_extensions/src/ecs/steering.cpp @@ -46,8 +46,7 @@ auto arrive(const cpVect ¤t_position, const cpVect &target_position) -> cp } auto evade(const cpVect ¤t_position, const cpVect &target_position, const cpVect &target_velocity) -> cpVect { - // Calculate the future position of the target based on their distance, and steer away from it. - // Higher distances will require more time to reach, so the future position will be further away + // Calculate the future position of the target based on their distance, and steer away from it return flee(current_position, target_position + target_velocity * (cpvdist(target_position, current_position) / MAX_VELOCITY)); } @@ -99,8 +98,7 @@ auto obstacle_avoidance(cpSpace *space, const cpVect ¤t_position, const cp } auto pursue(const cpVect ¤t_position, const cpVect &target_position, const cpVect &target_velocity) -> cpVect { - // Calculate the future position of the target based on their distance, and steer away from it. - // Higher distances will require more time to reach, so the future position will be further away + // Calculate the future position of the target based on their distance, and steer towards it return seek(current_position, target_position + target_velocity * (cpvdist(target_position, current_position) / MAX_VELOCITY)); } diff --git a/src/hades_extensions/src/ecs/systems/effects.cpp b/src/hades_extensions/src/ecs/systems/effects.cpp index 40f144bd..25514ed1 100644 --- a/src/hades_extensions/src/ecs/systems/effects.cpp +++ b/src/hades_extensions/src/ecs/systems/effects.cpp @@ -11,9 +11,8 @@ void EffectSystem::update(const double delta_time) const { auto &applied_effects{std::get<0>(component_tuple)->applied_effects}; std::vector expired_status_effects; - // Update the status effects and keep track of the expired ones. - // Note that in reality, delta_time will be ~0.016 (60 FPS), so big jumps in time where multiple intervals are - // covered within a single update should never happen. + // Update the status effects and keep track of the expired ones. Note that in reality, delta_time will be ~0.016 + // (60 FPS), so big jumps in time where multiple intervals are covered within a single update should never happen. // But if they do, this will accumulate the leftover time and the status effect is applied in subsequent updates for (auto &[status_effect_type, status_effect] : std::get<0>(component_tuple)->applied_effects) { status_effect.time_counter += delta_time; diff --git a/src/hades_extensions/src/ecs/systems/inventory.cpp b/src/hades_extensions/src/ecs/systems/inventory.cpp index bd4b7603..924491d2 100644 --- a/src/hades_extensions/src/ecs/systems/inventory.cpp +++ b/src/hades_extensions/src/ecs/systems/inventory.cpp @@ -38,8 +38,7 @@ auto InventorySystem::add_item_to_inventory(const GameObjectID game_object_id, c get_registry()->notify_callbacks(EventType::InventoryUpdate, game_object_id); get_registry()->notify_callbacks(EventType::SpriteRemoval, item); - // If the item has a kinematic component, set the collected flag to true to - // prevent collision detection + // If the item has a kinematic component, set the collected flag to true to prevent collision detection if (get_registry()->has_component(item, typeid(KinematicComponent))) { get_registry()->get_component(item)->collected = true; } @@ -61,8 +60,7 @@ auto InventorySystem::remove_item_from_inventory(const GameObjectID game_object_ return false; } - // Remove the item from the inventory, delete the game object, and notify the - // callbacks + // Remove the item from the inventory, delete the game object, and notify the callbacks inventory->items.erase(inventory->items.begin() + index); get_registry()->delete_game_object(item_id); get_registry()->notify_callbacks(EventType::InventoryUpdate, game_object_id); diff --git a/src/hades_extensions/src/game_engine.cpp b/src/hades_extensions/src/game_engine.cpp index e6db3d5d..9eeb06cf 100644 --- a/src/hades_extensions/src/game_engine.cpp +++ b/src/hades_extensions/src/game_engine.cpp @@ -67,8 +67,7 @@ void GameEngine::create_game_objects() { continue; } - // If the tile is not a wall tile, we want an extra floor tile placed at - // the same position + // If the tile is not a wall tile, we want an extra floor tile placed at the same position static const std::unordered_map tile_to_game_object_type{ {TileType::Floor, GameObjectType::Floor}, {TileType::Wall, GameObjectType::Wall}, @@ -106,8 +105,7 @@ void GameEngine::generate_enemy(const double /*delta_time*/) { } std::ranges::shuffle(floor_positions, std::mt19937{std::random_device{}()}); - // Determine which floor to place the enemy on only trying - // ENEMY_RETRY_ATTEMPTS times + // Determine which floor to place the enemy on only trying ENEMY_RETRY_ATTEMPTS times const auto &factories{get_factories()}; for (auto attempt{0}; attempt < std::min(static_cast(floor_positions.size()), ENEMY_RETRY_ATTEMPTS); attempt++) { const auto position{floor_positions[attempt]}; diff --git a/src/hades_extensions/src/generation/dijkstra.cpp b/src/hades_extensions/src/generation/dijkstra.cpp index af9907f6..4813c57f 100644 --- a/src/hades_extensions/src/generation/dijkstra.cpp +++ b/src/hades_extensions/src/generation/dijkstra.cpp @@ -65,8 +65,8 @@ auto pathfind(const Grid &grid, const Position &start, const Position &end, } // namespace auto calculate_astar_path(const Grid &grid, const Position &start, const Position &end) -> std::vector { - // Explore the grid using the A* algorithm with the Chebyshev distance - // heuristic and then check if we've reached the end + // Explore the grid using the A* algorithm with the Chebyshev distance heuristic and then check if we've reached the + // end const auto obstacle_check{ [&grid](const Position &neighbour) { return grid.get_value(neighbour) == TileType::Obstacle; }}; const auto chebyshev_heuristic{ @@ -76,8 +76,7 @@ auto calculate_astar_path(const Grid &grid, const Position &start, const Positio return {}; } - // Backtrack through the neighbours to get the resultant path since we've - // reached the end + // Backtrack through the neighbours to get the resultant path since we've reached the end std::vector path; for (Position current{end}; current != start; current = result.at(current).source) { path.push_back(current); @@ -91,8 +90,7 @@ auto get_furthest_position(const Grid &grid, const Position &start) -> Position Position furthest_position{.x = -1, .y = -1}; int max_distance{-1}; - // Explore the grid using the Dijkstra algorithm to find the furthest - // position from the start + // Explore the grid using the Dijkstra algorithm to find the furthest position from the start const auto floor_check{[&grid](const Position &neighbour) { return grid.get_value(neighbour) != TileType::Floor; }}; const auto dijkstra_heuristic{[&max_distance, &furthest_position](const Position &neighbour, const int cost) { if (cost > max_distance) { diff --git a/src/hades_extensions/src/generation/map.cpp b/src/hades_extensions/src/generation/map.cpp index 8f1af24f..09803a89 100644 --- a/src/hades_extensions/src/generation/map.cpp +++ b/src/hades_extensions/src/generation/map.cpp @@ -106,8 +106,7 @@ void place_tiles(const Grid &grid, std::mt19937 &random_generator, const TileTyp valid_positions.pop_back(); grid.set_value(possible_tile, target_tile); - // Remove all tiles from valid_positions within MIN_TILE_DISTANCE of the - // placed tile + // Remove all tiles from valid_positions within MIN_TILE_DISTANCE of the placed tile std::erase_if(valid_positions, [&possible_tile](const Position &pos) { return std::abs(pos.x - possible_tile.x) <= MIN_TILE_DISTANCE || std::abs(pos.y - possible_tile.y) <= MIN_TILE_DISTANCE; diff --git a/src/hades_extensions/tests/ecs/systems/test_attacks.cpp b/src/hades_extensions/tests/ecs/systems/test_attacks.cpp index a6cc2968..a1c92fd0 100644 --- a/src/hades_extensions/tests/ecs/systems/test_attacks.cpp +++ b/src/hades_extensions/tests/ecs/systems/test_attacks.cpp @@ -28,9 +28,8 @@ class AttackSystemFixture : public testing::Test { return target; }}; - // Create the targets and add the attack system offseting the positions - // by (32, 32) since grid_pos_to_pixel() converts the target position to - //(32, 32) + // Create the targets and add the attack system offseting the positions by (32, 32) since grid_pos_to_pixel() + // converts the target position to (32, 32) targets = { create_target({12, -68}), create_target({52, 92}), create_target({-168, 132}), create_target({132, -68}), create_target({-68, -68}), create_target({32, -168}), create_target({32, -160}), create_target({32, 32}), diff --git a/src/hades_extensions/tests/ecs/systems/test_inventory.cpp b/src/hades_extensions/tests/ecs/systems/test_inventory.cpp index 93501650..daed82f6 100644 --- a/src/hades_extensions/tests/ecs/systems/test_inventory.cpp +++ b/src/hades_extensions/tests/ecs/systems/test_inventory.cpp @@ -108,8 +108,7 @@ TEST_F(InventorySystemFixture, TestInventorySystemRemoveItemFromInventoryValid) auto sprite_removal_callback{[&](const GameObjectID game_object_id) { sprite_removal = game_object_id; }}; registry.add_callback(EventType::SpriteRemoval, sprite_removal_callback); - // Add two items and remove one of them from the inventory and check the - // results + // Add two items and remove one of them from the inventory and check the results const auto item_id_one{create_item(GameObjectType::HealthPotion)}; const auto item_id_two{create_item(GameObjectType::HealthPotion)}; ASSERT_TRUE(get_inventory_system()->add_item_to_inventory(0, item_id_one)); diff --git a/src/hades_extensions/tests/ecs/systems/test_movements.cpp b/src/hades_extensions/tests/ecs/systems/test_movements.cpp index c6e9f680..1c6daa79 100644 --- a/src/hades_extensions/tests/ecs/systems/test_movements.cpp +++ b/src/hades_extensions/tests/ecs/systems/test_movements.cpp @@ -35,8 +35,7 @@ class FootprintSystemFixture : public testing::Test { registry.add_system(); registry.add_system(); - // Set the position of the game object to (0, 0) since grid_pos_to_pixel - // sets the position to (32, 32) + // Set the position of the game object to (0, 0) since grid_pos_to_pixel() sets the position to (32, 32) cpBodySetPosition(*registry.get_component(0)->body, cpvzero); } diff --git a/src/hades_extensions/tests/ecs/test_registry.cpp b/src/hades_extensions/tests/ecs/test_registry.cpp index 16f52aee..5a68d617 100644 --- a/src/hades_extensions/tests/ecs/test_registry.cpp +++ b/src/hades_extensions/tests/ecs/test_registry.cpp @@ -204,9 +204,8 @@ TEST_F(RegistryFixture, TestRegistryGameObjectKinematicComponent) { ASSERT_FALSE(cpSpaceContainsShape(registry.get_space(), shape)); } -/// Test that a game object with duplicate components is added to the registry correctly. +/// Test that a game object with two identical components only adds the first one. TEST_F(RegistryFixture, TestRegistryGameObjectDuplicateComponents) { - // Test that creating a game object with two of the same components only adds the first one registry.create_game_object(GameObjectType::Player, cpvzero, {std::make_shared(std::vector({10})), std::make_shared(std::vector({20}))});