scripts.c File Reference

UFO scripts used in client and server. More...

#include "scripts.h"
#include "../shared/parse.h"
#include "../game/inventory.h"
Include dependency graph for scripts.c:

Go to the source code of this file.

Data Structures

struct  com_constNameInt_s
 Structure to map (script) strings and integer (enum) values. More...

Defines

#define CONSTNAMEINT_HASH_SIZE   32
#define MAX_CONSTNAMEINT_NAME   32
#define TERRAIN_HASH_SIZE   64

Typedefs

typedef struct com_constNameInt_s com_constNameInt_t
 Structure to map (script) strings and integer (enum) values.
typedef enum model_script_s model_script_t

Enumerations

enum  { OD_WEAPON, OD_PROTECTION, OD_RATINGS }
 

The order here must be the same as in od_vals.

More...
enum  model_script_s {
  MODEL_PATH, MODEL_BODY, MODEL_HEAD, MODEL_SKIN,
  MODEL_NUM_TYPES
}

Functions

static const char * Com_ConstIntGetVariable (const char *name)
 Will extract the variable from a string<=>int mapping string which contain a namespace.
qboolean Com_GetConstInt (const char *name, int *value)
 Searches whether a given value was registered as a string to int mapping.
qboolean Com_GetConstIntFromNamespace (const char *space, const char *variable, int *value)
 Searches whether a given value was registered as a string to int mapping.
const char * Com_GetConstVariable (const char *space, int value)
 Searches the mapping variable for a given integer value and a namespace.
qboolean Com_UnregisterConstVariable (const char *name)
 Removes a registered constant from the script mapping hash table.
void Com_RegisterConstInt (const char *name, int value)
 Register mappings between script strings and enum values for values of the type V_INT.
qboolean Com_UnregisterConstList (const constListEntry_t constList[])
 Unregisters a list of string aliases.
void Com_RegisterConstList (const constListEntry_t constList[])
 Registers a list of string aliases.
const char * Com_EParse (const char **text, const char *errhead, const char *errinfo)
 Parsing function that prints an error message when there is no text in the buffer.
static void Com_ParseVersion (const char *version)
 CASSERT (lengthof(vt_names)==V_NUM_TYPES)
 CASSERT (lengthof(align_names)==ALIGN_LAST)
 CASSERT (lengthof(blend_names)==BLEND_LAST)
 CASSERT (lengthof(style_names)==STYLE_LAST)
 CASSERT (lengthof(fade_names)==FADE_LAST)
 CASSERT (lengthof(vt_sizes)==V_NUM_TYPES)
 CASSERT (lengthof(vt_aligns)==V_NUM_TYPES)
const char * Com_GetLastParseError (void)
void * Com_AlignPtr (void *memory, valueTypes_t type)
 Align a memory to use a natural address for the data type we will write.
int Com_ParseValue (void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
 Parse a value from a string.
int Com_EParseValue (void *base, const char *token, valueTypes_t type, int ofs, size_t size)
qboolean Com_ParseBoolean (const char *token)
 Parses a boolean from a string.
int Com_SetValue (void *base, const void *set, valueTypes_t type, int ofs, size_t size)
const char * Com_ValueToStr (const void *base, const valueTypes_t type, const int ofs)
static void Com_ParseFire (const char *name, const char **text, fireDef_t *fd)
static void Com_ParseArmourOrResistance (const char *name, const char **text, short *ad, qboolean rating)
 Parses the armour definitions or the team resistance values from script files. The protection and rating values.
 CASSERT (lengthof(air_slot_type_strings)==MAX_ACITEMS)
static void Com_ParseItem (const char *name, const char **text)
 Parses weapon, equipment, craft items and armour.
static void Com_ParseInventory (const char *name, const char **text)
static void Com_ParseEquipment (const char *name, const char **text)
static const char * Com_GiveName (int gender, const teamDef_t *td)
static const char * Com_GiveModel (int type, int gender, const teamDef_t *td)
const char * Com_GetActorSound (teamDef_t *td, int gender, actorSound_t soundType)
 Returns the actor sounds for a given category.
teamDef_tCom_GetTeamDefinitionByID (const char *team)
 Returns the teamDef pointer for the searched team id - or NULL if not found in the teamDef array.
void Com_GetCharacterValues (const char *teamDefition, character_t *chr)
 Assign character values, 3D models and names to a character.
static void Com_ParseActorNames (const char *name, const char **text, teamDef_t *td)
 Parses "name" definition from team_* ufo script files.
static void Com_ParseActorModels (const char *name, const char **text, teamDef_t *td)
 Parses "actors" definition from team_* ufo script files.
static void Com_ParseActorSounds (const char *name, const char **text, teamDef_t *td)
 Parses "actorsounds" definition from team_* ufo script files.
static void Com_ParseTeam (const char *name, const char **text)
const chrTemplate_tCom_GetCharacterTemplateByID (const char *chrTemplate)
 Returns the chrTemplate pointer for the given id - or NULL if not found in the chrTemplates array.
static void Com_ParseUGVs (const char *name, const char **text)
 Parse 2x2 units (e.g. UGVs).
static void Com_ParseCharacterTemplate (const char *name, const char **text)
 Parses character templates from scripts.
const terrainType_tCom_GetTerrainType (const char *textureName)
 Searches the terrain definition if given.
static void Com_ParseTerrain (const char *name, const char **text)
 Parses "terrain" definition from script files.
static void Com_ParseGameTypes (const char *name, const char **text)
static void Com_ParseDamageTypes (const char *name, const char **text)
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.
humanAircraftType_t Com_DropShipShortNameToID (const char *token)
 Translate DropShip type to short name.
const char * Com_DropShipTypeToShortName (humanAircraftType_t type)
 Translate DropShip type to short name.
ufoType_t Com_UFOShortNameToID (const char *token)
 Translate UFO type to short name.
const char * Com_UFOTypeToShortName (ufoType_t type)
 Translate UFO type to short name.
const char * Com_UFOCrashedTypeToShortName (ufoType_t type)
 Translate UFO type to short name when UFO is crashed.
const ugv_tCom_GetUGVByIDSilent (const char *ugvID)
 Searches an UGV definition by a given script id and returns the pointer to the global data.
const ugv_tCom_GetUGVByID (const char *ugvID)
 Searches an UGV definition by a given script id and returns the pointer to the global data.
static void Com_AddObjectLinks (void)
 Creates links to other items (i.e. ammo<->weapons).
void Com_ParseScripts (qboolean onlyServer)
int Com_GetScriptChecksum (void)

Variables

static com_constNameInt_tcom_constNameInt
 Linked list of all the registeres mappings.
static com_constNameInt_tcom_constNameInt_hash [CONSTNAMEINT_HASH_SIZE]
 Hash of all the registeres mappings.
static qboolean versionParsed
const char *const vt_names []
 possible values for parsing functions
const char *const align_names []
const char *const blend_names []
const char *const style_names []
const char *const fade_names []
static const size_t vt_sizes []
 target sizes for buffer
static const size_t vt_aligns []
 natural align for each targets
static char parseErrorMessage [256]
static const char *const skillNames [SKILL_NUM_TYPES+1]
static const value_t od_vals []
static const value_t fdps []
const char *const air_slot_type_strings []
 List of valid strings for slot types.
static linkedList_tparseItemWeapons = NULL
 Temporary list of weapon ids as parsed from the ufo file "weapon_mod \<id\>" in Com_ParseItem and used in Com_AddObjectLinks.
static const value_t idps []
const char *const name_strings [NAME_NUM_TYPES]
static const value_t equipment_definition_vals []
 Valid equipment definition values from script files.
static const value_t teamDefValues []
 possible teamdesc values (ufo-scriptfiles)
static const value_t ugvValues []
static terrainType_tterrainTypesHash [TERRAIN_HASH_SIZE]
static const value_t terrainTypeValues []
gametype_t gts [MAX_GAMETYPES]
int numGTs = 0
static const value_t gameTypeValues []
 possible gametype values for the gameserver (ufo-scriptfiles)

Detailed Description

UFO scripts used in client and server.

Note:
interpreters for: object, inventory, equipment, name and team, damage

Definition in file scripts.c.


Define Documentation

#define CONSTNAMEINT_HASH_SIZE   32

Definition at line 28 of file scripts.c.

Referenced by Com_GetConstInt(), Com_RegisterConstInt(), and Com_UnregisterConstVariable().

#define MAX_CONSTNAMEINT_NAME   32

Definition at line 30 of file scripts.c.

#define TERRAIN_HASH_SIZE   64

Definition at line 2775 of file scripts.c.

Referenced by Com_GetTerrainType(), and Com_ParseTerrain().


Typedef Documentation

Structure to map (script) strings and integer (enum) values.


Enumeration Type Documentation

anonymous enum

The order here must be the same as in od_vals.

Enumerator:
OD_WEAPON 

parse a weapon

OD_PROTECTION 

parse armour protection values

OD_RATINGS 

parse rating values for displaying in the menus

Definition at line 1391 of file scripts.c.

Enumerator:
MODEL_PATH 
MODEL_BODY 
MODEL_HEAD 
MODEL_SKIN 
MODEL_NUM_TYPES 

Definition at line 1949 of file scripts.c.


Function Documentation

CASSERT ( lengthof(air_slot_type_strings = =MAX_ACITEMS  ) 
CASSERT ( lengthof(vt_aligns = =V_NUM_TYPES  ) 
CASSERT ( lengthof(vt_sizes = =V_NUM_TYPES  ) 
CASSERT ( lengthof(fade_names = =FADE_LAST  ) 
CASSERT ( lengthof(style_names = =STYLE_LAST  ) 
CASSERT ( lengthof(blend_names = =BLEND_LAST  ) 
CASSERT ( lengthof(align_names = =ALIGN_LAST  ) 
CASSERT ( lengthof(vt_names = =V_NUM_TYPES  ) 
static void Com_AddObjectLinks ( void   )  [static]
void* Com_AlignPtr ( 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 449 of file scripts.c.

References Sys_Error(), V_NULL, and V_NUM_TYPES.

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

static const char* Com_ConstIntGetVariable ( const char *  name  )  [static]

Will extract the variable from a string<=>int mapping string which contain a namespace.

Parameters:
name The name of the script entry to map to an integer
Returns:
The namespace in case one was found, NULL otherwise

Definition at line 53 of file scripts.c.

Referenced by Com_GetConstInt(), Com_RegisterConstInt(), and Com_UnregisterConstVariable().

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 3069 of file scripts.c.

References Com_ParseValue(), and V_AIRCRAFTTYPE.

Referenced by BS_AddAircraftToMarket(), BS_GetAircraftBuyingPrice(), BS_GetAircraftOnMarket(), BS_GetAircraftSellingPrice(), BS_LoadXML(), BS_RemoveAircraftFromMarket(), and Com_ParseEquipment().

const char* Com_DropShipTypeToShortName ( humanAircraftType_t  type  ) 

Translate DropShip type to short name.

See also:
Com_DropShipShortNameToID

Definition at line 3081 of file scripts.c.

References Com_ValueToStr(), and V_AIRCRAFTTYPE.

Referenced by B_SetUpFirstBase(), BS_InitMarket(), BS_SaveXML(), CL_CampaignRunMarket(), and GAME_InitMenuOptions().

const char* Com_EParse ( const char **  text,
const char *  errhead,
const char *  errinfo 
)
int Com_EParseValue ( void *  base,
const char *  token,
valueTypes_t  type,
int  ofs,
size_t  size 
)
const char* Com_GetActorSound ( teamDef_t td,
int  gender,
actorSound_t  soundType 
)

Returns the actor sounds for a given category.

Parameters:
[in] td teamDef pointer
[in] gender The gender of the actor
[in] soundType Which sound category (actorSound_t)

Definition at line 2154 of file scripts.c.

References Com_DPrintf(), linkedList_s::data, DEBUG_CLIENT, DEBUG_SOUND, teamDef_s::id, NAME_LAST, linkedList_s::next, teamDef_s::numSounds, random, and teamDef_s::sounds.

Referenced by CL_ActorPlaySound().

const chrTemplate_t* Com_GetCharacterTemplateByID ( const char *  chrTemplate  ) 

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

Parameters:
[in] team The character template id (given in ufo-script files)

Definition at line 2626 of file scripts.c.

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

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] teamDefition The team definition id to use to generate the character values.
[in,out] chr The character that should get the paths to the different models/skins.
See also:
Com_GiveName
Com_GiveModel

Definition at line 2208 of file scripts.c.

References ACTOR_SIZE_INVALID, ACTOR_SIZE_NORMAL, character_s::body, Com_Error(), Com_GetTeamDefinitionByID(), Com_GiveModel(), Com_GiveName(), ERR_DROP, character_s::fieldSize, character_s::gender, character_s::head, MODEL_BODY, MODEL_HEAD, MODEL_PATH, MODEL_SKIN, character_s::name, NAME_LAST, character_s::path, Q_strcat(), Q_strncpyz(), teamDef_s::size, character_s::skin, and character_s::teamDef.

Referenced by CL_GenerateCharacter(), and SV_InitGameProgs().

qboolean Com_GetConstInt ( const char *  name,
int *  value 
)

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

Parameters:
[in] name The name of the string mapping (maybe including a namespace)
[out] value The 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 70 of file scripts.c.

References Com_ConstIntGetVariable(), Com_HashKey(), CONSTNAMEINT_HASH_SIZE, com_constNameInt_s::fullname, hash(), com_constNameInt_s::hash_next, com_constNameInt_s::name, qfalse, qtrue, and com_constNameInt_s::value.

Referenced by Com_GetConstIntFromNamespace(), Com_ParseValue(), CP_LoadInterestsXML(), SV_InitGameProgs(), and testConstInt().

qboolean 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] space The namespace of the mapping variable
[in] variable The name of the string mapping
[out] value The 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.c.

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

Referenced by AIR_LoadAircraftXML(), B_LoadXML(), CL_LoadCharacterXML(), CP_LoadMissionsXML(), E_LoadXML(), INS_LoadXML(), MS_LoadXML(), RS_LoadXML(), SV_InitGameProgs(), and US_LoadXML().

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

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

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

Definition at line 122 of file scripts.c.

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

Referenced by AIR_SaveAircraftXML(), B_SaveXML(), CL_SaveCharacterXML(), CP_SaveInterestsXML(), CP_SaveMissionsXML(), E_SaveXML(), INS_SaveXML(), MS_MessageSaveXML(), RS_SaveXML(), SV_InitGameProgs(), testConstInt(), and US_SaveXML().

const char* Com_GetLastParseError ( void   ) 

Returns the last error message

Returns:
string that contains the last error message

Definition at line 440 of file scripts.c.

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
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 3058 of file scripts.c.

References va().

Referenced by CP_CreateBattleParameters(), GAME_InitMenuOptions(), GAME_SK_HideDropships(), and GAME_SK_HideUFOs().

int Com_GetScriptChecksum ( void   ) 

Definition at line 3298 of file scripts.c.

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

Referenced by CL_CanMultiplayerStart(), and SV_Map().

teamDef_t* Com_GetTeamDefinitionByID ( const char *  team  ) 

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

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

Definition at line 2188 of file scripts.c.

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

Referenced by AC_LoadXML(), AIR_LoadAircraftXML(), CL_LoadCharacterXML(), CL_ParseAlienTeam(), Com_GetCharacterValues(), GAME_ItemIsUseable(), and RS_AssignTechLinks().

const terrainType_t* Com_GetTerrainType ( const char *  textureName  ) 

Searches the terrain definition if given.

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

Definition at line 2792 of file scripts.c.

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

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

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] ugvID The script id of the UGV definition you are looking for
Returns:
ugv_t pointer or NULL if not found.

Definition at line 3144 of file scripts.c.

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

Referenced by E_InitialEmployees().

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] ugvID The script id of the UGV definition you are looking for
Returns:
ugv_t pointer or NULL if not found.
Note:
This function gives no warning on null name or if no ugv found

Definition at line 3124 of file scripts.c.

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

Referenced by Com_GetUGVByID(), E_LoadXML(), and UP_Article().

static const char* Com_GiveModel ( int  type,
int  gender,
const teamDef_t td 
) [static]
Parameters:
[in] type MODEL_PATH, MODEL_BODY, MODEL_HEAD, MODEL_SKIN (path, body, head, skin - see team_*.ufo)
[in] gender 1 (female) or 2 (male)
[in] td The team definition
See also:
Com_GetCharacterValues

Definition at line 2123 of file scripts.c.

References Com_Printf(), linkedList_s::data, teamDef_s::id, MODEL_NUM_TYPES, teamDef_s::models, linkedList_s::next, and teamDef_s::numModels.

Referenced by Com_GetCharacterValues().

static const char* Com_GiveName ( int  gender,
const teamDef_t td 
) [static]
Parameters:
[in] gender 1 (female) or 2 (male)
[in] td The team definition to get the name from
See also:
Com_GetCharacterValues

Definition at line 2086 of file scripts.c.

References Com_DPrintf(), linkedList_s::data, DEBUG_ENGINE, teamDef_s::id, name, NAME_NUM_TYPES, teamDef_s::names, linkedList_s::next, teamDef_s::numNames, and Sys_Error().

Referenced by Com_GetCharacterValues().

static void Com_ParseActorModels ( const char *  name,
const char **  text,
teamDef_t td 
) [static]

Parses "actors" definition from team_* ufo script files.

See also:
Com_ParseNames
Com_ParseScripts

Definition at line 2346 of file scripts.c.

References Com_EParse(), Com_Parse(), Com_Printf(), i, teamDef_s::id, LIST_AddString(), teamDef_s::models, NAME_NUM_TYPES, teamDef_s::numModels, and Sys_Error().

Referenced by Com_ParseTeam().

static void Com_ParseActorNames ( const char *  name,
const char **  text,
teamDef_t td 
) [static]

Parses "name" definition from team_* ufo script files.

See also:
Com_ParseActors
Com_ParseScripts

Definition at line 2271 of file scripts.c.

References Com_EParse(), Com_Parse(), Com_Printf(), i, teamDef_s::id, LIST_AddString(), NAME_FEMALE, NAME_FEMALE_LAST, NAME_LAST, NAME_MALE, NAME_MALE_LAST, NAME_NEUTRAL, NAME_NUM_TYPES, teamDef_s::names, teamDef_s::numNames, and Sys_Error().

Referenced by Com_ParseTeam().

static void Com_ParseActorSounds ( const char *  name,
const char **  text,
teamDef_t td 
) [static]

Parses "actorsounds" definition from team_* ufo script files.

See also:
Com_ParseNames
Com_ParseScripts

Definition at line 2425 of file scripts.c.

References Com_EParse(), Com_Parse(), Com_Printf(), i, LIST_AddString(), NAME_LAST, NAME_NUM_TYPES, teamDef_s::numSounds, SND_DEATH, SND_HURT, and teamDef_s::sounds.

Referenced by Com_ParseTeam().

static void Com_ParseArmourOrResistance ( const char *  name,
const char **  text,
short *  ad,
qboolean  rating 
) [static]

Parses the armour definitions or the team resistance values from script files. The protection and rating values.

Note:
The rating values are just for menu displaying
See also:
Com_ParseItem

Definition at line 1575 of file scripts.c.

References Com_EParse(), Com_Parse(), Com_Printf(), csi, csi_s::dts, i, damageType_s::id, csi_s::numDTs, damageType_s::showInMenu, and Sys_Error().

Referenced by Com_ParseItem(), and Com_ParseTeam().

qboolean Com_ParseBoolean ( const char *  token  ) 

Parses a boolean from a string.

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

Definition at line 895 of file scripts.c.

References Com_ParseValue(), qfalse, RESULT_ERROR, and V_BOOL.

Referenced by GAME_CP_Results_f(), and HUD_RemainingTUs_f().

static void Com_ParseCharacterTemplate ( const char *  name,
const char **  text 
) [static]
static void Com_ParseDamageTypes ( const char *  name,
const char **  text 
) [static]
static void Com_ParseEquipment ( const char *  name,
const char **  text 
) [static]
static void Com_ParseFire ( const char *  name,
const char **  text,
fireDef_t fd 
) [static]
static void Com_ParseGameTypes ( const char *  name,
const char **  text 
) [static]
static void Com_ParseInventory ( const char *  name,
const char **  text 
) [static]
static void Com_ParseItem ( const char *  name,
const char **  text 
) [static]
void Com_ParseScripts ( qboolean  onlyServer  ) 
static void Com_ParseTeam ( const char *  name,
const char **  text 
) [static]
static void Com_ParseTerrain ( const char *  name,
const char **  text 
) [static]
static void Com_ParseUGVs ( const char *  name,
const char **  text 
) [static]
int 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] base The start pointer to a given data type (typedef, struct) where the parsed data is stored
[in] token The data which should be parsed
[in] type The data type that should be parsed
[in] ofs The offset for the value
[in] size The 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 472 of file scripts.c.

References ALIGN_LAST, BLEND_LAST, byte, Com_GetConstInt(), csi, DAYS_PER_YEAR, DROPSHIP_FIREBIRD, DROPSHIP_HERAKLES, DROPSHIP_RAPTOR, csi_s::dts, f, FADE_LAST, i, damageType_s::id, int(), INTERCEPTOR_DRAGON, INTERCEPTOR_SARACEN, INTERCEPTOR_STARCHASER, INTERCEPTOR_STILETTO, INTERCEPTOR_STINGRAY, MAX_VAR, csi_s::numDTs, Q_strncpyz(), qfalse, qtrue, RACE_BLOODSPIDER, RACE_CIVILIAN, RACE_ORTNOK, RACE_PHALANX_HUMAN, RACE_ROBOT, RACE_SHEVAAR, RACE_TAMAN, 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, UFO_BOMBER, UFO_CARRIER, UFO_CORRUPTER, UFO_FIGHTER, UFO_GUNBOAT, UFO_HARVESTER, UFO_MOTHERSHIP, UFO_RIPPER, UFO_SCOUT, UFO_SIZE_T, UFO_SUPPLY, V_AIRCRAFTTYPE, V_ALIGN, V_BLEND, V_BOOL, V_CHAR, V_CLIENT_HUNK, V_CLIENT_HUNK_STRING, V_COLOR, V_DATE, V_DMGTYPE, V_DMGWEIGHT, V_FADE, V_FLOAT, V_INT, V_INT2, V_LONGSTRING, V_NULL, V_POS, V_RACE, V_RELABS, V_RGBA, 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(), UI_MaterialEditorChangeValue_f(), UI_NodeSetProperty(), UI_ParseProperty(), and UI_PushDropDownWindow_f().

static void Com_ParseVersion ( const char *  version  )  [static]

Definition at line 294 of file scripts.c.

References qtrue, Sys_Error(), UFO_VERSION, and versionParsed.

Referenced by Com_ParseScripts().

void Com_RegisterConstInt ( const char *  name,
int  value 
)

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

Parameters:
name The 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"
value The 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 204 of file scripts.c.

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

Referenced by Com_RegisterConstList(), SV_InitGameProgs(), testConstInt(), UI_RegisterAbstractNode(), UI_RegisterBaseInventoryNode(), UI_RegisterPanelNode(), and UI_RegisterTextNode().

void Com_RegisterConstList ( const constListEntry_t  constList[]  ) 
int Com_SetValue ( void *  base,
const void *  set,
valueTypes_t  type,
int  ofs,
size_t  size 
)
Parameters:
[in] base The start pointer to a given data type (typedef, struct)
[in] set The data which should be parsed
[in] type The data type that should be parsed
[in] ofs The offset for the value
[in] size The 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 918 of file scripts.c.

References byte, Com_Printf(), DROPSHIP_FIREBIRD, DROPSHIP_HERAKLES, DROPSHIP_RAPTOR, int(), INTERCEPTOR_DRAGON, INTERCEPTOR_SARACEN, INTERCEPTOR_STARCHASER, INTERCEPTOR_STILETTO, INTERCEPTOR_STINGRAY, len, MAX_VAR, Q_strncpyz(), qfalse, qtrue, RACE_BLOODSPIDER, RACE_CIVILIAN, RACE_ORTNOK, RACE_PHALANX_HUMAN, RACE_ROBOT, RACE_SHEVAAR, RACE_TAMAN, SHAPE_BIG_MAX_HEIGHT, SHAPE_SMALL_MAX_HEIGHT, Sys_Error(), TEAM_ALIEN, TEAM_CIVILIAN, TEAM_PHALANX, UFO_BOMBER, UFO_CARRIER, UFO_CORRUPTER, UFO_FIGHTER, UFO_GUNBOAT, UFO_HARVESTER, UFO_MOTHERSHIP, UFO_RIPPER, UFO_SCOUT, UFO_SIZE_T, UFO_SUPPLY, V_AIRCRAFTTYPE, V_ALIGN, V_BLEND, V_BOOL, V_CHAR, V_COLOR, V_DATE, V_DMGTYPE, V_DMGWEIGHT, V_FADE, V_FLOAT, V_INT, V_INT2, V_LONGSTRING, V_NULL, V_POS, V_RACE, V_RGBA, 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().

const char* Com_UFOCrashedTypeToShortName ( ufoType_t  type  ) 

Translate UFO type to short name when UFO is crashed.

See also:
Com_UFOTypeToShortName

Definition at line 3113 of file scripts.c.

References Com_ValueToStr(), and V_UFOCRASHED.

Referenced by CP_CreateBattleParameters(), CP_MapIsSelectable(), and GAME_InitMenuOptions().

ufoType_t Com_UFOShortNameToID ( const char *  token  ) 

Translate UFO type to short name.

See also:
UFO_TypeToName
Com_UFOTypeToShortName

Definition at line 3091 of file scripts.c.

References Com_ParseValue(), and V_UFO.

Referenced by AIR_ParseAircraft().

const char* Com_UFOTypeToShortName ( ufoType_t  type  ) 
qboolean Com_UnregisterConstList ( const constListEntry_t  constList[]  ) 
qboolean Com_UnregisterConstVariable ( const char *  name  ) 

Removes a registered constant from the script mapping hash table.

Parameters:
name The 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 148 of file scripts.c.

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

Referenced by Com_UnregisterConstList(), SV_InitGameProgs(), and testConstInt().

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

Variable Documentation

const char* const air_slot_type_strings[]
Initial value:
 {
    "base_missile",
    "base_laser",
    "weapon",
    "shield",
    "electronics",
    "pilot",
    "ammo",
    "base_ammo_missile",
    "base_ammo_laser"
}

List of valid strings for slot types.

Note:
slot names are the same as the item types (and must be in the same order)

Definition at line 1621 of file scripts.c.

Referenced by AIR_ParseAircraft().

const char* const align_names[]
Initial value:
 {
    "ul", "uc", "ur", "cl", "cc", "cr", "ll", "lc", "lr", "ul_rsl", "uc_rsl", "ur_rsl", "cl_rsl", "cc_rsl", "cr_rsl", "ll_rsl", "lc_rsl", "lr_rsl"
}

Definition at line 344 of file scripts.c.

const char* const blend_names[]
Initial value:
 {
    "replace", "one", "blend", "add", "filter", "invfilter"
}

Definition at line 349 of file scripts.c.

Linked list of all the registeres mappings.

Definition at line 44 of file scripts.c.

com_constNameInt_t* com_constNameInt_hash[CONSTNAMEINT_HASH_SIZE] [static]

Hash of all the registeres mappings.

Definition at line 46 of file scripts.c.

Initial value:
 {
    {"mininterest", V_INT, offsetof(equipDef_t, minInterest), 0},
    {"maxinterest", V_INT, offsetof(equipDef_t, maxInterest), 0},

    {NULL, 0, 0, 0}
}

Valid equipment definition values from script files.

Definition at line 1968 of file scripts.c.

const char* const fade_names[]
Initial value:
 {
    "none", "in", "out", "sin", "saw"
}

Definition at line 359 of file scripts.c.

const value_t fdps[] [static]

Definition at line 1460 of file scripts.c.

const value_t gameTypeValues[] [static]
Initial value:
 {
    {"name", V_TRANSLATION_STRING, offsetof(gametype_t, name), 0}, 
    {NULL, 0, 0, 0}
}

possible gametype values for the gameserver (ufo-scriptfiles)

Definition at line 2881 of file scripts.c.

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

const value_t idps[] [static]
Initial value:
 {
    {"shape", V_SHAPE_BIG, offsetof(invDef_t, shape), 0},
    
    {"single", V_BOOL, offsetof(invDef_t, single), MEMBER_SIZEOF(invDef_t, single)},
    
    {"scroll", V_BOOL, offsetof(invDef_t, scroll), MEMBER_SIZEOF(invDef_t, scroll)},
    
    {"extension", V_BOOL, offsetof(invDef_t, extension), MEMBER_SIZEOF(invDef_t, extension)},
    
    {"armour", V_BOOL, offsetof(invDef_t, armour), MEMBER_SIZEOF(invDef_t, armour)},
    
    {"headgear", V_BOOL, offsetof(invDef_t, headgear), MEMBER_SIZEOF(invDef_t, headgear)},
    
    {"all", V_BOOL, offsetof(invDef_t, all), MEMBER_SIZEOF(invDef_t, all)},
    {"temp", V_BOOL, offsetof(invDef_t, temp), MEMBER_SIZEOF(invDef_t, temp)},
    
    {"in", V_INT, offsetof(invDef_t, in), MEMBER_SIZEOF(invDef_t, in)},
    
    {"out", V_INT, offsetof(invDef_t, out), MEMBER_SIZEOF(invDef_t, out)},

    {NULL, 0, 0, 0}
}

Definition at line 1824 of file scripts.c.

const char* const name_strings[NAME_NUM_TYPES]
Initial value:
 {
    "neutral",
    "female",
    "male",
    "lastname",
    "female_lastname",
    "male_lastname"
}

Definition at line 1958 of file scripts.c.

int numGTs = 0

Definition at line 2878 of file scripts.c.

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

const value_t od_vals[] [static]
Note:
Make sure, that you don't change the order of the first entries or you have the change the enum values OD_*, too

Definition at line 1401 of file scripts.c.

char parseErrorMessage[256] [static]

Definition at line 434 of file scripts.c.

linkedList_t* parseItemWeapons = NULL [static]

Temporary list of weapon ids as parsed from the ufo file "weapon_mod \<id\>" in Com_ParseItem and used in Com_AddObjectLinks.

Definition at line 1639 of file scripts.c.

const char* const skillNames[SKILL_NUM_TYPES+1] [static]
Initial value:
 {
    "strength",
    "speed",
    "accuracy",
    "mind",
    "close",
    "heavy",
    "assault",
    "sniper",
    "explosive",
    "health"
}

Definition at line 1377 of file scripts.c.

const char* const style_names[]
Initial value:
 {
    "facing", "rotated", "beam", "line", "axis", "circle"
}

Definition at line 354 of file scripts.c.

const value_t teamDefValues[] [static]
Initial value:
 {
    {"tech", V_STRING, offsetof(teamDef_t, tech), 0}, 
    {"name", V_TRANSLATION_STRING, offsetof(teamDef_t, name), 0}, 
    {"armour", V_BOOL, offsetof(teamDef_t, armour), MEMBER_SIZEOF(teamDef_t, armour)}, 
    {"weapons", V_BOOL, offsetof(teamDef_t, weapons), MEMBER_SIZEOF(teamDef_t, weapons)}, 
    {"size", V_INT, offsetof(teamDef_t, size), MEMBER_SIZEOF(teamDef_t, size)}, 
    {"hit_particle", V_STRING, offsetof(teamDef_t, hitParticle), 0}, 
    {"death_texture", V_STRING, offsetof(teamDef_t, deathTextureName), 0},
    {"race", V_RACE, offsetof(teamDef_t, race), MEMBER_SIZEOF(teamDef_t, race)},

    {NULL, 0, 0, 0}
}

possible teamdesc values (ufo-scriptfiles)

Definition at line 2488 of file scripts.c.

terrainType_t* terrainTypesHash[TERRAIN_HASH_SIZE] [static]

Definition at line 2776 of file scripts.c.

const value_t terrainTypeValues[] [static]
Initial value:
 {
    {"footstepsound", V_STRING, offsetof(terrainType_t, footStepSound), 0},
    {"particle", V_STRING, offsetof(terrainType_t, particle), 0},
    {"footstepvolume", V_FLOAT, offsetof(terrainType_t, footStepVolume), 0},
    {"bouncefraction", V_FLOAT, offsetof(terrainType_t, bounceFraction), 0},

    {NULL, 0, 0, 0}
}

Definition at line 2778 of file scripts.c.

const value_t ugvValues[] [static]
Initial value:
 {
    {"tu", V_INT, offsetof(ugv_t, tu), MEMBER_SIZEOF(ugv_t, tu)},
    {"weapon", V_STRING, offsetof(ugv_t, weapon), 0},
    {"armour", V_STRING, offsetof(ugv_t, armour), 0},
    {"actors", V_STRING, offsetof(ugv_t, actors), 0},
    {"price", V_INT, offsetof(ugv_t, price), 0},

    {NULL, 0, 0, 0}
}

Definition at line 2639 of file scripts.c.

Definition at line 292 of file scripts.c.

Referenced by Com_ParseScripts(), and Com_ParseVersion().

const size_t vt_aligns[] [static]

natural align for each targets

Definition at line 400 of file scripts.c.

const char* const vt_names[]

possible values for parsing functions

See also:
valueTypes_t

Definition at line 310 of file scripts.c.

Referenced by CL_ParsePtlCmds(), and CL_ParticleFunction().

const size_t vt_sizes[] [static]

target sizes for buffer

Definition at line 365 of file scripts.c.


Generated by  doxygen 1.6.2