common.c File Reference

Misc functions used in client and server. More...

#include "common.h"
#include "../server/server.h"
#include "../shared/parse.h"
#include "../ports/system.h"
#include <setjmp.h>
Include dependency graph for common.c:

Go to the source code of this file.

Data Structures

struct  event
struct  timer
struct  debugLevel_s

Defines

#define MAXPRINTMSG   4096
#define MAX_NUM_ARGVS   50
#define TIMER_CHECK_INTERVAL   100
#define TIMER_CHECK_LAG   3
#define TIMER_LATENESS_HIGH   200
#define TIMER_LATENESS_LOW   50
#define TIMER_LATENESS_HISTORY   32
#define MACRO_CVAR_ID_LENGTH   6

Typedefs

typedef struct debugLevel_s debugLevel_t

Functions

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 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 ap)
void Com_Printf (const char *const fmt,...)
void Com_DPrintf (int level, const char *fmt,...)
 A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error (int code, const char *fmt,...)
void Com_Drop (void)
void Com_Quit (void)
int Com_ServerState (void)
 Check whether we are the server or have a singleplayer tactical mission.
void Com_SetServerState (int state)
unsigned int Com_HashKey (const char *name, int hashsize)
 returns hash key for a string
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.
void Com_InitArgv (int argc, const char **argv)
const char * Com_MacroExpandString (const char *text)
 Expands strings with cvar values that are dereferenced by a '*cvar'.
qboolean Com_ConsoleCompleteCommand (const char *s, char *target, size_t bufSize, int *pos, int offset)
 Console completion for command and variables.
void Com_SetGameType (void)
static void Com_GameTypeList_f (void)
static void Com_DeveloperSet_f (void)
static qboolean Com_CvarCheckMaxFPS (cvar_t *cvar)
 Watches that the cvar cl_maxfps is never getting lower than 10.
void Com_WriteConfigToFile (const char *filename)
static void Com_WriteConfig_f (void)
 Write the config file to a specific name.
static void Cbuf_Execute_timer (int now, void *data)
void Qcommon_Init (int argc, const char **argv)
 Init function.
static void tick_timer (int now, void *data)
void Schedule_Timer (cvar_t *freq, event_func *func, void *data)
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.
static struct eventDequeue_Event (int now)
 Finds and returns the first event in the event_queue that is due. If the event has a check function, we check to see if the event can be run now, and skip it if not (even if it is due).
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 Qcommon_Frame (void)
 This is the function that is called directly from main().
void Qcommon_Shutdown (void)

Variables

csi_t csi
static int com_argc
static const char * com_argv [MAX_NUM_ARGVS+1]
static jmp_buf abortframe
cvar_tdeveloper
cvar_thttp_proxy
cvar_thttp_timeout
static cvar_tlogfile_active
cvar_tsv_dedicated
static cvar_tcl_maxfps
cvar_ts_language
cvar_tsv_gametype
cvar_tmasterserver_url
cvar_tport
cvar_tsys_priority
cvar_tsys_affinity
cvar_tsys_os
static qFILE logfile
struct memPool_scom_aliasSysPool
struct memPool_scom_cmdSysPool
struct memPool_scom_cmodelSysPool
struct memPool_scom_cvarSysPool
struct memPool_scom_fileSysPool
struct memPool_scom_genericPool
struct memPool_scom_networkPool
static struct eventevent_queue = NULL
static char * rd_buffer
static unsigned int rd_buffersize
static struct net_streamrd_stream
static const debugLevel_t debugLevels []

Detailed Description

Misc functions used in client and server.

Definition in file common.c.


Define Documentation

#define MACRO_CVAR_ID_LENGTH   6

Definition at line 590 of file common.c.

Referenced by Com_MacroExpandString().

#define MAX_NUM_ARGVS   50

Definition at line 33 of file common.c.

Referenced by Com_InitArgv(), and ParseCommandLine().

#define MAXPRINTMSG   4096

Definition at line 32 of file common.c.

Referenced by Com_BeginRedirect(), Com_Error(), and Com_vPrintf().

#define TIMER_CHECK_INTERVAL   100

Definition at line 79 of file common.c.

Referenced by Schedule_Timer(), and tick_timer().

#define TIMER_CHECK_LAG   3

Definition at line 80 of file common.c.

Referenced by tick_timer().

#define TIMER_LATENESS_HIGH   200

Definition at line 81 of file common.c.

Referenced by tick_timer().

#define TIMER_LATENESS_HISTORY   32

Definition at line 83 of file common.c.

Referenced by Schedule_Timer(), and tick_timer().

#define TIMER_LATENESS_LOW   50

Definition at line 82 of file common.c.

Referenced by tick_timer().


Typedef Documentation

typedef struct debugLevel_s debugLevel_t

Function Documentation

static void Cbuf_Execute_timer ( int  now,
void *  data 
) [static]

Definition at line 976 of file common.c.

References Cbuf_Execute().

Referenced by Qcommon_Init().

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

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

static qboolean Com_CvarCheckMaxFPS ( cvar_t cvar  )  [static]

Watches that the cvar cl_maxfps is never getting lower than 10.

Definition at line 929 of file common.c.

References Cvar_AssertValue(), and qtrue.

Referenced by Qcommon_Init().

static void Com_DeveloperSet_f ( void   )  [static]

Definition at line 885 of file common.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), Cvar_GetInteger(), Cvar_SetValue(), debugLevel_s::debugLevel, and i.

Referenced by Qcommon_Init().

void Com_DPrintf ( int  level,
const char *  fmt,
  ... 
)

A Com_Printf that only shows up if the "developer" cvar is set.

Definition at line 412 of file common.c.

References Com_vPrintf(), and cvar_s::integer.

Referenced by AC_AlienClick(), AC_AlienClick_f(), AC_KillOne_f(), AI_PrepBestAction(), AII_CollectingItems(), AII_CollectItem(), AIM_AddEmployeeFromMenu(), AIM_AircraftStart_f(), AIR_AddToAircraftTeam(), AIR_AircraftGetFromIDX(), AIR_AircraftReturnToBase(), AIR_GetDestinationFindRoot(), AIR_GetDestinationWhilePursuing(), AIR_IsInAircraftTeam(), AIR_Move(), AIR_MoveAircraftIntoNewHomebase(), AIR_MoveEmployeeInventoryIntoStorage(), AIR_NewAircraft(), AIR_ParseAircraft(), AIR_RemoveEmployee(), AIR_RemoveFromAircraftTeam(), AIR_SendAircraftPursuingUFO(), AIR_UpdateHangarCapForAll(), AIRFIGHT_ActionsAfterAirfight(), AIRFIGHT_AddProjectile(), AIRFIGHT_ProbabilityToHit(), AL_AddAliens(), AL_FillInContainment(), B_AddBuildingToBasePos(), B_AssembleMap_f(), B_BuildingClick_f(), B_BuildingDestroy(), B_CheckBuildingConstruction(), B_CheckUpdateBuilding(), B_ConstructBuilding(), B_NewBuilding(), B_PackInitialEquipment(), B_ParseBuildings(), B_RemoveItemsExceedingCapacity(), B_ResetAllStatusAndCapacities(), B_SelectBase(), B_SetBuildingByClick(), B_SetBuildingStatus(), B_SetUpFirstBase(), B_UpdateBaseCapacities(), B_UpdateStorageAndCapacity(), BS_Autosell_f(), BS_BuyItem_f(), BS_SellAircraft_f(), BS_SellItem_f(), Cbuf_AddText(), CL_ActorDoorAction(), CL_ActorDoorAction_f(), CL_ActorDoShoot(), CL_ActorGetChr(), CL_ActorPlaySound(), CL_ActorReservedTUs(), CL_ActorResetClientAction(), CL_ActorTraceMove(), CL_ActorUseDoor(), CL_AddEdict(), CL_AddMapParticle(), CL_CheckDefault(), CL_CleanupAircraftCrew(), CL_ConnectionlessPacket(), CL_DisplayPopupInterceptUFO(), CL_DoorClose(), CL_DoorOpen(), CL_EntAppear(), CL_EntPerish(), CL_ExecuteBattlescapeEvent(), CL_GameAutoGo(), CL_GetComponentsByItem(), CL_GetEventTime(), CL_GetLocaleID(), CL_HandleNationData(), CL_Init(), CL_InvAmmo(), CL_LanguageInit(), CL_LanguageTest(), CL_LanguageTryToSet(), CL_NetSendItem(), CL_ParseCampaignEvents(), CL_ParseCities(), CL_ParseComponents(), CL_ParseConfigString(), CL_ParseEvent(), CL_ParseEventMails(), CL_ParseNations(), CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), CL_ParseResults(), CL_ParseServerData(), CL_ParseServerInfoMessage(), CL_ParseServerMessage(), CL_ParseTeamInfoMessage(), CL_ParticleSpawn(), CL_PingServer(), CL_PingServers_f(), CL_PopupAircraftClick_f(), CL_PopupChangeHomebase_f(), CL_ProcessPingReply(), CL_QueryMasterServerThread(), CL_ReadSinglePlayerData(), CL_SetClientState(), CL_TeamNum_f(), CL_UpdateActorAircraftVar(), CL_UpdateCharacterStats(), CL_ViewPrecacheModels(), CM_AddMapTile(), CM_LoadMap(), Cmd_AddCommand(), Cmd_Close_f(), Cmd_ExecuteString(), Cmd_Open_f(), CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadNodes(), CMod_LoadPlanes(), CMod_LoadRouting(), CMod_LoadSubmodels(), CMod_LoadSurfaces(), CMod_RerouteMap(), Com_GetActorSound(), Com_GetMapDefinitionByID(), Com_GiveName(), Com_ParseDamageTypes(), Com_ParseItem(), Com_ParseTeam(), Com_SetServerState(), CP_AddItemAsCollected_f(), CP_AddWeaponAmmo(), CP_BaseAttackStartMission(), CP_BuildBaseSetUpBase(), CP_CampaignExit(), CP_ChooseMap(), CP_CountMissionActive(), CP_ExecuteMissionTrigger(), CP_GetRandomPosOnGeoscape(), CP_GetRandomPosOnGeoscapeWithParameters(), CP_GetWinProbabilty(), CP_LoadXML(), CP_MissionEnd(), CP_MissionRemove(), CP_MissionStageEnd(), CP_SetAlienEquipmentByInterest(), CP_SetMissionVars(), CP_SpawnAlienBaseMission(), CP_SpawnNewMissions(), CP_SupplyGoToBase(), CP_SupplyMissionCreate(), CP_SupplySetStayAtBase(), CP_TerrorMissionGo(), Door_Use(), E_CreateEmployeeAtIndex(), E_DeleteAllEmployees(), E_DeleteEmployee(), E_EmployeeDelete_f(), E_EmployeeHire_f(), E_GetHiredRobot(), E_HireForBuilding(), E_ResetEmployees(), E_UnhireEmployee(), G_ClientTeamInfo(), G_ClientUserinfoChanged(), G_Damage(), G_GetTeam(), G_ShootSingle(), G_TouchEdicts(), GAME_CP_MissionAutoCheck_f(), GAME_CP_MissionAutoGo_f(), GAME_SendCurrentTeamSpawningInfo(), Grid_CheckForbidden(), Grid_Fall(), Grid_MoveCalc(), Grid_MoveLength(), Grid_MoveMark(), Grid_RecalcBoxRouting(), Grid_RecalcRouting(), HOS_UpdateMenu(), HUD_DisplayFiremodes(), I_AddInvList(), I_AddToInventory(), I_EquipActor(), I_GetUsedSlots(), I_MoveInInventory(), I_PackAmmoAndWeapon(), I_RemoveFromInventory(), I_RemoveInvList(), IN_StartupJoystick(), INS_DestroyInstallation_f(), INS_FinishInstallation(), INS_InitStartup(), INS_ParseInstallations(), INS_SelectInstallation(), INS_SetUpInstallation(), INVSH_CheckShapeCollision(), INVSH_CheckToInventory(), INVSH_FindSpace(), INVSH_LoadableInWeapon(), Irc_Client_CmdPrivmsg(), Irc_Input_Activate_f(), Irc_Logic_AddChannelName(), Irc_Proto_Msg(), Irc_Proto_ProcessServerMsg(), Key_Message(), Key_SetBinding(), LE_AddAmbientSound(), LE_Cleanup(), LE_ExecuteThink(), LE_PlaySoundFileAndParticleForSurface(), LE_SetThink(), M_Change_f(), M_RandomTrack_f(), MAP_GetMissionModel(), MAP_GetNation(), MAP_MultiSelectExecuteAction_f(), Master_HeartbeatThread(), Master_Shutdown(), MP_LoadTeamMultiplayerInfo(), MP_SaveTeamMultiplayerInfo(), NAT_UpdateHappinessForAllNations(), NET_DatagramFindFreeSocket(), NET_StreamClose(), NET_StreamGetFree(), NET_Wait(), PR_CalculateProductionPercentDone(), PR_DisassembleItem(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_UpdateProductionList(), R_BindColorAttachments(), R_LoadMaterials(), R_LoadObjModelLine(), R_LoadShader(), R_ModLoadEdges(), R_ModLoadLeafs(), R_ModLoadNodes(), R_ModLoadPlanes(), R_ModLoadSubmodels(), R_ModLoadSurfaces(), R_ModLoadSurfedges(), R_ModLoadTexinfo(), R_ModLoadVertexes(), R_ParseStage(), R_ProgramVariable(), R_RunThread(), R_SortSurfacesArrays(), RS_AssignScientist(), RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_Collected_(), RS_GetTechByProvided(), RS_InitGUI(), RS_InitTree(), RS_MarkOneResearchable(), RS_MarkResearchable(), RS_MarkResearched(), RS_ParseTechnologies(), RS_RequirementsMet(), RS_ResearchStart_f(), S_PlaySample(), SAV_GameLoad_f(), SAV_VerifyHeader(), SEQ_ExecuteModel(), SEQ_ExecutePrecache(), SetWorkingDirectory(), SP_func_breakable(), SP_func_door(), SP_func_rotating(), SV_AddEvent(), SV_AssembleMap(), SV_Begin_f(), SV_ClipMoveToEntities(), SV_ConnectionlessPacket(), SV_ExecuteClientMessage(), SV_ExecuteUserCommand(), SV_GetCvarToken(), SV_LoadGame(), SV_Map(), SV_MapcycleAdd(), SV_New_f(), SV_NextMapcycle(), SV_ServerCommand_f(), SV_SetClientState(), SV_SetMaster_f(), SV_Spawn_f(), SV_UserinfoChanged(), SVC_DirectConnect(), SVC_Info(), tick_timer(), TR_CargoList(), TR_CargoListSelect_f(), TR_TransferAlienAfterMissionStart(), TR_TransferStart(), UFO_AddToGeoscape(), UFO_RemoveFromGeoscape(), UI_ButtonNodeLoaded(), UI_ContainerNodeAutoPlace(), UI_FireInit_f(), UI_ImageNodeLoaded(), UI_PanelNodeLoaded(), UI_ParseFont(), UI_ParseNode(), UI_ParseUIModel(), UI_TextScrollEnd(), UI_VScrollbarNodeLoaded(), UI_WindowNodeDraw(), UI_WindowNodeLoaded(), UP_FindEntry_f(), UR_DialogSelectSellNation_f(), and US_StoreUFO().

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

void Com_Error ( int  code,
const char *  fmt,
  ... 
)
Note:
Both client and server can use this, and it will do the appropriate things.

Definition at line 431 of file common.c.

References CL_Drop(), CL_Shutdown(), Com_Drop(), Com_Printf(), Cvar_Set(), ERR_DISCONNECT, ERR_DROP, FS_CloseFile(), MAXPRINTMSG, NET_Wait(), Q_vsnprintf(), Qcommon_Shutdown(), qfalse, qtrue, SV_Shutdown(), Sys_Backtrace(), and Sys_Error().

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_IsAircraftOnGeoscape(), 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_CanMultiplayerStart(), 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_ParseSequence(), CL_ParseServerData(), CL_ParseServerMessage(), CL_ParticleFunction(), CL_ParticleGetArt(), CL_ParticleLoadArt(), CL_ParticleSpawnTimed(), CL_ReadSinglePlayerData(), CL_SendCommand(), CL_SetClientState(), CL_SetConfigString(), CL_SetHTTPServer(), CL_SetRatioFilter_f(), 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_GetCharacterValues(), Com_InitArgv(), CP_BaseAttackGoToBase(), CP_ChooseMap(), CP_MissionChooseUFO(), CP_ParseCharacterData(), CP_SetAlienEquipmentByInterest(), CP_SetAlienTeamByInterest(), CP_SpawnAlienBaseMission(), 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_Event(), Key_Message(), LE_Add(), LE_DoEndPathMove(), LE_Lock(), LE_PlaceItem(), LE_Unlock(), LM_AddModel(), LM_AddToSceneOrder(), LMT_Init(), LoadModel(), MAP_GetCivilianNumberByPosition(), MAP_GetColor(), MAP_GetMissionModel(), MAP_Init(), MAP_InitStartup(), MD2GLCmdsRemove(), MD2HeaderCheck(), ModelWorker(), NET_DatagramBroadcast(), NET_Init(), NET_ReadDir(), NET_vReadFormat(), NET_vWriteFormat(), PR_DisassembleItem(), PR_ProductionInfo(), PR_UpdateRequiredItemsInBasestorage(), PrecalcNormalsAndTangents(), R_AddEntity(), R_AliasModelState(), R_CalcTransform(), R_CreateSurfaceLightmap(), R_Draw3DGlobe(), R_DrawBspNormals(), R_DrawEntities(), R_DrawFlatGeoscape(), R_DrawInitLocal(), R_DrawSurfaceStage(), R_EnforceVersion(), R_FindImage(), R_FontAnalyze(), R_FontInit(), R_GetFont(), R_GetFreeEntity(), R_GetFreeFBOTexture(), R_GetSpriteVectors(), R_InitExtensions(), R_InitializeShader(), R_InitImages(), R_LoadBspVertexArrays(), R_LoadImage(), R_LoadImageData(), R_LoadObjModel(), R_LoadObjModelFace(), R_LoadObjModelLine(), R_ModAddMapTile(), R_ModBeginLoading(), R_ModForName(), R_ModLoadAliasDPMModel(), R_ModLoadAliasMD2Mesh(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), R_ModLoadAnims(), R_ModLoadEdges(), R_ModLoadLeafs(), R_ModLoadMDX(), R_ModLoadNodes(), R_ModLoadNormals(), R_ModLoadPlanes(), R_ModLoadSubmodels(), R_ModLoadSurfaces(), R_ModLoadSurfedges(), R_ModLoadTags(), R_ModLoadTexinfo(), R_ModLoadVertexes(), R_PreprocessShader(), R_SetBlendMode(), R_SetupSubmodels(), R_SoftenTexture(), R_UploadData(), R_VerifyDriver(), RADAR_UpdateInstallationRadarCoverage(), Rimp_Init(), RS_AssignScientist(), RS_AssignTechLinks(), RS_GetTechForItem(), RS_InitTree(), RS_ParseTechnologies(), RS_RemoveScientist(), SEQ_Execute2Dobj(), SEQ_ExecuteModel(), SP_misc_model(), SV_AddMapTiles(), SV_AddTile(), SV_AssembleMap(), SV_Configstring(), SV_CreateWorldSector(), SV_error(), SV_FindIndex(), SV_GetConfigString(), SV_GetConfigStringInteger(), SV_GetCvarToken(), SV_GetGameAPI(), SV_GetServerDataForEdict(), SV_GetTileFromTileSet(), SV_HullForEntity(), SV_InitGameProgs(), SV_LoadModelMinsMaxs(), SV_ParseAssembly(), SV_ParseMapTileSet(), SV_ParseUMP(), SV_SetConfigString(), SV_SetModel(), SZ_GetSpace(), tileMask(), TR_BoxTrace(), TR_BuildTracingNode_r(), TR_TransferAlienAfterMissionStart(), TR_TransferStart(), UFO_GetByType(), UFO_IsUFOSeenOnGeoscape(), UFO_TypeToName(), UI_AllocNodeWithoutNew(), UI_AllocStaticAction(), UI_AllocStaticColor(), UI_AllocStaticFloat(), UI_AllocStaticIcon(), UI_AllocStaticKeyBinding(), UI_AllocStaticString(), UI_AllocTimer(), UI_BaseMapNodeClick(), UI_BaseMapNodeDraw(), UI_BaseMapNodeMiddleClick(), UI_BuildRadarImageList(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_DrawString(), UI_ExecuteAction(), UI_ExecuteSetAction(), UI_GetBooleanFromExpression(), UI_GetFloatFromExpression(), UI_GetNodeAbsPos(), UI_GetStringFromExpression(), UI_InitializeNodeBehaviour(), UI_InitNodes(), UI_InsertComponent(), UI_InsertWindow(), UI_NodeAbsoluteToRelativePos(), UI_NodeSetPropertyFromRAW(), UI_ParseComponent(), UI_ParseValueExpression(), UI_ParseWindow(), UI_PoolAllocAction(), UI_PopupButton(), UI_PopupList(), UI_RegisterFont(), UI_ReleaseVariable(), UI_SetKeyBinding(), UI_SetOneButton(), UI_TextNodeLoaded(), UP_Article(), UP_DisplayTechTree(), UP_GenerateSummary(), UP_SetMailHeader(), UP_TechTreeClick_f(), and US_RemoveUFOsExceedingCapacity().

static void Com_GameTypeList_f ( void   )  [static]

Definition at line 816 of file common.c.

References Com_Printf(), gametype_s::cvars, gt, gts, i, gametype_s::id, cvarlist_s::name, numGTs, and cvarlist_s::value.

Referenced by Qcommon_Init().

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

void Com_Printf ( const char *const   fmt,
  ... 
)

Definition at line 400 of file common.c.

References Com_vPrintf().

Referenced by _Mem_CreatePool(), AB_LoadXML(), AC_AlienClick_f(), AC_Init_f(), AC_InitCallbacks(), AC_KillOne_f(), AC_LoadXML(), AC_OpenUFOpedia_f(), AC_UpdateMenu(), AII_AddAmmoToSlot(), AII_AddItemToSlot(), AII_GetCraftitemTechsByType(), AII_SelectAircraftSlot(), AIM_AircraftEquipMenuClick_f(), AIM_AircraftEquipMenuUpdate_f(), AIM_AircraftEquipSlotSelect_f(), AIM_AircraftEquipZoneSelect_f(), AIM_AircraftItemtypeByName_f(), AIR_AssignInitial(), AIR_GetSlotItems(), AIR_IsInAircraftTeam(), AIR_LoadAircraftSlotsXML(), AIR_LoadAircraftXML(), AIR_LoadRouteXML(), AIR_LoadXML(), AIR_MoveEmployeeInventoryIntoStorage(), AIR_NewAircraft(), AIR_ParseAircraft(), AIR_RemoveFromAircraftTeam(), AIR_SaveAircraftXML(), AIR_ScriptSanityCheck(), AIR_UpdateHangarCapForOne(), AIRFIGHT_AddProjectile(), AIRFIGHT_LoadXML(), AIRFIGHT_ProbabilityToHit(), AL_AlienTypeToName(), AL_ChangeAliveAlienNumber(), AL_GetAlienGlobalIDX(), AL_GetAlienIDX(), AL_RemoveAliens(), AngleToDir(), ASE_Process(), B_AssembleMap(), B_BuildingClick_f(), B_BuildingOnDestroy_f(), B_CheckBuildingStatusForMenu_f(), B_Destroy_AntimaterStorage_f(), B_GetBaseTemplate(), B_GetBuildingStatus(), B_GetBuildingTemplate(), B_GetNumberOfBuildingsInBaseByBuildingType(), B_GetNumberOfBuildingsInBaseByTemplate(), B_LoadStorageXML(), B_LoadXML(), B_MakeBaseMapShot_f(), B_ParseBaseTemplate(), B_ParseBuildings(), B_ResetAllStatusAndCapacities(), B_SaveXML(), B_ScriptSanityCheck(), B_SelectBase_f(), B_SetBuildingStatus(), B_UpdateStorageAndCapacity(), BaseSummary_SelectBase_f(), BDEF_AddBattery(), BDEF_AddBattery_f(), BDEF_AddItem_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_RemoveBattery(), BDEF_RemoveBattery_f(), BDEF_RemoveItem_f(), BDEF_SelectItem_f(), BrushBSP(), BS_Autosell_f(), BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuySellItem_f(), BS_InitMarket(), BS_LoadXML(), BS_MarketClick_f(), BS_MarketScroll_f(), BS_SellAircraft_f(), BS_SellItem_f(), BuildFacelights(), BuildLights(), Cbuf_AddText(), Check_Stats(), CheckNodraws(), CheckZFighting(), CIN_OGM_PlayCinematic(), CIN_PlayCinematic(), CIN_ROQ_DecodeChunk(), CIN_ROQ_PlayCinematic(), CIN_ROQ_StopCinematic(), CL_ActorAdd(), CL_ActorAddToTeamList(), CL_ActorAppear(), CL_ActorEquipmentSelect_f(), CL_ActorGetSkillString(), CL_ActorPilotSelect_f(), CL_ActorSelect_f(), CL_ActorStartShoot(), CL_ActorStateChange(), CL_ActorStats(), CL_ActorTeamSelect_f(), CL_AddMapParticle(), CL_AssignPilot_f(), CL_AssignSoldier_f(), CL_BookmarkAdd_f(), CL_CamSetAngles_f(), CL_CamSetZoom_f(), CL_CanMultiplayerStart(), CL_ChangeIndividualInterest(), CL_CheckAndQueueDownload(), CL_CheckCvars_f(), CL_CheckOrDownloadFile(), CL_CompleteNetworkAddress(), CL_Connect(), CL_Connect_f(), CL_ConnectionlessPacket(), CL_DoEndRound(), CL_Env_f(), CL_EventAddMail_f(), CL_FinishHTTPDownload(), CL_ForwardToServer_f(), CL_GetAlienMissionTypeByID(), CL_GetCampaign(), CL_GetTipOfTheDay_f(), CL_LanguageInit(), CL_LanguageTryToSet(), CL_LoadCharacterXML(), CL_LoadInventoryXML(), CL_LoadItemXML(), CL_NationSelect_f(), CL_ParseAlienTeam(), CL_ParseCampaign(), CL_ParseCampaignEvents(), CL_ParseCities(), CL_ParseComponents(), CL_ParseCustomSkin(), CL_ParseEventMails(), CL_ParseLanguages(), CL_ParseMapDefinition(), CL_ParseNations(), CL_ParseParticle(), CL_ParsePtlCmds(), CL_ParseRanks(), CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), CL_ParseSalary(), CL_ParseSequence(), CL_ParseServerInfoMessage(), CL_ParseServerMessage(), CL_ParseTipsOfTheDay(), CL_ParticleAppear(), CL_ParticleFunction(), CL_ParticleLoadArt(), CL_ParticleSpawn(), CL_ParticleSpawnTimed(), CL_PingServer(), CL_PopupAircraftClick_f(), CL_PopupChangeHomebase_f(), CL_PopupInterceptBaseClick_f(), CL_PrecacheCharacterModels(), CL_PrintServerList_f(), CL_QueryMasterServerThread(), CL_Rcon_f(), CL_RconCallback(), CL_ReadSinglePlayerData(), CL_Reconnect_f(), CL_RequestNextDownload(), CL_ResearchSelect_f(), CL_Reset(), CL_RunHTTPDownloads(), CL_ScriptSanityCheck(), CL_SequenceStart_f(), CL_ServerInfo_f(), CL_ServerListClick_f(), CL_SetGameTime_f(), CL_SetRatioFilter_f(), CL_ShowConfigstrings_f(), CL_StartGame(), CL_StartHTTPDownload(), CL_UpdateEmployeeList(), CL_UpdatePilotList_f(), CL_UpdateSoldierList_f(), CL_UserInfo_f(), CM_LoadMap(), Cmd_AddCommand(), Cmd_Alias_f(), Cmd_CompleteCommand(), Cmd_CompleteExecCommand(), Cmd_Echo_f(), Cmd_Exec_f(), Cmd_ExecuteString(), Cmd_ForwardToServer(), Cmd_GetUserdata(), Cmd_List_f(), Cmd_RemoveCommand(), CMod_RerouteMap(), Com_ConsoleCompleteCommand(), Com_DeveloperSet_f(), Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Error(), Com_GameTypeList_f(), Com_GetCharacterTemplateByID(), Com_GetTeamDefinitionByID(), Com_GetUGVByID(), Com_GiveModel(), Com_MacroExpandString(), Com_ParseActorModels(), Com_ParseActorNames(), Com_ParseActorSounds(), Com_ParseArmourOrResistance(), Com_ParseCharacterTemplate(), Com_ParseDamageTypes(), Com_ParseEquipment(), Com_ParseFire(), Com_ParseGameTypes(), Com_ParseInventory(), Com_ParseItem(), Com_ParseScripts(), Com_ParseTeam(), Com_ParseTerrain(), Com_ParseUGVs(), Com_RegisterConstInt(), Com_SetGameType(), Com_SetValue(), Com_WriteConfig_f(), Com_WriteConfigToFile(), CompareAttributes(), Con_Init(), Con_SaveConsoleHistory(), CP_AddItemAsCollected_f(), CP_AddTechAsResearchable_f(), CP_BaseAttackGoToBase(), CP_BaseAttackMissionNextStage(), CP_BuildBaseMissionNextStage(), CP_ChangeNationHappiness_f(), CP_CheckBaseAttacks_f(), CP_ChooseMap(), CP_CountMission(), CP_ExecuteMissionTrigger(), CP_GetMissionByID(), CP_HarvestMissionGo(), CP_HarvestMissionNextStage(), CP_InterceptGoToInstallation(), CP_InterceptNextStage(), CP_ItemsSanityCheck(), CP_LoadInterestsXML(), CP_LoadMapDefStatXML(), CP_LoadMissionsXML(), CP_LoadXML(), CP_MissionAddToGeoscape(), CP_MissionBegin(), CP_MissionIsOver(), CP_MissionRemove(), CP_MissionStageEnd(), CP_NationStatsClick_f(), CP_ParseCharacterData(), CP_ReconMissionGroundGo(), CP_ReconMissionNextStage(), CP_SpawnAlienBaseMission(), CP_SpawnCrashSiteMission(), CP_StartMissionMap(), CP_StartSelectedMission(), CP_SupplyMissionCreate(), CP_SupplyMissionNextStage(), CP_TerrorMissionNextStage(), CP_XVIMissionNextStage(), Cvar_Add_f(), Cvar_AssertString(), Cvar_AssertValue(), Cvar_Command(), Cvar_CompleteVariable(), Cvar_Copy_f(), Cvar_Define_f(), Cvar_Del_f(), Cvar_Delete(), Cvar_FixCheatVars(), Cvar_Get(), Cvar_List_f(), Cvar_Mod_f(), Cvar_RegisterChangeListener(), Cvar_Set2(), Cvar_Set_f(), Cvar_SetCheckFunction(), Cvar_SetOld_f(), Cvar_UnRegisterChangeListener(), do_accept(), E_DeleteEmployeesExceedingCapacity(), E_EmployeeDelete_f(), E_EmployeeHire_f(), E_EmployeeList_f(), E_EmployeeSelect_f(), E_GetHiredEmployees(), E_GetUnhiredEmployee(), E_GetUnhiredRobot(), E_LoadXML(), EndOfScript(), ExportLightmap(), ExportLightmaps(), FS_AddGameDirectory(), FS_AddHomeAsGameDirectory(), FS_CopyFile(), FS_GetFileData(), FS_GetMaps(), FS_InitFilesystem(), FS_LoadPackFile(), FS_NextFileFromFileList(), FS_OpenFileSingle(), FS_RemoveFile(), FS_Shutdown(), FS_Write(), FS_WriteFile(), G_ClientConnect(), G_ClientTeamInfo(), G_MissionThink(), G_Shutdown(), G_SpawnEntities(), GAME_CP_CampaignListClick_f(), GAME_CP_DisplayItemInfo(), GAME_CP_MissionAutoGo_f(), GAME_CP_Results_f(), GAME_EndBattlescape(), GAME_MP_ChangeGametype_f(), GAME_SetMode(), GAME_SetMode_f(), GAME_SK_ChangeEquip_f(), GAME_SK_Start_f(), GAME_StartBattlescape(), GenerateFootstepList(), GenerateMaterialFile(), GLCmdsRemove(), Grid_Ceiling(), Grid_Floor(), Grid_Height(), Grid_PosToVec(), Grid_RecalcRouting(), Grid_SetMoveData(), Grid_StepUp(), HOS_EmployeeInit_f(), HOS_ListClick_f(), HTTP_GetURL(), HUD_ActorGetCvarData_f(), HUD_FireWeapon_f(), HUD_RemainingTUs_f(), HUD_SelectReactionFiremode_f(), HUD_ShotReserve_f(), HUD_SwitchFiremodeList_f(), I_PackAmmoAndWeapon(), I_RemoveFromInventory(), IN_EventEnqueue(), IN_Frame(), IN_Init(), IN_KeyDown(), IN_PrintKey(), IN_StartupJoystick(), IN_TranslateKey(), Info_Print(), Info_SetValueForKey(), INS_BuildInstallation_f(), INS_LoadXML(), INS_ParseInstallations(), INS_SelectInstallation_f(), INV_EquipmentDefSanityCheck(), INV_ItemMatchesFilter(), INV_UpdateObject_f(), INVSH_CheckShape(), INVSH_CheckShapeSmall(), INVSH_GetItemByID(), INVSH_ShapeSetBit(), Irc_AppendToBuffer(), Irc_Client_CmdPrivmsg(), Irc_Client_Invite_f(), Irc_Client_Join(), Irc_Client_Join_f(), Irc_Client_Kick_f(), Irc_Client_Mode_f(), Irc_Client_Msg_f(), Irc_Client_Names_f(), Irc_Client_Part_f(), Irc_Client_PrivMsg_f(), Irc_Client_Topic_f(), Irc_Client_Who_f(), Irc_Client_Whois_f(), Irc_Client_Whowas_f(), Irc_Connect_f(), Irc_Logic_Connect(), Irc_Logic_Disconnect(), Irc_Proto_Enqueue(), Irc_Proto_Join(), Irc_Proto_PollServerMsg(), Irc_Proto_ProcessServerMsg(), Key_Bind_f(), Key_Bindlist_f(), Key_CompleteKeyName(), Key_Console(), Key_Message(), Key_Unbind_f(), Key_WriteBindings(), Key_WriteBindings_f(), LE_AddAmbientSound(), LET_StartPathMove(), LM_Register(), LoadJPG(), LoadMapFile(), LoadModel(), LoadPNG(), M_Change_f(), M_CompleteMusic(), M_ParseMusic(), M_RandomTrack_f(), M_Start(), main(), MakeBrushWindings(), MakeTreePortals_r(), MAP_DeactivateOverlay_f(), MAP_GetMissionByIDX(), MAP_PrintParameterStringByPos(), MAP_Scroll_f(), MAP_SelectObject_f(), MAP_SetOverlay_f(), MAP_Zoom_f(), Master_HeartbeatThread(), MD2Check(), MD2GLCmdsRemove(), MD2SkinEdit(), MD2SkinFix(), MP_LoadTeamMultiplayer(), MP_LoadTeamMultiplayer_f(), MP_MultiplayerTeamSlotComments_f(), MP_SaveTeamMultiplayer(), MP_SaveTeamMultiplayer_f(), MP_TeamSelect_f(), MP_ToggleActorForTeam_f(), MS_LoadXML(), MSO_LoadXML(), MSO_ParseCategories(), MSO_ParseSettings(), MSO_Set_f(), MSO_SetAll_f(), MSO_Toggle_f(), NAT_GetNationByID(), NAT_ScriptSanityCheck(), NET_Connect(), NET_ConnectToLoopBack(), NET_DatagramSocketDoNew(), NET_DatagramSocketNew(), NET_DoConnect(), NET_DoStartServer(), NET_Init(), NET_ShowStreams_f(), NET_SockaddrToStrings(), NET_SocketSetNonBlocking(), NET_StreamClose(), NET_StreamPeerToName(), NET_Wait(), ParseBrush(), ParseMapEntity(), PR_LoadXML(), PR_ProductionChange_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), PR_UpdateProductionList(), PrecalcNormalsAndTangents(), PrecalcNormalsAndTangentsBatch(), Print2Vector(), Print3Vector(), PrintBSPFileSizes(), PrintMapName(), ProcessSubModel(), PTL_DebugList_f(), PTL_DebugSpawnMarker_f(), Q_vsnprintf(), Qcommon_Init(), R_AddLightsource(), R_AliasModelState(), R_AnimChange(), R_AnimGet(), R_BeginFrame(), R_BindTextureDebug(), R_CheckErrorDebug(), R_ConstByName(), R_CreateFramebuffer(), R_CvarCheckMaxLightmap(), R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), R_DrawInitLocal(), R_DrawModelDirect(), R_DrawModelParticle(), R_FindImage(), R_FontGenerateTexture(), R_FontInit(), R_FontListCache_f(), R_ImageList_f(), R_InitExtensions(), R_InitGraphics(), R_InitImages(), R_InitPrograms(), R_LoadAnimImages(), R_LoadImageData(), R_LoadMaterials(), R_LoadProgram(), R_LoadShader(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadLevelOfDetailData(), R_ModLoadTags(), R_ModModellist_f(), R_ParseStage(), R_PreprocessShader(), R_PrintInfo(), R_ProgramVariable(), R_RegisterModelShort(), R_RestartPrograms_f(), R_ScreenShot(), R_SetMode(), R_SwitchModelMemPoolTag(), R_TextureAlphaMode(), R_TextureMode(), R_TextureSolidMode(), R_UploadLightmapBlock(), R_UseFramebuffer(), R_VerifyDriver(), RADAR_AddUFO(), RADAR_UpdateBaseRadarCoverage_f(), Rimp_Init(), RS_AssignScientist(), RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_GetTechByID(), RS_GetTechIdxByName(), RS_InitGUI(), RS_InitTree(), RS_LoadXML(), RS_ParseTechnologies(), RS_RemoveScientist_f(), RS_RequirementsMet(), RS_ResearchStart_f(), RS_ResearchStop_f(), RS_ScriptSanityCheck(), RS_UpdateInfo(), RT_CalcNewZ(), RT_CheckCell(), RT_FillPassageData(), RT_FindOpening(), RT_FindOpeningCeiling(), RT_FindOpeningCeilingFrac(), RT_FindOpeningFloor(), RT_FindOpeningFloorFrac(), RT_MicroTrace(), RT_TraceOnePassage(), RT_TraceOpening(), RT_TracePassage(), RT_UpdateConnection(), RT_UpdateConnectionColumn(), S_CompleteSounds(), S_Init(), S_LoadSampleChunk(), S_Play_f(), S_Restart_f(), S_StartLocalSample(), SAV_AddSubsystem(), SAV_GameLoad(), SAV_GameLoad_f(), SAV_GameQuickLoad_f(), SAV_GameQuickSave_f(), SAV_GameReadGameComment(), SAV_GameSave(), SAV_GameSave_f(), SAV_GameSaveNameCleanup_f(), SAV_Init(), SAV_QuickSave(), SAV_VerifyHeader(), SCR_TimeRefresh_f(), SCR_TouchPics(), SCR_UpdateScreen(), SEQ_Execute2Dobj(), SEQ_ExecuteCamera(), SEQ_ExecuteModel(), SEQ_ExecuteMusic(), SEQ_ExecutePrecache(), SEQ_ExecuteRemove(), SEQ_InitSequence(), SetWorkingDirectory(), SP_misc_model(), SP_worldspawn(), SplitBrush(), STATS_LoadXML(), SV_AreaEdicts_r(), SV_AssembleMap(), SV_Begin_f(), SV_BroadcastPrintf(), SV_CheckMap(), SV_CompleteMapCommand(), SV_CompleteServerCommand(), SV_ConnectionlessPacket(), SV_DumpPlaced(), SV_DumpRating(), SV_ExecuteClientMessage(), SV_GetCvarToken(), SV_GetGameAPI(), SV_GetMapTitle(), SV_GetPlayerClientStructure(), SV_Init(), SV_Kick_f(), SV_ListMaps_f(), SV_LoadGame(), SV_Map(), SV_Map_f(), SV_MapcycleAdd_f(), SV_MapcycleList_f(), SV_MapcycleNext_f(), SV_New_f(), SV_NextMapcycle(), SV_ParallelSearch(), SV_ParseMapcycle(), SV_ParseMapTile(), SV_ParseMapTileSet(), SV_ParseUMP(), SV_PlayerPrintf(), SV_PrintConfigStrings_f(), SV_ServerCommand_f(), SV_Serverinfo_f(), SV_SetMaster_f(), SV_Shutdown(), SV_ShutdownGameProgs(), SV_Start(), SV_Status_f(), SV_Trace(), SV_UnlinkEdict(), SV_UnloadGame(), SV_UserInfo_f(), SVC_DirectConnect(), SVC_RemoteCommand(), Swap_Init(), Sys_ConsoleEditProc(), Sys_ConsoleInit(), Sys_GetHomeDirectory(), Sys_Init(), Sys_Mkdir(), Sys_SetAffinityAndPriority(), TR_BuildTracingNode_r(), TR_LoadXML(), TR_MakeTracingNode(), TR_SaveXML(), TR_SelectBase_f(), TR_TransferAlienAfterMissionStart(), TR_TransferAliensFromMission_f(), TR_TransferBaseListClick_f(), TR_TransferList_Scroll_f(), TR_TransferSelect(), TR_TransferStart(), TR_TransferStart_f(), TUT_List_f(), TUT_ListClick_f(), TUT_ParseTutorials(), UFO_AddToGeoscape(), UI_AbstractBaseNodeLoaded(), UI_AbstractNodeCallCreateChild(), UI_AbstractNodeCallDelete(), UI_AbstractNodeCallRemovaAllChild(), UI_AbstractOptionGetCurrentValue(), UI_ActiveVScrollbarNode_f(), UI_AddListener(), UI_AddListener_f(), UI_AllocNodeWithoutNew(), UI_AllocStaticStringCondition(), UI_BarNodeCapturedMouseMove(), UI_BarNodeDraw(), UI_BuildRadarImageList(), UI_CloneNode(), UI_CloseWindow(), UI_CloseWindow_f(), UI_CloseWindowByRef(), UI_ColumnLayout(), UI_CompleteWithWindow(), UI_ConFuncNodeLoaded(), UI_DebugTree(), UI_DebugTree_f(), UI_DeleteNode(), UI_DisplayNotice(), UI_DrawItem(), UI_DrawModelNode(), UI_DrawModelNodeWithUIModel(), UI_DrawNormImageByName(), UI_EditorNodeExtract_f(), UI_ExecuteAction(), UI_ExecuteActions(), UI_ExecuteCallAction(), UI_ExecuteSetAction(), UI_FireInit_f(), UI_FuncNodeLoaded(), UI_GenInjectedString(), UI_GetFloatFromExpression(), UI_GetFloatFromNodeProperty(), UI_GetNodeFromExpression(), UI_GetParam(), UI_GetStringFromExpression(), UI_GetStringFromNodeProperty(), UI_HideNode(), UI_InitFonts(), UI_InitRadar(), UI_InitRawActionValue(), UI_InitStack_f(), UI_KeyPressedInWindow(), UI_LineChartNodeDraw(), UI_ListUIModels_f(), UI_MaterialEditorChangeValue_f(), UI_MaterialEditorNewStage_f(), UI_MaterialEditorRemoveStage_f(), UI_MaterialEditorSelectStage_f(), UI_MaterialEditorStart_f(), UI_ModelNodeLoaded(), UI_Modify_f(), UI_ModifyWrap_f(), UI_NodeGetPoint(), UI_NodeSetProperty(), UI_NodeSetPropertyFromRAW(), UI_OptionTreeSetSelectedValue(), UI_PanelNodeDoLayout(), UI_ParseActionList(), UI_ParseCallAction(), UI_ParseEventProperty(), UI_ParseExcludeRect(), UI_ParseExpression(), UI_ParseFont(), UI_ParseIcon(), UI_ParseNode(), UI_ParseNodeBody(), UI_ParseNodeProperties(), UI_ParseProperty(), UI_ParseSetAction(), UI_ParseUIModel(), UI_ParseValueExpression(), UI_ParseWindow(), UI_PopWindow_f(), UI_PushChildWindow_f(), UI_PushDropDownWindow_f(), UI_PushWindow_f(), UI_PushWindowDelete(), UI_RadioButtonNodeActivate(), UI_RemoveListener(), UI_RemoveListener_f(), UI_ResetData_f(), UI_SelectMap_f(), UI_SetCvar(), UI_SetKeyBinding(), UI_SetNewWindowPos_f(), UI_TabNodeInit(), UI_TextListNodeDraw(), UI_TextNodeLoaded(), UI_TextScrollEnd(), UI_Translate_f(), UI_UnHideNode(), UI_WindowNodeClone(), UI_WindowNodeSetRenderNode(), UM_Parameter(), UP_ChangeDisplay(), UP_FindEntry_f(), UP_ParseChapters(), UP_SetMailButtons_f(), UR_DialogInit_f(), UR_DialogSelectSellNation_f(), UR_DialogSortByColumn_f(), UR_DialogStartStore_f(), UR_GetSortFunctionByColumn(), US_LoadXML(), Usage(), VID_Restart_f(), and WriteToFile().

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

static void Com_WriteConfig_f ( void   )  [static]

Write the config file to a specific name.

Definition at line 962 of file common.c.

References Cmd_Argc(), Cmd_Argv(), Com_DefaultExtension(), Com_Printf(), Com_WriteConfigToFile(), MAX_QPATH, and Q_strncpyz().

Referenced by Qcommon_Init().

void Com_WriteConfigToFile ( const char *  filename  ) 
static struct event* Dequeue_Event ( int  now  )  [static, read]

Finds and returns the first event in the event_queue that is due. If the event has a check function, we check to see if the event can be run now, and skip it if not (even if it is due).

Returns:
Returns a pointer to the event, NULL if none found.

Definition at line 1265 of file common.c.

References event::next.

Referenced by Qcommon_Frame().

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 freq,
event_func func,
void *  data 
)
static void tick_timer ( int  now,
void *  data 
) [static]

Variable Documentation

jmp_buf abortframe [static]

Definition at line 40 of file common.c.

Referenced by Com_Drop(), Qcommon_Frame(), Qcommon_Init(), and tick_timer().

cvar_t* cl_maxfps [static]

Definition at line 48 of file common.c.

Definition at line 60 of file common.c.

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

int com_argc [static]

Definition at line 37 of file common.c.

Referenced by Com_Argc(), Com_Argv(), Com_ClearArgv(), and Com_InitArgv().

const char* com_argv[MAX_NUM_ARGVS+1] [static]

Definition at line 38 of file common.c.

Referenced by Com_Argv(), Com_ClearArgv(), and Com_InitArgv().

Definition at line 61 of file common.c.

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

Definition at line 66 of file common.c.

Definition at line 35 of file common.c.

Referenced by AII_CarriedItems(), AII_GetCraftitemTechsByType(), AIR_GetStorageRoom(), AIR_MoveEmployeeInventoryIntoStorage(), AIR_TransferItemsCarriedByCharacterToBase(), AL_AlienTypeToName(), AL_FillInContainment(), AL_GetAlienGlobalIDX(), AL_GetAlienIDX(), B_InitialEquipment(), B_RemoveItemsExceedingCapacity(), B_SaveStorageXML(), B_UpdateStorageCap(), BS_BuyType(), BS_InitMarket(), BS_SaveXML(), CL_ActorAdd(), CL_ActorAppear(), CL_ActorEquipmentSelect_f(), CL_ActorGetContainerForReload(), CL_ActorReload(), CL_CampaignRunMarket(), CL_CanMultiplayerStart(), CL_CleanTempInventory(), CL_CleanupAircraftCrew(), CL_EntPerish(), CL_InvAdd(), CL_InvDel(), CL_LoadItemXML(), CL_NetSendInventory(), CL_PrecacheCharacterModels(), CL_ReadSinglePlayerData(), CL_ResetSinglePlayerData(), CL_SaveInventoryXML(), CL_SaveItemXML(), CL_TeamDefInitMenu(), CL_UpdateEmployeeList(), CL_ViewLoadMedia(), CL_ViewPrecacheModels(), Com_AddObjectLinks(), Com_GetCharacterTemplateByID(), Com_GetTeamDefinitionByID(), Com_GetUGVByID(), Com_GetUGVByIDSilent(), Com_ParseArmourOrResistance(), Com_ParseCharacterTemplate(), Com_ParseDamageTypes(), Com_ParseEquipment(), Com_ParseInventory(), Com_ParseItem(), Com_ParseScripts(), Com_ParseTeam(), Com_ParseUGVs(), Com_ParseValue(), Com_ValueToStr(), CP_AddItemAsCollected_f(), CP_AddWeaponAmmo(), CP_ItemsSanityCheck(), CP_SetAlienEquipmentByInterest(), CP_SetMissionVars(), E_RemoveInventoryFromStorage(), GAME_SetMode(), GAME_SK_ChangeEquip_f(), GAME_SK_SetMissionParameters(), GAME_Spawn(), HUD_GetLeftHandWeapon(), HUD_RefreshButtons(), HUD_ReloadLeft_f(), HUD_ReloadRight_f(), HUD_UpdateActor(), I_EquipActor(), INV_EquipmentDefSanityCheck(), INV_GetEquipmentDefinitionByID(), INV_ItemDescription(), INV_UpdateObject_f(), LE_AddProjectile(), LE_Cleanup(), LET_Projectile(), MP_SaveTeamMultiplayer(), PR_UpdateProductionList(), ResetInventoryList(), RS_InitTree(), S_LoadSamples(), SV_InitGameProgs(), SV_Map(), testItemMassActions(), TR_CargoList(), TR_CargoListSelect_f(), TR_CheckItem(), TR_EmptyTransferCargo(), TR_TransferAlienAfterMissionStart(), TR_TransferList_Scroll_f(), TR_TransferListClear_f(), TR_TransferListSelect_f(), TR_TransferSelect(), TR_TransferStart(), UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), UI_ContainerItemIteratorNext(), UI_ContainerNodeAutoPlace(), UI_ContainerNodeDraw(), UI_ContainerNodeDrawSingle(), UI_ContainerNodeUpdateEquipment(), and UP_Article().

const debugLevel_t debugLevels[] [static]
Initial value:
 {
    {"DEBUG_ALL", DEBUG_ALL},
    {"DEBUG_ENGINE", DEBUG_ENGINE},
    {"DEBUG_SHARED", DEBUG_SHARED},
    {"DEBUG_SYSTEM", DEBUG_SYSTEM},
    {"DEBUG_COMMANDS", DEBUG_COMMANDS},
    {"DEBUG_CLIENT", DEBUG_CLIENT},
    {"DEBUG_EVENTSYS", DEBUG_EVENTSYS},
    {"DEBUG_PATHING", DEBUG_PATHING},
    {"DEBUG_SERVER", DEBUG_SERVER},
    {"DEBUG_GAME", DEBUG_GAME},
    {"DEBUG_RENDERER", DEBUG_RENDERER},
    {"DEBUG_SOUND", DEBUG_SOUND},

    {NULL, 0}
}

Definition at line 868 of file common.c.

Definition at line 42 of file common.c.

Referenced by Con_DrawNotify(), and MS_LoadXML().

struct event* event_queue = NULL [static]

Definition at line 77 of file common.c.

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

qFILE logfile [static]

Definition at line 58 of file common.c.

Definition at line 45 of file common.c.

char* rd_buffer [static]

Definition at line 291 of file common.c.

Referenced by Com_BeginRedirect(), Com_EndRedirect(), and Com_vPrintf().

unsigned int rd_buffersize [static]

Definition at line 292 of file common.c.

Referenced by Com_BeginRedirect(), Com_EndRedirect(), and Com_vPrintf().

struct net_stream* rd_stream [static]

Definition at line 293 of file common.c.

Definition at line 49 of file common.c.

Referenced by CL_LanguageInit(), CL_LanguageTryToSet(), and CL_SlowFrame().

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