Merge pull request 'racemanagers.cpp: Do not list championship on no cars' (#22) from xavi/speed-dreams-code:fix-championship into main

Reviewed-on: #22
This commit is contained in:
Xavier Del Campo Romero 2025-01-19 08:18:18 +01:00
commit 4776e34329
2 changed files with 22 additions and 4 deletions

@ -1 +1 @@
Subproject commit 9749171cef65b4bc93094df17fcf2ec79e8d187a
Subproject commit 53904d8e2c9c34e78d2c7be1bdb89becbe4cc6a7

View file

@ -124,13 +124,31 @@ GfRaceManagers::GfRaceManagers()
continue;
}
bool insert = false;
// Create the race manager and load it from the params file.
//GfLogDebug("GfRaceManagers::GfRaceManagers: creating '%s'\n", strRaceManId.c_str());
GfRaceManager* pRaceMan = new GfRaceManager(strRaceManId, hparmRaceMan);
const std::vector<std::string>& catIds =
pRaceMan->getAcceptedCarCategoryIds();
// Update the GfRaceManagers singleton.
_pPrivate->vecRaceMans.push_back(pRaceMan);
_pPrivate->mapRaceMansById[strRaceManId] = pRaceMan;
for (const std::string &category : catIds)
{
std::vector<GfCar *> cars =
GfCars::self()->getCarsInCategory(category);
if (!cars.empty())
{
insert = true;
break;
}
}
if (insert)
{
// Update the GfRaceManagers singleton.
_pPrivate->vecRaceMans.push_back(pRaceMan);
_pPrivate->mapRaceMansById[strRaceManId] = pRaceMan;
}
}
while ((pFile = pFile->next) != lstFiles);