Added RtTeamIsPitFree and damages as value
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@781 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b25c1f8f6bd32773927e699ba10afa391d6a6896 Former-commit-id: 4a13f7ec09580f1716a34dd5ad83fe1c6dd6175e
This commit is contained in:
parent
9a3df5638a
commit
eb86101f8f
4 changed files with 26 additions and 10 deletions
|
@ -107,9 +107,8 @@ bool TSimpleStrategy::IsPitFree()
|
|||
if (CarPit != NULL)
|
||||
{
|
||||
#ifdef _USE_RTTEAMMANAGER_
|
||||
tTeam* Team = oDriver->GetTeam();
|
||||
if ((CarPit->pitCarIndex == TR_PIT_STATE_FREE)
|
||||
&& ((Team->PitState == oCar) || (Team->PitState == PIT_IS_FREE)))
|
||||
if (RtTeamIsPitFree(oDriver->GetTeam(), oDriver->TeamIndex()))
|
||||
return true;
|
||||
#else
|
||||
TTeamManager::TTeam* Team = oDriver->GetTeam();
|
||||
if ((CarPit->pitCarIndex == TR_PIT_STATE_FREE)
|
||||
|
@ -138,7 +137,7 @@ bool TSimpleStrategy::NeedPitStop()
|
|||
{ // Wenn ja,
|
||||
if (!IsPitFree()) // ist die Box frei?
|
||||
{
|
||||
GfOut("#IsPitFree = false: %s\n",oDriver->GetBotName());
|
||||
//GfOut("#IsPitFree = false: %s\n",oDriver->GetBotName());
|
||||
return Result; // Wenn nicht, Pech!
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +161,7 @@ bool TSimpleStrategy::NeedPitStop()
|
|||
if (CarFuel < FuelNeeded) // Wenn der Tankinhalt nicht
|
||||
{
|
||||
Result = true; // reicht, tanken
|
||||
GfOut("#Pitstop by fuel: %s\n",oDriver->GetBotName());
|
||||
GfOut("#Pitstop by fuel: %s (%g<%g)\n",oDriver->GetBotName(),CarFuel,FuelNeeded);
|
||||
}
|
||||
else if (!oDriver->oPitSharing) // Ist pitsharing aktiviert?
|
||||
{
|
||||
|
@ -211,7 +210,7 @@ bool TSimpleStrategy::NeedPitStop()
|
|||
if (CarFuel < FuelNeeded) // Wenn der Tankinhalt nicht
|
||||
{ // reicht, tanken
|
||||
Result = true;
|
||||
GfOut("#Pitstop by Teammate: %s (%d:%d)\n",oDriver->GetBotName(),FuelForLaps,MinLaps);
|
||||
GfOut("#Pitstop by Teammate: %s (%d<=%d)\n",oDriver->GetBotName(),FuelForLaps,MinLaps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,16 +241,16 @@ bool TSimpleStrategy::NeedPitStop()
|
|||
void TAbstractStrategy::PitRelease()
|
||||
{
|
||||
#ifdef _USE_RTTEAMMANAGER_
|
||||
tTeam* Team = oDriver->GetTeam();
|
||||
if (Team->PitState == oCar) // Box für mich reserviert?
|
||||
RtTeamReleasePit(oDriver->GetTeam(),oDriver->TeamIndex());
|
||||
oCar->ctrl.raceCmd = 0;
|
||||
#else
|
||||
TTeamManager::TTeam* Team = oDriver->GetTeam();
|
||||
if (Team->PitState == CarDriverIndex) // Box für mich reserviert?
|
||||
#endif
|
||||
{
|
||||
Team->PitState = PIT_IS_FREE;
|
||||
oCar->ctrl.raceCmd = 0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
//==========================================================================*
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ EXPORTS
|
|||
RtTeamUpdate
|
||||
RtTeamAdd
|
||||
RtTeamAllocatePit
|
||||
RtTeamIsPitFree
|
||||
RtTeamReleasePit
|
||||
RtTeammate
|
||||
RtTeammateFree
|
||||
|
|
|
@ -255,6 +255,8 @@ void RtTeamUpdate(tTeam* const Team, const int TeamIndex, tTeammateData& Data)
|
|||
return;
|
||||
Team->Data[TeamIndex].Fuel = Data.Fuel;
|
||||
Team->Data[TeamIndex].MinLapTime = Data.MinLapTime;
|
||||
Team->Data[TeamIndex].Damages = Data.Damages;
|
||||
Team->Data[TeamIndex].RemainingDistance = Data.RemainingDistance;
|
||||
Team->Data[TeamIndex].TimeBeforeNextTeammate = Data.TimeBeforeNextTeammate;
|
||||
if ((Team->Header.MajorVersion < 2) || (Data.MajorVersion < 2))
|
||||
return;
|
||||
|
@ -293,6 +295,18 @@ bool RtTeamAllocatePit(tTeam* const Team, const int TeamIndex)
|
|||
return Team->PitState == Team->Cars[TeamIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Is pit free?
|
||||
//
|
||||
bool RtTeamIsPitFree(tTeam* const Team, const int TeamIndex)
|
||||
{
|
||||
if ((Team->Cars[TeamIndex]->_pit->pitCarIndex == TR_PIT_STATE_FREE)
|
||||
&& ((Team->PitState == Team->Cars[TeamIndex]) || (Team->PitState == PIT_IS_FREE)))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Release pit
|
||||
//
|
||||
|
|
|
@ -84,7 +84,8 @@ typedef struct
|
|||
int FuelForLaps; // Fuel for laps
|
||||
int Fuel; // current fuel
|
||||
int MinLapTime; // Lap time of fastest lap
|
||||
float RemainigDistance; // Remaining Distance to race
|
||||
int Damages; // Dammages of teammate
|
||||
float RemainingDistance; // Remaining Distance to race
|
||||
double TimeBeforeNextTeammate; // Time in s
|
||||
// <<< NEVER CHANGE THIS V1.X
|
||||
// Extend it here if needed but increment MAJOR VERSION!
|
||||
|
@ -149,6 +150,7 @@ extern void RtTeamSetMinLaps(tTeam* const Team, const int TeamIndex, const int F
|
|||
extern void RtTeamUpdate(tTeam* const Team, const int TeamIndex, tTeammateData& Data);
|
||||
extern int RtTeamAdd(tTeam* const Team, tTeammate* const Teammate);
|
||||
extern bool RtTeamAllocatePit(tTeam* const Team, const int TeamIndex);
|
||||
extern bool RtTeamIsPitFree(tTeam* const Team, const int TeamIndex);
|
||||
extern void RtTeamReleasePit(tTeam* const Team, const int TeamIndex);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue