73 const int BUFSIZE = 1024;
79 GfOut(
"Loading Track Loader...\n");
81 snprintf(buf, BUFSIZE,
"%smodules/track/%s.%s",
GetLibDir (),
dllname, DLLEXT);
85 GfOut(
"Loading Graphic Engine...\n");
87 snprintf(buf, BUFSIZE,
"%smodules/graphic/%s.%s",
GetLibDir (),
dllname, DLLEXT);
111 ReInfo->_reTrackItf.trkShutdown();
147 while ((m = strstr(s,
"/")) != 0) {
151 e = strstr(s, PARAMEXT);
153 ReInfo->_reFilename[e-s] =
'\0';
165 const int BUFSIZE = 1024;
172 GfOut(
"Loading Track Loader...\n");
174 snprintf(buf, BUFSIZE,
"%smodules/track/%s.%s",
GetLibDir (),
dllname, DLLEXT);
180 const char *s, *e, *m;
184 GfError(
"Could not open file: %s\n", raceconfig);
189 while ((m = strstr(s,
"/")) != 0) {
193 e = strstr(s, PARAMEXT);
195 ReInfo->_reFilename[e-s] =
'\0';
210 const int BUFSIZE = 1024;
213 snprintf(buf, BUFSIZE,
"%sconfig/raceman/%s",
GetLocalDir(), racemanCur->
name);
228 while (cur->
next != head) {
233 if (tmp->
next != cur) {
262 GfOut(
"No race manager available\n");
266 racemanCur = racemanList;
269 racemanCur = racemanCur->
next;
270 }
while (racemanCur != racemanList);
274 racemanCur = racemanList;
281 racemanCur = racemanCur->
next;
282 }
while (racemanCur != racemanList);
292 }
while (rl != racemanList);
325 const int BUFSIZE = 1024;
334 curseg = curseg->
next;
345 if (strcmp(pole,
"left") == 0) {
369 for (i = 0; i <
ReInfo->
s->_ncars; i++) {
371 car->_speed_x = speedInit;
372 car->_commitBestLapTime =
true;
374 tr = a + b * ((i % rows) + 1) / (rows + 1);
376 while (startpos < curseg->lgfromstart) {
377 curseg = curseg->
prev;
380 car->_trkPos.seg = curseg;
381 car->_trkPos.toRight = tr;
382 switch (curseg->
type) {
384 car->_trkPos.toStart =
ts;
389 car->_trkPos.toStart =
ts / curseg->
radius;
391 car->_yaw = curseg->
angle[
TR_ZS] - car->_trkPos.toStart;
394 car->_trkPos.toStart =
ts / curseg->
radius;
396 car->_yaw = curseg->
angle[
TR_ZS] + car->_trkPos.toStart;
432 if (carsPerPit < 1) {
437 GfOut(
"Cars per pit: %d\n", carsPerPit);
447 for (i = 0; i < pits->
nMaxPits; i++) {
458 for (i = 0; i <
ReInfo->
s->_ncars; i++) {
461 for (j = 0; j < pits->
nMaxPits; j++) {
466 (strcmp(pit->
car[0]->_teamname, car->_teamname) == 0 && pit->
freeCarIndex < carsPerPit))
493 for (i = 0; i < pits->
nMaxPits; i++) {
497 GfOut(
"Pit %d, Team: %s, ", i, pit->
car[j]->_teamname);
499 GfOut(
"%d: %s ", j, pit->
car[j]->_name);
519 if (modInfo->
index == robotIdx) {
526 if (modInfo->
name != NULL && driverName != NULL && strcmp(modInfo->
name, driverName) == 0) {
528 const int BUFSIZE = 1024;
532 GfError(
"Driver list in results is empty");
536 if (resultDriverName != NULL && strcmp(resultDriverName, modInfo->
name) == 0) {
564 const int BUFSIZE = 1024;
565 char buf[BUFSIZE], path[BUFSIZE];
569 GfOut(
"loading %d cars\n", nCars);
578 int defaultSkillLevel = 2;
580 for(k = 0; k < (int)(
sizeof(
level_str)/
sizeof(
char*)); k++) {
581 if (strcmp(
level_str[k], defaultSkillLevelStr) == 0) {
582 defaultSkillLevel = k;
587 for (i = 1; i < nCars + 1; i++) {
591 snprintf(path, BUFSIZE,
"%sdrivers/%s/%s.%s",
GetLibDir (), cardllname, cardllname, DLLEXT);
595 GfTrace(
"Pb with loading %s driver\n", path);
605 int robotIdx = curModInfo->
index;
606 GfOut(
"Driver's name: %s\n", curModInfo->
name);
609 curModInfo->
fctInit(robotIdx, (
void*)(curRobot));
610 snprintf(buf, BUFSIZE,
"%sdrivers/%s/%s.xml",
GetLocalDir(), cardllname, cardllname);
613 snprintf(buf, BUFSIZE,
"drivers/%s/%s.xml", cardllname, cardllname);
616 if (robhdle != NULL) {
621 elt->
robot = curRobot;
622 elt->_paramsHandle = robhdle;
623 elt->_driverIndex = robotIdx;
639 GfError(
"Human drivers not allowed in console race, fix race setup.\n");
645 elt->_skillLevel = 0;
647 for(k = 0; k < (int)(
sizeof(
level_str)/
sizeof(
char*)); k++) {
649 elt->_skillLevel = k;
653 elt->_startRank = index;
655 elt->_remainingLaps =
ReInfo->
s->_totLaps;
659 snprintf(buf, BUFSIZE,
"cars/%s/%s.xml", elt->_carName, elt->_carName);
660 GfOut(
"Car Specification: %s\n", buf);
663 snprintf(buf, BUFSIZE,
"Loading Driver %-20s... Car: %s", curModInfo->
name, elt->_carName);
671 snprintf(buf, BUFSIZE,
"categories/%s.xml", category);
672 GfOut(
"Category Specification: %s\n", buf);
675 GfTrace(
"Car %s not in Category %s (driver %s) !!!\n", elt->_carName, category, elt->_name);
681 if (handle != NULL) {
683 GfTrace(
"Bad Car parameters for driver %s\n", elt->_name);
691 elt->_carHandle = handle;
694 elt->_category[0] =
'\0';
695 GfTrace(
"Bad Car category for driver %s\n", elt->_name);
700 GfTrace(
"Pb No description file for driver %s\n", cardllname);
709 GfTrace(
"No driver for that race...\n");
712 GfOut(
"%d drivers ready to race\n", nCars);
718 for (i = 0; i < nCars; i++) {
746 const int BUFSIZE = 1024;
750 const char *stype[4] = {
"",
"RGT",
"LFT",
"STR" };
754 snprintf(buf, BUFSIZE,
">>> Track Name %s",
track->name);
756 snprintf(buf, BUFSIZE,
">>> Track Author %s",
track->author);
758 snprintf(buf, BUFSIZE,
">>> Track Length %.2f m",
track->length);
760 snprintf(buf, BUFSIZE,
">>> Track Width %.2f m",
track->width);
763 GfOut(
"++++++++++++ Track ++++++++++++\n");
774 switch (
track->pits.type) {
776 GfOut(
"Pits = none\n");
779 GfOut(
"Pits = present on track side\n");
782 GfOut(
"Pits = present on separate path\n");
786 for (i = 0, seg =
track->seg->next; i < track->nseg; i++, seg = seg->
next) {
787 GfOut(
" segment %d -------------- \n", seg->
id);
798 GfOut(
" vertices: %-8.8f %-8.8f %-8.8f ++++ ",
802 GfOut(
"%-8.8f %-8.8f %-8.8f\n",
806 GfOut(
" vertices: %-8.8f %-8.8f %-8.8f ++++ ",
810 GfOut(
"%-8.8f %-8.8f %-8.8f\n",
817 GfOut(
"From Last To First\n");
818 GfOut(
"Dx = %-8.8f Dy = %-8.8f Dz = %-8.8f\n",
837 const int BUFSIZE = 1024;
844 if (!trackName)
return -1;
847 if (!catName)
return -1;
849 snprintf(buf, BUFSIZE,
"Loading Track %s...", trackName);
851 snprintf(buf, BUFSIZE,
"tracks/%s/%s/%s.%s", catName, trackName, trackName, TRKEXT);
862 ReInfo->_reSimItf.shutdown();
864 ReInfo->_reGraphicItf.shutdowncars();
880 for (i = 0; i < nCars; i++) {
911 const int BUFSIZE = 1024;
925 const int BUFSIZE = 1024;
int nMaxPits
number max of pits
static void reSelectRaceman(void *params)
int driversPitsNb
Number of drivers.
void ReStoreRaceResults(const char *race)
tFList * GfDirGetListFiltered(const char *dir, const char *suffix)
Get the list of files with matching suffix of a given directory.
Race Manager General Info.
#define TR_SR
Start-Right corner.
tRmCarRules * rules
by car rules
int GfModLoad(unsigned int gfid, char *dllname, tModList **modlist)
Load the specified DLLs.
tModInfo modInfo[MAX_MOD_ITF]
module info list for this dll
void ReRunRaceOnConsole(const char *raceconfig)
void * userData
User data.
tTrackOwnPit * driversPits
List of pits by driver.
int GfParmCheckHandle(void *ref, void *tgt)
Check the values in the parameter set tgt against the min/max/within definitions in the ref parameter...
int type
Geometrical type:
static void initPits(void)
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
#define TR_ER
End_Right corner.
cars situation used to inform the GUI and the drivers
Interface Structure for Robots.
void ReRaceCleanDrivers(void)
#define RM_ATT_CAPTURE_OUT_DIR
int GfuiMenuButtonCreate(void *scr, const char *text, const char *tip, void *userdata, tfuiCallback onpush)
Add a button to a menu screen.
int GfParmListSeekNext(void *handle, const char *path)
Go the the next subsection element in the parameter set handle.
#define GFPARM_RMODE_STD
if handle already openned return it
void * GfParmMergeHandles(void *ref, void *tgt, int mode)
Merge two parameter sets into a new one, either containing parameters from ref, tgt or from both sets...
#define TR_ZS
Rotation angles of the track in rad anti-clockwise: Index in:
tCarElt ** cars
list of cars
static const char * level_str[]
static tModList * reEventModList
tdble lmax
Pitting area length max.
void * results
Race results.
int pitCarIndex
Index of the car in the car array below which occupies the pit.
#define TR_PIT_ON_TRACK_SIDE
The pits are on the track side.
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
#define TR_SL
Start-Left corner.
tdble width
main track width
Robot Module Interface Definition.
#define MAX_MOD_ITF
Maximum number of interface in one DLL.
static void reSortRacemanList(tFList **racemanList)
#define TR_CS
Center start angle.
tdble lmin
Pitting area length min.
void ReAddRacemanListButton(void *menuHandle)
static void initStartingGrid(void)
#define RM_SECT_STARTINGGRID
tdble lgfromstart
Length of beginning of segment from starting line.
tSituation * s
Situation during race.
List of (DLL) files for a Directory.
tdble length
Length in meters of the middle of the track.
#define TR_PIT_ON_SEPARATE_PATH
#define RM_ATTR_INITSPEED
#define RM_ATT_CAPTURE_FPS
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
#define RAD2DEG(x)
Radian to degree conversion.
static void reRegisterRaceman(tFList *racemanCur)
#define GFPARM_MMODE_RELDST
release tgt after the merge
The Gaming Framework API (client part).
void ReStartNewRace(void *)
static char * strndup(const char *str, int len)
tCarElt * carList
List of all the cars racing.
tdble length
main track length
tTrkLocPos pos
Center of the pit position.
int GfParmListSeekFirst(void *handle, const char *path)
Go the the first subsection element in the parameter set handle.
struct CarElt * car[TR_PIT_MAXCARPERPIT]
Car links for pit.
bool isItThisRobot(tRmInfo *reInfo, const char *path, tModInfo *modInfo)
int ReInitTrack(void)
Initialize the track for a race manager.
#define RM_ATTR_COLOFFSET
tModList ** modList
drivers loaded
#define TR_LFT
Left curve.
struct FList * next
Next entry.
tfModPrivInit fctInit
init function
#define TR_PIT_MAXCARPERPIT
#define RM_SECT_MOVIE_CAPTURE
float tdble
Floating point type used in TORCS.
char * dispName
Name to display on screen.
#define RM_ATTR_INITHEIGHT
struct RobotItf * robot
private
const char * name
Name of the track.
#define GFPARM_RMODE_REREAD
reread the parameters from file and release the previous ones
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
tTrack * track
Current track.
#define RM_ATT_CAPTURE_ENABLE
void * params
Parameters handle.
tdble arc
Arc in rad of the curve (>0)
#define TR_ZE
Z End angle.
int ReInitCars(void)
Initialize the cars for a race.
tdble radius
Radius in meters of the middle of the track (>0)
int GfModUnloadList(tModList **modlist)
Unload the DLLs of a list.
tRmMovieCapture movieCapture
const char * ReGetCurrentRaceName(void)
t3Dd vertex[4]
Coordinates of the 4 corners of the segment.
#define TR_PIT_NONE
No pits for that tracks.
This is the race information structures.
#define RE_STATE_EVENT_INIT
#define GF_TAILQ_FIRST(head)
First element of a TAILQ.
tTrackSeg * seg
Track segment.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
#define TR_EL
End-Left corner.
#define GF_TAILQ_REMOVE(head, elm, field)
Remove an element.
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.
struct FList * prev
Previous entry.
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
int track(tModInfo *modInfo)
char * name
name of the module (short) (NULL if no module)
int index
index if multiple interface in one dll
#define GFPARM_MMODE_RELSRC
release ref after the merge
#define RM_ATTR_SKILL_LEVEL_DEFAULT
#define TR_RGT
Right curve.
tdble len
Lenght of each pit stop.
tdble toStart
Distance to start of segment (or arc if turn)
#define RM_ATTR_CARSPERPIT
#define NORM0_2PI(x)
Angle normalization between 0 and 2 * PI.
struct trackSeg * prev
Previous segment.
#define TR_PIT_STATE_FREE
int GfParmGetEltNb(void *handle, const char *path)
Count the number of subsections in a section in the parameter set handle.
struct trackSeg * next
Next segment.
#define RM_DISP_MODE_CONSOLE
char * GfParmGetFileName(void *handle)
Get the filename property of the parameter set handle.
#define GFPARM_MMODE_DST
use tgt and verify ref parameters
#define RM_DISP_MODE_NORMAL
#define RE_ATTR_CUR_TRACK
list of module interfaces
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.
const char * ReGetPrevRaceName(void)
#define RM_SECT_DRIVERS_RACING
tTrackSeg * seg
Main track.
static void reDumpTrack(tTrack *track, int verbose)
Dump the track segments on screen.
Module information structure.
void ReStateApply(void *vstate)
tTrackPitInfo pits
Pits information.
void * params
Raceman parameters.
#define GFPARM_RMODE_CREAT
Create the file if doesn't exist.
#define GFPARM_MMODE_SRC
use ref and modify existing parameters with tgt