Skip to content

Add FPS replication + projectile authority, client prediction hooks, and convergence smoke test#423

Merged
Krilliac merged 2 commits into
Workingfrom
codex/add-multiplayer-replication-features
Apr 9, 2026
Merged

Add FPS replication + projectile authority, client prediction hooks, and convergence smoke test#423
Krilliac merged 2 commits into
Workingfrom
codex/add-multiplayer-replication-features

Conversation

@Krilliac

@Krilliac Krilliac commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide end-to-end multiplayer integration points for the FPS game: replicate player transform/velocity/actions, authoritative projectile lifecycle and server-side hit validation, and client-side prediction/reconciliation hooks.
  • Give immediate visibility into networking health by exposing RTT/packet-loss and prediction correction metrics to console/editor for debug and tuning.
  • Add a deterministic, minimal smoke test to validate server/client state convergence and basic projectile spawn/despawn behavior under simulated latency.

Description

  • Extended NetworkPlayerState and PlayerInput in GameModules/SparkGameFPS/Source/Game/MultiplayerSystem.{h,cpp} to include per-player velocity, actionFlags, and acknowledgedInputSequence, and added ProjectileData fields for position/velocity/lifetime/ID/active state.
  • Implemented server-authoritative projectile spawn/update/despawn and per-frame UpdateProjectiles() with server-side hit checks that call NetworkManager::ValidateHit(...), and wired projectile spawn on both client prediction and server receipt.
  • Hooked up client prediction: FPSMultiplayerSystem records inputs into Spark::ClientPrediction, applies local prediction on SendInput(), and reconciles with authoritative snapshots via ReconcileToAuthoritativeState() while counting corrections.
  • Added light-weight interpolation buffer (m_remoteSnapshots) for remote players and snapshotting with acknowledged input sequences in SendStateSnapshot() to support reconciliation.
  • Exposed debug metrics: added correctionCount to NetworkStats, surfaced it in NetworkManager::Console_GetStats() and in FPSMultiplayerSystem::Console_GetStatus(), and provided NetworkManager::SetPredictionCorrectionCount() to update the global stat.
  • Added a minimal smoke test TEST(NetReplication_MultiplayerSmoke_ServerClientConvergence) in Tests/TestNetworkReplicationIntegration.cpp that simulates server/client frame loops with 2-frame latency, spawns/despawns a projectile, runs reconciliation, and asserts convergence and corrective behavior.

Testing

  • Ran cmake --preset linux-gcc-release successfully to configure the project.
  • Built SparkGameFPS with cmake --build build/linux-gcc-release --config Release --target SparkGameFPS -j 4 and the target completed successfully.
  • Began building the full test suite (SparkTests) but did not wait for the full test run to complete in-session due to build duration, so the new smoke test is included but not executed end-to-end here.

Codex Task

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/MemoryMonitor.cpp                        | 9.3%   236| 0.0%  19|    -    0
Utils/MemoryMonitor.h                          |85.7%    14| 0.0%  12|    -    0
Utils/MultiISA.h                               |42.9%    14| 0.0%   6|    -    0
Utils/NetworkHealthMonitor.cpp                 | 113%    15| 0.0%   2|    -    0
Utils/NetworkHealthMonitor.h                   |    -     0|    -   0|    -    0
Utils/OpaqueHandle.h                           | 282%    11| 0.0%  15|    -    0
Utils/ProcessLinux.cpp                         |16.5%   182| 0.0%  28|    -    0
Utils/Profiler.cpp                             |14.2%   113| 0.0%  15|    -    0
Utils/Profiler.h                               |36.4%    33| 0.0%  12|    -    0
Utils/RandomEngine.h                           |29.3%    41| 0.0%  12|    -    0
Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 108%    59| 0.0%  64|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             | 100%    48| 0.0%  42|    -    0
Utils/SparkConsole.cpp                         |28.5%   144| 0.0%  17|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |10.8%    74| 0.0%   8|    -    0
Utils/StateMachine.h                           |54.0%    63| 0.0%  32|    -    0
Utils/StringUtils.h                            |18.1%   116| 0.0%  21|    -    0
Utils/Telemetry.h                              |21.8%    87| 0.0%  16|    -    0
Utils/ThreadDebugger.h                         |11.6%   199| 0.0%  23|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/TimerManager.h                           |19.8%    96| 0.0%  19|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |6700%     1| 0.0%   1|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|29.4% 23168| 0.0%  3k|    -    0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 2776 694 25% 35%
Animation 160 154 96.2% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 2171 1328 61.2% 40%
ECS 161 103 64% 40%
Editor 5997 1864 31.1% 25%
GameModules 6244 3136 50.2% 30%
Graphics 7026 3643 51.9% 30%
Networking 3323 2091 62.9% 35%
Physics 0 0 0% 35%
Scripting 0 0 0% 30%
Utils 7625 4812 63.1% 60%

Total: 50.2% (17825/35483 lines)

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

❌ CI Error Report

Failed jobs: windows-vs2022-Debug
Errors: 4 | Test failures: 0 | Warnings: 0

Build Errors

Other errors (4)
SparkEditor\Source\Profiler\PerformanceProfiler.cpp(943,21): error C7568: argument list missing after assumed function template 'ComPtr' [build\SparkEditor\SparkEditor.vcxproj]
SparkEditor\Source\Profiler\PerformanceProfiler.cpp(944,34): error C2198: 'HRESULT (__cdecl *)(UINT,const IID &,void **)': too few arguments for call [build\SparkEditor\SparkEditor.vcxproj]
SparkEditor\Source\Profiler\PerformanceProfiler.cpp(988,17): error C7568: argument list missing after assumed function template 'ComPtr' [build\SparkEditor\SparkEditor.vcxproj]
SparkEditor\Source\Profiler\PerformanceProfiler.cpp(989,30): error C2198: 'HRESULT (__cdecl *)(UINT,const IID &,void **)': too few arguments for call [build\SparkEditor\SparkEditor.vcxproj]

Updated: 2026-04-09T06:40:47Z — this comment is updated in-place, not duplicated.

@Krilliac
Krilliac merged commit e9fcbe0 into Working Apr 9, 2026
21 of 23 checks passed
@Krilliac
Krilliac deleted the codex/add-multiplayer-replication-features branch April 9, 2026 05:49
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Code Coverage (GCC + lcov)

Utils/MemoryMonitor.cpp                        | 9.3%   236| 0.0%  19|    -    0
Utils/MemoryMonitor.h                          |85.7%    14| 0.0%  12|    -    0
Utils/MultiISA.h                               |42.9%    14| 0.0%   6|    -    0
Utils/NetworkHealthMonitor.cpp                 | 113%    15| 0.0%   2|    -    0
Utils/NetworkHealthMonitor.h                   |    -     0|    -   0|    -    0
Utils/OpaqueHandle.h                           | 282%    11| 0.0%  15|    -    0
Utils/ProcessLinux.cpp                         |16.5%   182| 0.0%  28|    -    0
Utils/Profiler.cpp                             |14.2%   113| 0.0%  15|    -    0
Utils/Profiler.h                               |36.4%    33| 0.0%  12|    -    0
Utils/RandomEngine.h                           |29.3%    41| 0.0%  12|    -    0
Utils/Result.h                                 | 100%    29| 0.0%  28|    -    0
Utils/RingBuffer.h                             | 108%    59| 0.0%  64|    -    0
Utils/ScopeGuard.h                             | 142%    36| 0.0%  51|    -    0
Utils/ScopedTimer.h                            |25.0%    12| 0.0%   3|    -    0
Utils/Serializer.h                             | 100%    48| 0.0%  42|    -    0
Utils/SparkConsole.cpp                         |28.5%   144| 0.0%  17|    -    0
Utils/SparkConsole.h                           | 100%     2| 0.0%   2|    -    0
Utils/SparkError.h                             |10.9%    55| 0.0%   6|    -    0
Utils/SplinePath.h                             |    -     0|    -   0|    -    0
Utils/StackTrace.h                             |10.8%    74| 0.0%   8|    -    0
Utils/StateMachine.h                           |54.0%    63| 0.0%  32|    -    0
Utils/StringUtils.h                            |18.1%   116| 0.0%  21|    -    0
Utils/Telemetry.h                              |21.8%    87| 0.0%  16|    -    0
Utils/ThreadDebugger.h                         |11.6%   199| 0.0%  23|    -    0
Utils/ThreadSafeQueue.h                        |27.5%    40| 0.0%  11|    -    0
Utils/TimerManager.h                           |19.8%    96| 0.0%  19|    -    0
Utils/UUID.h                                   |43.2%    37| 0.0%  16|    -    0
Utils/Validate.h                               |    -     0|    -   0|    -    0

[/home/runner/work/SparkEngine/SparkEngine/SparkSDK/Include/Spark/]
IEngineContext.h                               |6700%     1| 0.0%   1|    -    0
Version.h                                      |    -     0|    -   0|    -    0
================================================================================
                                         Total:|29.1% 23472| 0.0%  4k|    -    0

Per-Subsystem Coverage

Subsystem Lines Hit Coverage Threshold Status
AI 2776 694 25% 35%
Animation 160 154 96.2% 35%
Audio 0 0 0% 30%
Camera 0 0 0% 40%
Core 2184 1387 63.5% 40%
ECS 190 114 60% 40%
Editor 5997 1864 31.1% 25%
GameModules 6244 3131 50.1% 30%
Graphics 7172 3773 52.6% 30%
Networking 3323 2146 64.6% 35%
Physics 0 0 0% 35%
Scripting 0 0 0% 30%
Utils 7630 4817 63.1% 60%

Total: 50.7% (18080/35676 lines)

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