- update raceinit

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6054 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: c150948b7501660a060dcaa9c03c89f18b1e2982
Former-commit-id: 0a33d7c19bb41e580e45a201ff5305e0b67b7114
This commit is contained in:
torcs-ng 2015-07-27 19:37:46 +00:00
parent e7f55cb4c1
commit 1e31db3d2a
2 changed files with 650 additions and 614 deletions

View file

@ -426,7 +426,9 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
char buf2[256]; char buf2[256];
char const *str; char const *str;
char const *category; char const *category;
char const *subcategory;
char const *teamname; char const *teamname;
std::string carname;
tModInfoNC *curModInfo; tModInfoNC *curModInfo;
tRobotItf *curRobot; tRobotItf *curRobot;
void *robhdle; void *robhdle;
@ -451,6 +453,8 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
/* Retrieve the driver interface (function pointers) */ /* Retrieve the driver interface (function pointers) */
curRobot = (tRobotItf*)calloc(1, sizeof(tRobotItf)); curRobot = (tRobotItf*)calloc(1, sizeof(tRobotItf));
subcategory = ReInfo->track->subcategory;
/* ... and initialize the driver */ /* ... and initialize the driver */
if (!(ReInfo->_displayMode & RM_DISP_MODE_SIMU_SIMU)) { if (!(ReInfo->_displayMode & RM_DISP_MODE_SIMU_SIMU)) {
curModInfo->fctInit(robotIdx, (void*)(curRobot)); curModInfo->fctInit(robotIdx, (void*)(curRobot));
@ -556,17 +560,44 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
elt->_endRaceMemPool = NULL; elt->_endRaceMemPool = NULL;
elt->_shutdownMemPool = NULL; elt->_shutdownMemPool = NULL;
carname = elt->_carName;
GfLogTrace("Driver #%d(%d) : module='%s', name='%s', car='%s', cat='%s', skin='%s' on %x\n", GfLogTrace("Driver #%d(%d) : module='%s', name='%s', car='%s', cat='%s', skin='%s' on %x\n",
carindex, listindex, elt->_modName, elt->_name, elt->_carName, carindex, listindex, elt->_modName, elt->_name, elt->_carName,
elt->_category, elt->_skinName, elt->_skinTargets); elt->_category, elt->_skinName, elt->_skinTargets);
if ((strncmp(carname.c_str(), "mpa11", 5) == 0) || (strncmp(carname.c_str(), "mpa12", 5) == 0))
{
if (strcmp(subcategory, "long") == 0)
carname = carname+"-long";
else if (strcmp(subcategory, "short") == 0)
carname = carname+"-short";
else
carname = carname+"-road";
GfLogTrace("MPA... Category car = %s \n", carname.c_str());
/* Retrieve and load car specs : merge car default specs, /* Retrieve and load car specs : merge car default specs,
category specs and driver modifications (=> handle) */ category specs and driver modifications (=> handle) */
/* Read Car model specifications */ /* Read Car model specifications */
snprintf(buf, sizeof(buf), "cars/models/%s/%s.xml", elt->_carName, carname.c_str());
carhdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
}
else
{
/* Retrieve and load car specs : merge car default specs,
category specs and driver modifications (=> handle) */
/* Read Car model specifications */
snprintf(buf, sizeof(buf), "cars/models/%s/%s.xml", elt->_carName, elt->_carName); snprintf(buf, sizeof(buf), "cars/models/%s/%s.xml", elt->_carName, elt->_carName);
carhdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT); carhdle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
}
category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL); category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL);
if (category) {
if (category)
{
GfLogTrace("Checking/Merging %s specs into %s base setup for %s ...\n", GfLogTrace("Checking/Merging %s specs into %s base setup for %s ...\n",
category, elt->_carName, curModInfo->name); category, elt->_carName, curModInfo->name);
strncpy(elt->_category, category, MAX_NAME_LEN - 1); strncpy(elt->_category, category, MAX_NAME_LEN - 1);
@ -575,6 +606,7 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
snprintf(buf2, sizeof(buf2), "cars/categories/%s.xml", elt->_category); snprintf(buf2, sizeof(buf2), "cars/categories/%s.xml", elt->_category);
cathdle = GfParmReadFile(buf2, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT); cathdle = GfParmReadFile(buf2, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
int errorcode = 0; int errorcode = 0;
if ((errorcode = GfParmCheckHandle(cathdle, carhdle))) if ((errorcode = GfParmCheckHandle(cathdle, carhdle)))
{ {
switch (errorcode) switch (errorcode)
@ -597,6 +629,7 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
} }
return NULL; return NULL;
} }
carhdle = GfParmMergeHandles(cathdle, carhdle, carhdle = GfParmMergeHandles(cathdle, carhdle,
GFPARM_MMODE_SRC | GFPARM_MMODE_DST | GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST); GFPARM_MMODE_SRC | GFPARM_MMODE_DST | GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST);

View file

@ -652,7 +652,8 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
} }
category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL); category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL);
if (category) { if (category)
{
GfLogTrace("Checking/Merging %s specs into %s base setup for %s ...\n", GfLogTrace("Checking/Merging %s specs into %s base setup for %s ...\n",
category, elt->_carName, curModInfo->name); category, elt->_carName, curModInfo->name);
strncpy(elt->_category, category, MAX_NAME_LEN - 1); strncpy(elt->_category, category, MAX_NAME_LEN - 1);
@ -661,6 +662,7 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
snprintf(buf2, sizeof(buf2), "cars/categories/%s.xml", elt->_category); snprintf(buf2, sizeof(buf2), "cars/categories/%s.xml", elt->_category);
cathdle = GfParmReadFile(buf2, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT); cathdle = GfParmReadFile(buf2, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
int errorcode = 0; int errorcode = 0;
if ((errorcode = GfParmCheckHandle(cathdle, carhdle))) if ((errorcode = GfParmCheckHandle(cathdle, carhdle)))
{ {
switch (errorcode) switch (errorcode)
@ -683,6 +685,7 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
} }
return NULL; return NULL;
} }
carhdle = GfParmMergeHandles(cathdle, carhdle, carhdle = GfParmMergeHandles(cathdle, carhdle,
GFPARM_MMODE_SRC | GFPARM_MMODE_DST | GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST); GFPARM_MMODE_SRC | GFPARM_MMODE_DST | GFPARM_MMODE_RELSRC | GFPARM_MMODE_RELDST);