How volpestyle/kh2-multiplayer works
KH2 Multiplayer is a Kingdom Hearts II co-op mod: each player streams their own character, while the host owns shared enemies, rooms, and story state. The principal path runs from game hooks and bridges through the runtime’s network client to a session relay, then back to each runtime to apply remote-player and enemy state. The README documents the gameplay authority model and supported features; source-index references support selected internal links. Unsampled modules are included only where the README or tree identifies a meaningful subsystem, so some internal flows are omitted.
Main entry points: RuntimeMain.cpp Runtime orchestration · NetworkClient.cpp Network client · SessionHost.cpp Session relay · GameBridgePC.cpp PC game bridge
Components 19
Game integration
- Inject hooks
inject/src/DllMain.cpp - PC game bridge
runtime/src/GameBridgePC.cpp - Runtime orchestration
runtime/src/RuntimeMain.cpp
Gameplay synchronization
- Avatar bridge
common/include/kh2coop/AvatarBridge.hpp - Input mailbox
common/include/kh2coop/InputMailbox.hpp - Replica application
runtime/include/kh2coop/ReplicaController.hpp - Enemy and combat sync
inject/src/EnemySync.cpp
Network session
- Message protocol
common/include/kh2coop/Protocol.hpp - Packet codec
common/include/kh2coop/Codec.hpp - Network client
common/src/NetworkClient.cpp - Transport
common/include/kh2coop/Transport.hpp - Session relay
server/src/SessionHost.cpp
World and recovery
- Progress mirroring
common/include/kh2coop/ProgressMirror.hpp - World resync
common/include/kh2coop/ResyncProtocol.hpp - Client recovery
common/include/kh2coop/ClientRecovery.hpp
Diagnostics
- Desync collection
runtime/src/DesyncCollector.cpp - Relay capture
server/src/DesyncCapture.cpp
Other components
- Player
- KH2 process
Connections 21
- Player → KH2 process: plays locally
README.md - Inject hooks → KH2 process: hooks
README.md - PC game bridge → KH2 process: bridges memory
README.md - Runtime orchestration → PC game bridge: uses
runtime/src/RuntimeMain.cpp - Runtime orchestration → Network client: pumps
runtime/src/RuntimeMain.cpp - Runtime orchestration → Avatar bridge: streams avatars
runtime/src/RuntimeMain.cpp - Runtime orchestration → Input mailbox: exchanges input
runtime/src/RuntimeMain.cpp - Runtime orchestration → Replica application: applies snapshots
runtime/src/RuntimeMain.cpp - Replica application → PC game bridge: applies state
runtime/include/kh2coop/ReplicaController.hpp - Network client → Packet codec: encodes packets
- Network client → Transport: sends traffic
- Network client → Session relay: connects
README.md - Session relay → Network client: forwards traffic
README.md - Session relay → Message protocol: version-gates
- Network client → Message protocol: exchanges messages
- Runtime orchestration → Enemy and combat sync: synchronizes combat
README.md - Runtime orchestration → Progress mirroring: syncs progress
README.md - Runtime orchestration → World resync: requests recovery
runtime/src/RuntimeMain.cpp - Runtime orchestration → Client recovery: coordinates recovery
runtime/src/RuntimeMain.cpp - Runtime orchestration → Desync collection: collects reports
runtime/src/RuntimeMain.cpp - Session relay → Relay capture: captures evidence