1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef ENGINE_SHARED_PROTOCOL_H
4#define ENGINE_SHARED_PROTOCOL_H
5
6#include <engine/shared/protocol7.h>
7
8#include <bitset>
9
10/*
11 Connection diagram - How the initialization works.
12
13 Client -> INFO -> Server
14 Contains version info, name, and some other info.
15
16 Client <- MAP <- Server
17 Contains current map.
18
19 Client -> READY -> Server
20 The client has loaded the map and is ready to go,
21 but the mod needs to send it's information as well.
22 modc_connected is called on the client and
23 mods_connected is called on the server.
24 The client should call client_entergame when the
25 mod has done it's initialization.
26
27 Client -> ENTERGAME -> Server
28 Tells the server to start sending snapshots.
29 client_entergame and server_client_enter is called.
30*/
31
32enum
33{
34 NETMSG_EX = 0,
35
36 // the first thing sent by the client
37 // contains the version info for the client
38 NETMSG_INFO,
39
40 // sent by server
41 NETMSG_MAP_CHANGE, // sent when client should switch map
42 NETMSG_MAP_DATA, // map transfer, contains a chunk of the map file
43 NETMSG_CON_READY, // connection is ready, client should send start info
44 NETMSG_SNAP, // normal snapshot, multiple parts
45 NETMSG_SNAPEMPTY, // empty snapshot
46 NETMSG_SNAPSINGLE, // ?
47 NETMSG_SNAPSMALL, //
48 NETMSG_INPUTTIMING, // reports how off the input was
49 NETMSG_RCON_AUTH_STATUS, // result of the authentication
50 NETMSG_RCON_LINE, // line that should be printed to the remote console
51
52 NETMSG_UNUSED1,
53 NETMSG_UNUSED2,
54
55 // sent by client
56 NETMSG_READY, //
57 NETMSG_ENTERGAME,
58 NETMSG_INPUT, // contains the inputdata from the client
59 NETMSG_RCON_CMD, //
60 NETMSG_RCON_AUTH, //
61 NETMSG_REQUEST_MAP_DATA, //
62
63 NETMSG_UNUSED3,
64 NETMSG_UNUSED4,
65
66 // sent by both
67 NETMSG_PING,
68 NETMSG_PING_REPLY,
69 NETMSG_UNUSED5,
70
71 // sent by server (todo: move it up)
72 NETMSG_RCON_CMD_ADD,
73 NETMSG_RCON_CMD_REM,
74
75 NUM_NETMSGS,
76};
77
78// this should be revised
79enum
80{
81 SERVER_TICK_SPEED = 50,
82 SERVER_FLAG_PASSWORD = 1 << 0,
83 SERVER_FLAG_TIMESCORE = 1 << 1,
84 SERVERINFO_LEVEL_MIN = 0,
85 SERVERINFO_LEVEL_MAX = 2,
86
87 MAX_SERVER_ADDRESSES = 16,
88 SERVERINFO_MAX_CLIENTS = 128,
89 MAX_CLIENTS = 128,
90 VANILLA_MAX_CLIENTS = 16,
91 SERVER_MAX_CLIENTS = 128,
92 LEGACY_MAX_CLIENTS = 64,
93 MAX_CHECKPOINTS = 25,
94 MIN_TICK = 0,
95 MAX_TICK = 0x6FFFFFFF,
96
97 /**
98 * The minimum size of inputs (in `int32_t`s) accepted by the server.
99 *
100 * Currently `10` because this has always been the minimum size of CNetObj_PlayerInput in all supported protocols.
101 */
102 MIN_INPUT_SIZE = 10,
103 /**
104 * The maximum size of inputs (in `int32_t`s) accepted by the server.
105 */
106 MAX_INPUT_SIZE = 128,
107 MAX_SNAPSHOT_PACKSIZE = 900,
108
109 MAX_NAME_LENGTH = 16,
110 MAX_CLAN_LENGTH = 12,
111 MAX_SKIN_LENGTH = 24,
112
113 // message packing
114 /**
115 * Guaranteed to be delivered, resent on packet loss.
116 */
117 MSGFLAG_VITAL = 1 << 0,
118 /**
119 * Makes the message be sent immediately. Without this flag the message will be delayed until the next flush.
120 */
121 MSGFLAG_FLUSH = 1 << 1,
122 /**
123 * Don't write message to demo recorders. This flag is server-side only, where sent messages are recorded by default.
124 */
125 MSGFLAG_NORECORD = 1 << 2,
126 /**
127 * Write message to demo recorders. This flag is client-side only, where sent messages are not recorded by default.
128 */
129 MSGFLAG_RECORD = 1 << 3,
130 /**
131 * Don't send the message to client/server. Useful combined with @link MSGFLAG_RECORD @endlink to record a message without sending it.
132 */
133 MSGFLAG_NOSEND = 1 << 4,
134
135 /**
136 * for 0.7 player mapping fake disconnect/connects
137 */
138 MSGFLAG_NOTRANSLATE = 1 << 5,
139};
140
141enum
142{
143 VERSION_NONE = -1,
144 VERSION_VANILLA = 0,
145 VERSION_DDRACE = 1,
146 VERSION_DDNET_OLD = 2,
147 VERSION_DDNET_WHISPER = 217,
148 VERSION_DDNET_ANTIPING_PROJECTILE = 604,
149 VERSION_DDNET_UPDATER_FIXED = 707,
150 VERSION_DDNET_GAMETICK = 10042,
151 VERSION_DDNET_EARLY_VERSION = 13020,
152 VERSION_DDNET_MSG_LEGACY = 15040,
153 VERSION_DDNET_INDEPENDENT_SPECTATORS_TEAM = 16000,
154 VERSION_DDNET_WEAPON_SHIELDS = 16010,
155 VERSION_DDNET_NEW_HUD = 16020,
156 VERSION_DDNET_MULTI_LASER = 16040,
157 VERSION_DDNET_ENTITY_NETOBJS = 16200,
158 VERSION_DDNET_REDIRECT = 17020,
159 VERSION_DDNET_PLAYERFLAG_SPEC_CAM = 18090,
160 VERSION_DDNET_RECONNECT = 18090,
161 VERSION_DDNET_128_PLAYERS = 19000,
162 VERSION_DDNET_PREINPUT = 19040,
163 VERSION_DDNET_SAVE_CODE = 19060,
164 VERSION_DDNET_IMPORTANT_ALERT = 19060,
165 VERSION_DDNET_MAP_BESTTIME = 19070,
166 VERSION_DDNET_128_TEAMS = 20000,
167};
168
169/**
170 * Country codes in ISO 3166-1 numeric.
171 */
172namespace CountryCode
173{
174 inline constexpr int DEFAULT = -1;
175 inline constexpr int MINIMUM = -1;
176 inline constexpr int MAXIMUM = 999;
177};
178
179namespace TuneZone
180{
181 inline constexpr int OVERRIDE_NONE = -1;
182 inline constexpr int NUM = 256;
183};
184
185namespace FinishTime
186{
187 inline constexpr int NOT_FINISHED_TIMESCORE = -9999;
188 inline constexpr int NOT_FINISHED_MILLIS = -1;
189 inline constexpr int UNSET = -2;
190}
191
192typedef std::bitset<MAX_CLIENTS> CClientMask;
193
194#endif
195