fix(netpacket): Fix undefined behavior with NetPacket buffer writes#2304
Merged
xezon merged 1 commit intoTheSuperHackers:mainfrom Feb 15, 2026
Merged
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameNetwork/NetPacket.cpp | Replaces placement-new into raw byte buffers with stack construction + memcpy across all 20 FillBufferWith* functions, eliminating alignment and strict aliasing undefined behavior. All changes are mechanical and consistent. |
Flowchart
flowchart TD
A["FillBufferWithCommand(buffer, ref)"] --> B{Switch on\nNetCommandType}
B --> C["FillBufferWithGameCommand"]
B --> D["FillBufferWithAckCommand"]
B --> E["FillBufferWithFrameCommand"]
B --> F["...18 other FillBufferWith* functions"]
subgraph old["Old Pattern (Undefined Behavior)"]
G["placement-new: NetPacketXxx* p = new (buffer) NetPacketXxx"] --> H["Write fields via p->field = value"]
end
subgraph new["New Pattern (Well-Defined)"]
I["Stack construct: NetPacketXxx packet"] --> J["Write fields via packet.field = value"]
J --> K["memcpy(buffer, &packet, sizeof(packet))"]
end
C --> new
D --> new
E --> new
F --> new
K --> L["Append variable data via memcpy at offset sizeof(NetPacketXxx)"]
Last reviewed commit: 55e69ea
Mauller
reviewed
Feb 14, 2026
Mauller
reviewed
Feb 14, 2026
Andreas-W
added a commit
to Andreas-W/GeneralsGameCode_Modding
that referenced
this pull request
Feb 15, 2026
* bugfix(network): Assign disconnect frame when quitting the game via the disconnection menu (TheSuperHackers#2020) * chore: Implement scripts for custom isEmpty() and singleton refs clang-tidy checks (TheSuperHackers#2010) * bugfix(input): Replace frame-based timings with real-time timings in input system (TheSuperHackers#1835) * bugfix(aiupdate): Repairing Chinooks and Helixes no longer take off after evacuating all passengers (TheSuperHackers#1762) * bugfix(aiupdate): Chinooks and Helixes no longer take off after repair if passengers want to board or exit (TheSuperHackers#1787) * refactor: Apply clang-tidy fixes for generals-use-this-instead-of-singleton (TheSuperHackers#2017) * refactor: Apply clang-tidy fixes for generals-use-is-empty (TheSuperHackers#2018) * fix(logic): Fix unexpected return in GameLogic::logicMessageDispatcher's switch case MSG_CANCEL_UNIT_CREATE (TheSuperHackers#1881) * perf(audio): Optimize fail condition order in AudioManager::addAudioEvent (TheSuperHackers#1843) * refactor(audio): Simplify volume related code in AudioManager and MilesAudioManager (TheSuperHackers#2030) * ci(vcpkg): Stabilize vcpkg binary caching; add compiler-aware keys and explicit cache path (TheSuperHackers#2028) * bugfix(aiupdate): Invalidate build task of Dozers and Workers if the assigned target scaffold no longer exists (TheSuperHackers#1868) * perf(contain): Optimize Object::isHero with cached hero counter (TheSuperHackers#1841) * refactor(network): Simplify error prone net packet size calculations with packed structs (TheSuperHackers#1675) * refactor(logic): Simplify code in GameLogic's init, reset, startNewGame (TheSuperHackers#2027) * bugfix(heightmap): Disable old uv adjument for cliffs (TheSuperHackers#2038) * bugfix(heightmap): Fix dynamic lights on terrain (TheSuperHackers#2039) * perf(weaponstore): Optimize WeaponStore::findWeaponTemplatePrivate with hash map lookup (TheSuperHackers#2042) * bugfix(thingfactory): Reset next ThingTemplate ID after clearing custom map template overrides to avoid CRC mismatch in the next multiplayer game session (TheSuperHackers#2034) * tweak(drawable): Set correct model tint color after loading a save game (TheSuperHackers#2025) * bugfix(aiupdate): Prevent manually ejecting rappelling Rangers during Chinook Combat Drop (TheSuperHackers#1789) * bugfix(ai): Undetected mines can now be approached when using a disarm weapon (TheSuperHackers#1883) * bugfix(lobby): Properly sort CRC mismatched game rooms to the bottom of the lobby (TheSuperHackers#1845) * perf(ai): Avoid a few std::vector copies when passing ai paths to functions (TheSuperHackers#1895) * tweak(drawable): Decouple stealth detected opacity fade time step from render update (TheSuperHackers#2047) * bugfix(audio): UI audio no longer plays at maximum volume for a single frame when navigating between shell map menus (TheSuperHackers#2019) * bugfix(object): Do not apply veterancy bonuses and animations for dead units (TheSuperHackers#1968) * fix(xfer): Fix xfer retail compatibility code (TheSuperHackers#2024) * refactor(audio): Use MilesAudioManager::getEffectiveVolume consistently (TheSuperHackers#2058) * bugfix(worldbuilder): Initialize boolean in ScriptConditionsDlg::OnEditCondition to show logical condition (TheSuperHackers#2062) * bugfix(worldbuilder): Avoid taking action on cancel button for script conditions and actions (TheSuperHackers#2065) * bugfix(network): Fix packet size setup mistakes (TheSuperHackers#2040) * refactor(heightmap): Remove HALF_RES_MESH because it was never used and is broken (TheSuperHackers#2076) * bugfix(actionmanager): Do not show false resume construction cursor for allied scaffolds (TheSuperHackers#2068) * bugfix(render2d): Fix possible greyscale image rendering issues on hardware without DOT3 support (TheSuperHackers#2080) * perf(heightmap): Reduce cost of min height loop in HeightMapRenderObjClass::updateCenter by 93% (TheSuperHackers#2077) * fix(heightmap): Fix CENTER_LIMIT condition in HeightMapRenderObjClass::updateCenter (TheSuperHackers#2078) * refactor(heightmap): Clarify magic numbers related to VERTEX_BUFFER_TILE_LENGTH (TheSuperHackers#2079) * build(cmake): Move most CppMacros.h includes into precompiled headers and make them available in all build targets (TheSuperHackers#2090) * refactor: Modernize NULL to nullptr (TheSuperHackers#1938) * bugfix(scriptengine): Fix script dialog text spelling mistakes and errors in ScriptEngine (TheSuperHackers#2093) * perf(heightmap): Optimize repeated calls to getXWithOrigin, getYWithOrigin in HeightMapRenderObjClass::updateVB (TheSuperHackers#2102) * refactor(heightmap): Simplify functions getXWithOrigin(), getYWithOrigin() of HeightMapRenderObjClass (TheSuperHackers#2103) * perf(heightmap): Optimize data locality for m_vertexBufferTiles and m_vertexBufferBackup in HeightMapRenderObjClass (TheSuperHackers#2104) * refactor(gamelogic): Rearrange local variables in GameLogic::startNewGame() (TheSuperHackers#2115) * refactor(cmake): Move core_config into corei_always for simplification (TheSuperHackers#2091) * build(cmake): Expose source files of interface libraries core_utility, corei/gi/zi_libraries_include in Visual Studio solution (TheSuperHackers#2092) * refactor(ww3dformat): Merge function PixelSize into Get_Bytes_Per_Pixel (TheSuperHackers#2072) * perf(radar): Reduce cost of radar pixel draw in PartitionManager::refreshShroudForLocalPlayer by 96% (TheSuperHackers#2072) * bugfix(actionmanager): Restore retail compatibility after construction cursor change in ActionManager (TheSuperHackers#2125) * bugfix(buildassistant): Restore retail compatibility after build assistant shroud logic change (TheSuperHackers#2131) * bugfix(dx8caps): Resolve greyscale texture rendering issues in VMWare environments (TheSuperHackers#2128) * bugfix: Fix spelling errors in debug/diagnostic strings (TheSuperHackers#2108) Co-authored-by: Stubbjax <stubbjax02@hotmail.com> * fix: Rename misspelled identifiers (TheSuperHackers#2109) * docs: Fix spelling errors in Core/Libraries comments (TheSuperHackers#2116) * docs: Fix spelling errors in Core/Tools and Core/GameEngine comments (TheSuperHackers#2117) * docs: Fix spelling errors in Generals Libraries, Tools, GameEngineDevice comments (TheSuperHackers#2120) * docs: Fix spelling errors in GeneralsMD Libraries, Tools, GameEngineDevice comments (TheSuperHackers#2124) * docs: Fix spelling errors in Generals/Code/GameEngine/Include comments (TheSuperHackers#2119) * docs: Fix spelling errors in GeneralsMD/Code/GameEngine/Include comments (TheSuperHackers#2123) * docs: Fix spelling errors in Generals/Code/GameEngine/Source comments (TheSuperHackers#2118) * docs: Fix spelling errors in GeneralsMD/Code/GameEngine/Source/GameLogic comments (TheSuperHackers#2121) * docs: Fix spelling errors in GeneralsMD/Code/GameEngine/Source/GameClient and Common comments (TheSuperHackers#2122) * ci: Add workflow to trigger build from any commit for replay mismatch testing (TheSuperHackers#2114) * bugfix(audio): Restore retail compatibility after optimization change in AudioManager::addAudioEvent (TheSuperHackers#2132) * bugfix(script): Restore retail compatibility for sequential scripts in ScriptEngine (TheSuperHackers#2129) * feat(build): Add new docker build and game install scripts for Linux (TheSuperHackers#2085) Add convenience scripts for Linux users to build using Docker: - scripts/build-linux.sh: Docker-based build script for Linux that wraps the existing Docker infrastructure with Wine and VC6 toolchain - scripts/install-to-game.sh: Script to install built files to existing game installation with backup/restore support - .gitignore: Add /tmp/, /.claude/, /CLAUDE.md to ignored paths - README.md: Add quick start build section for Windows and Linux The Linux build uses the existing Docker infrastructure in resources/dockerbuild to produce Windows-compatible executables that can run under Wine. Usage: ./scripts/build-linux.sh # Build using Docker ./scripts/install-to-game.sh --detect # Install to your game * bugfix(logic): Decouple scripted audio events from CRC computation (TheSuperHackers#2075) * bugfix(ghostobject): Readd null check for 3DScene in W3DRenderObjectSnapshot::addToScene to prevent crash in headless replay playback (TheSuperHackers#2133) * bugfix(heightmap): Revert optimization for m_vertexBufferTiles in HeightMapRenderObjClass because it does not work properly (TheSuperHackers#2135) * bugfix(ai): Fix crash when AI player attempts to build a supply center with an invalid name (TheSuperHackers#2095) * bugfix(object): Preserve unit behaviour when transferring assets to allies (TheSuperHackers#1885) * bugfix(wbview3d): Fix crash on window resize in Generals World Builder (TheSuperHackers#2151) * fix(debug): Fix spelling errors in DEBUG macro strings (TheSuperHackers#2148) * fix: Fix spelling errors in code words (TheSuperHackers#2149) * refactor(math): Implement Matrix4x4::Inverse, Matrix3D::Get_Inverse and replace unsafe Matrix4x4 to D3DMATRIX casts with conversion functions that apply the required transpose (TheSuperHackers#2052) * perf(radar): Reduce cost of W3DRadar::renderObjectList (by 80%), W3DRadar::buildTerrainTexture (by 25%) and W3DRadar::clearShroud (TheSuperHackers#2138) This is achieved by locking the radar surface only once instead of every pixel draw * fix(tunnel): Fix undefined behavior in TunnelTracker::onTunnelDestroyed() and incomplete asset transfer in Team::setControllingPlayer() (TheSuperHackers#1958) * build(cmake): Add MinGW-w64 toolchain and base configuration (TheSuperHackers#2067) Add cross-compilation support for building with MinGW-w64 (GCC) on Linux targeting 32-bit Windows executables. This enables building Generals and Zero Hour without requiring MSVC or Windows. Core components: - Toolchain file for i686-w64-mingw32 cross-compiler - MinGW-specific compiler flags and library linking - MSVC compatibility macros (__forceinline, __int64, _int64) - Math constants header (mingw.h) with MinGW-specific definitions - Windows library dependencies (ole32, d3d8, dinput8, etc.) - d3dx8 library aliasing for MinGW compatibility The toolchain forces 32-bit compilation, disables MFC-dependent tools, and configures proper search paths for cross-compilation environment. Math constants are provided via mingw.h header (included through always.h) rather than CMake compile definitions, allowing proper scoping and avoiding global namespace pollution. Build with: cmake -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64-i686.cmake Files: - cmake/toolchains/mingw-w64-i686.cmake: Cross-compilation toolchain - cmake/mingw.cmake: MinGW-specific build configuration - Core/Libraries/Source/WWVegas/WWLib/mingw.h: Math constants header - CMakeLists.txt: Include MinGW configuration when MINGW is detected * build(cmake): Add widl integration for COM interface generation (TheSuperHackers#2067) Add Wine IDL Compiler (widl) as a replacement for Microsoft's MIDL compiler when building with MinGW-w64. This enables generation of COM interface code from IDL files on Linux cross-compilation environments. Features: - Auto-detect widl executable (widl or widl-stable) - Version detection and reporting - Dynamic Wine include path detection via wineg++ preprocessor - Configure Wine header paths for COM interface compilation - Fallback to known Wine stable/development include paths - IDL compilation function for generating headers and type libraries The widl compiler generates compatible COM interface definitions required for DirectX 8, Windows browser control, and other COM-based APIs used by the game engine. Files: - cmake/widl.cmake: widl detection and configuration - CMakeLists.txt: Include widl configuration for MinGW builds * build(cmake): Add ReactOS ATL and PSEH compatibility layer (TheSuperHackers#2067) Add ReactOS Active Template Library (ATL) support for MinGW-w64 builds, enabling ATL/COM functionality without MSVC dependencies. This provides the ATL headers needed for COM-based browser control integration. Components: - ReactOS ATL headers (v0.4.15) fetched from ReactOS project - ReactOS PSEH (exception handling) in C++-compatible dummy mode - ATL compatibility header with MinGW-specific macro definitions - PSEH compatibility header ensuring proper exception handling The implementation uses ReactOS PSEH in dummy mode (_USE_DUMMY_PSEH) because MinGW-w64's native PSEH uses GNU C nested functions which are incompatible with C++. This provides ATL functionality needed for: - CComPtr and CComBSTR smart pointers - ATL string conversion macros - COM interface implementations Files: - cmake/reactos-atl.cmake: ReactOS ATL integration - Dependencies/Utility/Utility/atl_compat.h: ATL compatibility layer - Dependencies/Utility/Utility/pseh_compat.h: PSEH compatibility layer - CMakeLists.txt: Include ReactOS ATL configuration * build(cmake): Add ReactOS COM support utilities (comsupp) (TheSuperHackers#2067) Add header-only implementation of COM support string conversion utilities for MinGW-w64. These utilities are provided by comsuppw.lib in MSVC but are not available in MinGW-w64's standard library. Provides: - _com_util::ConvertStringToBSTR(): Convert char* to BSTR - _com_util::ConvertBSTRToString(): Convert BSTR to char* These functions are essential for COM string handling in the browser control integration and other COM-based APIs. The header-only approach eliminates the need for linking against an external library and provides a lightweight, portable solution compatible with both MSVC and MinGW-w64. Implementation uses standard Windows APIs (SysAllocString, WideCharToMultiByte, MultiByteToWideChar) to perform the conversions. Files: - Dependencies/Utility/Utility/comsupp_compat.h: COM string utilities * build(deps): Update external dependencies for MinGW-w64 support (TheSuperHackers#2067) Update DirectX 8, Miles Sound System, and Bink Video SDK to versions with MinGW-w64 compatibility fixes. * build(cmake): Configure MinGW-specific compiler and linker settings (TheSuperHackers#2067) Add MinGW-w64 detection and configure compiler flags to optimize build output for cross-compilation: - Detect MinGW-w64 compiler and set IS_MINGW_BUILD flag - Skip debug symbols (-g) in MinGW Release builds to reduce executable size (MSVC Release builds already exclude debug info by default) - Maintain debug symbols for MinGW Debug builds This reduces the size of MinGW Release builds significantly while keeping compatibility with MSVC build configurations. Debug builds still include full debugging information for development. Files: - cmake/compilers.cmake: Add MinGW detection and conditional debug flags * build(cmake): Add MinGW CMake presets for i686 (TheSuperHackers#2067) Add configure, build, and workflow presets for MinGW-w64 32-bit (i686) cross-compilation. Enables easy building with standardized configurations. Presets: - mingw-w64-i686: Release build (optimized, no debug symbols) - mingw-w64-i686-debug: Debug build (with debugging symbols) - mingw-w64-i686-profile: Profile build (optimized with profiling) All presets: - Use Unix Makefiles generator (as required for MinGW) - Reference the mingw-w64-i686.cmake toolchain file - Generate compile_commands.json for IDE integration - Build to build/mingw-w64-i686 directory - Include corresponding build and workflow presets Usage: cmake --preset mingw-w64-i686 cmake --build --preset mingw-w64-i686 Or use workflow preset: cmake --workflow --preset mingw-w64-i686 Files: - CMakePresets.json: Add MinGW i686 configure/build/workflow presets * fix(precompiled): Add ATL compatibility to precompiled headers (TheSuperHackers#2067) Include ATL compatibility layer in precompiled headers for both Generals and Zero Hour to enable MinGW-w64 builds with ReactOS ATL support. Changes: - Include atl_compat.h before atlbase.h for GCC/MinGW builds - Add pragma pop at end of header to restore warnings - Conditional compilation ensures MSVC builds remain unchanged The ATL compatibility header must be included before ATL headers to: - Define _USE_DUMMY_PSEH for C++-compatible exception handling - Configure ReactOS ATL include paths - Disable problematic GCC warnings for ATL code - Define ATL-specific macros for MinGW compatibility This change enables CComPtr, CComBSTR, and other ATL functionality in MinGW-w64 builds while maintaining full MSVC compatibility. Files: - Generals/Code/GameEngine/Include/Precompiled/PreRTS.h - GeneralsMD/Code/GameEngine/Include/Precompiled/PreRTS.h * fix(cmake): Fix CMake dependencies and library linking for MinGW (TheSuperHackers#2067) Update CMakeLists.txt files to fix library dependencies and ensure proper linking for MinGW-w64 builds: Core libraries: - WW3D2: Add core_wwdebug, core_wwlib, core_wwmath dependencies Make comsuppw library MSVC-only (MinGW uses header-only comsupp_compat.h) Link WW3D2 libraries for core_wwdebug target - WWMath: Add core_wwsaveload dependency - GameEngine: Add widl support for browser control IDL compilation - EABrowserDispatch/Engine: Include widl-generated headers Game executables: - Generals/GeneralsMD Main: Make NODEFAULTLIB and RC files MSVC-only (MinGW doesn't support /NODEFAULTLIB or .rc resource compilation via these paths) These changes ensure: - Proper link order and dependency resolution - MSVC-specific features don't break MinGW builds - COM interface code generation works with widl - All required libraries are linked Files: - Core/GameEngine/CMakeLists.txt - Core/Libraries/Source/EABrowserDispatch/CMakeLists.txt - Core/Libraries/Source/EABrowserEngine/CMakeLists.txt - Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt - Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt - Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt - Generals/Code/Main/CMakeLists.txt - GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt - GeneralsMD/Code/Main/CMakeLists.txt * fix(core): Add MinGW-w64 compatibility fixes to Core libraries (TheSuperHackers#2067) Add comprehensive MinGW-w64 compatibility fixes to Core engine and library code: Type definitions and compatibility (always.h, BaseTypeCore.h): - Add __int64 and _int64 type definitions for MinGW - Add NOMINMAX and min/max template handling - Add __forceinline macro mapping Calling conventions (wwstring, widestring, GameText, profile): - Standardize Format() functions to __cdecl for cross-compiler compatibility - Fix variadic macro handling for GCC - Add explicit calling convention specifications where needed Headers and forward declarations: - Add missing forward declarations (WorldHeightMap.h, texture.h, textureloader.h) - Fix include path case sensitivity (endian_compat.h, winsock.h) - Include comsupp_compat.h before comutil.h for COM support Compiler guards and compatibility: - Guard MSVC SEH (MiniDumper.cpp) with _MSC_VER checks - Guard inline assembly with compiler checks (debug_stack.cpp, debug_except.cpp) - Add GCC inline assembly alternatives where needed - Disable MSVC SEH for MinGW (thread.cpp, Except.cpp) Linkage fixes: - Remove inappropriate static qualifiers (W3DWaterTracks.cpp) - Fix extern/static mismatches (missingtexture.cpp) - Add explicit void* casts for function pointers Includes and dependencies: - Add stddef.h for size_t (wwmemlog.h) - Add missing headers for MinGW compilation - Fix COM browser header inclusion order Audio and misc: - Fix __stdcall in AudioEvents.h function pointer typedefs - Fix volatile atomic operations (NoxCompress.cpp) - Use portable sint64 types (wwprofile.cpp) All changes are guarded with compiler checks to maintain MSVC compatibility. Files: 31 Core library source and header files * fix(headers): Add missing forward declarations for MinGW (TheSuperHackers#2067) Add forward declarations for PathfindCell and Anim2DCollection classes to resolve MinGW-w64 compilation errors due to incomplete types. MinGW-w64 is stricter about forward declarations than MSVC, requiring explicit forward declarations for classes used in header files before their first usage. Files modified: - Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h - Generals/Code/GameEngine/Include/GameClient/Anim2D.h - GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h - GeneralsMD/Code/GameEngine/Include/GameClient/Anim2D.h * fix(linkage): Fix static/extern linkage mismatches for MinGW (TheSuperHackers#2067) Adjust function and variable linkage to resolve MinGW-w64 linker errors caused by inconsistent static/extern declarations across translation units. MinGW-w64 is stricter about ODR (One Definition Rule) violations and requires consistent linkage specifications. Changes - Arrays and data: - Eva.cpp: Remove 'static' from TheEvaMessageNames array - Scripts.cpp: Remove 'static' from TheShellHookNames array - PopupPlayerInfo.cpp: Add 'static' to messageBoxYes to match definition Changes - Helper functions: - PartitionManager.cpp: Remove 'static' from hLine* functions Changes - Callback functions: - WOLBuddyOverlay.cpp: Remove 'static' from insertChat() - WOLLobbyMenu.cpp: Remove 'static' from WOL helper functions - W3DMainMenu.cpp: Remove 'static' from menu callback functions - GameWindowTransitionsStyles.cpp: Remove 'static' from transition functions All affected functions/variables are referenced from other translation units and require external linkage to resolve correctly with MinGW-w64. Files modified (8 files × 2 games = 16 total): - Eva.cpp, Scripts.cpp, PartitionManager.cpp, PopupPlayerInfo.cpp - WOLBuddyOverlay.cpp, WOLLobbyMenu.cpp - W3DMainMenu.cpp, GameWindowTransitionsStyles.cpp * fix(calling-convention): Standardize calling conventions and variadic macros (TheSuperHackers#2067) Standardize function calling conventions and variadic macro definitions for MinGW-w64 compatibility. Changes: - Add missing __cdecl to function pointers in GameText.h - Fix VA_ARGS macro definitions to use __VA_ARGS__ properly - Ensure consistent calling conventions across platforms This resolves calling convention mismatches that could cause undefined behavior when crossing DLL boundaries or using variadic macros with MinGW-w64. * fix(compatibility): Add compiler guards and GCC inline assembly for StackDump (TheSuperHackers#2067) Add explicit compiler checks and GCC-specific inline assembly implementation for the StackDump function to enable MinGW-w64 support. Changes: - Add #ifdef _MSC_VER guards around MSVC-specific inline assembly - Implement GCC-compatible inline assembly version using __asm__ __volatile__ - Add #error directive for unsupported compilers - Maintain identical functionality across compilers This enables stack dumping functionality to work correctly with both MSVC and MinGW-w64/GCC toolchains. * fix(casts): Add explicit void* casts for function pointers (TheSuperHackers#2067) Add explicit void* casts to function pointers in function tables and callback registrations to resolve MinGW-w64 type-punning warnings. Changes: 1. FunctionLexicon.cpp: - Cast all GameWindow callback functions to (void*) in: * gameWinDrawTable * gameWinSystemTable * gameWinInputTable * gameWinHelpBoxTable * gameWinTooltipTable 2. W3DFunctionLexicon.cpp: - Cast all W3D callback functions to (void*) in lexicon tables 3. SkirmishGameOptionsMenu.cpp: - Cast aiPlayerControlCallback to (void*) in window registrations MinGW-w64 requires explicit casts when storing function pointers with different signatures in void* fields, as the compiler is stricter about type safety than MSVC in this context. These casts are safe because the functions are later cast back to their correct types before invocation. Files modified: - FunctionLexicon.cpp (both games) - W3DFunctionLexicon.cpp (both games) - SkirmishGameOptionsMenu.cpp (both games) * fix(debug): Simplify unconditional DEBUG_ASSERTCRASH to DEBUG_CRASH (TheSuperHackers#2067) Replace DEBUG_ASSERTCRASH(nullptr, ...) with DEBUG_CRASH(...) for unconditional crash assertions in MinGW-w64 debug builds. Changes: - PlayerTemplate.cpp: DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH - ChallengeGenerals.cpp: DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH - LoadScreen.cpp: 2× DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH Total: 4 instances simplified across GeneralsMD codebase Rationale: DEBUG_ASSERTCRASH(nullptr, ...) was causing compilation errors with MinGW-w64 due to implicit nullptr-to-bool conversion. These instances represent "unconditional crash" assertions (always false condition). The DEBUG_CRASH macro is the semantically correct choice for this use case, making the intent explicit and avoiding type conversion issues. Error resolved: error: converting to 'bool' from 'std::nullptr_t' requires direct-initialization [-fpermissive] Historical note: These instances were introduced by commit f891c5f ("refactor: Modernize NULL to nullptr"). The original NULL was semantically 0 (false), not a null pointer check. Affects: GeneralsMD debug builds only * feat(cmake): Add debug symbol stripping for MinGW Release builds (TheSuperHackers#2067) Implement complete debug symbol separation for MinGW-w64 Release builds, matching MSVC PDB workflow. Debug symbols are now generated with -g and then stripped to separate .debug files post-build. Changes: - cmake/debug_strip.cmake: New module with add_debug_strip_target() function - Automatically finds toolchain objcopy and strip tools - Three-step process: extract symbols, strip exe, add debug link - Only applies to Release builds (Debug keeps embedded symbols) - cmake/compilers.cmake: Enable -g for all Release builds - Removed MinGW exception that was skipping debug symbols - Added comment explaining stripping workflow - CMakeLists.txt: Include debug_strip.cmake module - Generals/Code/Main/CMakeLists.txt: Apply stripping to g_generals - GeneralsMD/Code/Main/CMakeLists.txt: Apply stripping to z_generals Result files (Release): - generalsv.exe (12 MB, stripped) + generalsv.exe.debug (231 MB, symbols) - generalszh.exe (13 MB, stripped) + generalszh.exe.debug (250 MB, symbols) Benefits: - Crash dump analysis support (crashpad, breakpad) - Post-mortem debugging with full symbols - Performance profiling of optimized code - Parity with MSVC (exe + pdb workflow) - Smaller shipped binaries (symbols separate) Debug builds keep symbols embedded for development convenience. Tools used: GNU Binutils objcopy and strip * refactor(bitflags): Simplify and improve setup for DAMAGE_TYPE_FLAGS_ALL, DISABLEDMASK_ALL, KINDOFMASK_FS (TheSuperHackers#2159) * build(cmake): Dial back BINK upgrade to get the CMake INSTALL target to work again (TheSuperHackers#2167) * unify(damage): Merge DamageTypeFlags from Zero Hour (TheSuperHackers#2141) * refactor(pathfinder): Move obstacle handling functions from PathfindCell header to the cpp (TheSuperHackers#2140) * bugfix(pathfinder): Fix late game unit lockups and erroneous impassable terrain (TheSuperHackers#2140) * bugfix(aiupdate): Chinooks and Helixes now correctly wait for their passengers to disembark (TheSuperHackers#1792) Adjusts Chinook and Helix behavior so that they evacuate their passengers with the correct timing. Originally, the ExitDelay INI field of the TransportContain module was ignored and all passengers were immediately evacuated - unless the aircraft was already landed. With this change, the ExitDelay field is always respected and remains consistent across all evacuation pathways. If the immediate evacuation behavior is preferred, then the ExitDelay can be tweaked to 0. * fix(optionsmenu): Change incorrect OR/AND precedence of an unused condition in the OptionsMenu (TheSuperHackers#2164) * refactor: Fix confusing use of logical AND and OR expressions (TheSuperHackers#954) * perf(ini): Simplify, optimize and merge INI read line buffer implementation (TheSuperHackers#2143) * fix(thingfactory): Prevent use-after-free from assert in ThingFactory::reset() (TheSuperHackers#2172) * tweak(upgrade): Increase upgrade limit to 512 (TheSuperHackers#2162) * bugfix(ai): Units located above the terrain can no longer teleport into airborne transports (TheSuperHackers#1794) * unity(basetype): Merge Lib/BaseType.h code (TheSuperHackers#2180) * unify(subsystem): Merge SubsystemInterface code (TheSuperHackers#2180) * unify(ini): Merge INI and related code (TheSuperHackers#2180) * unify(common): Merge GameCommon and related code (TheSuperHackers#2180) * unify(userpreferences): Merge UserPreferences and related code (TheSuperHackers#2182) * unify(userpreferences): Move UserPreferences files to Core (TheSuperHackers#2182) * refactor(audioevent): Remove const casts for calling AudioEventRTS::setPlayingAudioIndex() (TheSuperHackers#2179) * unify(common): Merge TerrainTypes from Zero Hour (TheSuperHackers#2196) * unify(common): Merge PerfTimer, StackDump code from Zero Hour (TheSuperHackers#2195) * unify(common): Merge CriticalSection, ScopedMutex code from Generals (TheSuperHackers#2194) * unify(common): Merge Registry code (TheSuperHackers#2193) * unify(lib): Move BaseType.h, trig.h to Core (TheSuperHackers#2185) * unify(common): Move some common system files to Core (TheSuperHackers#2185) All that is needed for ParticleEditor to move to Core * bugfix(network): Revert changes to ConnectionManager::getMaximumLatency() to avoid a higher latency runahead than required (TheSuperHackers#2199) * fix(network): Fix slightly unstable latency calculation in FrameMetrics::processLatencyResponse() (TheSuperHackers#2200) * bugfix(dozeraiupdate): Builders now resume their task after having been disabled (TheSuperHackers#1870) * bugfix(actionmanager): Allow immediate resumed construction of buildings if the existing builder dies (TheSuperHackers#1872) * fix(activebody): Subdual damage can no longer go negative (TheSuperHackers#2184) * fix(basetype): Add min/max template functions to BaseType.h (TheSuperHackers#2183) Add lowercase min/max template functions to BaseType.h alongside existing uppercase MIN/MAX macros from BaseTypeCore.h. Problem: BitFlags.h and other GameEngine code needed readable min() calls, but VC6's <algorithm> lacks std::min/std::max. GameEngine code cannot rely on always.h (WWVegas layer). Solution: Add min/max templates to BaseType.h with header guard to prevent conflicts when GameEngine code includes both BaseType.h and WWVegas headers (which also define min/max in always.h). Implementation: - Use same header guard as always.h (_MIN_MAX_TEMPLATES_DEFINED_) - Templates coexist with uppercase MIN/MAX macros - Works with VC6, MSVC, and MinGW-w64 - Follows existing BaseType.h pattern (sqr, clamp, sign templates) * bugfix(ghostobject): Add Ghost Objects of the local player to the scene correctly after loading a savegame (TheSuperHackers#2186) * bugfix(mouse): Make Cursor Capture opt-in to prevent capture in GUIEdit (TheSuperHackers#2187) * unity(particlesys): Merge removal of Drawable Particle Attachments from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Merge addition of ParticleSystem::setSkipParentXfrm from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Compile out superfluous X and Y particle angles in Generals (TheSuperHackers#2153) * unify(particlesys): Merge addition of SMUDGE particle type from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Merge optimization of alpha particle update from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Merge fix for erroneous particle visibility thresholds in Particle::isInvisible from Generals (TheSuperHackers#2153) This merge fixes 13 broken particle effects in Zero Hour: airCarrierExplosion2 airCarrierHotPillarArms airCarrierJet01Explosion airCarrierJetExplosion1 airCarrierJetExplosion2 airCarrierJetExplosion3 ArmExplosionSmall01 BarrelExplosion BuggyNewExplosionArms FireBaseHowitzerPillarArms HotPillarArms MammothTankExplosionArms SpectreHotPillarArms * unify(particlesys): Merge optimization for wind motion particle update when disabled from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Merge changes to math for aligning particle Z rotation with emitter direction from Zero Hour (TheSuperHackers#2153) * unify(particlesys): Merge minor refactors in ParticleSystem (TheSuperHackers#2153) * refactor(view): Fix variable names in View::getScreenCornerWorldPointsAtZ() (TheSuperHackers#2201) * unify(particlesys): Move ParticleSys and ParticleEditor files to Core (TheSuperHackers#2212) * fix(radar): Fix Radar pixel color format for non A8R8B8G8 surfaces (TheSuperHackers#2170) * tweak(jetaiupdate): Defer offensive commands for parked jets without ammo (TheSuperHackers#2174) * build(debug): Add CMake option RTS_DEBUG_CHEATS to enable debug cheats in release builds (TheSuperHackers#1842) * bugfix(pathfinder): Fix some pinched cells being changed to impassable cells in internal_classifyObjectFootprint() (TheSuperHackers#2222) * unify(w3ddraw): Merge W3DModelDraw, W3DDependencyModelDraw code (TheSuperHackers#2225) * unify(w3ddraw): Move W3D Draw files to Core (TheSuperHackers#2225) * fix(camera): Apply misc code type and comment fixes (TheSuperHackers#2227) * refactor(basetype): Implement new functions Region3D::setFromPointsNoZ, Region3D::setFromPoints (TheSuperHackers#2228) * fix(radar): Always keep Radar View Box in sync with the actual Camera View (TheSuperHackers#2229) * fix(display): Polish the camera debug text in W3DDisplay::gatherDebugStats() (TheSuperHackers#2230) * bugfix(aigroup): GLA Battle Bus can now respond to attack commands while in bunkered form (TheSuperHackers#2213) * bugfix(gui): Fix game window animation movements to scale with display resolution (TheSuperHackers#2210) * fix(shadow): Fix crash by initializing debris shadow name to an empty string (TheSuperHackers#2221) * perf(particlesys): Reduce cost of ParticleSystemManager::findParticleSystem() by 80% (TheSuperHackers#2217) * perf(particlesys): Optimize angleBetween() in Particle System (TheSuperHackers#2218) * docs: Fix spelling errors in Generals/Code/GameEngine comments (2) (TheSuperHackers#2145) * docs: Fix spelling errors in GeneralsMD/Code/GameEngine comments (2) (TheSuperHackers#2146) * docs: Fix spelling errors in Core, GameEngineDevice, Libraries, Tools comments (2) (TheSuperHackers#2147) * refactor(view): Remove unused functions in View class (TheSuperHackers#2232) * refactor(view): Improve functions, variables, comments in View, W3DView (TheSuperHackers#2232) * refactor(view): Split View::setAngleAndPitchToDefault into 2 separate functions (TheSuperHackers#2232) * refactor(view): Simplify zoom adjustment code in W3DView::update() (TheSuperHackers#2232) * refactor(view): Consolidate duplicate terrain render update logic into new function W3DView::updateTerrain() (TheSuperHackers#2232) * refactor(view): Simplify Real Zoom Cam related code (TheSuperHackers#2232) * refactor(view): Simplify position code in W3DView::buildCameraTransform() (TheSuperHackers#2232) * refactor(view): Simplify Clip Planes related code in W3DView::setCameraTransform() (TheSuperHackers#2232) * fix(draw): Fix illogical dirt effect update code in W3DTruckDraw::doDrawModule(), W3DTankTruckDraw::doDrawModule() (TheSuperHackers#2234) * refactor(lanapi): Make LANMessage accessible in LANAPI (TheSuperHackers#2241) * feat(version): Add functions to get Git short hash string (TheSuperHackers#2243) * refactor(draw): Simplify particle effects code in W3DTankDraw, W3DTankTruckDraw, W3DTruckDraw (TheSuperHackers#2235) * fix(draw): Replace ParticleSystem pointers with ParticleSystemID for safe particle lookups in W3DTrankDraw, W3DTankTruckDraw, W3DTruckDraw (TheSuperHackers#2235) * fix(update): Fix value initialization of ProjectileStreamUpdate::m_projectileIDs (TheSuperHackers#2248) * refactor(audio): Replace AudioManager's loseFocus/regainFocus with reason-based mute/unmute functions (TheSuperHackers#2236) * tweak(pathfinder): Add audio event and message to announce pathfinding failover (TheSuperHackers#2242) * fix(update): Extend the height of the USA Particle Cannon laser beam for enormous camera heights (TheSuperHackers#2220) * feat(lanapi): Add LANAPI function to find LAN game with host IP address (TheSuperHackers#2249) * fix(debug): Allocate enough terrain debug icons based on the map dimensions in W3DDebugIcons() (TheSuperHackers#2231) * tweak(gui): Use default locale of user for listed replays and save games to match regional date time formats (TheSuperHackers#2254) * build(cmake): Force include CppMacros.h globally for VC6 (TheSuperHackers#2252) * fix: Replace sprintf with snprintf to prevent potential stack overflows (TheSuperHackers#2262) * refactor(netpacket): Simplify packet serialization code by using packed structs (TheSuperHackers#1680) * feat(gui): Implement Player Info List (TheSuperHackers#2136) * fix(netpacket): Fix misplaced null test in NetPacket::addCommand() (TheSuperHackers#2272) * fix(intro): Fix order of Display Update and Draw in intro loop (TheSuperHackers#2264) * fix(display): Fix VideoBuffer format selection in W3DDisplay::createVideoBuffer (TheSuperHackers#2265) * feat(gui): Add replay dates to replay list in Replay Menu (TheSuperHackers#2255) * refactor(view): Simplify View angle normalization (TheSuperHackers#2271) * fix(view): Prevent float division by zero in W3DView::setupWaypointPath() (TheSuperHackers#2274) * bugfix(object): Cancel previous tasks for captured dozers (TheSuperHackers#2237) * bugfix(cratecollide): Prevent crates from being collected multiple times in a single frame (TheSuperHackers#2279) * feat(gui): Add support for extra column to separate time and date in Replay Menu (TheSuperHackers#2278) To enable the fifth column, put COLUMNS: 5 in ReplayMenu.wnd:ListboxReplayFiles * bugfix(gui): Fix application hang from scrolling a map list with arrow keys (TheSuperHackers#2281) * perf(view): Optimize and simplify camera transform update logic (TheSuperHackers#2280) * fix(comments): Use 2026 for this year's code comments (TheSuperHackers#2285) * refactor(netpacket): Remove duplicate packed commands and cleanup code comments (TheSuperHackers#2283) * refactor(netpacket): Use more consistent names for packed net packet structs (TheSuperHackers#2283) * fix(netcommandmsg): Fix new/delete mismatch in NetWrapperCommandMsg (TheSuperHackers#2287) * fix(netpacket): Protect text length value from overflowing in NetPacketChatCommand, NetPacketDisconnectChatCommand (TheSuperHackers#2284) * bugfix(pathfinder): Fix uninitialized variable in Pathfinder::classifyFence() and possible source of mismatches in Retail-compatible builds (TheSuperHackers#1748) * bugfix(projectile): Fix out-of-bounds access in DumbProjectile which causes mismatch with very high speed weapons at small hit distances (TheSuperHackers#2087) * bugfix(ocl): Fix uninitialized variable in ObjectCreationList to avoid mismatches (TheSuperHackers#2096) * bugfix(contain): Prevent undefined behaviour when a dead unit enters a container (TheSuperHackers#2258) * chore(gui): Implement function GadgetTextEntrySetMaxLen() (TheSuperHackers#2290) * bugfix(view): Recalculate camera area constraints when toggling Control Bar or changing Pitch, FOV (TheSuperHackers#2291) * bugfix(worldbuilder): Fix script condition selection when editing newly created condition (TheSuperHackers#2289) * refactor(draw): Rename emitters functions in W3DTankDraw, W3DTankTruckDraw, W3DTruckDraw (TheSuperHackers#2251) * fix(draw): Recover tread debris effects for W3DTankTruckDraw (TheSuperHackers#2251) Tread debris can be enabled in W3DTankTruckDraw INI modules by setting TreadDebrisLeft=TrackDebrisDirtLeft TreadDebrisRight=TrackDebrisDirtRight * refactor(netpacket): Streamline order of net packet fields (TheSuperHackers#2288) * refactor(netpacket): Simplify initialization of net packet field types (TheSuperHackers#2288) * bugfix: Remove superfluous CD checks and related code (TheSuperHackers#2261) Investigations revealed that the Music.big handling was primarily a copy protection mechanism (SafeDisc) rather than for streaming audio. The engine attempted to read a specific file (often generalsa.sec) from the archive to verify a hash. Failure to read this file would trigger copy protection. This mechanism has been non-functional from the start and is now removed. * bugfix(network): Increase message buffer and max packet sizes to reduce connection issues (TheSuperHackers#2277) * fix(netpacket): Fix undefined behavior with NetPacket buffer writes (TheSuperHackers#2304) --------- Co-authored-by: Stubbjax <stubbjax02@hotmail.com> Co-authored-by: Bobby Battista <bobtista@gmail.com> Co-authored-by: xezon <4720891+xezon@users.noreply.github.com> Co-authored-by: stm <14291421+stephanmeesters@users.noreply.github.com> Co-authored-by: IamInnocent3X <i337y01_05vv4g@hotmail.com> Co-authored-by: Caball009 <82909616+Caball009@users.noreply.github.com> Co-authored-by: Sebyx07 <sebyx07@users.noreply.github.com> Co-authored-by: SkyAero <21192585+Skyaero42@users.noreply.github.com> Co-authored-by: Salem B. <46156444+jurassicLizard@users.noreply.github.com> Co-authored-by: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Co-authored-by: Mauller <26652186+Mauller@users.noreply.github.com> Co-authored-by: toph <tophroxx@outlook.com> Co-authored-by: githubawn <115191165+githubawn@users.noreply.github.com> Co-authored-by: abhatem <al.hatem.abdullah@gmail.com> Co-authored-by: Lemon <100478094+L3-M@users.noreply.github.com> Co-authored-by: helmutbuhler <buhler@8gadgetpack.net> Co-authored-by: Mads Jans <90150876+ViTeXFTW@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change fixes the undefined behavior with NetPacket buffer writes in
NetPacket::FillBufferfunctions.TODO