update overlay to have ps controls too
[carveJwlIkooP6JGAAIwe30JlM.git] / network_msg.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef NETWORK_MSG_H
6 #define NETWORK_MSG_H
7
8 #include "world_info.h"
9 #include "vg/vg_platform.h"
10 ;
11
12 #pragma pack(push,1)
13
14 typedef struct netmsg_blank netmsg_blank;
15 enum{ k_inetmsg_blank = 0 };
16 struct netmsg_blank{
17 u16 inetmsg_id;
18 };
19
20 /* send after version */
21 typedef struct netmsg_auth netmsg_auth;
22 enum{ k_inetmsg_auth = 1 };
23 struct netmsg_auth
24 {
25 u16 inetmsg_id;
26
27 u32 ticket_length;
28 u8 ticket[];
29 };
30
31 /* version should be sent before auth */
32 typedef struct netmsg_version netmsg_version;
33 enum{ k_inetmsg_version = 2 };
34 struct netmsg_version{
35 u16 inetmsg_id;
36 u32 version;
37 };
38
39 /* server control 100 */
40
41 /* player updates 200 */
42
43 #define NETMSG_BOUNDARY_BIT 0x8000
44 #define NETMSG_GATE_BOUNDARY_BIT 0x4000
45 #define NETMSG_BOUNDARY_MASK (NETMSG_BOUNDARY_BIT|NETMSG_GATE_BOUNDARY_BIT)
46 #define NETMSG_PLAYERFRAME_INSTANCE_ID 0x3
47 #define NETMSG_PLAYERFRAME_HAVE_GLIDER 0x4
48 #define NETMSG_PLAYERFRAME_GLIDER_ORPHAN 0x8
49
50 typedef struct netmsg_playerframe netmsg_playerframe;
51 enum{ k_inetmsg_playerframe = 200 };
52 struct netmsg_playerframe{
53 u16 inetmsg_id;
54 f64 timestamp;
55
56 u8 client, subsystem,
57 flags, sound_effects;
58 u16 boundary_hash; /* used for animating correctly through gates, teleport..
59 msb is a flip flop for teleporting
60 second msb is flip flop for gate */
61
62 u8 animdata[];
63 };
64
65 typedef struct netmsg_playerjoin netmsg_playerjoin;
66 enum{ k_inetmsg_playerjoin = 201 };
67 struct netmsg_playerjoin{
68 u16 inetmsg_id;
69 u8 index;
70 u64 steamid;
71 };
72
73 typedef struct netmsg_playerleave netmsg_playerleave;
74 enum{ k_inetmsg_playerleave = 202 };
75 struct netmsg_playerleave{
76 u16 inetmsg_id;
77 u8 index;
78 };
79
80 typedef struct netmsg_playerusername netmsg_playerusername;
81 enum{ k_inetmsg_playerusername = 203 };
82 struct netmsg_playerusername{
83 u16 inetmsg_id;
84 u8 index;
85 char name[];
86 };
87
88 typedef struct netmsg_playeritem netmsg_playeritem;
89 enum{ k_inetmsg_playeritem = 204 };
90 struct netmsg_playeritem{
91 u16 inetmsg_id;
92 u8 client;
93 u8 type_index;
94 char uid[];
95 };
96 enum netmsg_playeritem_type {
97 k_netmsg_playeritem_board = 0,
98 k_netmsg_playeritem_player,
99 k_netmsg_playeritem_world0,
100 k_netmsg_playeritem_world1,
101 k_netmsg_playeritem_max
102 };
103
104 typedef struct netmsg_chat netmsg_chat;
105 enum{ k_inetmsg_chat = 205 };
106 struct netmsg_chat {
107 u16 inetmsg_id;
108 u8 client;
109 char msg[];
110 };
111
112 typedef struct netmsg_region netmsg_region;
113 enum{ k_inetmsg_region = 206 };
114 struct netmsg_region {
115 u16 inetmsg_id;
116 u8 client;
117 u32 flags;
118 char loc[];
119 };
120
121 /* requests 300 */
122 typedef struct netmsg_request netmsg_request;
123 enum{ k_inetmsg_request = 300, k_inetmsg_response = 301 };
124 struct netmsg_request {
125 u16 inetmsg_id;
126 u8 id, status;
127 u8 q[];
128 };
129
130 enum request_status {
131 k_request_status_client_error = 0,
132 k_request_status_invalid_endpoint = 1,
133 k_request_status_unauthorized = 2,
134
135 k_request_status_server_error = 100,
136 k_request_status_out_of_memory = 101,
137 k_request_status_database_error = 102,
138
139 k_request_status_ok = 200,
140 k_request_status_not_found = 201
141 };
142
143 #pragma pack(pop)
144 #endif /* NETWORK_MSG_H */