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 = 64,
92 MAX_CHECKPOINTS = 25,
93 MIN_TICK = 0,
94 MAX_TICK = 0x6FFFFFFF,
95
96 /**
97 * The minimum size of inputs (in `int32_t`s) accepted by the server.
98 *
99 * Currently `10` because this has always been the minimum size of CNetObj_PlayerInput in all supported protocols.
100 */
101 MIN_INPUT_SIZE = 10,
102 /**
103 * The maximum size of inputs (in `int32_t`s) accepted by the server.
104 */
105 MAX_INPUT_SIZE = 128,
106 MAX_SNAPSHOT_PACKSIZE = 900,
107
108 MAX_NAME_LENGTH = 16,
109 MAX_CLAN_LENGTH = 12,
110 MAX_SKIN_LENGTH = 24,
111
112 // message packing
113 /**
114 * Guaranteed to be delivered, resent on packet loss.
115 */
116 MSGFLAG_VITAL = 1 << 0,
117 /**
118 * Makes the message be sent immediately. Without this flag the message will be delayed until the next flush.
119 */
120 MSGFLAG_FLUSH = 1 << 1,
121 /**
122 * Don't write message to demo recorders. This flag is server-side only, where sent messages are recorded by default.
123 */
124 MSGFLAG_NORECORD = 1 << 2,
125 /**
126 * Write message to demo recorders. This flag is client-side only, where sent messages are not recorded by default.
127 */
128 MSGFLAG_RECORD = 1 << 3,
129 /**
130 * Don't send the message to client/server. Useful combined with @link MSGFLAG_RECORD @endlink to record a message without sending it.
131 */
132 MSGFLAG_NOSEND = 1 << 4,
133};
134
135enum
136{
137 VERSION_NONE = -1,
138 VERSION_VANILLA = 0,
139 VERSION_DDRACE = 1,
140 VERSION_DDNET_OLD = 2,
141 VERSION_DDNET_WHISPER = 217,
142 VERSION_DDNET_ANTIPING_PROJECTILE = 604,
143 VERSION_DDNET_UPDATER_FIXED = 707,
144 VERSION_DDNET_GAMETICK = 10042,
145 VERSION_DDNET_EARLY_VERSION = 13020,
146 VERSION_DDNET_MSG_LEGACY = 15040,
147 VERSION_DDNET_INDEPENDENT_SPECTATORS_TEAM = 16000,
148 VERSION_DDNET_WEAPON_SHIELDS = 16010,
149 VERSION_DDNET_NEW_HUD = 16020,
150 VERSION_DDNET_MULTI_LASER = 16040,
151 VERSION_DDNET_ENTITY_NETOBJS = 16200,
152 VERSION_DDNET_REDIRECT = 17020,
153 VERSION_DDNET_PLAYERFLAG_SPEC_CAM = 18090,
154 VERSION_DDNET_RECONNECT = 18090,
155 VERSION_DDNET_128_PLAYERS = 19000,
156 VERSION_DDNET_PREINPUT = 19040,
157 VERSION_DDNET_SAVE_CODE = 19060,
158 VERSION_DDNET_IMPORTANT_ALERT = 19060,
159 VERSION_DDNET_MAP_BESTTIME = 19070,
160};
161
162namespace TuneZone
163{
164 inline constexpr int OVERRIDE_NONE = -1;
165 inline constexpr int NUM = 256;
166};
167
168namespace FinishTime
169{
170 inline constexpr int NOT_FINISHED_TIMESCORE = -9999;
171 inline constexpr int NOT_FINISHED_MILLIS = -1;
172 inline constexpr int UNSET = -2;
173}
174
175typedef std::bitset<MAX_CLIENTS> CClientMask;
176
177#endif
178