Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
game_types.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <string.h> // for memset
4 
6 #define INEXOR_SERVINFO_PORT 31413
7 #define INEXOR_LANINFO_PORT 31414
8 #define INEXOR_SERVER_PORT 31415
9 #define INEXOR_MASTER_PORT 31416
10 #define INEXOR_DEFAULT_MASTER "master.inexor.org"
11 
12 #define MAX_POSSIBLE_PORT 65535
13 
14 #define PROTOCOL_VERSION 303 // bump when protocol changes last sauerbraten protocol was 259
15 #define DEMO_VERSION 1 // bump when demo format changes
16 #define DEMO_MAGIC "INEXOR_DEMO"
17 
18 
19 inline int lan_info_port() { return INEXOR_LANINFO_PORT; }
20 inline int server_info_port(int servport) { return servport < 0 ? INEXOR_SERVINFO_PORT : servport+1; }
21 inline int server_port(int infoport = -1) { return infoport < 0 ? INEXOR_SERVER_PORT : infoport-1; }
22 
23 // sendf/sendfile channels
24 enum
25 {
26  CHAN_POS = 0, // Priority messages (position updates ..)
27  CHAN_MSG, // Low prio updates (text messages ..)
28  CHAN_FILE, // File upload/download
30 };
31 
35 enum
36 {
37  N_CONNECT = 0,
77 
78  // edit mode specific network messages
106 
107  // capture mode specific network messages
114 
115  // demo specific network messages
124 
125  // ctf/hold specific network messages
134 
135  // text, bots, options, gamespeed
140 
144 
156 
157  // collect mode messages
164 
169 };
170 
172 static const int msgsizes[] =
173 {
174  N_CONNECT, 0, N_SERVINFO, 0, N_WELCOME, 1, N_INITCLIENT, 0, N_POS, 0, N_TEXT, 0, N_SOUND, 2, N_CDIS, 2,
175  N_SHOOT, 0, N_EXPLODE, 0, N_SUICIDE, 1,
176  N_DIED, 5, N_DAMAGE, 6, N_HITPUSH, 7, N_SHOTFX, 10, N_EXPLODEFX, 4,
178  N_GUNSELECT, 2, N_TAUNT, 1, N_FOV, 2,
179  N_MAPCHANGE, 0, N_MAPVOTE, 0, N_TEAMINFO, 0,
181  N_PING, 2, N_PONG, 2, N_CLIENTPING, 2,
183  N_SERVMSG, 0, N_ITEMLIST, 0, N_RESUME, 0,
184  N_EDITMODE, 2, N_EDITENT, 11, N_EDITF, 16, N_EDITT, 16, N_EDITM, 16, N_FLIP, 14, N_COPY, 14, N_PASTE, 14, N_ROTATE, 15, N_REPLACE, 17, N_DELCUBE, 14, N_REMIP, 1, N_EDITVSLOT, 16, N_UNDO, 0, N_REDO, 0, N_NEWMAP, 2, N_GETMAP, 1, N_SENDMAP, 0, N_EDITVAR, 0,
190  N_SAYTEAM, 0, N_PRIVMSG, 0, N_HUDANNOUNCE, 0,
191  N_CLIENT, 0,
193  N_ADDBOT, 2, N_DELBOT, 1, N_INITAI, 0, N_FROMAI, 2, N_BOTLIMIT, 2, N_BOTBALANCE, 2,
194  N_MAPCRC, 0, N_CHECKMAPS, 1,
197  N_SERVCMD, 0,
198  N_DEMOPACKET, 0,
199  N_SPAWNLOC, 0,
200  -1
201 };
202 
203 inline int msgsizelookup(int msg)
204 {
205  static int sizetable[NUMMSG] ={-1};
206  if(sizetable[0] < 0)
207  {
208  memset(sizetable, -1, sizeof(sizetable));
209  for(const int *p = msgsizes; *p >= 0; p += 2) sizetable[p[0]] = p[1];
210  }
211  return msg >= 0 && msg < NUMMSG ? sizetable[msg] : -1;
212 }
213 
217 {
218  char magic[16];
220 };
221 
222 
224 
225 
226 // TODO: Can we make this server only?
227 inline const char *disconnectreason(int reason)
228 {
229  switch(reason)
230  {
231  case DISC_EOP: return "end of packet";
232  case DISC_KICK: return "kicked/banned";
233  case DISC_MSGERR: return "message error";
234  case DISC_IPBAN: return "ip is banned";
235  case DISC_PRIVATE: return "server is in private mode";
236  case DISC_MAXCLIENTS: return "server FULL";
237  case DISC_TIMEOUT: return "connection timed out";
238  case DISC_OVERFLOW: return "overflow";
239  case DISC_PASSWORD: return "invalid password";
240  default: return nullptr;
241  }
242 }
Definition: game_types.hpp:223
Definition: game_types.hpp:223
S2C client synchronisation.
Definition: game_types.hpp:141
C2S request a list of demos available for download.
Definition: game_types.hpp:117
S2C a flag has been reset.
Definition: game_types.hpp:129
S2C send clients spawn information.
Definition: game_types.hpp:55
int protocol
Definition: game_types.hpp:219
S2C server changed map.
Definition: game_types.hpp:61
#define INEXOR_SERVINFO_PORT
This file contains static protocol information for the (soon to be legacy) network code...
Definition: game_types.hpp:6
S2C the EFFECT OF A SHOT (see N_SHOT)
Definition: game_types.hpp:52
Definition: game_types.hpp:223
int version
Definition: game_types.hpp:219
C2S clear ban list.
Definition: game_types.hpp:102
C2S|S2C do not shuffle teams when enabled.
Definition: game_types.hpp:145
S2C server messages can be colored and will be rendered in game console.
Definition: game_types.hpp:75
C2S send connection request to server.
Definition: game_types.hpp:38
S2C we are now connected. also close my GUI.
Definition: game_types.hpp:40
C2S|S2C (?) a player wants to copy a certain selection (requires editmode)
Definition: game_types.hpp:86
S2C send information about teams and their frags.
Definition: game_types.hpp:63
S2C announce spawn of quad damage or health boost (normal capture only)
Definition: game_types.hpp:116
C2S|S2C team chat.
Definition: game_types.hpp:137
S2C send base score to client.
Definition: game_types.hpp:111
S2C a client disconnected.
Definition: game_types.hpp:45
static const int msgsizes[]
size incuding message token, 0 for variable or not-checked sizes
Definition: game_types.hpp:172
C2S|S2C a player rotated a selection (requires editmode)
Definition: game_types.hpp:88
C2S|S2C a player in game has used a jumppad.
Definition: game_types.hpp:69
C2S|S2C send client ping mesaure request / servers sends clients' pings.
Definition: game_types.hpp:72
C2S take client number from bot x?
Definition: game_types.hpp:149
S2C server sends map to client (requires coop mode. YOU CAN'T SEND MAPS IN INSTACTF e...
Definition: game_types.hpp:97
Definition: game_types.hpp:223
Definition: game_types.hpp:37
C2S send copied data from your clipboard to server.
Definition: game_types.hpp:98
C2S send sound signal.
Definition: game_types.hpp:44
C2S|S2C a player has changed his name.
Definition: game_types.hpp:154
C2S|S2C a player toggled his edit mode on/off (requires editmode)
Definition: game_types.hpp:80
C2S an explosion was triggered (grenades, rockets..)
Definition: game_types.hpp:47
Definition: game_types.hpp:160
Definition: game_types.hpp:223
S2C another client connected or existing client changed name, team, or player model.
Definition: game_types.hpp:41
C2S|S2C a player changed a FACE (requires editmode)
Definition: game_types.hpp:82
C2S clear the last n / all demos.
Definition: game_types.hpp:126
demos contain stored network messages of a game which can be replayed to review games ...
Definition: game_types.hpp:216
S2C regen capture: refill health and ammo of players near captured bases.
Definition: game_types.hpp:113
S2C send a list of flags available in game.
Definition: game_types.hpp:136
S2C BOMBERMAN Announcement.
Definition: game_types.hpp:139
C2S|S2C a player has changed his player model.
Definition: game_types.hpp:155
Definition: game_types.hpp:162
C2S|S2C a player wants to replace a selection (requires editmode)
Definition: game_types.hpp:89
-S- add a bot to the current game
Definition: game_types.hpp:146
C2S|S2C a client has changed its field of view.
Definition: game_types.hpp:60
S2C send how long flag will stay transparent in hold mode ? (vistime)
Definition: game_types.hpp:130
Definition: game_types.hpp:26
C2S a client selects a weapon.
Definition: game_types.hpp:58
C2S|S2C set map var value (requires editmode)
Definition: game_types.hpp:99
C2S|S2C (?) send clipboard to other palyers (requires editmode)
Definition: game_types.hpp:87
C2S|S2C send undo edit message.
Definition: game_types.hpp:93
char magic[16]
Definition: game_types.hpp:218
S2C finish demo playback.
Definition: game_types.hpp:121
C2S|S2C a player has switched his team (some game modes have more than 2 teams!)
Definition: game_types.hpp:158
C2S|S2C a client is now spawning.
Definition: game_types.hpp:56
Definition: game_types.hpp:27
C2S|S2C a player in game has teleported to a teleport destination.
Definition: game_types.hpp:68
C2S claim game master.
Definition: game_types.hpp:105
C2S client suggests a map/mode.
Definition: game_types.hpp:62
S2C resume transmission of new data from lagged client (NOT: RESUMING A PAUSED GAME!) ...
Definition: game_types.hpp:79
S2C server sends a demo.
Definition: game_types.hpp:120
C2S advise the server to record demo.
Definition: game_types.hpp:122
C2S|S2C a player changed a TEXTURE (requires editmode)
Definition: game_types.hpp:83
C2S|S2C toggle spectator status.
Definition: game_types.hpp:104
S2C a player returned a flag.
Definition: game_types.hpp:128
S2C a player got damages.
Definition: game_types.hpp:50
S2C replace ammo around bases in capture mode.
Definition: game_types.hpp:112
-S- set bot balance
Definition: game_types.hpp:151
#define INEXOR_SERVER_PORT
Definition: game_types.hpp:8
Definition: game_types.hpp:159
C2S a client requests to download a demo.
Definition: game_types.hpp:119
S2C servers could send advanced messages to clients. standard clients do not interpret this custom me...
Definition: game_types.hpp:166
S2C a client has scored the flag.
Definition: game_types.hpp:133
Definition: game_types.hpp:223
C2S lose items when killed (BOMBERMAN)
Definition: game_types.hpp:67
C2S|S2C a client used a v.. command (vscale, vcolor..) to modify a texture.
Definition: game_types.hpp:92
Definition: game_types.hpp:29
C2S|S2C change game speed (and broadcast that change)
Definition: game_types.hpp:143
Definition: game_types.hpp:223
int msgsizelookup(int msg)
Definition: game_types.hpp:203
S2C BOMBERMAN spawn location?
Definition: game_types.hpp:168
C2S I just picked up this item.
Definition: game_types.hpp:65
C2S|S2C client request a list of items available in the current match / server answers with list...
Definition: game_types.hpp:76
S2C commit AI settings to server. bots are still server side.
Definition: game_types.hpp:148
S2C server ended current game: set game time to 0 ("intermission")
Definition: game_types.hpp:74
C2S|S2C server paused game. stop player movement and actions.
Definition: game_types.hpp:142
-S- set the bot limit
Definition: game_types.hpp:150
S2C send connection attempt answer (can be denied in case of wrong protocol or server password protec...
Definition: game_types.hpp:39
C2S I suicided (other clients receive N_DIED where actor = victim)
Definition: game_types.hpp:48
S2C change remaining time.
Definition: game_types.hpp:73
S2C a player got pushed back.
Definition: game_types.hpp:51
S2C send a list of available bases in capture mode.
Definition: game_types.hpp:109
C2S a players tries to spawn.
Definition: game_types.hpp:54
S2C force a client to die.
Definition: game_types.hpp:57
int server_port(int infoport=-1)
Definition: game_types.hpp:21
C2S tell the server that you would like to drop your flag.
Definition: game_types.hpp:131
int lan_info_port()
Definition: game_types.hpp:19
S2C send extended information about bases.
Definition: game_types.hpp:110
C2S|S2C send redo edit message.
Definition: game_types.hpp:94
C2S|C2S send player position and rotation.
Definition: game_types.hpp:42
Definition: game_types.hpp:223
C2S a client downloaded the current map from server's map buffer (NOT ALWAYS UP TO DATE! MAP MUST BE ...
Definition: game_types.hpp:96
C2S|S2C a client forcedremip (requires editmode, no administrative levels required) ...
Definition: game_types.hpp:91
Definition: game_types.hpp:28
S2C send a requested demo packet.
Definition: game_types.hpp:167
C2S finish demo recording add add recorded material to demo list.
Definition: game_types.hpp:123
C2S a shot was fired.
Definition: game_types.hpp:46
Definition: game_types.hpp:161
C2S force server to check client maps manually (requires permissions)
Definition: game_types.hpp:153
C2S send map CRC32 hash value.
Definition: game_types.hpp:152
S2C the EFFECT OF AN EXPLOSION (see N_EXPLODE)
Definition: game_types.hpp:53
S2C a player creates a new entity (requires editmode)
Definition: game_types.hpp:81
S2C servers answers ping packet.
Definition: game_types.hpp:71
S2C an item has spawned.
Definition: game_types.hpp:64
const char * disconnectreason(int reason)
Definition: game_types.hpp:227
C2S change master mode (requires permissions)
Definition: game_types.hpp:100
C2S client sends ping packet to server.
Definition: game_types.hpp:70
C2S|S2C (?) a client sent "Im gonna kill you" animation.
Definition: game_types.hpp:59
S2C a player took a flag.
Definition: game_types.hpp:127
C2S|S2C private/personal message.
Definition: game_types.hpp:138
C2S|S2C a player edited MATERIAL (requires editmode)
Definition: game_types.hpp:84
S2C send a list of demos available for download.
Definition: game_types.hpp:118
C2S send chat message to global game chat.
Definition: game_types.hpp:43
S2C a client has dropped the flag.
Definition: game_types.hpp:132
C2S|S2C a client started a new map (requires editmode)
Definition: game_types.hpp:95
Definition: game_types.hpp:223
Definition: game_types.hpp:223
int server_info_port(int servport)
Definition: game_types.hpp:20
C2S kick a specific player.
Definition: game_types.hpp:101
S2C server sent information about who is the current game master.
Definition: game_types.hpp:103
C2S|S2C a player flipped the current selection (requires editmode)
Definition: game_types.hpp:85
S2C item pickup was acknowledged for a client (item is occupied/despawned. wait for spawn) ...
Definition: game_types.hpp:66
C2S|S2C team chat.
Definition: game_types.hpp:108
-S- remove a bot from the current game
Definition: game_types.hpp:147
Definition: game_types.hpp:165
C2S|S2C a player wants to delete a selection (requires editmode)
Definition: game_types.hpp:90
Definition: game_types.hpp:163
#define INEXOR_LANINFO_PORT
Definition: game_types.hpp:7
Definition: game_types.hpp:223
S2C a player got killed (or suicided)
Definition: game_types.hpp:49