Skip to content

Add FiveM 3717/3757 compatibility layer and guarded native integration#13

Open
Lens931 wants to merge 1 commit into
masterfrom
codex/port-chaosmod-for-fivem-clients-3717-and-3757
Open

Add FiveM 3717/3757 compatibility layer and guarded native integration#13
Lens931 wants to merge 1 commit into
masterfrom
codex/port-chaosmod-for-fivem-clients-3717-and-3757

Conversation

@Lens931

@Lens931 Lens931 commented Feb 24, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Support FiveM modern clients (3717 and 3757) by isolating low-level native/signature differences and avoiding incompatible hooks.
  • Keep ChaosMod gameplay/effects intact while making the integration layer (ScriptHookV/ASI, GetGlobalPtr, native wrappers, hook gating) robust across these FiveM builds.

Description

  • Added a new compatibility module Memory::FiveMCompat with ClientBuild detection for 3717/3757, per-build NativeOffsets profiles, and detailed startup logs via LogCompatibilityStatus(); see ChaosMod/Memory/FiveMCompat.* and docs docs/fivem_3717_3757_build.json.
  • Centralized native call compatibility in NativeCompat (in Main.cpp) and replaced direct calls to WAIT, IS_SCREEN_FADED_OUT, DO_SCREEN_FADE_IN, and SET_ENTITY_HEALTH with wrappers that consult FiveMCompat profiles and support a guarded 2-arg SET_ENTITY_HEALTH variant via #if defined(CHAOS_FIVEM_SET_ENTITY_HEALTH_2ARGS).
  • Updated Memory::GetGlobalPtr routing to consult FiveMCompat::IsFiveM()/DetectClientBuild() and emit build-specific logs while keeping a conservative fallback to SHV where required; added #include "Memory/FiveMCompat.h" where needed.
  • Added a loader-compatibility helper in dllmain.cpp (CanRegisterWithCurrentLoader) to log/guard scriptRegister/ASI registration on FiveM hosts and documented loader limitations.
  • Added a compile-time gate CHAOS_DISABLE_INCOMPATIBLE_FIVEM_HOOKS to skip the rage::scrThread::Run hook on unsupported FiveM builds and inserted checks in Memory/Hooks/ScriptThreadRunHook.cpp.
  • Documented build and runtime notes and a machine-readable test/build profile at docs/fivem_3717_3757_build.json and added a short README section explaining limitations and expected logs.
  • Preserved the project structure and effect code (components/effects) and limited changes to the low-level integration layer only, with clear inline comments explaining each change and limitation.

Testing

  • Verified code changes via repository searches for inserted symbols/logs using ripgrep (rg) to confirm FiveMCompat, NativeCompat wrappers, build guards, and compatibility logs were added and referenced (succeeded).
  • Attempted to configure a local build with cmake -S ChaosMod -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo, which failed because the environment CMake is 3.28.3 while the project requires 3.31+ (configuration failed).
  • Performed lightweight validations (file presence and grep-based smoke tests) to confirm the new JSON doc docs/fivem_3717_3757_build.json and README section are present and the compatibility log strings exist (succeeded).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant