From ff39fc6e40eda76de2d051f1794b15eaf360ee0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Thu, 17 Jun 2021 22:57:12 +0200 Subject: [PATCH] fixing compil but linkage issues --- sources/Parser/ParserYaml.cpp | 4 ++-- sources/Parser/ParserYaml.hpp | 15 +++++++-------- sources/System/Lobby/LobbySystem.cpp | 12 ++++++------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sources/Parser/ParserYaml.cpp b/sources/Parser/ParserYaml.cpp index 22ea3eaa..d2bc328e 100644 --- a/sources/Parser/ParserYaml.cpp +++ b/sources/Parser/ParserYaml.cpp @@ -227,7 +227,7 @@ namespace BBM { for (int j = 0; j < Runner::mapHeight; j++) map[std::make_tuple(i, 0, j)] = MapGenerator::NOTHING; auto childNode = node.getChildNodes("blocks").at(0).getChildNodes(); - for (auto child : childNode) + for (const auto& child : childNode) _loadBlock(scene, child, map); MapGenerator::loadMap(Runner::mapWidth, Runner::mapHeight, map, scene); } @@ -262,7 +262,7 @@ namespace BBM { _loadPlayers(gameScene, playerInfos); } - Vector3f ParserYAML::_parsePosition(std::string line) + Vector3f ParserYAML::_parsePosition(const std::string& line) { float x; float y; diff --git a/sources/Parser/ParserYaml.hpp b/sources/Parser/ParserYaml.hpp index 0802ac40..d4a350da 100644 --- a/sources/Parser/ParserYaml.hpp +++ b/sources/Parser/ParserYaml.hpp @@ -55,7 +55,7 @@ namespace BBM { static float _parseSpeed(const std::string& line); //!@param line to parse //!@brief return vector3f of position parsed - static Vector3f _parsePosition(std::string line); + static Vector3f _parsePosition(const std::string& line); //!@param blockType to parse //!@brief return BlockType of type parsed static MapGenerator::BlockType _parseBlockType(const std::string& blockType); @@ -106,19 +106,18 @@ namespace BBM { static Node parseFile(const std::string &path); - struct PlayerInfos { - std::string playerName; + std::string name; //! @brief Player position - Vector3f playerPosition; + Vector3f position; //! @brief The amount of bomb a player had - int playerBombCount; + int maxBombCount; //! @brief The explosion range of a player - int playerExplosionRange; + int explosionRange; //! @brief The speed of a player - float playerSpeed; + float speed; //! @brief The assets of the player - std::string playerAssets; + std::string asset; }; static std::vector playersInfos; diff --git a/sources/System/Lobby/LobbySystem.cpp b/sources/System/Lobby/LobbySystem.cpp index a502732b..18255b4d 100644 --- a/sources/System/Lobby/LobbySystem.cpp +++ b/sources/System/Lobby/LobbySystem.cpp @@ -300,18 +300,18 @@ namespace BBM std::cout << i << std::endl; i++; auto &player = Runner::createPlayer(*scene); - player.setName(ParserYAML::playerName[countPlayer]); + player.setName(ParserYAML::playersInfos[countPlayer].name); auto *position = player.tryGetComponent(); auto *bombHolder = player.tryGetComponent(); auto *model = player.tryGetComponent(); auto *controllable = player.tryGetComponent(); if (position && bombHolder && model && controllable) { dynamic_cast(model->drawable.get())->setTextureToMaterial(MAP_DIFFUSE, - ParserYAML::playerAssets[countPlayer]); - position->position = ParserYAML::playerPosition[countPlayer]; - bombHolder->explosionRadius = ParserYAML::playerExplosionRange[countPlayer]; - bombHolder->maxBombCount = ParserYAML::playerBombCount[countPlayer]; - controllable->speed = ParserYAML::playerSpeed[countPlayer]; + ParserYAML::playersInfos[countPlayer].asset); + position->position = ParserYAML::playersInfos[countPlayer].position; + bombHolder->explosionRadius = ParserYAML::playersInfos[countPlayer].explosionRange; + bombHolder->maxBombCount = ParserYAML::playersInfos[countPlayer].maxBombCount; + controllable->speed = ParserYAML::playersInfos[countPlayer].speed; } addController(player, lobby.layout); countPlayer++;