common.h File Reference

definitions common between client and server, but not game lib More...

#include "../shared/ufotypes.h"
#include "../shared/byte.h"
#include "../shared/shared.h"
#include "../shared/mathlib.h"
#include "../shared/defines.h"
#include "../shared/typedefs.h"
#include "tracing.h"
#include "cvar.h"
#include "mem.h"
#include "http.h"
#include "../ports/system.h"
#include "cmd.h"
#include "cmodel.h"
#include "filesys.h"
#include "scripts.h"
#include "net.h"
#include "dbuffer.h"
#include "netpack.h"
#include "md4.h"
#include "../shared/ufotypes.h"
#include "../shared/byte.h"
#include "../shared/shared.h"
#include "../shared/mathlib.h"
#include "../shared/defines.h"
#include "../shared/typedefs.h"
#include "../ports/system.h"
Include dependency graph for common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  date_s
 Engine-side time information in the game. More...
struct  cvarlist_s
struct  gametype_s

Defines

#define UFO_VERSION   "2.4-dev"
#define GAME_TITLE   "UFO:AI"
#define GAME_TITLE_LONG   "UFO:Alien Invasion"
#define BUILDSTRING_OS   "Unknown"
#define CPUSTRING   "Unknown"
#define BUILDSTRING_VARIANT   "RELEASE"
#define BUILDSTRING   BUILDSTRING_OS " " BUILDSTRING_VARIANT
#define MASTER_SERVER   "http://ufoai.ninex.info/"
#define PROTOCOL_VERSION   6
#define PORT_CLIENT   27901
#define PORT_SERVER   27910
#define SOUND_ATTN_NONE   0.0f
#define SOUND_ATTN_NORM   1.0f
#define SOUND_ATTN_IDLE   1.2f
#define SOUND_ATTN_STATIC   3.0f
#define SOUND_ATTN_MAX   SOUND_ATTN_STATIC
#define ANGLE2SHORT(x)   ((int)((x)*65536/360) & 65535)
#define SHORT2ANGLE(x)   ((x)*(360.0/65536))
#define ERR_FATAL   0
#define ERR_DROP   1
#define ERR_QUIT   2
#define COLORED_GREEN   "\1"
#define DAYS_PER_YEAR   365
#define DAYS_PER_YEAR_AVG   365.25
#define MONTHS_PER_YEAR   12
#define SEASONS_PER_YEAR   4
#define SECONDS_PER_DAY   86400
#define SECONDS_PER_HOUR   3600
#define SECONDS_PER_MINUTE   60
#define MINUTES_PER_HOUR   60
#define MAXCMDLINE   256
#define MAX_CVARLISTINGAMETYPE   16
#define MAX_GAMETYPES   16
#define REMOVE_ELEM_MEMSET(array, index, n, val)
#define REMOVE_ELEM(array, index, n)
#define REMOVE_ELEM_ADJUST_IDX(array, index, n)
#define HASH_Add(hash, elem, index)

Typedefs

typedef int32_t svc_ops_t
typedef struct date_s date_t
 Engine-side time information in the game.
typedef struct cvarlist_s cvarlist_t
typedef struct gametype_s gametype_t
typedef void event_func (int now, void *data)
typedef qboolean event_check_func (int now, void *data)
typedef qboolean event_filter (int when, event_func *func, event_check_func *check, void *data)
typedef void event_clean_func (void *data)

Enumerations

enum  svc_ops_e {
  svc_bad, svc_nop, svc_disconnect, svc_reconnect,
  svc_sound, svc_print, svc_stufftext, svc_serverdata,
  svc_configstring, svc_event, svc_oob = 0xff
}
 

server to client the svc_strings[] array in cl_parse.c should mirror this

More...
enum  clc_ops_e {
  clc_bad, clc_nop, clc_endround, clc_teaminfo,
  clc_initactorstates, clc_action, clc_userinfo, clc_stringcmd,
  clc_oob = 0xff
}
 

client to server

More...

Functions

void Com_BeginRedirect (struct net_stream *stream, char *buffer, int buffersize)
 Redirect packets/output from server to client.
void Com_EndRedirect (void)
 End the redirection of packets/output.
void Com_MakeTimestamp (char *ts, const size_t tslen)
 Creates a timestamp with date and time at the specified location.
void Com_vPrintf (const char *fmt, va_list)
void Com_Drop (void) __attribute__((noreturn))
void Com_Quit (void)
void Com_WriteConfigToFile (const char *filename)
void Cvar_WriteVariables (qFILE *f)
 appends lines containing "set variable value" for all variables with the archive flag set to true.
int Com_ServerState (void)
 Check whether we are the server or have a singleplayer tactical mission.
void Com_SetServerState (int state)
char * Com_MD5File (const char *fn, int length)
 Compute the md5sum of a given file.
void Qcommon_Init (int argc, const char **argv)
 Init function.
void Qcommon_Frame (void)
 This is the function that is called directly from main().
void Qcommon_Shutdown (void)
void Com_SetGameType (void)
float Com_GrenadeTarget (const vec3_t from, const vec3_t at, float speed, qboolean launched, qboolean rolled, vec3_t v0)
 Calculates parabola-type shot.
void Con_Print (const char *txt)
 Handles cursor positioning, line wrapping, etc All console printing must go through this in order to be logged to disk If no console is visible, the text will appear at the top of the game window.
void Schedule_Event (int when, event_func *func, event_check_func *check, event_clean_func *clean, void *data)
 Schedules an event to run on or after the given time, and when its check function returns true.
void Schedule_Timer (cvar_t *interval, event_func *func, void *data)
void CL_FilterEventQueue (event_filter *filter)
 Filters every event in the queue using the given function. Keeps all events for which the function returns true.
void CL_Init (void)
void CL_Drop (void)
 Ensures the right menu cvars are set after error drop or map change.
void CL_Shutdown (void)
 Saves configuration file and shuts the client systems down.
int CL_Milliseconds (void)
void CL_Frame (int now, void *data)
void CL_SlowFrame (int now, void *data)
void CL_ParseClientData (const char *type, const char *name, const char **text)
 Called at client startup.
void SCR_BeginLoadingPlaque (void)
void SCR_EndLoadingPlaque (void)
void CL_InitAfter (void)
 Init function for clients - called after menu was initialized and ufo-scripts were parsed.
void SV_Init (void)
 Only called once at startup, not for each game.
void SV_Clear (void)
 Cleanup when the whole game process is shutting down.
void SV_Shutdown (const char *finalmsg, qboolean reconnect)
 Called when each game quits, before Sys_Quit or Sys_Error.
void SV_ShutdownWhenEmpty (void)
 Will eventually shutdown the server once all clients have disconnected.
void SV_Frame (int now, void *)
mapData_tSV_GetMapData (void)
mapTiles_tSV_GetMapTiles (void)
int Com_Argc (void)
 Returns the script commandline argument count.
const char * Com_Argv (int arg)
 Returns an argument of script commandline.
void Com_ClearArgv (int arg)
 Reset com_argv entry to empty string.
unsigned int Com_HashKey (const char *name, int hashsize)
 returns hash key for a string
const char * Com_MacroExpandString (const char *text)
 Expands strings with cvar values that are dereferenced by a '*cvar'.
void Com_Init (void)
void Com_InitArgv (int argc, const char **argv)
qboolean Com_ConsoleCompleteCommand (const char *s, char *target, size_t bufSize, int *pos, int offset)
 Console completion for command and variables.
void Key_Init (void)

Variables

cvar_thttp_proxy
cvar_thttp_timeout
cvar_tdeveloper
cvar_tsv_dedicated
cvar_tsv_maxclients
cvar_tsv_gametype
cvar_tmasterserver_url
cvar_tport
cvar_tsys_priority
cvar_tsys_affinity
cvar_tsys_os
gametype_t gts [MAX_GAMETYPES]
int numGTs
memPool_tcom_aliasSysPool
memPool_tcom_cmdSysPool
memPool_tcom_cmodelSysPool
memPool_tcom_cvarSysPool
memPool_tcom_fileSysPool
memPool_tcom_genericPool

Detailed Description

definitions common between client and server, but not game lib

Definition in file common.h.


Define Documentation

#define ANGLE2SHORT (  )     ((int)((x)*65536/360) & 65535)

Definition at line 186 of file common.h.

Referenced by NET_WriteAngle16().

#define BUILDSTRING   BUILDSTRING_OS " " BUILDSTRING_VARIANT

Definition at line 107 of file common.h.

Referenced by Qcommon_Init().

#define BUILDSTRING_OS   "Unknown"

Definition at line 75 of file common.h.

#define BUILDSTRING_VARIANT   "RELEASE"

Definition at line 101 of file common.h.

#define COLORED_GREEN   "\1"
#define CPUSTRING   "Unknown"

Definition at line 95 of file common.h.

Referenced by Qcommon_Init(), and SV_LoadGame().

#define DAYS_PER_YEAR   365
#define DAYS_PER_YEAR_AVG   365.25

Definition at line 239 of file common.h.

Referenced by MAP_IsNight().

#define ERR_DROP   1

Definition at line 190 of file common.h.

Referenced by _LE_NotFoundError(), AC_ResearchAlien_f(), AII_ReloadWeapon(), AIM_AddEmployeeFromMenu(), AIM_AutoEquipAircraft(), AIR_AircraftSelect(), AIR_AircraftStatusToName(), AIR_DestroyAircraft(), AIR_GetAircraft(), AIR_GetCapacityByAircraftWeight(), AIR_GetDestinationFindRoot(), AIR_ParseAircraft(), AIR_RemoveEmployees(), AL_AddAliens(), AL_ChangeAliveAlienNumber(), AL_FillInContainment(), B_AntimatterInBase(), B_AssembleMap(), B_BuildFromTemplate(), B_BuildingDestroy(), B_ManageAntimatter(), B_ParseBaseTemplate(), B_ParseBuildings(), B_RemoveAircraftExceedingCapacity(), B_SetBuildingByClick(), B_SetCurrentSelectedBase(), B_SetUpFirstBase(), B_UpdateBaseCapacities(), BaseSummary_Init(), BDEF_AutoTarget(), BDEF_ReloadBaseWeapons(), BS_BuyItem_f(), BS_BuyType(), BS_GetObjectDefition(), BS_SellItem_f(), CIN_ROQ_DecodeInfo(), CIN_ROQ_PlayCinematic(), CL_ActorAppear(), CL_ActorDie(), CL_ActorDoMove(), CL_ActorDoShoot(), CL_ActorDoTurn(), CL_ActorGetMuzzle(), CL_ActorPilotSelect_f(), CL_ActorRevitalised(), CL_ActorSearchAtGridPos(), CL_ActorSelect(), CL_ActorStartShoot(), CL_ActorTeamSelect_f(), CL_AddActor(), CL_AddBrushModel(), CL_AssignPilot_f(), CL_BuildForbiddenList(), CL_CleanupAircraftCrew(), CL_DoSwapSkills(), CL_ExecuteBattlescapeEvent(), CL_FinishHTTPDownload(), CL_GetComponentsByID(), CL_GetComponentsByItem(), CL_GetConfigString(), CL_GetConfigStringInteger(), CL_GetEvent(), CL_GetHitProbability(), CL_GetTeamSkinName(), CL_HullForEntity(), CL_InvAdd(), CL_InvDel(), CL_NetReceiveItem(), CL_ParseAlienTeam(), CL_ParseEvent(), CL_ParseMapParticle(), CL_ParsePtlCmds(), CL_ParseRanks(), CL_ParseResults(), CL_ParseServerData(), CL_ParseServerMessage(), CL_ParticleFunction(), CL_ParticleGetArt(), CL_ParticleLoadArt(), CL_ParticleSpawnTimed(), CL_ReadSinglePlayerData(), CL_SendCommand(), CL_SetConfigString(), CL_SetHTTPServer(), CL_SpawnParseEntitystring(), CL_UpdateActorAircraftVar(), CL_ViewLoadMedia(), CM_AddMapTile(), CM_EntCompleteBoxTrace(), CM_EntTestLine(), CM_EntTestLineDM(), CM_InitBoxHull(), CM_InlineModel(), CM_LoadMap(), CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadEntityString(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadNodes(), CMod_LoadPlanes(), CMod_LoadRouting(), CMod_LoadSubmodels(), CMod_LoadSurfaces(), Com_BeginRedirect(), Com_Error(), Com_GetCharacterValues(), CP_BaseAttackGoToBase(), CP_ChooseMap(), CP_MissionChooseUFO(), CP_ParseCharacterData(), CP_SetAlienEquipmentByInterest(), CP_SetAlienTeamByInterest(), CP_SpawnCrashSiteMission(), CP_SpawnRescueMission(), CP_StartMissionMap(), CP_ToDifficultyName(), CP_XVIInit(), E_CreateEmployeeAtIndex(), E_EmployeeIsUnassigned(), E_GetEmployeeString(), E_RemoveEmployeeFromBuildingOrAircraft(), GAME_AppendTeamMember(), GAME_CP_TeamIsKnown(), GAME_GenerateTeam(), GAME_GetCharacter(), GAME_MP_MapInfo(), GAME_NetSendCharacter(), Grid_SetMoveData(), HUD_ActorGetCvarData_f(), INS_FinishInstallation(), INS_SetCurrentSelectedInstallation(), INV_GetEquipmentDefinitionByID(), Key_Message(), LE_Add(), LE_DoEndPathMove(), LE_Lock(), LE_PlaceItem(), LE_Unlock(), LM_AddModel(), LM_AddToSceneOrder(), LMT_Init(), MAP_GetCivilianNumberByPosition(), MAP_GetColor(), MAP_GetMissionModel(), MAP_Init(), MAP_InitStartup(), MD2GLCmdsRemove(), MD2HeaderCheck(), ModelWorker(), NET_DatagramBroadcast(), NET_ReadDir(), NET_vReadFormat(), NET_vWriteFormat(), PR_DisassembleItem(), PR_ProductionInfo(), PR_UpdateRequiredItemsInBasestorage(), PrecalcNormalsAndTangents(), R_AddEntity(), R_AliasModelState(), R_CalcTransform(), R_CreateSurfaceLightmap(), R_DrawBspNormals(), R_DrawEntities(), R_DrawSurfaceStage(), R_GetFreeEntity(), R_LoadBspVertexArrays(), R_LoadImageData(), R_LoadObjModel(), R_LoadObjModelFace(), R_LoadObjModelLine(), R_ModAddMapTile(), R_ModBeginLoading(), R_ModLoadAliasDPMModel(), R_ModLoadAliasMD2Mesh(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), R_ModLoadEdges(), R_ModLoadLeafs(), R_ModLoadMDX(), R_ModLoadNodes(), R_ModLoadNormals(), R_ModLoadPlanes(), R_ModLoadSubmodels(), R_ModLoadSurfaces(), R_ModLoadSurfedges(), R_ModLoadTexinfo(), R_ModLoadVertexes(), R_PreprocessShader(), R_SetBlendMode(), R_SetupSubmodels(), RADAR_UpdateInstallationRadarCoverage(), RS_AssignScientist(), RS_AssignTechLinks(), RS_GetTechForItem(), RS_InitTree(), RS_ParseTechnologies(), RS_RemoveScientist(), SP_misc_model(), SV_AddMapTiles(), SV_AddTile(), SV_AssembleMap(), SV_Configstring(), SV_CreateWorldSector(), SV_error(), SV_FindIndex(), SV_GetCvarToken(), SV_GetServerDataForEdict(), SV_GetTileFromTileSet(), SV_InitGameProgs(), SV_LoadModelMinsMaxs(), SV_ParseAssembly(), SV_ParseMapTileSet(), SV_ParseUMP(), SV_SetModel(), tileMask(), TR_BoxTrace(), TR_BuildTracingNode_r(), TR_TransferAlienAfterMissionStart(), TR_TransferStart(), UFO_GetByType(), UFO_IsUFOSeenOnGeoscape(), UFO_TypeToName(), UI_BaseMapNodeClick(), UI_BaseMapNodeDraw(), UI_BaseMapNodeMiddleClick(), UI_BuildRadarImageList(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_NodeAbsoluteToRelativePos(), UI_TextNodeLoaded(), UP_Article(), UP_DisplayTechTree(), UP_GenerateSummary(), UP_SetMailHeader(), UP_TechTreeClick_f(), and US_RemoveUFOsExceedingCapacity().

#define ERR_FATAL   0

Definition at line 189 of file common.h.

Referenced by AIR_IsAircraftOnGeoscape(), CL_ParseSequence(), CL_SetClientState(), CL_SetRatioFilter_f(), CM_AddMapTile(), Com_InitArgv(), CP_SpawnAlienBaseMission(), Key_Event(), LoadModel(), ModelWorker(), NET_Init(), R_Draw3DGlobe(), R_DrawFlatGeoscape(), R_DrawInitLocal(), R_EnforceVersion(), R_FindImage(), R_FontAnalyze(), R_FontInit(), R_GetFont(), R_GetFreeFBOTexture(), R_GetSpriteVectors(), R_InitExtensions(), R_InitializeShader(), R_InitImages(), R_LoadImage(), R_ModForName(), R_ModLoadAnims(), R_ModLoadTags(), R_PreprocessShader(), R_SoftenTexture(), R_UploadData(), R_VerifyDriver(), Rimp_Init(), RS_InitTree(), SEQ_Execute2Dobj(), SEQ_ExecuteModel(), SV_GetConfigString(), SV_GetConfigStringInteger(), SV_GetGameAPI(), SV_HullForEntity(), SV_SetConfigString(), SZ_GetSpace(), UI_AllocNodeWithoutNew(), UI_AllocStaticAction(), UI_AllocStaticColor(), UI_AllocStaticFloat(), UI_AllocStaticIcon(), UI_AllocStaticKeyBinding(), UI_AllocStaticString(), UI_AllocTimer(), UI_DrawString(), UI_ExecuteAction(), UI_ExecuteSetAction(), UI_GetBooleanFromExpression(), UI_GetFloatFromExpression(), UI_GetNodeAbsPos(), UI_GetStringFromExpression(), UI_InitializeNodeBehaviour(), UI_InitNodes(), UI_InsertComponent(), UI_InsertWindow(), UI_NodeSetPropertyFromRAW(), UI_ParseComponent(), UI_ParseValueExpression(), UI_ParseWindow(), UI_PoolAllocAction(), UI_PopupButton(), UI_PopupList(), UI_RegisterFont(), UI_ReleaseVariable(), UI_SetKeyBinding(), and UI_SetOneButton().

#define ERR_QUIT   2

Definition at line 191 of file common.h.

#define GAME_TITLE   "UFO:AI"

Definition at line 41 of file common.h.

Referenced by R_InitExtensions(), and Rimp_Init().

#define GAME_TITLE_LONG   "UFO:Alien Invasion"

Definition at line 42 of file common.h.

Referenced by Rimp_Init().

#define HASH_Add ( hash,
elem,
index   ) 
Value:
do { \
    elem->hash_next = hash[index]; \
    hash[index] = elem; \
} while (0)

Definition at line 373 of file common.h.

Referenced by Cmd_AddCommand(), and Cvar_Get().

#define MASTER_SERVER   "http://ufoai.ninex.info/"

Definition at line 110 of file common.h.

Referenced by CL_InitLocal(), and Qcommon_Init().

#define MAX_CVARLISTINGAMETYPE   16

Definition at line 250 of file common.h.

Referenced by Com_ParseGameTypes().

#define MAX_GAMETYPES   16

game types

Definition at line 264 of file common.h.

Referenced by Com_ParseGameTypes().

#define MAXCMDLINE   256
#define MINUTES_PER_HOUR   60

(60)

Definition at line 246 of file common.h.

Referenced by PR_DisassemblingFrame(), and PR_ProductionFrame().

#define MONTHS_PER_YEAR   12

DAYS_PER_MONTH ->

See also:
monthLength[] array in campaign.c

Definition at line 241 of file common.h.

Referenced by CL_DateConvert(), CL_NationDrawStats(), CL_NationsMaxFunding(), CP_NationBackupMonthlyData(), NAT_LoadXML(), and NAT_SaveXML().

#define PORT_CLIENT   27901

Definition at line 122 of file common.h.

Referenced by CL_PingServers_f().

#define PORT_SERVER   27910
#define PROTOCOL_VERSION   6
#define REMOVE_ELEM ( array,
index,
 ) 
Value:
do {                                                                               \
    size_t idx__ = (index);                                                          \
    size_t n__   = --(n);                                                            \
    assert(idx__ <= n__);                                                            \
    memmove((array) + idx__, (array) + idx__ + 1, (n__ - idx__) * sizeof(*(array))); \
    memset((array) + n__, 0, sizeof(*(array)));                                      \
} while (0)

Remove element at index from array of size n. n gets adjusted to the new array size, so must be an lvalue

Definition at line 351 of file common.h.

Referenced by B_BuildingDestroy(), B_RemoveItemsExceedingCapacity(), BDEF_RemoveBattery(), NAT_ScriptSanityCheck(), RADAR_RemoveUFO(), and TR_TransferCheck().

#define REMOVE_ELEM_ADJUST_IDX ( array,
index,
 ) 
Value:
do {                                            \
    size_t idx__ = (index);                       \
    size_t n__;                                   \
    size_t i__;                                   \
    REMOVE_ELEM(array, index, n);                 \
    n__ = (n);                                    \
    for (i__ = idx__; i__ < n__; ++i__)           \
        --(array)[i__].idx;                         \
} while (0)

Same as REMOVE_ELEM() and also updates the idx attribute of every moved element

Definition at line 362 of file common.h.

Referenced by AIRFIGHT_RemoveProjectile(), INS_DestroyInstallation(), PR_QueueDelete(), and UFO_RemoveFromGeoscape().

#define REMOVE_ELEM_MEMSET ( array,
index,
n,
val   ) 
Value:
do {                                                                               \
    size_t idx__ = (index);                                                          \
    size_t n__   = --(n);                                                            \
    assert(idx__ <= n__);                                                            \
    memmove((array) + idx__, (array) + idx__ + 1, (n__ - idx__) * sizeof(*(array))); \
    memset((array) + n__, val, sizeof(*(array)));                                      \
} while (0)

Remove element at index from array of size n. n gets adjusted to the new array size, so must be an lvalue - the old array slot is set to the value given via val

Definition at line 340 of file common.h.

Referenced by TR_NotifyAircraftRemoved().

#define SEASONS_PER_YEAR   4

Definition at line 242 of file common.h.

Referenced by R_Draw3DGlobe().

#define SECONDS_PER_DAY   86400
#define SECONDS_PER_HOUR   3600
#define SECONDS_PER_MINUTE   60

(60)

Definition at line 245 of file common.h.

Referenced by CL_CampaignRun().

#define SHORT2ANGLE (  )     ((x)*(360.0/65536))

Definition at line 187 of file common.h.

Referenced by NET_ReadAngle16().

#define SOUND_ATTN_IDLE   1.2f
#define SOUND_ATTN_MAX   SOUND_ATTN_STATIC

Definition at line 168 of file common.h.

Referenced by Com_ParseFire().

#define SOUND_ATTN_NONE   0.0f

full volume the entire level

Definition at line 164 of file common.h.

Referenced by Com_ParseFire().

#define SOUND_ATTN_NORM   1.0f

Definition at line 165 of file common.h.

Referenced by CL_ParseStartSoundPacket(), Com_ParseItem(), and S_StartLocalSample().

#define SOUND_ATTN_STATIC   3.0f

dimish very rapidly with distance

Definition at line 167 of file common.h.

Referenced by LE_PlaySoundFileAndParticleForSurface().

#define UFO_VERSION   "2.4-dev"

Typedef Documentation

typedef struct cvarlist_s cvarlist_t
typedef struct date_s date_t

Engine-side time information in the game.

Note:
Use this in your custom structs that need to get saved or sent over the network.
See also:
dateLong_t For runtime use (human readable).
CL_DateConvertLong
typedef qboolean event_check_func(int now, void *data)

Definition at line 280 of file common.h.

typedef void event_clean_func(void *data)

Definition at line 282 of file common.h.

typedef qboolean event_filter(int when, event_func *func, event_check_func *check, void *data)

Definition at line 281 of file common.h.

typedef void event_func(int now, void *data)

Definition at line 279 of file common.h.

typedef struct gametype_s gametype_t
typedef int32_t svc_ops_t

Definition at line 145 of file common.h.


Enumeration Type Documentation

enum clc_ops_e

client to server

Enumerator:
clc_bad 
clc_nop 
clc_endround 
clc_teaminfo 
clc_initactorstates 
clc_action 
clc_userinfo 

[[userinfo string]

clc_stringcmd 

[string] message

clc_oob 

out of band - connectionless

Definition at line 152 of file common.h.

enum svc_ops_e

server to client the svc_strings[] array in cl_parse.c should mirror this

Enumerator:
svc_bad 
svc_nop 

the rest are private to the client and server

svc_disconnect 
svc_reconnect 
svc_sound 
svc_print 

[byte] id [string] null terminated string

svc_stufftext 

[string] stuffed into client's console buffer, should be
terminated

svc_serverdata 

[long] protocol, spawncount, playernum, mapname, ...

svc_configstring 

[short] [string]

svc_event 

event like move or inventory usage - see EV_* and

See also:
CL_ParseEvent
svc_oob 

Definition at line 129 of file common.h.


Function Documentation

void CL_Drop ( void   ) 

Ensures the right menu cvars are set after error drop or map change.

Note:
E.g. called after an ERR_DROP was thrown
See also:
CL_Disconnect
SV_Map

Definition at line 172 of file cl_main.c.

References CL_Disconnect(), GAME_Drop(), and SCR_EndLoadingPlaque().

Referenced by CL_Disconnect_f(), CL_ParseServerMessage(), Com_Error(), GAME_HandleResults(), GAME_MP_Results(), and GAME_SK_Results().

void CL_FilterEventQueue ( event_filter filter  ) 

Filters every event in the queue using the given function. Keeps all events for which the function returns true.

Parameters:
filter Pointer to the filter function. When called with event info, it should return true if the event is to be kept.

Definition at line 1291 of file common.c.

References event::clean, event::data, Mem_Free, and event::next.

Referenced by CL_ClearBattlescapeEvents().

void CL_Frame ( int  now,
void *  data 
)
void CL_Init ( void   ) 
void CL_InitAfter ( void   ) 

Init function for clients - called after menu was initialized and ufo-scripts were parsed.

See also:
Qcommon_Init

Definition at line 901 of file cl_main.c.

References CL_LanguageInit(), CL_TeamDefInitMenu(), CL_VideoInitMenu(), CL_ViewPrecacheModels(), Com_MapDefSort(), IN_JoystickInitMenu(), cvar_s::integer, client_static_s::mds, client_static_s::numMDs, S_Frame(), S_LoadSamples(), and sv_dedicated.

Referenced by Qcommon_Init().

int CL_Milliseconds ( void   ) 
void CL_ParseClientData ( const char *  type,
const char *  name,
const char **  text 
)

Called at client startup.

Note:
not called for dedicated servers parses all *.ufos that are needed for single- and multiplayer
See also:
Com_ParseScripts
CL_ParseScriptSecond
CL_ParseScriptFirst
Note:
Nothing here should depends on items, equipments, actors and all other entities that are parsed in Com_ParseScripts (because maybe items are not parsed but e.g. techs would need those parsed items - thus we have to parse e.g. techs at a later stage)
This data is persistent until you shutdown the game

Definition at line 936 of file cl_main.c.

References CL_ParseCustomSkin(), CL_ParseLanguages(), CL_ParseMapDefinition(), CL_ParseParticle(), CL_ParseSequence(), CL_ParseTipsOfTheDay(), M_ParseMusic(), TUT_ParseTutorials(), UI_ParseComponent(), UI_ParseFont(), UI_ParseIcon(), UI_ParseUIModel(), and UI_ParseWindow().

Referenced by Com_ParseScripts().

void CL_Shutdown ( void   ) 

Saves configuration file and shuts the client systems down.

Todo:
this is a callback from Sys_Quit and Com_Error. It would be better to run quit through here before the final handoff to the sys code.
See also:
Sys_Quit
CL_Init

Definition at line 1347 of file cl_main.c.

References CIN_Shutdown(), CL_HTTP_Cleanup(), Con_SaveConsoleHistory(), GAME_NONE, GAME_SetMode(), Irc_Shutdown(), Key_WriteBindings(), qfalse, qtrue, R_Shutdown(), S_Shutdown(), and UI_Shutdown().

Referenced by Com_Error(), Com_Quit(), and Sys_Quit().

void CL_SlowFrame ( int  now,
void *  data 
)
See also:
CL_Frame

Definition at line 1263 of file cl_main.c.

References CL_LanguageTryToSet(), HUD_Update(), Irc_Logic_Frame(), cvar_s::modified, s_language, and cvar_s::string.

Referenced by Qcommon_Init().

int Com_Argc ( void   ) 

Returns the script commandline argument count.

Definition at line 547 of file common.c.

References com_argc.

Referenced by Cbuf_AddEarlyCommands(), and Cbuf_AddLateCommands().

const char* Com_Argv ( int  arg  ) 

Returns an argument of script commandline.

Definition at line 555 of file common.c.

References com_argc, and com_argv.

Referenced by Cbuf_AddEarlyCommands(), and Cbuf_AddLateCommands().

void Com_BeginRedirect ( struct net_stream stream,
char *  buffer,
int  buffersize 
)

Redirect packets/output from server to client.

See also:
Com_EndRedirect

This is used to redirect printf outputs for rcon commands

Definition at line 301 of file common.c.

References Com_Error(), ERR_DROP, MAXPRINTMSG, rd_buffer, and rd_buffersize.

Referenced by SVC_RemoteCommand().

void Com_ClearArgv ( int  arg  ) 

Reset com_argv entry to empty string.

Parameters:
[in] arg Which argument in com_argv
See also:
Com_InitArgv

Definition at line 567 of file common.c.

References com_argc, and com_argv.

Referenced by Cbuf_AddEarlyCommands().

qboolean Com_ConsoleCompleteCommand ( const char *  s,
char *  target,
size_t  bufSize,
int *  pos,
int  offset 
)

Console completion for command and variables.

See also:
Key_CompleteCommand
Cmd_CompleteCommand
Cvar_CompleteVariable
Parameters:
[in] s The string to complete
[out] target The target buffer of the completed command/cvar
[in] bufSize the target buffer size - might not be bigger than MAXCMDLINE
[out] pos The position in the buffer after command completion
[in] offset The input buffer position to put the completed command to

Definition at line 689 of file common.c.

References Cmd_CompleteCommand(), Cmd_CompleteCommandParameters(), Com_Printf(), Cvar_CompleteVariable(), MAX_QPATH, MAXCMDLINE, Q_strcat(), Q_strncpyz(), qfalse, and qtrue.

Referenced by Key_Console(), Sys_ConsoleEditProc(), and Sys_ConsoleInput().

void Com_Drop ( void   ) 

Definition at line 476 of file common.c.

References abortframe.

Referenced by Com_Error(), and CP_EndCampaign().

void Com_EndRedirect ( void   ) 

End the redirection of packets/output.

See also:
Com_BeginRedirect

Definition at line 318 of file common.c.

References NET_OOB_Printf(), rd_buffer, and rd_buffersize.

Referenced by SVC_RemoteCommand().

float Com_GrenadeTarget ( const vec3_t  from,
const vec3_t  at,
float  speed,
qboolean  launched,
qboolean  rolled,
vec3_t  v0 
)

Calculates parabola-type shot.

Note:
Grenade Aiming Maths --------------------------------------------------------------

There are two possibilities when aiming: either we can reach the target at maximum speed or we can't. If we can reach it we would like to reach it with as flat a trajectory as possible. To do this we calculate the angle to hit the target with the projectile traveling at the maximum allowed velocity.

However, if we can't reach it then we'd like the aiming curve to use the smallest possible velocity that would have reached the target.

let d = horizontal distance to target h = vertical distance to target g = gravity v = launch velocity vx = horizontal component of launch velocity vy = vertical component of launch velocity alpha = launch angle t = time

Then using the laws of linear motion and some trig

d = vx * t h = vy * t - 1/2 * g * t^2 vx = v * cos(alpha) vy = v * sin(alpha)

and some trig identities

2*cos^2(x) = 1 + cos(2*x) 2*sin(x)*cos(x) = sin(2*x) a*cos(x) + b*sin(x) = sqrt(a^2 + b^2) * cos(x - atan2(b,a))

it is possible to show that:

alpha = 0.5 * (atan2(d, -h) - theta)

where / 2 2 \ | v h + g d | | -------------- | theta = acos | ________ | | 2 / 2 2 | \ v \/ h + d /

Thus we can calculate the desired aiming angle for any given velocity.

With some more rearrangement we can show:

________________________ / 2 / g d v = / ------------------------ / ________ / / 2 2 \/ \/ h + d cos(theta) - h

Which we can also write as: _________________ / a f(theta) = / ---------------- \/ b cos(theta) - c

where a = g*d^2 b = sqrt(h*h+d*d) c = h

We can imagine a graph of launch velocity versus launch angle. When the angle is near 0 degrees (i.e. totally flat) more and more velocity is needed. Similarly as the angle gets closer and closer to 90 degrees.

Somewhere in the middle is the minimum velocity that we could possibly hit the target with and the 'optimum' angle to fire at. Note that when h = 0 the optimum angle is 45 degrees. We want to find the minimum velocity so we need to take the derivative of f (which I suggest doing with an algebra system!).

f'(theta) = a * b * sin(theta) / junk

the `junk` is unimportant because we're just going to set f'(theta) = 0 and multiply it out anyway.

0 = a * b * sin(theta)

Neither a nor b can be 0 as long as d does not equal 0 (which is a degenerate case). Thus if we solve for theta we get 'sin(theta) = 0', thus 'theta = 0'. If we recall that:

alpha = 0.5 * (atan2(d, -h) - theta)

then we get our 'optimum' firing angle alpha as

alpha = 1/2 * atan2(d, -h)

and if we substitute back into our equation for v and we get

_______________ / 2 / g d vmin = / --------------- / ________ / / 2 2 \/ \/ h + d - h

as the minimum launch velocity for that angle.

Parameters:
[in] from Starting position for calculations.
[in] at Ending position for calculations.
[in] speed Launch velocity.
[in] launched Set to true for grenade launchers.
[in] rolled Set to true for "roll" type shoot.
[in,out] v0 The velocity vector
Todo:

refactor and move me

Com_GrenadeTarget() is called from CL_TargetingGrenade() with speed param as (fireDef_s) fd->range (gi.GrenadeTarget, too), while it is being used here for speed calculations - a bug or just misleading documentation?

See also:
CL_TargetingGrenade

Definition at line 222 of file common.c.

References DIST_EPSILON, GRAVITY, len, torad, VectorLength(), VectorNormalize(), VectorScale, and VectorSubtract.

Referenced by CL_TargetingGrenade(), and SV_InitGameProgs().

unsigned int Com_HashKey ( const char *  name,
int  hashsize 
)
void Com_Init ( void   ) 
void Com_InitArgv ( int  argc,
const char **  argv 
)

Definition at line 575 of file common.c.

References com_argc, com_argv, Com_Error(), ERR_FATAL, i, MAX_NUM_ARGVS, and MAX_TOKEN_CHARS.

Referenced by Qcommon_Init().

const char* Com_MacroExpandString ( const char *  text  ) 

Expands strings with cvar values that are dereferenced by a '*cvar'.

Note:
There is an overflow check for cvars that also contain a '*cvar'
See also:
Cmd_TokenizeString
UI_GetReferenceString

Definition at line 597 of file common.c.

References Com_Parse(), Com_Printf(), count, Cvar_GetString(), i, len, MACRO_CVAR_ID_LENGTH, MAX_STRING_CHARS, pos, Q_strncpyz(), and qfalse.

Referenced by Cmd_TokenizeString(), and UI_GetReferenceString().

void Com_MakeTimestamp ( char *  ts,
const size_t  tslen 
)

Creates a timestamp with date and time at the specified location.

Parameters:
ts ptr to the resulting string
tslen length of target buffer

Definition at line 332 of file common.c.

References Com_sprintf().

Referenced by CL_LogEvent(), Com_vPrintf(), and SAV_GameSave().

char* Com_MD5File ( const char *  fn,
int  length 
)

Compute the md5sum of a given file.

Parameters:
[in] fn Filename to compute the md5 of
[in] length Compute the md5 of the first 'length' bytes (if 0 - complete file)
Returns:
the md5 sum buffer (char*)

Definition at line 268 of file md5.c.

References f, FILE_READ, FS_CloseFile(), FS_OpenFile(), FS_Read(), i, MD5Final(), MD5Init(), MD5Update(), Q_strcat(), and va().

void Com_Quit ( void   ) 

Both client and server can use this, and it will do the appropriate things.

Definition at line 485 of file common.c.

References CL_Shutdown(), Com_WriteConfigToFile(), FS_CloseFile(), NET_Wait(), qfalse, SV_Clear(), SV_Shutdown(), and Sys_Quit().

Referenced by CL_Quit_f(), and Qcommon_Init().

int Com_ServerState ( void   ) 
void Com_SetGameType ( void   ) 
void Com_SetServerState ( int  state  ) 
See also:
SV_SpawnServer
Com_ServerState

Definition at line 517 of file common.c.

References Com_DPrintf(), DEBUG_ENGINE, qfalse, qtrue, ss_dead, ss_restart, serverInstanceGame_t::state, sv, and SV_Shutdown().

Referenced by SV_Map(), and SV_ShutdownWhenEmpty().

void Com_vPrintf ( const char *  fmt,
va_list  ap 
)
Note:
Both client and server can use this, and it will output to the appropriate place.

Definition at line 348 of file common.c.

References COLORED_GREEN, Com_MakeTimestamp(), Con_Print(), qFILE_s::f, FILE_APPEND, FILE_WRITE, FS_OpenFile(), FS_Write(), cvar_s::integer, MAXPRINTMSG, name, NET_OOB_Printf(), Q_strcat(), Q_vsnprintf(), rd_buffer, rd_buffersize, and Sys_ConsoleOutput().

Referenced by Com_DPrintf(), Com_Printf(), and SV_dprintf().

void Com_WriteConfigToFile ( const char *  filename  ) 
void Con_Print ( const char *  txt  ) 

Handles cursor positioning, line wrapping, etc All console printing must go through this in order to be logged to disk If no console is visible, the text will appear at the top of the game window.

See also:
Sys_ConsoleOutput

Definition at line 306 of file cl_console.c.

References CL_Milliseconds(), Con_Linefeed(), CONSOLE_COLORED_TEXT_MASK, console_t::currentLine, console_t::initialized, console_t::lineWidth, NUM_CON_TIMES, console_t::pos, qfalse, console_t::text, console_t::times, and console_t::totalLines.

Referenced by Com_vPrintf().

void Cvar_WriteVariables ( qFILE f  ) 

appends lines containing "set variable value" for all variables with the archive flag set to true.

Note:
Stores the archive cvars

Definition at line 855 of file cvar.c.

References CVAR_ARCHIVE, cvar_s::flags, FS_Printf(), cvar_s::name, cvar_s::next, and cvar_s::string.

Referenced by Com_WriteConfigToFile().

void Key_Init ( void   ) 
void Qcommon_Frame ( void   ) 

This is the function that is called directly from main().

See also:
main
Qcommon_Init
Qcommon_Shutdown
SV_Frame
CL_Frame

Definition at line 1328 of file common.c.

References abortframe, event::data, Dequeue_Event(), Mem_Free, NET_Wait(), Sys_Milliseconds(), and event::when.

Referenced by main(), and WinMain().

void Qcommon_Init ( int  argc,
const char **  argv 
)
void Qcommon_Shutdown ( void   ) 
See also:
Qcommon_Init
Sys_Quit
Note:
Don't call anything that depends on cvars, command system, or any other subsystem that is allocated in the mem pools and maybe already freed

Definition at line 1373 of file common.c.

References Cmd_Shutdown(), Cvar_Shutdown(), FS_Shutdown(), HTTP_Cleanup(), and Mem_Shutdown().

Referenced by Com_Error(), and Sys_Quit().

void Schedule_Event ( int  when,
event_func func,
event_check_func check,
event_clean_func clean,
void *  data 
)

Schedules an event to run on or after the given time, and when its check function returns true.

Parameters:
when The earliest time the event can run
func The function to call when running the event
check A function that should return true when the event is safe to run. It should have no side-effects, as it might be called many times.
clean A function that should cleanup any memory allocated for the event in the case that it is not executed. Either this function or func will be called, but never both.
data Arbitrary data to be passed to the check and event functions.

Definition at line 1233 of file common.c.

References Mem_PoolAlloc, event::next, and event::when.

Referenced by CL_ParseEvent(), Schedule_Timer(), and tick_timer().

void Schedule_Timer ( cvar_t interval,
event_func func,
void *  data 
)
void SCR_BeginLoadingPlaque ( void   ) 
void SCR_EndLoadingPlaque ( void   ) 
void SV_Clear ( void   ) 

Cleanup when the whole game process is shutting down.

See also:
SV_Shutdown
Com_Quit

Definition at line 781 of file sv_main.c.

References SV_MapcycleClear().

Referenced by Com_Quit().

void SV_Frame ( int  now,
void *  data 
)
mapData_t* SV_GetMapData ( void   ) 

Definition at line 697 of file sv_main.c.

References serverInstanceGame_t::mapData, and sv.

Referenced by CL_RequestNextDownload().

mapTiles_t* SV_GetMapTiles ( void   ) 

Definition at line 702 of file sv_main.c.

References serverInstanceGame_t::mapTiles, and sv.

Referenced by CL_RequestNextDownload().

void SV_Init ( void   ) 
void SV_Shutdown ( const char *  finalmsg,
qboolean  reconnect 
)

Called when each game quits, before Sys_Quit or Sys_Error.

Parameters:
[in] finalmsg The message all clients get as server shutdown message
[in] reconnect True if this is only a restart (new map or map restart), false if the server shutdown completely and you also want to disconnect all clients

Definition at line 792 of file sv_main.c.

References serverInstanceStatic_t::clients, Com_Printf(), CVAR_LATCH, CVAR_NOSET, cvar_s::flags, i, serverInstanceStatic_t::initialized, Master_Shutdown(), Mem_Free, sv_model_s::name, NET_DatagramSocketClose(), serverInstanceStatic_t::netDatagramSocket, serverInstanceGame_t::numSVModels, serverInstanceStatic_t::serverMutex, sv, SV_FinalMessage(), SV_ShutdownGameProgs(), SV_Stop(), serverInstanceGame_t::svModels, and svs.

Referenced by CL_Connect_f(), CL_SequenceStart_f(), Com_Error(), Com_Quit(), Com_SetServerState(), CP_StartSelectedMission(), GAME_CP_Drop(), GAME_CP_Results(), GAME_CP_Shutdown(), GAME_Drop(), GAME_MP_Shutdown(), GAME_SK_Shutdown(), SV_Frame(), and SV_KillServer_f().

void SV_ShutdownWhenEmpty ( void   ) 

Will eventually shutdown the server once all clients have disconnected.

See also:
SV_CountPlayers

Definition at line 840 of file sv_main.c.

References serverInstanceStatic_t::abandon, Com_SetServerState(), qtrue, ss_dead, and svs.

Referenced by CL_Disconnect_f().


Variable Documentation

Definition at line 60 of file common.c.

Referenced by Cmd_Alias_f(), Com_RegisterConstInt(), and TEST_Init().

Definition at line 61 of file common.c.

Referenced by Cmd_AddCommand(), Cmd_TokenizeString(), and TEST_Init().

Definition at line 64 of file common.c.

Definition at line 65 of file common.c.

Definition at line 42 of file common.c.

Referenced by Con_DrawNotify(), and MS_LoadXML().

gametype_t gts[MAX_GAMETYPES]

Definition at line 2877 of file scripts.c.

Referenced by Com_GameTypeList_f(), Com_SetGameType(), and GAME_MP_ChangeGametype_f().

Definition at line 43 of file common.c.

Referenced by CL_StartHTTPDownload(), and HTTP_GetURL().

Definition at line 44 of file common.c.

Referenced by HTTP_GetURL().

int numGTs

Definition at line 2878 of file scripts.c.

Referenced by Com_GameTypeList_f(), Com_SetGameType(), and GAME_MP_ChangeGametype_f().

Definition at line 46 of file common.c.

Definition at line 55 of file common.c.

Referenced by CL_Frame(), Sys_Init(), and Sys_SetAffinityAndPriority().

Definition at line 56 of file common.c.

Referenced by Sys_Init().

Definition at line 54 of file common.c.

Referenced by CL_Frame(), Sys_Init(), and Sys_SetAffinityAndPriority().


Generated by  doxygen 1.6.2