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:
parent
36cda122e7
commit
63ffe4aa19
8 changed files with 34 additions and 8 deletions
|
@ -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));
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -391,6 +391,11 @@ bool GfDriver::isHuman() const
|
|||
return _bIsHuman;
|
||||
}
|
||||
|
||||
bool GfDriver::isNetwork() const
|
||||
{
|
||||
return _strModName == "networkhuman";
|
||||
}
|
||||
|
||||
const GfCar* GfDriver::getCar() const
|
||||
{
|
||||
return _pCar;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) :
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue