Skip to content

Commit

Permalink
simplify datagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed May 25, 2024
1 parent e0b95ec commit a58b4aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
25 changes: 11 additions & 14 deletions world/schemas/datagram.capnp
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
@0x875d2f2c381d4863;

struct Vec3 {
x @0 :Float32 = 0.0;
y @1 :Float32 = 0.0;
z @2 :Float32 = 0.0;
x @0 :Float32;
y @1 :Float32;
z @2 :Float32;
}

struct Vec4 {
x @0 :Float32 = 0.0;
y @1 :Float32 = 0.0;
z @2 :Float32 = 0.0;
w @3 :Float32 = 0.0;
}

struct Transform {
translation @0 :Vec3 = (x = 0.0, y = 0.0, z = 0.0);
rotation @1 :Vec4 = (x = 0.0, y = 0.0, z = 0.0, w = 0.0);
x @0 :Float32;
y @1 :Float32;
z @2 :Float32;
w @3 :Float32;
}

struct PublishTransform {
transform @0 :Transform;
translation @0 :Vec3;
rotation @1 :Vec4;
}

struct ReceiveTransform {
playerId @0 :UInt16;
transform @1 :Transform;
translation @1 :Vec3;
rotation @2 :Vec4;
}
28 changes: 14 additions & 14 deletions world/schemas/world_server.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

struct Option(T) {
union {
some @0: T;
none @1: Void;
some @0 :T;
none @1 :Void;
}
}

struct Result(T) {
union {
result @0: T;
error @1: Text;
result @0 :T;
error @1 :Text;
}
}

struct Success {
union {
success @0: Void;
error @1: Text;
success @0 :Void;
error @1 :Text;
}
}

interface WorldServer {
join @0 (recordId: Text) -> (success: Success);
leave @1 (recordId: Text);
join @0 (recordId :Text) -> (success :Success);
leave @1 (recordId :Text);

# Tickrate of the server, in seconds.
# Sending updates faster than this interval will be detrimental.
tickrate @2 () -> (tickrate: Float32);
# Sending updates faster than this will be detrimental.
tickrate @2 () -> (tickrate :Float32);

player @3 (id: UInt16) -> (player: Option(Player));
players @4 () -> (players: List(Player));
player @3 (id :UInt16) -> (player :Option(Player));
players @4 () -> (players :List(Player));

struct Player {
id @0: UInt16;
did @1: Text;
id @0 :UInt16;
did @1 :Text;
}
}

0 comments on commit a58b4aa

Please sign in to comment.