From 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 12 Feb 2025 18:05:18 +1100 Subject: initial commit --- src/shared/net/lib/protobuf/net.proto | 123 ++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/shared/net/lib/protobuf/net.proto (limited to 'src/shared/net/lib/protobuf/net.proto') diff --git a/src/shared/net/lib/protobuf/net.proto b/src/shared/net/lib/protobuf/net.proto new file mode 100644 index 0000000..79d58e7 --- /dev/null +++ b/src/shared/net/lib/protobuf/net.proto @@ -0,0 +1,123 @@ +syntax = "proto3"; + +package proto; + +// STRUCTS +message angles { + float pitch = 1; + float yaw = 2; +} + +message coords { + int32 x = 1; + int32 z = 2; +} + +message vec3 { + float x = 1; + float y = 2; + float z = 3; +} + +message ivec3 { + int32 x = 1; + int32 y = 2; + int32 z = 3; +} + +message player { + uint32 index = 1; + uint32 commands = 2; + + coords chunk_pos = 3; + vec3 local_pos = 4; + + angles viewangles = 5; + vec3 velocity = 6; +} +// END OF STRUCTS + +// PACKETS +message auth { + string username = 1; + string password = 2; +} + +message init { + uint64 seed = 1; + int32 draw_distance = 2; + player localplayer = 3; +} + +message move { + uint32 commands = 1; + angles viewangles = 2; +} + +message remove_player { + uint32 index = 1; +} + +message say { + string text = 1; +} + +message hear_player { + uint32 index = 1; + string text = 2; +} + +message request_chunk { + coords chunk_pos = 1; +} + +message remove_chunk { + coords chunk_pos = 1; +} + +message chunk { + coords chunk_pos = 1; + // There is no uint8, so we have to pack four blocks into each uint32. + repeated uint32 blocks = 2 [packed = true]; +} + +message add_block { + coords chunk_pos = 1; + ivec3 block_pos = 2; + // A bit inefficient as we only need 8 bits. We could use the rest for other + // stuff down the road. + uint32 block = 3; +} + +message remove_block { + coords chunk_pos = 1; + ivec3 block_pos = 2; +} + +message server_message { + string message = 1; + bool fatal = 2; +} +// END OF PACKETS + +// Actual thing we read. +message packet { + +oneof contents { + auth auth_packet = 1; + init init_packet = 2; + move move_packet = 3; + player player_packet = 4; + remove_player remove_player_packet = 5; + say say_packet = 6; + hear_player hear_player_packet = 7; + request_chunk request_chunk_packet = 8; + chunk chunk_packet = 9; + remove_chunk remove_chunk_packet = 10; + add_block add_block_packet = 11; + remove_block remove_block_packet = 12; + server_message server_message_packet = 13; +} + +} + -- cgit v1.2.3