refactor(network): Clean up utility functions for network commands#2725
refactor(network): Clean up utility functions for network commands#2725Caball009 wants to merge 5 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp | Refactors four if/else chains to switch statements and deduplicates CommandRequiresAck by delegating to DoesCommandRequireACommandID; all functionally equivalent except GetNetCommandTypeAsString loses its DEBUG_CRASH guard on unknown types. |
| Core/GameEngine/Include/GameNetwork/networkutil.h | Adds const-correctness to CommandRequiresAck and CommandRequiresDirectSend parameter declarations — straightforward improvement with no issues. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp:200
**Silent regression: `DEBUG_CRASH` removed without acknowledgement**
The original `default:` branch called `DEBUG_CRASH(("Unknown NetCommandType in GetNetCommandTypeAsString"))`, which would assert/abort in debug builds when an unrecognized enum value was passed — a deliberate guard to catch callers that forget to update this function when new command types are added. The new `default: return "NETCOMMANDTYPE_UNKNOWN"` silently swallows the unknown type in both debug and release builds. The PR description says "No change should have a functional difference," but this is a clear debug-build behavior change that removes active error detection.
Reviews (1): Last reviewed commit: "Refactored 'GetNetCommandTypeAsString'." | Re-trigger Greptile
| #define CASE_LABEL(x) case x: return #x; | ||
|
|
||
| switch (type) { | ||
| default: return "NETCOMMANDTYPE_UNKNOWN"; |
There was a problem hiding this comment.
Silent regression:
DEBUG_CRASH removed without acknowledgement
The original default: branch called DEBUG_CRASH(("Unknown NetCommandType in GetNetCommandTypeAsString")), which would assert/abort in debug builds when an unrecognized enum value was passed — a deliberate guard to catch callers that forget to update this function when new command types are added. The new default: return "NETCOMMANDTYPE_UNKNOWN" silently swallows the unknown type in both debug and release builds. The PR description says "No change should have a functional difference," but this is a clear debug-build behavior change that removes active error detection.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp
Line: 200
Comment:
**Silent regression: `DEBUG_CRASH` removed without acknowledgement**
The original `default:` branch called `DEBUG_CRASH(("Unknown NetCommandType in GetNetCommandTypeAsString"))`, which would assert/abort in debug builds when an unrecognized enum value was passed — a deliberate guard to catch callers that forget to update this function when new command types are added. The new `default: return "NETCOMMANDTYPE_UNKNOWN"` silently swallows the unknown type in both debug and release builds. The PR description says "No change should have a functional difference," but this is a clear debug-build behavior change that removes active error detection.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
I made a note of it in the first post.
This PR cleans up some utility functions in the network code, mainly by refactoring them from if/else chains to switch statements. No change should have a functional difference (with the exception of a removed debug assertion).
See commits for cleaner (per function) diffs.