User:Monster Iestyn/Source Code Documentation/d_clisrv.h

From SRB2 Wiki
Jump to navigation Jump to search
This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
Online link GitHub entry
File type C header file
#include guard __D_CLISRV__

Includes

Macros

Macro Defined as Description
Maximum limits
BACKUPTICS 32 The maximum number of tic commands that can be queued for a player.
MAXTEXTCMD 256 The maximum size of a net command buffer. For example, this is used by the doomdata_t struct's textcmd buffer, and the local textcmd buffers for storing data to be sent as PT_TEXTCMD or PT_TEXTCMD2.
MAXSERVERNAME 32 The maximum size of a server name string. This is used only by the serverinfo_pak struct's servername string.
MAXFILENEEDED 915 The maximum size of fileneeded in serverinfo_pak.
MAXSERVERLIST 64 The maximum number of servers that can be listed in-game. This is used as the size of the serverlist array.
Packet sizes
BASEPACKETSIZE
offsetof(doomdata_t, u)
The base size of a doomcom packet's header.
FILETXHEADER
offsetof(filetx_pak, data)
The base size of filetx_pak without the file data (which can vary in size).
BASESERVERTICSSIZE
offsetof(doomdata_t, u.serverpak.cmds[0])
The base size of servertics_pak without ticcmd data (which can vary in size).
Kick message types
KICK_MSG_GO_AWAY 1 "playername has been kicked (Go away)"
KICK_MSG_CON_FAIL 2 "playername left the game (Synch failure)"
KICK_MSG_PLAYER_QUIT 3 "playername left the game"
KICK_MSG_TIMEOUT 4 "playername left the game (Connection timeout)"
KICK_MSG_BANNED 5 "playername has been banned (Don't come back)"
KICK_MSG_PING_HIGH 6 Defined only if NEWPING is defined

"playername left the game (Broke ping limit)"

KICK_MSG_CUSTOM_KICK 7 "playername has been kicked (reason)"
KICK_MSG_CUSTOM_BAN 8 "playername has been banned (reason)"
Other
client (!server) This is true if the local player is a client (i.e. not the host) in a netgame, false if not. This will always be false in a Single Player game.

Typedefs

Name Type Attributes Description
packettype_t enum List of packet types.
clientcmd_pak struct ATTRPACK The struct for containing a client's ticcmd. Used by the packet types PT_CLIENTCMD, PT_CLIENTMIS, PT_NODEKEEPALIVE and PT_NODEKEEPALIVEMIS.
client2cmd_pak struct ATTRPACK The struct for containing two clients' ticcmds, for a node using splitscreen. Used by the packet types PT_CLIENT2CMD and PT_CLIENT2MIS.
servertics_pak struct ATTRPACK The struct for containing all the clients' ticcmds and other data for a tic. Used by the PT_SERVERTICS packet type.
resynchend_pak struct ATTRPACK The struct for containing other information about a game to be re-synched. Used by the PT_RESYNCHEND packet type.
resynch_pak struct ATTRPACK The struct for containing information about a player who is being re-synched. Used by the PT_RESYNCHING packet type.
serverconfig_pak struct ATTRPACK The struct for a server's configuration. Used by the PT_SERVERCFG packet type.
filetx_pak struct ATTRPACK The struct for a file fragment. Used by the PT_FILEFRAGMENT packet type.
clientconfig_pak struct ATTRPACK The struct for a client join request. Used by the PT_CLIENTJOIN packet type.
serverinfo_pak struct ATTRPACK The struct for information about a server. Used by the PT_SERVERINFO packet type and the serverelem_t struct.
serverrefuse_pak struct ATTRPACK The struct for a refusal notice sent by a server. Used by the PT_SERVERREFUSE packet type.
askinfo_pak struct ATTRPACK The struct for requesting info from a server. Used by the PT_ASKINFO packet type.
msaskinfo_pak struct ATTRPACK The struct for requesting info from a server via the MS. Used by the PT_ASKINFOVIAMS packet type.
plrinfo struct ATTRPACK The struct for storing information for a single player, e.g. their name, skin, and skin color. Used by the PT_PLAYERINFO packet type.
plrconfig struct ATTRPACK Unused struct for the now-removed PLAYERCONFIG packet type.
doomdata_t struct ATTRPACK The struct for a packet's data.
serverelem_t struct
kickreason_t enum

Enumerations

packettype_t

Value Name Description
0 PT_NOTHING
1 PT_SERVERCFG
2 PT_CLIENTCMD
3 PT_CLIENTMIS
4 PT_CLIENT2CMD
5 PT_CLIENT2MIS
6 PT_NODEKEEPALIVE
7 PT_NODEKEEPALIVEMIS
8 PT_SERVERTICS
9 PT_SERVERREFUSE
10 PT_SERVERSHUTDOWN
11 PT_CLIENTQUIT
12 PT_ASKINFO
13 PT_SERVERINFO
14 PT_PLAYERINFO
15 PT_REQUESTFILE
16 PT_ASKINFOVIAMS
17 PT_RESYNCHEND
18 PT_RESYNCHGET
19 PT_CANFAIL
19 PT_FILEFRAGMENT
20 PT_TEXTCMD
21 PT_TEXTCMD2
22 PT_CLIENTJOIN
23 PT_NODETIMEOUT
24 PT_RESYNCHING
25 PT_PING Defined only if NEWPING is defined
261 NUMPACKETTYPE

1 This is the value of the constant only if NEWPING is defined; otherwise, it is 25.

kickreason_t

Value Name Description
1 KR_KICK Kicked by server
2 KR_PINGLIMIT Broke Ping Limit
3 KR_SYNCH Synch Failure
4 KR_TIMEOUT Connection Timeout
5 KR_BAN Banned by server
6 KR_LEAVE Quit the game

Structs

clientcmd_pak

Data name Data type Description
client_tic UINT8
resendfrom UINT8
consistancy INT16
cmd ticcmd_t

client2cmd_pak

Data name Data type Description
client_tic UINT8
resendfrom UINT8
consistancy INT16
cmd
cmd2
ticcmd_t

servertics_pak

Data name Data type Description
starttic UINT8
numtics UINT8
numslots UINT8
cmds[45] ticcmd_t

resynchend_pak

Data name Data type Description
randomseed UINT32
flagplayer[2] SINT8
flagloose[2] INT32
flagflags[2] INT32
flagx[2] fixed_t
flagy[2] fixed_t
flagz[2] fixed_t
ingame UINT32
ctfteam[MAXPLAYERS] INT32
score[MAXPLAYERS] UINT32
numboxes[MAXPLAYERS] INT16
totalring[MAXPLAYERS] INT16
realtime[MAXPLAYERS] tic_t
laps[MAXPLAYERS] UINT8

resynch_pak

Data name Data type Description
playernum UINT8
playerstate UINT8
pflags UINT32
panim UINT8
aiming angle_t
currentweapon INT32
ringweapons INT32
powers[MAXPOWERS] UINT16
health INT32
lives SINT8
continues SINT8
scoreadd SINT8
xtralife SINT8
pity SINT8
skincolor UINT8
skin UINT32
normalspeed fixed_t
runspeed fixed_t
thrustfactor UINT8
accelstart UINT8
acceleration UINT8
charability UINT8
charability2 UINT8
charflags UINT32
thokitem UINT32
spinitem UINT32
revitem UINT32
actionspeed fixed_t
mindash fixed_t
maxdash fixed_t
jumpfactor fixed_t
speed fixed_t
jumping UINT8
secondjump UINT8
fly1 UINT8
glidetime tic_t
climbing UINT8
deadtimer INT32
exiting tic_t
homing UINT8
skidtime tic_t
cmomx fixed_t
cmomy fixed_t
rmomx fixed_t
rmomy fixed_t
weapondelay INT32
tossdelay INT32
starpostx INT16
starposty INT16
starpostz INT16
starpostnum INT32
starposttime tic_t
starpostangle angle_t
maxlink INT32
dashspeed fixed_t
dashtime INT32
angle_pos angle_t
old_angle_pos angle_t
bumpertime tic_t
flyangle INT32
drilltimer tic_t
linkcount INT32
linktimer tic_t
anotherflyangle INT32
nightstime tic_t
drillmeter INT32
drilldelay UINT8
bonustime UINT8
mare UINT8
lastsidehit
lastlinehit
INT16
losstime tic_t
timeshit UINT8
onconveyor INT32
hasmo UINT8
angle angle_t
x fixed_t
y fixed_t
z fixed_t
momx fixed_t
momy fixed_t
momz fixed_t
friction fixed_t
movefactor fixed_t
tics INT32
statenum statenum_t
flags UINT32
flags2 UINT32
eflags UINT16
radius fixed_t
height fixed_t
scale fixed_t
destscale fixed_t
scalespeed fixed_t

serverconfig_pak

Data name Data type Description
version UINT8
subversion UINT8
serverplayer UINT8
totalslotnum UINT8
gametic tic_t
clientnode UINT8
gamestate UINT8
playerskins[MAXPLAYERS] UINT8
playercolor[MAXPLAYERS] UINT8
gametype UINT8
modifiedgame UINT8
adminplayers[MAXPLAYERS] SINT8
server_context[8] char
varlengthinputs[0] UINT8

filetx_pak

Data name Data type Description
fileid UINT8
position UINT32
size UINT16
data[0] UINT8

clientconfig_pak

Data name Data type Description
version UINT8
subversion UINT8
localplayers UINT8
mode UINT8

serverinfo_pak

Data name Data type Description
version UINT8
subversion UINT8
numberofplayer UINT8
maxplayer UINT8
gametype UINT8
modifiedgame UINT8
cheatsenabled UINT8
isdedicated UINT8
fileneedednum UINT8
adminplayer SINT8
time tic_t
leveltime tic_t
servername[MAXSERVERNAME] char
mapname[8] char
maptitle[33] char
mapmd5[16] unsigned char
actnum UINT8
iszone UINT8
fileneeded[MAXFILENEEDED] UINT8

serverrefuse_pak

Data name Data type Description
reason[255] char

askinfo_pak

Data name Data type Description
version UINT8
time tic_t

msaskinfo_pak

Data name Data type Description
clientaddr[22] char
time tic_t

plrinfo

Data name Data type Description
node UINT8
name[MAXPLAYERNAME+1] char
address[4] UINT8
team UINT8
skin UINT8
data UINT8
score UINT32
timeinserver UINT16

plrconfig

Data name Data type Description
name[MAXPLAYERNAME+1] char
skin UINT8
color UINT8
pflags UINT32
score UINT32
ctfteam UINT8

doomdata_t

Data name Data type Description
checksum UINT32 The packet's checksum.
ack UINT8 The acknowledgment variable.
ackreturn UINT8 The acknowledgment variable's return.
packettype UINT8 The packet type.
reserved UINT8 Padding.
u union A union for the various different kinds of data a packet can store, depending on the type of packet being written or received.
{
u clientpak clientcmd_pak The data stored by the following packet types:
  • PT_CLIENTCMD
  • PT_CLIENTMIS
  • PT_NODEKEEPALIVE
  • PT_NODEKEEPALIVEMIS
client2pak client2cmd_pak The data stored by the following packet types:
  • PT_CLIENT2CMD
  • PT_CLIENT2MIS
serverpak servertics_pak The data stored in a PT_SERVERTICS packet.
servercfg serverconfig_pak The data stored in a PT_SERVERCFG packet.
resynchend resynchend_pak The data stored in a PT_RESYNCHEND packet.
resynchpak resynch_pak The data stored in a PT_RESYNCHING packet.
resynchgot UINT8 The data stored in a PT_RESYNCHGET packet. This simply stores the number of the player who was re-synched by the server, to confirm that the PT_RESYNCHING packet for that player has been received.
textcmd[MAXTEXTCMD+1] UINT8 A buffer used by the following packet types for various purposes:
  • PT_NOTHING – Stores data for acks.
  • PT_REQUESTFILE – Stores data for requested files.
  • PT_TEXTCMD/PT_TEXTCMD2 – Stores net command data. ([0] = size of buffer)
  • PT_NODETIMEOUT[0] stores the node that timed out.
filetxpak filetx_pak The data stored in a PT_FILEFRAGMENT packet.
clientcfg clientconfig_pak The data stored in a PT_CLIENTJOIN packet.
serverinfo serverinfo_pak The data stored in a PT_SERVERINFO packet.
serverrefuse serverrefuse_pak The data stored in a PT_SERVERREFUSE packet.
askinfo askinfo_pak The data stored in a PT_ASKINFO packet.
msaskinfo msaskinfo_pak The data stored in a PT_ASKINFOVIAMS packet.
playerinfo[MAXPLAYERS] plrinfo The data stored in a PT_PLAYERINFO packet.
playerconfig[MAXPLAYERS] plrconfig Unused member for the now-removed PLAYERCONFIG packet type.
pingtable[MAXPLAYERS] UINT32 This member of u is declared only if NEWPING is defined

The data stored in a PT_PING packet. This is simply an array of ping values for all players currently in-game.

}

serverelem_t

Data name Data type Description
node UINT8 The node number of the listed server. (?)
serverinfo serverinfo_pak The PT_SERVERINFO packet data received for the listed server.

Externs

Data name Data type Non-extern location(s) Description
serverlist[MAXSERVERLIST] serverelem_t d_clisrv.c An array storing data for all servers currently listed in-game.
serverlistcount UINT32 d_clisrv.c The number of servers currently listed in-game. This should not exceed MAXSERVERLIST.
mapchangepending INT32 d_netcmd.c This is set to 1 if D_MapChange was called from a menu, and is pending a later call to run the second step of the function. Otherwise, this is 0.
*netbuffer doomdata_t d_net.c A pointer to doomcom->data, for sending or reading packet data.
cv_playbackspeed consvar_t d_clisrv.c playbackspeed console variable struct
server boolean d_clisrv.c This is true if the local player is the host of a netgame (i.e. the server), false if not. This will always be true in a Single Player game.
dedicated boolean d_main.c This is true if the local player is running the game in dedicated mode (using the command line parameter -dedicated), false if not. Note: players joining a netgame cannot determine if it is running in dedicated mode using this.
software_MAXPACKETLENGTH UINT16 d_clisrv.c
acceptnewnode boolean d_clisrv.c
servernode SINT8 d_clisrv.c The node number of the server player. If the local player is the server, this will be 0.
connectiontimeout tic_t d_net.c
jointimeout tic_t d_clisrv.c
pingmeasurecount UINT16 d_clisrv.c Declared only if NEWPING is defined
realpingtable[MAXPLAYERS] UINT32 d_clisrv.c Declared only if NEWPING is defined
playerpingtable[MAXPLAYERS] UINT32 d_clisrv.c Declared only if NEWPING is defined
cv_joinnextround
cv_allownewplayer
cv_maxplayers
cv_resynchattempts
cv_blamecfail
cv_maxsend
cv_noticedownload
cv_downloadspeed
consvar_t d_clisrv.c joinnextround, allowjoin, maxplayers, resynchattempts, blamecfail, maxsend, noticedownload, downloadspeed console variable structs
motd[254]
server_context[8]
char d_clisrv.c String buffers for the current server's Message of the Day and unique context string, respectively.
playernode[MAXPLAYERS] UINT8 d_clisrv.c An array storing the node numbers for each player. If a player number is unused, this will give 255.
hu_resynching UINT8 d_clisrv.c This is true if the HUD should display the "Resynching..." message to indicate the game is currently re-synchronising players, false if not.

Function prototypes

Function name Return type Params Defined in Description
Command_Drop void none d_net.c Declared only if PACKETDROP is defined

Function called by the console command drop when executed.

Command_Droprate void none d_net.c Declared only if PACKETDROP is defined

Function called by the console command droprate when executed.

Command_Numnodes void none i_tcp.c Declared only if _DEBUG is defined

Function called by the console command numnodes when executed.

ExpandTics tic_t INT32 low d_clisrv.c Guesses the value of a tic from its lowest byte and from maketic
D_ClientServerInit void none d_clisrv.c Initialises some client/server settings, registers some client/server commands and variables.
RegisterNetXCmd void netxcmd_t id,
void (*cmd_f)(UINT8 **p, INT32 playernum)
d_clisrv.c Registers a net command type. Assigns the given function pointer (cmd_f) to the given net command id. The function itself can then be called when a net command of this type is received by the client.
SendNetXCmd void netxcmd_t id,
const void *param,
size_t nparam
d_clisrv.c Sends a net command. The arguments given are saved to the localtextcmd buffer, ready to be sent by a PT_TEXTCMD packet to the server. The net commands will be sent back to everyone in the netgame through a PT_SERVERTICS packet. id is the type of net command to be sent, param is a pointer to the net command's parameters buffer, and nparam is the size in bytes of param.
SendNetXCmd2 void netxcmd_t id,
const void *param,
size_t nparam
d_clisrv.c Sends a net command for Player 2 in splitscreen. The arguments given are saved to the localtextcmd2 buffer, ready to be sent by a PT_TEXTCMD2 packet to the server. id is the type of net command to be sent, param is a pointer to the net command's parameters buffer, and nparam is the size in bytes of param.
NetUpdate void none d_clisrv.c
SV_StartSinglePlayerServer void none d_clisrv.c Starts a server for Single Player.
SV_SpawnServer boolean none d_clisrv.c Starts up a server, if one is not already running, and adds any waiting players to the netgame (via XD_ADDPLAYER net commands). Returns true if any players were added, returns false if not. Note that starting up a server causes this function to loop until the local player has connected to their own server or cancels the connection.
SV_SpawnPlayer void INT32 playernum,
INT32 x,
INT32 y,
angle_t angle
d_clisrv.c
SV_StopServer void none d_clisrv.c Stops a server.
SV_ResetServer void none d_clisrv.c Resets the server.
CL_AddSplitscreenPlayer void none d_clisrv.c Adds a splitscreen player.
CL_RemoveSplitscreenPlayer void none d_clisrv.c Removes the splitscreen player.
CL_Reset void none d_clisrv.c Resets the client.
CL_ClearPlayer void INT32 playernum d_clisrv.c Clears the player data for the given player number, so a future client can then use the same slot.
CL_UpdateServerList void boolean internetsearch,
INT32 room
d_clisrv.c
Playing boolean none d_clisrv.c Returns true if there is a game running, returns false if not.
D_QuitNetGame void none d_clisrv.c If in a netgame, the client quits the netgame and closes the connection.
TryRunTics void tic_t realtic d_clisrv.c
nametonum SINT8 const char *name d_clisrv.c Declared only if NONET is not defined

Gets the player number corresponding to the player name string given, e.g.: if player 0 is named "Sonic", nametonum("Sonic") will return 0. The "name" string can also be itself a player number, in which case this function converts the number in the string to an actual integer, e.g.: nametonum("5") will return 5. If a player number for the name string given could not be found, this function returns -1.

This is used by the functions for the console commands BAN, KICK and SAYTO.

D_NumPlayers INT32 none d_clisrv.c Returns the number of players present in-game. Can be zero if in a dedicated server.
D_ResetTiccmds void none d_clisrv.c Clears all saved ticcmds and their corresponding net commands
GetLag tic_t INT32 node d_clisrv.c Gets the latency for the node, in tics.
GetFreeXCmdSize UINT8 none d_clisrv.c Gets the free space available in the net command buffer, in bytes. (?)