TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
tgf.h File Reference


The Gaming Framework API. More...

#include <stdio.h>
#include <sys/param.h>
#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <cstring>
#include <math.h>
#include <osspec.h>
Include dependency graph for tgf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  t3Df
struct  t3Dd
 3D point. More...
struct  t3Di
struct  tPosd
 6 DOF position. More...
struct  tDynPt
 Dynamic point structure. More...
struct  tForces
 Forces and moments. More...
struct  ModInfo
 Module information structure. More...
struct  ModList
 list of module interfaces More...
struct  FList
 List of (DLL) files for a Directory. More...
struct  tMeanVal

Macros

#define MAX(x, y)
#define MIN(x, y)
#define FREEZ(x)
#define freez   FREEZ
#define RADS2RPM(x)
 Radian/s to RPM conversion.
#define RPM2RADS(x)
 RPM to Radian/s conversion.
#define RAD2DEG(x)
 Radian to degree conversion.
#define DEG2RAD(x)
 Degree to radian conversion.
#define FEET2M(x)
 Feet to meter conversion.
#define SIGN(x)
 Sign of the expression.
#define NORM0_2PI(x)
 Angle normalization between 0 and 2 * PI.
#define NORM_PI_PI(x)
 Angle normalization between -PI and PI.
#define DIST(x1, y1, x2, y2)
 Distance between two points.
#define MAX_MOD_ITF   10
 Maximum number of interface in one DLL.
#define GFPARM_PARAMETER   0
 Parameter file.
#define GFPARM_TEMPLATE   1
 Template file.
#define GFPARM_PARAM_STR   "param"
#define GFPARM_TEMPL_STR   "template"
#define GFPARM_MODIFIABLE   1
 Parameter file allowed to be modified.
#define GFPARM_WRITABLE   2
 Parameter file allowed to be saved on disk.
#define GFPARM_RMODE_STD   0x01
 Return a new handle sharing cached data for this filename, if available.
#define GFPARM_RMODE_REREAD   0x02
 Clear shared cached data and reread the file.
#define GFPARM_RMODE_CREAT   0x04
 Allow an empty in-memory set on file-open failure; does not write a file.
#define GFPARM_RMODE_PRIVATE   0x08
 Private means the handle is not shared/cached.
#define GFPARM_MMODE_SRC   1
 Include ref attributes; merge common attributes using ref restrictions and tgt values.
#define GFPARM_MMODE_DST   2
 Include tgt attributes; merge common attributes using ref restrictions and tgt values.
#define GFPARM_MMODE_RELSRC   4
 release ref after the merge
#define GFPARM_MMODE_RELDST   8
 release tgt after the merge
#define GfTrace   printf
#define GfError   printf
#define GfOut   printf
#define GF_MEAN_MAX_VAL   5
#define GF_TAILQ_HEAD(name, type)
 Head type definition.
#define GF_TAILQ_ENTRY(type)
 Entry in structure.
#define GF_TAILQ_FIRST(head)
 First element of a TAILQ.
#define GF_TAILQ_NEXT(elm, field)
 Next element of a TAILQ.
#define GF_TAILQ_END(head)
 End of a TAILQ.
#define GF_TAILQ_LAST(head, headname)
 Last element of a TAILQ.
#define GF_TAILQ_PREV(elm, headname, field)
 Previous element of a TAILQ.
#define GF_TAILQ_INIT(head)
 Head initialization (Mandatory)
#define GF_TAILQ_INIT_ENTRY(elm, field)
 Entry initialization (optionnal if inserted)
#define GF_TAILQ_INSERT_HEAD(head, elm, field)
 Insert an element at the head.
#define GF_TAILQ_INSERT_TAIL(head, elm, field)
 Insert an element at the tail.
#define GF_TAILQ_INSERT_AFTER(head, listelm, elm, field)
 Insert an element after another element.
#define GF_TAILQ_INSERT_BEFORE(listelm, elm, field)
 Insert an element before another element.
#define GF_TAILQ_REMOVE(head, elm, field)
 Remove an element.
#define START_PROFILE(a)
#define STOP_PROFILE(a)
#define STOP_ACTIVE_PROFILES()
#define PRINT_PROFILE()
#define GF_HASH_TYPE_STR   0
 String key based hash table.
#define GF_HASH_TYPE_BUF   1
 Memory buffer key based hash table.
#define GF_DIR_CREATION_FAILED   0
#define GF_DIR_CREATED   1

Typedefs

typedef float tdble
 Floating point type used in TORCS.
typedef int(* tfModPrivInit) (int index, void *)
 initialisation of the function table
typedef struct ModInfo tModInfo
 Module information structure.
typedef int(* tfModInfo) (tModInfo *)
typedef struct ModList tModList
 list of module interfaces
typedef struct FList tFList
 List of (DLL) files for a Directory.
typedef void(* tfDirfreeUserData) (void *)
 Function to call for releasing the user data associated with file entry.
typedef void(* tfHashFree) (const void *)
 Function to call for releasing the user data associated with hash table.

Functions

void GfInit (void)
int GfModLoad (unsigned int gfid, char *dllname, tModList **modlist)
 Load the specified DLLs.
int GfModLoadDir (unsigned int gfid, char *dir, tModList **modlist)
 Load the DLLs in the specified directory.
int GfModUnloadList (tModList **modlist)
 Unload the DLLs of a list.
int GfModInfo (unsigned int gfid, char *filename, tModList **modlist)
 Get the generic information of the specified DLL.
int GfModInfoDir (unsigned int gfid, char *dir, int level, tModList **modlist)
 Get the generic module information of the DLLs of the specified directory.
int GfModFreeInfoList (tModList **modlist)
 Free the info contained in the specified list.
tFList * GfDirGetList (const char *dir)
 Get the list of files of a given directory.
tFList * GfDirGetListFiltered (const char *dir, const char *suffix)
 Get the list of files with matching suffix of a given directory.
void GfDirFreeList (tFList *list, tfDirfreeUserData freeUserDatabool, bool freename=false, bool freedispname=false)
 Free a directory list.
void * GfParmReadFile (const char *file, int mode)
 Read parameter set from file and return handle to parameter set.
int GfParmWriteFile (const char *file, void *handle, const char *name)
 Write parameter set into file.
int GfParmCreateDirectory (const char *file, void *parmHandle)
 Create directory for parameter set handle if it does not yet exist.
char * GfParmGetName (void *handle)
 Get the name property of the parameter set handle.
char * GfParmGetFileName (void *handle)
 Get the filename property of the parameter set handle.
void GfParmSetDTD (void *parmHandle, char *dtd, char *header)
 Set the dtd path and header.
const char * GfParmGetStr (void *handle, const char *path, const char *key, const char *deflt)
 Get a string parameter from the parameter set handle.
const char * GfParmGetCurStr (void *handle, const char *path, const char *key, const char *deflt)
 Get a string parameter from the parameter set handle based on subsection iteration.
int GfParmSetStr (void *handle, const char *path, const char *key, const char *val)
 Set a string parameter in the parameter set handle.
int GfParmSetCurStr (void *handle, const char *path, const char *key, const char *val)
 Set a string parameter in the parameter set handle based on subsection iteration.
tdble GfParmGetNum (void *handle, const char *path, const char *key, const char *unit, tdble deflt)
 Get a numerical parameter from the parameter set handle.
tdble GfParmGetCurNum (void *handle, const char *path, const char *key, const char *unit, tdble deflt)
 Get a numerical parameter from the parameter set handle based on subsection iteration.
int GfParmSetNum (void *handle, const char *path, const char *key, const char *unit, tdble val)
 Set a numerical parameter in the parameter set handle.
int GfParmSetNumEx (void *handle, const char *path, const char *key, const char *unit, tdble val, tdble min, tdble max)
 Set a numerical parameter and its bounds, creating it if necessary.
int GfParmSetCurNum (void *handle, const char *path, const char *key, const char *unit, tdble val)
 Set a numerical parameter in the parameter set handle based on subsection iteration.
void GfParmClean (void *handle)
 Clean all the parameters of a parameter set.
void GfParmReleaseHandle (void *handle)
 Release given parameter set handle parmHandle.
tdble GfParmUnit2SI (const char *unit, tdble val)
 Convert a value given in unit to SI.
tdble GfParmSI2Unit (const char *unit, tdble val)
 Convert a value from SI to given unit.
int GfParmCheckHandle (void *ref, void *tgt)
 Check the values in the parameter set tgt against the min/max/within definitions in the ref parameter set.
void * GfParmMergeHandles (void *ref, void *tgt, int mode)
 Merge two parameter sets into a new private set.
int GfParmGetNumBoundaries (void *handle, const char *path, const char *key, tdble *min, tdble *max)
 Get the min and max of a numerical parameter from the parameter set handle.
int GfParmGetEltNb (void *handle, const char *path)
 Count the number of subsections in a section in the parameter set handle.
int GfParmListSeekFirst (void *handle, const char *path)
 Select the first immediate subsection of a section.
int GfParmListSeekNext (void *handle, const char *path)
 Advance to the next immediate subsection.
char * GfParmListGetCurEltName (void *handle, const char *path)
 Get current subsection name of the parameter set handle during subsection iteration.
int GfParmListClean (void *handle, const char *path)
 Remove all the subsections in a section in the parameter set handle.
static void GfFatal (const char *fmt,...)
double GfTimeClock (void)
 Get the time in seconds.
tdble gfMean (tdble v, tMeanVal *pvt, int n, int w)
void gfMeanReset (tdble v, tMeanVal *pvt)
char * GetLocalDir (void)
void SetLocalDir (char *buf)
char * GetLibDir (void)
void SetLibDir (char *buf)
char * GetDataDir (void)
void SetDataDir (char *buf)
int GetSingleTextureMode (void)
void SetSingleTextureMode (void)
int GfNearestPow2 (int x)
int GfCreateDir (char *path)
 Create directory for given path recursively, so all missing parent directories are created as well.
int GfCreateDirForFile (const char *filenameandpath)
 Create directory for given file path recursively, so all missing parent directories are created as well.
void * GfHashCreate (int type)
 Create a new hash table.
int GfHashAddStr (void *hash, const char *key, const void *data)
 Add an element with a string key to a hash table.
const void * GfHashRemStr (void *hash, char *key)
 Remove an element with a string key from a hash table.
const void * GfHashGetStr (void *hash, const char *key)
 Get the user data associated with a string key.
void GfHashAddBuf (void *hash, char *key, size_t sz, void *data)
 Add an element with a memory buffer key to a hash table.
const void * GfHashRemBuf (void *hash, char *key, size_t sz)
 Remove an element with a memory buffer key from a hash table.
const void * GfHashGetBuf (void *hash, char *key, size_t sz)
 Get the user data associated with a memory buffer key.
void GfHashRelease (void *hash, tfHashFree hashFree)
 Release a hash table.
const void * GfHashGetFirst (void *hash)
 Get the first user data of a hash table, this is used for table scans.
const void * GfHashGetNext (void *hash)
 Get the next user data of a hash table, this is used for table scans.

Variables

const double PI = 3.14159265358979323846
 PI.
const tdble G = 9.80665f
 m/s/s

Detailed Description


The Gaming Framework API.

Author
Bernhard Wymann, Eric Espie

Definition in file tgf.h.

Macro Definition Documentation

◆ DEG2RAD

#define DEG2RAD ( x)
Value:
((x)*(PI/180.0))
static const double PI

Degree to radian conversion.

Definition at line 75 of file tgf.h.

◆ DIST

#define DIST ( x1,
y1,
x2,
y2 )
Value:
sqrt(((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))

Distance between two points.

Definition at line 96 of file tgf.h.

◆ FEET2M

#define FEET2M ( x)
Value:
((x)*0.304801)

Feet to meter conversion.

Definition at line 76 of file tgf.h.

◆ FREEZ

#define FREEZ ( x)
Value:
do { \
if (x) { \
free(x); \
x = 0; \
} \
} while (0)

Definition at line 59 of file tgf.h.

◆ freez

#define freez   FREEZ

Definition at line 66 of file tgf.h.

◆ GF_DIR_CREATED

#define GF_DIR_CREATED   1

Definition at line 622 of file tgf.h.

◆ GF_DIR_CREATION_FAILED

#define GF_DIR_CREATION_FAILED   0

Definition at line 621 of file tgf.h.

◆ GF_HASH_TYPE_BUF

#define GF_HASH_TYPE_BUF   1

Memory buffer key based hash table.

Definition at line 606 of file tgf.h.

◆ GF_HASH_TYPE_STR

#define GF_HASH_TYPE_STR   0

String key based hash table.

Definition at line 605 of file tgf.h.

◆ GF_MEAN_MAX_VAL

#define GF_MEAN_MAX_VAL   5

Definition at line 382 of file tgf.h.

◆ GfError

#define GfError   printf

Definition at line 350 of file tgf.h.

◆ GfOut

#define GfOut   printf

Definition at line 372 of file tgf.h.

◆ GFPARM_MMODE_DST

#define GFPARM_MMODE_DST   2

Include tgt attributes; merge common attributes using ref restrictions and tgt values.

Definition at line 313 of file tgf.h.

◆ GFPARM_MMODE_RELDST

#define GFPARM_MMODE_RELDST   8

release tgt after the merge

Definition at line 315 of file tgf.h.

◆ GFPARM_MMODE_RELSRC

#define GFPARM_MMODE_RELSRC   4

release ref after the merge

Definition at line 314 of file tgf.h.

◆ GFPARM_MMODE_SRC

#define GFPARM_MMODE_SRC   1

Include ref attributes; merge common attributes using ref restrictions and tgt values.

Definition at line 312 of file tgf.h.

◆ GFPARM_MODIFIABLE

#define GFPARM_MODIFIABLE   1

Parameter file allowed to be modified.

Definition at line 260 of file tgf.h.

◆ GFPARM_PARAM_STR

#define GFPARM_PARAM_STR   "param"

Definition at line 256 of file tgf.h.

◆ GFPARM_PARAMETER

#define GFPARM_PARAMETER   0

Parameter file.

Definition at line 254 of file tgf.h.

◆ GFPARM_RMODE_CREAT

#define GFPARM_RMODE_CREAT   0x04

Allow an empty in-memory set on file-open failure; does not write a file.

Definition at line 266 of file tgf.h.

◆ GFPARM_RMODE_PRIVATE

#define GFPARM_RMODE_PRIVATE   0x08

Private means the handle is not shared/cached.

Definition at line 267 of file tgf.h.

◆ GFPARM_RMODE_REREAD

#define GFPARM_RMODE_REREAD   0x02

Clear shared cached data and reread the file.

Definition at line 265 of file tgf.h.

◆ GFPARM_RMODE_STD

#define GFPARM_RMODE_STD   0x01

Return a new handle sharing cached data for this filename, if available.

Definition at line 264 of file tgf.h.

◆ GFPARM_TEMPL_STR

#define GFPARM_TEMPL_STR   "template"

Definition at line 257 of file tgf.h.

◆ GFPARM_TEMPLATE

#define GFPARM_TEMPLATE   1

Template file.

Definition at line 255 of file tgf.h.

◆ GFPARM_WRITABLE

#define GFPARM_WRITABLE   2

Parameter file allowed to be saved on disk.

Definition at line 261 of file tgf.h.

◆ GfTrace

#define GfTrace   printf

Definition at line 335 of file tgf.h.

◆ MAX

#define MAX ( x,
y )
Value:
((x) > (y) ? (x) : (y))
static Vector y[4]
Definition Convex.cpp:56

Definition at line 52 of file tgf.h.

◆ MAX_MOD_ITF

#define MAX_MOD_ITF   10

Maximum number of interface in one DLL.

See also
ModList

Definition at line 184 of file tgf.h.

◆ MIN

#define MIN ( x,
y )
Value:
((x) < (y) ? (x) : (y))

Definition at line 56 of file tgf.h.

◆ NORM0_2PI

#define NORM0_2PI ( x)
Value:
do { \
while ((x) > 2.0*PI) { (x) -= (tdble) (2.0*PI); } \
while ((x) < 0.0) { (x) += (tdble) (2.0*PI); } \
} while (0)
float tdble
Floating point type used in TORCS.
Definition tgf.h:47

Angle normalization between 0 and 2 * PI.

Definition at line 80 of file tgf.h.

◆ NORM_PI_PI

#define NORM_PI_PI ( x)
Value:
do { \
while ((x) > PI) { (x) -= (tdble) (2.0*PI); } \
while ((x) < -PI) { (x) += (tdble) (2.0*PI); } \
} while (0)

Angle normalization between -PI and PI.

Definition at line 87 of file tgf.h.

◆ PRINT_PROFILE

#define PRINT_PROFILE ( )

Definition at line 599 of file tgf.h.

◆ RAD2DEG

#define RAD2DEG ( x)
Value:
((x)*(180.0/PI))

Radian to degree conversion.

Definition at line 74 of file tgf.h.

◆ RADS2RPM

#define RADS2RPM ( x)
Value:
((x)*9.549296585)

Radian/s to RPM conversion.

Definition at line 72 of file tgf.h.

◆ RPM2RADS

#define RPM2RADS ( x)
Value:
((x)*.104719755)

RPM to Radian/s conversion.

Definition at line 73 of file tgf.h.

◆ SIGN

#define SIGN ( x)
Value:
((x) < 0.0f ? -1.0f : 1.0f)

Sign of the expression.

Definition at line 77 of file tgf.h.

◆ START_PROFILE

#define START_PROFILE ( a)

Definition at line 596 of file tgf.h.

◆ STOP_ACTIVE_PROFILES

#define STOP_ACTIVE_PROFILES ( )

Definition at line 598 of file tgf.h.

◆ STOP_PROFILE

#define STOP_PROFILE ( a)

Definition at line 597 of file tgf.h.

Typedef Documentation

◆ tfDirfreeUserData

typedef void(* tfDirfreeUserData) (void *)

Function to call for releasing the user data associated with file entry.

Definition at line 239 of file tgf.h.

◆ tfHashFree

typedef void(* tfHashFree) (const void *)

Function to call for releasing the user data associated with hash table.

Definition at line 608 of file tgf.h.

◆ tFList

typedef struct FList tFList

List of (DLL) files for a Directory.

See also
GfDirGetList

◆ tfModInfo

typedef int(* tfModInfo) (tModInfo *)

Definition at line 199 of file tgf.h.

◆ tfModPrivInit

typedef int(* tfModPrivInit) (int index, void *)

initialisation of the function table

See also
ModInfo

Definition at line 179 of file tgf.h.

◆ tModInfo

typedef struct ModInfo tModInfo

Module information structure.

◆ tModList

typedef struct ModList tModList

list of module interfaces

Function Documentation

◆ GetDataDir()

char * GetDataDir ( void )
extern

Definition at line 256 of file tgf.cpp.

◆ GetLibDir()

char * GetLibDir ( void )
extern

Definition at line 243 of file tgf.cpp.

◆ GetLocalDir()

char * GetLocalDir ( void )
extern

Definition at line 230 of file tgf.cpp.

◆ GetSingleTextureMode()

int GetSingleTextureMode ( void )
extern

Definition at line 272 of file tgf.cpp.

◆ GfCreateDir()

int GfCreateDir ( char * path)
extern

Create directory for given path recursively, so all missing parent directories are created as well.

Parameters
[in]pathPath
Returns
GF_DIR_CREATED if directory was created or already exits
GF_DIR_CREATION_FAILED if directory could not be created

Definition at line 308 of file tgf.cpp.

Here is the call graph for this function:

◆ GfCreateDirForFile()

int GfCreateDirForFile ( const char * filenameandpath)
extern

Create directory for given file path recursively, so all missing parent directories are created as well.

Parameters
[in]filenameandpathPath including file name
Returns
GF_DIR_CREATED if directory was created or already exits
GF_DIR_CREATION_FAILED if directory could not be created
See also
GfCreateDir

Definition at line 368 of file tgf.cpp.

Here is the call graph for this function:

◆ GfFatal()

void GfFatal ( const char * fmt,
... )
inlinestatic

Definition at line 338 of file tgf.h.

◆ GfInit()

void GfInit ( void )
extern

Definition at line 138 of file tgf.cpp.

Here is the call graph for this function:

◆ gfMean()

tdble gfMean ( tdble v,
tMeanVal * pvt,
int n,
int w )
extern

Definition at line 157 of file tgf.cpp.

◆ gfMeanReset()

void gfMeanReset ( tdble v,
tMeanVal * pvt )
extern

Definition at line 147 of file tgf.cpp.

◆ GfNearestPow2()

int GfNearestPow2 ( int x)
extern

Definition at line 284 of file tgf.cpp.

◆ GfTimeClock()

double GfTimeClock ( void )
extern

Get the time in seconds.

Returns
Time in seconds since the start of the system

Definition at line 50 of file os.cpp.

◆ SetDataDir()

void SetDataDir ( char * buf)
extern

Definition at line 262 of file tgf.cpp.

◆ SetLibDir()

void SetLibDir ( char * buf)
extern

Definition at line 249 of file tgf.cpp.

◆ SetLocalDir()

void SetLocalDir ( char * buf)
extern

Definition at line 236 of file tgf.cpp.

◆ SetSingleTextureMode()

void SetSingleTextureMode ( void )
extern

Definition at line 278 of file tgf.cpp.

Variable Documentation

◆ G

const tdble G = 9.80665f

m/s/s

Definition at line 69 of file tgf.h.

◆ PI

const double PI = 3.14159265358979323846

PI.

Definition at line 68 of file tgf.h.