RigsofRods
Soft-body Physics Simulation
RoRnet.h
Go to the documentation of this file.
1 /*
2  This file is part of Rigs of Rods
3 
4  Copyright 2007 Pierre-Michel Ricordel
5  Copyright 2014+ Petr Ohlidal & contributors.
6 
7  Rigs of Rods is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; version 3 of the License.
10 
11  Rigs of Rods is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "BitFlags.h"
23 
27 
28 namespace RoRnet {
29 
30 #define RORNET_MAX_PEERS 64
31 #define RORNET_MAX_MESSAGE_LENGTH 8192
32 #define RORNET_LAN_BROADCAST_PORT 13000
33 #define RORNET_MAX_USERNAME_LEN 40
34 
35 #define RORNET_VERSION "RoRnet_2.45"
36 
38 {
39  MSG2_HELLO = 1025,
40 
41  // Hello responses
47 
48  // Technical
54 
55  // Gameplay
61 
62  // Stream functions
68 
69  // Legacy values (RoRnet_2.38 and earlier)
71 };
72 
74 {
75  AUTH_NONE = 0,
81 };
82 
83 enum Netmask
84 {
93 
99 };
100 
102 {
113 
124 };
125 
126 // -------------------------------- structs -----------------------------------
127 // Only use datatypes with defined binary sizes (avoid bool, int, wchar_t...)
128 // Prefer alignment to 4 or 2 bytes (put int32/float/etc. fields on top)
129 
130 #pragma pack(push, 1)
131 
132 struct Header
133 {
134  uint32_t command;
135  int32_t source;
136  uint32_t streamid;
137  uint32_t size;
138 };
139 
141 {
142  int32_t type;
143  int32_t status;
144  int32_t origin_sourceid;
145  int32_t origin_streamid;
146  char name[128];
147  char data[128];
148 };
149 
151 {
152  // RoRnet::StreamRegister: Common
153  int32_t type;
154  int32_t status;
155  int32_t origin_sourceid;
156  int32_t origin_streamid;
157  char name[128];
158  // RoRnet::StreamRegister: Data buffer (128B)
159  int32_t bufferSize;
160  int32_t time;
161  char skin[60];
162  char sectionconfig[60];
163 };
164 
165 struct StreamUnRegister //< sent to remove a stream
166 {
167  uint32_t streamid;
168 };
169 
170 struct UserInfo
171 {
172  uint32_t uniqueid;
173  int32_t authstatus;
174  int32_t slotnum;
175  int32_t colournum;
176 
178  char usertoken[40];
179  char serverpassword[40];
180  char language[10];
181  char clientname[10];
182  char clientversion[25];
183  char clientGUID[40];
184  char sessiontype[10];
185  char sessionoptions[128];
186 };
187 
189 {
190  int32_t time;
191  float engine_speed;
192  float engine_force;
194  int32_t engine_gear;
196  float brake;
197  float wheelspeed;
200 };
201 
203 {
204  char protocolversion[20];
205  char terrain[128];
206  char servername[128];
207  uint8_t has_password;
208  char info[4096];
209 };
210 
212 {
213  char protocolversion[20];
214 };
215 
216 } // namespace RoRnet
217 
219 
220 #pragma pack(pop)
RoRnet::LIGHTMASK_SIDELIGHTS
@ LIGHTMASK_SIDELIGHTS
Definition: RoRnet.h:117
RoRnet::ActorStreamRegister
< Must preserve mem. layout of RoRnet::StreamRegister
Definition: RoRnet.h:150
RoRnet::StreamUnRegister::streamid
uint32_t streamid
Definition: RoRnet.h:167
RoRnet::LIGHTMASK_CUSTOM9
@ LIGHTMASK_CUSTOM9
custom light 9 on
Definition: RoRnet.h:111
RoRnet::LIGHTMASK_FOGLIGHTS
@ LIGHTMASK_FOGLIGHTS
Definition: RoRnet.h:116
RoRnet::MSG2_STREAM_UNREGISTER
@ MSG2_STREAM_UNREGISTER
remove stream
Definition: RoRnet.h:65
RoRnet::VehicleState::hydrodirstate
float hydrodirstate
the turning direction status
Definition: RoRnet.h:195
RoRnet::ActorStreamRegister::time
int32_t time
initial time stamp
Definition: RoRnet.h:160
RoRnet::LegacyServerInfo
Definition: RoRnet.h:211
RoRnet::LIGHTMASK_CUSTOM4
@ LIGHTMASK_CUSTOM4
custom light 4 on
Definition: RoRnet.h:106
RoRnet::VehicleState
< Formerly oob_t
Definition: RoRnet.h:188
RoRnet::NETMASK_HORN
@ NETMASK_HORN
horn is in use
Definition: RoRnet.h:85
RoRnet::MSG2_MASTERINFO
@ MSG2_MASTERINFO
master information response
Definition: RoRnet.h:52
RoRnet::UserInfo
Definition: RoRnet.h:170
RoRnet::NETMASK_POLICEAUDIO
@ NETMASK_POLICEAUDIO
police siren on
Definition: RoRnet.h:86
RoRnet::Header::source
int32_t source
source of this command: 0 = server
Definition: RoRnet.h:135
RoRnet::MSG2_WRONG_PW
@ MSG2_WRONG_PW
server send that on wrong pw
Definition: RoRnet.h:43
RORNET_MAX_USERNAME_LEN
#define RORNET_MAX_USERNAME_LEN
bytes.
Definition: RoRnet.h:33
RoRnet::LIGHTMASK_CUSTOM10
@ LIGHTMASK_CUSTOM10
custom light 10 on
Definition: RoRnet.h:112
RoRnet::LIGHTMASK_REVERSE
@ LIGHTMASK_REVERSE
reverse light on
Definition: RoRnet.h:119
RoRnet::ServerInfo::has_password
uint8_t has_password
passworded server?
Definition: RoRnet.h:207
RoRnet::ActorStreamRegister::name
char name[128]
truck file name
Definition: RoRnet.h:157
RoRnet::Header::command
uint32_t command
the command of this packet: MSG2_*
Definition: RoRnet.h:134
RoRnet::StreamRegister::origin_sourceid
int32_t origin_sourceid
origin sourceid
Definition: RoRnet.h:144
RoRnet::AUTH_ADMIN
@ AUTH_ADMIN
admin on the server
Definition: RoRnet.h:76
RoRnet::MessageType
MessageType
Definition: RoRnet.h:37
RoRnet::ServerInfo
Definition: RoRnet.h:202
RoRnet::LIGHTMASK_CUSTOM7
@ LIGHTMASK_CUSTOM7
custom light 7 on
Definition: RoRnet.h:109
RoRnet::NETMASK_ALB_ACTIVE
@ NETMASK_ALB_ACTIVE
anti lock brake light on?
Definition: RoRnet.h:90
RoRnet::NETMASK_ENGINE_MODE_MANUAL
@ NETMASK_ENGINE_MODE_MANUAL
engine mode
Definition: RoRnet.h:96
RoRnet::UserInfo::sessionoptions
char sessionoptions[128]
reserved for future options
Definition: RoRnet.h:185
RoRnet::VehicleState::engine_clutch
float engine_clutch
the clutch value
Definition: RoRnet.h:193
BITMASK
#define BITMASK(OFFSET)
Definition: BitFlags.h:10
RoRnet::VehicleState::engine_speed
float engine_speed
engine RPM
Definition: RoRnet.h:191
RoRnet
Definition: ForwardDeclarations.h:232
RoRnet::AUTH_BANNED
@ AUTH_BANNED
banned
Definition: RoRnet.h:80
RoRnet::MSG2_FULL
@ MSG2_FULL
no more slots for us
Definition: RoRnet.h:42
RoRnet::MSG2_BANNED
@ MSG2_BANNED
client not allowed to join
Definition: RoRnet.h:45
RoRnet::ActorStreamRegister::sectionconfig
char sectionconfig[60]
section configuration
Definition: RoRnet.h:162
RoRnet::MSG2_USER_JOIN
@ MSG2_USER_JOIN
new user joined
Definition: RoRnet.h:57
RoRnet::MSG2_WRONG_VER_LEGACY
@ MSG2_WRONG_VER_LEGACY
Wrong version.
Definition: RoRnet.h:70
RoRnet::LIGHTMASK_BLINK_LEFT
@ LIGHTMASK_BLINK_LEFT
left blinker on
Definition: RoRnet.h:121
RoRnet::MSG2_UTF8_CHAT
@ MSG2_UTF8_CHAT
broadcast chat line in UTF8 encoding; Payload: const char*(text)
Definition: RoRnet.h:59
RoRnet::NETMASK_ENGINE_MODE_MANUAL_RANGES
@ NETMASK_ENGINE_MODE_MANUAL_RANGES
engine mode
Definition: RoRnet.h:98
RoRnet::Lightmask
Lightmask
Definition: RoRnet.h:101
RoRnet::ActorStreamRegister::origin_sourceid
int32_t origin_sourceid
origin sourceid
Definition: RoRnet.h:155
RoRnet::MSG2_GAME_CMD
@ MSG2_GAME_CMD
Script message. Can be sent in both directions.
Definition: RoRnet.h:56
RoRnet::MSG2_STREAM_DATA
@ MSG2_STREAM_DATA
stream data
Definition: RoRnet.h:66
RoRnet::VehicleState::engine_gear
int32_t engine_gear
engine gear
Definition: RoRnet.h:194
BitFlags.h
Bit operations.
RoRnet::UserInfo::authstatus
int32_t authstatus
auth status set by server: AUTH_*
Definition: RoRnet.h:173
RoRnet::MSG2_UTF8_PRIVCHAT
@ MSG2_UTF8_PRIVCHAT
private chat line in UTF8 encoding; Payload: uint32_t(uniqueid), const char*(text)
Definition: RoRnet.h:60
RoRnet::StreamRegister::data
char data[128]
data used for stream setup
Definition: RoRnet.h:147
RoRnet::MSG2_VERSION
@ MSG2_VERSION
server responds with its version
Definition: RoRnet.h:49
RoRnet::LIGHTMASK_CUSTOM3
@ LIGHTMASK_CUSTOM3
custom light 3 on
Definition: RoRnet.h:105
RoRnet::NETMASK_ENGINE_CONT
@ NETMASK_ENGINE_CONT
ignition on?
Definition: RoRnet.h:91
RoRnet::NETMASK_ENGINE_MODE_AUTOMATIC
@ NETMASK_ENGINE_MODE_AUTOMATIC
engine mode
Definition: RoRnet.h:94
RoRnet::ServerInfo::info
char info[4096]
info text
Definition: RoRnet.h:208
RoRnet::UserInfo::serverpassword
char serverpassword[40]
server password
Definition: RoRnet.h:179
RoRnet::UserAuth
UserAuth
Definition: RoRnet.h:73
RoRnet::LegacyServerInfo::protocolversion
char protocolversion[20]
protocol version being used
Definition: RoRnet.h:213
RoRnet::AUTH_MOD
@ AUTH_MOD
moderator status
Definition: RoRnet.h:78
RoRnet::LIGHTMASK_HEADLIGHT
@ LIGHTMASK_HEADLIGHT
Definition: RoRnet.h:114
RoRnet::MSG2_STREAM_REGISTER
@ MSG2_STREAM_REGISTER
create new stream
Definition: RoRnet.h:63
RoRnet::ActorStreamRegister::origin_streamid
int32_t origin_streamid
origin streamid
Definition: RoRnet.h:156
RoRnet::NETMASK_ENGINE_MODE_MANUAL_STICK
@ NETMASK_ENGINE_MODE_MANUAL_STICK
engine mode
Definition: RoRnet.h:97
RoRnet::MSG2_SERVER_SETTINGS
@ MSG2_SERVER_SETTINGS
server send client the terrain name: server_info_t
Definition: RoRnet.h:50
RoRnet::UserInfo::slotnum
int32_t slotnum
slot number set by server
Definition: RoRnet.h:174
RoRnet::StreamUnRegister
Definition: RoRnet.h:165
RoRnet::VehicleState::lightmask
BitMask_t lightmask
flagmask: LIGHTMASK_*
Definition: RoRnet.h:199
RoRnet::VehicleState::time
int32_t time
time data
Definition: RoRnet.h:190
RoRnet::NETMASK_TC_ACTIVE
@ NETMASK_TC_ACTIVE
traction control light on?
Definition: RoRnet.h:89
RoRnet::Header
< Common header for every packet
Definition: RoRnet.h:132
RoRnet::MSG2_STREAM_REGISTER_RESULT
@ MSG2_STREAM_REGISTER_RESULT
result of a stream creation
Definition: RoRnet.h:64
RoRnet::Header::streamid
uint32_t streamid
streamid for this command
Definition: RoRnet.h:136
RoRnet::ServerInfo::protocolversion
char protocolversion[20]
protocol version being used
Definition: RoRnet.h:204
RoRnet::LIGHTMASK_CUSTOM5
@ LIGHTMASK_CUSTOM5
custom light 5 on
Definition: RoRnet.h:107
RoRnet::UserInfo::sessiontype
char sessiontype[10]
the requested session type. For example "normal", "bot", "rcon"
Definition: RoRnet.h:184
RoRnet::UserInfo::clientversion
char clientversion[25]
a version number of the client. For example 1 for RoR 0.35
Definition: RoRnet.h:182
RoRnet::AUTH_RANKED
@ AUTH_RANKED
ranked status
Definition: RoRnet.h:77
RoRnet::LIGHTMASK_BRAKES
@ LIGHTMASK_BRAKES
brake lights on
Definition: RoRnet.h:118
RoRnet::UserInfo::clientname
char clientname[10]
the name and version of the client. For exmaple: "ror" or "gamebot"
Definition: RoRnet.h:181
RoRnet::LIGHTMASK_HIGHBEAMS
@ LIGHTMASK_HIGHBEAMS
Definition: RoRnet.h:115
RoRnet::StreamRegister::status
int32_t status
initial stream status
Definition: RoRnet.h:143
RoRnet::MSG2_WRONG_VER
@ MSG2_WRONG_VER
wrong version
Definition: RoRnet.h:44
RoRnet::StreamRegister::type
int32_t type
0 = Actor, 1 = Character, 3 = ChatSystem
Definition: RoRnet.h:142
RoRnet::AUTH_NONE
@ AUTH_NONE
no authentication
Definition: RoRnet.h:75
RoRnet::LIGHTMASK_CUSTOM8
@ LIGHTMASK_CUSTOM8
custom light 8 on
Definition: RoRnet.h:110
RoRnet::LIGHTMASK_CUSTOM2
@ LIGHTMASK_CUSTOM2
custom light 2 on
Definition: RoRnet.h:104
RoRnet::NETMASK_ENGINE_MODE_SEMIAUTO
@ NETMASK_ENGINE_MODE_SEMIAUTO
engine mode
Definition: RoRnet.h:95
RoRnet::UserInfo::colournum
int32_t colournum
colour set by server
Definition: RoRnet.h:175
RoRnet::StreamRegister::name
char name[128]
file name
Definition: RoRnet.h:146
RoRnet::UserInfo::username
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
Definition: RoRnet.h:177
RoRnet::UserInfo::uniqueid
uint32_t uniqueid
user unique id
Definition: RoRnet.h:172
RoRnet::Netmask
Netmask
Definition: RoRnet.h:83
RoRnet::MSG2_STREAM_DATA_DISCARDABLE
@ MSG2_STREAM_DATA_DISCARDABLE
stream data that is allowed to be discarded
Definition: RoRnet.h:67
RoRnet::ActorStreamRegister::type
int32_t type
0
Definition: RoRnet.h:153
RoRnet::LIGHTMASK_BLINK_WARN
@ LIGHTMASK_BLINK_WARN
warn blinker on
Definition: RoRnet.h:123
RoRnet::ServerInfo::servername
char servername[128]
name of the server
Definition: RoRnet.h:206
RoRnet::LIGHTMASK_CUSTOM1
@ LIGHTMASK_CUSTOM1
custom light 1 on
Definition: RoRnet.h:103
RoRnet::AUTH_BOT
@ AUTH_BOT
bot status
Definition: RoRnet.h:79
RoRnet::NETMASK_PARTICLE
@ NETMASK_PARTICLE
custom particles on
Definition: RoRnet.h:87
RoRnet::ActorStreamRegister::bufferSize
int32_t bufferSize
initial stream status
Definition: RoRnet.h:159
RoRnet::StreamRegister::origin_streamid
int32_t origin_streamid
origin streamid
Definition: RoRnet.h:145
RoRnet::VehicleState::wheelspeed
float wheelspeed
the wheel speed value
Definition: RoRnet.h:197
RoRnet::NETMASK_PBRAKE
@ NETMASK_PBRAKE
parking brake
Definition: RoRnet.h:88
BitMask_t
uint32_t BitMask_t
Definition: BitFlags.h:7
RoRnet::VehicleState::engine_force
float engine_force
engine acceleration
Definition: RoRnet.h:192
RoRnet::MSG2_NETQUALITY
@ MSG2_NETQUALITY
network quality information
Definition: RoRnet.h:53
RoRnet::VehicleState::brake
float brake
the brake value
Definition: RoRnet.h:196
RoRnet::MSG2_HELLO
@ MSG2_HELLO
client sends its version as first message
Definition: RoRnet.h:39
RoRnet::LIGHTMASK_BEACONS
@ LIGHTMASK_BEACONS
beacons on
Definition: RoRnet.h:120
RoRnet::ActorStreamRegister::status
int32_t status
initial stream status
Definition: RoRnet.h:154
RoRnet::MSG2_USER_INFO
@ MSG2_USER_INFO
user data that is sent from the server to the clients
Definition: RoRnet.h:51
RoRnet::NETMASK_ENGINE_RUN
@ NETMASK_ENGINE_RUN
engine running?
Definition: RoRnet.h:92
RoRnet::MSG2_WELCOME
@ MSG2_WELCOME
we can proceed
Definition: RoRnet.h:46
RoRnet::VehicleState::flagmask
BitMask_t flagmask
flagmask: NETMASK_*
Definition: RoRnet.h:198
RoRnet::LIGHTMASK_BLINK_RIGHT
@ LIGHTMASK_BLINK_RIGHT
right blinker on
Definition: RoRnet.h:122
RoRnet::UserInfo::clientGUID
char clientGUID[40]
the clients GUID
Definition: RoRnet.h:183
RoRnet::ActorStreamRegister::skin
char skin[60]
skin
Definition: RoRnet.h:161
RoRnet::UserInfo::language
char language[10]
user's language. For example "de-DE" or "en-US"
Definition: RoRnet.h:180
RoRnet::MSG2_USER_LEAVE
@ MSG2_USER_LEAVE
user leaves
Definition: RoRnet.h:58
RoRnet::ServerInfo::terrain
char terrain[128]
terrain name
Definition: RoRnet.h:205
RoRnet::UserInfo::usertoken
char usertoken[40]
user token
Definition: RoRnet.h:178
RoRnet::LIGHTMASK_CUSTOM6
@ LIGHTMASK_CUSTOM6
custom light 6 on
Definition: RoRnet.h:108
RoRnet::Header::size
uint32_t size
size of the attached data block
Definition: RoRnet.h:137
RoRnet::StreamRegister
< Sent from the client to server and vice versa, to broadcast a new stream
Definition: RoRnet.h:140