Update to release pit if drivers is eliminated by TORCS-NG

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

Former-commit-id: 635ca9ddc1c583322a3aa79d57b5bdf30eacf452
Former-commit-id: 9aa73458ea92ecf5d460c7086ee605be666ca07d
This commit is contained in:
wdbee 2009-02-28 15:10:16 +00:00
parent febf3e6168
commit 66cedb917f
4 changed files with 28 additions and 5 deletions

View file

@ -1052,9 +1052,9 @@ int TDriver::PitCmd()
//--------------------------------------------------------------------------*
void TDriver::EndRace()
{
//GfOut("#TDriver::EndRace() >>>\n");
// This is never called by TORCS! Don't use it!
//GfOut("#<<< TDriver::EndRace()\n");
GfOut("#TDriver::EndRace() >>>\n");
oStrategy->PitRelease(); // Release pit if eliminated
GfOut("#<<< TDriver::EndRace()\n");
}
//==========================================================================*

View file

@ -685,10 +685,12 @@ int Driver::pitCommand(tSituation *s)
}
// Never called by TORCS!!! End of the current race.
// End of the current race for this driver, may be
// it was eliminated from a continuing race, so release pit!
void Driver::endRace(tSituation *s)
{
// Nothing for now.
RtTeamReleasePit(teamIndex); // Release pit if eliminated
car->ctrl.raceCmd = 0;
}
// Clean up

View file

@ -163,6 +163,7 @@ tTeamManager* RtTeamManager()
TeamManager->TeamDrivers = NULL;
TeamManager->Drivers = NULL;
TeamManager->Track = NULL;
TeamManager->State = RT_TM_STATE_INIT;
TeamManager->Count = 0;
TeamManager->PitSharing = false;
TeamManager->RaceDistance = 500000;
@ -200,6 +201,15 @@ bool RtTeamManagerInit()
RtTM = RtTeamManager();
return true;
}
else
{
if (RtTM->State != RT_TM_STATE_NULL)
{
RtTeamManagerFree();
RtTM = NULL;
return RtTeamManagerInit();
}
}
return false;
}
@ -448,6 +458,7 @@ int RtTeamManagerIndex(CarElt* const Car, tTrack* const Track, tSituation* Situa
{
TeamDriver->MinLaps = TeamDriver->TeamPit->Teammates->Count + RtTMLaps;
TeamDriver = TeamDriver->Next;
RtTM->State = RT_TM_STATE_INIT;
}
return TeamIndex;
}
@ -615,6 +626,11 @@ bool RtTeamNeedPitStop(const int TeamIndex, const float FuelPerM, const int Repa
GotoPit = (TeamDriver->TeamPit->PitState == TeamDriver->Car);
}
if(GotoPit)
{
RtTM->State = RT_TM_STATE_USED;
}
return GotoPit;
};

View file

@ -113,6 +113,10 @@ extern float RtTeamDriverRemainingDistance // Get the remaining distance t
#define RT_TM_PIT_IS_FREE NULL // = *Car if reserved/used
#define RT_TM_STATE_NULL 0 // Team manager was created
#define RT_TM_STATE_INIT 1 // Team manager was initialized
#define RT_TM_STATE_USED 2 // Team manager was used
// Teammanager Utilities
@ -206,6 +210,7 @@ typedef struct
tTeamDriver* TeamDrivers; // Linked list of drivers belonging to a team
tTrack* Track; // Track
tTeamDriver** Drivers; // Array of pointers to TeamDrivers
int State; // State of team manager
int Count; // Nbr of drivers in race
bool PitSharing; // Pit sharing activated?
float RaceDistance; // Distance to race