Files
Commonwealth-Online-Public/server/README.md
T
andrew 8c09e91534 Add basic movement state to transform packets
Add optional movement-state fields (isMoving, isSprinting, isSneaking, isJumping, weaponDrawn, movementSpeed) to transform packets and wire them end-to-end. Plugin changes: extend F4TNetworking API and RemotePlayerState, derive movement speed/jump state on the game-thread, validate values, include fields when formatting transform JSON, and add throttled remote movement-state logging. main.cpp adds sampling, speed/vertical calculations, jump hold logic, and change-detection to avoid extra sends. Networking parsing (F4TNetworking.cpp) reads optional booleans/floats safely, preserves backwards compatibility, and clears movement-state logs on disconnect. Proxy controller includes a TODO note for future animation use. Server and docs: update protocol and packet docs, dev-log, server README, and fake_client.py to parse/display optional fields safely. Also add several .cursor rule files for coding, documentation, protocol, project overview, and testing guidance. This milestone prepares the data model for later animation/behavior work while keeping existing relay behavior unchanged.
2026-06-02 13:27:40 +12:00

108 lines
3.1 KiB
Markdown

# Server
This folder is for the external multiplayer test server.
The current server is a tiny local-only TCP test server. It listens on
`127.0.0.1:7777`, accepts one or more clients, reads newline-separated JSON
packets, assigns incrementing `playerId` values, sends `welcome` packets, adds
`playerId` and `serverTime` to transform packets, broadcasts transform packets
to every other connected client, and broadcasts disconnect packets when clients
disconnect.
Transform packets may include optional movement-state fields such as
`isMoving`, `isSprinting`, `isSneaking`, `isJumping`, `weaponDrawn`, and
`movementSpeed`. The server preserves these fields automatically because it
broadcasts the original transform packet after adding server-owned fields.
This is still a local prototype. It does not make Fallout 4 multiplayer
playable yet.
## Run
```bash
cd server
python server.py
```
Then launch Fallout 4 through F4SE and move the player. The plugin should send
local player transform packets, and this server should print matching
`transform` packets.
If the server is not running, the plugin should log a warning and Fallout 4
should continue launching normally.
## Current Test Flow
Terminal 1:
```bash
cd server
python server.py
```
Terminal 2:
```bash
cd server
python fake_client.py
```
Then launch Fallout 4 through F4SE and move the player.
Expected behavior:
- The server assigns a `playerId` to each connected client and sends each client
a `welcome` packet.
- The server receives transforms from the Fallout 4 plugin.
- The server adds `playerId` and `serverTime` to each transform packet before
broadcast.
- The server preserves optional movement-state fields on transform packets.
- The server broadcasts those transform packets to connected clients except the
sender.
- `fake_client.py` receives broadcast transform packets.
- `fake_client.py` stores remote player state by `playerId`.
- When a client disconnects, the server removes that client and broadcasts a
`disconnect` packet with the departed `playerId` to the remaining clients.
- `fake_client.py` removes disconnected players from its in-memory
`remote_players` table.
The fake client exists so broadcast behavior can be tested before coordinating a
second Fallout 4/F4SE instance. It stores remote player transform state only; it
does not spawn remote actors or send movement.
## Implemented
- Start local server
- Accept client connections
- Assign server-owned player IDs
- Send welcome packets
- Receive transform packets
- Add server timestamps
- Preserve optional transform fields
- Broadcast transforms to other connected clients
- Broadcast disconnect packets
- Handle disconnect cleanup
## Working In Fake Client Only
- Receiving welcome packets
- Receiving transform broadcasts
- Storing remote player state
- Removing disconnected remote players
The Fallout 4 plugin does not yet receive remote transforms from the server.
## Planned Later
- Fallout 4 plugin receive loop
- Plugin-side remote player state storage
- Remote actor spawning
- Gameplay synchronization
- Authentication
- Public matchmaking
- Anti-cheat
- Persistence
- Quest state
- Settlement state
- Large-scale world simulation