From 7943b2e9660f2ac7eee58341506e2df4641a1213 Mon Sep 17 00:00:00 2001 From: Github Actions Date: Sun, 5 Nov 2023 19:29:43 +0000 Subject: [PATCH] FORMAT-AUTO: automatic format on pull request #143 --- src/Client/Systems/Events/EventsSystems.cpp | 32 +++++++++++-------- .../Menus/CreateLobby/CreateLobbySystems.cpp | 8 ++--- .../Systems/Menus/Menu/ButtonCallbacks.cpp | 10 +++--- src/Client/Systems/Menus/Menu/Menu.cpp | 17 +++++----- src/Client/Systems/Menus/Menu/MenuSystems.cpp | 15 ++++----- .../Menus/SelectLobby/SelectLobbySystems.cpp | 17 ++++++---- src/Client/Systems/Network/ClientNetwork.cpp | 31 +++++++++--------- src/Game/CreateMissiles.cpp | 30 ++++++++++------- src/Game/GameCustomTypes.cpp | 9 ++++-- src/Game/GameSystems.cpp | 4 +-- src/Game/PhysicSystems.cpp | 4 +-- src/Game/ResourcesManager.hpp | 18 +++++------ src/Game/WaveSystemsAll.cpp | 11 ++++--- src/Nitwork/ANitwork.cpp | 3 +- src/Nitwork/ANitwork.hpp | 7 ++-- src/Nitwork/NitworkClient.cpp | 2 +- src/Nitwork/NitworkServer.cpp | 16 +++++----- src/Nitwork/NitworkServer.hpp | 27 ++++++++-------- src/Server/Systems/Network/ServerNetwork.cpp | 2 +- src/Server/Systems/WaveSystem.cpp | 17 ++++++---- src/Server/Systems/WaveSystem.hpp | 4 +-- src/init.cpp | 14 ++++---- src/init.hpp | 11 ++++++- 23 files changed, 172 insertions(+), 137 deletions(-) diff --git a/src/Client/Systems/Events/EventsSystems.cpp b/src/Client/Systems/Events/EventsSystems.cpp index 7e308986..95c6bb94 100644 --- a/src/Client/Systems/Events/EventsSystems.cpp +++ b/src/Client/Systems/Events/EventsSystems.cpp @@ -120,7 +120,7 @@ namespace Systems { Registry ®istry = Registry::getInstance(); Clock &clock_ = registry.getClock(); Registry::components arrPosition = registry.getComponents(); - Registry::components arrHealth = registry.getComponents(); + Registry::components arrHealth = registry.getComponents(); std::vector ids = registry.getEntitiesByComponents({typeid(Types::Player), typeid(Types::Position)}); @@ -164,10 +164,10 @@ namespace Systems { { bool isKeyPressed = false; std::lock_guard lock(Registry::getInstance().mutex); - Registry ®istry = Registry::getInstance(); - Registry::components arrPos = registry.getComponents(); + Registry ®istry = Registry::getInstance(); + Registry::components arrPos = registry.getComponents(); Registry::components arrHealth = registry.getComponents(); - std::vector ids = registry.getEntitiesByComponents( + std::vector ids = registry.getEntitiesByComponents( {typeid(Types::Player), typeid(Types::Position), typeid(Types::Health)}); Clock &clock_ = registry.getClock(); static std::size_t clockId = clock_.create(true); @@ -223,9 +223,8 @@ namespace Systems { static bool isGameWin() { - Registry ®istry = Registry::getInstance(); - std::vector idsPlayer = - registry.getEntitiesByComponents({typeid(Types::Player)}); + Registry ®istry = Registry::getInstance(); + std::vector idsPlayer = registry.getEntitiesByComponents({typeid(Types::Player)}); std::vector idsOtherPlayer = registry.getEntitiesByComponents({typeid(Types::OtherPlayer)}); @@ -237,15 +236,15 @@ namespace Systems { static void modifEndGameText(const std::string &endGameMessage) { - bool found = false; - const Raylib::Vector2 pos = {0, 2}; - constexpr std::size_t fontSize = 2; - const std::string textKeywordWaveEnd = "WaveText"; - const std::string textKeyWordGameEnd = "endGameText"; + bool found = false; + const Raylib::Vector2 pos = {0, 2}; + constexpr std::size_t fontSize = 2; + const std::string textKeywordWaveEnd = "WaveText"; + const std::string textKeyWordGameEnd = "endGameText"; std::vector ids = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)}); - auto &textArray = Registry::getInstance().getComponents(); + auto &textArray = Registry::getInstance().getComponents(); for (auto &id : ids) { if (textArray[id]->getKeyword() == textKeyWordGameEnd) { @@ -259,7 +258,12 @@ namespace Systems { if (found == false) { Registry::getInstance().addEntity(); - Raylib::TextShared endGameText = Raylib::Text::fromText(endGameMessage, pos, fontSize, Raylib::Color(Raylib::ColorDef::White), textKeyWordGameEnd); + Raylib::TextShared endGameText = Raylib::Text::fromText( + endGameMessage, + pos, + fontSize, + Raylib::Color(Raylib::ColorDef::White), + textKeyWordGameEnd); Registry::getInstance().getComponents().insertBack(endGameText); } } diff --git a/src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp b/src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp index 1b6548e4..df7e1e40 100644 --- a/src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp +++ b/src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp @@ -9,15 +9,15 @@ #include #include // #include "CustomTypes.hpp" -#include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga-graphics/Raylib/Raylib.hpp" +#include "B-luga-physics/ECSCustomTypes.hpp" +#include "B-luga/SceneManager.hpp" +#include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "Menu.hpp" #include "MessageTypes.h" #include "NitworkClient.hpp" -#include "B-luga/SystemManagers/SystemManagersDirector.hpp" -#include "B-luga/SceneManager.hpp" -#include "ResourcesManager.hpp" #include "Parallax.hpp" +#include "ResourcesManager.hpp" #include "init.hpp" namespace Systems { diff --git a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp index 3aa51c0f..61d2aeca 100644 --- a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp +++ b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp @@ -6,12 +6,12 @@ */ #include "ButtonCallbacks.hpp" -#include "B-luga/Logger.hpp" -#include "NitworkClient.hpp" +#include "B-luga-graphics/GraphicsCustomTypes.hpp" #include "B-luga-graphics/Raylib/Raylib.hpp" +#include "B-luga/Logger.hpp" #include "B-luga/SceneManager.hpp" +#include "NitworkClient.hpp" #include "SelectLobbySystems.hpp" -#include "B-luga-graphics/GraphicsCustomTypes.hpp" #include "init.hpp" namespace Menu { @@ -160,8 +160,8 @@ namespace Menu { for (auto &id : idsButton) { Registry::getInstance().removeEntity(id); } - auto &arrText = Registry::getInstance().getComponents(); - auto idsText = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)}); + auto &arrText = Registry::getInstance().getComponents(); + auto idsText = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)}); for (auto &id : idsText) { if (arrText[id]->getCurrentText() == "READY !") { Registry::getInstance().removeEntity(id); diff --git a/src/Client/Systems/Menus/Menu/Menu.cpp b/src/Client/Systems/Menus/Menu/Menu.cpp index ccee6181..23fd2578 100644 --- a/src/Client/Systems/Menus/Menu/Menu.cpp +++ b/src/Client/Systems/Menus/Menu/Menu.cpp @@ -79,7 +79,7 @@ namespace Menu { ? Json::getInstance().getDataFromJson(elem, "name") : ""; Types::FontSize fsz({Json::getInstance().getDataFromJson(elem, "textSize")}); - auto textComp = Raylib::Text::fromText(text); + auto textComp = Raylib::Text::fromText(text); std::size_t maxChar(Json::getInstance().getDataFromJson(elem, "maxChar")); Types::InputBox inputBox(text, name, maxChar); auto search = @@ -165,10 +165,10 @@ namespace Menu { static std::size_t initText(nlohmann::json &elem) { - std::size_t id = Registry::getInstance().addEntity(); - std::string text = Json::isDataExist(elem, "text") - ? Json::getInstance().getDataFromJson(elem, "text") - : ""; + std::size_t id = Registry::getInstance().addEntity(); + std::string text = Json::isDataExist(elem, "text") + ? Json::getInstance().getDataFromJson(elem, "text") + : ""; Raylib::TextShared textComp = Raylib::Text::fromText(text); if (Json::isDataExist(elem, "size")) { Types::FontSize fsz({Json::getInstance().getDataFromJson(elem, "size")}); @@ -177,9 +177,10 @@ namespace Menu { if (Json::isDataExist(elem, "color")) { auto search = Types::colorMatchStrings.find( Json::getInstance().getDataFromJson(elem, "color")); - Raylib::Color color = search != Types::colorMatchStrings.end() ? Types::colorMatchStrings.at( - Json::getInstance().getDataFromJson(elem, "color")) - : Raylib::Color(Raylib::ColorDef::White); + Raylib::Color color = search != Types::colorMatchStrings.end() + ? Types::colorMatchStrings.at( + Json::getInstance().getDataFromJson(elem, "color")) + : Raylib::Color(Raylib::ColorDef::White); Registry::getInstance().getComponents().insertBack(color); } if (Json::isDataExist(elem, "position")) { diff --git a/src/Client/Systems/Menus/Menu/MenuSystems.cpp b/src/Client/Systems/Menus/Menu/MenuSystems.cpp index a162511a..cc3f5200 100644 --- a/src/Client/Systems/Menus/Menu/MenuSystems.cpp +++ b/src/Client/Systems/Menus/Menu/MenuSystems.cpp @@ -6,17 +6,17 @@ */ #include "MenuSystems.hpp" -#include "B-luga-graphics/Raylib/Graphics/Graphics.hpp" #include "B-luga-graphics/AnimRect.hpp" #include "B-luga-graphics/GraphicsCustomTypes.hpp" +#include "B-luga-graphics/Raylib/Graphics/Graphics.hpp" #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga/Maths/Maths.hpp" #include "B-luga/SceneManager.hpp" -#include "NitworkClient.hpp" #include "Menu.hpp" -#include "SelectLobbySystems.hpp" +#include "NitworkClient.hpp" #include "Parallax.hpp" #include "ResourcesManager.hpp" +#include "SelectLobbySystems.hpp" #include "init.hpp" namespace Systems { @@ -195,8 +195,9 @@ namespace Systems { } try { Parallax::initParalax(); - nlohmann::json jsonData = - Json::getInstance().getDataByJsonType(ResourcesManager::getPathByJsonType(JsonType::MENU), "menu"); + nlohmann::json jsonData = Json::getInstance().getDataByJsonType( + ResourcesManager::getPathByJsonType(JsonType::MENU), + "menu"); ::Menu::MenuBuilder::getInstance().initMenuSceneEntity( Json::getInstance().getDatasFromList(jsonData)); } catch (std::runtime_error &err) { @@ -213,9 +214,7 @@ namespace Systems { case CREATE_LOBBY_SCENE: Scene::SceneManager::getInstance().changeScene(SELECT_LOBBY); break; - case SELECT_LOBBY: - Scene::SceneManager::getInstance().changeScene(MENU); - break; + case SELECT_LOBBY: Scene::SceneManager::getInstance().changeScene(MENU); break; case GAME: Nitwork::NitworkClient::getInstance().disconnectLobby(); Scene::SceneManager::getInstance().changeScene(SELECT_LOBBY); diff --git a/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp b/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp index bed782f1..243a6dd5 100644 --- a/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp +++ b/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp @@ -15,8 +15,8 @@ #include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "Menu.hpp" #include "MessageTypes.h" -#include "Parallax.hpp" #include "NitworkClient.hpp" +#include "Parallax.hpp" #include "ResourcesManager.hpp" #include "init.hpp" @@ -37,8 +37,9 @@ namespace Systems::SelectLobbySystems { } try { Parallax::initParalax(); - nlohmann::json jsonData = - Json::getInstance().getDataByJsonType(ResourcesManager::getPathByJsonType(JsonType::SELECT_LOBBY), "lobbyMenu"); + nlohmann::json jsonData = Json::getInstance().getDataByJsonType( + ResourcesManager::getPathByJsonType(JsonType::SELECT_LOBBY), + "lobbyMenu"); ::Menu::MenuBuilder::getInstance().initMenuSceneEntity( Json::getInstance().getDatasFromList(jsonData)); } catch (const std::exception &err) { @@ -88,7 +89,9 @@ namespace Systems::SelectLobbySystems { arrPosition[id].y += offset * i; } if (arrLobbyText.exist(id)) { - Raylib::Vector2 pos(arrLobbyText[id]->getPosition().x, arrLobbyText[id]->getPosition().y); + Raylib::Vector2 pos( + arrLobbyText[id]->getPosition().x, + arrLobbyText[id]->getPosition().y); pos.y += Maths::intToFloatConservingDecimals(offset) * i; arrLobbyText[id]->setPosition(pos); } @@ -120,7 +123,7 @@ namespace Systems::SelectLobbySystems { + gameTypeToString(arrLobby[ids[index]].gameType); arrLobbyStatus[lobbyStatusId].ip = std::string(arrLobby[ids[index]].lobbyInfos.ip); arrLobbyStatus[lobbyStatusId].port = arrLobby[ids[index]].lobbyInfos.port; - Raylib::TextShared text = Raylib::Text::fromText(text_t); + Raylib::TextShared text = Raylib::Text::fromText(text_t); if (arrLobbyText.exist(lobbyStatusId)) { arrLobbyText[lobbyStatusId]->setCurrentText(text_t); } @@ -143,8 +146,8 @@ namespace Systems::SelectLobbySystems { } Registry::getInstance().getClock().decreaseSeconds(clockId, 1); // list of all lobby - auto idsLobbyStatus = - Registry::getInstance().getEntitiesByComponents({typeid(LobbyStatus), typeid(Raylib::TextShared)}); + auto idsLobbyStatus = Registry::getInstance().getEntitiesByComponents( + {typeid(LobbyStatus), typeid(Raylib::TextShared)}); auto idsClickableLobbys = Registry::getInstance().getEntitiesByComponents( {typeid(LobbyStatus), typeid(Raylib::TextShared), typeid(Types::InputBox)}); auto ids = Registry::getInstance().getEntitiesByComponents({typeid(struct lobby_s)}); diff --git a/src/Client/Systems/Network/ClientNetwork.cpp b/src/Client/Systems/Network/ClientNetwork.cpp index 21a37488..26b99c0b 100644 --- a/src/Client/Systems/Network/ClientNetwork.cpp +++ b/src/Client/Systems/Network/ClientNetwork.cpp @@ -1,5 +1,7 @@ #include "ClientNetwork.hpp" #include +#include "B-luga-graphics/Raylib/Events/Inputs.hpp" +#include "B-luga-graphics/Raylib/Graphics/Graphics.hpp" #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga-physics/ECSSystems.hpp" #include "B-luga/Json.hpp" @@ -7,23 +9,21 @@ #include "B-luga/Registry.hpp" #include "B-luga/SceneManager.hpp" #include "B-luga/SystemManagers/SystemManagersDirector.hpp" -#include "B-luga-graphics/Raylib/Events/Inputs.hpp" -#include "B-luga-graphics/Raylib/Graphics/Graphics.hpp" #include "CreateMissiles.hpp" +#include "EventsSystems.hpp" #include "GameSystems.hpp" #include "NitworkClient.hpp" -#include "EventsSystems.hpp" #include "init.hpp" namespace Systems { void receiveLifeUpdate(std::any &any, boost::asio::ip::udp::endpoint & /* unused */) { std::lock_guard lock(Registry::getInstance().mutex); - auto msg = std::any_cast(any); - Registry ®istry = Registry::getInstance(); + auto msg = std::any_cast(any); + Registry ®istry = Registry::getInstance(); Registry::components arrHealth = registry.getComponents(); - std::vector ids = Registry::getInstance().getEntitiesByComponents( - {typeid(Types::Health), typeid(Types::Player)}); + std::vector ids = + Registry::getInstance().getEntitiesByComponents({typeid(Types::Health), typeid(Types::Player)}); if (ids.empty()) { return; @@ -39,8 +39,8 @@ namespace Systems { std::lock_guard lock(Registry::getInstance().mutex); const auto enemyDeath = std::any_cast(any); Registry::components enemies = Registry::getInstance().getComponents(); - auto &arrHealth = Registry::getInstance().getComponents(); - std::vector ids = enemies.getExistingsId(); + auto &arrHealth = Registry::getInstance().getComponents(); + std::vector ids = enemies.getExistingsId(); for (auto id : ids) { if (enemies[id].getConstId().id == enemyDeath.enemyId.id) { @@ -84,8 +84,7 @@ namespace Systems { const auto wave = std::any_cast(any); Types::WaveInfos::getInstance().setWaveId(wave.waveId); Types::WaveInfos::getInstance().setWaitingForNextWave(false); - director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)) - .addSystem(initWave); + director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)).addSystem(initWave); Logger::info("Wave started"); } @@ -268,8 +267,8 @@ namespace Systems { Logger::error("Error: missile not created"); return; } - missiles[id].constId = msgNewBullet.id; - health[id].hp = msgNewBullet.life; + missiles[id].constId = msgNewBullet.id; + health[id].hp = msgNewBullet.life; } void receiveBroadcastAbsolutePosition(std::any &any, boost::asio::ip::udp::endpoint & /* unused*/) @@ -303,8 +302,8 @@ namespace Systems { auto &arrPlayer = Registry::getInstance().getComponents(); auto &arrOtherPlayers = Registry::getInstance().getComponents(); auto &arrHealth = Registry::getInstance().getComponents(); - auto playersIds = Registry::getInstance().getEntitiesByComponents( - {typeid(Types::Player), typeid(Types::Health)}); + auto playersIds = + Registry::getInstance().getEntitiesByComponents({typeid(Types::Player), typeid(Types::Health)}); auto otherPlayersIds = Registry::getInstance().getEntitiesByComponents( {typeid(Types::OtherPlayer), typeid(Types::Health)}); @@ -399,7 +398,7 @@ namespace Systems { } } - void receiveEndGame(std::any& /*unused*/, boost::asio::ip::udp::endpoint& /*unused*/) + void receiveEndGame(std::any & /*unused*/, boost::asio::ip::udp::endpoint & /*unused*/) { auto &director = SystemManagersDirector::getInstance(); std::lock_guard lock(director.mutex); diff --git a/src/Game/CreateMissiles.cpp b/src/Game/CreateMissiles.cpp index cbb0d9b4..41282e68 100644 --- a/src/Game/CreateMissiles.cpp +++ b/src/Game/CreateMissiles.cpp @@ -14,9 +14,9 @@ #include "PhysicSystems.hpp" #include "ResourcesManager.hpp" #ifdef CLIENT - #include "B-luga-graphics/Raylib/Raylib.hpp" #include "B-luga-graphics/AnimRect.hpp" #include "B-luga-graphics/GraphicsCustomTypes.hpp" + #include "B-luga-graphics/Raylib/Raylib.hpp" #include "NitworkClient.hpp" #endif @@ -63,8 +63,10 @@ namespace Systems { Json &json = Json::getInstance(); Registry::components arrSounds = Registry::getInstance().getComponents(); - nlohmann::json bulletData = - json.getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::BULLETS), getMissileIdFromType(typeOfMissile.type), "bullets"); + nlohmann::json bulletData = json.getJsonObjectById( + ResourcesManager::getPathByJsonType(JsonType::BULLETS), + getMissileIdFromType(typeOfMissile.type), + "bullets"); const std::string soundPathShoot = json.getDataFromJson(bulletData, "soundPath"); @@ -80,7 +82,7 @@ namespace Systems { #ifdef CLIENT static void addSpriteRectsForBullet(nlohmann::json &bulletData, Types::CollisionRect &collisionRect) { - Json &json = Json::getInstance(); + Json &json = Json::getInstance(); const std::string bulletPath = json.getDataFromJson(bulletData, "spritePath"); Types::Rect spriteRect = json.getDataFromJson(bulletData, "spriteRect"); Types::SpriteDatas @@ -102,17 +104,19 @@ namespace Systems { if (typeOfMissile.type >= MAX_MISSILE_TYPE || typeOfMissile.type < 0) { throw std::runtime_error("Unknown missile type"); } - Json &json = Json::getInstance(); - std::size_t id = Registry::getInstance().addEntity(); - nlohmann::json bulletData = - json.getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::BULLETS), getMissileIdFromType(typeOfMissile.type), "bullets"); + Json &json = Json::getInstance(); + std::size_t id = Registry::getInstance().addEntity(); + nlohmann::json bulletData = json.getJsonObjectById( + ResourcesManager::getPathByJsonType(JsonType::BULLETS), + getMissileIdFromType(typeOfMissile.type), + "bullets"); Types::CollisionRect collisionRect = json.getDataFromJson(bulletData, "collisionRect"); Types::Velocity velocity = json.getDataFromJson(bulletData, "velocity"); Types::Missiles missileType = typeOfMissile; Types::Dead deadComp = {}; Types::PlayerAllies playerAlliesComp = {}; - Types::Health healthComp = {json.getDataFromJson(bulletData, "health")}; + Types::Health healthComp = {json.getDataFromJson(bulletData, "health")}; Types::Damage damageComp = {json.getDataFromJson(bulletData, "damage")}; #ifdef CLIENT @@ -137,14 +141,16 @@ namespace Systems { { Json &json = Json::getInstance(); Registry::getInstance().addEntity(); - nlohmann::json bulletData = - json.getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::BULLETS), getMissileIdFromType(typeOfMissile.type), "bullets"); + nlohmann::json bulletData = json.getJsonObjectById( + ResourcesManager::getPathByJsonType(JsonType::BULLETS), + getMissileIdFromType(typeOfMissile.type), + "bullets"); Types::CollisionRect collisionRect = json.getDataFromJson(bulletData, "collisionRect"); Types::Missiles missileType = typeOfMissile; Types::Dead deadComp = {}; Types::EnemyAllies enemyAlliesComp = {}; - Types::Health healthComp = {json.getDataFromJson(bulletData, "health")}; + Types::Health healthComp = {json.getDataFromJson(bulletData, "health")}; Types::Damage damageComp = {json.getDataFromJson(bulletData, "damage")}; #ifdef CLIENT diff --git a/src/Game/GameCustomTypes.cpp b/src/Game/GameCustomTypes.cpp index 845f14ff..df3caaa8 100644 --- a/src/Game/GameCustomTypes.cpp +++ b/src/Game/GameCustomTypes.cpp @@ -31,7 +31,7 @@ namespace Types { const std::string textKeyword = "WaveText"; std::vector ids = registry.getEntitiesByComponents({typeid(Raylib::TextShared)}); Registry::components arrCol = registry.getComponents(); - static constexpr float fontSize = 4.0F; + static constexpr float fontSize = 4.0F; if (value == false) { for (auto &id : ids) { @@ -51,7 +51,12 @@ namespace Types { } } Registry::getInstance().addEntity(); - Raylib::TextShared endWaveText = Raylib::Text::fromText(text, {20, 10}, fontSize, Raylib::Color(Raylib::ColorDef::White), textKeyword); + Raylib::TextShared endWaveText = Raylib::Text::fromText( + text, + {20, 10}, + fontSize, + Raylib::Color(Raylib::ColorDef::White), + textKeyword); Registry::getInstance().getComponents().insertBack(endWaveText); } #endif diff --git a/src/Game/GameSystems.cpp b/src/Game/GameSystems.cpp index b32f54ea..48756bcc 100644 --- a/src/Game/GameSystems.cpp +++ b/src/Game/GameSystems.cpp @@ -2,10 +2,10 @@ #include "B-luga/Json.hpp" #include "B-luga/Maths/Maths.hpp" #include "B-luga/SystemManagers/SystemManagersDirector.hpp" +#include "CreateMissiles.hpp" #include "DeathSystems.hpp" #include "GameCustomTypes.hpp" #include "ResourcesManager.hpp" -#include "CreateMissiles.hpp" #include "WaveSystemsAll.hpp" #ifdef CLIENT #include "B-luga-graphics/AnimRect.hpp" @@ -157,7 +157,7 @@ namespace Systems { std::vector> deathSystems = DeathSystems::getDeathSystems(); std::vector> bulletSystems = getBulletsSystems(); - std::vector> waveSystems = getWaveSystems(); + std::vector> waveSystems = getWaveSystems(); gameSystems.insert(gameSystems.end(), deathSystems.begin(), deathSystems.end()); gameSystems.insert(gameSystems.end(), bulletSystems.begin(), bulletSystems.end()); diff --git a/src/Game/PhysicSystems.cpp b/src/Game/PhysicSystems.cpp index eec2e370..4d395161 100644 --- a/src/Game/PhysicSystems.cpp +++ b/src/Game/PhysicSystems.cpp @@ -10,14 +10,14 @@ #include #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga/Maths/Maths.hpp" -#include "MessageTypes.h" #include "B-luga/Registry.hpp" +#include "MessageTypes.h" // #include "Systems.hpp" #ifdef CLIENT // #include "CustomTypes.hpp" - #include "NitworkClient.hpp" #include "B-luga-graphics/Raylib/Raylib.hpp" + #include "NitworkClient.hpp" #else #include "NitworkServer.hpp" #endif diff --git a/src/Game/ResourcesManager.hpp b/src/Game/ResourcesManager.hpp index 5beb4347..0c7558b9 100644 --- a/src/Game/ResourcesManager.hpp +++ b/src/Game/ResourcesManager.hpp @@ -22,15 +22,15 @@ enum class JsonType : std::size_t { namespace ResourcesManagerValues { const std::vector paths = { - "assets/Json/playerData.json" , - "assets/Json/parallaxData.json", - "assets/Json/waves.json" , - "assets/Json/bullets.json" , - "assets/Json/menu.json" , - "assets/Json/selectLobby.json" , - "assets/Json/createLobby.json" , - "assets/Json/HUD.json" , - "assets/Json/enemies.json" , + "assets/Json/playerData.json", + "assets/Json/parallaxData.json", + "assets/Json/waves.json", + "assets/Json/bullets.json", + "assets/Json/menu.json", + "assets/Json/selectLobby.json", + "assets/Json/createLobby.json", + "assets/Json/HUD.json", + "assets/Json/enemies.json", }; } diff --git a/src/Game/WaveSystemsAll.cpp b/src/Game/WaveSystemsAll.cpp index 320551a8..99265ea4 100644 --- a/src/Game/WaveSystemsAll.cpp +++ b/src/Game/WaveSystemsAll.cpp @@ -15,16 +15,16 @@ #include "B-luga/Maths/Maths.hpp" #include "B-luga/Registry.hpp" #include "B-luga/SystemManagers/SystemManagersDirector.hpp" +#include "CreateMissiles.hpp" #include "GameCustomTypes.hpp" #include "PhysicSystems.hpp" #include "ResourcesManager.hpp" -#include "CreateMissiles.hpp" // #include "Systems.hpp" #ifdef CLIENT // #include "CustomTypes.hpp" - #include "NitworkClient.hpp" #include "B-luga-graphics/Raylib/Raylib.hpp" + #include "NitworkClient.hpp" #else #include "NitworkServer.hpp" #endif @@ -68,7 +68,10 @@ namespace Systems { Json &json = Json::getInstance(); const std::string enemyId = getEnemyId(enemyType); - nlohmann::json data = json.getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::ENEMIES), enemyId, "enemies"); + nlohmann::json data = json.getJsonObjectById( + ResourcesManager::getPathByJsonType(JsonType::ENEMIES), + enemyId, + "enemies"); return data; } @@ -141,7 +144,7 @@ namespace Systems { Types::Enemy enemyComp = (setId ? Types::Enemy(enemyType, enemyId) : Types::Enemy(enemyType)); Types::CollisionRect collisionRect = Json::getInstance().getDataFromJson(enemyData, "collisionRect"); - Types::Damage damageComp = {Json::getInstance().getDataFromJson(enemyData, "damage")}; + Types::Damage damageComp = {Json::getInstance().getDataFromJson(enemyData, "damage")}; Types::Health healthComp = {Json::getInstance().getDataFromJson(enemyData, "health")}; Types::Velocity velocity = Json::getInstance().getDataFromJson(enemyData, "velocity"); diff --git a/src/Nitwork/ANitwork.cpp b/src/Nitwork/ANitwork.cpp index de4d87f6..cf0dacb8 100644 --- a/src/Nitwork/ANitwork.cpp +++ b/src/Nitwork/ANitwork.cpp @@ -247,7 +247,8 @@ namespace Nitwork { try { action.second(action.first.data, action.first.endpoint); } catch (std::exception &e) { - Logger::error("StartInputHandler: NITWORK: catch action: " + std::string(e.what())); + Logger::error( + "StartInputHandler: NITWORK: catch action: " + std::string(e.what())); } } _actions.clear(); diff --git a/src/Nitwork/ANitwork.hpp b/src/Nitwork/ANitwork.hpp index cc1dfba7..9475feb8 100644 --- a/src/Nitwork/ANitwork.hpp +++ b/src/Nitwork/ANitwork.hpp @@ -12,11 +12,11 @@ #include #include #include +#include #include #include "B-luga/Logger.hpp" #include "INitwork.hpp" #include "Zstd.hpp" -#include namespace Nitwork { @@ -66,13 +66,14 @@ namespace Nitwork { } #ifdef DEBUG if constexpr (!std::is_same_v) { - Logger::fatal("id of packet = " + std::to_string(id) + " action type = " + std::to_string(data.action.magick)); + Logger::fatal( + "id of packet = " + std::to_string(id) + + " action type = " + std::to_string(data.action.magick)); } #endif std::shared_ptr> compressedPacket = std::make_shared>(Zstd::compress(data)); - _socket.async_send_to( boost::asio::buffer(*compressedPacket), packet.endpoint, diff --git a/src/Nitwork/NitworkClient.cpp b/src/Nitwork/NitworkClient.cpp index e5f27b55..2e7c1724 100644 --- a/src/Nitwork/NitworkClient.cpp +++ b/src/Nitwork/NitworkClient.cpp @@ -8,8 +8,8 @@ #if defined(_WIN32) #define _CRT_SECURE_NO_WARNINGS #endif -#include "B-luga/Logger.hpp" #include "NitworkClient.hpp" +#include "B-luga/Logger.hpp" #include "B-luga/Registry.hpp" namespace Nitwork { diff --git a/src/Nitwork/NitworkServer.cpp b/src/Nitwork/NitworkServer.cpp index 03943baa..5758d2ba 100644 --- a/src/Nitwork/NitworkServer.cpp +++ b/src/Nitwork/NitworkServer.cpp @@ -13,8 +13,8 @@ #include "B-luga-physics/ECSSystems.hpp" #include "B-luga/Logger.hpp" #include "B-luga/Registry.hpp" -#include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "B-luga/SceneManager.hpp" +#include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "GameSystems.hpp" #include "ResourcesManager.hpp" #include "WaveSystem.hpp" @@ -89,7 +89,7 @@ namespace Nitwork { // cppcoreguidelines-pro-bounds-pointer-arithmetic) auto action = *actionPtr; - auto it = _actionsHandlers.find(action.magick); + auto it = _actionsHandlers.find(action.magick); std::memmove( _receiveBuffer.data(), _receiveBuffer.data() + sizeof(struct action_s), @@ -264,7 +264,8 @@ namespace Nitwork { _isGameStarted = true; auto &director = Systems::SystemManagersDirector::getInstance(); std::lock_guard lock(director.mutex); - director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)).addSystem(Systems::waveHandler); // le sheeiiiiiitan VERIF + director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)) + .addSystem(Systems::waveHandler); // le sheeiiiiiitan VERIF } void @@ -305,8 +306,9 @@ namespace Nitwork { Logger::error("Error: magick is not MAGICK_DISCONNECT_LOBBY"); return; } - Logger::fatal("Client disconnected: " + endpoint.address().to_string() + ":" - + std::to_string(endpoint.port())); + Logger::fatal( + "Client disconnected: " + endpoint.address().to_string() + ":" + + std::to_string(endpoint.port())); _endpoints.erase(std::remove(_endpoints.begin(), _endpoints.end(), endpoint)); deletePacketFromEndPoints(endpoint); addPlayerDeathMsg(getPlayerId(endpoint)); @@ -548,9 +550,7 @@ namespace Nitwork { .action = {.magick = NITWORK_END_GAME}, .msg = {.magick = MAGICK_END_GAME} }; - Packet packet( - packetEndGame.action.magick, - std::make_any(packetEndGame)); + Packet packet(packetEndGame.action.magick, std::make_any(packetEndGame)); sendToAllClients(packet); } diff --git a/src/Nitwork/NitworkServer.hpp b/src/Nitwork/NitworkServer.hpp index 39641a61..1b55f285 100644 --- a/src/Nitwork/NitworkServer.hpp +++ b/src/Nitwork/NitworkServer.hpp @@ -356,52 +356,53 @@ namespace Nitwork { {NITWORK_CONNECT_LOBBY_RESP, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_INIT, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_LIFE_UPDATE, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_START_WAVE, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_ENEMY_DEATH, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_NEW_ENEMY, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_NEW_MISSILE, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_NEW_PLAYER, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_POSITION_RELATIVE_BROADCAST, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_POSITION_ABSOLUTE_BROADCAST, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_PLAYER_DEATH, [this](Packet &packet) { sendData(packet); - } }, + }}, {NITWORK_MISSILE_DEATH, [this](Packet &packet) { sendData(packet); - } }, - {NITWORK_INFO_LOBBY, [this](Packet &packet) { + }}, + {NITWORK_INFO_LOBBY, + [this](Packet &packet) { sendData(packet); }}, {NITWORK_END_GAME, diff --git a/src/Server/Systems/Network/ServerNetwork.cpp b/src/Server/Systems/Network/ServerNetwork.cpp index 48d68d8e..8f835195 100644 --- a/src/Server/Systems/Network/ServerNetwork.cpp +++ b/src/Server/Systems/Network/ServerNetwork.cpp @@ -63,7 +63,7 @@ namespace Systems { .life = {.hp = arrHealth[id].hp}, .pos = {static_cast(Maths::removeIntDecimals(arrPos[id].x)), - static_cast(Maths::removeIntDecimals(arrPos[id].y))}, + static_cast(Maths::removeIntDecimals(arrPos[id].y))}, .type = arrEnemies[id].type, }); } diff --git a/src/Server/Systems/WaveSystem.cpp b/src/Server/Systems/WaveSystem.cpp index 9807ad62..8013a992 100644 --- a/src/Server/Systems/WaveSystem.cpp +++ b/src/Server/Systems/WaveSystem.cpp @@ -9,8 +9,8 @@ #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga/Json.hpp" #include "B-luga/Registry.hpp" -#include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "B-luga/SystemManagers/SystemManager.hpp" +#include "B-luga/SystemManagers/SystemManagersDirector.hpp" #include "GameCustomTypes.hpp" #include "GameSystems.hpp" #include "ResourcesManager.hpp" @@ -23,7 +23,9 @@ std::mutex Wave::_mutex; Wave::Wave() : _waveIndex(0), _msBeforeNextWave(0), _isGameEnded(false), _isTimeBetweenWaves(false) { try { - _wavesId = Json::getInstance().getObjectsIdInArray(ResourcesManager::getPathByJsonType(JsonType::WAVE), "waves"); + _wavesId = Json::getInstance().getObjectsIdInArray( + ResourcesManager::getPathByJsonType(JsonType::WAVE), + "waves"); } catch (const std::exception &e) { Logger::fatal("WaveInit: " + std::string(e.what())); } @@ -48,9 +50,11 @@ void Wave::startNextWave() return; } try { - std::size_t id = _wavesId.at(_waveIndex); - nlohmann::json waveData = - Json::getInstance().getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::WAVE), id, "waves"); + std::size_t id = _wavesId.at(_waveIndex); + nlohmann::json waveData = Json::getInstance().getJsonObjectById( + ResourcesManager::getPathByJsonType(JsonType::WAVE), + id, + "waves"); _msBeforeNextWave = Json::getInstance().getDataFromJson(waveData, "msBeforeNextWave"); Types::WaveInfos::getInstance().setWaveId(static_cast(id)); server.addStarWaveMessage(static_cast(_wavesId.at(_waveIndex))); @@ -60,7 +64,8 @@ void Wave::startNextWave() _isGameEnded = true; return; } - director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)).addSystem(Systems::initWave); + director.getSystemManager(static_cast(SystemManagers::GAME_LOGIC)) + .addSystem(Systems::initWave); } bool Wave::isWaveEnded() const diff --git a/src/Server/Systems/WaveSystem.hpp b/src/Server/Systems/WaveSystem.hpp index ef70959b..e5f0bdc4 100644 --- a/src/Server/Systems/WaveSystem.hpp +++ b/src/Server/Systems/WaveSystem.hpp @@ -8,13 +8,12 @@ #pragma once #include -#include #include +#include #include "NitworkServer.hpp" class Wave { public: - Wave(); void startNextWave(); bool isWaveEnded() const; @@ -25,7 +24,6 @@ class Wave { static std::size_t _clockId; private: - std::vector _wavesId; int _waveIndex; std::size_t _msBeforeNextWave; diff --git a/src/init.cpp b/src/init.cpp index f0f3582b..d8b58759 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -8,10 +8,10 @@ #ifdef CLIENT #include "B-luga-graphics/GraphicsSystems.hpp" #include "ClientNetwork.hpp" + #include "CreateLobbySystems.hpp" #include "EventsSystems.hpp" #include "MenuSystems.hpp" #include "SelectLobbySystems.hpp" - #include "CreateLobbySystems.hpp" #endif static std::vector enumListTosizet(std::vector list) @@ -39,11 +39,11 @@ void initScenes() std::map>()>> systems = { #ifdef CLIENT - {SystemManagers::EVENTS, &Systems::EventsSystems::getEventsSystems }, - {SystemManagers::CLIENTNETWORK, &Systems::getNetworkSystems }, - {SystemManagers::MENU_SYSTEMS, &Systems::Menu::getMenuSystems }, - {SystemManagers::NETWORK_MENU, &Systems::SelectLobbySystems::getLobbySystems}, - {SystemManagers::NETWORK_CREATE_LOBBY, &Systems::CreateLobby::getCreateLobbySystems}, + {SystemManagers::EVENTS, &Systems::EventsSystems::getEventsSystems }, + {SystemManagers::CLIENTNETWORK, &Systems::getNetworkSystems }, + {SystemManagers::MENU_SYSTEMS, &Systems::Menu::getMenuSystems }, + {SystemManagers::NETWORK_MENU, &Systems::SelectLobbySystems::getLobbySystems}, + {SystemManagers::NETWORK_CREATE_LOBBY, &Systems::CreateLobby::getCreateLobbySystems }, #endif }; @@ -73,7 +73,7 @@ void initScenes() SystemManagers::MENU_SYSTEMS}); sceneManager.setScenes({menu, selectLobby, createLobby, mainScene}); #else - auto scene = enumListTosizet({SystemManagers::ECSSYSTEMS, SystemManagers::GAME_LOGIC}); + auto scene = enumListTosizet({SystemManagers::ECSSYSTEMS, SystemManagers::GAME_LOGIC}); auto scene2 = std::vector(); sceneManager.setScenes({scene, scene2}); #endif diff --git a/src/init.hpp b/src/init.hpp index 4329a5ca..9cf9dd02 100644 --- a/src/init.hpp +++ b/src/init.hpp @@ -1,6 +1,15 @@ #pragma once -enum SystemManagers { EVENTS, ECSSYSTEMS, GAME_LOGIC, CLIENTNETWORK, GRAPHICS, MENU_SYSTEMS, NETWORK_MENU, NETWORK_CREATE_LOBBY }; +enum SystemManagers { + EVENTS, + ECSSYSTEMS, + GAME_LOGIC, + CLIENTNETWORK, + GRAPHICS, + MENU_SYSTEMS, + NETWORK_MENU, + NETWORK_CREATE_LOBBY +}; enum Scenes { MENU, SELECT_LOBBY, CREATE_LOBBY_SCENE, GAME };