Implement tiled multiplayer city simulation and scaling stages

This commit is contained in:
mrleo1nid committed 2026-10-30 22:06:56 +03:00
1 parent 3d4b29fedf
commit 3b1fcd996a
53 files changed
+7354 -13

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# Shared protocol
`city.proto` defines WebSocket messages, city generation jobs and room snapshots.
Run `npm run proto:generate` to regenerate the committed TypeScript bindings.
Rust bindings are generated by Cargo using a vendored protoc executable.
Handshake protocol version is 1. Positions are signed centimetres and resident
IDs are uint32. Snapshots replace the AOI; deltas use absolute changed values
so intermediate ticks can be coalesced. New fields must be additive; never
reuse field numbers. An incompatible save version is rejected explicitly.
Static city format v1 uses JSON + gzip, independently of the network protocol.
+32
View File
@@ -0,0 +1,32 @@
syntax = "proto3";
package city;
message Rect { sint32 min_x = 1; sint32 min_y = 2; sint32 max_x = 3; sint32 max_y = 4; }
message Join { string room = 1; uint32 client_version = 2; string nickname = 3; }
message Subscribe { Rect rect = 1; uint32 lod = 2; }
message Ping { uint32 nonce = 1; }
message Propose { uint32 speed = 1; }
message Vote { bool yes = 1; }
message CreateCity { repeated double bbox = 1; string name = 2; uint32 seed = 3; }
message CityJob { string id = 1; string city_id = 2; string status = 3; string room_id = 4; string error = 5; string stage = 6; }
message ClientMessage {
oneof body { Join join = 1; Subscribe subscribe = 2; Ping ping = 3; Propose propose = 4; Vote vote = 5; }
}
message Agent { uint32 id = 1; sint32 x = 2; sint32 y = 3; uint32 kind = 4; }
message Welcome { string room = 1; uint64 tick = 2; string city_manifest_url = 3; string session = 4; uint32 protocol_version = 5; }
message Snapshot { uint64 tick = 1; repeated Agent entities = 2; }
message Delta { uint64 tick = 1; repeated Agent spawned = 2; repeated Agent changed = 3; repeated uint32 despawned = 4; }
message Error { string code = 1; string message = 2; }
message VoteState { bool active = 1; uint32 speed = 2; uint32 yes = 3; uint32 players = 4; uint32 remaining_seconds = 5; }
message Clock { uint64 tick = 1; double game_seconds = 2; uint32 speed = 3; }
message ServerMessage {
oneof body { Welcome welcome = 1; Snapshot snapshot = 2; Delta delta = 3; Error error = 4; Ping pong = 5; VoteState vote_state = 6; Clock clock = 7; }
}
message SavedAgent { uint32 id = 1; uint32 route = 2; double distance = 3; }
message Route { repeated sint32 xy = 1; string home_id = 2; string workplace_id = 3; }
message RoomSave {
uint32 version = 1; string id = 2; string city_id = 3; uint32 city_version = 4;
uint64 tick = 5; uint64 seed = 6; double game_seconds = 7; uint32 speed = 8;
repeated SavedAgent agents = 9; repeated Route routes = 10;
string city_revision = 11;
}