30 #include "../common/grid.h"
31 #include "../common/routing.h"
32 #include "../ports/system.h"
33 #include "../shared/thread.h"
34 #include "../shared/scopedmutex.h"
84 va_start(argptr, fmt);
103 if (!name || !name[0])
108 if (
Q_streq(configString, name))
116 SV_error(
"*Index: overflow '%s' start: %i, max: %i", name, start, max);
148 if (name[0] ==
'*') {
167 SV_error(
"configstring: bad index %i", index);
169 va_start(argptr, fmt);
234 va_start(ap, format);
300 va_start(ap, format);
427 static void SV_AddEvent (
unsigned int mask,
int eType,
int entnum)
435 const char* eventName = eventNames[rawType].
name;
475 const char* eventName = eventNames[rawType].
name;
550 static void SV_MemFree (
void* ptr,
const char* file,
int line)
625 #ifndef HARD_LINKED_GAME
633 #ifndef HARD_LINKED_GAME
641 Com_sprintf(name,
sizeof(name),
"%s/game.%s", path, SO_EXT);
661 #ifndef HARD_LINKED_GAME
669 Com_Printf(
"------- Loading game.%s -------\n", SO_EXT);
686 GetGameAPI = (game_api_t)(uintptr_t)SDL_LoadFunction(
svs.
gameLibrary,
"GetGameAPI");
724 Com_Printf(
"WARNING: Game memory leak (%u bytes)\n", size);
883 Com_Printf(
"setting game random seed to %i\n",
import.seed);
static int SV_ReadLong(void)
bool Grid_ShouldUseAutostand(const pathing_t *path, const pos3_t toPos)
Checks if a crouched actor could save TUs by standing up, walking and crouching again.
const char * Cmd_Argv(int arg)
Returns a given argument.
pending_event_t eventQueue[64]
void NET_ReadPos(dbuffer *buf, vec3_t pos)
void NET_ReadGPos(dbuffer *buf, pos3_t pos)
static void SV_WritePos(const vec3_t pos)
void void void SV_BroadcastPrintf(int level, const char *fmt,...) __attribute__((format(__printf__
static void SV_QueueWriteShort(int c)
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
bool Com_UnregisterConstVariable(const char *name)
Removes a registered constant from the script mapping hash table.
static bool SV_TestLine(const vec3_t start, const vec3_t stop, const int levelmask)
int Grid_GetTUsForDirection(const int dir, bool crouched)
Returns the amounts of TUs that are needed to perform one step into the given direction.
bool Com_GetConstIntFromNamespace(const char *space, const char *variable, int *value)
Searches whether a given value was registered as a string to int mapping.
int Grid_MoveNext(const pathing_t *path, const pos3_t toPos, byte crouchingState)
Get the direction to use to move to a position (used to reconstruct the path)
char * SV_GetConfigString(int index)
static void SV_ReadFormat(const char *format,...)
static void SV_Configstring(int index, const char *fmt,...)
void NET_ReadDir(dbuffer *buf, vec3_t dir)
static void SV_error(const char *fmt,...) __attribute__((noreturn))
Abort the server with a game error.
static void SV_ReadGPos(pos3_t pos)
static void SV_WriteGPos(const pos3_t pos)
int NET_ReadChar(dbuffer *buf)
void * _Mem_Alloc(size_t size, bool zeroFill, memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
pos_t Grid_Fall(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos)
Calculated the new height level when something falls down from a certain position.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
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.
void Grid_CalcPathing(const Routing &routing, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, int maxTUs, forbiddenList_t *fb_list)
Recalculate the pathing table for the given actor(-position)
static int SV_ReadString(char *str, size_t length)
void Cbuf_AddText(const char *format,...)
Adds command text at the end of the buffer.
static void SV_GetInlineModelAABB(const char *name, AABB &aabb)
void SV_ShutdownGameProgs(void)
Called when either the entire server is being killed, or it is changing to a different game directory...
void NET_WriteString(dbuffer *buf, const char *str)
void NET_WriteChar(dbuffer *buf, char c)
static const eventNames_t eventNames[]
static void SV_GridPosToVec(const int actorSize, const pos3_t pos, vec3_t vec)
void NET_WritePos(dbuffer *buf, const vec3_t pos)
static void SV_WriteChar(char c)
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
static void SV_WriteString(const char *s)
void SV_UnlinkEdict(edict_t *ent)
call before removing an entity, and before trying to move one, so it doesn't clip against itself ...
int NET_ReadLong(dbuffer *buf)
void set(const AABB &other)
Copies the values from the given aabb.
void Com_Printf(const char *const fmt,...)
SDL_Thread * Com_CreateThread(int(*fn)(void *), const char *name, void *data=nullptr)
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.
void Grid_RecalcRouting(mapTiles_t *mapTiles, Routing &routing, const char *name, const GridBox &box, const char **list)
This function recalculates the routing surrounding the entity name.
void NET_vReadFormat(dbuffer *buf, const char *format, va_list ap)
Reads from a buffer according to format; version without syntactic sugar for variable arguments...
void Com_SetServerState(int state)
bool SV_LoadModelAABB(const char *model, int frame, AABB &aabb)
Load the bounding box for the model on the serverside for pathfinding and clipping.
void SV_LinkEdict(edict_t *ent)
Needs to be called any time an entity changes origin, mins, maxs, or solid. Automatically unlinks if ...
void SV_InitGameProgs(void)
Init the game subsystem for a new map.
void Com_GetCharacterValues(const char *teamDefition, character_t *chr)
Assign character values, 3D models and names to a character.
void Com_Error(int code, const char *fmt,...)
client_t * SV_GetClient(int index)
pos_t Grid_MoveLength(const pathing_t *path, const pos3_t to, byte crouchingState, bool stored)
Return the needed TUs to walk to a given position.
void Cmd_ExecuteString(const char *text,...)
A complete command line has been parsed, so try to execute it.
void SV_Multicast(int mask, const dbuffer &msg)
Sends the contents of msg to a subset of the clients, then frees msg.
const char * FS_Gamedir(void)
Called to find where to write a file (savegames, etc)
serverInstanceGame_t * sv
pending_event_t pendingEvent
#define SV_SetConfigString(index, value)
functions exported by the game subsystem
CASSERT(lengthof(eventNames)==EV_NUM_EVENTS)
static int SV_ReadChar(void)
void _Mem_Free(void *ptr, const char *fileName, const int fileLine)
functions provided by the main engine
void NET_vWriteFormat(dbuffer *buf, const char *format, va_list ap)
Writes to buffer according to format; version without syntactic sugar for variable arguments...
void SV_RunGameFrame(void)
Calls the G_RunFrame function from game api let everything in the world think and move...
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
int NET_ReadString(dbuffer *buf, char *string, size_t length)
game lib logging handling
static unsigned int SV_ModelIndex(const char *name)
QGL_EXTERN GLuint GLsizei GLsizei * length
bool contains(const vec3_t point) const
float CM_GetVisibility(const mapTiles_t *mapTiles, const pos3_t position)
Checks how well a position is visible.
static float SV_ReadAngle(void)
static void SV_QueueWritePos(const vec3_t pos)
static void SV_FreeTags(int tagNum, const char *file, int line)
Makes sure the game DLL does not use client, or signed tags.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
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)
void NET_WriteLong(dbuffer *buf, int c)
Main server include file.
float Com_GrenadeTarget(const vec3_t from, const vec3_t at, float speed, bool launched, bool rolled, vec3_t v0)
Calculates parabola-type shot.
int NET_ReadShort(dbuffer *buf)
static forbiddenList_t forbiddenList
A list of locations that cannot be moved to.
#define Mem_CreatePool(name)
#define Mem_DeletePool(pool)
static void SV_SetModel(edict_t *ent, const char *name)
static void SV_UnloadGame(void)
void CM_GetInlineModelAABB(mapTiles_t *mapTiles, const char *name, AABB &aabb)
This function calculates a model's aabb in world coordinates.
bool CM_EntTestLine(mapTiles_t *mapTiles, const Line &traceLine, const int levelmask, const char **entlist)
Checks traces against the world and all inline models.
static void SV_WriteAngle(float f)
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
bool Grid_FindPath(const Routing &routing, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, const pos3_t targetPos, byte crouchingState, int maxTUs, forbiddenList_t *forbiddenList)
Tries to find a path from the given actor(-position) to a given target position.
int SV_PointContents(const vec3_t p)
Returns the content flags for a given point.
static void SV_AbortEvents(void)
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
static void SV_WriteFormat(const char *format,...)
bool Com_CheckConfigStringIndex(int index)
cBspModel_t * CM_InlineModel(const mapTiles_t *mapTiles, const char *name)
Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name...
static bool SV_GridIsOnMap(const vec3_t vec)
static void SV_EndEvents(void)
const char * Com_UnsignedIntToBinary(uint32_t x)
const char * Com_GetConstVariable(const char *space, int value)
Searches the mapping variable for a given integer value and a namespace.
void Grid_MoveStore(pathing_t *path)
Caches the calculated move.
static void SV_WriteByte(byte c)
void NET_ReadData(dbuffer *buf, void *data, int len)
void NET_WriteAngle(dbuffer *buf, float f)
static char const *const gameSysPoolName
int SV_RunGameFrameThread(void *data)
Thread for the game frame function.
static bool SV_TestLineWithEnt(const vec3_t start, const vec3_t stop, const int levelmask, const char **entlist)
static void SV_WriteLong(int c)
float NET_ReadAngle(dbuffer *buf)
float SV_GetBounceFraction(const char *texture)
Different terrain types might have different bounce fraction.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void NET_WriteByte(dbuffer *buf, byte c)
sv_edict_t edicts[MAX_EDICTS]
static void SV_ReadDir(vec3_t vector)
static void SV_RecalcRouting(const char *name, const GridBox &box, const char **list)
static void SV_QueueWriteString(const char *s)
bool TR_TestLine(mapTiles_t *mapTiles, const vec3_t start, const vec3_t end, const int levelmask)
Checks traces against the world.
cBspModel_t * CM_SetInlineModelOrientation(mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
This function updates a model's orientation.
static bool SV_CanActorStandHere(const int actorSize, const pos3_t pos)
static void SV_QueueWriteByte(byte c)
static void SV_ReadData(void *buffer, int size)
const char * SV_GetFootstepSound(const char *texture)
Query the footstep sound for the given surface texture.
static void SV_ReadPos(vec3_t pos)
void void SV_ClientPrintf(client_t *cl, int level, const char *fmt,...) __attribute__((format(__printf__
FILE * Sys_Fopen(const char *filename, const char *mode)
static int SV_ReadByte(void)
static float SV_GetVisibility(const pos3_t position)
Glue function to get the visibility from a given position.
trace_t SV_Trace(const Line &traceLine, const AABB &box, const edict_t *passedict, int contentmask)
Moves the given mins/maxs volume through the world from start to end.
game_export_t * GetGameAPI(game_import_t *import)
Returns a pointer to the structure with all entry points and global variables.
static void SV_GridCalcPathing(actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, int distance, forbiddenList_t *forbiddenList)
static void SV_AddEvent(unsigned int mask, int eType, int entnum)
void SV_LogAdd(const char *format, va_list ap)
Async version to add a log entry for the game lib.
GLsizei const GLvoid * data
static game_export_t * SV_GetGameAPI(game_import_t *parms)
Loads the game shared library and calls the api init function.
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
static pos_t SV_GridFall(const int actorSize, const pos3_t pos)
static bool SV_LoadGame(const char *path)
A list of locations that cannot be moved to.
void NET_WriteGPos(dbuffer *buf, const pos3_t pos)
static int SV_GetEvent(void)
void NET_WriteDir(dbuffer *buf, const vec3_t dir)
void _Mem_FreeTag(memPool_t *pool, const int tagNum, const char *fileName, const int fileLine)
Free memory blocks assigned to a specified tag within a pool.
static int SV_ReadShort(void)
void Grid_PosToVec(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec)
Converts a grid position to world coordinates.
static void SV_SetInlineModelOrientation(const char *name, const vec3_t origin, const vec3_t angles)
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.
bool RT_CanActorStandHere(const Routing &routing, const int actorSize, const pos3_t pos)
Check if an actor can stand(up) in the cell given by pos.
static void SV_WriteShort(int c)
int Com_ServerState(void)
Check whether we are the server or have a singleplayer tactical mission.
serverInstanceStatic_t svs
static void SV_MemFree(void *ptr, const char *file, int line)
static void SV_SendQueuedEvents(void)
static void SV_QueueEvent(unsigned int mask, int eType, int entnum)
void NET_WriteShort(dbuffer *buf, int c)
int NET_ReadByte(dbuffer *buf)
Reads a byte from the netchannel.
const char * Cmd_Args(void)
Returns a single string containing argv(1) to argv(argc()-1)
bool Com_GetConstInt(const char *name, int *value)
Searches whether a given value was registered as a string to int mapping.
void format(__printf__, 1, 2)))
static void SV_WriteDir(const vec3_t dir)
void FS_FreeFile(void *buffer)
static edict_t * SV_GetEventEdict(void)
int Sys_Milliseconds(void)
#define Mem_PoolSize(pool)
const char * FS_NextPath(const char *prevpath)
Allows enumerating all of the directories in the search path.