Skip to content

Commit

Permalink
Fixed source includes
Browse files Browse the repository at this point in the history
  • Loading branch information
Semitalis committed Jun 24, 2023
1 parent 48d2fc6 commit f542f29
Show file tree
Hide file tree
Showing 34 changed files with 67 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

#include "internal_state_interface.hpp"
16 changes: 8 additions & 8 deletions impl/game_client_lib/internal_state/internal_state_manager.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "internal_state_manager.hpp"
#include "end_lose.hpp"
#include "end_win.hpp"
#include "place_units.hpp"
#include "playback.hpp"
#include "select_starting_units.hpp"
#include "state_game.hpp"
#include "wait_for_all_players.hpp"
#include "wait_for_simulation_results.hpp"
#include <internal_state/end_lose.hpp>
#include <internal_state/end_win.hpp>
#include <internal_state/place_units.hpp>
#include <internal_state/playback.hpp>
#include <internal_state/select_starting_units.hpp>
#include <internal_state/wait_for_all_players.hpp>
#include <internal_state/wait_for_simulation_results.hpp>
#include <state_game.hpp>
#include <memory>

InternalStateManager::InternalStateManager()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "select_starting_units.hpp"
#include "state_game.hpp"
#include <state_game.hpp>
#include <imgui.h>
#include <string>

namespace {
// TODO move to separate file
Expand Down
4 changes: 2 additions & 2 deletions impl/game_client_lib/internal_state/wait_for_all_players.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "wait_for_all_players.hpp"
#include "internal_state_manager.hpp"
#include "state_game.hpp"
#include <internal_state/internal_state_manager.hpp>
#include <state_game.hpp>

void WaitForAllPlayers::update(StateGame& state, float /*elapsed*/)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "wait_for_simulation_results.hpp"
#include "internal_state_manager.hpp"
#include "state_game.hpp"
#include <internal_state/internal_state_manager.hpp>
#include <state_game.hpp>

void WaitForSimulationResults::update(StateGame& state, float /*elapsed*/)
{
Expand Down
3 changes: 0 additions & 3 deletions impl/game_client_lib/server_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
#include <json_keys.hpp>
#include <message.hpp>
#include <network_properties.hpp>
#include <object_properties.hpp>
#include <simulation_result_data.hpp>
#include <unit_info.hpp>
#include <mutex>
#include <stdexcept>
#include <string>

ServerConnection::ServerConnection(jt::LoggerInterface& logger)
: m_logger { logger }
Expand Down
10 changes: 4 additions & 6 deletions impl/game_client_lib/server_connector.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "server_connector.hpp"
#include "message.hpp"
#include "state_game.hpp"
#include <game_interface.hpp>
#include "imgui.h"
#include "misc/cpp/imgui_stdlib.h"
#include <iostream>
#include <memory>
#include <message.hpp>
#include <state_game.hpp>
#include <imgui.h>
#include <misc/cpp/imgui_stdlib.h>

ServerConnector::ServerConnector(std::shared_ptr<CompressorInterface> compressor)
: m_compressor { compressor }
Expand Down
3 changes: 2 additions & 1 deletion impl/game_client_lib/state_intro.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "state_intro.hpp"
#include "game_properties.hpp"
#include <audio/sound/sound.hpp>
#include <game_interface.hpp>
#include <game_properties.hpp>
#include <state_menu.hpp>
#include <tweens/tween_alpha.hpp>
#include <tweens/tween_position.hpp>
#include <vector.hpp>

void StateIntro::onCreate()
{
Expand Down
6 changes: 2 additions & 4 deletions impl/game_client_lib/state_menu.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include "state_menu.hpp"
#include "compression/compressor_impl.hpp"
#include "compression/logging_compressor.hpp"
#include "server_connector.hpp"
#include <build_info.hpp>
#include <color/color.hpp>
#include <compression/compressor_impl.hpp>
#include <compression/logging_compressor.hpp>
#include <drawable_helpers.hpp>
#include <game_interface.hpp>
#include <game_properties.hpp>
Expand All @@ -23,7 +22,6 @@
#include <tweens/tween_scale.hpp>
#include <algorithm>
#include <iostream>
#include <memory>

void StateMenu::onCreate()
{
Expand Down
2 changes: 2 additions & 0 deletions impl/game_client_lib/unit_placement/placed_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <game_properties.hpp>
#include <math_helper.hpp>
#include <network_data/unit_client_to_server_data.hpp>
#include <rect.hpp>
#include <tweens/tween_position.hpp>
#include <vector.hpp>
#include <memory>
Expand Down Expand Up @@ -82,6 +83,7 @@ std::shared_ptr<jt::Tween> PlacedUnit::createInitialTween()
}

int PlacedUnit::getLevel() const { return 1; }

int PlacedUnit::getPlayerID() const { return m_playerID; }

void PlacedUnit::flash() { m_anim->flash(0.4f, jt::colors::Green); }
2 changes: 1 addition & 1 deletion impl/game_common_lib/map/placement_area.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "placement_area.hpp"
#include <game_properties.hpp>
#include <map/placement_area.hpp>
#include <map/terrain.hpp>

namespace {
Expand Down
6 changes: 3 additions & 3 deletions impl/game_common_lib/map/terrain.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#define _USE_MATH_DEFINES
#include <cmath>

#include "vector.hpp"
#include <map/terrain.hpp>
#include "terrain.hpp"
#include <math_helper.hpp>
#include <nlohmann.hpp>
#include <vector.hpp>
#include <fstream>
#include <iostream>
#include <vector>

namespace {

Expand Down
4 changes: 2 additions & 2 deletions impl/game_common_lib/network_data/arrow_info.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#include "arrow_info.hpp"
#include "json_keys.hpp"
#include <json_keys.hpp>
#include <network_properties.hpp>

void to_json(nlohmann::json& j, const ArrowInfo& data)
Expand All @@ -11,7 +11,7 @@ void to_json(nlohmann::json& j, const ArrowInfo& data)
{ jk::positionY, static_cast<int>(data.currentPos.y * NetworkProperties::floatPrecision()) }
// clang-format on
};

if (data.arrowScale != 1.0f) {
j[jk::scale] = static_cast<int>(data.arrowScale * NetworkProperties::floatPrecision());
}
Expand Down
1 change: 1 addition & 0 deletions impl/game_common_lib/network_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <iomanip>
#include <sstream>

void NetworkHelpers::freeSendString(
std::string const& str, asio::ip::tcp::socket& socket, jt::LoggerInterface& logger)
Expand Down
1 change: 0 additions & 1 deletion impl/game_common_lib/receive_buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

#include "receive_buffer.hpp"
2 changes: 1 addition & 1 deletion impl/game_common_lib/simulation_result_data.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "simulation_result_data.hpp"
#include "json_keys.hpp"
#include <json_keys.hpp>

void to_json(nlohmann::json& j, const SimulationResultDataForOneFrame& data)
{
Expand Down
3 changes: 1 addition & 2 deletions impl/game_common_lib/unit_info.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "unit_info.hpp"
#include "json_keys.hpp"
#include <nlohmann.hpp>
#include <json_keys.hpp>

void to_json(nlohmann::json& j, AiInfo const& p)
{
Expand Down
2 changes: 0 additions & 2 deletions impl/game_common_lib/unit_info_collection.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "unit_info_collection.hpp"
#include <json_keys.hpp>
#include <nlohmann.hpp>
#include <fstream>
#include <stdexcept>
#include <string>

UnitInfoCollection::UnitInfoCollection(jt::LoggerInterface& logger, const std::string& infoFilename)
: m_logger { logger }
Expand Down
9 changes: 5 additions & 4 deletions impl/game_server/main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "compression/compressor_impl.hpp"
#include "compression/logging_compressor.hpp"
#include "log/default_logging.hpp"
#include "log/logger.hpp"
#include <compression/compressor_impl.hpp>
#include <compression/logging_compressor.hpp>
#include <game_server.hpp>
#include <log/default_logging.hpp>
#include <log/logger.hpp>
#include <chrono>
#include <exception>
#include <iostream>
#include <memory>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion impl/game_server_lib/close_combat_info.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

#include "close_combat_info.hpp"
2 changes: 1 addition & 1 deletion impl/game_server_lib/game_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void GameServer::performAI(std::map<int, PlayerInfo>& botDataCopy) const
unitData.positionX -= terrainChunkSizeInPixel * 2;
unitData.positionY -= terrainChunkSizeInPixel * 5 + 32 * (m_round - 10);
}
std::vector<std::string> const possibleUnits = m_unitInfos.getTypes();
auto const possibleUnits = m_unitInfos.getTypes();
auto const unitType
= *jt::SystemHelper::select_randomly(possibleUnits.cbegin(), possibleUnits.cend());

Expand Down
14 changes: 4 additions & 10 deletions impl/game_server_lib/game_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ void GameSimulation::handleArrows(
}
}
}
m_arrows.erase(std::remove_if(m_arrows.begin(), m_arrows.end(),
[](auto& arrow) { return arrow.age > arrow.totalTime; }),
m_arrows.end());
(void)std::erase_if(m_arrows, [](auto const& arrow) { return arrow.age > arrow.totalTime; });
}

void GameSimulation::handleArrowsToBeSpawned(float timePerUpdate)
Expand All @@ -231,9 +229,7 @@ void GameSimulation::handleArrowsToBeSpawned(float timePerUpdate)
}
}

m_arrowsToBeSpawned.erase(std::remove_if(m_arrowsToBeSpawned.begin(), m_arrowsToBeSpawned.end(),
[](auto& kvp) { return kvp.first <= 0; }),
m_arrowsToBeSpawned.end());
(void)std::erase_if(m_arrowsToBeSpawned, [](auto const& kvp) { return kvp.first <= 0; });
}

void GameSimulation::handleScheduledAttacks(float timePerUpdate)
Expand All @@ -256,10 +252,8 @@ void GameSimulation::handleScheduledAttacks(float timePerUpdate)
}
}

m_scheduledCloseCombatAttacks.erase(
std::remove_if(m_scheduledCloseCombatAttacks.begin(), m_scheduledCloseCombatAttacks.end(),
[](auto& kvp) { return kvp.first <= 0; }),
m_scheduledCloseCombatAttacks.end());
(void)std::erase_if(
m_scheduledCloseCombatAttacks, [](auto const& kvp) { return kvp.first <= 0; });
}

std::weak_ptr<SimulationObjectInterface> GameSimulation::getClosestTargetTo(
Expand Down
1 change: 0 additions & 1 deletion impl/game_server_lib/player_info.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

#include "player_info.hpp"
16 changes: 6 additions & 10 deletions impl/game_server_lib/server_network_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ServerNetworkConnection::ServerNetworkConnection(
NetworkProperties::NetworkProtocolType(), NetworkProperties::DefaultServerPort() } }
, m_buffer { std::make_unique<ReceiveBuffer>() }
{

awaitNextAccept();

startProcessing();
Expand Down Expand Up @@ -83,15 +82,12 @@ void ServerNetworkConnection::update()
std::lock_guard<std::mutex> lock { m_socketsMutex };

// clean up sockets
m_sockets.erase(
std::remove_if(m_sockets.begin(), m_sockets.end(),
[this](auto const& s) {
if (!s->is_open()) {
m_logger.info("remove closed socket", { "network", "ServerNetworkConnection" });
}
return !s->is_open();
}),
m_sockets.end());
(void)std::erase_if(m_sockets, [this](auto const& s) {
if (!s->is_open()) {
m_logger.info("remove closed socket", { "network", "ServerNetworkConnection" });
}
return !s->is_open();
});
}

void ServerNetworkConnection::handleReceive(
Expand Down
5 changes: 2 additions & 3 deletions impl/game_server_lib/simulation_result_message_sender.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "simulation_result_message_sender.hpp"
#include "object_properties.hpp"
#include "simulation_result_data.hpp"
#include <iostream>
#include <message.hpp>
#include <nlohmann.hpp>

SimulationResultMessageSender::SimulationResultMessageSender(ServerNetworkConnection& connection)
: m_connection { connection }
Expand Down
2 changes: 1 addition & 1 deletion impl/game_server_lib/units/ai/ai_close_combat.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "ai_close_combat.hpp"
#include "close_combat_info.hpp"
#include <close_combat_info.hpp>
#include <map/terrain.hpp>
#include <math_helper.hpp>
#include <random/random.hpp>
Expand Down
1 change: 0 additions & 1 deletion impl/game_server_lib/units/ai/ai_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

#include "ai_interface.hpp"
4 changes: 1 addition & 3 deletions impl/jamtemplate/common/audio/audio/audio_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ void jt::AudioImpl::update(float elapsed)

void jt::AudioImpl::cleanUpUnusedSounds()
{
m_temporarySounds.erase(std::remove_if(m_temporarySounds.begin(), m_temporarySounds.end(),
[](auto wptr) { return wptr.expired(); }),
m_temporarySounds.end());
(void)std::erase_if(m_temporarySounds, [](auto const& wptr) { return wptr.expired(); });
}

std::shared_ptr<jt::SoundInterface> jt::AudioImpl::addTemporarySound(std::string const& fileName)
Expand Down
9 changes: 3 additions & 6 deletions impl/jamtemplate/common/audio/fades/sound_fade_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ void SoundFadeManager::volumeFade(std::weak_ptr<SoundInterface> sound, float dur

void SoundFadeManager::update(float elapsed)
{
m_fadeInfos.erase(std::remove_if(m_fadeInfos.begin(), m_fadeInfos.end(),
[](auto const& fadeInfo) { return !fadeInfo.hasValidSound(); }),
m_fadeInfos.end());
(void)std::erase_if(
m_fadeInfos, [](auto const& fadeInfo) { return !fadeInfo.hasValidSound(); });

for (auto& fade : m_fadeInfos) {
fade.update(elapsed);
}

m_fadeInfos.erase(std::remove_if(m_fadeInfos.begin(), m_fadeInfos.end(),
[](auto const& fadeInfo) { return !fadeInfo.isAlive(); }),
m_fadeInfos.end());
(void)std::erase_if(m_fadeInfos, [](auto const& fadeInfo) { return !fadeInfo.isAlive(); });
}
std::size_t SoundFadeManager::size() const { return m_fadeInfos.size(); }

Expand Down
16 changes: 7 additions & 9 deletions impl/jamtemplate/common/game_object_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ void jt::GameObjectCollection::draw() const

void jt::GameObjectCollection::cleanUpObjects()
{
m_objects.erase(std::remove_if(m_objects.begin(), m_objects.end(),
[](auto go) {
bool const isDead = !go->isAlive();
if (isDead) {
go->destroy();
}
return isDead;
}),
m_objects.end());
(void)std::erase_if(m_objects, [](auto const& go) {
bool const isDead = !go->isAlive();
if (isDead) {
go->destroy();
}
return isDead;
});
}
void jt::GameObjectCollection::addNewObjects()
{
Expand Down
4 changes: 1 addition & 3 deletions impl/jamtemplate/common/object_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class ObjectGroup : public GameObject {

void doUpdate(const float /*elapsed*/) override
{
m_data.erase(std::remove_if(m_data.begin(), m_data.end(),
[](std::weak_ptr<T> wptr) { return wptr.expired(); }),
m_data.end());
(void)std::erase_if(m_data, [](auto const& wptr) { return wptr.expired(); });
}
};

Expand Down
4 changes: 1 addition & 3 deletions impl/jamtemplate/common/strutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,7 @@ static inline std::string join(const std::vector<T>& tokens, const std::string&
*/
static inline void drop_empty(std::vector<std::string>& tokens)
{
auto last = std::remove_if(
tokens.begin(), tokens.end(), [](const std::string& s) { return s.size() == 0; });
tokens.erase(last, tokens.end());
(void)std::erase_if(tokens, [](auto const& s) { return s.empty(); });
}

/**
Expand Down
Loading

0 comments on commit f542f29

Please sign in to comment.