Skip to content

Commit

Permalink
Feature/rb 146 network lobby (#131)
Browse files Browse the repository at this point in the history
* SERVER-NETWORK: Add begin of MainServerNitwork

MINOR

* SERVER-NETWORK/CLIENT-NETWORK: upgrade LIST_LOBBY receive for server and
client

MINOR

* SERVER-NITWORK: Fix missing sending of LIST_LOBBY packet

PATCH

* NITWORK: Fix compil

PATCH

* SERVER-NETWORK/NITWORK: Add begin of lobby creation

MINOR

* CLIENT-NITWORK: Add function not called

MINOR

* NITWORK/SERVER-NETWORK: Add CREATE_SERVER, LIST_SERVER, INFO_SERVER, OK_SERVER actions

MAJOR

* SERVER-NETWORK/SERVER-GAME: Upgrade main_server.cpp
create a class that check args and separate lobby / main server mains

MINOR

* NITWORK-SERVER: Fix indentation of _actionToSendHandlers map

PATCH

* NITWORK: Fix compil

PATCH

* NITWORK: Fix compilation (constexpr std::string doesn't work)

PATCH

* NITWORK-CLIENT/NITWORK-MAIN-SERVER/NITWORK-SERVER: Add nitwork client
packets for main server (send and receive)
Add methods doc for NITWORK-CLIENT/NITWORK-MAIN-SERVER/NITWORK-SERVER

MAJOR

* Fix: Fix compilation on windows/macos

PATCH

* NITWORK-MAIN-SERVER: Fix compilation windows

PATCH

* NITWORK-MAIN-SERVER: Fix compilation windows

PATCH

* NITWORK-CLIENT/NITWORK-MAIN-SERVER/NITWORK-SERVER: Add client
connexions methods and removing ip +  port at startup
Fix double connexion for nitwork

MAJOR

* CLIENT-GAME: Fix 2 times display added for menu

PATCH

* CLIENT-NETWORK: Call the right function to connect to main server

PATCH

* CLIENT-GAME: Fix menu were in the wrong index
PATCH

* NITWORK-MAIN-SERVER/NITWORK-CLIENT: Fix wrong endpoint added to
mainserver packets
Fix help for server

PATCH

* CLIENT-NETWORK: Add create lobby

MINOR

* NITWORK-MAIN-SERVER: Fix create new lobby
wrong ip and port of owner (must be mainServer)

PATCH

* CLIENT-NETWORK: Send list loby every 2 seconds

MINOR

* FIX/FORMAT: Fix createLobby and format code

PATCH

* CLIENT-NETWORK: show current lobby

MINOR

* CLIENT: remove part that set to empty the sstring

PATCH

* CLIENT: remove set cursor that crash on wayland

PATCH

* NITWORK: Fix multiple actions handling

PATCH

* CICD: remove parallel

PATCH

* MAINSERVER-NETWORK: Fix creation of multiple lobbies with same name

PATCH

* DOC: Add documentation for nitwork.h

PATCH

* DOC/FIX: Add code doc in nitwork.h & Fix checks for new lobby

PATCH

* FIX: Fix nb threads for compilation

(giving nb_proc  -2 for threads)

PATCH

* FIX: Fix pr (code rabbit requests)

PATCH

* FIX: Fix compilation (nb threads)

PATCH

* FORMAT-AUTO: automatic format on pull request #131

* FIX: Fix macos compilation

PATCH

* FIX: Fix coderabbit requests (add try catch)

PATCH

* FIX: Fix death message responde server side

PATCH

* FORMAT-AUTO: automatic format on pull request #131

* FIX: Removing --no-parallel flag for compil.sh

PATCH

* FIX: Fix codeRabbbit requests

PATCH

---------

Co-authored-by: Xavier Mitault <[email protected]>
Co-authored-by: Kitetsu <[email protected]>
Co-authored-by: Github Actions <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 30, 2023
1 parent eda3bc9 commit ac052c7
Show file tree
Hide file tree
Showing 36 changed files with 2,035 additions and 181 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: sudo ./scripts/install-deps-linux.sh

- name: Compil
run: ./scripts/compil.sh --no-tidy
run: ./scripts/compil.sh --no-tidy --no-parallel

macos-compil:
runs-on: macos-latest
Expand Down
121 changes: 121 additions & 0 deletions assets/Json/selectLobby.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"menu": {
"name": {
"name": "name",
"type": "input",
"font": "assets/Fonts/soliden/SolidenTrial-Black.otf",
"spritePath": "assets/R-TypeSheet/r-typesheet1.gif",
"text": "ServerOfSaverio",
"color": "red",
"textSize": 3,
"maxChar": 30,
"width": 500,
"height": 500,
"position" : {
"x": 2000,
"y": 2000
},
"rect": {
"x": 101.0,
"y": 0.0,
"width": 32.0,
"height": 19.0
},
"collisionRect": {
"width": 2000,
"height": 500
},
"animRect": [
{
"type": "hover",
"time": 80,
"noIncr": true,
"list": [
{
"x" : 233.0,
"y": 2.0,
"width": 32.0,
"height": 14.0
}
]
}
]
},
"maxNb": {
"name": "maxNb",
"type": "input",
"font": "assets/Fonts/soliden/SolidenTrial-Black.otf",
"spritePath": "assets/R-TypeSheet/r-typesheet1.gif",
"text": "2",
"color": "red",
"textSize": 3,
"maxChar": 2,
"width": 500,
"height": 500,
"position" : {
"x": 2000,
"y": 3000
},
"rect": {
"x": 101.0,
"y": 0.0,
"width": 32.0,
"height": 19.0
},
"collisionRect": {
"width": 2000,
"height": 500
},
"animRect": [
{
"type": "hover",
"time": 80,
"noIncr": true,
"list": [
{
"x" : 233.0,
"y": 2.0,
"width": 32.0,
"height": 14.0
}
]
}
]
},
"gametype_normal": {
"type": "button",
"spritePath": "assets/R-TypeSheet/r-typesheet2.gif",
"width": 500,
"height": 500,
"rect": {
"x": 101.0,
"y": 0.0,
"width": 32.0,
"height": 19.0
},
"position": {
"x": 2000,
"y": 4000
},
"collisionRect": {
"width": 500,
"height": 500
},
"animRect": [
{
"type": "hover",
"time": 80,
"noIncr": true,
"list": [
{
"x": 233.0,
"y": 2.0,
"width": 32.0,
"height": 14.0
}
]
}
]
}
}
}
13 changes: 11 additions & 2 deletions scripts/compil.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@

set -ex

if [[ "$1" == "--no-tidy" ]]; then
if [[ "$1" == "--no-tidy" ]] || [[ "$2" == "--no-tidy" ]]; then
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DNO_USE_CLANG_TIDY=true
else
cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
fi

cmake --build build --parallel
if ! command -v nproc &> /dev/null; then
cmake --build build --parallel 2
else
NB_PROC=$(nproc)
NB_THREADS=$(($NB_PROC - 2))
if [[ "$NB_PROC" -lt "3" ]]; then
NB_THREADS=1
fi
cmake --build build --parallel $NB_THREADS
fi
14 changes: 9 additions & 5 deletions src/Client/SceneManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,33 @@ namespace Scene {

enum class ReturnValue { OK = 0, RET_ERROR = 84 };

enum class Scene { MENU, MAIN_GAME, SCENE_MAX };
enum class Scene { MENU, MAIN_GAME, SELECT_LOBBY, SCENE_MAX };

enum class SystemManagers { GAME, EVENTS, DISPLAY, NETWORK, MENU };
enum class SystemManagers { GAME, EVENTS, DISPLAY, NETWORK, MENU, NETWORK_MENU };

class SceneManager {
public:
static SceneManager &getInstance();
int run();
void changeScene(Scene scene);
Scene getCurrentScene() const;
[[nodiscard]] Scene getCurrentScene() const;
void stop();

private:
SceneManager();

Scene _currentScene;
bool _stop;
const std::array<std::vector<SystemManagers>, 2> _scenes = {
const std::array<std::vector<SystemManagers>, 3> _scenes = {
{{SystemManagers::DISPLAY, SystemManagers::MENU},
{SystemManagers::EVENTS,
SystemManagers::GAME,
SystemManagers::DISPLAY,
SystemManagers::NETWORK}}
SystemManagers::NETWORK},
{SystemManagers::DISPLAY,
SystemManagers::NETWORK,
SystemManagers::NETWORK_MENU,
SystemManagers::MENU}}
};

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
Expand Down
1 change: 1 addition & 0 deletions src/Client/Systems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ add_subdirectory(Graphic)
add_subdirectory(Events)
add_subdirectory(Network)
add_subdirectory(CustomTypes)
add_subdirectory(Menus)
add_subdirectory(Menu)
6 changes: 4 additions & 2 deletions src/Client/Systems/ClientSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
#include "EventsSystems.hpp"
#include "GraphicSystems.hpp"
#include "MenuSystems.hpp"
#include "SelectLobbySystems.hpp"
#include "Systems.hpp"

namespace Systems {
std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 5> getSystemsGroups()
std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 6> getSystemsGroups()
{
return {
getECSSystems(),
EventsSystems::getEventSystems(),
GraphicSystems::getGraphicsSystems(),
getNetworkSystems(),
Menu::getMenuSystems()};
Menu::getMenuSystems(),
SelectLobbySystems::getLobbySystems()};
}
} // namespace Systems
2 changes: 1 addition & 1 deletion src/Client/Systems/ClientSystems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#include <vector>

namespace Systems {
std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 5> getSystemsGroups();
std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 6> getSystemsGroups();
} // namespace Systems
13 changes: 3 additions & 10 deletions src/Client/Systems/Menu/ButtonCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,11 @@ namespace Menu {

void initConnection()
{
std::string ip("");
std::string port("");
std::string ip;
std::string port;

getIpAndPort(ip, port);
if (!Nitwork::NitworkClient::getInstance()
.startClient(std::stoi(port.c_str()), ip.c_str(), DEFAULT_THREAD_NB, TICKS)) {
Logger::error("Error network couldn't connect");
return;
}
Nitwork::NitworkClient::getInstance().addInitMsg();
Nitwork::NitworkClient::getInstance().addReadyMsg();
Scene::SceneManager::getInstance().changeScene(Scene::Scene::MAIN_GAME);
Nitwork::NitworkClient::getInstance().connectMainServer(ip, std::stoi(port));
}
} // namespace Callback
} // namespace Menu
4 changes: 2 additions & 2 deletions src/Client/Systems/Menu/MenuSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ namespace Systems {
if (arrAnimRect.exist(id)) {
arrAnimRect[id].changeRectList(Types::RectListType::HOVER);
}
Raylib::setMouseCursor(MOUSE_CURSOR_IBEAM);
// Raylib::setMouseCursor(MOUSE_CURSOR_IBEAM);
return;
}
Raylib::setMouseCursor(MOUSE_CURSOR_DEFAULT);
// Raylib::setMouseCursor(MOUSE_CURSOR_DEFAULT);
if (arrAnimRect.exist(id)) {
arrAnimRect[id].changeRectList(Types::RectListType::UNDEFINED);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Client/Systems/Menus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.15)

add_subdirectory(SelectLobby)
13 changes: 13 additions & 0 deletions src/Client/Systems/Menus/SelectLobby/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.15)

target_include_directories(
${PROJECT_NAME_CLIENT}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

target_sources(
${PROJECT_NAME_CLIENT}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/SelectLobbySystems.cpp
)
Loading

0 comments on commit ac052c7

Please sign in to comment.