forked from speed-dreams/speed-dreams-code
Added race engine and weather traces
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3008 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: d3b2e6c351583d2662134a81c195a1cede371396 Former-commit-id: 8e00093b0d679a1ae62e6e7622d8bd3e7239a565
This commit is contained in:
parent
841ee6f7c5
commit
508d93ddf6
3 changed files with 103 additions and 73 deletions
|
@ -738,7 +738,7 @@ static tCarElt* reLoadSingleCar( int carindex, int listindex, int modindex, int
|
|||
|
||||
return elt;
|
||||
} else {
|
||||
GfLogError("No description file for driver %s\n", cardllname);
|
||||
GfLogError("No description file for robot %s\n", cardllname);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -786,7 +786,7 @@ ReInitCars(void)
|
|||
/* Load the driver type shared library */
|
||||
if (GfModLoad(CAR_IDENT, path, ReInfo->modList))
|
||||
{
|
||||
GfLogError("Failed to load %s driver\n", path);
|
||||
GfLogError("Failed to load robot module %s\n", path);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -804,13 +804,13 @@ ReInitCars(void)
|
|||
/* We have the right driver : load it */
|
||||
elt = reLoadSingleCar( index, i, j, robotIdx, TRUE, robotModuleName );
|
||||
if (!elt)
|
||||
GfLogError("No description file for driver %s (1)\n", robotModuleName);
|
||||
GfLogError("No descriptor file for robot %s (1)\n", robotModuleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GfLogTrace("Loading driver %s\n", robotModuleName );
|
||||
GfLogTrace("Loading robot %s descriptor file\n", robotModuleName );
|
||||
sprintf(buf, "%sdrivers/%s/%s.xml", GetLocalDir(), robotModuleName, robotModuleName);
|
||||
robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
|
||||
if (!robhdle)
|
||||
|
@ -829,7 +829,7 @@ ReInitCars(void)
|
|||
elt = reLoadSingleCar( index, i, (*(ReInfo->modList))->modInfoSize, robotIdx, FALSE, robotModuleName );
|
||||
}
|
||||
else
|
||||
GfLogError("No description for driver %s (2)\n", robotModuleName );
|
||||
GfLogError("No descriptor for robot %s (2)\n", robotModuleName );
|
||||
|
||||
}
|
||||
|
||||
|
@ -882,17 +882,17 @@ reDumpTrack(const tTrack *track, int verbose)
|
|||
track->author, track->length, track->width);
|
||||
RmLoadingScreenSetText(buf);
|
||||
|
||||
GfOut("++++++++++++ Track ++++++++++++\n");
|
||||
GfOut("Name = %s\n", track->name);
|
||||
GfOut("Author = %s\n", track->author);
|
||||
GfOut("Filename = %s\n", track->filename);
|
||||
GfOut("NSeg = %d\n", track->nseg);
|
||||
GfOut("Version = %d\n", track->version);
|
||||
GfOut("Length = %f\n", track->length);
|
||||
GfOut("Width = %f\n", track->width);
|
||||
GfOut("XSize = %f\n", track->max.x);
|
||||
GfOut("YSize = %f\n", track->max.y);
|
||||
GfOut("ZSize = %f\n", track->max.z);
|
||||
GfLogInfo("++++++++++++ Track ++++++++++++\n");
|
||||
GfLogInfo("Name = %s\n", track->name);
|
||||
GfLogInfo("Author = %s\n", track->author);
|
||||
GfLogInfo("Filename = %s\n", track->filename);
|
||||
GfLogInfo("NSeg = %d\n", track->nseg);
|
||||
GfLogInfo("Version = %d\n", track->version);
|
||||
GfLogInfo("Length = %f\n", track->length);
|
||||
GfLogInfo("Width = %f\n", track->width);
|
||||
GfLogInfo("XSize = %f\n", track->max.x);
|
||||
GfLogInfo("YSize = %f\n", track->max.y);
|
||||
GfLogInfo("ZSize = %f\n", track->max.z);
|
||||
|
||||
switch (track->pits.type) {
|
||||
case TR_PIT_NONE:
|
||||
|
@ -908,6 +908,9 @@ reDumpTrack(const tTrack *track, int verbose)
|
|||
break;
|
||||
}//switch pits.type
|
||||
|
||||
GfLogInfo("TimeOfDay= %d\n", track->Timeday);
|
||||
GfLogInfo("Weather = %d\n", track->weather);
|
||||
|
||||
if (verbose) {
|
||||
int i;
|
||||
tTrackSeg *seg;
|
||||
|
@ -967,8 +970,6 @@ ReInitTrack(void)
|
|||
const char *raceName;
|
||||
const char *cloudA;
|
||||
|
||||
//int rain;
|
||||
|
||||
void *params = ReInfo->params;
|
||||
void *results = ReInfo->results;
|
||||
|
||||
|
@ -1048,15 +1049,23 @@ ReInitTrack(void)
|
|||
|
||||
//DEBUG WEATHER - Verification function update friction
|
||||
#ifdef DEBUG
|
||||
tTrack *track = ReInfo->track;
|
||||
tTrackSurface *curSurf;
|
||||
curSurf = track->surfaces;
|
||||
do {
|
||||
GfLogDebug("ReInitTrack: Friction = %f - RollRes = %f\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
curSurf = curSurf->next;
|
||||
} while ( curSurf != 0);
|
||||
// No use since already done in that ReTrackUpdate is always called by ReStartWeather.
|
||||
// tTrack *track = ReInfo->track;
|
||||
// GfLogDebug("ReInitTrack : Track params : clouds=%d, rain=%d l/m2/h\n",
|
||||
// cloudA, weather_rain);
|
||||
// GfLogDebug("ReInitTrack : Track timeday=%d, weather=%d, rain=%d, rainp=%d, rainlp=%d\n",
|
||||
// track->Timeday, track->weather, track->Rain, track->rainprob, track->rainlprob);
|
||||
// GfLogDebug("ReInitTrack : kFriction, kRollRes for each track surface :\n");
|
||||
// tTrackSurface *curSurf;
|
||||
// curSurf = track->surfaces;
|
||||
// do {
|
||||
// GfLogDebug(" %.4f, %.4f %s\n",
|
||||
// curSurf->kFriction, curSurf->kRollRes, curSurf->material);
|
||||
// curSurf = curSurf->next;
|
||||
// } while ( curSurf );
|
||||
#endif
|
||||
// End Function DEBUG TRACE Variable kFriction
|
||||
|
||||
return 0;
|
||||
}//ReInitTrack
|
||||
|
||||
|
|
|
@ -500,17 +500,20 @@ ReRaceStart(void)
|
|||
void *params = ReInfo->params;
|
||||
void *results = ReInfo->results;
|
||||
|
||||
#ifdef DEBUG
|
||||
tTrack *track = ReInfo->track;
|
||||
tTrackSurface *curSurf;
|
||||
curSurf = track->surfaces;
|
||||
do
|
||||
{
|
||||
GfLogDebug("Raceinit Function Friction = %f - RollRes = %f No Rain\n",
|
||||
curSurf->kFriction, curSurf->kRollRes);
|
||||
curSurf = curSurf->next;
|
||||
} while ( curSurf != 0);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
tTrack *track = ReInfo->track;
|
||||
GfLogDebug("ReRaceStart : Track timeday=%d, weather=%d, rain=%d, rainp=%d, rainlp=%d\n",
|
||||
track->Timeday, track->weather, track->Rain, track->rainprob, track->rainlprob);
|
||||
GfLogDebug("ReRaceStart : kFriction, kRollRes for each track surface :\n");
|
||||
tTrackSurface *curSurf;
|
||||
curSurf = track->surfaces;
|
||||
do
|
||||
{
|
||||
GfLogDebug(" %.4f, %.4f %s\n",
|
||||
curSurf->kFriction, curSurf->kRollRes, curSurf->material);
|
||||
curSurf = curSurf->next;
|
||||
} while (curSurf);
|
||||
#endif
|
||||
|
||||
FREEZ(ReInfo->_reCarInfo);
|
||||
ReInfo->_reCarInfo = (tReCarInfo*)calloc(GfParmGetEltNb(params, RM_SECT_DRIVERS), sizeof(tReCarInfo));
|
||||
|
@ -518,7 +521,11 @@ ReRaceStart(void)
|
|||
/* Drivers starting order */
|
||||
GfParmListClean(params, RM_SECT_DRIVERS_RACING);
|
||||
if ((ReInfo->s->_raceType == RM_TYPE_QUALIF || ReInfo->s->_raceType == RM_TYPE_PRACTICE)
|
||||
&& ReInfo->s->_totTime < 0.0f) {
|
||||
&& ReInfo->s->_totTime < 0.0f)
|
||||
{
|
||||
GfLogInfo("Starting %s %s session\n",
|
||||
ReInfo->_reName, ReInfo->s->_raceType == RM_TYPE_PRACTICE ? "practice" : "qualification");
|
||||
|
||||
i = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
|
||||
if (i == 1) {
|
||||
RmLoadingScreenStart(ReInfo->_reName, "data/img/splash-raceload.png");
|
||||
|
@ -535,13 +542,19 @@ ReRaceStart(void)
|
|||
const char* pszSkinName = GfParmGetStr(params, path, RM_ATTR_SKINNAME, 0);
|
||||
if (pszSkinName && strlen(pszSkinName) > 0)
|
||||
GfParmSetStr(params, path2, RM_ATTR_SKINNAME, pszSkinName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RmLoadingScreenStart(ReInfo->_reName, "data/img/splash-raceload.png");
|
||||
RmLoadingScreenSetText("Preparing Starting Grid ...");
|
||||
|
||||
gridType = GfParmGetStr(params, raceName, RM_ATTR_START_ORDER, RM_VAL_DRV_LIST_ORDER);
|
||||
if (!strcmp(gridType, RM_VAL_LAST_RACE_ORDER)) {
|
||||
/* Starting grid in the arrival order of the previous race */
|
||||
|
||||
/* Starting grid in the arrival order of the previous race */
|
||||
if (!strcmp(gridType, RM_VAL_LAST_RACE_ORDER))
|
||||
{
|
||||
GfLogInfo("Starting %s : Starting grid in the order of the last race\n", ReInfo->_reName);
|
||||
|
||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
||||
nCars = MIN(nCars, maxCars);
|
||||
|
@ -559,8 +572,13 @@ ReRaceStart(void)
|
|||
if (pszSkinName && strlen(pszSkinName) > 0)
|
||||
GfParmSetStr(params, path2, RM_ATTR_SKINNAME, pszSkinName);
|
||||
}
|
||||
} else if (!strcmp(gridType, RM_VAL_LAST_RACE_RORDER)) {
|
||||
/* Starting grid in the reversed arrival order of the previous race */
|
||||
}
|
||||
|
||||
/* Starting grid in the reversed arrival order of the previous race */
|
||||
else if (!strcmp(gridType, RM_VAL_LAST_RACE_RORDER))
|
||||
{
|
||||
GfLogInfo("Starting %s : Starting grid in the reverse order of the last race\n", ReInfo->_reName);
|
||||
|
||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
||||
nCars = MIN(nCars, maxCars);
|
||||
|
@ -578,8 +596,13 @@ ReRaceStart(void)
|
|||
if (pszSkinName && strlen(pszSkinName) > 0)
|
||||
GfParmSetStr(params, path2, RM_ATTR_SKINNAME, pszSkinName);
|
||||
}
|
||||
} else {
|
||||
/* Starting grid in the drivers list order */
|
||||
}
|
||||
|
||||
/* Starting grid in the drivers list order */
|
||||
else
|
||||
{
|
||||
GfLogInfo("Starting %s : Starting grid in the order of the driver list\n", ReInfo->_reName);
|
||||
|
||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
||||
nCars = MIN(nCars, maxCars);
|
||||
|
@ -595,6 +618,7 @@ ReRaceStart(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ReWeatherUpdate();
|
||||
|
||||
if (!strcmp(GfParmGetStr(params, ReInfo->_reRaceName, RM_ATTR_SPLASH_MENU, RM_VAL_NO), RM_VAL_YES)) {
|
||||
|
|
|
@ -48,23 +48,27 @@ void ReStartWeather(void)
|
|||
int resul2;
|
||||
tTrack *track = ReInfo->track;
|
||||
|
||||
// TODO: Move this inside TGF initialization, or so (in order to have it done only once).
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
cloud = track->weather;
|
||||
Timeday = track->Timeday;
|
||||
|
||||
if (Timeday > 0)
|
||||
{
|
||||
GfLogDebug("ReStartWeather : Using loaded rain params\n");
|
||||
rainbool = track->weather;
|
||||
rainbool = rainbool - 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
GfLogDebug("ReStartWeather : Using random rain params\n");
|
||||
rain = track->rainprob;
|
||||
cloud = 1 + (int)(rand()/(float)RAND_MAX * 7); //random cloud on Track when championship or career
|
||||
track->weather = cloud; // cloud = random cloud
|
||||
|
||||
resul = 1 + (int)(rand()/(float)RAND_MAX * 99); // probability rain, if result < rain, so it rain
|
||||
//printf("Result = %d - Rain = %d\n", resul, rain);
|
||||
//GfLogDebug("Result = %d - Rain = %d\n", resul, rain);
|
||||
if (resul < rain)
|
||||
{
|
||||
problrain = track->rainlprob;
|
||||
|
@ -74,17 +78,17 @@ void ReStartWeather(void)
|
|||
if (resul2 < (problrain + 1)) // if result2 < probability little rain, so rain = little rain
|
||||
{
|
||||
rainbool = RAIN_VAL_LITTLE;
|
||||
//printf("RainBool = %d\n", rainbool);
|
||||
//GfLogDebug("RainBool = %d\n", rainbool);
|
||||
}
|
||||
else if (resul2 < (probrain +1)) // if result2 < probability normal rain, so rain = normal rain
|
||||
{
|
||||
rainbool = RAIN_VAL_NORMAL;
|
||||
//printf("RainBool = %d\n", rainbool);
|
||||
//GfLogDebug("RainBool = %d\n", rainbool);
|
||||
}
|
||||
else // result2 > probability normal rain so rain = Heavy rain
|
||||
{
|
||||
rainbool = RAIN_VAL_HEAVY;
|
||||
//printf("RainBool = %d\n", rainbool);
|
||||
//GfLogDebug("RainBool = %d\n", rainbool);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -93,23 +97,24 @@ void ReStartWeather(void)
|
|||
}
|
||||
|
||||
if (rainbool > 0)
|
||||
{
|
||||
track->Rain = rainbool;
|
||||
ReTrackUpdate();
|
||||
}
|
||||
track->Rain = rainbool;
|
||||
else
|
||||
track->Rain = 0;
|
||||
ReTrackUpdate();
|
||||
|
||||
ReTrackUpdate();
|
||||
}
|
||||
|
||||
// Update Track Physic
|
||||
void ReTrackUpdate(void)
|
||||
{
|
||||
int rain;
|
||||
tTrack *track = ReInfo->track;
|
||||
tTrackSurface *curSurf;
|
||||
int rain = track->Rain;
|
||||
|
||||
rain = track->Rain;
|
||||
GfLogDebug("ReTrackUpdate : Track timeday=%d, weather=%d, rain=%d, rainp=%d, rainlp=%d\n",
|
||||
track->Timeday, track->weather, track->Rain, track->rainprob, track->rainlprob);
|
||||
GfLogDebug("ReTrackUpdate : kFriction, kRollRes for each track surface :\n");
|
||||
|
||||
tTrackSurface *curSurf;
|
||||
curSurf = track->surfaces;
|
||||
do
|
||||
{
|
||||
|
@ -118,41 +123,33 @@ void ReTrackUpdate(void)
|
|||
case 1:
|
||||
{
|
||||
curSurf->kFriction = curSurf->kFriction2;
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
#ifdef DEBUG
|
||||
printf("ReTrackUpdate Function Friction = %f - RollRes = %f Little Rain\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
#endif
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
curSurf->kFriction = curSurf->kFriction2 * 0.9f;
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
#ifdef DEBUG
|
||||
printf("ReTrackUpdate Function Friction = %f - RollRes = %f Normal Rain\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
#endif
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
curSurf->kFriction = curSurf->kFriction2 * 0.7f;
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
#ifdef DEBUG
|
||||
printf("ReTrackUpdate Function Friction = %f - RollRes = %f Heavy Rain\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
#endif
|
||||
curSurf->kRollRes = curSurf->kRollRes2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
curSurf->kFriction = curSurf->kFriction;
|
||||
curSurf->kRollRes = curSurf->kRollRes;
|
||||
#ifdef DEBUG
|
||||
printf("ReTrackUpdate Function Friction = %f - RollRes = %f No Rain\n", curSurf->kFriction, curSurf->kRollRes);
|
||||
#endif
|
||||
curSurf->kRollRes = curSurf->kRollRes;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GfLogDebug(" %.4f, %.4f %s\n",
|
||||
curSurf->kFriction, curSurf->kRollRes, curSurf->material);
|
||||
|
||||
curSurf = curSurf->next;
|
||||
} while ( curSurf != 0);
|
||||
|
||||
} while ( curSurf );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue