UFO: Alien Invasion
|
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"
Go to the source code of this file.
Data Structures | |
struct | eventNames_t |
Macros | |
#define | M(x) { #x } |
Functions | |
static void | SV_dprintf (const char *fmt,...) |
Debug print to server console. More... | |
static void | SV_PlayerPrintf (const SrvPlayer *player, int level, const char *fmt, va_list ap) |
Print to a single client. More... | |
static float | SV_GetVisibility (const pos3_t position) |
Glue function to get the visibility from a given position. More... | |
static void | SV_error (const char *fmt,...) |
Abort the server with a game error. More... | |
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. More... | |
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_t * | SV_GetEventEdict (void) |
static void * | SV_TagAlloc (int size, int tagNum, const char *file, int line) |
Makes sure the game DLL does not use client, or signed tags. More... | |
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. More... | |
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 bool | SV_LoadGame (const char *path) |
static game_export_t * | SV_GetGameAPI (game_import_t *parms) |
Loads the game shared library and calls the api init function. More... | |
void | SV_ShutdownGameProgs (void) |
Called when either the entire server is being killed, or it is changing to a different game directory. More... | |
int | SV_RunGameFrameThread (void *data) |
Thread for the game frame function. More... | |
void | SV_RunGameFrame (void) |
Calls the G_RunFrame function from game api let everything in the world think and move. More... | |
void | SV_InitGameProgs (void) |
Init the game subsystem for a new map. More... | |
Variables | |
static const eventNames_t | eventNames [] |
static char const *const | gameSysPoolName = "Server: Game system" |
Interface to the game library.
Definition in file sv_game.cpp.
#define M | ( | x | ) | { #x } |
Definition at line 356 of file sv_game.cpp.
CASSERT | ( | lengthof(eventNames) | = =EV_NUM_EVENTS | ) |
Definition at line 308 of file sv_game.cpp.
References pending_event_s::buf, pending_event_s::pending, serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
[in] | mask | The player bitmask to send the events to. Use PM_ALL to send to every connected player. |
[in] | eType | The event type |
[in] | entnum | The entity number |
Definition at line 427 of file sv_game.cpp.
References pending_event_s::buf, Com_DPrintf(), Com_Error(), Com_UnsignedIntToBinary(), DEBUG_EVENTSYS, pending_event_s::entnum, ERR_DROP, EV_NUM_EVENTS, EVENT_INSTANTLY, eventNames_t::name, NET_WriteByte(), NET_WriteShort(), pending_event_s::pending, serverInstanceGame_s::pendingEvent, pending_event_s::playerMask, sv, SV_EndEvents(), SV_SendQueuedEvents(), svc_event, and pending_event_s::type.
Referenced by SV_InitGameProgs().
Definition at line 608 of file sv_game.cpp.
References serverInstanceGame_s::mapData, mapData_s::routing, RT_CanActorStandHere(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 161 of file sv_game.cpp.
References Com_CheckConfigStringIndex(), Com_ServerState(), MAX_TILESTRINGS, MAX_TOKEN_CHARS, NET_WriteByte(), NET_WriteShort(), NET_WriteString(), Q_vsnprintf(), ss_loading, SV_error(), SV_Multicast(), SV_SetConfigString, and svc_configstring.
Referenced by SV_InitGameProgs().
|
static |
Debug print to server console.
Definition at line 39 of file sv_game.cpp.
References SV_LogAdd().
Referenced by SV_InitGameProgs().
Definition at line 334 of file sv_game.cpp.
References pending_event_s::buf, EV_NULL, NET_WriteByte(), pending_event_s::pending, serverInstanceGame_s::pendingEvent, pending_event_s::playerMask, sv, SV_Multicast(), and SV_SendQueuedEvents().
Referenced by SV_AddEvent(), and SV_InitGameProgs().
|
static |
Abort the server with a game error.
Definition at line 79 of file sv_game.cpp.
References Com_Error(), ERR_DROP, and Q_vsnprintf().
Referenced by SV_Configstring(), SV_FindIndex(), SV_InitGameProgs(), and SV_SetModel().
Search the index in the config strings relative to a given start.
name | The value of the config string to search the index for |
start | The relative start point for the search |
max | The max. searched entries in the config string before giving up |
create | if true the value will get written into the config strings (appended) |
0
if not found Definition at line 99 of file sv_game.cpp.
References Com_ServerState(), i, 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().
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_s::gameSysPool, and sv.
Referenced by SV_InitGameProgs().
Definition at line 517 of file sv_game.cpp.
References pending_event_s::pending, serverInstanceGame_s::pendingEvent, sv, and pending_event_s::type.
Referenced by SV_InitGameProgs().
Definition at line 526 of file sv_game.cpp.
References serverInstanceGame_s::edicts, sv_edict_s::ent, pending_event_s::entnum, pending_event_s::pending, serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
|
static |
Loads the game shared library and calls the api init function.
Definition at line 659 of file sv_game.cpp.
References Com_Error(), Com_Printf(), ERR_FATAL, FS_NextPath(), serverInstanceStatic_s::gameLibrary, GetGameAPI(), PKGLIBDIR, SV_LoadGame(), SV_UnloadGame(), and svs.
Referenced by SV_InitGameProgs().
Definition at line 618 of file sv_game.cpp.
References CM_GetInlineModelAABB(), serverInstanceGame_s::mapTiles, and sv.
Referenced by SV_InitGameProgs().
|
static |
Glue function to get the visibility from a given position.
Definition at line 69 of file sv_game.cpp.
References CM_GetVisibility(), serverInstanceGame_s::mapTiles, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 598 of file sv_game.cpp.
References Grid_CalcPathing(), serverInstanceGame_s::mapData, mapData_s::routing, and sv.
Referenced by SV_InitGameProgs().
Definition at line 578 of file sv_game.cpp.
References Grid_Fall(), serverInstanceGame_s::mapData, mapData_s::routing, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 603 of file sv_game.cpp.
References Grid_FindPath(), serverInstanceGame_s::mapData, mapData_s::routing, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 593 of file sv_game.cpp.
References AABB::contains(), mapData_s::mapBox, serverInstanceGame_s::mapData, and sv.
Referenced by SV_InitGameProgs().
Definition at line 588 of file sv_game.cpp.
References Grid_PosToVec(), serverInstanceGame_s::mapData, mapData_s::routing, and sv.
Referenced by SV_InitGameProgs().
Init the game subsystem for a new map.
Definition at line 769 of file sv_game.cpp.
References game_export_s::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_s::gameFrameCond, serverInstanceGame_s::gameSysPool, serverInstanceStatic_s::gameThread, serverInstanceStatic_s::ge, Grid_GetTUsForDirection(), Grid_MoveLength(), Grid_MoveNext(), Grid_MoveStore(), Grid_ShouldUseAutostand(), cvar_s::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_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_InitGame(), and TEST_F().
|
static |
Definition at line 634 of file sv_game.cpp.
References Com_DPrintf(), Com_Printf(), Com_sprintf(), CPUSTRING, DEBUG_SYSTEM, serverInstanceStatic_s::gameLibrary, MAX_OSPATH, name, and svs.
Referenced by SV_GetGameAPI().
Definition at line 550 of file sv_game.cpp.
References _Mem_Free().
Referenced by SV_InitGameProgs().
|
static |
Definition at line 131 of file sv_game.cpp.
References CS_MODELS, MAX_MODELS, and SV_FindIndex().
Referenced by SV_InitGameProgs(), and SV_SetModel().
|
static |
Print to a single client.
Definition at line 52 of file sv_game.cpp.
References cl, SrvPlayer::getNum(), PRINT_NONE, Q_vsnprintf(), SV_ClientPrintf(), SV_GetClient(), and SV_LogAdd().
Referenced by SV_InitGameProgs().
[in] | mask | The player bitmask to send the events to. Use PM_ALL to send to every connected player. |
[in] | eType | The event type |
[in] | entnum | The entity number |
Definition at line 465 of file sv_game.cpp.
References pending_event_s::buf, Com_DPrintf(), Com_Error(), Com_UnsignedIntToBinary(), DEBUG_EVENTSYS, pending_event_s::entnum, ERR_DROP, EV_NUM_EVENTS, EVENT_INSTANTLY, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, lengthof, eventNames_t::name, NET_WriteByte(), NET_WriteShort(), pending_event_s::pending, pending_event_s::playerMask, sv, svc_event, and pending_event_s::type.
Referenced by SV_InitGameProgs().
Definition at line 494 of file sv_game.cpp.
References pending_event_s::buf, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, NET_WriteByte(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 504 of file sv_game.cpp.
References pending_event_s::buf, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, NET_WritePos(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 509 of file sv_game.cpp.
References pending_event_s::buf, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, NET_WriteShort(), and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 499 of file sv_game.cpp.
References pending_event_s::buf, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, NET_WriteString(), and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 279 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadAngle(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 244 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadByte(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 239 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadChar(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 284 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadData(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 274 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadDir(), and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 292 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_vReadFormat(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 269 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadGPos(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 254 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadLong(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 264 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadPos(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 249 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadShort(), and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 259 of file sv_game.cpp.
References serverInstanceGame_s::messageBuffer, NET_ReadString(), and sv.
Referenced by SV_InitGameProgs().
Definition at line 583 of file sv_game.cpp.
References Grid_RecalcRouting(), serverInstanceGame_s::mapData, serverInstanceGame_s::mapTiles, mapData_s::routing, and sv.
Referenced by SV_InitGameProgs().
Calls the G_RunFrame function from game api let everything in the world think and move.
Definition at line 758 of file sv_game.cpp.
References serverInstanceGame_s::endgame, serverInstanceStatic_s::ge, ss_game_shutdown, serverInstanceGame_s::state, sv, and svs.
Referenced by SV_Frame(), and SV_RunGameFrameThread().
Thread for the game frame function.
Definition at line 741 of file sv_game.cpp.
References serverInstanceGame_s::endgame, serverInstanceStatic_s::gameFrameCond, serverInstanceStatic_s::serverMutex, sv, SV_RunGameFrame(), and svs.
Referenced by SV_InitGameProgs().
Definition at line 320 of file sv_game.cpp.
References pending_event_s::buf, EV_NULL, serverInstanceGame_s::eventQueue, serverInstanceGame_s::eventQueuePos, i, NET_WriteByte(), pending_event_s::playerMask, sv, and SV_Multicast().
Referenced by SV_AddEvent(), and SV_EndEvents().
|
static |
Definition at line 613 of file sv_game.cpp.
References CM_SetInlineModelOrientation(), serverInstanceGame_s::mapTiles, and sv.
Referenced by SV_InitGameProgs().
Definition at line 140 of file sv_game.cpp.
References SrvEdict::angles, cBspModel_s::cbmBox, CM_InlineModel(), CM_SetInlineModelOrientation(), SrvEdict::entBox, serverInstanceGame_s::mapTiles, SrvEdict::modelindex, SrvEdict::origin, AABB::set(), sv, SV_error(), and SV_ModelIndex().
Referenced by SV_InitGameProgs().
Called when either the entire server is being killed, or it is changing to a different game directory.
Definition at line 703 of file sv_game.cpp.
References Cmd_ExecuteString(), Com_Printf(), Com_SetServerState(), serverInstanceStatic_s::gameFrameCond, serverInstanceGame_s::gameSysPool, serverInstanceStatic_s::gameThread, serverInstanceStatic_s::ge, Mem_DeletePool, Mem_PoolSize, ss_game_shutdown, sv, SV_UnloadGame(), and svs.
Referenced by SV_Shutdown(), GameTest::TearDown(), TEST_F(), GameTest::testCountSpawnpointsForMapInMultiplayerMode(), and GameTest::testCountSpawnpointsForMapInSingleplayerMode().
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_s::gameSysPool, and sv.
Referenced by SV_InitGameProgs().
Definition at line 566 of file sv_game.cpp.
References serverInstanceGame_s::mapTiles, sv, and TR_TestLine().
Referenced by SV_InitGameProgs().
|
static |
Definition at line 571 of file sv_game.cpp.
References CM_EntTestLine(), serverInstanceGame_s::mapTiles, and sv.
Referenced by SV_InitGameProgs().
Definition at line 623 of file sv_game.cpp.
References Com_Printf(), serverInstanceStatic_s::gameLibrary, and svs.
Referenced by SV_GetGameAPI(), and SV_ShutdownGameProgs().
|
static |
Definition at line 226 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteAngle(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 191 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteByte(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 186 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteChar(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 221 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteDir(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 231 of file sv_game.cpp.
References pending_event_s::buf, NET_vWriteFormat(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 216 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteGPos(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 201 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteLong(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 211 of file sv_game.cpp.
References pending_event_s::buf, NET_WritePos(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
Definition at line 196 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteShort(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 206 of file sv_game.cpp.
References pending_event_s::buf, NET_WriteString(), serverInstanceGame_s::pendingEvent, and sv.
Referenced by SV_InitGameProgs().
|
static |
Definition at line 357 of file sv_game.cpp.
|
static |
Definition at line 696 of file sv_game.cpp.