Fixed #245 (Network humans should never be selectable in non-network races) + crash when configuring race from Host Online Race menu

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

Former-commit-id: 74f61784786d1622de3a6dfe02e6815f5733d21c
Former-commit-id: f649bff5a1b76c7a9d04a881056c8fcb5987bd70
This commit is contained in:
pouillot 2011-02-04 16:29:45 +00:00
parent 36cda122e7
commit 63ffe4aa19
8 changed files with 34 additions and 8 deletions

View file

@ -35,6 +35,8 @@
#include <robot.h>
#include <teammanager.h>
#include <robottools.h>
#include <tracks.h>
#include <racemanagers.h>
#include <race.h>
@ -93,6 +95,9 @@ ReInit(void)
return;
reEventModList->modInfo->fctInit(reEventModList->modInfo->index, &ReInfo->_reTrackItf);
// Initialize GfTracks' track module interface (needed for some track infos).
GfTracks::self()->setTrackInterface(&ReInfo->_reTrackItf);
/* The graphic modules isn't loaded at this moment, so make sure _reGraphicItf equals NULL */
memset (&ReInfo->_reGraphicItf, 0, sizeof(tGraphicItf));

View file

@ -303,9 +303,6 @@ reOnSaveRaceToFile(void *pPrevMenu)
static void
reOnActivate(void * /* dummy */)
{
// Initialize GfTracks' track module interface (needed for some track infos).
GfTracks::self()->setTrackInterface(&ReInfo->_reTrackItf);
// Update GUI.
reOnRaceDataChanged();
}

View file

@ -35,6 +35,7 @@
#include <cars.h>
#include <drivers.h>
#include <racemanagers.h>
#include <race.h>
#include "racescreens.h"
@ -606,7 +607,14 @@ RmDriversSelect(void *vs)
VecCarCategoryNames = GfCars::self()->getCategoryNames();
VecCarCategoryNames.push_back(AnyCarCategory);
VecDriverTypes = GfDrivers::self()->getTypes();
std::vector<std::string>::const_iterator itDrvType = GfDrivers::self()->getTypes().begin();
while (itDrvType != GfDrivers::self()->getTypes().end())
{
// No network human in non network races.
if (*itDrvType != "networkhuman" || MenuData->pRace->getManager()->isNetwork())
VecDriverTypes.push_back(*itDrvType);
itDrvType++;
}
VecDriverTypes.push_back(AnyDriverType);
// Current Driver Info

View file

@ -391,6 +391,11 @@ bool GfDriver::isHuman() const
return _bIsHuman;
}
bool GfDriver::isNetwork() const
{
return _strModName == "networkhuman";
}
const GfCar* GfDriver::getCar() const
{
return _pCar;

View file

@ -70,6 +70,7 @@ public:
const std::string& getModuleName() const;
int getInterfaceIndex() const;
bool isHuman() const;
bool isNetwork() const;
const GfCar* getCar() const;
const std::string& getType() const;
const GfDriverSkin& getSkin() const;
@ -81,10 +82,6 @@ public:
double getSkillLevel() const;
// void setName(const std::string& strName);
// void setModuleName(const std::string& strModName);
// void setInterfaceIndex(int nItfIndex);
// void setIsHuman(bool bIsHuman);
void setCar(const GfCar* pCar);
void setSkin(const GfDriverSkin& skin);

View file

@ -198,6 +198,14 @@ void GfRace::load(GfRaceManager* pRaceMan)
pszModName, nItfIndex);
continue;
}
// Check if this driver can compete in this race.
if (pCompetitor->isNetwork() && !pRaceMan->isNetwork())
{
GfLogWarning("Ignoring '%s' driver #%d (%s) : Network humans can only race in network races\n",
pszModName, nItfIndex, pCompetitor->getName().c_str());
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) :

View file

@ -291,6 +291,11 @@ const std::string& GfRaceManager::getSubType() const
return _strSubType;
}
bool GfRaceManager::isNetwork() const
{
return _strType == "Online";
}
const int GfRaceManager::getPriority() const
{
return _nPriority;

View file

@ -49,6 +49,7 @@ public:
const std::string& getName() const;
const std::string& getType() const;
const std::string& getSubType() const;
bool isNetwork() const;
const int getPriority() const;
unsigned getEventCount() const;