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