Re #313 (Split Windows installer) Make Single event races work when some of the XML-specified drivers are not available
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3405 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: d131228896f7eb30eb1404dd80534cb0931b52bd Former-commit-id: aaabba6f24ffa73506b65aef9261b54e23b131a0
This commit is contained in:
parent
ed281f7b77
commit
ee42f9b62e
4 changed files with 61 additions and 64 deletions
|
@ -223,10 +223,9 @@ void
|
||||||
ReStartNewRace(void * /* dummy */)
|
ReStartNewRace(void * /* dummy */)
|
||||||
{
|
{
|
||||||
// Save the race settings to the race manager file is anything changed.
|
// Save the race settings to the race manager file is anything changed.
|
||||||
GfLogDebug("ReStartNewRace: _reName='%s', dirty=%d\n", ReInfo->_reName, PReRace->isDirty());
|
|
||||||
if (PReRace->isDirty())
|
if (PReRace->isDirty())
|
||||||
{
|
{
|
||||||
ReGetRace()->store(); // Save data to params.
|
PReRace->store(); // Save data to params.
|
||||||
GfParmWriteFile(NULL, ReInfo->params, ReInfo->_reName); // Save params to disk.
|
GfParmWriteFile(NULL, ReInfo->params, ReInfo->_reName); // Save params to disk.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,8 +177,8 @@ ReRaceEventInit(void)
|
||||||
|
|
||||||
/* Read the new params */
|
/* Read the new params */
|
||||||
ReInfo->params = GfParmReadFile( GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, "" ), GFPARM_RMODE_STD );
|
ReInfo->params = GfParmReadFile( GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, "" ), GFPARM_RMODE_STD );
|
||||||
GfLogDebug( "ReInfo->mainResults : curfile = %s\n",
|
GfLogDebug("Career : ReInfo->mainResults gives curfile = %s\n",
|
||||||
GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, "" ) );
|
GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, ""));
|
||||||
if (!params)
|
if (!params)
|
||||||
GfLogWarning( "Params weren't read correctly !!!\n" );
|
GfLogWarning( "Params weren't read correctly !!!\n" );
|
||||||
params = ReInfo->params;
|
params = ReInfo->params;
|
||||||
|
|
|
@ -390,10 +390,11 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
|
||||||
// hparmStartGrid == hparmResults ? "hRes" : GfParmGetFileName(hparmStartGrid));
|
// hparmStartGrid == hparmResults ? "hRes" : GfParmGetFileName(hparmStartGrid));
|
||||||
|
|
||||||
std::ostringstream ossDrvSecPath;
|
std::ostringstream ossDrvSecPath;
|
||||||
int nCompIndex = bReversedGrid ? nCompetitors : 1;
|
|
||||||
const int nCompIndexDelta = bReversedGrid ? -1 : +1;
|
const int nCompIndexDelta = bReversedGrid ? -1 : +1;
|
||||||
const int nEndCompIndex = bReversedGrid ? 0 : nCompetitors + 1;
|
const int nEndCompIndex = bReversedGrid ? 0 : nCompetitors + 1;
|
||||||
while (nCompIndex != nEndCompIndex)
|
int nCompIndex = bReversedGrid ? nCompetitors : 1;
|
||||||
|
nCompIndex -= nCompIndexDelta;
|
||||||
|
while ((nCompIndex += nCompIndexDelta) != nEndCompIndex)
|
||||||
{
|
{
|
||||||
// Get driver infos from the the starting grid.
|
// Get driver infos from the the starting grid.
|
||||||
ossDrvSecPath.str("");
|
ossDrvSecPath.str("");
|
||||||
|
@ -414,10 +415,16 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've got it : if we can keep it for the race, make it a competitor
|
// We've got it but can't keep it for the race,
|
||||||
// (there is a threshold on the number of competitors) :
|
// because there is a threshold on the number of competitors.
|
||||||
if (acceptsMoreCompetitors())
|
if (!acceptsMoreCompetitors())
|
||||||
{
|
{
|
||||||
|
GfLogWarning("Ignoring subsequent competitors (max=%u)\n",
|
||||||
|
_pPrivate->nMaxCompetitors);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've got it and can keep it for the race => make it a competitor
|
||||||
const char* pszSkinName =
|
const char* pszSkinName =
|
||||||
GfParmGetStr(hparmStartGrid, ossDrvSecPath.str().c_str(), RM_ATTR_SKINNAME, "");
|
GfParmGetStr(hparmStartGrid, ossDrvSecPath.str().c_str(), RM_ATTR_SKINNAME, "");
|
||||||
const int nSkinTargets =
|
const int nSkinTargets =
|
||||||
|
@ -437,9 +444,9 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
|
||||||
GfParmGetStr(hparmRaceMan, ossDrvSecPath.str().c_str(), RM_ATTR_CARNAME, "<none>");
|
GfParmGetStr(hparmRaceMan, ossDrvSecPath.str().c_str(), RM_ATTR_CARNAME, "<none>");
|
||||||
pCarForRace = GfCars::self()->getCar(pszCarId);
|
pCarForRace = GfCars::self()->getCar(pszCarId);
|
||||||
}
|
}
|
||||||
// GfLogDebug("GfRace::load(...) : car=%s (%s)\n",
|
// GfLogDebug("GfRace::load(...) : car=%s (%s)\n",
|
||||||
// pCarForRace ? pCarForRace->getName().c_str() : pCompetitor->getCar()->getName().c_str(),
|
// pCarForRace ? pCarForRace->getName().c_str() : pCompetitor->getCar()->getName().c_str(),
|
||||||
// pCarForRace ? "extended" : "standard");
|
// pCarForRace ? "extended" : "standard");
|
||||||
|
|
||||||
// Update the driver.
|
// Update the driver.
|
||||||
GfDriverSkin skin(pszSkinName);
|
GfDriverSkin skin(pszSkinName);
|
||||||
|
@ -461,16 +468,6 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
|
||||||
pCompetitor->getName().c_str(), pszModName, nItfIndex);
|
pCompetitor->getName().c_str(), pszModName, nItfIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GfLogWarning("Ignoring subsequent competitors (max=%u)\n",
|
|
||||||
_pPrivate->nMaxCompetitors);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next driver in the starting grid.
|
|
||||||
nCompIndex += nCompIndexDelta;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load focused competitor data from the raceman params.
|
// Load focused competitor data from the raceman params.
|
||||||
_pPrivate->strFocusedModuleName =
|
_pPrivate->strFocusedModuleName =
|
||||||
|
@ -855,10 +852,11 @@ bool GfRace::moveCompetitor(GfDriver* pComp, int nDeltaPlace)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Remove the competitor from his place.
|
// Remove the competitor from his place.
|
||||||
|
const int nOldIndex = itComp - _pPrivate->vecCompetitors.begin();
|
||||||
_pPrivate->vecCompetitors.erase(itComp);
|
_pPrivate->vecCompetitors.erase(itComp);
|
||||||
|
|
||||||
// Determine his new place.
|
// Determine his new place.
|
||||||
const int nNewIndex = (itComp - _pPrivate->vecCompetitors.begin()) + nDeltaPlace;
|
const int nNewIndex = nOldIndex + nDeltaPlace;
|
||||||
if (nNewIndex < 0)
|
if (nNewIndex < 0)
|
||||||
itComp = _pPrivate->vecCompetitors.begin();
|
itComp = _pPrivate->vecCompetitors.begin();
|
||||||
else if (nNewIndex >= (int)_pPrivate->vecCompetitors.size())
|
else if (nNewIndex >= (int)_pPrivate->vecCompetitors.size())
|
||||||
|
|
|
@ -343,8 +343,8 @@ void GfRaceManager::load() const
|
||||||
ossSectionPath.str("");
|
ossSectionPath.str("");
|
||||||
ossSectionPath << RM_SECT_TRACKS << '/' << nEventNum;
|
ossSectionPath << RM_SECT_TRACKS << '/' << nEventNum;
|
||||||
pszTrackId = GfParmGetStr(hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME, 0);
|
pszTrackId = GfParmGetStr(hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME, 0);
|
||||||
GfLogDebug("GfRaceManager::reset(...): event[%d].track = '%s'\n",
|
// GfLogDebug("GfRaceManager::reset(...): event[%d].track = '%s'\n",
|
||||||
nEventNum-1, pszTrackId);
|
// nEventNum-1, pszTrackId);
|
||||||
|
|
||||||
// If not end of event list :
|
// If not end of event list :
|
||||||
if (pszTrackId)
|
if (pszTrackId)
|
||||||
|
@ -405,7 +405,7 @@ void GfRaceManager::load() const
|
||||||
ossSecPath << RM_SECT_RACES << '/' << nSessionInd;
|
ossSecPath << RM_SECT_RACES << '/' << nSessionInd;
|
||||||
const char* pszSessionName =
|
const char* pszSessionName =
|
||||||
GfParmGetStr(hparmHandle, ossSecPath.str().c_str(), RM_ATTR_NAME, 0);
|
GfParmGetStr(hparmHandle, ossSecPath.str().c_str(), RM_ATTR_NAME, 0);
|
||||||
GfLogDebug("GfRaceManager::reset(...): session '%s'\n", pszSessionName);
|
// GfLogDebug("GfRaceManager::reset(...): session '%s'\n", pszSessionName);
|
||||||
if (pszSessionName && strlen(pszSessionName) > 0)
|
if (pszSessionName && strlen(pszSessionName) > 0)
|
||||||
_vecSessionNames.push_back(pszSessionName);
|
_vecSessionNames.push_back(pszSessionName);
|
||||||
|
|
||||||
|
@ -432,8 +432,8 @@ void GfRaceManager::store()
|
||||||
std::ostringstream ossSectionPath;
|
std::ostringstream ossSectionPath;
|
||||||
for (unsigned nEventInd = 0; nEventInd < _vecEventTrackIds.size(); nEventInd++)
|
for (unsigned nEventInd = 0; nEventInd < _vecEventTrackIds.size(); nEventInd++)
|
||||||
{
|
{
|
||||||
GfLogDebug("GfRaceManager::store(%s): event[%u].track = '%s'\n",
|
// GfLogDebug("GfRaceManager::store(%s): event[%u].track = '%s'\n",
|
||||||
_strName.c_str(), nEventInd, _vecEventTrackIds[nEventInd].c_str());
|
// _strName.c_str(), nEventInd, _vecEventTrackIds[nEventInd].c_str());
|
||||||
ossSectionPath.str("");
|
ossSectionPath.str("");
|
||||||
ossSectionPath << RM_SECT_TRACKS << '/' << nEventInd + 1;
|
ossSectionPath << RM_SECT_TRACKS << '/' << nEventInd + 1;
|
||||||
GfParmSetStr(_hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME,
|
GfParmSetStr(_hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME,
|
||||||
|
@ -567,8 +567,8 @@ void GfRaceManager::setEventTrack(unsigned nEventIndex, GfTrack* pTrack)
|
||||||
nEventIndex = _vecEventTrackIds.size() - 1;
|
nEventIndex = _vecEventTrackIds.size() - 1;
|
||||||
|
|
||||||
_vecEventTrackIds[nEventIndex] = pTrack->getId();
|
_vecEventTrackIds[nEventIndex] = pTrack->getId();
|
||||||
GfLogDebug("GfRaceManager::setEventTrack(evt #%u, track '%s')\n",
|
// GfLogDebug("GfRaceManager::setEventTrack(evt #%u, track '%s')\n",
|
||||||
nEventIndex, pTrack->getId().c_str());
|
// nEventIndex, pTrack->getId().c_str());
|
||||||
|
|
||||||
// Now we are no more consistent with the race managers params (in memory).
|
// Now we are no more consistent with the race managers params (in memory).
|
||||||
_bIsDirty = true;
|
_bIsDirty = true;
|
||||||
|
|
Loading…
Reference in a new issue