From edb93777451b404e127dcfac2b636b680f134567 Mon Sep 17 00:00:00 2001 From: Sceat Date: Wed, 10 Jul 2024 01:20:12 +0900 Subject: [PATCH] feat: improve fight packet --- generated/ares_pb.js | 20 ++++++++++++++++++++ proto/ares.proto | 3 +++ src/index.js | 1 + src/types.d.ts | 3 +++ 4 files changed, 27 insertions(+) diff --git a/generated/ares_pb.js b/generated/ares_pb.js index 4c4488f..1f4b261 100644 --- a/generated/ares_pb.js +++ b/generated/ares_pb.js @@ -269,6 +269,26 @@ export const FightSpawn = /*@__PURE__*/ proto3.makeMessageType( { no: 7, name: 'started', kind: 'scalar', T: 8 /* ScalarType.BOOL */ }, { no: 8, name: 'locked', kind: 'scalar', T: 8 /* ScalarType.BOOL */ }, { no: 9, name: 'need_help', kind: 'scalar', T: 8 /* ScalarType.BOOL */ }, + { + no: 10, + name: 'team1_positions', + kind: 'message', + T: Position, + repeated: true, + }, + { + no: 11, + name: 'team2_positions', + kind: 'message', + T: Position, + repeated: true, + }, + { + no: 12, + name: 'start_time', + kind: 'scalar', + T: 4 /* ScalarType.UINT64 */, + }, ], ) diff --git a/proto/ares.proto b/proto/ares.proto index e1a504c..92f56ac 100644 --- a/proto/ares.proto +++ b/proto/ares.proto @@ -69,6 +69,9 @@ message FightSpawn { bool started = 7; bool locked = 8; bool need_help = 9; + repeated Position team1_positions = 10; + repeated Position team2_positions = 11; + uint64 start_time = 12; } // ======================================== [CLIENT -> SERVER] diff --git a/src/index.js b/src/index.js index 2b1710b..2b9adf6 100644 --- a/src/index.js +++ b/src/index.js @@ -42,6 +42,7 @@ export function create_client({ socket_write, socket_end }) { const raw_packet = Packets.Packet.fromBinary( new Uint8Array(message), ).toJson({ + useProtoFieldName: true, emitDefaultValues: true, }) const [[type, value]] = Object.entries(raw_packet) diff --git a/src/types.d.ts b/src/types.d.ts index d7631f2..d31def3 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -64,12 +64,15 @@ type Fight = { id: string team1: Entity[] team2: Entity[] + team1_positions: Position[] + team2_positions: Position[] spectators: string[] top_left: Position bottom_right: Position started: boolean locked: boolean need_help: boolean + start_time: number } type Packets = {