Add a networking receive loop and in-plugin remote-player storage. Introduces F4TRemotePlayerState (header + implementation) to track assigned playerId and remote player snapshots with thread-safe access. Expands F4TNetworking to start/stop a background receive thread, parse newline-separated JSON packets (welcome, transform, disconnect), validate fields, update remote state, throttle logs, and handle socket/thread synchronization. Add nlohmann_json to xmake and plugin build. Update docs and dev log to reflect the new receive behavior and current prototype scope.
2.8 KiB
Architecture
Current Architecture
Fallout 4 Plugin ↔ Local Python Server ↔ Other Clients
↓
Plugin Remote Player State
The current system is still a local prototype, but the Fallout 4 plugin now has both send and receive paths:
- The Fallout 4 plugin reads local player transform data.
- The plugin sends transform packets to the local Python server on
127.0.0.1:7777. - The server assigns
playerIdvalues and sendswelcomepackets. - The plugin receives its
welcomepacket and stores its assignedplayerId. - The server adds
playerIdandserverTimeto transform packets. - The server broadcasts transform packets to other connected clients.
- The plugin and
server/fake_client.pystore remote player state byplayerId. - The server broadcasts
disconnectpackets when clients disconnect. - The plugin and fake client remove disconnected players from their remote player tables.
The Fallout 4 plugin still does not spawn or move remote actors.
Main Components
F4SE Plugin
The native plugin is responsible for:
- Loading into Fallout 4
- Reading local player state
- Sending local player data to the server
- Receiving server packets on a background thread
- Storing assigned and remote
playerIdstate internally
Planned later:
- Applying remote player updates safely
- Spawning or moving remote actors
External Server
The server is responsible for:
- Accepting client connections
- Assigning player IDs
- Sending welcome packets
- Receiving player state
- Broadcasting player state
- Tracking disconnects
- Broadcasting disconnect packets
Fake Client
The fake client is responsible for:
- Connecting to the local server
- Receiving welcome packets
- Receiving broadcast transform packets
- Storing remote player state by
playerId - Removing remote players when disconnect packets arrive
The fake client is a temporary receiver for testing the networking lifecycle. It does not spawn remote actors or represent playable multiplayer.
Creation Kit Plugin
The Creation Kit side is planned later and may be responsible for:
- Test cells
- Placeholder actors
- Optional Papyrus helper scripts
- Debug objects
- Controlled test environments
Threading Model
Networking should run separately from game update logic.
Current approach:
Networking thread receives packets
Networking thread stores remote player state
Game update reads remote player state
Future game update applies actor movement
The networking receive thread does not directly modify Fallout 4 actors or game objects. It parses newline-separated JSON, updates plain C++ remote-player state, and leaves actor spawning or movement for a later game-thread milestone.
Out Of Scope For Current Prototype
- Remote actor spawning
- Combat sync
- Quest sync
- Inventory sync
- Settlement sync
- Public servers or matchmaking