Skip to content

Conversation

@Matlord93
Copy link
Contributor

@Matlord93 Matlord93 commented Oct 5, 2025

This section introduces a compatibility layer for setting ConVar flags that adapts to different Source 2 SDK versions.
Older and newer SDK builds expose slightly different APIs for modifying ConVar flags (AddFlags, ClearFlags, RemoveFlags, or SetFlag).
To ensure compatibility across these versions, the new implementation detects at compile time which API is available and uses it automatically.

The concept definitions check whether the ConVar type provides specific flag functions:

HasAddClear: uses AddFlags() and ClearFlags()

HasAddRemove: uses AddFlags() and RemoveFlags()

HasSetFlagBit: uses SetFlag(bit, bool)

The SetAllFlagsCompat function then compares the current flags with the desired ones and applies the correct operations:

Adds or clears bits using whichever API the SDK exposes.

Falls back to setting individual bits if only SetFlag() is available.

This change is required for the current Source 2 SDK,
as the internal ConVar implementation and flag management functions have changed between builds.
The new logic ensures consistent behavior without relying on private members such as m_nFlags,
making the code safer, forward-compatible, and SDK-agnostic.

💬 In short:

This update introduces a flexible flag-handling mechanism required by the latest Source 2 SDK to remain compatible with internal API changes and to avoid direct access to private ConVar data.

Fix new Debian and Ubuntu version and Stop Leak
@Matlord93 Matlord93 requested a review from roflmuffin as a code owner October 5, 2025 08:29
@Matlord93
Copy link
Contributor Author

Fix issues #1013 and #1024

@Matlord93 Matlord93 changed the title Update natives_convars.cpp Fix new Debian and Ubuntu version and Stop Leak Oct 5, 2025
Fix new Debian and Ubuntu version, Stop Leak and Code format checks / Lint code with clang-format
@Matlord93
Copy link
Contributor Author

Please run the workflow again and check whether everything has been written and adjusted correctly.

I have now followed the guidelines and made this adjustment.

The change is currently compatible with the new update as well as the old Linux version

@Matlord93 Matlord93 mentioned this pull request Oct 17, 2025
@Matlord93 Matlord93 changed the title Fix new Debian and Ubuntu version and Stop Leak ConVar flags that adapts to different Source 2 SDK versions Oct 17, 2025
@roflmuffin roflmuffin enabled auto-merge (squash) October 18, 2025 01:02
@roflmuffin roflmuffin merged commit a21f0b5 into roflmuffin:main Oct 18, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants