Skip to content

Add snapshots patching plugin API#450

Open
ObelardO wants to merge 2 commits into
callofduty4x:masterfrom
ObelardO:snapshot-patch-api
Open

Add snapshots patching plugin API#450
ObelardO wants to merge 2 commits into
callofduty4x:masterfrom
ObelardO:snapshot-patch-api

Conversation

@ObelardO

@ObelardO ObelardO commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • Add minimal hook calls in SV_BuildClientSnapshot so plugins can modify outgoing per-client snapshots without rewriting snapshot build logic.
  • Implement snapshot patch dispatch in new plugin_snapshot_patching.c (registration, chained multi-plugin callbacks, sorted append for injected entities/clientStates).
  • Expose plugin API: three patch hooks (playerState, entity, clientState) with SNAPSHOT_PATCH_MODIFY / SNAPSHOT_PATCH_APPEND modes, plus archived client lookup helpers for killcam replay.

Design

  • sv_snapshot.c only calls thin wrappers; all plugin-specific logic lives in plugin_snapshot_patching.c.
  • Multiple plugins can register hooks; callbacks run in plugin slot order (chained MODIFY, each plugin may APPEND).
  • function_declarations.h and plugin_exports.c export register/unregister and Plugin_SV_GetArchived* helpers.

Test plan

  • Server builds on Windows/Linux
  • Plugin loads and registers snapshot patch callbacks without errors
  • Existing plugins unaffected when no snapshot patch is registered
  • Two plugins registering snapshot hooks both receive MODIFY/APPEND calls in order
  • Archived client origin/entity/state helpers return expected replay data during killcam

Notes

Companion plugin (FinalKillcamEntityCamera) lives on fork branch final-killcam-plugin and is intentionally not included in this PR.

@proxict

proxict commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Hi, could you please elaborate what your goal is with these changes?

@ObelardO

ObelardO commented Jul 6, 2026

Copy link
Copy Markdown
Author

Hi! I'm currently working on a couple of plugins for my server:

  1. An anti-cheat plugin that can modify outgoing snapshots. My goal is to strip redundant data, for instance, based on player distance.

  2. A final killcam plugin capable of replaying match events with specific modifications. For example, a third-person killcam for entities like explosives, vehicles, or killstreaks. The stock game has an issue where the killcam's camera angle is calculated client-side and is bound to the player watching the killcam rather than the player getting killed in it. To avoid modifying the client files, I'm using some entity-spoofing workarounds.

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