Skip to content

refactor(pathutil): Add ensureTrailingSeparatorInPath helper - #3444

Merged
xezon merged 6 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/append-path-separator
Nov 16, 2026
Merged

xezon merged 6 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/append-path-separator

Conversation

@bobtista

@bobtista bobtista commented Oct 8, 2026 •

Copy link
Copy Markdown

Adds ensureTrailingSeparatorInPath to PathUtil.h. It appends the native separator unless the path is empty or already ends with a separator, and fails when the buffer has no room for it. It returns the result in .ok and the new path length in .length.

Replaces the hand-written trailing separator checks in ImagePacker, W3DView, Autorun, WWLib, WW3D2 and WorldBuilder.

The CString overload of Delimit_Path in W3DView now skips an empty path instead of reading before its start.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

  • Last reviewed commit: 382efc8a3e5b6cffb1520a0484917732710db959
  • Latest commit, not reviewed: abc0851

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The 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.

Changes

Shared path handling

Layer / File(s) Summary
Path utility and file-transfer APIs
Core/Libraries/Include/Lib/PathUtil.h, Core/GameEngine/Include/GameNetwork/FileTransfer.h, Core/GameEngine/Source/GameNetwork/FileTransfer.cpp
PathUtil.h adds wide-character and mutable-pointer overloads, a first-separator lookup, and appendPathSeparator. File-transfer code uses shared path and extension helpers and removes GetFileFromPath and GetExtensionFromFile.
Engine path operations and map names
Core/GameEngine/Source/Common/*, Core/GameEngine/Source/GameClient/*, Core/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp, Core/GameEngine/Source/GameNetwork/*, Core/GameEngineDevice/Source/*
Engine code uses shared helpers to locate separators, extract filenames, append separators, and parse archive paths. Map-name fallbacks, path matching, INI loading, and preview-image naming also use the helpers.
Library assets, audio, and diagnostics
Core/Libraries/Source/WWVegas/*, Core/Libraries/Source/debug/*
Library code uses shared helpers for asset and sound filenames, download directory scanning, file-factory paths, and debug output. The inline Get_Filename_From_Path helper is removed.
Core tools and launcher paths
Core/Tools/Autorun/*, Core/Tools/ImagePacker/Source/*, Core/Tools/Launcher/*, Core/Tools/W3DView/*, Core/Tools/WW3D/max2w3d/w3dutil.cpp
Tool code uses shared helpers for filename extraction, executable-directory lookup, separator checks, and path delimiting.
Generals game-engine paths
Generals/Code/GameEngine/Source/*, Generals/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cpp, GeneralsMD/Code/GameEngine/Source/*, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cpp
Both game variants use shared helpers for replay names, map names, save-game labels, and map-directory paths.
Generals and GeneralsMD tool paths
Generals/Code/Tools/*, GeneralsMD/Code/Tools/*
WorldBuilder and GUI tools use shared helpers for path delimiters, executable paths, and filename extraction. GeneralsMD wdump also uses the filename helper.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: xezon

Merge Risk: Low · up to 382ef

The path-handling refactor appears behavior-preserving for archive loading. One minor open concern remains in the W3DView Delimit_Path helper: it can mishandle an empty path. It should be addressed or explicitly accepted.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title names a refactor that adds an ensureTrailingSeparatorInPath helper to PathUtil. The changeset does not add that helper. The PR objectives and the summaries describe an appendPathSeparator he… Rename the title to match the actual helper, for example: "refactor(pathutil): Add appendPathSeparator helper". The title should name the function that PathUtil.h actually adds.
Passed Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description names the new helper (ensureTrailingSeparatorInPath in PathUtil.h) and the files it touches (ImagePacker, W3DView, Autorun, WWLib, WW3D2, WorldBuilder). The changeset adds appendPathSe…
Full details: Description check

Explanation

The description names the new helper (ensureTrailingSeparatorInPath in PathUtil.h) and the files it touches (ImagePacker, W3DView, Autorun, WWLib, WW3D2, WorldBuilder). The changeset adds appendPathSeparator to PathUtil.h and replaces trailing-separator checks in those components, so the description relates to the changes. It also describes the W3DView Delimit_Path fix, which appears in the changeset. The description names a different function (ensureTrailingSeparatorInPath with .ok and .length outputs) than the summary's appendPathSeparator(char*, size_t), which is a mismatch the author should reconcile, but the description remains related to the changeset and passes this lenient check.

Full details: Title check

Explanation

The title names a refactor that adds an ensureTrailingSeparatorInPath helper to PathUtil. The changeset does not add that helper. The PR objectives and the summaries describe an appendPathSeparator helper in PathUtil.h, which the changed call sites use. The title names a different function from the one the changeset adds, so it does not describe the main change accurately.

Resolution

Rename the title to match the actual helper, for example: "refactor(pathutil): Add appendPathSeparator helper". The title should name the function that PathUtil.h actually adds.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acbbee24-a5bc-4724-a356-849fb31fd890
📥 Commits

Reviewing files that changed from the base of the PR and between b64c8c654fa14ee1e02155ab73cb67653fb3b149 and 382efc8a3e5b6cffb1520a0484917732710db959.

📒 Files selected for processing (17)

  • Core/GameEngine/Source/Common/CommandLine.cpp
  • Core/GameEngine/Source/Common/INI/INI.cpp
  • Core/GameEngine/Source/Common/ReplaySimulation.cpp
  • Core/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
  • Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp
  • Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp
  • Core/Libraries/Include/Lib/PathUtil.h
  • Core/Libraries/Source/WWVegas/WWAudio/Utils.h
  • Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp
  • Core/Tools/Launcher/findpatch.cpp
  • Core/Tools/Launcher/patch.cpp
  • Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
  • Generals/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp
  • Generals/Code/Tools/WorldBuilder/src/TerrainModal.cpp
  • GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/TerrainModal.cpp
💤 Files with no reviewable changes (1)

  • Core/Libraries/Source/WWVegas/WWAudio/Utils.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a9d0ce7-d8fc-4873-a0c0-c8cd27bd0843
📥 Commits

Reviewing files that changed from the base of the PR and between 9176130 and 6700aad51d9f5e930cf4a9f306171a02352d2437.

📒 Files selected for processing (80)
  • Core/GameEngine/Include/GameNetwork/FileTransfer.h
  • Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
  • Core/GameEngine/Source/Common/CRCDebug.cpp
  • Core/GameEngine/Source/Common/INI/INIMapCache.cpp
  • Core/GameEngine/Source/Common/MiniLog.cpp
  • Core/GameEngine/Source/Common/System/Debug.cpp
  • Core/GameEngine/Source/Common/System/FileSystem.cpp
  • Core/GameEngine/Source/Common/System/GameMemoryInit.cpp
  • Core/GameEngine/Source/Common/WorkingDirectory.cpp
  • Core/GameEngine/Source/GameClient/MapUtil.cpp
  • Core/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp
  • Core/GameEngine/Source/GameNetwork/FileTransfer.cpp
  • Core/GameEngine/Source/GameNetwork/GameInfo.cpp
  • Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp
  • Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
  • Core/Libraries/Include/Lib/PathUtil.h
  • Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp
  • Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp
  • Core/Libraries/Source/WWVegas/WWAudio/Utils.h
  • Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp
  • Core/Libraries/Source/WWVegas/WWLib/WWCommon.h
  • Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp
  • Core/Libraries/Source/debug/debug_debug.cpp
  • Core/Libraries/Source/debug/debug_io_flat.cpp
  • Core/Libraries/Source/debug/debug_stack.cpp
  • Core/Tools/Autorun/Utils.cpp
  • Core/Tools/Autorun/Wnd_file.cpp
  • Core/Tools/ImagePacker/Source/ImagePacker.cpp
  • Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp
  • Core/Tools/Launcher/DatGen/DatGen.cpp
  • Core/Tools/Launcher/findpatch.cpp
  • Core/Tools/Launcher/main.cpp
  • Core/Tools/Launcher/patch.cpp
  • Core/Tools/W3DView/GraphicView.cpp
  • Core/Tools/W3DView/MainFrm.cpp
  • Core/Tools/W3DView/SaveSettingsDialog.cpp
  • Core/Tools/W3DView/Utils.cpp
  • Core/Tools/W3DView/Utils.h
  • Core/Tools/W3DView/W3DViewDoc.cpp
  • Core/Tools/WW3D/max2w3d/w3dutil.cpp
  • Generals/Code/GameEngine/Source/Common/Recorder.cpp
  • Generals/Code/GameEngine/Source/Common/StatsCollector.cpp
  • Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupSaveLoad.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
  • Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cpp
  • Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp
  • Generals/Code/Tools/WorldBuilder/src/BuildList.cpp
  • Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp
  • Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
  • Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
  • Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
  • GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
  • GeneralsMD/Code/GameEngine/Source/Common/StatsCollector.cpp
  • GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/DownloadMenu.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupSaveLoad.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_ldr.cpp
  • GeneralsMD/Code/Tools/GUIEdit/Source/GUIEdit.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
  • GeneralsMD/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.

Comment thread Core/Libraries/Include/Lib/PathUtil.h Resolved
Comment thread Core/Tools/W3DView/Utils.h Resolved
@bobtista
bobtista force-pushed the bobtista/refactor/append-path-separator branch 5 times, most recently from 382efc8 to 63de2c4 Compare October 11, 2026 19:44
@bobtista
bobtista force-pushed the bobtista/refactor/append-path-separator branch 5 times, most recently from 962122f to 5ec1b8c Compare October 19, 2026 00:16
@bobtista
bobtista force-pushed the bobtista/refactor/append-path-separator branch from 5ec1b8c to 641b280 Compare October 21, 2026 04:35
@bobtista
bobtista force-pushed the bobtista/refactor/append-path-separator branch from 641b280 to 9abcce4 Compare October 28, 2026 18:08
@bobtista
bobtista force-pushed the bobtista/refactor/append-path-separator branch from 9abcce4 to 7cdd6b3 Compare November 5, 2026 16:52
@bobtista
bobtista marked this pull request as ready for review November 6, 2026 14:29
@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Adds ensureTrailingSeparatorInPath for character buffers and replaces repeated trailing-separator checks across tools and libraries.

  • Directory paths use one shared rule for adding a trailing separator.
  • WorldBuilder prepares map and image folders with the shared separator rule.
  • W3DView skips the trailing-character check for empty strings.

No new actionable issues were found. No previous review threads were supplied.

Reviews (3) · Last reviewed commit: "refactor(pathutil): Use strlen_t in ensu..." · Reviewed by Greptile

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we certain this covers all call sites?

Comment thread Core/Tools/W3DView/Utils.h Resolved
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing labels Nov 7, 2026
@bobtista

bobtista commented Nov 7, 2026

Copy link
Copy Markdown
Author

No, not all of them. Autorun/Utils.cpp:397 and :407 (Path_Add_Back_Slash) and W3DView/Utils.h:65 and :72 (Delimit_Path) still do it by hand, because they take a path with no buffer size. The Babylon and DatGen strcat calls have no existing-separator check, so I left them. If you want the unsized ones covered too, I'll add overloads for them.

@xezon

xezon commented Nov 15, 2026

Copy link
Copy Markdown

The title and description are outdated.

@bobtista bobtista changed the title refactor(pathutil): Add appendPathSeparator for character buffers refactor(pathutil): Add ensureTrailingSeparatorInPath helper Nov 15, 2026
@bobtista

Copy link
Copy Markdown
Author

Updated

@xezon
xezon merged commit 6eeaaca into TheSuperHackers:main Nov 16, 2026
29 checks passed
Ronnin2011 pushed a commit to Ronnin2011/GeneralsGameCode that referenced this pull request Nov 19, 2026
Upstream TheSuperHackers/GeneralsGameCode up to ee27e89 (19 commits, through TheSuperHackers#3691), with the DX9 side of
their changes:
- The embedded web browser removed (TheSuperHackers#3691): DX8WebBrowser's start-up, update, render and shutdown go, and with
  them dx8webbrowser.h, W3DWebBrowser.cpp in both trees and the core_browserengine link. Our edits there were
  d3d8 -> d3d9 includes only. Kept beside them: the RmlUi start-up in W3DDisplay::init, Begin_Scene's handling of
  an already-active scene (dx8wrapper.cpp), and WW3D2's d3d9 link.
- Dynamic vertices written through VertexFormatXYZNDUV2 fields (TheSuperHackers#3671), our dynamic buffer's own layout: the
  streak renderer takes upstream's writes with its UVs still mapped into the particle atlas cell (6bae419);
  seglinerenderer merged as upstream wrote it.
- max2w3d's libraries (TheSuperHackers#3679): upstream's list, d3d9 where it names d3d8lib - the fork has no d3d8lib target.
  The exporter is not built in this configuration.
- Taken as they are: Targa header validation (TheSuperHackers#3572 - every loose, repo and archived TGA the game loads passes
  it), Convert_Color without a reinterpret (TheSuperHackers#3655), shore waves restored when a saved game loads (TheSuperHackers#3493),
  RawFileClass::Raw_Seek returning the position again (TheSuperHackers#3679), the special-power fixes (TheSuperHackers#3666 - in this
  retail-compatible build only MissileLauncherBuildingUpdate's crash fix changes anything), map cache and path
  helpers (TheSuperHackers#3107, TheSuperHackers#3444), the MinGW CI job (TheSuperHackers#3552).
Checked before merging: the merged tree configured and built in a scratch worktree (z_generals Release, 0
errors); this commit's tree is that build's source. Six tools fail to build exactly as they do on main before
the merge (ParticleEditor, DebugWindow, WorldBuilder, wdump, W3DView, the old tree's WW3D2).

# Conflicts:
#	Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
#	Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt
#	Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h
#	Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
#	Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp
#	Core/Tools/WW3D/max2w3d/CMakeLists.txt
#	Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DWebBrowser.cpp
#	GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DWebBrowser.cpp
fbraz3 added a commit to fbraz3/GeneralsX that referenced this pull request Nov 22, 2026
…442)

* fix(targa): Validate header sizes when loading Targa images (TheSuperHackers#3572)

* fix(dx8wrapper): Prevent undefined behavior when converting Vector4 colors (TheSuperHackers#3655)

* fix(ww3d2): Prevent undefined behavior when writing dynamic vertices and reading screenshot pixels (TheSuperHackers#3671)

* refactor(pathutil): Add ensureTrailingSeparatorInPath helper (TheSuperHackers#3444)

* bugfix(max2w3d): Let the timecoded animation compression drop keys of slow rotations (TheSuperHackers#3679)

The compression tests whether a rotation key can be rebuilt from its neighbours with
Slerp and measures the angle to the original. Slerp interpolated linearly without
normalizing when the neighbours were less than about 5.1 degrees apart. The shortened
quaternion read as an error of about half that span, so with the default tolerance of
0.05 degrees, keys of bones rotating between about 0.05 and 2.5 degrees per frame were
never dropped, while faster bones compressed normally.

Slerp now interpolates linearly only below the threshold that WWMath's Slerp and the
game's Fast_Slerp use. Measured with VC6 on 61-frame test tracks, a constant rotation
of 0.1 to 2.5 degrees per frame now keeps 2 keys instead of 61, and an ease in/out over
30 degrees keeps 15 instead of 59. Fast rotations are unchanged.

The compression checks a removed key only against its neighbours at the time of removal,
as it does for translations. Slow rotations now reach that limit too: on the test
tracks, the largest error at removed frames is about 0.1 to 0.16 degrees.

* refactor(maxsdk): Read max.h and maxscrpt.h through wrappers that restore the clashing macros (TheSuperHackers#3679)

The force included max_undef.h removed the VC6 override shim and PI for the whole file,
so no header read after the Max SDK could use the shim. max_sdk.h and maxscrpt_sdk.h now
hide both macros only while the Max SDK headers are read, and restore them afterwards.
max_undef.h keeps WIN32_LEAN_AND_MEAN, which must be undone before any header includes
Windows.h.

The wrappers have no include guard, because max.h has none: each time it is read, it
redefines assert through assert1.h as an assert that also checks in release builds, and
the plugin relies on that. Both PI values are the same float.

* bugfix(rawfile): Return the file position from RawFileClass::Raw_Seek again (TheSuperHackers#3679)

Since the switch of RawFileClass to the C stdio API, Raw_Seek returned the result of
fseek, which is 0 on success, instead of the position that SetFilePointer returned. Seek
and Tell of RawFileClass and of the classes derived from it returned 0 as well.

ChunkSaveClass keeps these positions to go back to a chunk header and to continue
writing behind the chunk, so files it wrote through these classes were overwritten from
the start. This broke W3DView's saves of emitters, LODs, aggregates and animations.
ChunkLoadClass::Seek always failed, and WWAudio passed 0 to the seek callback of Miles,
which W3DView uses to play sounds.

Raw_Seek now returns the position after the seek again, or -1 on failure. The game
reads its files through GameFileClass, which already returns the position, and does not
use the result when it writes files through RawFileClass.

* refactor(max2w3d): Replace pluglib's copies of WWLib and WWMath with WWLib and WWMath (TheSuperHackers#3679)

max2w3d and pluglib now include the WWLib and WWMath headers and link core_wwvegas, plus
core_wwstub for the memory pool and operator new hooks that WWLib's always.h declares.
pluglib keeps only its 3ds Max helpers and the Max matrix variant of EulerAnglesClass.

The returning forms of Slerp and Vector3::Cross_Product only exist in WWMath with
ALLOW_TEMPORARIES, so their callers use the forms with an output parameter. The AABTree
builder no longer needs its own WWASSERT.

WWMath normalizes vectors with Inv_Sqrt_Legacy instead of 1/sqrt. Measured with VC6 over
a million random vectors, 87% of the exported normals stay bit-identical and the others
differ by 1 or 2 ulp. Slerp computes with WWMath::Acos and Sinf_Legacy, which changes the
components of its results by at most 2.4e-7, measured over a million random pairs.

The abstract classes of the plugin now take _purecall from WWLib instead of the C
library, as in the other tools that use WWLib. It pulls in the CPU detection and the
system timer, so loading the plugin detects the CPU and calls timeBeginPeriod(1).

* refactor(max2w3d): Use WWMath's EulerAnglesClass (TheSuperHackers#3679)

pluglib's EulerAnglesClass was WWMath's adapted to take a Max matrix. The two callers now
convert the Max matrix into a Matrix3D with the new Convert_Max_Matrix, which keeps the
layout the adapted class used, and use WWMath's EulerAnglesClass.

WWMath computes the angles in float instead of double. Measured with VC6 over a million
random rotations, 98.7% of the exported pivot Euler angles stay bit-identical, and none
differs by more than 5e-10 radians. The game does not read them.

* refactor(max2w3d): Replace the Targa class with WWLib's (TheSuperHackers#3679)

max2w3d's copy of TARGA differed from WWLib's only in writing through the C runtime file
functions instead of WWLib's file factory, and in fixes that WWLib has since received.
The exporter writes its 16x16 texture of material colors through WWLib's class now, with
the same bytes.

* refactor(max2w3d): Use w3d_file.h and w3d_obsolete.h from WW3D2 (TheSuperHackers#3679)

max2w3d's copies of the W3D format headers were older versions of the WW3D2 ones. The
newer w3d_file.h adds chunks, structs and enum values and swaps the values of
SORT_LEVEL_BIN1 and SORT_LEVEL_BIN3, none of which max2w3d uses, apart from five surface
types that the material dialog now also offers: Water Permeable, Tiberium Water, Tiberium
Water Permeable, Underwater Dirt and Underwater Tiberium Dirt.

* refactor(max2w3d): Move the remaining pluglib files into max2w3d (TheSuperHackers#3679)

Only max2w3d used pluglib's 3ds Max helpers, so they move into max2w3d unchanged and the
core_pluglib target is removed.

* fix: Fix map cache path slashes for non-Windows (TheSuperHackers#3107)

* bugfix(specialpower): Fix special powers never becoming ready on constructed structures (TheSuperHackers#3666)

Non-retail builds started every special power of an object that is created under
construction with a ready frame of 0xFFFFFFFF, so that it could not be used before the
construction was finished. Only a SpecialPowerCreate module started the recharge on
build completion, so the powers of structures without one, such as the Battle Plans and
the CIA Intelligence of the America Strategy Center, never became ready.

The ready frame now starts at 0 as in retail. The new
SpecialPowerModule::canDoSpecialPower() tells whether the object can use its special
power now, regardless of the timer. In non-retail builds it is false while the object is
disabled, the power is paused, or the object is under construction, and isReady()
requires it. This keeps shared powers unavailable on a structure that cannot use them,
and stops the skirmish AI from firing a superweapon from a structure that is still being
built.

getPercentReady() now reports 1 only when isReady() is true, so that ActionManager no
longer accepts a command that the special power then refuses. A power under construction
reports 0, a paused power keeps the percent it was paused at, and any other power that
is not ready stays below 1.

* bugfix(specialpower): Prevent special powers from executing on structures under construction (TheSuperHackers#3666)

Scripts and forced command button commands execute a special power without asking
isReady(), so they could still use the special power of a structure under construction.
In Zero Hour this dereferenced the special power module of MissileLauncherBuildingUpdate
before its first update had looked it up.

The special power entry points of SpecialPowerModule now refuse when canDoSpecialPower()
is false. The powers that can sit on a structure and act after the base class call check
it as well: OCLSpecialPower, SpyVisionSpecialPower, BaikonurLaunchPower,
CashHackSpecialPower, DefectorSpecialPower and, in Zero Hour, FireWeaponPower. In
non-retail builds this also stops these powers from creating their effect while the
power is paused, for example the scan of a GLA Radar Van before its upgrade, which the
base class already refused. MissileLauncherBuildingUpdate no longer crashes while it
does not know its special power module yet.

The retail escape path for an unready MissileLauncherBuildingUpdate now also stops
OCLSpecialPower::doSpecialPower() from creating its object creation list, as it already
did for doSpecialPowerAtLocation().

* bugfix(missilelauncherbuildingupdate): Look up the special power module when the object is created (TheSuperHackers#3666)

MissileLauncherBuildingUpdate looked up its special power module only in its first
update after construction. A special power fired before that, by a script on the frame
the launcher is created or right after a save game is loaded, found no module. This no
longer crashes, but in non-retail builds the missile was launched without the door
sequence.

In non-retail builds the module is now looked up in onObjectCreated(), once all modules
of the object exist. Retail-compatible builds keep the lazy lookup in update() and the
escape path that refuses the launch.

* bugfix(watertracks): Restore shore waves when loading saved games (TheSuperHackers#3493)

* refactor: Remove unused embedded web browser (TheSuperHackers#3691)

* refactor(ww3d2): Route lights and fog via Renderer (TheSuperHackers#3420)

* refactor(ww3d2): Remove the unused black and white shadow renderer (TheSuperHackers#3670)

TexProjectClass only rendered with BWRenderClass inside an #if 0 block, so
SpecialRenderInfoClass::BWRenderer was always null and
MeshModelClass::Shadow_Render returned without drawing.

* refactor(filesystem): Rename appendPathSeparator to ensureTrailingPathSeparatorInPath (TheSuperHackers#3694)

* build(max2w3d): Fix the compile error from passing no image size to Targa::SetImage (TheSuperHackers#3696)

* refactor: Replace _isnan and _finite with std::isnan and std::isfinite (TheSuperHackers#3686)

_isnan and _finite are MSVC CRT functions from <float.h>. Use the standard
functions instead. The new cmath_adapter.h gives VC6 std::isnan and
std::isfinite built on _isnan and _finite, because neither VC6 nor
STLport 4.5.3 has them.

* ci(build): Keep precompiled headers when caching with ccache (TheSuperHackers#3701)

* ci(build): Cache the MinGW-w64 toolchain packages (TheSuperHackers#3710)

* feat(ww3d2): Implement texture atlas (TheSuperHackers#3562)

* bugfix(worldheightmap): Restore Generals retail compatibility of the cliff state (TheSuperHackers#3634)

Merging the Height Map code gave Generals the cliff state rows of Zero Hour, which have
(width+7)/8 bytes. Retail Generals keeps them in rows of (width+1)/8 bytes, which are
too short for the last cells of a row when the map width modulo 8 is 2 to 6. These cells
share their bit with the first cells of the next row. Since the merge they read as no
cliff instead, so the pathfinder classifies them differently and retail Generals replays
on such maps mismatch.

Retail Generals also reads the cliff bits of version 8 maps, which come from Zero Hour,
in rows of (width+1)/8 bytes, while Zero Hour writes them in rows of (width+7)/8 bytes.
When the map width modulo 8 is 1 to 6, each row in the file is one byte longer than the
row retail reads, so retail reads each row one byte further off than the row before.

A retail compatible Generals now restores the cliff state of retail after loading. For
version 7 maps the last cells of a row take the stored bits of the first cells of the
next row. For older maps, whose flags are computed from the heights column by column,
the first cells of the next row take the flags of the last cells, which retail computes
last. For version 8 maps the bits are regrouped into the rows that retail reads.

Without retail compatibility, Generals and Zero Hour compute the flags of these cells
from the heights for version 7 maps, because the file has no bits for them. Steep slopes
in the last columns of such maps are no longer passable for ground units. Version 8 maps
without retail compatibility and a retail compatible Zero Hour keep the cliff state as
before.

* bugfix(polygontrigger): Restore Generals retail compatibility of version 4 polygon triggers (TheSuperHackers#3634)

Merging the map code gave Generals the layer name that Zero Hour stores in version 4
polygon triggers. Retail Generals does not know it and reads the following values of
such triggers from the wrong bytes. With an empty layer name, the first trigger is never
a water area, and reading its points runs past the end of the file, so no further
triggers are read. Since the merge, Generals reads the water areas of Zero Hour maps
correctly, so retail Generals replays on such maps mismatch.

A retail compatible Generals now skips the layer name again and reads these triggers
like retail. In debug builds this raises an assert for each value read past the end of
the chunk. Without retail compatibility, and in Zero Hour, the layer name is read as
before.

* refactor: Replace Westwood function comment blocks with slim comments (TheSuperHackers#3697)

The Westwood comment blocks above the functions are replaced by slim comments.
Descriptions are kept where they add to the function name. INPUT and OUTPUT entries
are dropped unless they say something the signature does not, such as units or
valid ranges. History entries are dropped, except for notes on how a function
behaves today and the TheSuperHackers entries, which keep their keyword. The
Functions lists in the file headers are removed as well, since they repeat the
function descriptions.

* refactor: Remove the unused ATL includes (TheSuperHackers#3711)

* ci(build): Remove the Wine and widl install step from MinGW-w64 jobs (TheSuperHackers#3675)

* fix(worldbuilder): Prevent null dereferences and simplify name restore in object editing (TheSuperHackers#3383)

* fix(build): restore winsock2 include in NetworkMesh and undef PAGE_SIZE in textureatlas

* fix(build): use winsock2.h in udp.h for Windows compatibility

* fix(build): include winsock2.h before windows.h in PreRTS.h

* docs(worklog): remove leftover merge marker in 2026-11-DIARY.md

---------

Co-authored-by: Bobby Battista <[email protected]>
Co-authored-by: Jacob Lane Ledbetter <[email protected]>
Co-authored-by: xezon <[email protected]>
Co-authored-by: Omar Aglan <[email protected]>
Co-authored-by: stm <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants