Working on the server
This commit is contained in:
1 parent
075750442f
commit
28c6e83eda
30 files changed
+646
-362
No files matched your search
+25
-11
@@ -35,6 +35,8 @@ not enable the battle-zone test bot.
|
||||
thread from `update()`.
|
||||
- It maintains an internal `InternalGameServer` replica so existing snapshot
|
||||
consumers and transitional runtime-state bindings continue to work.
|
||||
- Camera orientation lives in host-owned `LocationLocalState`, so incoming
|
||||
authoritative snapshots cannot overwrite camera movement.
|
||||
- `submit()` intentionally discards all commands.
|
||||
- `drainEvents()` returns no events.
|
||||
- Client-side save and load calls are ignored because persistence remains
|
||||
@@ -51,11 +53,21 @@ The graphical game uses stable router objects for `IGameServer` and
|
||||
|
||||
When `NETWORK` is defined:
|
||||
|
||||
- `battle_zone` uses `WebsocketGameClient` and `RemoteGameServerHost`.
|
||||
- Every other campaign uses `InternalGameServer` and `LocalGameServerHost`.
|
||||
- `battle_zone_multiplayer` uses `WebsocketGameClient` and `RemoteGameServerHost`.
|
||||
- `main`, `battle_zone`, and every other campaign use `InternalGameServer` and
|
||||
`LocalGameServerHost`.
|
||||
|
||||
The WebSocket client is created only when `battle_zone` is selected and is
|
||||
destroyed when that campaign is unloaded.
|
||||
The WebSocket client is created only when `battle_zone_multiplayer` is selected
|
||||
and is destroyed when that campaign is unloaded. The single-player and
|
||||
multiplayer Battle Zone entries share location content and the start-state path,
|
||||
so the state can be regenerated through the single-player entry. At startup, the
|
||||
standalone server loads the authoritative half of that shared save and rewrites
|
||||
its campaign ID to `battle_zone_multiplayer`; each remote client restores only
|
||||
the local presentation half.
|
||||
|
||||
If DNS resolution, TCP connection, the WebSocket handshake, or the active socket
|
||||
fails, the client unloads the remote campaign and returns to the campaign
|
||||
selection screen.
|
||||
|
||||
## JSON Protocol
|
||||
|
||||
@@ -66,20 +78,22 @@ Messages use a versioned JSON envelope:
|
||||
"protocolVersion": 1,
|
||||
"type": "state",
|
||||
"payload": {
|
||||
"schemaVersion": 1
|
||||
"schemaVersion": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The payload temporarily uses the existing `GameState::save()` representation.
|
||||
The payload uses the authoritative `GameState::save()` representation and excludes
|
||||
the client-local location map, including camera orientation.
|
||||
The client applies it through `InternalGameServer::load()`.
|
||||
|
||||
Malformed JSON, unsupported protocol versions, unsupported message types, and
|
||||
invalid state payloads are logged and ignored.
|
||||
|
||||
This temporary full-state format is expected to be replaced or separated from
|
||||
the persistence schema as command handling and production replication are
|
||||
implemented.
|
||||
Single-player persistence uses a separate envelope that combines this authoritative
|
||||
document with client-local location state. The temporary full-state network format
|
||||
is still expected to be replaced by a dedicated replication schema or deltas as
|
||||
command handling and production replication are implemented.
|
||||
|
||||
## Build Configuration
|
||||
|
||||
@@ -106,7 +120,7 @@ cmake --build server/build --config Debug --target GameServer
|
||||
Run it from the repository root:
|
||||
|
||||
```powershell
|
||||
.\server\build\Debug\GameServer.exe --campaign battle_zone --location uni_exterior
|
||||
.\server\build\Debug\GameServer.exe --campaign battle_zone_multiplayer --location uni_exterior
|
||||
```
|
||||
|
||||
The listener defaults to `0.0.0.0:8080`. It can be changed with:
|
||||
@@ -116,7 +130,7 @@ The listener defaults to `0.0.0.0:8080`. It can be changed with:
|
||||
--port N
|
||||
```
|
||||
|
||||
Launch the Windows game and select `battle_zone`. The client connects to
|
||||
Launch the Windows game and select `battle_zone_multiplayer`. The client connects to
|
||||
`127.0.0.1:8080`. Selecting another campaign continues to use the local server.
|
||||
|
||||
## Verification
|
||||
|
||||
Reference in new issue
Block a user