Update Teammanager: Protection if teamindex is taken more than once
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@1195 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: e71bb06eb95f559d4752abf34f19d24cd817cc9f Former-commit-id: ac19f1804d7ab638e36c69ffd5cba55eea018519
This commit is contained in:
parent
a03480e007
commit
4f1014eb0d
1 changed files with 19 additions and 0 deletions
|
@ -476,6 +476,18 @@ int RtTeamManagerIndex(CarElt* const Car, tTrack* const Track, tSituation* Situa
|
|||
RtTM->Drivers =
|
||||
(tTeamDriver**) malloc(Situation->_ncars * sizeof(tTeamDriver*));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Avoid adding same car twice
|
||||
tTeamDriver* TeamDriver = RtTM->TeamDrivers;
|
||||
while (TeamDriver)
|
||||
{
|
||||
if (TeamDriver->Car == Car)
|
||||
return TeamDriver->Count;
|
||||
|
||||
TeamDriver = TeamDriver->Next;
|
||||
}
|
||||
}
|
||||
|
||||
RtTM->Track = Track;
|
||||
RtTM->RaceDistance = Track->length * Situation->_totLaps;
|
||||
|
@ -562,6 +574,8 @@ void RtTeamReleasePit(const int TeamIndex)
|
|||
return;
|
||||
|
||||
tTeamDriver* TeamDriver = RtTeamDriverGet(TeamIndex);
|
||||
if (TeamDriver == NULL)
|
||||
return;
|
||||
|
||||
if (TeamDriver->TeamPit->PitState == TeamDriver->Car)
|
||||
TeamDriver->TeamPit->PitState = RT_TM_PIT_IS_FREE;
|
||||
|
@ -576,8 +590,13 @@ bool RtTeamNeedPitStop(const int TeamIndex, const float FuelPerM, const int Repa
|
|||
return false;
|
||||
|
||||
tTeamDriver* TeamDriver = RtTeamDriverGet(TeamIndex);
|
||||
if (TeamDriver == NULL)
|
||||
return false;
|
||||
|
||||
CarElt* Car = TeamDriver->Car;
|
||||
if (Car == NULL)
|
||||
return false;
|
||||
|
||||
if (Car->_pit == NULL)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue