TORCS  1.3.9
The Open Racing Car Simulator
raceinit.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : raceinit.cpp
4  created : Sat Nov 16 10:34:35 CET 2002
5  copyright : (C) 2002-2017 by Eric Espie, Bernhard Wymann
6  email : eric.espie@torcs.org
7  version : $Id$
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
27 /* Race initialization routines */
28 
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <tgfclient.h>
32 #include <raceman.h>
33 #include <robot.h>
34 #include <racescreens.h>
35 #include <robottools.h>
36 #include <portability.h>
37 #include <string>
38 #include <map>
39 #include <portability.h>
41 
42 #include "raceengine.h"
43 #include "racemain.h"
44 #include "racestate.h"
45 #include "racegl.h"
46 #include "raceresults.h"
47 
48 #include "raceinit.h"
49 
51 
54 
55 typedef struct
56 {
57  int index;
59 } tMainMod;
60 
61 /* Race Engine Initialization */
62 void
63 ReInit(void)
64 {
65  tRmMovieCapture *capture;
66 
67  ReShutdown();
68 
69  ReInfo = (tRmInfo *)calloc(1, sizeof(tRmInfo));
70  ReInfo->s = (tSituation *)calloc(1, sizeof(tSituation));
72 
73  const int BUFSIZE = 1024;
74  char buf[BUFSIZE];
75  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), RACE_ENG_CFG);
76 
78 
79  GfOut("Loading Track Loader...\n");
80  const char* dllname = GfParmGetStr(ReInfo->_reParam, "Modules", "track", "");
81  snprintf(buf, BUFSIZE, "%smodules/track/%s.%s", GetLibDir (), dllname, DLLEXT);
82  if (GfModLoad(0, buf, &reEventModList)) return;
84 
85  GfOut("Loading Graphic Engine...\n");
86  dllname = GfParmGetStr(ReInfo->_reParam, "Modules", "graphic", "");
87  snprintf(buf, BUFSIZE, "%smodules/graphic/%s.%s", GetLibDir (), dllname, DLLEXT);
88  if (GfModLoad(0, buf, &reEventModList)) return;
90 
91  capture = &(ReInfo->movieCapture);
92  if (strcmp(GfParmGetStr(ReInfo->_reParam, RM_SECT_MOVIE_CAPTURE, RM_ATT_CAPTURE_ENABLE, "no"), "no") == 0){
93  capture->enabled = 0;
94  } else {
95  capture->enabled = 1;
96  capture->state = 0;
97  capture->deltaFrame = 1.0 / GfParmGetNum(ReInfo->_reParam, RM_SECT_MOVIE_CAPTURE, RM_ATT_CAPTURE_FPS, NULL, 1.0);
99  capture->deltaSimu = RCM_MAX_DT_SIMU;
100  }
101 
102  ReInfo->_reGameScreen = ReHookInit();
103 }
104 
105 
106 /* Race Engine Exit */
107 void ReShutdown(void)
108 {
109  /* Free previous situation */
110  if (ReInfo) {
111  ReInfo->_reTrackItf.trkShutdown();
112 
114 
115  if (ReInfo->results) {
117  }
118  if (ReInfo->_reParam) {
119  GfParmReleaseHandle(ReInfo->_reParam);
120  }
121  FREEZ(ReInfo->s);
122  FREEZ(ReInfo->carList);
123  FREEZ(ReInfo->rules);
124  FREEZ(ReInfo->_reFilename);
125  FREEZ(ReInfo);
126  }
127 }
128 
129 
130 void
131 ReStartNewRace(void * /* dummy */)
132 {
133  ReInitResults();
134  ReStateManage();
135 }
136 
137 
138 /* Launch a race manager */
139 static void reSelectRaceman(void *params)
140 {
141  char *s, *e, *m;
142 
143  ReInfo->params = params;
144  FREEZ(ReInfo->_reFilename);
145 
146  s = GfParmGetFileName(params);
147  while ((m = strstr(s, "/")) != 0) {
148  s = m + 1;
149  }
150 
151  e = strstr(s, PARAMEXT);
152  ReInfo->_reFilename = strndup(s, e-s+1);
153  ReInfo->_reFilename[e-s] = '\0';
154  ReInfo->_reName = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_NAME, "");
156 }
157 
158 
159 void ReRunRaceOnConsole(const char* raceconfig)
160 {
161  ReInfo = (tRmInfo *)calloc(1, sizeof(tRmInfo));
162  ReInfo->s = (tSituation *)calloc(1, sizeof(tSituation));
164 
165  const int BUFSIZE = 1024;
166  char buf[BUFSIZE];
167  snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), RACE_ENG_CFG);
168 
170  ReInfo->_displayMode = RM_DISP_MODE_CONSOLE;
171 
172  GfOut("Loading Track Loader...\n");
173  const char* dllname = GfParmGetStr(ReInfo->_reParam, "Modules", "track", "");
174  snprintf(buf, BUFSIZE, "%smodules/track/%s.%s", GetLibDir (), dllname, DLLEXT);
175  if (GfModLoad(0, buf, &reEventModList)) return;
177 
179 
180  const char *s, *e, *m;
181 
183  if (ReInfo->params == 0) {
184  GfError("Could not open file: %s\n", raceconfig);
185  exit(1);
186  }
187 
189  while ((m = strstr(s, "/")) != 0) {
190  s = m + 1;
191  }
192 
193  e = strstr(s, PARAMEXT);
194  ReInfo->_reFilename = strndup(s, e-s+1);
195  ReInfo->_reFilename[e-s] = '\0';
197 
198  ReInitResults();
199 
202  ReShutdown();
203 }
204 
205 
206 /* Register a race manager */
207 static void
209 {
210  const int BUFSIZE = 1024;
211  char buf[BUFSIZE];
212 
213  snprintf(buf, BUFSIZE, "%sconfig/raceman/%s", GetLocalDir(), racemanCur->name);
214  racemanCur->userData = GfParmReadFile(buf, GFPARM_RMODE_STD);
215  racemanCur->dispName = strndup(GfParmGetStr(racemanCur->userData, RM_SECT_HEADER, RM_ATTR_NAME, 0), 1024);
216 }
217 
218 /* Sort race managers by priority */
219 static void
220 reSortRacemanList(tFList **racemanList)
221 {
222  tFList *head;
223  tFList *cur;
224  tFList *tmp;
225 
226  head = *racemanList;
227  cur = head;
228  while (cur->next != head) {
229  if (GfParmGetNum(cur->userData, RM_SECT_HEADER, RM_ATTR_PRIO, NULL, 10000) >
230  GfParmGetNum(cur->next->userData, RM_SECT_HEADER, RM_ATTR_PRIO, NULL, 10000)) {
231  /* swap cur and cur->next */
232  tmp = cur->next;
233  if (tmp->next != cur) {
234  cur->next = tmp->next;
235  tmp->next = cur;
236  tmp->prev = cur->prev;
237  cur->prev = tmp;
238  cur->next->prev = cur;
239  tmp->prev->next = tmp;
240  }
241  if (cur == head) {
242  head = tmp;
243  } else {
244  cur = tmp->prev;
245  }
246  } else {
247  cur = cur->next;
248  }
249  }
250  *racemanList = head;
251 }
252 
253 
254 /* Load race managers selection menu */
256 {
257  tFList *racemanList;
258  tFList *racemanCur;
259 
260  racemanList = GfDirGetListFiltered("config/raceman", "xml");
261  if (!racemanList) {
262  GfOut("No race manager available\n");
263  return;
264  }
265 
266  racemanCur = racemanList;
267  do {
268  reRegisterRaceman(racemanCur);
269  racemanCur = racemanCur->next;
270  } while (racemanCur != racemanList);
271 
272  reSortRacemanList(&racemanList);
273 
274  racemanCur = racemanList;
275  do {
277  racemanCur->dispName,
279  racemanCur->userData,
281  racemanCur = racemanCur->next;
282  } while (racemanCur != racemanList);
283 
284  // The list contains at least one element, checked above.
285  tFList *rl = racemanList;
286  do {
287  tFList *tmp = rl;
288  rl = rl->next;
289  // Do not free userData and dispName, is in use.
290  freez(tmp->name);
291  free(tmp);
292  } while (rl != racemanList);
293 }
294 
295 
296 
297 /*
298  * Function
299  * initStartingGrid
300  *
301  * Description
302  * Place the cars on the starting grid
303  *
304  * Parameters
305  * Race Information structure initialized
306  *
307  * Return
308  * none
309  */
310 static void
312 {
313  int i;
314  tTrackSeg *curseg;
315  int rows;
316  tdble a, b; //, wi2;
317  tdble d1, d2,d3;
318  tdble startpos, tr, ts;
319  tdble speedInit;
320  tdble heightInit;
321  tCarElt *car;
322  const char *pole;
323  void *trHdle = ReInfo->track->params;
324  void *params = ReInfo->params;
325  const int BUFSIZE = 1024;
326  char path[BUFSIZE];
327 
328  snprintf(path, BUFSIZE, "%s/%s", ReInfo->_reRaceName, RM_SECT_STARTINGGRID);
329 
330  /* Search for the first turn for find the pole side */
331  curseg = ReInfo->track->seg->next;
332  while (curseg->type == TR_STR) {
333  /* skip the straight segments */
334  curseg = curseg->next;
335  }
336  /* Set the pole for the inside of the first turn */
337  if (curseg->type == TR_LFT) {
338  pole = GfParmGetStr(params, path, RM_ATTR_POLE, "left");
339  } else {
340  pole = GfParmGetStr(params, path, RM_ATTR_POLE, "right");
341  }
342  /* Tracks definitions can force the pole side */
343  pole = GfParmGetStr(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_POLE, pole);
344 
345  if (strcmp(pole, "left") == 0) {
346  a = ReInfo->track->width;
347  b = -a;
348  } else {
349  a = 0;
350  b = ReInfo->track->width;
351  }
352  //wi2 = ReInfo->track->width * 0.5;
353 
354  rows = (int)GfParmGetNum(params, path, RM_ATTR_ROWS, (char*)NULL, 2);
355  rows = (int)GfParmGetNum(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_ROWS, (char*)NULL, rows);
356  d1 = GfParmGetNum(params, path, RM_ATTR_TOSTART, (char*)NULL, 10);
357  d1 = GfParmGetNum(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_TOSTART, (char*)NULL, d1);
358  d2 = GfParmGetNum(params, path, RM_ATTR_COLDIST, (char*)NULL, 10);
359  d2 = GfParmGetNum(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_COLDIST, (char*)NULL, d2);
360  d3 = GfParmGetNum(params, path, RM_ATTR_COLOFFSET, (char*)NULL, 5);
361  d3 = GfParmGetNum(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_COLOFFSET, (char*)NULL, d3);
362  speedInit = GfParmGetNum(params, path, RM_ATTR_INITSPEED, (char*)NULL, 0.0);
363  heightInit = GfParmGetNum(params, path, RM_ATTR_INITHEIGHT, (char*)NULL, 0.3);
364  heightInit = GfParmGetNum(trHdle, RM_SECT_STARTINGGRID, RM_ATTR_INITHEIGHT, (char*)NULL, heightInit);
365 
366  if (rows < 1) {
367  rows = 1;
368  }
369  for (i = 0; i < ReInfo->s->_ncars; i++) {
370  car = &(ReInfo->carList[i]);
371  car->_speed_x = speedInit;
372  car->_commitBestLapTime = true;
373  startpos = ReInfo->track->length - (d1 + (i / rows) * d2 + (i % rows) * d3);
374  tr = a + b * ((i % rows) + 1) / (rows + 1);
375  curseg = ReInfo->track->seg; /* last segment */
376  while (startpos < curseg->lgfromstart) {
377  curseg = curseg->prev;
378  }
379  ts = startpos - curseg->lgfromstart;
380  car->_trkPos.seg = curseg;
381  car->_trkPos.toRight = tr;
382  switch (curseg->type) {
383  case TR_STR:
384  car->_trkPos.toStart = ts;
385  RtTrackLocal2Global(&(car->_trkPos), &(car->_pos_X), &(car->_pos_Y), TR_TORIGHT);
386  car->_yaw = curseg->angle[TR_ZS];
387  break;
388  case TR_RGT:
389  car->_trkPos.toStart = ts / curseg->radius;
390  RtTrackLocal2Global(&(car->_trkPos), &(car->_pos_X), &(car->_pos_Y), TR_TORIGHT);
391  car->_yaw = curseg->angle[TR_ZS] - car->_trkPos.toStart;
392  break;
393  case TR_LFT:
394  car->_trkPos.toStart = ts / curseg->radius;
395  RtTrackLocal2Global(&(car->_trkPos), &(car->_pos_X), &(car->_pos_Y), TR_TORIGHT);
396  car->_yaw = curseg->angle[TR_ZS] + car->_trkPos.toStart;
397  break;
398  }
399  car->_pos_Z = RtTrackHeightL(&(car->_trkPos)) + heightInit;
400 
401  NORM0_2PI(car->_yaw);
402  ReInfo->_reSimItf.config(car, ReInfo);
403  }
404 }
405 
406 
407 static void
408 initPits(void)
409 {
410  tTrackPitInfo *pits;
411  int i, j;
412 
413  /*
414  typedef std::map<std::string, int> tTeamsMap;
415  typedef tTeamsMap::const_iterator tTeamsMapIterator;
416  tTeamsMap teams;
417  tTeamsMapIterator teamsIterator;
418 
419  // create a list with the teams, a pit can just be used by one team.
420  for (i = 0; i < ReInfo->s->_ncars; i++) {
421  tCarElt *car = &(ReInfo->carList[i]);
422  teams[car->_teamname] = teams[car->_teamname] + 1;
423  }
424 
425  for (teamsIterator = teams.begin(); teamsIterator != teams.end(); ++teamsIterator) {
426  printf("----------------- %s\t%d\n", (teamsIterator->first).c_str(), teamsIterator->second);
427  }
428  */
429 
430  // How many cars are sharing a pit?
431  int carsPerPit = (int) GfParmGetNum(ReInfo->params, ReInfo->_reRaceName, RM_ATTR_CARSPERPIT, NULL, 1.0f);
432  if (carsPerPit < 1) {
433  carsPerPit = 1;
434  } else if (carsPerPit > TR_PIT_MAXCARPERPIT) {
435  carsPerPit = TR_PIT_MAXCARPERPIT;
436  }
437  GfOut("Cars per pit: %d\n", carsPerPit);
438 
439  switch (ReInfo->track->pits.type) {
441  pits = &(ReInfo->track->pits);
442  pits->driversPitsNb = ReInfo->s->_ncars;
443  pits->carsPerPit = carsPerPit;
444 
445  // Initialize pit data for every pit, necessary because of restarts
446  // (track gets not reloaded, no calloc).
447  for (i = 0; i < pits->nMaxPits; i++) {
448  tTrackOwnPit *pit = &(pits->driversPits[i]);
449  pit->freeCarIndex = 0;
451  for (j = 0; j < TR_PIT_MAXCARPERPIT; j++) {
452  pit->car[j] = NULL;
453  }
454  }
455 
456  // Assign cars to pits. Inefficient (O(n*n)), but just at initialization, so do not care.
457  // One pit can just host cars of one team (this matches with the reality)
458  for (i = 0; i < ReInfo->s->_ncars; i++) {
459  // Find pit for the cars team.
460  tCarElt *car = &(ReInfo->carList[i]);
461  for (j = 0; j < pits->nMaxPits; j++) {
462  tTrackOwnPit *pit = &(pits->driversPits[j]);
463  // Put car in this pit if the pit is unused or used by a teammate and there is
464  // space left.
465  if (pit->freeCarIndex <= 0 ||
466  (strcmp(pit->car[0]->_teamname, car->_teamname) == 0 && pit->freeCarIndex < carsPerPit))
467  {
468  // Assign car to pit.
469  pit->car[pit->freeCarIndex] = car;
470  // If this is the first car set up more pit values, assumtion: the whole team
471  // uses the same car. If not met it does not matter much, but the car might be
472  // captured a bit too easy or too hard.
473  if (pit->freeCarIndex == 0) {
475  pit->lmin = pit->pos.seg->lgfromstart + pit->pos.toStart - pits->len / 2.0 + car->_dimension_x / 2.0;
476  if (pit->lmin > ReInfo->track->length) {
477  pit->lmin -= ReInfo->track->length;
478  }
479  pit->lmax = pit->pos.seg->lgfromstart + pit->pos.toStart + pits->len / 2.0 - car->_dimension_x / 2.0;
480  if (pit->lmax > ReInfo->track->length) {
481  pit->lmax -= ReInfo->track->length;
482  }
483  }
484  (pit->freeCarIndex)++;
485  ReInfo->carList[i]._pit = pit;
486  // Assigned, continue with next car.
487  break;
488  }
489  }
490  }
491 
492  // Print out assignments.
493  for (i = 0; i < pits->nMaxPits; i++) {
494  tTrackOwnPit *pit = &(pits->driversPits[i]);
495  for (j = 0; j < pit->freeCarIndex; j++) {
496  if (j == 0) {
497  GfOut("Pit %d, Team: %s, ", i, pit->car[j]->_teamname);
498  }
499  GfOut("%d: %s ", j, pit->car[j]->_name);
500  }
501  if (j > 0) {
502  GfOut("\n");
503  }
504  }
505 
506  break;
508  break;
509  case TR_PIT_NONE:
510  break;
511  }
512 }
513 
514 bool isItThisRobot(tRmInfo* reInfo, const char* path, tModInfo* modInfo)
515 {
516  int robotIdx = (int) GfParmGetNum(reInfo->params, path, RM_ATTR_IDX, NULL, tModInfo::INVALID_INDEX);
517  // Check normal TORCS case where index is given
518  if (robotIdx != tModInfo::INVALID_INDEX) {
519  if (modInfo->index == robotIdx) {
520  return true;
521  }
522  }
523 
524  // Check TRB case where driver name is given
525  const char* driverName = GfParmGetStr(reInfo->params, path, RM_ATTR_DRVNAME, NULL);
526  if (modInfo->name != NULL && driverName != NULL && strcmp(modInfo->name, driverName) == 0) {
527  // Update the index in the result list.
528  const int BUFSIZE = 1024;
529  char path2[BUFSIZE];
530  snprintf(path2, BUFSIZE, "%s/%s", reInfo->track->name, RM_SECT_DRIVERS);
531  if (GfParmListSeekFirst(reInfo->results, path2) != 0) {
532  GfError("Driver list in results is empty");
533  } else {
534  do {
535  const char* resultDriverName = GfParmGetCurStr(reInfo->results, path2, RM_ATTR_DRVNAME, "");
536  if (resultDriverName != NULL && strcmp(resultDriverName, modInfo->name) == 0) {
537  GfParmSetCurNum(reInfo->results, path2, RE_ATTR_INDEX, NULL, modInfo->index);
538  break;
539  }
540 
541  } while (GfParmListSeekNext(reInfo->results, path2) == 0);
542  }
543 
544  return true;
545  }
546 
547  return false;
548 }
549 
555 int
557 {
558  int index;
559  int i, j, k;
560  tRobotItf *curRobot;
561  void *handle;
562  tCarElt *elt;
563  void *params = ReInfo->params;
564  const int BUFSIZE = 1024;
565  char buf[BUFSIZE], path[BUFSIZE];
566 
567  /* Get the number of cars racing */
568  int nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS_RACING);
569  GfOut("loading %d cars\n", nCars);
570 
571  FREEZ(ReInfo->carList);
572  ReInfo->carList = (tCarElt*)calloc(nCars, sizeof(tCarElt));
573  FREEZ(ReInfo->rules);
574  ReInfo->rules = (tRmCarRules*)calloc(nCars, sizeof(tRmCarRules));
575  index = 0;
576 
577  // Adjust skill level default if overridden
578  int defaultSkillLevel = 2;
579  const char* defaultSkillLevelStr = GfParmGetStr(params, RM_SECT_DRIVERS, RM_ATTR_SKILL_LEVEL_DEFAULT, ROB_VAL_SEMI_PRO);
580  for(k = 0; k < (int)(sizeof(level_str)/sizeof(char*)); k++) {
581  if (strcmp(level_str[k], defaultSkillLevelStr) == 0) {
582  defaultSkillLevel = k;
583  break;
584  }
585  }
586 
587  for (i = 1; i < nCars + 1; i++) {
588  /* Get Shared library name */
589  snprintf(path, BUFSIZE, "%s/%d", RM_SECT_DRIVERS_RACING, i);
590  const char* cardllname = GfParmGetStr(params, path, RM_ATTR_MODULE, "");
591  snprintf(path, BUFSIZE, "%sdrivers/%s/%s.%s", GetLibDir (), cardllname, cardllname, DLLEXT);
592 
593  /* load the robot shared library */
594  if (GfModLoad(CAR_IDENT, path, ReInfo->modList)) {
595  GfTrace("Pb with loading %s driver\n", path);
596  break;
597  }
598 
599  /* search for corresponding index */
600  for (j = 0; j < MAX_MOD_ITF; j++) {
601  tModInfo* curModInfo = &((*(ReInfo->modList))->modInfo[j]);
602  snprintf(path, BUFSIZE, "%s/%d", RM_SECT_DRIVERS_RACING, i);
603  if (isItThisRobot(ReInfo, path, curModInfo)) {
604  /* good robot found */
605  int robotIdx = curModInfo->index;
606  GfOut("Driver's name: %s\n", curModInfo->name);
607  /* retrieve the robot interface (function pointers) */
608  curRobot = (tRobotItf*)calloc(1, sizeof(tRobotItf));
609  curModInfo->fctInit(robotIdx, (void*)(curRobot));
610  snprintf(buf, BUFSIZE, "%sdrivers/%s/%s.xml", GetLocalDir(), cardllname, cardllname);
611  void* robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
612  if (!robhdle) {
613  snprintf(buf, BUFSIZE, "drivers/%s/%s.xml", cardllname, cardllname);
614  robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
615  }
616  if (robhdle != NULL) {
617  elt = &(ReInfo->carList[index]);
618  GF_TAILQ_INIT(&(elt->_penaltyList));
619 
620  elt->index = index;
621  elt->robot = curRobot;
622  elt->_paramsHandle = robhdle;
623  elt->_driverIndex = robotIdx;
624  strncpy(elt->_modName, cardllname, MAX_NAME_LEN - 1);
625  elt->_modName[MAX_NAME_LEN - 1] = 0;
626 
627  snprintf(path, BUFSIZE, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, robotIdx);
628  strncpy(elt->_name, GfParmGetStr(robhdle, path, ROB_ATTR_NAME, "<none>"), MAX_NAME_LEN - 1);
629  elt->_name[MAX_NAME_LEN - 1] = 0;
630  strncpy(elt->_teamname, GfParmGetStr(robhdle, path, ROB_ATTR_TEAM, "<none>"), MAX_NAME_LEN - 1);
631  elt->_teamname[MAX_NAME_LEN - 1] = 0;
632 
633  strncpy(elt->_carName, GfParmGetStr(robhdle, path, ROB_ATTR_CAR, ""), MAX_NAME_LEN - 1);
634  elt->_carName[MAX_NAME_LEN - 1] = 0;
635  elt->_raceNumber = (int)GfParmGetNum(robhdle, path, ROB_ATTR_RACENUM, (char*)NULL, 0);
636  if (strcmp(GfParmGetStr(robhdle, path, ROB_ATTR_TYPE, ROB_VAL_ROBOT), ROB_VAL_ROBOT)) {
637  elt->_driverType = RM_DRV_HUMAN;
638  if (ReInfo->_displayMode == RM_DISP_MODE_CONSOLE) {
639  GfError("Human drivers not allowed in console race, fix race setup.\n");
640  exit(1);
641  }
642  } else {
643  elt->_driverType = RM_DRV_ROBOT;
644  }
645  elt->_skillLevel = 0;
646  const char* str = GfParmGetStr(robhdle, path, ROB_ATTR_LEVEL, level_str[defaultSkillLevel]);
647  for(k = 0; k < (int)(sizeof(level_str)/sizeof(char*)); k++) {
648  if (strcmp(level_str[k], str) == 0) {
649  elt->_skillLevel = k;
650  break;
651  }
652  }
653  elt->_startRank = index;
654  elt->_pos = index+1;
655  elt->_remainingLaps = ReInfo->s->_totLaps;
656 
657  /* handle contains the drivers modifications to the car */
658  /* Read Car model specifications */
659  snprintf(buf, BUFSIZE, "cars/%s/%s.xml", elt->_carName, elt->_carName);
660  GfOut("Car Specification: %s\n", buf);
661  void* carhdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
662  const char* category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL);
663  snprintf(buf, BUFSIZE, "Loading Driver %-20s... Car: %s", curModInfo->name, elt->_carName);
665  if (category != 0) {
666  strncpy(elt->_category, category, MAX_NAME_LEN - 1);
667  elt->_category[MAX_NAME_LEN - 1] = '\0';
668 
669  /* Read Car Category specifications */
670  // TODO: eventually use new Rt function
671  snprintf(buf, BUFSIZE, "categories/%s.xml", category);
672  GfOut("Category Specification: %s\n", buf);
673  void* cathdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
674  if (GfParmCheckHandle(cathdle, carhdle)) {
675  GfTrace("Car %s not in Category %s (driver %s) !!!\n", elt->_carName, category, elt->_name);
676  break;
677  }
678  carhdle = GfParmMergeHandles(cathdle, carhdle,
680  curRobot->rbNewTrack(robotIdx, ReInfo->track, carhdle, &handle, ReInfo->s);
681  if (handle != NULL) {
682  if (GfParmCheckHandle(carhdle, handle)) {
683  GfTrace("Bad Car parameters for driver %s\n", elt->_name);
684  break;
685  }
686  handle = GfParmMergeHandles(carhdle, handle,
688  } else {
689  handle = carhdle;
690  }
691  elt->_carHandle = handle;
692  RtInitCarPitSetup(handle, &(elt->pitcmd.setup), false);
693  } else {
694  elt->_category[0] = '\0';
695  GfTrace("Bad Car category for driver %s\n", elt->_name);
696  break;
697  }
698  index ++;
699  } else {
700  GfTrace("Pb No description file for driver %s\n", cardllname);
701  }
702  break;
703  }
704  }
705  }
706 
707  nCars = index; /* real number of cars */
708  if (nCars == 0) {
709  GfTrace("No driver for that race...\n");
710  return -1;
711  } else {
712  GfOut("%d drivers ready to race\n", nCars);
713  }
714 
715  ReInfo->s->_ncars = nCars;
716  FREEZ(ReInfo->s->cars);
717  ReInfo->s->cars = (tCarElt **)calloc(nCars, sizeof(tCarElt *));
718  for (i = 0; i < nCars; i++) {
719  ReInfo->s->cars[i] = &(ReInfo->carList[i]);
720  }
721 
722  ReInfo->_reSimItf.init(
723  nCars,
724  ReInfo->track,
728  );
729 
731 
732  initPits();
733 
734  return 0;
735 }
736 
741 static void
742 reDumpTrack(tTrack *track, int verbose)
743 {
744  int i;
745  tTrackSeg *seg;
746  const int BUFSIZE = 1024;
747  char buf[BUFSIZE];
748 
749 #ifdef DEBUG
750  const char *stype[4] = { "", "RGT", "LFT", "STR" };
751 #endif
752 
753  RmLoadingScreenSetText("Loading Track Geometry...");
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);
762 
763  GfOut("++++++++++++ Track ++++++++++++\n");
764  GfOut("name = %s\n", track->name);
765  GfOut("author = %s\n", track->author);
766  GfOut("filename = %s\n", track->filename);
767  GfOut("nseg = %d\n", track->nseg);
768  GfOut("version = %d\n", track->version);
769  GfOut("length = %f\n", track->length);
770  GfOut("width = %f\n", track->width);
771  GfOut("XSize = %f\n", track->max.x);
772  GfOut("YSize = %f\n", track->max.y);
773  GfOut("ZSize = %f\n", track->max.z);
774  switch (track->pits.type) {
775  case TR_PIT_NONE:
776  GfOut("Pits = none\n");
777  break;
779  GfOut("Pits = present on track side\n");
780  break;
782  GfOut("Pits = present on separate path\n");
783  break;
784  }
785  if (verbose) {
786  for (i = 0, seg = track->seg->next; i < track->nseg; i++, seg = seg->next) {
787  GfOut(" segment %d -------------- \n", seg->id);
788 #ifdef DEBUG
789  GfOut(" type %s\n", stype[seg->type]);
790 #endif
791  GfOut(" length %f\n", seg->length);
792  GfOut(" radius %f\n", seg->radius);
793  GfOut(" arc %f Zs %f Ze %f Zcs %f\n", RAD2DEG(seg->arc),
794  RAD2DEG(seg->angle[TR_ZS]),
795  RAD2DEG(seg->angle[TR_ZE]),
796  RAD2DEG(seg->angle[TR_CS]));
797  GfOut(" Za %f\n", RAD2DEG(seg->angle[TR_ZS]));
798  GfOut(" vertices: %-8.8f %-8.8f %-8.8f ++++ ",
799  seg->vertex[TR_SR].x,
800  seg->vertex[TR_SR].y,
801  seg->vertex[TR_SR].z);
802  GfOut("%-8.8f %-8.8f %-8.8f\n",
803  seg->vertex[TR_SL].x,
804  seg->vertex[TR_SL].y,
805  seg->vertex[TR_SL].z);
806  GfOut(" vertices: %-8.8f %-8.8f %-8.8f ++++ ",
807  seg->vertex[TR_ER].x,
808  seg->vertex[TR_ER].y,
809  seg->vertex[TR_ER].z);
810  GfOut("%-8.8f %-8.8f %-8.8f\n",
811  seg->vertex[TR_EL].x,
812  seg->vertex[TR_EL].y,
813  seg->vertex[TR_EL].z);
814  GfOut(" prev %d\n", seg->prev->id);
815  GfOut(" next %d\n", seg->next->id);
816  }
817  GfOut("From Last To First\n");
818  GfOut("Dx = %-8.8f Dy = %-8.8f Dz = %-8.8f\n",
819  track->seg->next->vertex[TR_SR].x - track->seg->vertex[TR_ER].x,
820  track->seg->next->vertex[TR_SR].y - track->seg->vertex[TR_ER].y,
821  track->seg->next->vertex[TR_SR].z - track->seg->vertex[TR_ER].z);
822 
823  }
824 }
825 
826 
831 int
833 {
834  int curTrkIdx;
835  void *params = ReInfo->params;
836  void *results = ReInfo->results;
837  const int BUFSIZE = 1024;
838  char buf[BUFSIZE];
839 
840 
841  curTrkIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1);
842  snprintf(buf, BUFSIZE, "%s/%d", RM_SECT_TRACKS, curTrkIdx);
843  const char* trackName = GfParmGetStr(params, buf, RM_ATTR_NAME, 0);
844  if (!trackName) return -1;
845 
846  const char* catName = GfParmGetStr(params, buf, RM_ATTR_CATEGORY, 0);
847  if (!catName) return -1;
848 
849  snprintf(buf, BUFSIZE, "Loading Track %s...", trackName);
851  snprintf(buf, BUFSIZE, "tracks/%s/%s/%s.%s", catName, trackName, trackName, TRKEXT);
852  ReInfo->track = ReInfo->_reTrackItf.trkBuild(buf);
853  reDumpTrack(ReInfo->track, 0);
854 
855  return 0;
856 }
857 
858 void
860 {
861  ReInfo->_reGameScreen = ReHookInit();
862  ReInfo->_reSimItf.shutdown();
863  if (ReInfo->_displayMode == RM_DISP_MODE_NORMAL) {
864  ReInfo->_reGraphicItf.shutdowncars();
865  startMenuMusic();
866  }
867  ReStoreRaceResults(ReInfo->_reRaceName);
869 }
870 
871 
872 void
874 {
875  int i;
876  tRobotItf *robot;
877  int nCars;
878 
879  nCars = ReInfo->s->_ncars;
880  for (i = 0; i < nCars; i++) {
881  robot = ReInfo->s->cars[i]->robot;
882  if (robot->rbShutdown) {
883  robot->rbShutdown(robot->index);
884  }
885  GfParmReleaseHandle(ReInfo->s->cars[i]->_paramsHandle);
886  GfParmReleaseHandle(ReInfo->s->cars[i]->_carHandle);
887  free(robot);
888 
889  // Release penalties
890  tCarPenalty *penalty = GF_TAILQ_FIRST(&(ReInfo->s->cars[i]->_penaltyList));
891  while (penalty) {
892  GF_TAILQ_REMOVE(&(ReInfo->s->cars[i]->_penaltyList), penalty, link);
893  FREEZ(penalty);
894  penalty = GF_TAILQ_FIRST(&(ReInfo->s->cars[i]->_penaltyList));
895  }
896  }
897 
898  FREEZ(ReInfo->s->cars);
899  ReInfo->s->cars = 0;
900  ReInfo->s->_ncars = 0;
902 }
903 
904 
905 const char *
907 {
908  int curRaceIdx;
909  void *params = ReInfo->params;
910  void *results = ReInfo->results;
911  const int BUFSIZE = 1024;
912  char path[BUFSIZE];
913 
914  curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
915  snprintf(path, BUFSIZE, "%s/%d", RM_SECT_RACES, curRaceIdx);
916  return GfParmGetStr(params, path, RM_ATTR_NAME, 0);
917 }
918 
919 const char *
921 {
922  int curRaceIdx;
923  void *params = ReInfo->params;
924  void *results = ReInfo->results;
925  const int BUFSIZE = 1024;
926  char path[BUFSIZE];
927 
928  curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1) - 1;
929  snprintf(path, BUFSIZE, "%s/%d", RM_SECT_RACES, curRaceIdx);
930  return GfParmGetStr(params, path, RM_ATTR_NAME, 0);
931 }
#define RM_ATTR_TOSTART
Definition: raceman.h:275
tdble RtTrackHeightL(tTrkLocPos *p)
Returns the absolute height in meters of the road at the Local position p.
Definition: rttrack.cpp:314
#define RM_ATTR_PRIO
Definition: raceman.h:256
int nMaxPits
number max of pits
Definition: track.h:462
#define GfError
Definition: tgf.h:351
tdble angle[7]
Definition: track.h:337
static void reSelectRaceman(void *params)
Definition: raceinit.cpp:139
int driversPitsNb
Number of drivers.
Definition: track.h:477
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.
Definition: directory.cpp:59
Race Manager General Info.
Definition: raceman.h:218
#define TR_SR
Start-Right corner.
Definition: track.h:333
tRmCarRules * rules
by car rules
Definition: raceman.h:226
int GfModLoad(unsigned int gfid, char *dllname, tModList **modlist)
Load the specified DLLs.
Definition: module.cpp:57
tModInfo modInfo[MAX_MOD_ITF]
module info list for this dll
Definition: tgf.h:204
void ReStateManage(void)
Definition: racestate.cpp:56
void ReRunRaceOnConsole(const char *raceconfig)
Definition: raceinit.cpp:159
void * userData
User data.
Definition: tgf.h:235
void ReInit(void)
Definition: raceinit.cpp:63
tTrackOwnPit * driversPits
List of pits by driver.
Definition: track.h:475
int GfParmCheckHandle(void *ref, void *tgt)
Check the values in the parameter set tgt against the min/max/within definitions in the ref parameter...
Definition: params.cpp:2728
#define PRM_CATEGORY
Definition: car.h:511
int type
Geometrical type:
Definition: track.h:280
void RtInitCarPitSetup(void *carparmhandle, tCarPitSetup *setup, bool minmaxonly)
Initialize tCarPitSetup from data in parameter set given in handle hdle.
Definition: rttrack.cpp:714
#define ROB_ATTR_LEVEL
Definition: robot.h:142
static void initPits(void)
Definition: raceinit.cpp:408
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition: params.cpp:1157
#define TR_ER
End_Right corner.
Definition: track.h:335
cars situation used to inform the GUI and the drivers
Definition: raceman.h:85
Interface Structure for Robots.
Definition: robot.h:107
void ReRaceCleanDrivers(void)
Definition: raceinit.cpp:873
int index
Definition: raceinit.cpp:57
#define RM_DRV_ROBOT
Definition: car.h:123
#define ROB_ATTR_TYPE
Definition: robot.h:137
#define RM_ATT_CAPTURE_OUT_DIR
Definition: raceman.h:325
int GfuiMenuButtonCreate(void *scr, const char *text, const char *tip, void *userdata, tfuiCallback onpush)
Add a button to a menu screen.
Definition: guimenu.cpp:110
int GfParmListSeekNext(void *handle, const char *path)
Go the the next subsection element in the parameter set handle.
Definition: params.cpp:2184
int freeCarIndex
Definition: track.h:448
#define GFPARM_RMODE_STD
if handle already openned return it
Definition: tgf.h:265
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...
Definition: params.cpp:2962
#define TR_ZS
Rotation angles of the track in rad anti-clockwise: Index in:
Definition: track.h:347
#define TR_STR
Straight.
Definition: track.h:287
tCarElt ** cars
list of cars
Definition: raceman.h:90
#define RACE_ENG_CFG
Definition: raceinit.h:29
#define FREEZ(x)
Definition: tgf.h:60
#define RM_SECT_TRACKS
Definition: raceman.h:239
#define RE_ATTR_INDEX
Definition: raceman.h:338
#define ROB_ATTR_TEAM
Definition: robot.h:127
static const char * level_str[]
Definition: raceinit.cpp:50
#define RM_ATTR_DRVNAME
Definition: raceman.h:258
#define RM_DRV_HUMAN
Definition: car.h:122
static tModList * reEventModList
Definition: raceinit.cpp:52
tdble lmax
Pitting area length max.
Definition: track.h:447
void * results
Race results.
Definition: raceman.h:224
int pitCarIndex
Index of the car in the car array below which occupies the pit.
Definition: track.h:443
void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag)
Calculate global coordinates from a local position relative to the given track segment (segment...
Definition: rttrack.cpp:80
Car structure (tCarElt).
Definition: car.h:455
#define TR_PIT_ON_TRACK_SIDE
The pits are on the track side.
Definition: track.h:460
One penalty.
Definition: car.h:130
char * GetLocalDir(void)
Definition: tgf.cpp:231
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
Definition: params.cpp:1834
double deltaSimu
Definition: raceman.h:206
double deltaFrame
Definition: raceman.h:207
#define TR_SL
Start-Left corner.
Definition: track.h:332
tModList * ReRaceModList
Definition: raceinit.cpp:53
tCarPitCmd pitcmd
private
Definition: car.h:463
#define RE_ATTR_CUR_RACE
Definition: raceman.h:333
Robots Tools.
tdble width
main track width
Definition: track.h:513
#define ROB_ATTR_RACENUM
Definition: robot.h:132
Track structure.
Definition: track.h:502
Robot Module Interface Definition.
#define MAX_MOD_ITF
Maximum number of interface in one DLL.
Definition: tgf.h:185
static void reSortRacemanList(tFList **racemanList)
Definition: raceinit.cpp:220
#define TR_CS
Center start angle.
Definition: track.h:353
tdble lmin
Pitting area length min.
Definition: track.h:446
void ReAddRacemanListButton(void *menuHandle)
Definition: raceinit.cpp:255
#define RE_SECT_CURRENT
Definition: raceman.h:332
static void initStartingGrid(void)
Definition: raceinit.cpp:311
#define RM_SECT_STARTINGGRID
Definition: raceman.h:237
tdble lgfromstart
Length of beginning of segment from starting line.
Definition: track.h:319
tfRbNewTrack rbNewTrack
Definition: robot.h:108
tSituation * s
Situation during race.
Definition: raceman.h:221
List of (DLL) files for a Directory.
Definition: tgf.h:229
tdble length
Length in meters of the middle of the track.
Definition: track.h:315
#define TR_PIT_ON_SEPARATE_PATH
Definition: track.h:461
#define RM_ATTR_INITSPEED
Definition: raceman.h:278
void ReShutdown(void)
Definition: raceinit.cpp:107
#define RM_ATTR_NAME
Definition: raceman.h:257
#define RM_ATTR_POLE
Definition: raceman.h:283
#define RM_ATT_CAPTURE_FPS
Definition: raceman.h:324
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
Definition: params.cpp:2311
#define RAD2DEG(x)
Radian to degree conversion.
Definition: tgf.h:75
static void reRegisterRaceman(tFList *racemanCur)
Definition: raceinit.cpp:208
#define GFPARM_MMODE_RELDST
release tgt after the merge
Definition: tgf.h:316
The Gaming Framework API (client part).
void ReStartNewRace(void *)
Definition: raceinit.cpp:131
#define dllname
static char * strndup(const char *str, int len)
Definition: portability.h:39
tCarElt * carList
List of all the cars racing.
Definition: raceman.h:220
#define RM_ATTR_COLDIST
Definition: raceman.h:276
tdble length
main track length
Definition: track.h:512
tTrkLocPos pos
Center of the pit position.
Definition: track.h:442
int GfParmListSeekFirst(void *handle, const char *path)
Go the the first subsection element in the parameter set handle.
Definition: params.cpp:2148
#define ROB_LIST_INDEX
Definition: robot.h:124
struct CarElt * car[TR_PIT_MAXCARPERPIT]
Car links for pit.
Definition: track.h:449
bool isItThisRobot(tRmInfo *reInfo, const char *path, tModInfo *modInfo)
Definition: raceinit.cpp:514
static const char * d3
int ReInitTrack(void)
Initialize the track for a race manager.
Definition: raceinit.cpp:832
tRmInfo * ReInfo
Definition: raceengine.cpp:45
#define RM_ATTR_COLOFFSET
Definition: raceman.h:277
#define CAR_IDENT
Definition: car.h:33
tModList ** modList
drivers loaded
Definition: raceman.h:225
#define TR_LFT
Left curve.
Definition: track.h:286
struct FList * next
Next entry.
Definition: tgf.h:231
tfModPrivInit fctInit
init function
Definition: tgf.h:191
char * GetLibDir(void)
Definition: tgf.cpp:244
#define TR_PIT_MAXCARPERPIT
Definition: track.h:445
#define RM_SECT_MOVIE_CAPTURE
Definition: raceman.h:321
Driver&#39;s pit.
Definition: track.h:440
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
char * dispName
Name to display on screen.
Definition: tgf.h:234
#define RM_ATTR_INITHEIGHT
Definition: raceman.h:279
struct RobotItf * robot
private
Definition: car.h:464
#define RM_ATTR_IDX
Definition: raceman.h:266
#define ROB_ATTR_NAME
Definition: robot.h:126
#define GfOut
Definition: tgf.h:373
#define RM_ATTR_MODULE
Definition: raceman.h:265
const char * name
Name of the track.
Definition: track.h:504
tModList * curmod
Definition: raceinit.cpp:58
#define GFPARM_RMODE_REREAD
reread the parameters from file and release the previous ones
Definition: tgf.h:266
tCarPitSetup setup
Definition: car.h:441
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
Definition: tgf.h:485
#define RM_ATTR_ROWS
Definition: raceman.h:274
tTrack * track
Current track.
Definition: raceman.h:222
tRmRaceRules raceRules
Definition: raceman.h:229
#define RM_ATT_CAPTURE_ENABLE
Definition: raceman.h:323
void * params
Parameters handle.
Definition: track.h:507
tdble arc
Arc in rad of the curve (>0)
Definition: track.h:323
#define TR_ZE
Z End angle.
Definition: track.h:348
int ReInitCars(void)
Initialize the cars for a race.
Definition: raceinit.cpp:556
#define ROB_VAL_AMATEUR
Definition: robot.h:145
tdble radius
Radius in meters of the middle of the track (>0)
Definition: track.h:320
#define ROB_VAL_ROOKIE
Definition: robot.h:144
tdble y
y coordinate
Definition: tgf.h:117
int GfModUnloadList(tModList **modlist)
Unload the DLLs of a list.
Definition: module.cpp:91
tRmMovieCapture movieCapture
Definition: raceman.h:228
tdble z
z coordinate
Definition: tgf.h:118
const char * ReGetCurrentRaceName(void)
Definition: raceinit.cpp:906
t3Dd vertex[4]
Coordinates of the 4 corners of the segment.
Definition: track.h:325
#define ROB_VAL_PRO
Definition: robot.h:147
#define TR_PIT_NONE
No pits for that tracks.
Definition: track.h:459
This is the race information structures.
#define RE_STATE_EVENT_INIT
Definition: raceman.h:102
int index
car index
Definition: car.h:457
tdble fuelFactor
Definition: raceman.h:188
#define RM_SECT_DRIVERS
Definition: raceman.h:236
#define GF_TAILQ_FIRST(head)
First element of a TAILQ.
Definition: tgf.h:464
tdble tireFactor
Definition: raceman.h:193
#define ROB_SECT_ROBOTS
Definition: robot.h:122
tTrackSeg * seg
Track segment.
Definition: track.h:420
#define SECT_CAR
Definition: car.h:473
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
#define TR_EL
End-Left corner.
Definition: track.h:334
void ReInitResults(void)
#define GF_TAILQ_REMOVE(head, elm, field)
Remove an element.
Definition: tgf.h:541
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.
Definition: params.cpp:2679
struct FList * prev
Previous entry.
Definition: tgf.h:232
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
Definition: track.h:276
int track(tModInfo *modInfo)
Definition: trackitf.cpp:85
char * name
name of the module (short) (NULL if no module)
Definition: tgf.h:189
int index
index if multiple interface in one dll
Definition: tgf.h:193
int carsPerPit
Definition: track.h:476
tfRbShutdown rbShutdown
Definition: robot.h:113
Pits Info Structure.
Definition: track.h:453
#define GFPARM_MMODE_RELSRC
release ref after the merge
Definition: tgf.h:315
#define ROB_ATTR_CAR
Definition: robot.h:130
#define RM_ATTR_SKILL_LEVEL_DEFAULT
Definition: raceman.h:254
#define RM_ATTR_CATEGORY
Definition: raceman.h:259
#define TR_RGT
Right curve.
Definition: track.h:285
tdble len
Lenght of each pit stop.
Definition: track.h:468
tdble toStart
Distance to start of segment (or arc if turn)
Definition: track.h:431
#define RM_ATTR_CARSPERPIT
Definition: raceman.h:284
#define RM_SECT_RACES
Definition: raceman.h:238
#define NORM0_2PI(x)
Angle normalization between 0 and 2 * PI.
Definition: tgf.h:81
struct trackSeg * prev
Previous segment.
Definition: track.h:398
#define ROB_VAL_SEMI_PRO
Definition: robot.h:146
#define TR_PIT_STATE_FREE
Definition: track.h:444
int GfParmGetEltNb(void *handle, const char *path)
Count the number of subsections in a section in the parameter set handle.
Definition: params.cpp:2106
struct trackSeg * next
Next segment.
Definition: track.h:397
#define RM_DISP_MODE_CONSOLE
Definition: raceman.h:149
#define TR_TORIGHT
Definition: track.h:413
char * GfParmGetFileName(void *handle)
Get the filename property of the parameter set handle.
Definition: params.cpp:2082
#define ROB_VAL_ROBOT
Definition: robot.h:140
#define GFPARM_MMODE_DST
use tgt and verify ref parameters
Definition: tgf.h:314
void RmLoadingScreenSetText(const char *text)
Set a new line of text on the loading screen.
char * name
File name.
Definition: tgf.h:233
static tRmTrackSelect ts
Definition: racemanmenu.cpp:45
#define RM_ATTR_DESCR
Definition: raceman.h:260
#define GfTrace
Definition: tgf.h:336
#define RE_STATE_CONFIG
Definition: raceman.h:101
#define RM_DISP_MODE_NORMAL
Definition: raceman.h:146
#define RE_ATTR_CUR_TRACK
Definition: raceman.h:334
void ReRaceCleanup(void)
Definition: raceinit.cpp:859
tdble damageFactor
Definition: raceman.h:189
list of module interfaces
Definition: tgf.h:203
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.
Definition: params.cpp:2354
const char * ReGetPrevRaceName(void)
Definition: raceinit.cpp:920
int index
Definition: robot.h:114
#define RM_SECT_DRIVERS_RACING
Definition: raceman.h:244
tTrackSeg * seg
Main track.
Definition: track.h:515
void startMenuMusic()
Definition: musicplayer.cpp:80
static void reDumpTrack(tTrack *track, int verbose)
Dump the track segments on screen.
Definition: raceinit.cpp:742
Module information structure.
Definition: tgf.h:188
void ReStateApply(void *vstate)
Definition: racestate.cpp:177
tTrackPitInfo pits
Pits information.
Definition: track.h:514
void * params
Raceman parameters.
Definition: raceman.h:223
tdble x
x coordinate
Definition: tgf.h:116
#define GFPARM_RMODE_CREAT
Create the file if doesn&#39;t exist.
Definition: tgf.h:267
#define RCM_MAX_DT_SIMU
Definition: raceman.h:56
#define RM_SECT_HEADER
Definition: raceman.h:235
int id
Segment number.
Definition: track.h:278
#define MAX_NAME_LEN
Definition: car.h:35
#define freez
Definition: tgf.h:67
#define GFPARM_MMODE_SRC
use ref and modify existing parameters with tgt
Definition: tgf.h:313
void * ReHookInit(void)
Definition: racegl.cpp:230
const char * outputBase
Definition: raceman.h:209
int type
Type of Pit:
Definition: track.h:455