-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/rb 160 fix client init protocol #138
Conversation
Merge MINOR
…B/R-Bus into feature/RB-142-menu-de-connection
…B/R-Bus into feature/RB-142-menu-de-connection
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Modif some static method inside the menu.cpp file MINOR
…B/R-Bus into feature/RB-142-menu-de-connection
…B/R-Bus into feature/RB-142-menu-de-connection
…B/R-Bus into feature/RB-142-menu-de-connection
…B/R-Bus into feature/RB-142-menu-de-connection
…B/R-Bus into feature/RB-142-menu-de-connection
…-B/R-Bus into feature/RB-142-menu-de-connection
And move good systems from list lobby scene to create lobby scene MINOR
Here is the updated walkthrough: WalkthroughThe changes primarily revolve around enhancing the game's lobby creation and selection functionality, improving the networking capabilities, and refining the graphical interface. New functions and systems have been added to handle lobby creation, selection, and connection. The networking components have been updated to handle new message types and actions. The graphical interface has been improved with new functions for text positioning and parallax effects. Changes
Poem
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 8
Configuration used: CodeRabbit UI
Files ignored due to filter (7)
- assets/Json/createLobby.json
- assets/Json/menu.json
- assets/Json/selectLobby.json
- assets/Menu/bix-box.png
- assets/Menu/button.png
- assets/Menu/input-box.png
- assets/Menu/text-box.png
Files selected for processing (36)
- src/Client/Raylib/Graphics/Graphics.cpp (1 hunks)
- src/Client/Raylib/Graphics/Graphics.hpp (1 hunks)
- src/Client/SceneManager.cpp (1 hunks)
- src/Client/SceneManager.hpp (2 hunks)
- src/Client/Systems/CMakeLists.txt (1 hunks)
- src/Client/Systems/ClientSystems.cpp (1 hunks)
- src/Client/Systems/ClientSystems.hpp (1 hunks)
- src/Client/Systems/CustomTypes/AnimRect.hpp (2 hunks)
- src/Client/Systems/Events/EventsSystems.cpp (3 hunks)
- src/Client/Systems/Graphic/GraphicSystems.cpp (1 hunks)
- src/Client/Systems/Graphic/ParallaxSystems.cpp (1 hunks)
- src/Client/Systems/Graphic/TextSystems.cpp (3 hunks)
- src/Client/Systems/Menus/CMakeLists.txt (1 hunks)
- src/Client/Systems/Menus/CreateLobby/CMakeLists.txt (1 hunks)
- src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp (1 hunks)
- src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.hpp (1 hunks)
- src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp (2 hunks)
- src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp (1 hunks)
- src/Client/Systems/Menus/Menu/Menu.cpp (3 hunks)
- src/Client/Systems/Menus/Menu/Menu.hpp (3 hunks)
- src/Client/Systems/Menus/Menu/MenuSystems.cpp (9 hunks)
- src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp (3 hunks)
- src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.hpp (1 hunks)
- src/Client/Systems/Network/ClientNetwork.cpp (4 hunks)
- src/Client/Systems/Network/ClientNetwork.hpp (1 hunks)
- src/ECS/Json.hpp (2 hunks)
- src/ECS/Systems/Systems.hpp (1 hunks)
- src/Nitwork/ANitwork.cpp (1 hunks)
- src/Nitwork/ANitwork.hpp (2 hunks)
- src/Nitwork/Nitwork.h (4 hunks)
- src/Nitwork/NitworkClient.cpp (2 hunks)
- src/Nitwork/NitworkClient.hpp (6 hunks)
- src/Nitwork/NitworkMainServer.cpp (1 hunks)
- src/Nitwork/NitworkServer.cpp (5 hunks)
- src/Nitwork/NitworkServer.hpp (4 hunks)
- src/ServerArgsHandling.hpp (1 hunks)
Files skipped from review due to trivial changes (9)
- src/Client/Raylib/Graphics/Graphics.hpp
- src/Client/SceneManager.cpp
- src/Client/Systems/CMakeLists.txt
- src/Client/Systems/Graphic/GraphicSystems.cpp
- src/Client/Systems/Graphic/ParallaxSystems.cpp
- src/Client/Systems/Menus/CMakeLists.txt
- src/Client/Systems/Network/ClientNetwork.hpp
- src/ECS/Json.hpp
- src/ServerArgsHandling.hpp
Additional comments: 79
src/Client/Raylib/Graphics/Graphics.cpp (1)
- 718-720: The
getPosition
function is now a const member function, which is a good practice as it does not modify any class members.src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp (2)
10-14: The includes seem to be in order and all necessary headers are included.
48-62: The
connectLobbySelected
function retrieves the selected input box and lobby status components from the registry and iterates over them. If an input box is selected and has a valid IP and port, it callsNitwork::NitworkClient::connectLobby()
with the corresponding IP and port values. This function seems to be logically correct, but it's important to ensure that theconnectLobby
function handles any potential connection errors.src/Client/Systems/ClientSystems.cpp (3)
14-15: New include statements for "CreateLobbySystems.hpp" and "ParallaxSystems.hpp" have been added. Ensure that these files exist and are in the correct location.
19-31: The size of the array returned by "getSystemsGroups()" has been increased from 6 to 8. This change should be reflected wherever this function is called to avoid out-of-bounds access.
- std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 6> getSystemsGroups() + std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 8> getSystemsGroups()
- 25-29: New function calls to "ParallaxSystems::getParallaxSystems()", "SelectLobbySystems::getLobbySystems()", and "CreateLobby::getCreateLobbySystems()" have been added. Ensure that these functions exist and return the expected type.
src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.hpp (2)
15-23: The
LobbyStatus
struct now includes a constructor and a static member variablepageNbr
. Ensure that these changes do not break any existing code that uses this struct. Also, consider initializingpageNbr
to a default value to avoid undefined behavior.25-25: The
sendListLobby
function signature remains unchanged. No action required.src/Client/Systems/Graphic/TextSystems.cpp (1)
- 57-59: The condition in the
if
statement is checking ifarrPosition
exists for the givenid
andarrInputBox
andarrButton
do not exist for the sameid
. This logic seems to be excludingarrInputBox
andarrButton
from affecting the position of thetext
object. If this is the intended behavior, then it's fine. However, ifarrInputBox
andarrButton
should also affect the position of thetext
object, then this condition needs to be revised.src/Client/Systems/Menus/Menu/MenuSystems.cpp (5)
6-14: The addition of
#include <iostream>
and#include "Systems.hpp"
is fine as long as they are used in the code. If not, they should be removed to avoid unnecessary includes.150-162: The
manageClick
function is a good addition for handling button clicks. It changes the button's state based on the mouse's actions and calls the button's callback when the mouse button is released. This is a good practice for handling user interactions.129-171: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [164-181]
The
pressButton
function has been updated to use the newmanageClick
function. This is a good practice as it reduces code duplication and makes the code easier to maintain.
217-228: The
quitScene
function is a good addition for handling scene quitting. It checks if the escape key is pressed and changes the current scene based on the current scene. This is a good practice for handling user interactions.235-243: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [230-241]
The addition of
Systems::moveEntities
andquitScene
to the list of exported functions is fine as long as they are used in the code. If not, they should be removed to avoid unnecessary exports.src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp (5)
24-35: The
onButtonGotoCreateLobbyClicked
function changes the scene toCREATE_LOBBY
. Ensure that theCREATE_LOBBY
scene is properly implemented and can handle the transition.41-58: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [37-58]
The
initSelectLoby
function has been updated to initialize a new menu entity for the "joinLobby" button. Ensure that the JSON data for the "joinLobby" button is correctly formatted and that theconnectLobbySelected
callback function is implemented.+ Menu::MenuBuilder::getInstance().initMenuEntity( + joinLobbyButton, + Menu::Callback::connectLobbySelected);
- 83-110: The
initLobbyRow
function has been added to initialize lobby rows. This function creates a newLobbyStatus
component for each row. Ensure that the JSON data for the "lobbyBox" is correctly formatted.+ void initLobbyRow(std::size_t managerId, std::size_t systemId) + { + // function implementation + }
- 115-157: The
updateLobbyRow
function has been added to update lobby rows. This function updates theLobbyStatus
andRaylib::Text
components of each row. Ensure that thelobby_s
struct and thegameTypeToString
function are correctly implemented.+ void updateLobbyRow(std::size_t /* unused */, std::size_t /* unused */) + { + // function implementation + }
- 159-162: The list of functions returned by
getLobbySystems
has been modified to include the new functions. Ensure that these functions are correctly implemented and can be called without any issues.- return {initSelectLoby, sendListLobby, Systems::moveEntities}; + return {initSelectLoby, initLobbyRow, updateLobbyRow, sendListLobby, Systems::moveEntities};src/ECS/Systems/Systems.hpp (1)
- 36-42: The new function
moveEntities
has been added. Ensure that it is implemented correctly and used appropriately throughout the codebase. Also, verify that the function does not introduce any potential data races when moving entities concurrently.src/Nitwork/ANitwork.cpp (2)
392-394: The function
addPacketToSend
adds a packet to the_outputQueue
. Ensure that the packet is valid before adding it to the queue.396-405: The function
deletePacketFromEndPoints
removes packets from the_outputQueue
that have the same IP address and port as the given endpoint. This function is thread-safe as it locks the_outputQueueMutex
before modifying the_outputQueue
.src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp (1)
- 12-17: The addition of the
connectLobbySelected()
function in theMenu::Callback
namespace seems to be in line with the changes described in the pull request summary. However, ensure that this function is implemented somewhere in the codebase and is being used correctly.src/Client/Systems/Menus/CreateLobby/CMakeLists.txt (1)
- 1-13: The CMakeLists.txt file is correctly set up to include the current source directory and add the "CreateLobbySystems.cpp" file to the
${PROJECT_NAME_CLIENT}
target's private sources. Ensure that the minimum required version of CMake (3.15) is installed on all systems where this project will be built.src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp (6)
25-28: This function checks if a string is a number by checking if all characters are digits. This is a good use of the
std::all_of
function.30-33: This function changes the scene to
SELECT_LOBBY
when the "Go Back" button is clicked. It's a good practice to encapsulate such actions in functions.35-57: This function retrieves the name and maximum number of players from input boxes. It checks if the maximum number of players is a number and if it's greater than 0. It's good that you're validating the input.
59-68: This function creates a lobby with the name and maximum number of players retrieved from the input boxes. It's good that you're checking if the name and maximum number of players are not empty before creating the lobby.
70-114: This function initializes the "Create Lobby" menu. It retrieves data from a JSON file and initializes menu entities with this data. It's good that you're catching exceptions that might be thrown when retrieving data from the JSON file.
116-119: This function returns a vector of functions for initializing and moving entities. It's a good practice to encapsulate such actions in functions.
src/Client/Systems/Network/ClientNetwork.cpp (6)
1-10: The inclusion of the "Raylib.hpp" header file is new. Ensure that it is necessary and that it doesn't introduce any conflicts with existing code.
143-150: The
sendInitPacket
function sends an initialization packet and removes a system from the system manager. It's important to ensure that the removal of the system doesn't cause any unintended side effects elsewhere in the code.140-154: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [152-275]
The
sendPositionRelative
function has been added. It sends the relative position of the player. Ensure that the position is being calculated correctly and that the message is being sent to the correct recipient.
336-351: The
receiveConnectLobbyResp
function has been added. It handles the response to a lobby connection request. Ensure that the response is being handled correctly and that the appropriate action is taken based on the response.353-361: The
quitGame
function has been added. It allows the player to quit the game by pressing the escape key. Ensure that the game quits cleanly and that all resources are properly cleaned up.363-366: The
getNetworkSystems
function has been modified to include the new functionssendInitPacket
,receiveConnectLobbyResp
, andquitGame
. Ensure that these functions are being called correctly and that they don't introduce any conflicts with existing code.src/Client/Systems/CustomTypes/AnimRect.hpp (2)
35-35: The addition of the
SELECTED
enum value toRectListType
is clear and straightforward. Ensure that this new enum value is properly handled in all places whereRectListType
is used.46-46: The serialization of the new
SELECTED
enum value is correct. Ensure that the serialized string "selected" is correctly handled in the JSON parsing code.src/Nitwork/NitworkClient.hpp (6)
37-40: The return type of
connectMainServer
has been changed fromvoid
tobool
. This is a breaking change and all calls to this function should be updated to handle the return value. The return value should indicate whether the connection was successful or not.47-52: Two new functions
connectLobby
anddisconnectLobby
have been added. Ensure that these functions are used correctly in the codebase.146-146: A new function
addConnectLobbyMsg
has been added. This function should be used to add a connection message to the lobby.224-236: A new action type
CONNECT_LOBBY_RESP
has been added to the_actionsHandlers
map. This action type should be used to handle responses from the lobby connection.372-379: A new action type
CONNECT_LOBBY
has been added to the_actionToSendHandlers
map. This action type should be used to send connection requests to the lobby.447-451: A new action type
DISCONNECT_LOBBY
has been added to the_actionToSendHandlers
map. This action type should be used to send disconnection requests to the lobby.src/Nitwork/NitworkClient.cpp (2)
139-156: The
disconnectLobby
function has been added. This function locks the_receivedPacketsIdsMutex
mutex, creates apacketDisconnectLobby_s
struct, and adds the packet to the send queue. This function seems to be thread-safe due to the use of the mutex, but it's important to ensure that the mutex is also locked whenever_receivedPacketsIdsMutex
is accessed elsewhere in the code to prevent data races.394-410: The
addConnectLobbyMsg
function has been added. This function locks the_receivedPacketsIdsMutex
mutex, creates apacketConnectLobby_s
struct, and adds the packet to the send queue. This function seems to be thread-safe due to the use of the mutex, but it's important to ensure that the mutex is also locked whenever_receivedPacketsIdsMutex
is accessed elsewhere in the code to prevent data races.src/Nitwork/NitworkServer.hpp (5)
59-72: The function
addConnectLobbyRespMsg
is added to send a message to the client about whether they can connect to the lobby or not. Ensure that the function is called appropriately in the codebase.208-245: The functions
handleConnectLobbyMsg
andhandleDisconnectMsg
are added to handle the connect and disconnect messages from clients. Make sure these functions are used correctly in the codebase.256-262: The boolean variable
isGameStarted
is added to track whether the game has started or not. Ensure that this variable is updated correctly throughout the game lifecycle.256-278: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [268-338]
The
_actionsHandlers
map is updated to include handlers forCONNECT_LOBBY
,DISCONNECT_LOBBY
, andCONNECT_LOBBY_RESP
message types. Make sure these handlers are implemented correctly and are being used in the appropriate places in the codebase.
- 343-350: The
_actionToSendHandlers
map is updated to include a handler forCONNECT_LOBBY_RESP
message type. Ensure that this handler is used correctly in the codebase.src/Client/SceneManager.hpp (2)
16-21: The addition of new enum values
CREATE_LOBBY
andNETWORK_CREATE_LOBBY
seems to be in line with the PR's goal of enhancing lobby creation features. Ensure that these new enum values are handled appropriately in the rest of the codebase.33-53: The
_scenes
array has been updated to include the new enum valuesPARALLAX
andNETWORK_CREATE_LOBBY
. Ensure that these changes do not break any existing functionality that relies on the_scenes
array.src/Client/Systems/ClientSystems.hpp (1)
- 13-17: The change in the size of the array returned by
getSystemsGroups
from 6 to 8 may have implications on the parts of the codebase that use this function. Ensure that all such instances are updated to handle the new array size correctly. Also, consider adding a comment to explain why the size of the array has been increased, as this would improve code readability and maintainability.namespace Systems { // Returns an array of vectors. Each vector contains functions to be executed in a specific system group. // The array size has been increased from 6 to 8 to accommodate additional system groups. std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 8> getSystemsGroups(); } // namespace Systemssrc/Client/Systems/Menus/Menu/Menu.hpp (2)
- 15-21: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [18-28]
The addition of the
SPRITE
enum value toObjectType
is a good way to extend the types of objects that can be created. Ensure that the new enum value is handled correctly in all places whereObjectType
is used.
- 64-66: The change in the return type of
initMenuEntity
fromvoid
tostd::size_t
is significant. Make sure that all calls to this function have been updated to handle the returned value correctly. Also, ensure that the function is now actually returning a value of typestd::size_t
.src/Client/Systems/Events/EventsSystems.cpp (2)
113-119: The
sendReadyPacket
function is added to send a ready packet when the R key is pressed and remove the system with the givensystemId
from the system manager with the givenmanagerId
. Ensure that the function is used correctly in the codebase and that the removal of the system does not cause any unintended side effects.220-223: The
sendReadyPacket
function is added to the list of event systems returned by thegetEventSystems
function. Ensure that the function is used correctly in the codebase.src/Client/Systems/Menus/Menu/Menu.cpp (9)
24-46: The function
initSpriteFromJson
is well-structured and follows good practices. It initializes a sprite from a JSON object and returns the ID of the created entity. The function checks if certain properties exist in the JSON object before trying to access them, which is a good practice to avoid potential runtime errors.48-65: The function
initFromSprite
is similar toinitSpriteFromJson
, but it does not create a new entity or return an ID. It seems to be used to initialize a sprite for an existing entity. The function also checks if certain properties exist in the JSON object before trying to access them.67-95: The function
initInputBoxText
initializes the text for an input box from a JSON object. It checks if certain properties exist in the JSON object before trying to access them. It also handles the case where the color is not specified in the JSON object by defaulting to white.20-108: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [97-118]
The function
initInputBox
creates a new entity and initializes an input box for it from a JSON object. It callsinitInputBoxText
to initialize the text for the input box. It checks if a sprite path is specified in the JSON object, and if not, it creates a rectangle shape for the input box.
120-135: The function
initButtonFromSprite
creates a new entity and initializes a button for it from a JSON object. It uses a sprite for the button.112-140: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [137-154]
The function
initButtonFromRectangle
is similar toinitButtonFromSprite
, but it uses a rectangle shape for the button instead of a sprite.
157-182: The function
initText
creates a new entity and initializes text for it from a JSON object. It checks if certain properties exist in the JSON object before trying to access them. It also handles the case where the color is not specified in the JSON object by defaulting to white.185-192: The function
initButton
initializes a button from a JSON object. It checks if a sprite path is specified in the JSON object, and if so, it callsinitButtonFromSprite
. Otherwise, it callsinitButtonFromRectangle
.194-203: The function
initMenuEntity
initializes a menu entity from a JSON object. It checks the type of the entity specified in the JSON object and calls the appropriate initialization function. If the type is not recognized, it logs an error message and returns 0.src/Nitwork/ANitwork.hpp (2)
112-115: The new function
deletePacketFromEndPoints
is added. Ensure that it is used correctly in the codebase and that it properly handles any potential exceptions or errors.156-157: The function
addPacketToSentPackages
is removed. Make sure that this does not break any existing functionality and that all references to this function have been removed or replaced.src/Nitwork/NitworkServer.cpp (6)
8-8: Including
<fstream>
is a good practice when file operations are performed in the code. Ensure that it is used appropriately in the code.171-189: The
handleConnectLobbyMsg
function handles a connect lobby message. It checks if the game has already started and if the maximum number of players has been reached. If the game has started or the maximum number of players has been reached, it refuses the connection. It also checks if the message magic number matches the expected magic number. If not, it logs an error and returns. If the connection can be established, it callsaddConnectLobbyRespMsg
to add a connect lobby response message.192-201: The
handleInitMsg
function handles an initialization message. It checks if the game has already started and if the maximum number of players has been reached. If the game has started or the maximum number of players has been reached, it refuses the connection.237-245: The
handleReadyMsg
function handles a ready message. It checks if the game has already started and if the client is already connected. If the game has started or the client is not connected, it refuses the connection.289-301: The
handleDisconnectMsg
function handles a disconnect message. It checks if the message magic number matches the expected magic number. If not, it logs an error and returns. If the magic number matches, it removes the client from the list of endpoints and deletes the packet from the endpoints. It then callsaddPlayerDeathMsg
to add a player death message.304-318: The
addConnectLobbyRespMsg
function adds a connect lobby response message. It creates apacketConnectLobbyResp_s
struct with the appropriate values and adds it to the list of packets to be sent.src/Nitwork/Nitwork.h (4)
18-21: The constant
MAX_MAIN_SERVER_CLIENT
has been increased from 30 to 300. This change will allow more clients to connect to the main server. However, it's important to ensure that the server can handle this increased load without performance degradation.45-50: New constants
MAGICK_CONNECT_LOBBY
,MAGICK_CONNECT_LOBBY_RESP
, andMAGICK_DISCONNECT_LOBBY
have been added. These constants are used as magic numbers to validate packets related to lobby connection and disconnection. This is a good practice for packet validation.78-83: New enum values
CONNECT_LOBBY
,CONNECT_LOBBY_RESP
, andDISCONNECT_LOBBY
have been added to then_actionType_t
enum. These new enum values will be used to identify the type of action in the packet. This is a good practice for packet processing.360-398: New message and packet structs
msgConnectLobby_s
,msgConnectLobbyResp_s
,msgDisconnectLobby_s
,packetConnectLobby_s
,packetConnectLobbyResp_s
, andpacketDisconnectLobby_s
have been added. These structs will be used to handle lobby connection and disconnection messages and packets. This is a good practice for packet processing.
getIpAndPort(ip, port); | ||
Nitwork::NitworkClient::getInstance().connectMainServer(ip, std::stoi(port)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initConnection
function retrieves the IP and port from the input boxes and attempts to connect to the main server. It's important to ensure that the std::stoi(port)
conversion doesn't throw an exception if the port isn't a valid integer. Consider adding error handling here.
|
||
void NitworkMainServer::handleInitMsg(std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint) | ||
{ | ||
if (_endpoints.size() >= _maxNbPlayer) { | ||
Logger::error("Too many clients, can't add an other one"); | ||
return; | ||
} | ||
if (isClientAlreadyConnected(endpoint)) { | ||
Logger::error("Client already connected"); | ||
Logger::info("Client already connected"); | ||
sendConnectMainServerResp(endpoint); | ||
return; | ||
} | ||
_endpoints.emplace_back(endpoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function handleInitMsg
no longer checks for the maximum number of clients. This could potentially lead to an unlimited number of clients being connected, which might cause performance issues or other unexpected behavior. Consider adding a check to ensure that the number of connected clients does not exceed a certain limit.
+ if (_endpoints.size() >= _maxNbPlayer) {
+ Logger::info("Maximum number of clients reached");
+ return;
+ }
Commitable suggestion (Beta)
void NitworkMainServer::handleInitMsg(std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint) | |
{ | |
if (_endpoints.size() >= _maxNbPlayer) { | |
Logger::error("Too many clients, can't add an other one"); | |
return; | |
} | |
if (isClientAlreadyConnected(endpoint)) { | |
Logger::error("Client already connected"); | |
Logger::info("Client already connected"); | |
sendConnectMainServerResp(endpoint); | |
return; | |
} | |
_endpoints.emplace_back(endpoint); | |
void NitworkMainServer::handleInitMsg(std::any & /* unused */, boost::asio::ip::udp::endpoint &endpoint) | |
{ | |
if (isClientAlreadyConnected(endpoint)) { | |
Logger::info("Client already connected"); | |
sendConnectMainServerResp(endpoint); | |
return; | |
} | |
if (_endpoints.size() >= _maxNbPlayer) { | |
Logger::info("Maximum number of clients reached"); | |
return; | |
} | |
_endpoints.emplace_back(endpoint); | |
} |
bool NitworkClient::connectMainServer(const std::string &ip, n_port_t port) | ||
{ | ||
Logger::info("NITWORK: connecting to main server"); | ||
setMainEndpoint(ip, port); | ||
addConnectMainServerMsg(); | ||
try { | ||
setMainEndpoint(ip, port); | ||
addConnectMainServerMsg(); | ||
} catch (const std::exception &e) { | ||
return false; | ||
} | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The connectMainServer
function has been updated to return a boolean value. This is a good practice as it allows the caller to handle the case where the connection fails. However, the exception caught in the try-catch block is not logged or rethrown, which could make debugging difficult if an exception occurs. Consider logging the exception message.
try {
setMainEndpoint(ip, port);
addConnectMainServerMsg();
} catch (const std::exception &e) {
+ Logger::error("Failed to connect to main server: " + std::string(e.what()));
return false;
}
Commitable suggestion (Beta)
bool NitworkClient::connectMainServer(const std::string &ip, n_port_t port) | |
{ | |
Logger::info("NITWORK: connecting to main server"); | |
setMainEndpoint(ip, port); | |
addConnectMainServerMsg(); | |
try { | |
setMainEndpoint(ip, port); | |
addConnectMainServerMsg(); | |
} catch (const std::exception &e) { | |
return false; | |
} | |
return true; | |
bool NitworkClient::connectMainServer(const std::string &ip, n_port_t port) | |
{ | |
try { | |
setMainEndpoint(ip, port); | |
addConnectMainServerMsg(); | |
} catch (const std::exception &e) { | |
Logger::error("Failed to connect to main server: " + std::string(e.what())); | |
return false; | |
} | |
return true; | |
} |
void NitworkClient::connectLobby(const std::string &ip, n_port_t port) | ||
{ | ||
setLobbyEndpoint(ip, port); | ||
addInitMsg(); | ||
addConnectLobbyMsg(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The connectLobby
function sets the lobby endpoint and sends a connect lobby message. However, it does not handle any potential errors that could occur when setting the endpoint or sending the message. Consider adding error handling to this function.
/* | ||
** EPITECH PROJECT, 2023 | ||
** r-type | ||
** File description: | ||
** CreateLobbySystems | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <vector> | ||
|
||
namespace Systems { | ||
namespace CreateLobby { | ||
std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>> getCreateLobbySystems(); | ||
} // namespace CreateLobby | ||
} // namespace Systems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function getCreateLobbySystems
takes two parameters that are marked as unused. If these parameters are not needed, consider removing them to avoid confusion. If they are placeholders for future use, consider adding a comment to clarify this.
- std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>> getCreateLobbySystems();
+ std::vector<std::function<void()>> getCreateLobbySystems();
Commitable suggestion (Beta)
/* | |
** EPITECH PROJECT, 2023 | |
** r-type | |
** File description: | |
** CreateLobbySystems | |
*/ | |
#pragma once | |
#include <functional> | |
#include <vector> | |
namespace Systems { | |
namespace CreateLobby { | |
std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>> getCreateLobbySystems(); | |
} // namespace CreateLobby | |
} // namespace Systems | |
/* | |
** EPITECH PROJECT, 2023 | |
** r-type | |
** File description: | |
** CreateLobbySystems | |
*/ | |
#pragma once | |
#include <functional> | |
#include <vector> | |
namespace Systems { | |
namespace CreateLobby { | |
std::vector<std::function<void()>> getCreateLobbySystems(); // The function `getCreateLobbySystems` takes two parameters that are marked as unused. If these parameters are not needed, consider removing them to avoid confusion. If they are placeholders for future use, consider adding a comment to clarify this. | |
} // namespace CreateLobby | |
} // namespace Systems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 23
Configuration used: CodeRabbit UI
Files selected for processing (21)
- src/Client/SceneManager.hpp (2 hunks)
- src/Client/Systems/ClientSystems.cpp (1 hunks)
- src/Client/Systems/CustomTypes/AnimRect.hpp (1 hunks)
- src/Client/Systems/Events/EventsSystems.cpp (3 hunks)
- src/Client/Systems/Graphic/GraphicSystems.cpp (1 hunks)
- src/Client/Systems/Graphic/ParallaxSystems.cpp (1 hunks)
- src/Client/Systems/Graphic/TextSystems.cpp (3 hunks)
- src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp (1 hunks)
- src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.hpp (1 hunks)
- src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp (2 hunks)
- src/Client/Systems/Menus/Menu/Menu.cpp (3 hunks)
- src/Client/Systems/Menus/Menu/MenuSystems.cpp (9 hunks)
- src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp (3 hunks)
- src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.hpp (1 hunks)
- src/Client/Systems/Network/ClientNetwork.cpp (4 hunks)
- src/Nitwork/ANitwork.cpp (1 hunks)
- src/Nitwork/ANitwork.hpp (1 hunks)
- src/Nitwork/Nitwork.h (4 hunks)
- src/Nitwork/NitworkClient.cpp (2 hunks)
- src/Nitwork/NitworkServer.cpp (5 hunks)
- src/Nitwork/NitworkServer.hpp (4 hunks)
Files skipped from review due to trivial changes (2)
- src/Client/Systems/Graphic/GraphicSystems.cpp
- src/Client/Systems/Graphic/ParallaxSystems.cpp
Additional comments: 47
src/Nitwork/ANitwork.hpp (1)
- 112-115: The
deletePacketFromEndPoints
function has been added. Ensure that it is implemented correctly in the corresponding .cpp file and that it is being used appropriately in the codebase. Also, consider adding a comment to describe what this function does.src/Client/Systems/CustomTypes/AnimRect.hpp (1)
- 35-47: The
RectListType
enum has been extended with a new valueSELECTED
. Ensure that all switch-case or if-else statements that use this enum are updated to handle this new value where necessary.src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.hpp (1)
- 16-23: The
LobbyStatus
struct now has a constructor and a static member variablepageNbr
. Ensure that these changes are reflected whereverLobbyStatus
is used. Also, consider initializingpageNbr
to avoid undefined behavior.struct LobbyStatus { LobbyStatus(const std::string &ip, n_port_t port) : ip(ip), port(port) {} std::string ip; n_port_t port; static std::size_t pageNbr = 0; };src/Client/Systems/Graphic/TextSystems.cpp (1)
- 57-59: The condition in the
if
statement has been modified to excludearrInputBox
andarrButton
from affecting the position of thetext
object. Ensure that this change does not introduce any unexpected behavior in the application.src/Client/SceneManager.hpp (1)
- 16-30: The addition of the
CREATE_LOBBY
value to theScene
enum class and thePARALLAX
andNETWORK_CREATE_LOBBY
values to theSystemManagers
enum class is a logical extension of the existing code. Ensure that these new enum values are handled correctly in all places where these enum classes are used.src/Nitwork/Nitwork.h (4)
18-22: The constants have been updated and new ones have been added. Ensure that these changes do not affect other parts of the code that rely on these constants. Also, verify that the new constants are used correctly throughout the codebase.
45-50: New magick numbers have been added. Ensure that these are used correctly in the code and that they do not conflict with existing magick numbers.
78-83: New action types have been added to the
n_actionType_t
enum. Make sure these new action types are handled correctly in the code where this enum is used.360-398: New message and packet structures have been added. Ensure that these structures are used correctly in the code and that they are properly initialized before use. Also, verify that the memory for these structures is correctly managed.
src/Client/Systems/ClientSystems.cpp (2)
7-14: The new include statements for "CreateLobbySystems.hpp" and "ParallaxSystems.hpp" are added. Ensure that these files exist and are in the correct location.
18-32: The function "getSystemsGroups()" now returns an array of size 8 instead of 6. This change is due to the addition of two new function calls to "CreateLobby::getCreateLobbySystems()" and "ParallaxSystems::getParallaxSystems()". Make sure that these functions are defined and return the expected type.
- std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 6> getSystemsGroups() + std::array<std::vector<std::function<void(std::size_t, std::size_t)>>, 8> getSystemsGroups()src/Client/Systems/Menus/Menu/MenuSystems.cpp (1)
- 242-250: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [237-248]
The
getMenuSystems
function returns a vector of function pointers. It's a good practice to usestd::function
for storing function pointers as it provides a level of type safety and allows for storing lambdas and functors in addition to plain function pointers.src/Nitwork/NitworkServer.hpp (4)
59-71: The function
addConnectLobbyRespMsg
is added to send a message to the client about whether they can connect to the lobby or not. This is a good addition for better client-server communication.207-245: The functions
handleConnectLobbyMsg
andhandleDisconnectMsg
are added to handle the connect and disconnect messages respectively. These functions will improve the robustness of the client-server communication.255-261: The boolean variable
isGameStarted
is added to track if the game has started or not. This is a good addition for better game state management.328-337: The
DISCONNECT_LOBBY
action handler is added to the_actionsHandlers
map. This is a good addition for better client-server communication.src/Client/Systems/Events/EventsSystems.cpp (2)
113-119: The
sendReadyPacket
function sends a ready message and removes a system from the system manager when the R key is pressed. Ensure that the removal of the system doesn't cause any unexpected behavior or crashes in the rest of the application. Also, consider adding error handling for the case when the system manager doesn't contain the specified system.220-223: The
getEventSystems
function now returns a vector that includes thesendReadyPacket
function. Ensure that all calls to this function have been updated to handle the new return value.src/Client/Systems/Network/ClientNetwork.cpp (7)
4-10: The new include "Raylib.hpp" is added. Ensure that this library is properly installed and available in the project's include paths.
143-150: The new function
sendInitPacket
is added. It sends an initialization packet and removes a system from the system manager. Ensure that the removal of the system doesn't cause any side effects in the application.140-154: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [152-275]
The new function
sendPositionRelative
is added. It sends the relative position of the player. Ensure that the position is calculated correctly and the message is sent to the correct recipient.
276-281: The new function
sendPositionAbsolute
is added. It sends the absolute position of the player. Ensure that the position is calculated correctly and the message is sent to the correct recipient.333-350: The new function
receiveConnectLobbyResp
is added. It receives a response to a lobby connection request and changes the scene accordingly. Ensure that the scene transition is handled correctly and the user is properly notified in case of a full lobby.352-360: The new function
quitGame
is added. It disconnects from the lobby and changes the scene to the lobby selection when the escape key is pressed. Ensure that the disconnection is handled correctly and the scene transition is smooth.362-365: The
getNetworkSystems
function is updated to include the new functions. Ensure that these functions are correctly integrated into the system and don't cause any conflicts with existing systems.src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp (5)
25-28: The
isNumber
function checks if a string is a number by checking if all characters are digits. This will not handle negative numbers or floating point numbers. If these are not expected inputs, this is fine. Otherwise, you may want to use a more robust method for checking if a string is a number.30-33: The
onButtonGoBackClicked
function changes the scene toSELECT_LOBBY
. Ensure that this scene exists and is properly set up to handle being switched to.35-57: The
getNameAndMaxNb
function retrieves the name and maximum number of players from input boxes. It logs an error and returns false if the maximum number of players is not a number or if either the name or maximum number of players is not provided. This function seems to be well-implemented, but you may want to consider adding error handling for whenstd::stoi
throws an exception.70-121: The
initCreateLobby
function initializes the lobby creation menu. It retrieves data from a JSON file and uses it to initialize various menu entities. It catches any exceptions thrown during this process and logs an error message. This function seems to be well-implemented, but you may want to consider adding error handling for when the JSON data does not contain the expected keys.123-127: The
getCreateLobbySystems
function returns a vector of functions to be used for initializing the lobby and moving entities. This function seems to be well-implemented.src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp (2)
24-35: The function
onButtonGotoCreateLobbyClicked
is a good refactor as it makes the code more readable and understandable. It's clear that this function is intended to handle the event of the "Create Lobby" button being clicked.163-166: The
getLobbySystems
function now includes theinitLobbyRow
andupdateLobbyRow
functions in addition to the existing functions. This is a good change as it makes the code more modular and easier to maintain.src/Client/Systems/Menus/Menu/Menu.cpp (8)
23-48: The function
initSpriteFromJson
is well-structured and follows good practices. It initializes a sprite from a JSON object and returns the ID of the created entity. The function checks if certain properties exist in the JSON object before attempting to access them, which is a good practice to avoid potential runtime errors.72-103: The function
initInputBoxText
initializes the text for an input box from a JSON object. It checks if certain properties exist in the JSON object before attempting to access them, which is a good practice to avoid potential runtime errors.20-116: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [105-125]
The function
initInputBox
creates a new entity and initializes an input box from a JSON object. It callsinitInputBoxText
to initialize the text for the input box. This is a good example of the Single Responsibility Principle, as each function has a clear, distinct purpose.
128-142: The function
initButtonFromSprite
creates a new entity and initializes a button from a JSON object. It checks if certain properties exist in the JSON object before attempting to access them, which is a good practice to avoid potential runtime errors.120-148: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [145-162]
The function
initButtonFromRectangle
is similar toinitButtonFromSprite
, but it initializes a button from a rectangle instead of a sprite. It also checks if certain properties exist in the JSON object before attempting to access them.
165-190: The function
initText
creates a new entity and initializes text from a JSON object. It checks if certain properties exist in the JSON object before attempting to access them, which is a good practice to avoid potential runtime errors.193-200: The function
initButton
decides whether to initialize a button from a sprite or a rectangle based on the properties of the JSON object. This is a good example of the Single Responsibility Principle, as each function has a clear, distinct purpose.202-210: The function
initMenuEntity
decides which function to call to initialize a menu entity based on the type of the object in the JSON object. It uses a switch statement to handle different object types, which is a good practice for handling multiple conditions.src/Nitwork/NitworkServer.cpp (7)
6-12: The addition of
<fstream>
is not used in the provided code. Ensure it's necessary.171-189: The
handleConnectLobbyMsg
function handles a connect lobby message. It checks if the game has already started and if the maximum number of clients has been reached. If these conditions are met, it refuses the connection. It also checks if the message magic number matches the expected one. If not, it logs an error and returns. If the client can connect, it adds a connect lobby response message.191-201: The
handleInitMsg
function handles an initialization message. It checks if the game has already started and if the maximum number of clients has been reached. If these conditions are met, it refuses the connection. It also locks theRegistry::getInstance().mutex
to prevent data races.236-245: The
handleReadyMsg
function handles a ready message. It checks if the game has already started and if the client is already connected. If these conditions are not met, it refuses the connection.248-256: The
handleReadyMsg
function setsisGameStarted
to true when the number of clients reaches the maximum. It also adds a start wave message and locks thedirector.mutex
to prevent data races.289-301: The
handleDisconnectMsg
function handles a disconnect message. It checks if the message magic number matches the expected one. If not, it logs an error and returns. It also removes the client from the endpoints list, deletes the packet from the endpoints, and adds a player death message.304-318: The
addConnectLobbyRespMsg
function adds a connect lobby response message. It locks the_receivedPacketsIdsMutex
to prevent data races.
/* | ||
** EPITECH PROJECT, 2023 | ||
** r-type | ||
** File description: | ||
** CreateLobbySystems | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <vector> | ||
|
||
namespace Systems { | ||
namespace CreateLobby { | ||
std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>> | ||
getCreateLobbySystems(); | ||
} // namespace CreateLobby | ||
} // namespace Systems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function getCreateLobbySystems
takes two parameters that are marked as unused. If these parameters are not needed, consider removing them to avoid confusion. If they are placeholders for future use, consider documenting this in a comment to clarify their purpose.
- std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>>
- getCreateLobbySystems();
+ std::vector<std::function<void()>>
+ getCreateLobbySystems();
Commitable suggestion (Beta)
/* | |
** EPITECH PROJECT, 2023 | |
** r-type | |
** File description: | |
** CreateLobbySystems | |
*/ | |
#pragma once | |
#include <functional> | |
#include <vector> | |
namespace Systems { | |
namespace CreateLobby { | |
std::vector<std::function<void(std::size_t /*unused*/, std::size_t /*unused*/)>> | |
getCreateLobbySystems(); | |
} // namespace CreateLobby | |
} // namespace Systems | |
/* | |
** EPITECH PROJECT, 2023 | |
** r-type | |
** File description: | |
** CreateLobbySystems | |
*/ | |
#pragma once | |
#include <functional> | |
#include <vector> | |
namespace Systems { | |
namespace CreateLobby { | |
std::vector<std::function<void()>> getCreateLobbySystems(); | |
} // namespace CreateLobby | |
} // namespace Systems |
_outputQueue.emplace_back(packet); | ||
Logger::trace("NITWORK: Adding packet to send of type: " + std::to_string(packet.action)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addPacketToSend
function is adding packets to the _outputQueue
without checking if the queue is already full or not. This could potentially lead to memory issues if the queue gets too large. Consider adding a check to ensure the queue does not exceed a certain size.
void ANitwork::deletePacketFromEndPoints(const boost::asio::ip::udp::endpoint &endpoint) | ||
{ | ||
std::lock_guard<std::mutex> lock(_outputQueueMutex); | ||
|
||
_outputQueue.remove_if([endpoint](auto &packet) { | ||
return packet.endpoint.address() == endpoint.address() | ||
&& packet.endpoint.port() == endpoint.port(); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deletePacketFromEndPoints
function is removing packets from the _outputQueue
that match a certain endpoint. This function is correctly using a lock to ensure thread safety when modifying the _outputQueue
. However, it's not checking if the _outputQueue
is empty before trying to remove elements. While this won't cause an error, it's a good practice to check if the queue is empty before trying to remove elements to avoid unnecessary computations.
+ if (_outputQueue.empty()) {
+ return;
+ }
Commitable suggestion (Beta)
void ANitwork::deletePacketFromEndPoints(const boost::asio::ip::udp::endpoint &endpoint) | |
{ | |
std::lock_guard<std::mutex> lock(_outputQueueMutex); | |
_outputQueue.remove_if([endpoint](auto &packet) { | |
return packet.endpoint.address() == endpoint.address() | |
&& packet.endpoint.port() == endpoint.port(); | |
}); | |
} | |
void ANitwork::deletePacketFromEndPoints(const boost::asio::ip::udp::endpoint &endpoint) | |
{ | |
std::lock_guard<std::mutex> lock(_outputQueueMutex); | |
if (_outputQueue.empty()) { | |
return; | |
} | |
_outputQueue.remove_if([endpoint](auto &packet) { | |
return packet.endpoint.address() == endpoint.address() | |
&& packet.endpoint.port() == endpoint.port(); | |
}); | |
} |
@@ -6,6 +6,7 @@ | |||
*/ | |||
|
|||
#include "TextSystems.hpp" | |||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including <iostream>
is not necessary unless you are using it in this file. If it's not used, it's better to remove it to reduce the compilation time and keep the code clean.
Registry::components<Types::InputBox> arrInputBox = | ||
Registry::getInstance().getComponents<Types::InputBox>(); | ||
Registry::components<Types::Button> arrButton = | ||
Registry::getInstance().getComponents<Types::Button>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The arrInputBox
and arrButton
variables are declared but not used anywhere in the code. If they are not used, consider removing them to improve readability and maintainability.
void NitworkClient::addConnectLobbyMsg() | ||
{ | ||
std::lock_guard<std::mutex> lock(_receivedPacketsIdsMutex); | ||
struct packetConnectLobby_s packetConnectLobby = { | ||
.header = {0, 0, 0, 0, 1, 0}, | ||
.action = | ||
{ | ||
.magick = CONNECT_LOBBY, | ||
}, | ||
.msg = {.magick = MAGICK_CONNECT_LOBBY}, | ||
}; | ||
Packet packet( | ||
packetConnectLobby.action.magick, | ||
std::make_any<struct packetConnectLobby_s>(packetConnectLobby), | ||
_serverEndpoint); | ||
addPacketToSend(packet); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addConnectLobbyMsg
function is thread-safe due to the use of std::lock_guard
, which is good practice when dealing with shared data. However, it does not handle any potential errors that could occur when adding the connect lobby packet to send. Consider adding error handling to this function.
return; | ||
} | ||
try { | ||
nlohmann::json createLobbyNormalButton = | ||
Json::getInstance().getDataByVector({"menu", "gametype_normal"}, JsonType::SELECT_LOBBY); | ||
nlohmann::json lobbyName = | ||
Json::getInstance().getDataByVector({"menu", "name"}, JsonType::SELECT_LOBBY); | ||
nlohmann::json maxNbPlayer = | ||
Json::getInstance().getDataByVector({"menu", "maxNb"}, JsonType::SELECT_LOBBY); | ||
nlohmann::json bigBox = | ||
Json::getInstance().getDataByVector({"lobbyMenu", "bigBox"}, JsonType::SELECT_LOBBY); | ||
nlohmann::json createLobbyNormalButton = Json::getInstance().getDataByVector( | ||
{"lobbyMenu", "gotoCreateLobby"}, | ||
JsonType::SELECT_LOBBY); | ||
nlohmann::json joinLobbyButton = | ||
Json::getInstance().getDataByVector({"lobbyMenu", "joinLobby"}, JsonType::SELECT_LOBBY); | ||
Menu::MenuBuilder::getInstance().initMenuEntity( | ||
joinLobbyButton, | ||
Menu::Callback::connectLobbySelected); | ||
Menu::MenuBuilder::getInstance().initMenuEntity( | ||
createLobbyNormalButton, | ||
onButtonCreateLobbyNormalClicked); | ||
Menu::MenuBuilder::getInstance().initMenuEntity(lobbyName); | ||
Menu::MenuBuilder::getInstance().initMenuEntity(maxNbPlayer); | ||
onButtonGotoCreateLobbyClicked); | ||
Menu::MenuBuilder::getInstance().initMenuEntity(bigBox); | ||
} catch (const std::exception &err) { | ||
Logger::error( | ||
"Counldn't load menu correctly, verify your json data : " + std::string(err.what())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [37-60]
The initSelectLoby
function has a typo in its name. It should be initSelectLobby
. Also, it's good to see error handling in place for JSON data loading. However, the error message could be more specific about which JSON data failed to load.
- void initSelectLoby(std::size_t managerId, std::size_t systemId)
+ void initSelectLobby(std::size_t managerId, std::size_t systemId)
void initLobbyRow(std::size_t managerId, std::size_t systemId) | ||
{ | ||
auto &arrLobbyText = Registry::getInstance().getComponents<Raylib::Text>(); | ||
auto &arrPosition = Registry::getInstance().getComponents<Types::Position>(); | ||
int offset = 1000; | ||
|
||
try { | ||
for (std::size_t i = 0; i < 5; i++) { | ||
Logger::info("INIT LOBBYSTATUS...."); | ||
nlohmann::json lobbyBox = | ||
Json::getInstance().getDataByVector({"lobbyMenu", "lobbyBox"}, JsonType::SELECT_LOBBY); | ||
std::size_t id = ::Menu::MenuBuilder::getInstance().initMenuEntity(lobbyBox); | ||
Logger::info("MENU ENTITY CORRECTLY INIT"); | ||
if (arrPosition.exist(id)) { | ||
Logger::info("ACTUAL OFFSET FOR LOBBY : " + std::to_string(offset)); | ||
arrPosition[id].y += offset * i; | ||
} | ||
if (arrLobbyText.exist(id)) { | ||
Raylib::Vector2 pos(arrLobbyText[id].getPosition().x, arrLobbyText[id].getPosition().y); | ||
pos.y += Maths::intToFloatConservingDecimals(offset) * i; | ||
arrLobbyText[id].setPosition(pos); | ||
} | ||
LobbyStatus newLobby; | ||
Registry::getInstance().getComponents<LobbyStatus>().insertBack(newLobby); | ||
} | ||
} catch (std::runtime_error &err) { | ||
Logger::error( | ||
"Counldn't load menu correctly, verify your json data : " + std::string(err.what())); | ||
} | ||
Logger::info("OUI OUI OUI"); | ||
SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initLobbyRow
function seems to be initializing multiple lobby entities. However, the offset value is hardcoded to 1000. Consider making this a parameter or a constant to increase flexibility and readability. Also, the log message "OUI OUI OUI" at line 114 doesn't provide any useful information and should be removed or replaced with a more meaningful message.
void updateLobbyRow(std::size_t /* unused */, std::size_t /* unused */) | ||
{ | ||
static std::size_t clockId = Registry::getInstance().getClock().create(); | ||
|
||
if (Registry::getInstance().getClock().elapsedSecondsSince(clockId) < 1) { | ||
return; | ||
} | ||
Registry::getInstance().getClock().decreaseSeconds(clockId, 1); | ||
// already created lobby | ||
// list of all lobby | ||
auto idsLobbyStatus = | ||
Registry::getInstance().getEntitiesByComponents({typeid(LobbyStatus), typeid(Raylib::Text)}); | ||
auto idsClickableLobbys = Registry::getInstance().getEntitiesByComponents( | ||
{typeid(LobbyStatus), typeid(Raylib::Text), typeid(Types::InputBox)}); | ||
auto ids = Registry::getInstance().getEntitiesByComponents({typeid(struct lobby_s)}); | ||
auto &arrLobbyStatus = Registry::getInstance().getComponents<LobbyStatus>(); | ||
auto &arrLobbyText = Registry::getInstance().getComponents<Raylib::Text>(); | ||
// list of all lobby | ||
auto ids = Registry::getInstance().getEntitiesByComponents({typeid(struct lobby_s)}); | ||
auto &arrLobby = Registry::getInstance().getComponents<struct lobby_s>(); | ||
float x = 10; | ||
float y = 50; | ||
|
||
for (auto id : ids) { | ||
bool found = false; | ||
for (auto idLobbyStatus : idsLobbyStatus) { | ||
if (arrLobby[id].lobbyInfos.port == arrLobbyStatus[idLobbyStatus].port | ||
&& std::string(arrLobby[id].lobbyInfos.ip) == arrLobbyStatus[idLobbyStatus].ip) { | ||
x = arrLobbyText[idLobbyStatus].x(); | ||
y = arrLobbyText[idLobbyStatus].y(); | ||
found = true; | ||
auto &arrLobby = Registry::getInstance().getComponents<struct lobby_s>(); | ||
static std::size_t nbrOfIt = 0; | ||
static std::size_t pageNbr = 1; | ||
|
||
if (idsLobbyStatus.empty()) { | ||
pageNbr = arrLobbyStatus[idsLobbyStatus[0]].pageNbr; | ||
} | ||
for (; nbrOfIt < pageNbr * 5 && nbrOfIt < ids.size();) { | ||
for (auto &id : idsLobbyStatus) { | ||
if (arrLobbyStatus[id].ip.empty() && nbrOfIt < ids.size()) { | ||
std::string name(arrLobby[ids[nbrOfIt]].name); | ||
if (name.size() > 15) { | ||
name = name.substr(0, 15); | ||
name += "..."; | ||
} | ||
std::string text_t = name + " | " + std::to_string(arrLobby[ids[nbrOfIt]].maxNbPlayer) | ||
+ " | " + gameTypeToString(arrLobby[ids[nbrOfIt]].gameType); | ||
arrLobbyStatus[id].ip = std::string(arrLobby[ids[nbrOfIt]].lobbyInfos.ip); | ||
arrLobbyStatus[id].port = arrLobby[ids[nbrOfIt]].lobbyInfos.port; | ||
Raylib::Text text(text_t); | ||
if (arrLobbyText.exist(id)) { | ||
arrLobbyText[id].setCurrentText(text_t); | ||
} | ||
nbrOfIt++; | ||
} | ||
} | ||
if (!found) { | ||
Registry::getInstance().addEntity(); | ||
LobbyStatus NewLobby(arrLobby[id].lobbyInfos.ip, arrLobby[id].lobbyInfos.port); | ||
arrLobbyStatus.insertBack(NewLobby); | ||
std::string text_t = std::string(arrLobby[id].name) + " | " | ||
+ std::to_string(arrLobby[id].maxNbPlayer) + " | " | ||
+ gameTypeToString(arrLobby[id].gameType); | ||
y += 5; | ||
Raylib::Text text(text_t, Raylib::Vector2(x, y), 2, Raylib::Red); | ||
arrLobbyText.insertBack(text); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updateLobbyRow
function is quite complex and could benefit from being broken down into smaller, more manageable functions. This would improve readability and maintainability. Also, consider adding comments to explain the logic and purpose of the code.
static void initFromSprite(nlohmann::json &elem) | ||
{ | ||
std::size_t id = Registry::getInstance().addEntity(); | ||
Types::SpriteDatas spriteDatas( | ||
Json::getInstance().getDataFromJson<std::string>(elem, "spritePath"), | ||
Json::getInstance().getDataFromJson<int>(elem, "width"), | ||
Json::getInstance().getDataFromJson<int>(elem, "height"), | ||
FRONTLAYER, | ||
static_cast<std::size_t>(FRONT)); | ||
if (Json::isDataExist(elem, "rect")) { | ||
Types::Rect rect = { | ||
Types::Rect(Json::getInstance().getDataFromJson<Types::Rect>(elem, "rect"))}; | ||
if (Json::isDataExist(elem, "animRect")) { | ||
Types::AnimRect animRect( | ||
rect, | ||
Json::getInstance().getDataFromJson<nlohmann::json>(elem, "animRect")); | ||
Registry::getInstance().getComponents<Types::AnimRect>().insertBack(animRect); | ||
} | ||
Registry::getInstance().getComponents<Types::Rect>().insertBack(rect); | ||
} | ||
Registry::getInstance().getComponents<Types::SpriteDatas>().insertBack(spriteDatas); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function initFromSprite
is almost identical to initSpriteFromJson
, but it does not create a new entity or return an ID. This is a good example of the Single Responsibility Principle, as each function has a clear, distinct purpose. However, there is a significant amount of code duplication between these two functions. Consider refactoring to eliminate this duplication.
…X-R-G-B/R-Bus into feature/RB-160-fix-client-init-protocol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- docs/network/rfc/RFC.md (19 hunks)
Additional comments: 8
docs/network/rfc/RFC.md (8)
33-61: The action codes have been reordered and renamed. Ensure that these changes are reflected in the implementation and that the new order is maintained for consistency.
292-307: The
CONNECT_LOBBY
action now requires amagick
value of20
. Ensure that this is correctly implemented in the code.513-515: The
magick
values for these actions have been updated. Ensure that these changes are reflected in the implementation.537-550: The
DISCONNECT_LOBBY
action has been added with amagick
value of22
. Ensure that this is correctly implemented in the code.657-659: The response actions
CONNECT_MAIN_SERVER_RESP
andCONNECT_LOBBY_RESP
have been added. Ensure that these are correctly implemented in the code.659-665: The
CONNECT_LOBBY_RESP
action now includes anisOk
field. Ensure that this is correctly implemented in the code.1010-1012: The
magick
values for these actions have been updated. Ensure that these changes are reflected in the implementation.1006-1012: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [1011-1013]
The
INFO_LOBBY
action now requires amagick
value of17
. Ensure that this is correctly implemented in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- src/Client/Systems/Graphic/ParallaxSystems.cpp (1 hunks)
- src/Nitwork/NitworkServer.cpp (4 hunks)
- src/Nitwork/NitworkServer.hpp (4 hunks)
Files skipped from review due to trivial changes (1)
- src/Client/Systems/Graphic/ParallaxSystems.cpp
Additional comments: 11
src/Nitwork/NitworkServer.hpp (5)
59-71: The function
addConnectLobbyRespMsg
is added to send a message to the client about whether they can connect to the lobby or not. Ensure that this function is called appropriately in the code where the client tries to connect to the lobby.207-245: New message handling functions
handleConnectLobbyMsg
,handleInitMsg
,handleReadyMsg
,handleRelativePositionMsg
, andhandleDisconnectMsg
are added. Make sure these functions are correctly implemented and handle all edge cases.255-264: New variables
_playersReady
and_isGameStarted
are added. Ensure that these variables are updated and checked at the appropriate places in the code.255-280: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [270-341]
The map
_actionsHandlers
is updated with new handlers forCONNECT_LOBBY
,INIT
,READY
,POSITION_RELATIVE
, andDISCONNECT_LOBBY
. Make sure these handlers are correctly implemented and handle all edge cases.
- 345-352: The map
_actionToSendHandlers
is updated with a new handler forCONNECT_LOBBY_RESP
. Make sure this handler is correctly implemented and used at the appropriate places in the code.src/Nitwork/NitworkServer.cpp (6)
6-12: The addition of
<fstream>
is not used in the provided code. Ensure it's necessary.171-189: The
handleConnectLobbyMsg
function handles a specific type of message. It checks if the game has already started and if the maximum number of players has been reached. If either of these conditions is true, it refuses the connection. It also checks if the message magic number matches the expected one. If not, it logs an error and returns. If all checks pass, it callsaddConnectLobbyRespMsg
to create a response message.191-201: The
handleInitMsg
function has been updated to check if the game has already started or if the maximum number of players has been reached. If either of these conditions is true, it refuses the connection.236-255: The
handleReadyMsg
function has been updated to check if the game has already started. If it has, it refuses the connection. It also checks if the client is already connected. If not, it logs an error and returns. If all clients are ready, it sets_isGameStarted
to true and callsaddStarWaveMessage
to start the game.288-300: The
handleDisconnectMsg
function has been updated to check if the message magic number matches the expected one. If not, it logs an error and returns. If the magic number matches, it removes the client from the list of endpoints, deletes the packet from the endpoints, and callsaddPlayerDeathMsg
to notify other clients of the player's disconnection.303-317: The
addConnectLobbyRespMsg
function creates a response message for the connect lobby action. It locks the mutex to ensure thread safety, creates the packet, and adds it to the send queue.
* ECS: Add button that can change scene Merge MINOR * CLIENT-GAME: Add physics to ennemies * GAME-LOGIC: Add a generic function for add physics * CLIENT-GAME: Add physics customizable by json MINOR * CLIENT-GAME: Fix compilation * GAME-CLIENT: Add maxy and minY for zigzag * CLIENT-GAME: Add attack struct * CLIENT-GAME: Add attack struct to ennemies MINOR * CLIENT-GAME: Enemies shoot bullets * CLIENT-GAME/DOCUMENTATION: Add first functional version of menu + some docs MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME/DOCUMENTATION: Update client game and error management * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Separe player and enemies missiles * CLIENT-GAME: Fix coderabbit review PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Add bullet direction for enemies * CLIENT-GAME: Modif now menu can init entity with the singletone MenuFactory MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Update src/Client/Systems/Menu/ButtonCallbacks.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * CLIENT-GAME: Add circle * CLIENT-GAME: Remove useless 1 * FORMAT-AUTO: automatic format on pull request #130 * CLIENT-GAME: Modif script to debug compil PATCH * CLIENT-GAME: Update code to make it cleaner PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Fix maths warnings * FORMAT-AUTO: automatic format on pull request #130 * CLIENT-GAME: Add missile to boss * CLIENT-GAME/DOCUMENTATION: Add some docs for menu builder class Modif some static method inside the menu.cpp file MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Update setAllInputBoxFalse to be more optimized PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Fix some bad includes PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * DOCUMENTATION: Update json doc Modif compil.ps1 to compil as before MINOR * SCRIPTS: Modif scripts to do the same things as before PATCH * ECS: Add button that can change scene Merge MINOR * CLIENT-GAME/DOCUMENTATION: Add first functional version of menu + some docs MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME/DOCUMENTATION: Update client game and error management * CLIENT-GAME: Fix coderabbit review PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now menu can init entity with the singletone MenuFactory MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Update src/Client/Systems/Menu/ButtonCallbacks.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * CLIENT-GAME: Modif script to debug compil PATCH * CLIENT-GAME: Update code to make it cleaner PATCH * CLIENT-GAME/DOCUMENTATION: Add some docs for menu builder class Modif some static method inside the menu.cpp file MINOR * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Update setAllInputBoxFalse to be more optimized PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Fix some bad includes PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * CLIENT-GAME: Modif now use template Json function PATCH * FORMAT-AUTO: automatic format on pull request #129 * DOCUMENTATION: Update json doc Modif compil.ps1 to compil as before MINOR * FORMAT-AUTO: automatic format on pull request #129 * SCRIPTS: Modif scripts to do the same things as before PATCH * FORMAT-AUTO: automatic format on pull request #129 * GAME-CLIENT: Adjust game difficulty * CLIENT-GAME: Add unused * FORMAT-AUTO: automatic format on pull request #130 * CLIENT-GAME: Add first version of connection menu (need work) MINOR * CLIENT-GAME: Add list-libby menu (begin) MINOR * CLIENT-GAME: Add MAX_MISSILE_TYPE PATCH * CLIENT-GAME: Remove strcpy warnings * CLIENT-GAME: Add final version of main menu to connect to main server MINOR * CLIENT-GAME: Remove useless print PATCH * CLIENT-GAME: Add create lobby scene And move good systems from list lobby scene to create lobby scene MINOR * CLIENT-GAME: Add create lobby menu MINOR * CLIENT-GAME: Add parallax to menus MINOR * CLIENT-GAME: Add better enemies system * CLIENT-GAME: Remove current boss system * CLIENT-GAME: Add features to enemies * CLIENT-GAME: Clean code before waves refactor * CLIENT-GAME: Add begin of wave refactor * SERVER-NETWORK: Add current progress * SERVER-NETWORK: Add current progress * CLIENT-NETWORK/SERVER-NETWORK: Add receive new bullet server side Upgrade create missile func in order to get the bullet's sparseArray id MINOR * CLIENT-GAME: Call initWave function * FORMAT-AUTO: automatic format on pull request #137 * CLIENT-GAME: Add first version of new waves * CLIENT-GAME: Fix latency problem * CLIENT-GAME: Fix next waves start * CLIENT-GAME: Add napstablook * CLIENT-GAME: Add first version of select lobby menu (need debug) MINOR * CLIENT-GAME: Fix texts * CLIENT-GAME: Add second version of select lobby menu (more functional) MINOR * CLIENT-GAME: Add 2 new boss MINOR * CLIENT-GAME: Add default2 enemy (dragon) MINOR * CLIENT-GAME: Fix missing perforant bullet PATCH * CLIENT-GAME: Add daemon enemie MINOR * CLIENT-GAME: Update the new spaceship MINOR * CLIENT-GAME: Add spaceship animations when going down MINOR * Update src/Nitwork/NitworkServer.hpp Co-authored-by: Xavier Mitault <[email protected]> * Update src/ECS/ECSCustomTypes.hpp Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * Update docs/network/rfc/RFC.md Co-authored-by: Xavier Mitault <[email protected]> * RFC: Fix missing fields form missile id and health (signed or not) PATCH * NITWORK-SERVER: Update doc PATCH * CLIENT-GAME: Fix warnings PATCH * CLIENT-GAME: Remove parameters for startNextWave * CLIENT-GAME: Change msBeforeNext by msBeforeSpawn * ECS: Fix segfault * CLIENT-NETWORK/SERVER-NETWORK: Add smooth lobby connexion & quit events MAJOR * FORMAT-AUTO: automatic format on pull request #138 * RFC: Add RFC for connect_lobby, connect_lobby_resp & disconnect_lobby MINOR * CLIENT-GAME: Add final version of the menu MINOR * CLIENT-NETWORK/SERVER-NETWORK: Add end game packets MAJOR * CLIENT-GAME: Add final version of the menu MINOR * FORMAT-AUTO: automatic format on pull request #140 * CLIENT-GAME: Fix warnings PATCH * CLIENT-GAME: Fix macOS compil PATCH * NITWORK-MAIN-SERVER: Fix ip resolve of mainServer PATCH * FORMAT-AUTO: automatic format on pull request #140 * NITWORK-MAIN-SERVER: Fix fork on windows PATCH * FORMAT-AUTO: automatic format on pull request #140 * CLIENT-GAME: Remove iostream * NITWORK-MAIN-SERVER: Add print of available ips at mainServer start MINOR * FORMAT-AUTO: automatic format on pull request #140 * NITWORK-SERVER: Upgrade ready message handling (start game when everyone is connected MAJOR * CLIENT-GAME: Add powerUp assets MINOR * CLIENT-GAME: Modif how menu builder build entities MINOR * FORMAT-AUTO: automatic format on pull request #140 * Update src/Client/Systems/Menus/CreateLobby/CreateLobbySystems.cpp Co-authored-by: Tenshi <[email protected]> * CLIENT-GAME: Add space to lobby PATCH * CLIENT-GAME: Fix review commentaries PATCH * FORMAT-AUTO: automatic format on pull request #140 * CLIENT-GAME: Add end game text * CLIENT-GAME: Fix linux warnings * CLIENT-GAME: Add big-daemon enemie MAJOR * CLIENT-GAME: Add ready button to click on it MINOR' * FORMAT-AUTO: automatic format on pull request #140 * CLIENT-GAME: Fix warnings * CLIENT-GAME: Fix end game message * CLIENT-GAME: Add begin of collisionRectOffset * CLIENT-GAME: Add collision rect offset MINOR * CLIENT-GAME: Fix boss size * CLIENT-GAME: Fix aspect ratio when resize * CLIENT-GAME: Add fullscreen * CLIENT-GAME: Remove fullscreen * CLIENT-GAME: Add 2nd parallax MINOR * CLIENT-GAME: Fix windows compile PATCH * NETWORK: Fix send wave message PATCH * CLIENT-GAME: Add enemies init * CLIENT-GAME: Add enemies weapons * Fix: Fix begin of compilation PATCH * *: Fix merge conflit MAJOR * SERVER-NETWORK: Fix ctrl+c PATCH * CLIENT-GAME: Fix windows compile * CLIENT-GAME: Fix text input deletion * *: Fix slect lobby row system called on create lobby PATCH * *: Begin of network fix PATCH * COMPILATION: Fix compilation PATCH * CLIENT: Remove unused file PATCH * CLIENT-GAME: Remove useless wave file * CLIENT-GAME: Add paralax * NITWORK: Add logger * CLIENT-GAME: Add preload texture func * NITWORK: Fix connect lobby bug, (action cast bug) PATCH * *: Begin of debug fantom bullets PATCH * *: Remove all log not ok with level PATCH * NITWORK: Add begin of restart server PATCH * FORMAT-AUTO: automatic format on pull request #143 * CLIENT-GAME: Add loading screen * FORMAT-AUTO: automatic format on pull request #143 * CLIENT-GAME: Add bullets to preload texture * NITWORK: Add reload of lobby MAJOR * FORMAT-AUTO: automatic format on pull request #143 * NITWORK-CLIENT: Remove useless debug prints PATCH * CLIENT-GAME: Fix windows compile * FORMAT-AUTO: automatic format on pull request #143 * CLIENT-MENU: Create Servers from GUI / Add menu music (#142) * CLIENT-MENU: Add the possibility for client to create servers MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-MENU: Add a little text to indicate scene + fix quiGame bug MINOR * CLIENT-MENU: Fix bad merging conflicts PATCH * CLIENT-MENU: Now client can create only 1 server MINOR * CLIENT-MENU: Fix windows compilation PATCH * FORMAT-AUTO: automatic format on pull request #142 * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-MENU: Now users can choose parallax MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-GAME: Fix compile * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-MENU: Now users can choose parallax MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-GAME: Add music menu / Remove debug * CLIENT-MENU: Now users can choose parallax MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT: Remove log unused PATCH * CLIENT-MENU: Now users can know if they already create a server MINOR * CLIENT-MENU: Now users can click on a button to exit programm MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-MENU: Modif text button MINOR * CLIENT-MENU: Modif now text button can reappeared even if the scene is changed MINOR * FORMAT-AUTO: automatic format on pull request #142 * CLIENT-MENU: Modif now it s working MINOR --------- Co-authored-by: Github Actions <github-actions[bot]@users.noreply.github.com> Co-authored-by: tenshi <[email protected]> Co-authored-by: Xavier Mitault <[email protected]> * CLIENT-GAME: Fix esc key handling PATCH --------- Co-authored-by: Kitetsu <[email protected]> Co-authored-by: tenshi <[email protected]> Co-authored-by: Github Actions <github-actions[bot]@users.noreply.github.com> Co-authored-by: Desousa Brice <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: romain <[email protected]> Co-authored-by: guillaume abel <[email protected]> Co-authored-by: Tenshi <[email protected]>
What is the current behavior? (link an issue based on the kind of change this pr introduce)
What is the new behavior (if this is a feature change)?
Other information:
Summary by CodeRabbit
New Features:
Raylib::Text
class.CREATE_LOBBY
to theScene
andSystemManagers
enum classes.sendReadyPacket
to send a ready packet when the R key is pressed.SELECTED
to theRectListType
enum to represent a new type of rectangle for selected objects.connectLobbySelected
to connect to a lobby based on the selected input box.moveEntities
to move entities within the game.Refactor:
SceneManager::run()
function.std::array
in thegetSystemsGroups
function from 6 to 8.initFromSprite
function into two separate functions:initSpriteFromJson
andinitFromSprite
.Bug Fixes:
text
object's position being affected byarrInputBox
andarrButton
.Chores:
MAX_LOBBY_NAME_SIZE
constant from 20 to 32, and theMAX_LOBBY_IP_SIZE
constant from 15 to 16.