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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe pull request extends shared path utilities and updates engine, library, and tool code to use them. The changes replace backslash-specific parsing in path operations and filename extraction. They also remove two file-transfer helpers and one library filename helper. ChangesShared path handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Refactor Suggested reviewers: Merge Risk: 🔵 Low · up to The path-handling refactor appears behavior-preserving for archive loading. One minor open concern remains in the W3DView Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1a9d0ce7-d8fc-4873-a0c0-c8cd27bd0843
📒 Files selected for processing (80)
Core/GameEngine/Include/GameNetwork/FileTransfer.hCore/GameEngine/Source/Common/Audio/AudioEventRTS.cppCore/GameEngine/Source/Common/CRCDebug.cppCore/GameEngine/Source/Common/INI/INIMapCache.cppCore/GameEngine/Source/Common/MiniLog.cppCore/GameEngine/Source/Common/System/Debug.cppCore/GameEngine/Source/Common/System/FileSystem.cppCore/GameEngine/Source/Common/System/GameMemoryInit.cppCore/GameEngine/Source/Common/WorkingDirectory.cppCore/GameEngine/Source/GameClient/MapUtil.cppCore/GameEngine/Source/GameLogic/Map/TerrainLogic.cppCore/GameEngine/Source/GameNetwork/FileTransfer.cppCore/GameEngine/Source/GameNetwork/GameInfo.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.cppCore/Libraries/Include/Lib/PathUtil.hCore/Libraries/Source/WWVegas/WW3D2/agg_def.cppCore/Libraries/Source/WWVegas/WW3D2/ringobj.cppCore/Libraries/Source/WWVegas/WW3D2/sphereobj.cppCore/Libraries/Source/WWVegas/WW3D2/w3d_dep.cppCore/Libraries/Source/WWVegas/WWAudio/AudibleSound.cppCore/Libraries/Source/WWVegas/WWAudio/Utils.hCore/Libraries/Source/WWVegas/WWDownload/FTP.cppCore/Libraries/Source/WWVegas/WWLib/WWCommon.hCore/Libraries/Source/WWVegas/WWLib/ffactory.cppCore/Libraries/Source/debug/debug_debug.cppCore/Libraries/Source/debug/debug_io_flat.cppCore/Libraries/Source/debug/debug_stack.cppCore/Tools/Autorun/Utils.cppCore/Tools/Autorun/Wnd_file.cppCore/Tools/ImagePacker/Source/ImagePacker.cppCore/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cppCore/Tools/Launcher/DatGen/DatGen.cppCore/Tools/Launcher/findpatch.cppCore/Tools/Launcher/main.cppCore/Tools/Launcher/patch.cppCore/Tools/W3DView/GraphicView.cppCore/Tools/W3DView/MainFrm.cppCore/Tools/W3DView/SaveSettingsDialog.cppCore/Tools/W3DView/Utils.cppCore/Tools/W3DView/Utils.hCore/Tools/W3DView/W3DViewDoc.cppCore/Tools/WW3D/max2w3d/w3dutil.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.cppGenerals/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cppGenerals/Code/Tools/GUIEdit/Source/GUIEdit.cppGenerals/Code/Tools/WorldBuilder/src/BuildList.cppGenerals/Code/Tools/WorldBuilder/src/SaveMap.cppGenerals/Code/Tools/WorldBuilder/src/ScriptDialog.cppGenerals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cppGenerals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.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.cppGeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cppGeneralsMD/Code/Tools/GUIEdit/Source/GUIEdit.cppGeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cppGeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cppGeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cppGeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cppGeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cppGeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cppGeneralsMD/Code/Tools/wdump/wdump.cpp
💤 Files with no reviewable changes (2)
- Core/GameEngine/Include/GameNetwork/FileTransfer.h
- Core/GameEngine/Source/Common/System/FileSystem.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.
| inline void appendPathSeparator(char* path, size_t size) | ||
| { | ||
| const size_t len = strlen(path); | ||
| if (len > 0 && len + 1 < size && !isPathSeparator(path[len - 1])) | ||
| { | ||
| path[len] = getNativePathSeparator(); | ||
| path[len + 1] = '\0'; | ||
| } | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- diff ---'
git diff --unified=40 ba7a17a684d6466a49f42652838f81ff90d9bd1b 6700aad51d9f5e930cf4a9f306171a02352d2437 -- Core/Libraries/Include/Lib/PathUtil.h
printf '%s\n' '--- call sites ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'appendPathSeparator(' . || test "$?" -eq 1
printf '%s\n' '--- related identifiers ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'ffactory' . || test "$?" -eq 1
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'W3DView' . || test "$?" -eq 1
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'WorldBuilder' . || test "$?" -eq 1Repository: TheSuperHackers/GeneralsGameCode
Length of output: 40757
🏁 Script executed:
set -eu
for spec in \
'Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp:110,215' \
'GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp:390,445' \
'GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp:95,155' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:100,145' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:235,280' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:330,370' \
'Core/Tools/Autorun/Wnd_file.cpp:245,295'; do
file=${spec%%:*}; range=${spec##*:}
printf '\\n--- %s:%s ---\\n' "$file" "$range"
sed -n "${range}p" "$file"
done
printf '\\n--- ffactory declarations and uses ---\\n'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'Get_File' Core/Libraries/Source/WWVegas Generals GeneralsMD Core/Tools/W3DView || test "$?" -eq 1
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'temp_sub_dir' Core/Libraries/Source/WWVegas Generals GeneralsMD Core/Tools/W3DView || test "$?" -eq 1
printf '\\n--- path construction near asset loading ---\\n'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'strcat' Generals/Code/Libraries/Source/WWVegas/WW3D2 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2 Generals/Code/GameEngineDevice GeneralsMD/Code/GameEngineDevice Core/Tools/W3DView || test "$?" -eq 1Repository: TheSuperHackers/GeneralsGameCode
Length of output: 25713
🏁 Script executed:
set -eu
for spec in \
'Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp:110,215' \
'GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp:390,445' \
'GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp:95,155' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:100,145' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:235,280' \
'Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp:330,370' \
'Core/Tools/Autorun/Wnd_file.cpp:245,295'; do
file=${spec%%:*}; range=${spec##*:}
printf '\n--- %s:%s ---\n' "$file" "$range"
sed -n "${range}p" "$file"
done
printf '\n--- ffactory declarations and uses ---\n'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'Get_File' Core/Libraries/Source/WWVegas Generals GeneralsMD Core/Tools/W3DView || test "$?" -eq 1
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'temp_sub_dir' Core/Libraries/Source/WWVegas Generals GeneralsMD Core/Tools/W3DView || test "$?" -eq 1
printf '\n--- path construction near asset loading ---\n'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'strcat' Generals/Code/Libraries/Source/WWVegas/WW3D2 GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2 Generals/Code/GameEngineDevice GeneralsMD/Code/GameEngineDevice Core/Tools/W3DView || test "$?" -eq 1Repository: TheSuperHackers/GeneralsGameCode
Length of output: 25695
🏁 Script executed:
set -eu
printf '%s\n' '--- SaveMap and WorldHeightMap callers ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'loadDirectoryOfImages(' GeneralsMD/Code/Tools/WorldBuilder Generals/Code/Tools/WorldBuilder || test "$?" -eq 1
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'getFileListInDirectory' GeneralsMD/Code Generals/Code Core/GameEngine GeneralsMD/Code/Tools/WorldBuilder Generals/Code/Tools/WorldBuilder || test "$?" -eq 1
printf '%s\n' '--- getFileListInDirectory definitions ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'FileSystem::getFileListInDirectory' Core Generals GeneralsMD || test "$?" -eq 1
printf '%s\n' '--- SaveMap path source declarations ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'getPath_UserData' Core Generals GeneralsMD || test "$?" -eq 1
printf '%s\n' '--- Autorun DebugFile declarations and uses ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'DebugFile' Core/Tools/Autorun || test "$?" -eq 1
printf '%s\n' '--- ImagePacker path construction ---'
sed -n '140,225p' Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp
sed -n '280,335p' Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp
printf '%s\n' '--- W3D/asset path buffers and helper-adjacent code ---'
sed -n '430,475p' GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp
sed -n '760,815p' GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/assetmgr.cpp
sed -n '760,810p' GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cppRepository: TheSuperHackers/GeneralsGameCode
Length of output: 30791
🏁 Script executed:
set -eu
printf '%s\n' '--- GlobalData user-data initialization and declarations ---'
sed -n '540,605p' Generals/Code/GameEngine/Include/Common/GlobalData.h
sed -n '1025,1085p' Generals/Code/GameEngine/Source/Common/GlobalData.cpp
sed -n '550,600p' GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'm_userDataDir' Generals/Code GeneralsMD/Code Core/GameEngine || test "$?" -eq 1
printf '%s\n' '--- SaveMap/OpenMap complete path blocks ---'
sed -n '55,145p' Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp
sed -n '105,155p' Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp
sed -n '340,395p' Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp
printf '%s\n' '--- local filesystem directory implementation ---'
sed -n '110,175p' Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp
sed -n '205,270p' Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp
printf '%s\n' '--- Autorun constants and API call context ---'
sed -n '45,75p' Core/Tools/Autorun/Wnd_file.cpp
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'DEBUG_FILE' Core/Tools/AutorunRepository: TheSuperHackers/GeneralsGameCode
Length of output: 19823
🏁 Script executed:
set -eu
printf '%s\n' '--- caller diffs against merge base ---'
git diff --unified=20 ba7a17a684d6466a49f42652838f81ff90d9bd1b 6700aad51d9f5e930cf4a9f306171a02352d2437 -- \
Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp \
Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp \
GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp \
Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp \
GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp \
Core/Tools/Autorun/Wnd_file.cpp \
Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp
printf '%s\n' '--- user-data path builders ---'
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'BuildUserDataPathFromIni' Generals/Code GeneralsMD/Code
rg -n -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'BuildUserDataPathFromRegistry' Generals/Code GeneralsMD/Code
sed -n '1160,1210p' Generals/Code/GameEngine/Source/Common/GlobalData.cpp
sed -n '1030,1070p' GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
printf '%s\n' '--- exact helper call inventory with surrounding declarations ---'
rg -n -C 8 -F --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'appendPathSeparator(' Core Generals GeneralsMDRepository: TheSuperHackers/GeneralsGameCode
Length of output: 41794
🏁 Script executed:
set -eu
printf '%s\n' '--- locate user-data builders ---'
rg -n -F -- 'GlobalData::BuildUserDataPath' .
rg -n -F -- 'BuildUserDataPathFromIni' .
rg -n -F -- 'BuildUserDataPathFromRegistry' .
printf '%s\n' '--- complete GeneralsMD SaveMap diff ---'
git diff --unified=30 ba7a17a684d6466a49f42652838f81ff90d9bd1b 6700aad51d9f5e930cf4a9f306171a02352d2437 -- GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp
printf '%s\n' '--- repository constants and path-setting documentation ---'
rg -n -i -F --glob '*.{h,hpp,c,cc,cpp,cxx,ini,txt,md}' -- 'userdata' GeneralsMD/Code/GameEngine Generals/Code/GameEngine Core | head -120Repository: TheSuperHackers/GeneralsGameCode
Length of output: 23355
🏁 Script executed:
set -eu
printf '%s\n' '--- Generals user-data builder ---'
sed -n '1325,1375p' Generals/Code/GameEngine/Source/Common/GlobalData.cpp
printf '%s\n' '--- GeneralsMD user-data builder ---'
sed -n '1330,1385p' GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
printf '%s\n' '--- GeneralsMD SaveMap changed block with line numbers ---'
nl -ba GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp | sed -n '118,150p'
printf '%s\n' '--- path source APIs around builder inputs ---'
rg -n -C 6 -i --glob '*.{h,hpp,c,cc,cpp,cxx}' -- 'SHGetFolderPath|GetEnvironmentVariable|Reg(Open|Query)|USERPROFILE|APPDATA|UserData' GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp Generals/Code/GameEngine/Source/Common/GlobalData.cppRepository: TheSuperHackers/GeneralsGameCode
Length of output: 16863
🏁 Script executed:
set -eu
printf '%s\n' '--- exact ImagePacker path construction ---'
nl -ba Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp | sed -n '180,205p'
printf '%s\n' '--- exact helper and affected SaveMap ranges ---'
nl -ba Core/Libraries/Include/Lib/PathUtil.h | sed -n '104,116p'
nl -ba GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp | sed -n '122,149p'
printf '%s\n' '--- exact user-data builder tail ---'
nl -ba GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | sed -n '1375,1398p'Repository: TheSuperHackers/GeneralsGameCode
Length of output: 3775
Handle separator-appending failure before building a child path.
appendPathSeparator can leave a non-empty buffer unchanged when it has no room for the separator. SaveMap.cpp can truncate the configurable user-data path into dirBuf, then concatenate search and map names without checking the result. ImagePacker also inserts text directly after buffer; its final hard-coded \\ does not repair a missing separator.
Return a status and reject the path before concatenation.
Suggested fix
-inline void appendPathSeparator(char* path, size_t size)
+inline bool appendPathSeparator(char* path, size_t size)
{
const size_t len = strlen(path);
- if (len > 0 && len + 1 < size && !isPathSeparator(path[len - 1]))
+ if (len == 0 || isPathSeparator(path[len - 1]))
+ return true;
+ if (len + 1 < size)
{
path[len] = getNativePathSeparator();
path[len + 1] = '\0';
+ return true;
}
+ return false;
}- appendPathSeparator(dirBuf, ARRAY_SIZE(dirBuf));
+ if (!appendPathSeparator(dirBuf, ARRAY_SIZE(dirBuf)))
+ return;Apply the same check at ImagePacker and other callers before they concatenate another path component.
| __inline void Delimit_Path (CString &path) | ||
| { | ||
| if (path[::lstrlen (path) - 1] != '\\') { | ||
| if (!isPathSeparator (path[::lstrlen (path) - 1])) { |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Guard against an empty CString in Delimit_Path.
For an empty string, path[::lstrlen(path) - 1] reads index -1. The LPTSTR overload checks lstrlen > 0 first. Add the same check here.
Proposed fix
--- "a/Core/Tools/W3DView/Utils.h"
+++ "b/Core/Tools/W3DView/Utils.h"
@@ -69,7 +69,7 @@
__inline void Delimit_Path (CString &path)
{
- if (!isPathSeparator (path[::lstrlen (path) - 1])) {
+ if (path.GetLength () > 0 && !isPathSeparator (path[path.GetLength () - 1])) {
path += CString ("\\");
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!isPathSeparator (path[::lstrlen (path) - 1])) { | |
| if (path.GetLength () > 0 && !isPathSeparator (path[path.GetLength () - 1])) { |
6700aad to
b64c8c6
Compare
…ileName in findpatch
b64c8c6 to
abff68e
Compare
… the launcher patch and FTP code
abff68e to
4e0b258
Compare
4e0b258 to
382efc8
Compare
Follow up to #3362. Merge that first.
Adds appendPathSeparator to PathUtil.h. It appends the native separator when the path does not already end with one. Replaces the hand-written trailing separator checks in ImagePacker, W3DView, Autorun, WWLib, WW3D2 and WorldBuilder.
TODO: Replicate in Generals.