UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scripts.h File Reference

Header for script parsing functions. More...

#include "common.h"
#include "../game/q_shared.h"

Go to the source code of this file.

Data Structures

struct  value_s
 
struct  terrainType_s
 Different terrain definitions for footsteps and particles. More...
 
struct  constListEntry_s
 list of script aliases to register More...
 

Macros

#define MEMBER_SIZEOF(TYPE, MEMBER)   sizeof(((TYPE*)0)->MEMBER)
 
#define V_BASETYPEMASK   0x3F
 Allow to add extra bit into the type. More...
 
#define UFO_MAX   16
 
#define AIRCRAFT_NONE   -1
 
#define UFO_NONE   AIRCRAFT_NONE
 
#define AIR_SLOT_TYPE_STRINGS
 
#define SND_VOLUME_FOOTSTEPS   0.4f
 

Typedefs

typedef short ufoType_t
 
typedef struct value_s value_t
 
typedef struct terrainType_s terrainType_t
 Different terrain definitions for footsteps and particles. More...
 
typedef struct constListEntry_s constListEntry_t
 list of script aliases to register More...
 

Enumerations

enum  valueTypes_t {
  V_NULL, V_BOOL, V_CHAR, V_INT,
  V_INT2, V_FLOAT, V_POS, V_VECTOR,
  V_COLOR, V_STRING, V_TRANSLATION_STRING, V_LONGSTRING,
  V_ALIGN, V_BLEND, V_STYLE, V_FADE,
  V_SHAPE_SMALL, V_SHAPE_BIG, V_DAMAGE, V_DATE,
  V_RELABS, V_HUNK_STRING, V_TEAM, V_UFO,
  V_UFOCRASHED, V_AIRCRAFTTYPE, V_LIST, V_NUM_TYPES,
  V_ENSURE32BIT = 0xffffffff
}
 possible values for parsing functions More...
 
enum  align_t {
  ALIGN_UL, ALIGN_UC, ALIGN_UR, ALIGN_CL,
  ALIGN_CC, ALIGN_CR, ALIGN_LL, ALIGN_LC,
  ALIGN_LR, ALIGN_UL_RSL, ALIGN_UC_RSL, ALIGN_UR_RSL,
  ALIGN_CL_RSL, ALIGN_CC_RSL, ALIGN_CR_RSL, ALIGN_LL_RSL,
  ALIGN_LC_RSL, ALIGN_LR_RSL, ALIGN_LAST
}
 We need this here for checking the boundaries from script values. More...
 
enum  blend_t {
  BLEND_REPLACE, BLEND_ONE, BLEND_BLEND, BLEND_ADD,
  BLEND_FILTER, BLEND_INVFILTER, BLEND_LAST
}
 
enum  style_t {
  STYLE_FACING, STYLE_ROTATED, STYLE_BEAM, STYLE_LINE,
  STYLE_AXIS, STYLE_CIRCLE, STYLE_LAST
}
 
enum  fade_t {
  FADE_NONE, FADE_IN, FADE_OUT, FADE_SIN,
  FADE_SAW, FADE_LAST
}
 
enum  resultStatus_t { RESULT_ERROR = -1, RESULT_WARNING = -2, RESULT_OK = 0 }
 

Functions

template<typename T >
T & Com_GetValue (void *const object, value_t const *const value)
 
template<typename T >
T const & Com_GetValue (void const *const object, value_t const *const value)
 
int Com_SetValue (void *base, const void *set, valueTypes_t type, int ofs, size_t size)
 
int Com_EParseValue (void *base, const char *token, valueTypes_t type, int ofs, size_t size)
 
bool Com_ParseBlock (const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool)
 
bool Com_ParseBlockToken (const char *name, const char **text, void *base, const value_t *values, memPool_t *mempool, const char *token)
 
bool Com_ParseList (const char **text, linkedList_t **list)
 
voidCom_AlignPtr (const void *memory, valueTypes_t type)
 Align a memory to use a natural address for the data type we will write. More...
 
const char * Com_ValueToStr (const void *base, const valueTypes_t type, const int ofs)
 
const char * Com_GetLastParseError (void)
 
resultStatus_t Com_ParseValue (void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
 Parse a value from a string. More...
 
bool Com_ParseBoolean (const char *token)
 Parses a boolean from a string. More...
 
const terrainType_tCom_GetTerrainType (const char *textureName)
 Searches the terrain definition if given. More...
 
bool Com_GetConstInt (const char *name, int *value)
 Searches whether a given value was registered as a string to int mapping. More...
 
bool Com_GetConstIntFromNamespace (const char *space, const char *variable, int *value)
 Searches whether a given value was registered as a string to int mapping. More...
 
const char * Com_GetConstVariable (const char *space, int value)
 Searches the mapping variable for a given integer value and a namespace. More...
 
bool Com_UnregisterConstVariable (const char *name)
 Removes a registered constant from the script mapping hash table. More...
 
void Com_RegisterConstInt (const char *name, int value)
 Register mappings between script strings and enum values for values of the type V_INT. More...
 
void Com_RegisterConstList (const constListEntry_t constList[])
 Registers a list of string aliases. More...
 
bool Com_UnregisterConstList (const constListEntry_t constList[])
 Unregisters a list of string aliases. More...
 
void Com_ParseScripts (bool onlyServer)
 
const char * Com_EParse (const char **text, const char *errhead, const char *errinfo, char *target=0, size_t size=0)
 Parsing function that prints an error message when there is no text in the buffer. More...
 
const char * Com_GetRandomMapAssemblyNameForCraft (const char *craftID)
 Returns the name of an aircraft or an ufo that is used in the ump files for the random map assembly. More...
 
const char * Com_GetRandomMapAssemblyNameForCrashedCraft (const char *craftID)
 
ufoType_t Com_UFOShortNameToID (const char *token)
 Translate short name to UFO type. More...
 
const char * Com_UFOTypeToShortName (ufoType_t type)
 Translate UFO type to short name. More...
 
const char * Com_UFOCrashedTypeToShortName (ufoType_t type)
 Translate UFO type to short name when UFO is crashed. More...
 
short Com_GetUfoIdsNum (void)
 
short Com_GetDropShipIdsNum (void)
 
short Com_GetHumanAircraftIdsNum (void)
 
int Com_GetScriptChecksum (void)
 
void Com_Shutdown (void)
 
const ugv_tCom_GetUGVByIDSilent (const char *ugvID)
 Searches an UGV definition by a given script id and returns the pointer to the global data. More...
 
const ugv_tCom_GetUGVByID (const char *ugvID)
 Searches an UGV definition by a given script id and returns the pointer to the global data. More...
 
const char * Com_DropShipTypeToShortName (humanAircraftType_t type)
 Translate DropShip type to short name. More...
 
humanAircraftType_t Com_DropShipShortNameToID (const char *token)
 Translate DropShip type to short name. More...
 
void Com_GetCharacterValues (const char *teamDefition, character_t *chr)
 Assign character values, 3D models and names to a character. More...
 
bool Com_GetCharacterModel (character_t *chr)
 
const teamDef_tCom_GetTeamDefinitionByID (const char *team)
 Returns the teamDef pointer for the searched team id - or nullptr if not found in the teamDef array. More...
 
const chrTemplate_tCom_GetCharacterTemplateByID (const char *chrTemplate)
 Returns the chrTemplate pointer for the given id - or nullptr if not found in the chrTemplates array. More...
 

Variables

const char *const vt_names []
 possible values for parsing functions More...
 
const char *const align_names []
 
const char *const blend_names []
 
const char *const style_names []
 
const char *const fade_names []
 
const char *const longlines_names []
 
const char *const name_strings []
 

Detailed Description

Header for script parsing functions.

Definition in file scripts.h.

Macro Definition Documentation

#define AIR_SLOT_TYPE_STRINGS
Value:
{ \
"base_missile", \
"base_laser", \
"weapon", \
"shield", \
"electronics", \
"pilot", \
"ammo", \
"base_ammo_missile", \
"base_ammo_laser" \
}

Definition at line 155 of file scripts.h.

#define MEMBER_SIZEOF (   TYPE,
  MEMBER 
)    sizeof(((TYPE*)0)->MEMBER)

Definition at line 34 of file scripts.h.

Referenced by AIR_ParseAircraft(), UI_SpriteExists(), and WEB_ListCGameFilesCallback().

#define SND_VOLUME_FOOTSTEPS   0.4f

Definition at line 213 of file scripts.h.

Referenced by Com_ParseTerrain(), LE_PlayFootStepSound(), and LE_PlaySoundFileForContents().

#define UFO_MAX   16
#define V_BASETYPEMASK   0x3F

Allow to add extra bit into the type.

Note
If valueTypes_t is bigger than 63 the mask must be changed
See also
valueTypes_t

Definition at line 41 of file scripts.h.

Referenced by UI_InitRawActionValue(), UI_NodeSetPropertyFromRAW(), and UI_ParseProperty().

Typedef Documentation

list of script aliases to register

Note
must be terminated with a nullptr ({nullptr, -1}) entry!
See also
saveEmployeeConstants[]
typedef struct terrainType_s terrainType_t

Different terrain definitions for footsteps and particles.

typedef short ufoType_t

Definition at line 146 of file scripts.h.

typedef struct value_s value_t

used e.g. in our parsers

Enumeration Type Documentation

enum align_t

We need this here for checking the boundaries from script values.

possible align values - see also align_names

Enumerator
ALIGN_UL 
ALIGN_UC 
ALIGN_UR 
ALIGN_CL 
ALIGN_CC 
ALIGN_CR 
ALIGN_LL 
ALIGN_LC 
ALIGN_LR 
ALIGN_UL_RSL 
ALIGN_UC_RSL 
ALIGN_UR_RSL 
ALIGN_CL_RSL 
ALIGN_CC_RSL 
ALIGN_CR_RSL 
ALIGN_LL_RSL 
ALIGN_LC_RSL 
ALIGN_LR_RSL 
ALIGN_LAST 

Definition at line 90 of file scripts.h.

enum blend_t

possible blend modes - see also blend_names

Enumerator
BLEND_REPLACE 
BLEND_ONE 
BLEND_BLEND 
BLEND_ADD 
BLEND_FILTER 
BLEND_INVFILTER 
BLEND_LAST 

Definition at line 114 of file scripts.h.

enum fade_t
Enumerator
FADE_NONE 
FADE_IN 
FADE_OUT 
FADE_SIN 
FADE_SAW 
FADE_LAST 

Definition at line 136 of file scripts.h.

Enumerator
RESULT_ERROR 
RESULT_WARNING 
RESULT_OK 

Definition at line 185 of file scripts.h.

enum style_t
Enumerator
STYLE_FACING 

rotates a sprint into the camera direction

STYLE_ROTATED 

use the particle angles vector

STYLE_BEAM 
STYLE_LINE 
STYLE_AXIS 
STYLE_CIRCLE 
STYLE_LAST 

Definition at line 125 of file scripts.h.

possible values for parsing functions

See also
vt_names
vt_sizes
Enumerator
V_NULL 
V_BOOL 
V_CHAR 
V_INT 
V_INT2 
V_FLOAT 
V_POS 
V_VECTOR 
V_COLOR 
V_STRING 
V_TRANSLATION_STRING 

remove _ but don't translate

V_LONGSTRING 

not buffer safe - use this only for menu node data array values!

V_ALIGN 
V_BLEND 
V_STYLE 
V_FADE 
V_SHAPE_SMALL 

space a weapon allocates in the inventory shapes, w, h

V_SHAPE_BIG 

inventory shape, x, y, w, h

V_DAMAGE 
V_DATE 
V_RELABS 

relative (e.g. 1.50) and absolute (e.g. +15) values

V_HUNK_STRING 

store the string in a mem pool

V_TEAM 

team string to int mapper

V_UFO 

Valid ufo types.

Note
Use the same values for the names as we are already using in the scriptfiles here, otherwise they are not translatable because they don't appear in the po files
Every ufotype (id) that doesn't have nogeoscape set to true must have an assembly in the ufocrash[dn].ump files
V_UFOCRASHED 
V_AIRCRAFTTYPE 
V_LIST 
V_NUM_TYPES 
V_ENSURE32BIT 

Definition at line 48 of file scripts.h.

Function Documentation

void* Com_AlignPtr ( const void memory,
valueTypes_t  type 
)

Align a memory to use a natural address for the data type we will write.

Note
it speed up data read, and fix crash on PPC processors

Definition at line 440 of file scripts.cpp.

References Sys_Error(), type, V_NULL, and V_NUM_TYPES.

Referenced by CL_ParsePtlCmds(), Com_ParseValue(), Com_SetValue(), Com_ValueToStr(), UI_InitRawActionValue(), and UI_ParseProperty().

humanAircraftType_t Com_DropShipShortNameToID ( const char *  token)

Translate DropShip type to short name.

Returns
Will always return a valid human aircraft type or errors out if the given token can't be mapped to an human aircraft type
See also
Com_DropShipTypeToShortName

Definition at line 3329 of file scripts.cpp.

References Com_ParseValue(), and V_AIRCRAFTTYPE.

Referenced by Com_ParseEquipment(), and GAME_GetImportData().

const char* Com_DropShipTypeToShortName ( humanAircraftType_t  type)

Translate DropShip type to short name.

See also
Com_DropShipShortNameToID

Definition at line 3341 of file scripts.cpp.

References Com_ValueToStr(), and V_AIRCRAFTTYPE.

Referenced by GAME_GetImportData().

int Com_EParseValue ( void base,
const char *  token,
valueTypes_t  type,
int  ofs,
size_t  size 
)
const chrTemplate_t* Com_GetCharacterTemplateByID ( const char *  chrTemplate)

Returns the chrTemplate pointer for the given id - or nullptr if not found in the chrTemplates array.

Parameters
[in]chrTemplateThe character template id (given in ufo-script files)

Definition at line 2831 of file scripts.cpp.

References csi_s::chrTemplates, Com_Printf(), csi, i, chrTemplate_s::id, csi_s::numChrTemplates, Q_streq, and Q_strnull().

Referenced by Com_ParseTeam().

void Com_GetCharacterValues ( const char *  teamDefition,
character_t chr 
)

Assign character values, 3D models and names to a character.

Parameters
[in]teamDefitionThe team definition id to use to generate the character values.
[in,out]chrThe character that should get the paths to the different models/skins.
See also
Com_GiveName
Com_GiveModel

Definition at line 2430 of file scripts.cpp.

References ACTOR_SIZE_INVALID, ACTOR_SIZE_NORMAL, Com_Error(), Com_GetCharacterModel(), Com_GetGender(), Com_GetTeamDefinitionByID(), Com_GiveName(), ERR_DROP, character_s::fieldSize, character_s::gender, character_s::name, NAME_LAST, Q_strcat(), Q_strncpyz(), teamDef_s::size, and character_s::teamDef.

Referenced by CL_GenerateCharacter(), and SV_InitGameProgs().

bool Com_GetConstInt ( const char *  name,
int value 
)

Searches whether a given value was registered as a string to int mapping.

Parameters
[in]nameThe name of the string mapping (maybe including a namespace)
[out]valueThe mapped integer if found, not touched if the given string was found in the registered values.
Returns
True if the value is found.
See also
Com_RegisterConstInt
Com_ParseValue

Definition at line 74 of file scripts.cpp.

References Com_ConstIntGetVariable(), Com_HashKey(), CONSTNAMEINT_HASH_SIZE, hash, com_constNameInt_s::hash_next, and Q_streq.

Referenced by Com_GetConstIntFromNamespace(), Com_ParseValue(), GAME_GetImportData(), SV_InitGameProgs(), and TEST_F().

bool Com_GetConstIntFromNamespace ( const char *  space,
const char *  variable,
int value 
)

Searches whether a given value was registered as a string to int mapping.

Parameters
[in]spaceThe namespace of the mapping variable
[in]variableThe name of the string mapping
[out]valueThe mapped integer if found, not touched if the given string was found in the registered values.
Returns
True if the value is found.
See also
Com_RegisterConstInt
Com_ParseValue
Com_GetConstInt

Definition at line 103 of file scripts.cpp.

References Com_GetConstInt(), Q_strnull(), and va().

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), and SV_InitGameProgs().

const char* Com_GetConstVariable ( const char *  space,
int  value 
)

Searches the mapping variable for a given integer value and a namespace.

Parameters
[in]spaceThe namespace to search in - might not be nullptr or empty.
[in]valueThe mapped integer
Note
only variables with a namespace given are found here
See also
Com_RegisterConstInt
Com_ParseValue

Definition at line 122 of file scripts.cpp.

References com_constNameInt, com_constNameInt_s::fullname, com_constNameInt_s::name, com_constNameInt_s::next, and com_constNameInt_s::value.

Referenced by GAME_GetImportData(), GAME_SaveCharacter(), SV_InitGameProgs(), and TEST_F().

short Com_GetDropShipIdsNum ( void  )

Definition at line 579 of file scripts.cpp.

References CRAFT_DROP.

Referenced by GAME_GetImportData().

short Com_GetHumanAircraftIdsNum ( void  )

Definition at line 584 of file scripts.cpp.

References CRAFT_DROP, and CRAFT_INTER.

Referenced by GAME_GetImportData().

const char* Com_GetLastParseError ( void  )

Returns the last error message

Returns
string that contains the last error message

Definition at line 431 of file scripts.cpp.

References parseErrorMessage.

Referenced by UI_NodeSetProperty(), and UI_ParseProperty().

const char* Com_GetRandomMapAssemblyNameForCraft ( const char *  craftID)

Returns the name of an aircraft or an ufo that is used in the ump files for the random map assembly.

See also
cvar rm_drop, rm_ufo, rm_crashed
Note
Uses a static buffer - so after you got the name you should ensure that you put it into a proper location. Otherwise it will get overwritten with the next call of this function.

Definition at line 3299 of file scripts.cpp.

References va().

Referenced by GAME_GetImportData(), TEST_F(), GameTest::testCountSpawnpointsForMapWithAssembly(), and GameTest::testCountSpawnpointsForMapWithAssemblyAndAircraft().

const char* Com_GetRandomMapAssemblyNameForCrashedCraft ( const char *  craftID)
Todo:
implement this in a better way

Definition at line 3307 of file scripts.cpp.

References Q_streq.

Referenced by GAME_GetImportData().

int Com_GetScriptChecksum ( void  )

Definition at line 3739 of file scripts.cpp.

References Com_BlockChecksum(), FS_GetFileData(), and LittleLong.

Referenced by CL_CanMultiplayerStart(), and SV_Map().

const teamDef_t* Com_GetTeamDefinitionByID ( const char *  team)

Returns the teamDef pointer for the searched team id - or nullptr if not found in the teamDef array.

Parameters
[in]teamThe team id (given in ufo-script files)

Definition at line 2367 of file scripts.cpp.

References Com_Printf(), csi, i, teamDef_s::id, csi_s::numTeamDefs, Q_streq, and csi_s::teamDef.

Referenced by Com_GetCharacterValues(), GAME_GetImportData(), GAME_ItemIsUseable(), GAME_LoadCharacter(), and TEST_F().

const terrainType_t* Com_GetTerrainType ( const char *  textureName)

Searches the terrain definition if given.

Parameters
[in]textureNameThe terrain definition id from script files which is the texture name relative to base/textures

Definition at line 3089 of file scripts.cpp.

References Com_HashKey(), hash, terrainType_s::hash_next, Q_streq, and TERRAIN_HASH_SIZE.

Referenced by Com_ParseTerrain(), LE_PlaySoundFileAndParticleForSurface(), SV_GetBounceFraction(), and SV_GetFootstepSound().

short Com_GetUfoIdsNum ( void  )

Definition at line 574 of file scripts.cpp.

References CRAFT_UFO.

Referenced by GAME_GetImportData(), and TEST_F().

const ugv_t* Com_GetUGVByID ( const char *  ugvID)

Searches an UGV definition by a given script id and returns the pointer to the global data.

Parameters
[in]ugvIDThe script id of the UGV definition you are looking for
Returns
ugv_t pointer or nullptr if not found.

Definition at line 3403 of file scripts.cpp.

References Com_GetUGVByIDSilent(), Com_Printf(), csi, and csi_s::numUGV.

Referenced by GAME_GetImportData(), and TEST_F().

const ugv_t* Com_GetUGVByIDSilent ( const char *  ugvID)

Searches an UGV definition by a given script id and returns the pointer to the global data.

Parameters
[in]ugvIDThe script id of the UGV definition you are looking for
Returns
ugv_t pointer or nullptr if not found.
Note
This function gives no warning on null name or if no ugv found

Definition at line 3384 of file scripts.cpp.

References csi, i, ugv_s::id, csi_s::numUGV, Q_streq, and csi_s::ugvs.

Referenced by Com_GetUGVByID(), GAME_AppendTeamMember(), and GAME_GetImportData().

template<typename T >
T& Com_GetValue ( void *const  object,
value_t const *const  value 
)
inline

Definition at line 175 of file scripts.h.

References value_s::ofs.

template<typename T >
T const& Com_GetValue ( void const *const  object,
value_t const *const  value 
)
inline

Definition at line 180 of file scripts.h.

bool Com_ParseBlock ( const char *  name,
const char **  text,
void base,
const value_t values,
memPool_t mempool 
)
bool Com_ParseBoolean ( const char *  token)

Parses a boolean from a string.

Parameters
tokenThe token to convert into a boolean
Returns
false if the string could not get parsed

Definition at line 1000 of file scripts.cpp.

References Com_ParseValue(), RESULT_ERROR, and V_BOOL.

Referenced by GAME_GetImportData(), and HUD_RemainingTUs_f().

bool Com_ParseList ( const char **  text,
linkedList_t **  list 
)

Parse tokens between '(' and ')' and return them into a linked list. It the list is not well formed, the returned list is null.

Parameters
[in]textPointer to a token stream
[out]listlist to return
Returns
True if the list is well formed, else false.

Definition at line 1385 of file scripts.cpp.

References Com_GetToken(), Com_NextToken(), Com_Printf(), LIST_AddString(), LIST_Delete(), TT_BEGIN_LIST, TT_CONTENT, TT_END_LIST, and TT_EOF.

Referenced by CL_ParseLanguages(), CL_ParseSequence(), Com_ParseActorModels(), Com_ParseActorNames(), Com_ParseBlockToken(), Com_ParseBodyPart(), Com_ParseEquipment(), Com_ParseMapDefinition(), Com_ParseTeam(), GAME_GetImportData(), M_ParseMusic(), and TEST_F().

resultStatus_t Com_ParseValue ( void base,
const char *  token,
valueTypes_t  type,
int  ofs,
size_t  size,
size_t *  writtenBytes 
)

Parse a value from a string.

Parameters
[in]baseThe start pointer to a given data type (typedef, struct) where the parsed data is stored
[in]tokenThe data which should be parsed
[in]typeThe data type that should be parsed
[in]ofsThe offset for the value
[in]sizeThe expected size of the data type. If 0, no checks are done
[out]writtenBytes
Returns
A resultStatus_t value
Note
instead of , this function separate error message and write byte result
Todo:
This function has much in common with Com_SetValue. Refactor them !

Definition at line 659 of file scripts.cpp.

References AIRCRAFT_NONE, ALIGN_LAST, BLEND_LAST, Com_AlignPtr(), Com_GetConstInt(), Com_GetCrashedUfoIdNum(), Com_GetHumanCraftIdNum(), Com_GetUfoIdNum(), Com_Printf(), csi, DAYS_PER_YEAR, csi_s::dts, f, FADE_LAST, damageType_s::id, int(), MAX_VAR, csi_s::numDTs, Q_streq, Q_strncpyz(), RESULT_ERROR, RESULT_OK, RESULT_WARNING, SECONDS_PER_HOUR, SHAPE_BIG_MAX_HEIGHT, SHAPE_BIG_MAX_WIDTH, SHAPE_SMALL_MAX_HEIGHT, SHAPE_SMALL_MAX_WIDTH, STYLE_LAST, Sys_Error(), TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, type, UFO_NONE, UFO_SIZE_T, V_AIRCRAFTTYPE, V_ALIGN, V_BLEND, V_BOOL, V_CHAR, V_COLOR, V_DAMAGE, V_DATE, V_FADE, V_FLOAT, V_HUNK_STRING, V_INT, V_INT2, V_LONGSTRING, V_NULL, V_POS, V_RELABS, V_SHAPE_BIG, V_SHAPE_SMALL, V_STRING, V_STYLE, V_TEAM, V_TRANSLATION_STRING, V_UFO, V_UFOCRASHED, and V_VECTOR.

Referenced by Com_DropShipShortNameToID(), Com_EParseValue(), Com_ParseBoolean(), Com_UFOShortNameToID(), TEST_F(), UI_MaterialEditorChangeValue_f(), UI_NodeSetProperty(), UI_ParseProperty(), and UI_PushDropDownWindow_f().

void Com_RegisterConstInt ( const char *  name,
int  value 
)

Register mappings between script strings and enum values for values of the type V_INT.

Parameters
nameThe name of the script entry to map to an integer. This can also include a namespace prefix for the case we want to map back an integer to a string from a specific namespace. In case this string is equipped with a namespace, the string is in the form "namespace::variable"
valueThe value to map the given name to
Note
You still can't register the same name twice even if you put it into different namespaces (yet). The namespaces are only for converting an integer back into a string.
See also
Com_GetConstInt
Com_UnregisterConstVariable

Definition at line 198 of file scripts.cpp.

References com_aliasSysPool, Com_ConstIntGetVariable(), com_constNameInt, Com_HashKey(), Com_Printf(), CONSTNAMEINT_HASH_SIZE, com_constNameInt_s::fullname, hash, com_constNameInt_s::hash_next, Mem_PoolAllocType, Mem_StrDup, com_constNameInt_s::name, com_constNameInt_s::next, Q_streq, Q_strncpyz(), and com_constNameInt_s::value.

Referenced by Com_RegisterConstList(), GAME_GetImportData(), SV_InitGameProgs(), TEST_F(), UI_RegisterAbstractNode(), UI_RegisterBaseInventoryNode(), UI_RegisterPanelNode(), UI_RegisterSpinnerNode(), and UI_RegisterTextNode().

void Com_RegisterConstList ( const constListEntry_t  constList[])

Registers a list of string aliases.

Parameters
[in]constListArray of string => int mappings. Must be terminated with a nullptr string ({nullptr, -1}) line
See also
constListEntry_t

Definition at line 253 of file scripts.cpp.

References Com_RegisterConstInt(), i, name, constListEntry_s::name, and com_constNameInt_s::value.

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), GAME_SaveCharacter(), and TEST_F().

int Com_SetValue ( void base,
const void set,
valueTypes_t  type,
int  ofs,
size_t  size 
)
Parameters
[in]baseThe start pointer to a given data type (typedef, struct)
[in]setThe data which should be parsed
[in]typeThe data type that should be parsed
[in]ofsThe offset for the value
[in]sizeThe expected size of the data type. If 0, no checks are done
See also
Com_ValueToStr
Note
The offset is most likely given by the offsetof macro

Definition at line 1023 of file scripts.cpp.

References AIRCRAFT_NONE, Com_AlignPtr(), Com_GetCrashedUfoIdNum(), Com_GetHumanCraftIdNum(), Com_GetUfoIdNum(), Com_Printf(), int(), len, MAX_VAR, Q_streq, Q_strncpyz(), SHAPE_BIG_MAX_HEIGHT, SHAPE_SMALL_MAX_HEIGHT, Sys_Backtrace(), Sys_Error(), TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, UFO_NONE, UFO_SIZE_T, V_AIRCRAFTTYPE, V_ALIGN, V_BLEND, V_BOOL, V_CHAR, V_COLOR, V_DAMAGE, V_DATE, V_FADE, V_FLOAT, V_INT, V_INT2, V_LONGSTRING, V_NULL, V_POS, V_SHAPE_BIG, V_SHAPE_SMALL, V_STRING, V_STYLE, V_TEAM, V_UFO, V_UFOCRASHED, and V_VECTOR.

Referenced by CL_ParticleFunction(), and UI_NodeSetPropertyFromRAW().

void Com_Shutdown ( void  )

Definition at line 3754 of file scripts.cpp.

References OBJZERO, and versionParsed.

Referenced by Qcommon_Shutdown(), and TEST_Shutdown().

const char* Com_UFOCrashedTypeToShortName ( ufoType_t  type)

Translate UFO type to short name when UFO is crashed.

See also
Com_UFOTypeToShortName

Definition at line 3373 of file scripts.cpp.

References Com_ValueToStr(), and V_UFOCRASHED.

Referenced by GAME_GetImportData().

ufoType_t Com_UFOShortNameToID ( const char *  token)

Translate short name to UFO type.

See also
UFO_TypeToName
Com_UFOTypeToShortName

Definition at line 3351 of file scripts.cpp.

References Com_ParseValue(), and V_UFO.

Referenced by GAME_GetImportData().

const char* Com_UFOTypeToShortName ( ufoType_t  type)

Translate UFO type to short name.

See also
UFO_TypeToName
Com_UFOShortNameToID

Definition at line 3364 of file scripts.cpp.

References Com_ValueToStr(), and V_UFO.

Referenced by GAME_GetImportData().

bool Com_UnregisterConstList ( const constListEntry_t  constList[])

Unregisters a list of string aliases.

Parameters
[in]constListArray of string => int mappings. Must be terminated with a nullptr string ({nullptr, -1}) line
See also
constListEntry_t

Definition at line 237 of file scripts.cpp.

References Com_UnregisterConstVariable(), i, name, and constListEntry_s::name.

Referenced by GAME_GetImportData(), GAME_LoadCharacter(), GAME_SaveCharacter(), and TEST_F().

bool Com_UnregisterConstVariable ( const char *  name)

Removes a registered constant from the script mapping hash table.

Parameters
nameThe name of the script entry to remove out of the const int hash. In case this string is equipped with a namespace, the string is in the form "namespace::variable". If you try to unregister a variable that was registered with a namespace, this namespace must be included in the given name, too.
See also
Com_RegisterConstInt
Com_GetConstVariable

Definition at line 147 of file scripts.cpp.

References Com_ConstIntGetVariable(), com_constNameInt, Com_HashKey(), CONSTNAMEINT_HASH_SIZE, com_constNameInt_s::fullname, hash, com_constNameInt_s::hash_next, Mem_Free, com_constNameInt_s::next, and Q_streq.

Referenced by Com_UnregisterConstList(), GAME_GetImportData(), SV_InitGameProgs(), and TEST_F().

const char* Com_ValueToStr ( const void base,
const valueTypes_t  type,
const int  ofs 
)

Variable Documentation

const char* const align_names[]

Definition at line 341 of file scripts.cpp.

const char* const blend_names[]

Definition at line 346 of file scripts.cpp.

const char* const fade_names[]

Definition at line 356 of file scripts.cpp.

const char* const longlines_names[]
const char* const name_strings[]

Definition at line 2184 of file scripts.cpp.

Referenced by Com_FindNameType().

const char* const style_names[]

Definition at line 351 of file scripts.cpp.

const char* const vt_names[]

possible values for parsing functions

See also
valueTypes_t

Definition at line 310 of file scripts.cpp.

Referenced by CL_ParsePtlCmds(), and CL_ParticleFunction().