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:
pouillot 2011-02-27 10:47:31 +00:00
parent ed281f7b77
commit ee42f9b62e
4 changed files with 61 additions and 64 deletions

View file

@ -223,10 +223,9 @@ void
ReStartNewRace(void * /* dummy */)
{
// 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())
{
ReGetRace()->store(); // Save data to params.
PReRace->store(); // Save data to params.
GfParmWriteFile(NULL, ReInfo->params, ReInfo->_reName); // Save params to disk.
}

View file

@ -177,7 +177,7 @@ ReRaceEventInit(void)
/* Read the new params */
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, ""));
if (!params)
GfLogWarning( "Params weren't read correctly !!!\n" );

View file

@ -390,10 +390,11 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
// hparmStartGrid == hparmResults ? "hRes" : GfParmGetFileName(hparmStartGrid));
std::ostringstream ossDrvSecPath;
int nCompIndex = bReversedGrid ? nCompetitors : 1;
const int nCompIndexDelta = bReversedGrid ? -1 : +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.
ossDrvSecPath.str("");
@ -414,10 +415,16 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
continue;
}
// We've got it : if we can keep it for the race, make it a competitor
// (there is a threshold on the number of competitors) :
if (acceptsMoreCompetitors())
// We've got it but can't keep it for the race,
// because there is a threshold on the number of competitors.
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 =
GfParmGetStr(hparmStartGrid, ossDrvSecPath.str().c_str(), RM_ATTR_SKINNAME, "");
const int nSkinTargets =
@ -461,16 +468,6 @@ void GfRace::load(GfRaceManager* pRaceMan, void* hparmResults)
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.
_pPrivate->strFocusedModuleName =
@ -855,10 +852,11 @@ bool GfRace::moveCompetitor(GfDriver* pComp, int nDeltaPlace)
return false;
// Remove the competitor from his place.
const int nOldIndex = itComp - _pPrivate->vecCompetitors.begin();
_pPrivate->vecCompetitors.erase(itComp);
// Determine his new place.
const int nNewIndex = (itComp - _pPrivate->vecCompetitors.begin()) + nDeltaPlace;
const int nNewIndex = nOldIndex + nDeltaPlace;
if (nNewIndex < 0)
itComp = _pPrivate->vecCompetitors.begin();
else if (nNewIndex >= (int)_pPrivate->vecCompetitors.size())

View file

@ -343,8 +343,8 @@ void GfRaceManager::load() const
ossSectionPath.str("");
ossSectionPath << RM_SECT_TRACKS << '/' << nEventNum;
pszTrackId = GfParmGetStr(hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME, 0);
GfLogDebug("GfRaceManager::reset(...): event[%d].track = '%s'\n",
nEventNum-1, pszTrackId);
// GfLogDebug("GfRaceManager::reset(...): event[%d].track = '%s'\n",
// nEventNum-1, pszTrackId);
// If not end of event list :
if (pszTrackId)
@ -405,7 +405,7 @@ void GfRaceManager::load() const
ossSecPath << RM_SECT_RACES << '/' << nSessionInd;
const char* pszSessionName =
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)
_vecSessionNames.push_back(pszSessionName);
@ -432,8 +432,8 @@ void GfRaceManager::store()
std::ostringstream ossSectionPath;
for (unsigned nEventInd = 0; nEventInd < _vecEventTrackIds.size(); nEventInd++)
{
GfLogDebug("GfRaceManager::store(%s): event[%u].track = '%s'\n",
_strName.c_str(), nEventInd, _vecEventTrackIds[nEventInd].c_str());
// GfLogDebug("GfRaceManager::store(%s): event[%u].track = '%s'\n",
// _strName.c_str(), nEventInd, _vecEventTrackIds[nEventInd].c_str());
ossSectionPath.str("");
ossSectionPath << RM_SECT_TRACKS << '/' << nEventInd + 1;
GfParmSetStr(_hparmHandle, ossSectionPath.str().c_str(), RM_ATTR_NAME,
@ -567,8 +567,8 @@ void GfRaceManager::setEventTrack(unsigned nEventIndex, GfTrack* pTrack)
nEventIndex = _vecEventTrackIds.size() - 1;
_vecEventTrackIds[nEventIndex] = pTrack->getId();
GfLogDebug("GfRaceManager::setEventTrack(evt #%u, track '%s')\n",
nEventIndex, pTrack->getId().c_str());
// GfLogDebug("GfRaceManager::setEventTrack(evt #%u, track '%s')\n",
// nEventIndex, pTrack->getId().c_str());
// Now we are no more consistent with the race managers params (in memory).
_bIsDirty = true;