Re #138 (D29) Fixed crash when opening the CarSelect menu the 2nd time after finishing race configuration
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@2780 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 5fee8db3cc9993b7bdb194c0f42f88dcb3a10d8b Former-commit-id: 09438967760fbff6f556e3d26c4ed31ccf1138fd
This commit is contained in:
parent
17d6f7f069
commit
a5df528271
2 changed files with 24 additions and 1 deletions
|
@ -32,6 +32,8 @@
|
|||
|
||||
void RmCarSelectMenu::onActivateCB(void *pCarSelectMenu)
|
||||
{
|
||||
//GfLogDebug("RmCarSelectMenu::onActivateCB\n");
|
||||
|
||||
// Get the RmCarSelectMenu instance.
|
||||
RmCarSelectMenu* pMenu = static_cast<RmCarSelectMenu*>(pCarSelectMenu);
|
||||
|
||||
|
@ -330,6 +332,8 @@ void RmCarSelectMenu::resetCarPreviewImage(const std::string& strSelectedSkinNam
|
|||
|
||||
void RmCarSelectMenu::RunMenu(trmdDrvElt* pDriver)
|
||||
{
|
||||
//GfLogDebug("RmCarSelectMenu::RunMenu\n");
|
||||
|
||||
// Initialize if not already done.
|
||||
if (!GetMenuHandle())
|
||||
Initialize();
|
||||
|
@ -343,7 +347,9 @@ void RmCarSelectMenu::RunMenu(trmdDrvElt* pDriver)
|
|||
|
||||
bool RmCarSelectMenu::Initialize()
|
||||
{
|
||||
//CarInfo::self()->print();
|
||||
//GfLogDebug("RmCarSelectMenu::Initialize\n");
|
||||
|
||||
CarInfo::self()->print();
|
||||
|
||||
// Create the menu and all its controls.
|
||||
CreateMenuEx(NULL, this, onActivateCB, NULL, (tfuiCallback)NULL, 1);
|
||||
|
@ -395,6 +401,7 @@ trmdDrvElt* RmCarSelectMenu::getDriver()
|
|||
void RmCarSelectMenu::setDriver(trmdDrvElt* pDriver)
|
||||
{
|
||||
_pDriver = pDriver;
|
||||
_hCarParams = 0; // No newly selected car for the moment.
|
||||
}
|
||||
|
||||
void RmCarSelectMenu::setSelectedCarParamsHandle(void* hdle)
|
||||
|
|
|
@ -111,6 +111,8 @@ static void rmdsClickOnDriver(void * /* dummy */);
|
|||
static void
|
||||
rmdsActivate(void * /* notused */)
|
||||
{
|
||||
//GfLogDebug("rmdsActivate\n");
|
||||
|
||||
// Update selected driver displayed info
|
||||
rmdsClickOnDriver(NULL);
|
||||
}
|
||||
|
@ -119,6 +121,8 @@ rmdsActivate(void * /* notused */)
|
|||
static void
|
||||
rmdsDeactivate(void *nextScreenHdle)
|
||||
{
|
||||
//GfLogDebug("rmdsDeactivate\n");
|
||||
|
||||
rmdsCleanup();
|
||||
GfuiScreenRelease(ScrHandle);
|
||||
|
||||
|
@ -267,6 +271,8 @@ rmdsPreviousMenu(void *screen)
|
|||
static void
|
||||
rmdsCarSelectMenu(void *pPreviousMenu)
|
||||
{
|
||||
//GfLogDebug("rmdsCarSelectMenu\n");
|
||||
|
||||
trmdDrvElt *pDriver = rmdsGetHighlightedDriver();
|
||||
|
||||
if (pDriver)
|
||||
|
@ -509,6 +515,8 @@ RmDriversSelect(void *vs)
|
|||
int human;
|
||||
const char* initCarCat;
|
||||
|
||||
//GfLogDebug("RmDriversSelect\n");
|
||||
|
||||
// Initialize drivers selection
|
||||
MenuData = (tRmDriverSelect*)vs;
|
||||
|
||||
|
@ -596,6 +604,7 @@ RmDriversSelect(void *vs)
|
|||
curDrv->skinName = 0; // Initialized later if needed from race params.
|
||||
curDrv->name = strdup(curmod->modInfo[i].name);
|
||||
curDrv->carParmHdle = carhdle;
|
||||
//GfLogDebug("Candidate %s : %s on %s\n", modName, curDrv->name, carName);
|
||||
const char* carCat = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, "");
|
||||
if (std::find(VecCarCategories.begin(), VecCarCategories.end(), carCat) == VecCarCategories.end()) {
|
||||
VecCarCategories.push_back(carCat);
|
||||
|
@ -639,6 +648,7 @@ RmDriversSelect(void *vs)
|
|||
NbMaxSelectedDrivers =
|
||||
(int)GfParmGetNum(MenuData->param, RM_SECT_DRIVERS, RM_ATTR_MAXNUM, NULL, 0);
|
||||
nDrivers = GfParmGetEltNb(MenuData->param, RM_SECT_DRIVERS);
|
||||
//GfLogDebug("Competitors : n=%d (max=%d)\n", nDrivers, NbMaxSelectedDrivers);
|
||||
initCarCat = 0;
|
||||
index = 1;
|
||||
for (i = 1; i < nDrivers+1; i++) {
|
||||
|
@ -649,6 +659,8 @@ RmDriversSelect(void *vs)
|
|||
skinName = GfParmGetStr(MenuData->param, path, RM_ATTR_SKINNAME, rmdStdSkinName);
|
||||
extended = GfParmGetNum(MenuData->param, path, RM_ATTR_EXTENDED, NULL, 0);
|
||||
|
||||
//GfLogDebug("Competitor #%d : ext=%d, itf %d\n", i, extended, robotIdx);
|
||||
|
||||
// Try and retrieve this driver in the full drivers list
|
||||
if ((curDrv = GF_TAILQ_FIRST(&DriverList))) {
|
||||
do {
|
||||
|
@ -657,6 +669,8 @@ RmDriversSelect(void *vs)
|
|||
// (there is a threshold on the number of competitors) :
|
||||
if (NbSelectedDrivers < NbMaxSelectedDrivers) {
|
||||
|
||||
//GfLogDebug(" Name = %s\n", curDrv->name);
|
||||
|
||||
// The driver is selected for the race !
|
||||
curDrv->isSelected = index++;
|
||||
|
||||
|
@ -672,12 +686,14 @@ RmDriversSelect(void *vs)
|
|||
// Get the chosen car for the race if any specified (human only).
|
||||
if (curDrv->isHuman && extended)
|
||||
{
|
||||
//GfLogDebug(" Extended && Human\n");
|
||||
sprintf(path, "%s/%s/%d/%d", RM_SECT_DRIVERINFO, moduleName, extended, robotIdx);
|
||||
carName = GfParmGetStr(MenuData->param, path, RM_ATTR_CARNAME, 0);
|
||||
sprintf(path, "cars/%s/%s.xml", carName, carName);
|
||||
if (!stat(path, &st)) {
|
||||
carhdle = GfParmReadFile(path, GFPARM_RMODE_STD);
|
||||
if (carhdle) {
|
||||
//GfLogDebug(" Car XML OK : %s\n", path);
|
||||
if (curDrv->carParmHdle)
|
||||
GfParmReleaseHandle(curDrv->carParmHdle);
|
||||
curDrv->carParmHdle = carhdle;
|
||||
|
|
Loading…
Reference in a new issue