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 sizesize)
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_t * SV_GetEventEdict (void)
static void * SV_TagAlloc (int sizesize, 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 originorigin, const vec3_t angles)
static void SV_GetInlineModelAABB (const char *name, AABB &aabb)
static void SV_UnloadGame (void)
static game_export_t * SV_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()

◆ 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, serverInstanceGame_t::pendingEvent, sv, and SV_AbortEvents().

Referenced by SV_AbortEvents(), and 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(), dbuffer::dbuffer(), DEBUG_EVENTSYS, pending_event_t::entnum, ERR_DROP, EV_NUM_EVENTS, eventNames, eventNames_t::name, NET_WriteByte(), NET_WriteShort(), pending_event_t::pending, serverInstanceGame_t::pendingEvent, pending_event_t::playerMask, sv, SV_AddEvent(), SV_EndEvents(), SV_SendQueuedEvents(), svc_event, and pending_event_t::type.

Referenced by SV_AddEvent(), and SV_InitGameProgs().

◆ SV_CanActorStandHere()

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

◆ 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_dprintf(), and SV_LogAdd().

Referenced by SV_dprintf(), and SV_InitGameProgs().

◆ SV_EndEvents()

◆ 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_FindIndex(), SV_GetConfigString(), SV_Multicast(), SV_SetConfigString, and svc_configstring.

Referenced by SV_FindIndex(), and 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(), serverInstanceGame_t::gameSysPool, sv, and SV_FreeTags().

Referenced by SV_FreeTags(), and 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, serverInstanceGame_t::pendingEvent, sv, SV_GetEvent(), and pending_event_t::type.

Referenced by SV_GetEvent(), and SV_InitGameProgs().

◆ SV_GetEventEdict()

◆ 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(), serverInstanceStatic_t::gameLibrary, GetGameAPI(), PKGLIBDIR, SV_GetGameAPI(), SV_UnloadGame(), and svs.

Referenced by SV_GetGameAPI(), and SV_InitGameProgs().

◆ SV_GetInlineModelAABB()

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

◆ 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(), serverInstanceGame_t::mapTiles, sv, and SV_GetVisibility().

Referenced by SV_GetVisibility(), and SV_InitGameProgs().

◆ SV_GridCalcPathing()

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

◆ SV_GridFall()

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

◆ 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

◆ SV_GridIsOnMap()

bool SV_GridIsOnMap ( const vec3_t vec)
static

◆ SV_GridPosToVec()

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

◆ 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 game_export_t::apiversion, 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, serverInstanceStatic_t::gameFrameCond, serverInstanceGame_t::gameSysPool, gameSysPoolName, serverInstanceStatic_t::gameThread, serverInstanceStatic_t::ge, Grid_GetTUsForDirection(), Grid_MoveLength(), Grid_MoveNext(), Grid_MoveStore(), Grid_ShouldUseAutostand(), cvar_t::integer, 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_InitGameProgs(), 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(), SV_InitGameProgs(), 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(), and SV_MemFree().

Referenced by SV_InitGameProgs(), and SV_MemFree().

◆ 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, SV_FindIndex(), and SV_ModelIndex().

Referenced by SV_InitGameProgs(), SV_ModelIndex(), 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(), SV_LogAdd(), and SV_PlayerPrintf().

Referenced by SV_InitGameProgs(), and SV_PlayerPrintf().

◆ 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(), dbuffer::dbuffer(), DEBUG_EVENTSYS, pending_event_t::entnum, ERR_DROP, EV_NUM_EVENTS, eventNames, serverInstanceGame_t::eventQueue, serverInstanceGame_t::eventQueuePos, lengthof, eventNames_t::name, NET_WriteByte(), NET_WriteShort(), pending_event_t::pending, pending_event_t::playerMask, sv, SV_QueueEvent(), svc_event, and pending_event_t::type.

Referenced by SV_InitGameProgs(), and SV_QueueEvent().

◆ SV_QueueWriteByte()

◆ SV_QueueWritePos()

◆ SV_QueueWriteShort()

◆ SV_QueueWriteString()

void SV_QueueWriteString ( const char * s)
static

◆ SV_ReadAngle()

float SV_ReadAngle ( void )
static

Definition at line 279 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadAngle(), sv, and SV_ReadAngle().

Referenced by SV_InitGameProgs(), and SV_ReadAngle().

◆ SV_ReadByte()

int SV_ReadByte ( void )
static

Definition at line 244 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadByte(), sv, and SV_ReadByte().

Referenced by SV_InitGameProgs(), and SV_ReadByte().

◆ SV_ReadChar()

int SV_ReadChar ( void )
static

Definition at line 239 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadChar(), sv, and SV_ReadChar().

Referenced by SV_InitGameProgs(), and SV_ReadChar().

◆ SV_ReadData()

void SV_ReadData ( void * buffer,
int size )
static

Definition at line 284 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadData(), sv, and SV_ReadData().

Referenced by SV_InitGameProgs(), and SV_ReadData().

◆ SV_ReadDir()

void SV_ReadDir ( vec3_t vector)
static

Definition at line 274 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadDir(), sv, and SV_ReadDir().

Referenced by SV_InitGameProgs(), and SV_ReadDir().

◆ SV_ReadFormat()

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

◆ SV_ReadGPos()

void SV_ReadGPos ( pos3_t pos)
static

Definition at line 269 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadGPos(), sv, and SV_ReadGPos().

Referenced by SV_InitGameProgs(), and SV_ReadGPos().

◆ SV_ReadLong()

int SV_ReadLong ( void )
static

Definition at line 254 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadLong(), sv, and SV_ReadLong().

Referenced by SV_InitGameProgs(), and SV_ReadLong().

◆ SV_ReadPos()

void SV_ReadPos ( vec3_t pos)
static

Definition at line 264 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadPos(), sv, and SV_ReadPos().

Referenced by SV_InitGameProgs(), and SV_ReadPos().

◆ SV_ReadShort()

int SV_ReadShort ( void )
static

Definition at line 249 of file sv_game.cpp.

References serverInstanceGame_t::messageBuffer, NET_ReadShort(), sv, and SV_ReadShort().

Referenced by SV_InitGameProgs(), and SV_ReadShort().

◆ SV_ReadString()

int SV_ReadString ( char * str,
size_t length )
static

◆ SV_RecalcRouting()

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

◆ 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 serverInstanceGame_t::endgame, serverInstanceStatic_t::ge, ss_game_shutdown, serverInstanceGame_t::state, sv, SV_RunGameFrame(), and svs.

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

◆ SV_RunGameFrameThread()

◆ SV_SendQueuedEvents()

◆ SV_SetInlineModelOrientation()

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

◆ 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(), serverInstanceGame_t::gameSysPool, sv, and SV_TagAlloc().

Referenced by SV_InitGameProgs(), and SV_TagAlloc().

◆ 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 serverInstanceGame_t::mapTiles, sv, SV_TestLine(), and TR_TestLine().

Referenced by SV_InitGameProgs(), and SV_TestLine().

◆ SV_TestLineWithEnt()

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

◆ SV_UnloadGame()

void SV_UnloadGame ( void )
static

◆ SV_WriteAngle()

void SV_WriteAngle ( float f)
static

◆ SV_WriteByte()

void SV_WriteByte ( byte c)
static

◆ SV_WriteChar()

void SV_WriteChar ( char c)
static

◆ SV_WriteDir()

void SV_WriteDir ( const vec3_t dir)
static

◆ SV_WriteFormat()

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

◆ SV_WriteGPos()

void SV_WriteGPos ( const pos3_t pos)
static

◆ SV_WriteLong()

void SV_WriteLong ( int c)
static

◆ SV_WritePos()

void SV_WritePos ( const vec3_t pos)
static

◆ SV_WriteShort()

void SV_WriteShort ( int c)
static

◆ SV_WriteString()

void SV_WriteString ( const char * s)
static

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().