| 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 | |
| 32 | enum |
| 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 |
| 79 | enum |
| 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 | MAX_INPUT_SIZE = 128, |
| 97 | MAX_SNAPSHOT_PACKSIZE = 900, |
| 98 | |
| 99 | MAX_NAME_LENGTH = 16, |
| 100 | MAX_CLAN_LENGTH = 12, |
| 101 | MAX_SKIN_LENGTH = 24, |
| 102 | |
| 103 | // message packing |
| 104 | /** |
| 105 | * Guaranteed to be delivered, resent on packet loss. |
| 106 | */ |
| 107 | MSGFLAG_VITAL = 1 << 0, |
| 108 | /** |
| 109 | * Makes the message be sent immediately. Without this flag the message will be delayed until the next flush. |
| 110 | */ |
| 111 | MSGFLAG_FLUSH = 1 << 1, |
| 112 | /** |
| 113 | * Don't write message to demo recorders. This flag is server-side only, where sent messages are recorded by default. |
| 114 | */ |
| 115 | MSGFLAG_NORECORD = 1 << 2, |
| 116 | /** |
| 117 | * Write message to demo recorders. This flag is client-side only, where sent messages are not recorded by default. |
| 118 | */ |
| 119 | MSGFLAG_RECORD = 1 << 3, |
| 120 | /** |
| 121 | * Don't send the message to client/server. Useful combined with @link MSGFLAG_RECORD @endlink to record a message without sending it. |
| 122 | */ |
| 123 | MSGFLAG_NOSEND = 1 << 4, |
| 124 | }; |
| 125 | |
| 126 | enum |
| 127 | { |
| 128 | VERSION_NONE = -1, |
| 129 | VERSION_VANILLA = 0, |
| 130 | VERSION_DDRACE = 1, |
| 131 | VERSION_DDNET_OLD = 2, |
| 132 | VERSION_DDNET_WHISPER = 217, |
| 133 | VERSION_DDNET_GOODHOOK = 221, |
| 134 | VERSION_DDNET_RCONPROTECT = 408, |
| 135 | VERSION_DDNET_ANTIPING_PROJECTILE = 604, |
| 136 | VERSION_DDNET_UPDATER_FIXED = 707, |
| 137 | VERSION_DDNET_GAMETICK = 10042, |
| 138 | VERSION_DDNET_EARLY_VERSION = 13020, |
| 139 | VERSION_DDNET_MSG_LEGACY = 15040, |
| 140 | VERSION_DDNET_SWITCH = 15060, |
| 141 | VERSION_DDNET_INDEPENDENT_SPECTATORS_TEAM = 16000, |
| 142 | VERSION_DDNET_WEAPON_SHIELDS = 16010, |
| 143 | VERSION_DDNET_NEW_HUD = 16020, |
| 144 | VERSION_DDNET_MULTI_LASER = 16040, |
| 145 | VERSION_DDNET_ENTITY_NETOBJS = 16200, |
| 146 | VERSION_DDNET_REDIRECT = 17020, |
| 147 | VERSION_DDNET_PLAYERFLAG_SPEC_CAM = 18090, |
| 148 | VERSION_DDNET_RECONNECT = 18090, |
| 149 | VERSION_DDNET_128_PLAYERS = 19000, |
| 150 | VERSION_DDNET_PREINPUT = 19040, |
| 151 | VERSION_DDNET_SAVE_CODE = 19060, |
| 152 | VERSION_DDNET_IMPORTANT_ALERT = 19060, |
| 153 | }; |
| 154 | |
| 155 | namespace TuneZone |
| 156 | { |
| 157 | inline constexpr int OVERRIDE_NONE = -1; |
| 158 | inline constexpr int NUM = 256; |
| 159 | }; |
| 160 | |
| 161 | typedef std::bitset<MAX_CLIENTS> CClientMask; |
| 162 | |
| 163 | #endif |
| 164 | |