aboutsummaryrefslogtreecommitdiff
path: root/src/shared/net/lib/protobuf/net.proto
blob: 79d58e7e31830dcb02c9bc630b6216b411e56b98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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;
}

}