Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe changes replace manual path-separator searches with shared ChangesShared path filename extraction
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: 🔵 Low · up to Maps with mixed separator styles can miss their water-grid settings. This is a narrow, pre-existing limitation, so the change is mergeable with owner awareness. Security Architecture Review
Pre-merge checks |
|
|
ffcf008 to
312cf98
Compare
xezon
left a comment
There was a problem hiding this comment.
Looks plausible. Can you make a full audit over the code if there are any other places like that and fix them too?
|
Done. Audited all places that take a file name from a path with only a backslash and switched them to getFileName or getLastPathSeparator. I left the windows-only tools stuff eg WorldBuilder and getMapLeafAndDirName alone |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 822dca59-ce18-4fcc-ae4a-c01b2145c2d2
📒 Files selected for processing (29)
Core/GameEngine/Source/Common/Audio/AudioEventRTS.cppCore/GameEngine/Source/Common/CRCDebug.cppCore/GameEngine/Source/Common/INI/INIMapCache.cppCore/GameEngine/Source/GameClient/MapUtil.cppCore/GameEngine/Source/GameLogic/Map/TerrainLogic.cppCore/GameEngine/Source/GameNetwork/FileTransfer.cppCore/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cppCore/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cppCore/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cppCore/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppGenerals/Code/GameEngine/Source/Common/Recorder.cppGenerals/Code/GameEngine/Source/Common/StatsCollector.cppGenerals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupSaveLoad.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cppGenerals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cppGenerals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cppGeneralsMD/Code/GameEngine/Source/Common/Recorder.cppGeneralsMD/Code/GameEngine/Source/Common/StatsCollector.cppGeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupSaveLoad.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cppGeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
10a872c to
a426ff8
Compare
xezon
left a comment
There was a problem hiding this comment.
Very nice improvements. Does this cover all of them or is something left hanging?
|
Open question is left. |
|
I found and fixed a couple more directory checks in GameInfo and one in the window script loader. Then there's getMapLeafAndDirName, which I fixed in #3108. I didn't touch Windows-specific path handling, tools and the unused Get_W3D_Name helper |
|
The bot has a complaint. |
|
The bot was right. Layout names like |
|
There are more slashes in CWorldBuilderDoc::OnOpenDocument And there are a lot more in many places using This changes needs more auditing |
87f267a to
d9cc923
Compare
Comments Outside DiffThese findings could not be posted inline.
|
|
I audited every All path parsing now handles both separators: engine code, Windows API paths, the debug library, WorldBuilder and the other tools, one commit per area. The remaining hits are not file paths: text escapes in GameText and Babylon, the GameSpy key/value delimiter, registry keys, UNC checks, and code that already converts backslashes to slashes. The window layout loader stays as it is, because relative layout names rely on '/' not being a separator. |
…ileName in findpatch
| char *tempPtr; | ||
| DWORD version; | ||
| while( (tempPtr=strchr(cptr,'\\')) !=nullptr) | ||
| while( (tempPtr=strpbrk(cptr,"\\/")) !=nullptr) |
There was a problem hiding this comment.
There are more strpbrk calls in the code base
There was a problem hiding this comment.
Done. Added getFirstPathSeparator for the forward searches. I also found a few more places that checked for separators by hand and switched them to the PathUtil helpers
There was a problem hiding this comment.
Lot's of magical things in this code base.
… the launcher patch and FTP code
|
|
||
| inline const char* getLastPathSeparator(const char* path) | ||
| { | ||
| return path ? maxPtr(strrchr(path, '/'), strrchr(path, '\\')) : nullptr; |
There was a problem hiding this comment.
How about we also use the strpbrk approach for this function? This means we need a reverse strpbrk. It does not exist in C. I asked Chat Gippy and it produced this:
Try add this to stringex.h and then simplify these.
char *strrpbrk(const char *str, const char *accept)
{
const char *last = nullptr;
for (; *str; ++str) {
if (strchr(accept, *str)) {
last = str;
}
}
return (char *)last;
}| return false; | ||
| } | ||
|
|
||
| inline const char* getFirstPathSeparator(const char* path) |
There was a problem hiding this comment.
Should also add a wchar_t version for good measure.
…_t getFirstPathSeparator
Many path checks search only for a backslash. Paths using forward slashes can therefore retain directory names, and some callers use an invalid pointer when no backslash is found.
Use
getFileName,getLastPathSeparatorandisPathSeparatorfromPathUtil.hto handle both separators. For example, the save list fallback label now usesfoo.mapforMaps/foo/foo.map. Existing map labels remain unchanged.The changes cover save labels and default descriptions, map cache names and map preview names, lobby and game setup map names, replay lists, generated stats and replay filenames, audio localization, file transfer helpers, particle and model texture names, the file factory, the download helpers, executable paths, diagnostic output, the debug library, WorldBuilder, W3DView, GUIEdit, ImagePacker, Autorun, Launcher, wdump and max2w3d. Applied to Generals and Zero Hour.
PathUtil.hgains non-constgetLastPathSeparatoroverloads and awchar_toverload ofisPathSeparator.Unchanged:
getMapLeafAndDirName, which constructs the portable save path (bugfix(network): Handle both map path separators #3108)Menus/MessageBox.wndrely on/not being a separatorVerification:
In-game verification covers the save list fallback label. The other changed call sites have not been tested in game, and the tools have not been run. max2w3d was not built because it needs the 3ds Max SDK.