-
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 136 other player distroyed when player die #124
Feature/rb 136 other player distroyed when player die #124
Conversation
by merging them MINOR
on server side PATCH
…of github.com:X-R-G-B/R-Bus into feature/RB-136-other-player-distroyed-when-player-die
…layer-distroyed-when-player-die
systems.cpp PATCH
Warning Rate Limit Exceeded@romainpanno has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 0 minutes and 40 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, convert this PR to a draft and then mark it as ready for review again to re-trigger the review. Alternatively, you can push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per repository. WalkthroughThis pull request introduces significant changes to the game's network protocol, player and enemy death handling, and player creation. It enhances the game's functionality and communication between the client and server by adding new fields to data structures, renaming actions, and adding new actions. It also improves code maintainability and readability. Changes
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: 1
Configuration used: CodeRabbit UI
Files selected for processing (15)
- docs/network/rfc/RFC.md (9 hunks)
- src/Client/Systems/Graphic/DeathSystems.cpp (2 hunks)
- src/Client/Systems/Network/ClientNetwork.cpp (5 hunks)
- src/Client/Systems/Network/ClientNetwork.hpp (1 hunks)
- src/ECS/Systems/Systems.cpp (6 hunks)
- src/ECS/Systems/Systems.hpp (1 hunks)
- src/Nitwork/ANitwork.cpp (3 hunks)
- src/Nitwork/ANitwork.hpp (2 hunks)
- src/Nitwork/Nitwork.h (7 hunks)
- src/Nitwork/NitworkClient.cpp (2 hunks)
- src/Nitwork/NitworkClient.hpp (5 hunks)
- src/Nitwork/NitworkServer.cpp (5 hunks)
- src/Nitwork/NitworkServer.hpp (7 hunks)
- src/Server/Systems/Network/ServerNetwork.cpp (1 hunks)
- src/Server/Systems/Network/ServerNetwork.hpp (1 hunks)
Additional comments (Suppressed): 51
src/Server/Systems/Network/ServerNetwork.hpp (1)
- 18-18: The new function
receivePlayerDeathMsg
has been added to handle player death messages. Ensure that this function is implemented correctly and that it is called in the appropriate places in the codebase. Also, verify that the function properly handles themsg
andendpoint
parameters.src/Client/Systems/Network/ClientNetwork.hpp (2)
12-12: The function
receiveNewPlayer
has been added. Ensure that this function is implemented correctly and that it handles the new player data as expected. Also, verify that the function is being called in the appropriate places in the codebase.17-17: The function
receivePlayerDeath
has been added. Ensure that this function is implemented correctly and that it handles the player death data as expected. Also, verify that the function is being called in the appropriate places in the codebase.src/Client/Systems/Graphic/DeathSystems.cpp (2)
16-16: The
setPlayerAnimRectDeath
function has been changed from a lambda function to a regular function. Ensure that this change does not affect any other parts of the codebase where this function is used.29-29: The
deathFunctions
map has been updated to include a death function for theTypes::OtherPlayer
type. This is a good addition as it extends the death handling functionality to other players in the game.src/Nitwork/ANitwork.hpp (2)
99-99: The change from
sizeof(struct header_s)
toHEADER_SIZE
seems to be a refactoring change. Ensure thatHEADER_SIZE
is correctly defined and equivalent tosizeof(struct header_s)
. IfHEADER_SIZE
is not equivalent, it could lead to incorrect memory access, causing undefined behavior.169-174: The
_packetId
member variable has been removed. Ensure that this does not affect any functionality where_packetId
was used. If_packetId
was used in any logic, removing it could cause issues.src/Nitwork/NitworkClient.cpp (2)
52-52: The change from
sizeof(struct header_s)
toHEADER_SIZE
is a good practice as it makes the code more readable and maintainable. However, please ensure thatHEADER_SIZE
is correctly defined and equals the size ofheader_s
structure to avoid any potential issues.227-248: The new method
addPlayerDeathMsg
is introduced to handle the creation and sending of player death messages. It uses a mutex lock to ensure thread safety when accessing_receivedPacketsIdsMutex
. This is a good practice for preventing data races in multithreaded environments. However, please ensure that the lock is released in all possible execution paths to avoid potential deadlocks.src/Nitwork/Nitwork.h (4)
34-35: The magic numbers for
MAGICK_NEW_PLAYER
andMAGICK_PLAYER_DEATH
have been added. Ensure that these magic numbers are unique and not used elsewhere in the codebase. Also, verify that these magic numbers are handled correctly in the network protocol.52-55: The action types
NEW_PLAYER
andPLAYER_DEATH
have been added to then_actionType_t
enumeration. Ensure that these new action types are handled correctly in the network protocol and that theN_ACTION_TYPE_MAX
value is updated accordingly.181-187: The
msgCreatePlayer_s
structure has been modified to include new fieldspos
,life
, andisOtherPlayer
. Ensure that these fields are initialized correctly when creating a new player and that they are used correctly in the network protocol.222-225: A new structure
msgPlayerDeath_s
has been added to handle player death messages. Ensure that this structure is used correctly in the network protocol and that theplayerId
field is set correctly when a player dies.src/Nitwork/ANitwork.cpp (3)
- 13-13: The initialization of
_packetId
has been removed from the constructor. If_packetId
is used elsewhere in the code, ensure that it is properly initialized before use to avoid undefined behavior.- ANitwork::ANitwork() : _socket(_context), _packetId(0) + ANitwork::ANitwork() : _socket(_context)
- 140-140: The check for packet size has been changed from
sizeof(struct header_s)
toHEADER_SIZE
. Ensure thatHEADER_SIZE
is correctly defined and is equivalent tosizeof(struct header_s)
. If not, this could lead to incorrect behavior when receiving packets.- if (packetSize > MAX_PACKET_SIZE || packetSize < sizeof(struct header_s)) { + if (packetSize > MAX_PACKET_SIZE || packetSize < HEADER_SIZE) {
- 239-239: The error message for an action not found in
actionToSendHandlers
has been improved to include the action that was not found. This is a good change as it will make debugging easier by providing more context in the error message.- Logger::error("NITWORK: action not found"); + Logger::error("NITWORK: action not found: " + std::to_string(data.action));src/Client/Systems/Network/ClientNetwork.cpp (4)
1-1: The new hunk includes the
CustomTypes.hpp
header file. Ensure that this file exists and contains the necessary definitions for the custom types used in the code.37-45: The code now checks if the health component exists for the enemy before setting its health to 0. This is a good practice as it prevents potential runtime errors if the health component does not exist for a particular enemy.
76-97: The
createNewPlayer
function has been significantly modified. It now checks if a player or other player with the same ID already exists, and if so, removes that entity before initializing a new one. This could potentially prevent duplication of player entities. However, ensure that removing an existing player entity does not have unintended side effects elsewhere in the code.243-265: The new function
receivePlayerDeath
handles the death of a player. It sets the health of the player or other player with the matching ID to 0. This is a good way to represent the death of a player in the game. However, ensure that other parts of the code properly handle a player's health being set to 0, such as removing the player from the game or triggering a respawn.src/Nitwork/NitworkClient.hpp (5)
39-39: The new method
addPlayerDeathMsg
is introduced to handle player death messages. Ensure that this method is called appropriately in the codebase whenever a player death event occurs.72-75: The
handleBody
function now usesmsgCreatePlayer_s
instead ofmsgPlayerInit_s
and thereceiveNewPlayer
function is called instead ofreceivePlayerInit
. Verify that these changes are consistent with the new network protocol and that themsgCreatePlayer_s
struct andreceiveNewPlayer
function are implemented correctly.124-130: The
NEW_ALLIE
action has been replaced withNEW_PLAYER
. ThehandleBody
function now usesmsgCreatePlayer_s
instead ofmsgNewAllie_s
and thereceiveNewPlayer
function is called instead ofreceiveNewAllie
. Ensure that these changes are consistent with the new network protocol and that themsgCreatePlayer_s
struct andreceiveNewPlayer
function are implemented correctly.166-176: A new
PLAYER_DEATH
action is introduced. ThehandleBody
function usesmsgPlayerDeath_s
and thereceivePlayerDeath
function is called. Ensure that these are implemented correctly and that thePLAYER_DEATH
action is handled appropriately in the codebase.224-229: The
sendData
function now usespacketPlayerDeath_s
for thePLAYER_DEATH
action. Verify thatpacketPlayerDeath_s
is implemented correctly and that thePLAYER_DEATH
action is handled appropriately when sending data.src/Nitwork/NitworkServer.hpp (5)
40-40: The function signature for
addPlayerInitMessage
has been changed to accept amsgCreatePlayer_s
object instead of a player ID. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that themsgCreatePlayer_s
object contains all the necessary information that was previously provided by the player ID.50-54: New functions
addPlayerDeathMsg
andaddNewPlayerMsg
have been added. Ensure that these functions are being called at the appropriate places in the codebase to handle player death and the addition of new players. Also, verify that the necessary data is being passed to these functions.78-82: The function
sendNewAllie
has been modified to accept apacketCreatePlayer_s
object instead of apacketNewAllie_s
object. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that thepacketCreatePlayer_s
object contains all the necessary information that was previously provided by thepacketNewAllie_s
object.150-156: A new action
PLAYER_DEATH
has been added to the_actionsHandlers
map. Ensure that this action is being handled correctly in theSystems::receivePlayerDeathMsg
function and that the necessary data is being passed to this function.196-197: The
sendData
function is now being called with different packet types (packetCreatePlayer_s
andpacketPlayerDeath_s
) for theINIT
,NEW_PLAYER
, andPLAYER_DEATH
actions. Ensure that thesendData
function can handle these new packet types and that all necessary data is being included in these packets.src/ECS/Systems/Systems.cpp (6)
341-341: The
deadList
variable is now a reference to the list of dead components. This change is good for performance as it avoids unnecessary copying of the list. However, ensure that the list is not modified elsewhere in a way that could invalidate this reference.361-373: The code now checks if the dead entity is a player or other player and sends a death message accordingly. This is a new feature introduced in this PR. Ensure that the
addPlayerDeathMsg
function handles these messages correctly and that the server and client code can process these messages.386-402: The
sendDeathMsg
function has been modified to handle death messages for both players and enemies. This is a significant change from the previous version which only handled enemy death messages. Ensure that the server and client code can process these new types of messages.418-418: The
sendDeathMsg
function is now called when an entity's health reaches zero. This is a change from the previous version wheresendEnemyDeath
was called. This change is part of the new feature introduced in this PR where death messages are sent for both players and enemies.466-474: The
initPlayer
function now takes additional parameters for position and health. This is a significant change from the previous version which only took a constant ID and a boolean indicating if the player is another player. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.501-501: The
position
variable is now initialized with the passed in position instead of a default position. This is a significant change from the previous version where the position was initialized with a default value. Ensure that the passed in position is valid and that this change does not affect the gameplay or player spawning mechanics.docs/network/rfc/RFC.md (8)
43-45: The addition of "Position", "Life", and "Is Other Player" fields to the server action in the network protocol is noted. Ensure that these fields are properly handled in the server-side code and that the client-side code is updated to correctly interpret these new fields.
104-110: The renaming of the "NEW_ALLIE" action to "NEW_PLAYER" and the addition of "Position", "Life", and "Is Other Player" fields are noted. Make sure that all instances of "NEW_ALLIE" in the codebase are updated to "NEW_PLAYER" and that these new fields are correctly handled.
125-131: The addition of the "PLAYER_DEATH" action is noted. Ensure that this action is correctly handled in both the client-side and server-side code, and that the "Player ID" field is correctly interpreted.
260-263: The renaming of the "NEW_ALLIE" action to "NEW_PLAYER" and the addition of the "PLAYER_DEATH" action in the action body are noted. Make sure that all instances of "NEW_ALLIE" in the codebase are updated to "NEW_PLAYER" and that the "PLAYER_DEATH" action is correctly handled.
290-292: The addition of "pos", "life", and "isOtherPlayer" fields to the server action is noted. Ensure that these fields are properly handled in the server-side code and that the client-side code is updated to correctly interpret these new fields.
310-342: The detailed specifications for the new "Position", "Life", and "Is Other Player" fields are noted. Ensure that these specifications are correctly implemented in the server-side code and that the client-side code is updated to correctly interpret these new fields.
720-782: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [714-778]
The renaming of the "NEW_ALLIE" action to "NEW_PLAYER" and the detailed specifications for the new "Position", "Life", and "Is Other Player" fields are noted. Make sure that all instances of "NEW_ALLIE" in the codebase are updated to "NEW_PLAYER" and that these new fields are correctly handled.
- 868-915: The addition of the "PLAYER_DEATH" action and the detailed specifications for the "Player ID" field are noted. Ensure that this action and field are correctly handled in both the client-side and server-side code.
src/Nitwork/NitworkServer.cpp (7)
- 70-70: The change from
sizeof(struct header_s)
toHEADER_SIZE
is not inherently problematic, but it's important to ensure thatHEADER_SIZE
is defined correctly and matches the size ofheader_s
. IfHEADER_SIZE
is not equal tosizeof(struct header_s)
, it could lead to incorrect memory access and undefined behavior.// Verify that HEADER_SIZE is defined correctly static_assert(HEADER_SIZE == sizeof(struct header_s), "HEADER_SIZE does not match the size of header_s");
113-130: The function
sendNewAllie
has been modified to take apacketCreatePlayer_s
instead ofpacketNewAllie_s
. Ensure that all calls to this function have been updated to match the new signature. Also, the function now sets theplayerId
field of thepacketMsgCreatePlayer
argument, which could potentially overwrite existing data. If this is not the intended behavior, consider passingplayerId
as a separate argument.133-165: The new function
sendAlliesAlreadyPresent
sends information about existing players to a newly connected player. This is a good addition for maintaining game state consistency across all players. However, the function uses a lot of nested loops and conditionals, which increases its complexity. Consider refactoring this function to improve readability and maintainability.181-196: The
handleInitMsg
function has been significantly modified. It now uses apacketCreatePlayer_s
structure instead ofpacketNewAllie_s
, and it initializes the player using theSystems::initPlayer
function with additional parameters for position and health. Ensure that these changes are compatible with the rest of the codebase. Also, the function now sends apacketCreatePlayer_s
packet to all clients, which could potentially overwrite existing data. If this is not the intended behavior, consider passingplayerId
as a separate argument.247-260: The
addPlayerInitMessage
function has been modified to take amsgCreatePlayer_s
instead of an_id_t
. Ensure that all calls to this function have been updated to match the new signature. Also, the function now sets themsg
field of thepacketCreatePlayer
argument, which could potentially overwrite existing data. If this is not the intended behavior, consider passingplayerMsg
as a separate argument.361-373: The new function
addPlayerDeathMsg
sends apacketPlayerDeath_s
packet to all clients when a player dies. This is a good addition for maintaining game state consistency across all players. However, the function uses astd::lock_guard
to lock_receivedPacketsIdsMutex
, which could potentially lead to deadlocks if not handled properly. Ensure that this mutex is always unlocked, even in case of exceptions.375-390: The new function
addNewPlayerMsg
sends apacketCreatePlayer_s
packet to a specific client. This is a good addition for maintaining game state consistency across all players. However, the function uses astd::lock_guard
to lock_receivedPacketsIdsMutex
, which could potentially lead to deadlocks if not handled properly. Ensure that this mutex is always unlocked, even in case of exceptions.
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 (9)
- src/Client/Systems/Graphic/DeathSystems.cpp (2 hunks)
- src/Client/Systems/Network/ClientNetwork.cpp (5 hunks)
- src/ECS/Systems/Systems.cpp (6 hunks)
- src/ECS/Systems/Systems.hpp (1 hunks)
- src/Nitwork/ANitwork.hpp (2 hunks)
- src/Nitwork/NitworkClient.cpp (2 hunks)
- src/Nitwork/NitworkServer.cpp (5 hunks)
- src/Nitwork/NitworkServer.hpp (7 hunks)
- src/Server/Systems/Network/ServerNetwork.cpp (1 hunks)
Additional comments (Suppressed): 30
src/ECS/Systems/Systems.hpp (1)
- 32-36: The function signature of
initPlayer
has been changed to include two new parameters:const struct position_absolute_s &pos
andconst struct health_s &life
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the new parameters are being used correctly within the function.src/Nitwork/ANitwork.hpp (2)
98-99: The reinterpret cast has been modified to use
HEADER_SIZE
instead ofsizeof(struct header_s)
. Ensure thatHEADER_SIZE
is equivalent tosizeof(struct header_s)
. If not, this could lead to incorrect memory access.169-174: The member variable
_packetId
has been removed. Ensure that this does not affect any functionality where_packetId
was used.src/Client/Systems/Graphic/DeathSystems.cpp (2)
16-17: The
setPlayerAnimRectDeath
function has been changed from a lambda function to a regular function. Ensure that this change does not affect any other parts of the codebase where this function might be used.29-30: The
deathFunctions
map has been updated to include a new entity typeTypes::OtherPlayer
. This change seems to be in line with the PR's goal of handling death notifications for other players. However, it's important to ensure that thesetPlayerAnimRectDeath
function can handleTypes::OtherPlayer
entities correctly.src/Server/Systems/Network/ServerNetwork.cpp (1)
- 116-151: The
receivePlayerDeathMsg
function is responsible for handling player death messages. It locks the registry mutex to ensure thread safety, retrieves the necessary components from the registry, and then iterates over the entities that have these components. If it finds an entity with the same ID as the player who died, it checks if the player's health is greater than 0. If it is, it sends a new player message to the endpoint. If the player is not found, it logs a debug message.This function seems to be well-structured and follows good practices for thread safety and error handling. However, there is a potential issue with the logic in lines 133-146. If the player's health is greater than 0, it sends a new player message. This seems counterintuitive as the function is supposed to handle player death messages. Please verify if this is the intended behavior.
Also, the ternary operator in lines 141-144 could be simplified. The comparison itself returns a boolean value, so the ternary operator is unnecessary.
- .isOtherPlayer = (Nitwork::NitworkServer::getInstance().getPlayerId(endpoint) - != otherPlayer.constId) - ? true - : false, + .isOtherPlayer = Nitwork::NitworkServer::getInstance().getPlayerId(endpoint) != otherPlayer.constId,src/Nitwork/NitworkClient.cpp (2)
52-52: The reinterpret cast is now using
HEADER_SIZE
instead ofsizeof(struct header_s)
. Ensure thatHEADER_SIZE
is correctly defined and equivalent tosizeof(struct header_s)
. If not, this could lead to incorrect memory access.227-244: The new function
addPlayerDeathMsg
is added to send a player death message to the server. It uses a mutex lock to ensure thread safety when accessing_receivedPacketsIdsMutex
. This is a good practice for preventing data races in a multithreaded environment. However, ensure that the lock is released in all possible execution paths to avoid deadlocks.The function constructs a
packetPlayerDeath_s
structure and sends it as a packet. Ensure that theheader
andaction
fields are correctly initialized. Currently, theheader
field is initialized with all zeros, which might not be correct depending on the protocol specification. Also, theaction
field only has themagick
field set toPLAYER_DEATH
, ensure that this is the intended behavior.The function uses
std::make_any
to create astd::any
object frompacketPlayerDeath
. This is a good practice for creating type-safe containers. However, ensure that the receiver of this packet correctly handlesstd::any
and knows how to extractpacketPlayerDeath_s
from it.src/Client/Systems/Network/ClientNetwork.cpp (4)
3-3: The inclusion of "CustomTypes.hpp" is new. Ensure that this header file exists and is necessary for the code changes in this PR.
37-45: The logic for handling enemy death has been modified. Previously, the enemy entity was removed from the registry. Now, the enemy's health is set to 0 if it exists. This change could have implications on how the game handles enemy entities after their death. Ensure that this change is intended and that it doesn't introduce bugs or unexpected behavior in the game.
76-101: The
createNewPlayer
function is a new addition. It creates a new player or other player entity in the game. The function first checks if a player or other player with the same ID already exists. If so, it removes the existing entity before creating a new one. This could potentially cause issues if the existing player is still in use or referenced elsewhere in the code. Ensure that removing existing players is safe and doesn't cause any issues.247-271: The
receivePlayerDeath
function is a new addition. It handles the death of a player or other player entity. The function sets the health of the dying player to 0. This is a significant change to the game's death handling logic and could have implications on how the game handles player deaths. Ensure that this change is intended and that it doesn't introduce bugs or unexpected behavior in the game.src/Nitwork/NitworkServer.hpp (6)
40-42: The function signature for
addPlayerInitMessage
has been changed. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. The new signature now includes amsgCreatePlayer_s
parameter.52-56: New functions
addPlayerDeathMsg
andaddNewPlayerMsg
have been added. These functions seem to handle player death and new player messages respectively. Ensure that these functions are used correctly in the codebase.80-84: The function signature for
sendNewAllie
has been changed. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. The new signature now includes apacketCreatePlayer_s
parameter instead ofpacketNewAllie_s
.152-158: A new action
PLAYER_DEATH
has been added to the_actionsHandlers
map. This action seems to handle player death messages. Ensure that this action is used correctly in the codebase.185-187: The
NEW_ALLIE
action has been renamed toNEW_PLAYER
in the_actionToSendHandlers
map. Ensure that this change is reflected throughout the codebase.197-200: A new action
PLAYER_DEATH
has been added to the_actionToSendHandlers
map. This action seems to handle player death messages. Ensure that this action is used correctly in the codebase.src/Nitwork/NitworkServer.cpp (6)
70-70: The reinterpret cast is now using
HEADER_SIZE
instead ofsizeof(struct header_s)
. Ensure thatHEADER_SIZE
is correctly defined and equivalent tosizeof(struct header_s)
. If not, this could lead to incorrect memory access.113-130: The function
sendNewAllie
now takes apacketCreatePlayer_s
instead ofpacketNewAllie_s
. Ensure that all calls to this function have been updated to match the new signature. Also, thepacketCreatePlayer_s
structure seems to have more fields thanpacketNewAllie_s
. Make sure these additional fields are correctly handled in the function.179-204: The
handleInitMsg
function now initializes a player with position and health parameters. Ensure that these parameters are correctly set in thepacketMsgCreatePlayer
structure. Also, the function now callssendAlliesAlreadyPresent
after sending the new ally. Make sure this does not introduce any race conditions or other issues.255-270: The
addPlayerInitMessage
function now takes amsgCreatePlayer_s
instead of a player ID. Ensure that all calls to this function have been updated to match the new signature. Also, themsgCreatePlayer_s
structure seems to have more fields than just a player ID. Make sure these additional fields are correctly handled in the function.371-383: The new function
addPlayerDeathMsg
sends aPLAYER_DEATH
message to all clients. Ensure that this message is correctly handled on the client side and that the player death is correctly reflected in the game state.385-400: The new function
addNewPlayerMsg
sends aNEW_PLAYER
message to a specific client. Ensure that this message is correctly handled on the client side and that the new player is correctly added to the game state.src/ECS/Systems/Systems.cpp (6)
341-344: The
deadList
variable is now a reference instead of a copy. This change is good for performance as it avoids unnecessary copying. However, ensure that the original data is not modified unintentionally through this reference.361-373: The
executeDeathFunction
now checks if the dead entity is a player or other player and sends a death message accordingly. This is a new feature introduced in this PR. Ensure that theaddPlayerDeathMsg
function handles these messages correctly.386-402: The
sendEnemyDeath
function is renamed tosendDeathMsg
and now handles death messages for both enemies and other players. This is a good change for code maintainability as it reduces code duplication. However, ensure that theaddPlayerDeathMsg
andaddEnemyDeathMsg
functions handle these messages correctly.418-420: The
deathChecker
function now callssendDeathMsg
instead ofsendEnemyDeath
. This change is consistent with the renaming of thesendEnemyDeath
function tosendDeathMsg
.466-478: The
initPlayer
function now takes additional parameters for position and health. This change provides more flexibility in player initialization. However, ensure that all calls to this function throughout the codebase have been updated to match the new signature.505-507: The
initPlayer
function now directly uses the passed position for player initialization. This change is consistent with the new parameter added to the function. However, ensure that the passed position is valid and within the game window boundaries.
health_s is not present PATCH
…of github.com:X-R-G-B/R-Bus into feature/RB-136-other-player-distroyed-when-player-die
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: 1
Configuration used: CodeRabbit UI
Files selected for processing (2)
- docs/network/rfc/RFC.md (9 hunks)
- src/Client/Systems/Network/ClientNetwork.cpp (5 hunks)
Additional comments (Suppressed): 11
src/Client/Systems/Network/ClientNetwork.cpp (3)
3-3: The inclusion of the "CustomTypes.hpp" header file is new. Ensure that this file exists and is in the correct location. Also, verify that the types defined in this file are used in the new code.
37-47: The new code introduces a health component for enemies. This is a significant change from the previous logic where enemies were simply removed upon death. Now, the health of an enemy is set to 0 upon death. If an enemy does not have a health component, a fatal error is logged and the enemy is removed. This change could have implications for game mechanics and should be thoroughly tested.
249-273: The
receivePlayerDeath
function is a new addition. It handles player death messages by setting the health of the player or other player to 0. This is a significant change from the previous logic where player death was not handled. This change could have implications for game mechanics and should be thoroughly tested.docs/network/rfc/RFC.md (8)
43-45: The addition of "Position", "Life", and "Is Other Player" fields to the server's data structure is noted. Ensure that these fields are properly initialized and used in the server-side code. Also, verify that the client-side code has been updated to handle these new fields.
104-110: The renaming of the "NEW_ALLIE" action to "NEW_PLAYER" and the addition of "PLAYER_DEATH" action is noted. Make sure that all instances of "NEW_ALLIE" in the codebase have been updated to "NEW_PLAYER". Also, ensure that the "PLAYER_DEATH" action is properly handled in both the client-side and server-side code.
125-131: The addition of the "PLAYER_DEATH" action is noted. Ensure that this action is properly handled in both the client-side and server-side code. Also, verify that the "Player ID" field is correctly used to identify the player who died.
260-263: The addition of "NEW_PLAYER" and "PLAYER_DEATH" actions to the list of actions is noted. Make sure that these actions are properly handled in the codebase.
290-292: The addition of "pos", "life", and "isOtherPlayer" fields to the server action is noted. Ensure that these fields are properly initialized and used in the server-side code. Also, verify that the client-side code has been updated to handle these new fields.
310-344: The addition of "Position", "Life", and "Is Other Player" fields to the server's data structure is noted. Ensure that these fields are properly initialized and used in the server-side code. Also, verify that the client-side code has been updated to handle these new fields.
722-786: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [716-782]
The renaming of the "NEW_ALLIE" action to "NEW_PLAYER" and the addition of "PLAYER_DEATH" action is noted. Make sure that all instances of "NEW_ALLIE" in the codebase have been updated to "NEW_PLAYER". Also, ensure that the "PLAYER_DEATH" action is properly handled in both the client-side and server-side code.
- 872-919: The addition of the "PLAYER_DEATH" action is noted. Ensure that this action is properly handled in both the client-side and server-side code. Also, verify that the "Player ID" field is correctly used to identify the player who died.
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)
- src/Nitwork/Zstd.hpp (1 hunks)
Files skipped from review due to trivial changes (1)
- src/Nitwork/Zstd.hpp
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)
- src/Nitwork/ANitwork.hpp (3 hunks)
Files skipped from review due to trivial changes (1)
- src/Nitwork/ANitwork.hpp
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