diff options
Diffstat (limited to 'test-client')
-rw-r--r-- | test-client/main.ts | 5 | ||||
-rw-r--r-- | test-client/protocol.ts | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/test-client/main.ts b/test-client/main.ts index f295e0ca..0d2ba8fb 100644 --- a/test-client/main.ts +++ b/test-client/main.ts @@ -98,7 +98,7 @@ export const players = new Map<PlayerID, PlayerData>() export const tiles = new Map<string, TileData>() export const items_removed = new Set<ItemData>() -export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], tile_collide: [], tile_interact: [], map_names: [] } +export let data: Gamedata = { item_names: [], tile_names: [], spawn: [0, 0], tile_collide: [], tile_interact: [], maps: {} } export let time_remaining: number | null = null export let global_message: MessageData | undefined = undefined @@ -126,6 +126,9 @@ function packet(p: PacketC) { if (!["position", "set_progress", "update_map"].includes(p.type)) console.log(p); switch (p.type) { + case "version": + console.log(`Protocol version: ${p.major}.${p.minor}`); + break; case "init": my_id = p.id break; diff --git a/test-client/protocol.ts b/test-client/protocol.ts index 10b5b2dc..2cd58f75 100644 --- a/test-client/protocol.ts +++ b/test-client/protocol.ts @@ -44,7 +44,8 @@ export type PacketS = | { type: "collide", player: PlayerID, force: Vec2 } // Apply force to another player as a result of a collision export type PacketC = - { type: "init", id: PlayerID } // You just connected. This is your id for this session. + { type: "version", minor: number, major: number } // Sent once after connecting to ensure you client is compatible + | { type: "init", id: PlayerID } // You just connected. This is your id for this session. | { type: "data", data: Gamedata } // Game data was changed | { type: "add_player", id: PlayerID, name: string, position: Vec2, character: number } // Somebody else joined (or was already in the game) | { type: "remove_player", id: PlayerID } // Somebody left |