UFO: Alien Invasion
Loading...
Searching...
No Matches
sv_game.cpp File Reference

Interface to the game library. More...

#include "server.h"
#include "sv_log.h"
#include "../common/grid.h"
#include "../common/routing.h"
#include "../ports/system.h"
#include "../shared/thread.h"
#include "../shared/scopedmutex.h"
Include dependency graph for sv_game.cpp:

Go to the source code of this file.

Data Structures

struct  eventNames_t

Macros

#define M(x)

Functions

static void SV_dprintf (const char *fmt,...)
 Debug print to server console.
static void SV_PlayerPrintf (const SrvPlayer *player, int level, const char *fmt, va_list ap)
 Print to a single client.
static float SV_GetVisibility (const pos3_t position)
 Glue function to get the visibility from a given position.
static void SV_error (const char *fmt,...)
 Abort the server with a game error.
static unsigned int SV_FindIndex (const char *name, int start, int max, bool create)
 Search the index in the config strings relative to a given start.
static unsigned int SV_ModelIndex (const char *name)
static void SV_SetModel (edict_t *ent, const char *name)
static void SV_Configstring (int index, const char *fmt,...)
static void SV_WriteChar (char c)
static void SV_WriteByte (byte c)
static void SV_WriteShort (int c)
static void SV_WriteLong (int c)
static void SV_WriteString (const char *s)
static void SV_WritePos (const vec3_t pos)
static void SV_WriteGPos (const pos3_t pos)
static void SV_WriteDir (const vec3_t dir)
static void SV_WriteAngle (float f)
static void SV_WriteFormat (const char *format,...)
static int SV_ReadChar (void)
static int SV_ReadByte (void)
static int SV_ReadShort (void)
static int SV_ReadLong (void)
static int SV_ReadString (char *str, size_t length)
static void SV_ReadPos (vec3_t pos)
static void SV_ReadGPos (pos3_t pos)
static void SV_ReadDir (vec3_t vector)
static float SV_ReadAngle (void)
static void SV_ReadData (void *buffer, int size)
static void SV_ReadFormat (const char *format,...)
static void SV_AbortEvents (void)
static void SV_SendQueuedEvents (void)
static void SV_EndEvents (void)
 CASSERT (lengthof(eventNames)==EV_NUM_EVENTS)
static void SV_AddEvent (unsigned int mask, int eType, int entnum)
static void SV_QueueEvent (unsigned int mask, int eType, int entnum)
static void SV_QueueWriteByte (byte c)
static void SV_QueueWriteString (const char *s)
static void SV_QueueWritePos (const vec3_t pos)
static void SV_QueueWriteShort (int c)
static int SV_GetEvent (void)
static edict_tSV_GetEventEdict (void)
static voidSV_TagAlloc (int size, int tagNum, const char *file, int line)
 Makes sure the game DLL does not use client, or signed tags.
static void SV_MemFree (void *ptr, const char *file, int line)
static void SV_FreeTags (int tagNum, const char *file, int line)
 Makes sure the game DLL does not use client, or signed tags.
static bool SV_TestLine (const vec3_t start, const vec3_t stop, const int levelmask)
static bool SV_TestLineWithEnt (const vec3_t start, const vec3_t stop, const int levelmask, const char **entlist)
static pos_t SV_GridFall (const int actorSize, const pos3_t pos)
static void SV_RecalcRouting (const char *name, const GridBox &box, const char **list)
static void SV_GridPosToVec (const int actorSize, const pos3_t pos, vec3_t vec)
static bool SV_GridIsOnMap (const vec3_t vec)
static void SV_GridCalcPathing (actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, int distance, forbiddenList_t *forbiddenList)
static bool SV_GridFindPath (actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, const pos3_t targetPos, byte crouchingState, int maxTUs, forbiddenList_t *forbiddenList)
static bool SV_CanActorStandHere (const int actorSize, const pos3_t pos)
static void SV_SetInlineModelOrientation (const char *name, const vec3_t origin, const vec3_t angles)
static void SV_GetInlineModelAABB (const char *name, AABB &aabb)
static void SV_UnloadGame (void)
static game_export_tSV_GetGameAPI (game_import_t *parms)
 Loads the game shared library and calls the api init function.
void SV_ShutdownGameProgs (void)
 Called when either the entire server is being killed, or it is changing to a different game directory.
int SV_RunGameFrameThread (void *data)
 Thread for the game frame function.
void SV_RunGameFrame (void)
 Calls the G_RunFrame function from game api let everything in the world think and move.
void SV_InitGameProgs (void)
 Init the game subsystem for a new map.

Variables

static const eventNames_t eventNames []
static char const *const gameSysPoolName = "Server: Game system"

Detailed Description

Interface to the game library.

Definition in file sv_game.cpp.

Macro Definition Documentation

◆ M

#define M ( x)
Value:
{ #x }

Definition at line 356 of file sv_game.cpp.

Function Documentation

◆ CASSERT()

References EV_NUM_EVENTS, and eventNames.

◆ SV_AbortEvents()

void SV_AbortEvents ( void )
static
See also
gi.AbortEvents

Definition at line 308 of file sv_game.cpp.

References pending_event_t::buf, pending_event_t::pending, and sv.

Referenced by SV_InitGameProgs().

◆ SV_AddEvent()

void SV_AddEvent ( unsigned int mask,
int eType,
int entnum )
static
See also
gi.AddEvent
Parameters
[in]maskThe player bitmask to send the events to. Use PM_ALL to send to every connected player.
[in]eTypeThe event type
[in]entnumThe entity number

Definition at line 427 of file sv_game.cpp.

References pending_event_t::buf, Com_DPrintf(), Com_Error(), Com_UnsignedIntToBinary(), DEBUG_EVENTSYS, pending_event_t::entnum, ERR_DROP, EV_NUM_EVENTS, eventNames, NET_WriteByte(), NET_WriteShort(), pending_event_t::pending, pending_event_t::playerMask, sv, SV_EndEvents(), SV_SendQueuedEvents(), svc_event, and pending_event_t::type.

Referenced by SV_InitGameProgs().

◆ SV_CanActorStandHere()

bool SV_CanActorStandHere ( const int actorSize,
const pos3_t pos )
static

Definition at line 608 of file sv_game.cpp.

References RT_CanActorStandHere(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_Configstring()

◆ SV_dprintf()

void SV_dprintf ( const char * fmt,
... )
static

Debug print to server console.

Definition at line 39 of file sv_game.cpp.

References SV_LogAdd().

Referenced by SV_InitGameProgs().

◆ SV_EndEvents()

void SV_EndEvents ( void )
static

◆ SV_error()

void SV_error ( const char * fmt,
... )
static

Abort the server with a game error.

Note
The error message should not have a newline - it's added inside of this function

Definition at line 79 of file sv_game.cpp.

References Com_Error(), ERR_DROP, Q_vsnprintf(), and SV_error().

Referenced by SV_Configstring(), SV_error(), SV_FindIndex(), SV_InitGameProgs(), and SV_SetModel().

◆ SV_FindIndex()

unsigned int SV_FindIndex ( const char * name,
int start,
int max,
bool create )
static

Search the index in the config strings relative to a given start.

Parameters
nameThe value of the config string to search the index for
startThe relative start point for the search
maxThe max. searched entries in the config string before giving up
createif true the value will get written into the config strings (appended)
Returns
0 if not found

Definition at line 99 of file sv_game.cpp.

References Com_ServerState(), i, name, NET_WriteByte(), NET_WriteShort(), NET_WriteString(), Q_streq, ss_loading, SV_error(), SV_GetConfigString(), SV_Multicast(), SV_SetConfigString, and svc_configstring.

Referenced by SV_ModelIndex().

◆ SV_FreeTags()

void SV_FreeTags ( int tagNum,
const char * file,
int line )
static

Makes sure the game DLL does not use client, or signed tags.

Definition at line 558 of file sv_game.cpp.

References _Mem_FreeTag(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_GetEvent()

int SV_GetEvent ( void )
static
Returns
The current active event or -1 if no event is active at the moment

Definition at line 517 of file sv_game.cpp.

References pending_event_t::pending, sv, and pending_event_t::type.

Referenced by SV_InitGameProgs().

◆ SV_GetEventEdict()

edict_t * SV_GetEventEdict ( void )
static

Definition at line 526 of file sv_game.cpp.

References sv_edict_t::ent, pending_event_t::entnum, pending_event_t::pending, and sv.

Referenced by SV_InitGameProgs().

◆ SV_GetGameAPI()

game_export_t * SV_GetGameAPI ( game_import_t * parms)
static

Loads the game shared library and calls the api init function.

Definition at line 636 of file sv_game.cpp.

References Com_Error(), Com_LoadLibrary(), Com_Printf(), ERR_FATAL, FS_NextPath(), GetGameAPI(), PKGLIBDIR, SV_UnloadGame(), and svs.

Referenced by SV_InitGameProgs().

◆ SV_GetInlineModelAABB()

void SV_GetInlineModelAABB ( const char * name,
AABB & aabb )
static

Definition at line 618 of file sv_game.cpp.

References CM_GetInlineModelAABB(), name, and sv.

Referenced by SV_InitGameProgs().

◆ SV_GetVisibility()

float SV_GetVisibility ( const pos3_t position)
static

Glue function to get the visibility from a given position.

Definition at line 69 of file sv_game.cpp.

References CM_GetVisibility(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_GridCalcPathing()

void SV_GridCalcPathing ( actorSizeEnum_t actorSize,
pathing_t * path,
const pos3_t from,
int distance,
forbiddenList_t * forbiddenList )
static

Definition at line 598 of file sv_game.cpp.

References forbiddenList, Grid_CalcPathing(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_GridFall()

pos_t SV_GridFall ( const int actorSize,
const pos3_t pos )
static

Definition at line 578 of file sv_game.cpp.

References Grid_Fall(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_GridFindPath()

bool SV_GridFindPath ( actorSizeEnum_t actorSize,
pathing_t * path,
const pos3_t from,
const pos3_t targetPos,
byte crouchingState,
int maxTUs,
forbiddenList_t * forbiddenList )
static

Definition at line 603 of file sv_game.cpp.

References forbiddenList, Grid_FindPath(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_GridIsOnMap()

bool SV_GridIsOnMap ( const vec3_t vec)
static

Definition at line 593 of file sv_game.cpp.

References sv.

Referenced by SV_InitGameProgs().

◆ SV_GridPosToVec()

void SV_GridPosToVec ( const int actorSize,
const pos3_t pos,
vec3_t vec )
static

Definition at line 588 of file sv_game.cpp.

References Grid_PosToVec(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_InitGameProgs()

void SV_InitGameProgs ( void )

Init the game subsystem for a new map.

See also
SV_ShutdownGameProgs

Definition at line 747 of file sv_game.cpp.

References Cbuf_AddText(), Cmd_Argc(), Cmd_Args(), Cmd_Argv(), Com_CreateThread(), Com_Error(), Com_GetCharacterValues(), Com_GetConstInt(), Com_GetConstIntFromNamespace(), Com_GetConstVariable(), Com_GrenadeTarget(), Com_Printf(), Com_RegisterConstInt(), Com_UnregisterConstVariable(), csi, Cvar_Get(), Cvar_GetString(), Cvar_Set(), ERR_DROP, FS_FreeFile(), FS_Gamedir(), FS_LoadFile(), GAME_API_VERSION, gameSysPoolName, Grid_GetTUsForDirection(), Grid_MoveLength(), Grid_MoveNext(), Grid_MoveStore(), Grid_ShouldUseAutostand(), Mem_CreatePool, sv, SV_AbortEvents(), SV_AddEvent(), SV_BroadcastPrintf(), SV_CanActorStandHere(), SV_Configstring(), SV_dprintf(), SV_EndEvents(), SV_error(), SV_FreeTags(), SV_GetBounceFraction(), SV_GetEvent(), SV_GetEventEdict(), SV_GetFootstepSound(), SV_GetGameAPI(), SV_GetInlineModelAABB(), SV_GetVisibility(), SV_GridCalcPathing(), SV_GridFall(), SV_GridFindPath(), SV_GridIsOnMap(), SV_GridPosToVec(), SV_LinkEdict(), SV_LoadModelAABB(), SV_MemFree(), SV_ModelIndex(), SV_PlayerPrintf(), SV_PointContents(), SV_QueueEvent(), SV_QueueWriteByte(), SV_QueueWritePos(), SV_QueueWriteShort(), SV_QueueWriteString(), SV_ReadAngle(), SV_ReadByte(), SV_ReadChar(), SV_ReadData(), SV_ReadDir(), SV_ReadFormat(), SV_ReadGPos(), SV_ReadLong(), SV_ReadPos(), SV_ReadShort(), SV_ReadString(), SV_RecalcRouting(), SV_RunGameFrameThread(), SV_SetInlineModelOrientation(), SV_SetModel(), SV_TagAlloc(), SV_TestLine(), SV_TestLineWithEnt(), sv_threads, SV_Trace(), SV_UnlinkEdict(), SV_WriteAngle(), SV_WriteByte(), SV_WriteChar(), SV_WriteDir(), SV_WriteFormat(), SV_WriteGPos(), SV_WriteLong(), SV_WritePos(), SV_WriteShort(), SV_WriteString(), svs, Sys_Fopen(), and Sys_Milliseconds().

Referenced by SV_BroadcastPrintf(), SV_InitGame(), and TEST_F().

◆ SV_MemFree()

void SV_MemFree ( void * ptr,
const char * file,
int line )
static

Definition at line 550 of file sv_game.cpp.

References _Mem_Free().

Referenced by SV_InitGameProgs().

◆ SV_ModelIndex()

unsigned int SV_ModelIndex ( const char * name)
static

Definition at line 131 of file sv_game.cpp.

References CS_MODELS, MAX_MODELS, name, and SV_FindIndex().

Referenced by SV_InitGameProgs(), and SV_SetModel().

◆ SV_PlayerPrintf()

void SV_PlayerPrintf ( const SrvPlayer * player,
int level,
const char * fmt,
va_list ap )
static

Print to a single client.

See also
SV_BroadcastPrintf

Definition at line 52 of file sv_game.cpp.

References cl, SrvPlayer::getNum(), level, PRINT_NONE, Q_vsnprintf(), SV_ClientPrintf(), SV_GetClient(), and SV_LogAdd().

Referenced by SV_InitGameProgs().

◆ SV_QueueEvent()

void SV_QueueEvent ( unsigned int mask,
int eType,
int entnum )
static
See also
gi.QueueEvent
Parameters
[in]maskThe player bitmask to send the events to. Use PM_ALL to send to every connected player.
[in]eTypeThe event type
[in]entnumThe entity number

Definition at line 465 of file sv_game.cpp.

References pending_event_t::buf, Com_DPrintf(), Com_Error(), Com_UnsignedIntToBinary(), DEBUG_EVENTSYS, pending_event_t::entnum, ERR_DROP, EV_NUM_EVENTS, eventNames, lengthof, NET_WriteByte(), NET_WriteShort(), pending_event_t::pending, pending_event_t::playerMask, sv, svc_event, and pending_event_t::type.

Referenced by SV_InitGameProgs().

◆ SV_QueueWriteByte()

void SV_QueueWriteByte ( byte c)
static

Definition at line 494 of file sv_game.cpp.

References NET_WriteByte(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_QueueWritePos()

void SV_QueueWritePos ( const vec3_t pos)
static

Definition at line 504 of file sv_game.cpp.

References NET_WritePos(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_QueueWriteShort()

void SV_QueueWriteShort ( int c)
static

Definition at line 509 of file sv_game.cpp.

References NET_WriteShort(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_QueueWriteString()

void SV_QueueWriteString ( const char * s)
static

Definition at line 499 of file sv_game.cpp.

References NET_WriteString(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadAngle()

float SV_ReadAngle ( void )
static

Definition at line 279 of file sv_game.cpp.

References NET_ReadAngle(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadByte()

int SV_ReadByte ( void )
static

Definition at line 244 of file sv_game.cpp.

References NET_ReadByte(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadChar()

int SV_ReadChar ( void )
static

Definition at line 239 of file sv_game.cpp.

References NET_ReadChar(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadData()

void SV_ReadData ( void * buffer,
int size )
static

Definition at line 284 of file sv_game.cpp.

References NET_ReadData(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadDir()

void SV_ReadDir ( vec3_t vector)
static

Definition at line 274 of file sv_game.cpp.

References NET_ReadDir(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadFormat()

void SV_ReadFormat ( const char * format,
... )
static
See also
NET_vReadFormat

Definition at line 292 of file sv_game.cpp.

References format(), NET_vReadFormat(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadGPos()

void SV_ReadGPos ( pos3_t pos)
static

Definition at line 269 of file sv_game.cpp.

References NET_ReadGPos(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadLong()

int SV_ReadLong ( void )
static

Definition at line 254 of file sv_game.cpp.

References NET_ReadLong(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadPos()

void SV_ReadPos ( vec3_t pos)
static

Definition at line 264 of file sv_game.cpp.

References NET_ReadPos(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadShort()

int SV_ReadShort ( void )
static

Definition at line 249 of file sv_game.cpp.

References NET_ReadShort(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_ReadString()

int SV_ReadString ( char * str,
size_t length )
static

Definition at line 259 of file sv_game.cpp.

References length, NET_ReadString(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_RecalcRouting()

void SV_RecalcRouting ( const char * name,
const GridBox & box,
const char ** list )
static

Definition at line 583 of file sv_game.cpp.

References Grid_RecalcRouting(), name, and sv.

Referenced by SV_InitGameProgs().

◆ SV_RunGameFrame()

void SV_RunGameFrame ( void )

Calls the G_RunFrame function from game api let everything in the world think and move.

See also
G_RunFrame
SV_Frame

Definition at line 736 of file sv_game.cpp.

References ss_game_shutdown, sv, and svs.

Referenced by SV_BroadcastPrintf(), SV_Frame(), and SV_RunGameFrameThread().

◆ SV_RunGameFrameThread()

int SV_RunGameFrameThread ( void * data)

Thread for the game frame function.

See also
SV_RunGameFrame
SV_Frame

Definition at line 719 of file sv_game.cpp.

References data, sv, SV_RunGameFrame(), and svs.

Referenced by SV_BroadcastPrintf(), and SV_InitGameProgs().

◆ SV_SendQueuedEvents()

void SV_SendQueuedEvents ( void )
static

◆ SV_SetInlineModelOrientation()

void SV_SetInlineModelOrientation ( const char * name,
const vec3_t origin,
const vec3_t angles )
static

Definition at line 613 of file sv_game.cpp.

References CM_SetInlineModelOrientation(), name, and sv.

Referenced by SV_InitGameProgs().

◆ SV_SetModel()

void SV_SetModel ( edict_t * ent,
const char * name )
static

◆ SV_ShutdownGameProgs()

◆ SV_TagAlloc()

void * SV_TagAlloc ( int size,
int tagNum,
const char * file,
int line )
static

Makes sure the game DLL does not use client, or signed tags.

Definition at line 542 of file sv_game.cpp.

References _Mem_Alloc(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_TestLine()

bool SV_TestLine ( const vec3_t start,
const vec3_t stop,
const int levelmask )
static

Definition at line 566 of file sv_game.cpp.

References sv, and TR_TestLine().

Referenced by SV_InitGameProgs().

◆ SV_TestLineWithEnt()

bool SV_TestLineWithEnt ( const vec3_t start,
const vec3_t stop,
const int levelmask,
const char ** entlist )
static

Definition at line 571 of file sv_game.cpp.

References CM_EntTestLine(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_UnloadGame()

void SV_UnloadGame ( void )
static

Definition at line 623 of file sv_game.cpp.

References Com_Printf(), and svs.

Referenced by SV_GetGameAPI(), and SV_ShutdownGameProgs().

◆ SV_WriteAngle()

void SV_WriteAngle ( float f)
static

Definition at line 226 of file sv_game.cpp.

References f, NET_WriteAngle(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteByte()

void SV_WriteByte ( byte c)
static

Definition at line 191 of file sv_game.cpp.

References NET_WriteByte(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteChar()

void SV_WriteChar ( char c)
static

Definition at line 186 of file sv_game.cpp.

References NET_WriteChar(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteDir()

void SV_WriteDir ( const vec3_t dir)
static

Definition at line 221 of file sv_game.cpp.

References NET_WriteDir(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteFormat()

void SV_WriteFormat ( const char * format,
... )
static

Definition at line 231 of file sv_game.cpp.

References format(), NET_vWriteFormat(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteGPos()

void SV_WriteGPos ( const pos3_t pos)
static

Definition at line 216 of file sv_game.cpp.

References NET_WriteGPos(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteLong()

void SV_WriteLong ( int c)
static

Definition at line 201 of file sv_game.cpp.

References NET_WriteLong(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WritePos()

void SV_WritePos ( const vec3_t pos)
static

Definition at line 211 of file sv_game.cpp.

References NET_WritePos(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteShort()

void SV_WriteShort ( int c)
static

Definition at line 196 of file sv_game.cpp.

References NET_WriteShort(), and sv.

Referenced by SV_InitGameProgs().

◆ SV_WriteString()

void SV_WriteString ( const char * s)
static

Definition at line 206 of file sv_game.cpp.

References NET_WriteString(), and sv.

Referenced by SV_InitGameProgs().

Variable Documentation

◆ eventNames

const eventNames_t eventNames[]
static

Definition at line 357 of file sv_game.cpp.

Referenced by CASSERT(), SV_AddEvent(), and SV_QueueEvent().

◆ gameSysPoolName

char const* const gameSysPoolName = "Server: Game system"
static

Definition at line 674 of file sv_game.cpp.

Referenced by SV_InitGameProgs(), and SV_ShutdownGameProgs().