RigsofRods
Soft-body Physics Simulation
source
main
network
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.44"
36
37
enum
MessageType
38
{
39
MSG2_HELLO
= 1025,
40
41
// Hello responses
42
MSG2_FULL
,
43
MSG2_WRONG_PW
,
44
MSG2_WRONG_VER
,
45
MSG2_BANNED
,
46
MSG2_WELCOME
,
47
48
// Technical
49
MSG2_VERSION
,
50
MSG2_SERVER_SETTINGS
,
51
MSG2_USER_INFO
,
52
MSG2_MASTERINFO
,
53
MSG2_NETQUALITY
,
54
55
// Gameplay
56
MSG2_GAME_CMD
,
57
MSG2_USER_JOIN
,
58
MSG2_USER_LEAVE
,
59
MSG2_UTF8_CHAT
,
60
MSG2_UTF8_PRIVCHAT
,
61
62
// Stream functions
63
MSG2_STREAM_REGISTER
,
64
MSG2_STREAM_REGISTER_RESULT
,
65
MSG2_STREAM_UNREGISTER
,
66
MSG2_STREAM_DATA
,
67
MSG2_STREAM_DATA_DISCARDABLE
,
68
69
// Legacy values (RoRnet_2.38 and earlier)
70
MSG2_WRONG_VER_LEGACY
= 1003
71
};
72
73
enum
UserAuth
74
{
75
AUTH_NONE
= 0,
76
AUTH_ADMIN
=
BITMASK
(1),
77
AUTH_RANKED
=
BITMASK
(2),
78
AUTH_MOD
=
BITMASK
(3),
79
AUTH_BOT
=
BITMASK
(4),
80
AUTH_BANNED
=
BITMASK
(5)
81
};
82
83
enum
Netmask
84
{
85
NETMASK_HORN
=
BITMASK
(1),
86
NETMASK_POLICEAUDIO
=
BITMASK
(2),
87
NETMASK_PARTICLE
=
BITMASK
(3),
88
NETMASK_PBRAKE
=
BITMASK
(4),
89
NETMASK_TC_ACTIVE
=
BITMASK
(5),
90
NETMASK_ALB_ACTIVE
=
BITMASK
(6),
91
NETMASK_ENGINE_CONT
=
BITMASK
(7),
92
NETMASK_ENGINE_RUN
=
BITMASK
(8),
93
94
NETMASK_ENGINE_MODE_AUTOMATIC
=
BITMASK
(9),
95
NETMASK_ENGINE_MODE_SEMIAUTO
=
BITMASK
(10),
96
NETMASK_ENGINE_MODE_MANUAL
=
BITMASK
(11),
97
NETMASK_ENGINE_MODE_MANUAL_STICK
=
BITMASK
(12),
98
NETMASK_ENGINE_MODE_MANUAL_RANGES
=
BITMASK
(13),
99
};
100
101
enum
Lightmask
102
{
103
LIGHTMASK_CUSTOM1
=
BITMASK
(1),
104
LIGHTMASK_CUSTOM2
=
BITMASK
(2),
105
LIGHTMASK_CUSTOM3
=
BITMASK
(3),
106
LIGHTMASK_CUSTOM4
=
BITMASK
(4),
107
LIGHTMASK_CUSTOM5
=
BITMASK
(5),
108
LIGHTMASK_CUSTOM6
=
BITMASK
(6),
109
LIGHTMASK_CUSTOM7
=
BITMASK
(7),
110
LIGHTMASK_CUSTOM8
=
BITMASK
(8),
111
LIGHTMASK_CUSTOM9
=
BITMASK
(9),
112
LIGHTMASK_CUSTOM10
=
BITMASK
(10),
113
114
LIGHTMASK_HEADLIGHT
=
BITMASK
(11),
115
LIGHTMASK_HIGHBEAMS
=
BITMASK
(12),
116
LIGHTMASK_FOGLIGHTS
=
BITMASK
(13),
117
LIGHTMASK_SIDELIGHTS
=
BITMASK
(14),
118
LIGHTMASK_BRAKES
=
BITMASK
(15),
119
LIGHTMASK_REVERSE
=
BITMASK
(16),
120
LIGHTMASK_BEACONS
=
BITMASK
(17),
121
LIGHTMASK_BLINK_LEFT
=
BITMASK
(18),
122
LIGHTMASK_BLINK_RIGHT
=
BITMASK
(19),
123
LIGHTMASK_BLINK_WARN
=
BITMASK
(20),
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
140
struct
StreamRegister
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
150
struct
ActorStreamRegister
151
{
152
int32_t
type
;
153
int32_t
status
;
154
int32_t
origin_sourceid
;
155
int32_t
origin_streamid
;
156
char
name
[128];
157
int32_t
bufferSize
;
158
int32_t
time
;
159
char
skin
[60];
160
char
sectionconfig
[60];
161
};
162
163
struct
StreamUnRegister
//< sent to remove a stream
164
{
165
uint32_t
streamid
;
166
};
167
168
struct
UserInfo
169
{
170
uint32_t
uniqueid
;
171
int32_t
authstatus
;
172
int32_t
slotnum
;
173
int32_t
colournum
;
174
175
char
username
[
RORNET_MAX_USERNAME_LEN
];
176
char
usertoken
[40];
177
char
serverpassword
[40];
178
char
language
[10];
179
char
clientname
[10];
180
char
clientversion
[25];
181
char
clientGUID
[40];
182
char
sessiontype
[10];
183
char
sessionoptions
[128];
184
};
185
186
struct
VehicleState
187
{
188
int32_t
time
;
189
float
engine_speed
;
190
float
engine_force
;
191
float
engine_clutch
;
192
int32_t
engine_gear
;
193
float
hydrodirstate
;
194
float
brake
;
195
float
wheelspeed
;
196
BitMask_t
flagmask
;
197
BitMask_t
lightmask
;
198
};
199
200
struct
ServerInfo
201
{
202
char
protocolversion
[20];
203
char
terrain
[128];
204
char
servername
[128];
205
uint8_t
has_password
;
206
char
info
[4096];
207
};
208
209
struct
LegacyServerInfo
210
{
211
char
protocolversion
[20];
212
};
213
214
}
// namespace RoRnet
215
217
218
#pragma pack(pop)
RoRnet::LIGHTMASK_SIDELIGHTS
@ LIGHTMASK_SIDELIGHTS
Definition:
RoRnet.h:117
RoRnet::ActorStreamRegister
Definition:
RoRnet.h:150
RoRnet::StreamUnRegister::streamid
uint32_t streamid
Definition:
RoRnet.h:165
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:193
RoRnet::ActorStreamRegister::time
int32_t time
initial time stamp
Definition:
RoRnet.h:158
RoRnet::LegacyServerInfo
Definition:
RoRnet.h:209
RoRnet::LIGHTMASK_CUSTOM4
@ LIGHTMASK_CUSTOM4
custom light 4 on
Definition:
RoRnet.h:106
RoRnet::VehicleState
< Formerly oob_t
Definition:
RoRnet.h:186
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:168
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
port used to send the broadcast announcement in LAN mode
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:205
RoRnet::ActorStreamRegister::name
char name[128]
filename
Definition:
RoRnet.h:156
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:200
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:183
RoRnet::VehicleState::engine_clutch
float engine_clutch
the clutch value
Definition:
RoRnet.h:191
BITMASK
#define BITMASK(OFFSET)
Definition:
BitFlags.h:10
RoRnet::VehicleState::engine_speed
float engine_speed
engine RPM
Definition:
RoRnet.h:189
RoRnet
Definition:
ForwardDeclarations.h:233
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:160
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:154
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:192
BitFlags.h
Bit operations.
RoRnet::UserInfo::authstatus
int32_t authstatus
auth status set by server: AUTH_*
Definition:
RoRnet.h:171
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:206
RoRnet::UserInfo::serverpassword
char serverpassword[40]
server password
Definition:
RoRnet.h:177
RoRnet::UserAuth
UserAuth
Definition:
RoRnet.h:73
RoRnet::LegacyServerInfo::protocolversion
char protocolversion[20]
protocol version being used
Definition:
RoRnet.h:211
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:155
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:172
RoRnet::StreamUnRegister
Definition:
RoRnet.h:163
RoRnet::VehicleState::lightmask
BitMask_t lightmask
flagmask: LIGHTMASK_*
Definition:
RoRnet.h:197
RoRnet::VehicleState::time
int32_t time
time data
Definition:
RoRnet.h:188
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:202
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:182
RoRnet::UserInfo::clientversion
char clientversion[25]
a version number of the client. For example 1 for RoR 0.35
Definition:
RoRnet.h:180
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:179
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
stream type
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:173
RoRnet::StreamRegister::name
char name[128]
the actor filename
Definition:
RoRnet.h:146
RoRnet::UserInfo::username
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
Definition:
RoRnet.h:175
RoRnet::UserInfo::uniqueid
uint32_t uniqueid
user unique id
Definition:
RoRnet.h:170
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
stream type
Definition:
RoRnet.h:152
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:204
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:157
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:195
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:190
RoRnet::MSG2_NETQUALITY
@ MSG2_NETQUALITY
network quality information
Definition:
RoRnet.h:53
RoRnet::VehicleState::brake
float brake
the brake value
Definition:
RoRnet.h:194
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:153
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:196
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:181
RoRnet::ActorStreamRegister::skin
char skin[60]
skin
Definition:
RoRnet.h:159
RoRnet::UserInfo::language
char language[10]
user's language. For example "de-DE" or "en-US"
Definition:
RoRnet.h:178
RoRnet::MSG2_USER_LEAVE
@ MSG2_USER_LEAVE
user leaves
Definition:
RoRnet.h:58
RoRnet::ServerInfo::terrain
char terrain[128]
terrain name
Definition:
RoRnet.h:203
RoRnet::UserInfo::usertoken
char usertoken[40]
user token
Definition:
RoRnet.h:176
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
Generated by
1.8.17