From eb86101f8ffbb6d8f8f77efa720494defd25c157 Mon Sep 17 00:00:00 2001 From: wdbee Date: Mon, 23 Feb 2009 20:40:54 +0000 Subject: [PATCH] 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 --- src/drivers/simplix/src/unitstrategy.cpp | 17 ++++++++--------- src/libs/robottools/robotools.def | 1 + src/libs/robottools/rtteammanager.cpp | 14 ++++++++++++++ src/libs/robottools/teammanager.h | 4 +++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/drivers/simplix/src/unitstrategy.cpp b/src/drivers/simplix/src/unitstrategy.cpp index bb6f44f77..0d6b10e59 100644 --- a/src/drivers/simplix/src/unitstrategy.cpp +++ b/src/drivers/simplix/src/unitstrategy.cpp @@ -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 }; //==========================================================================* diff --git a/src/libs/robottools/robotools.def b/src/libs/robottools/robotools.def index 8dbc2eee5..158fc095b 100644 --- a/src/libs/robottools/robotools.def +++ b/src/libs/robottools/robotools.def @@ -34,6 +34,7 @@ EXPORTS RtTeamUpdate RtTeamAdd RtTeamAllocatePit + RtTeamIsPitFree RtTeamReleasePit RtTeammate RtTeammateFree diff --git a/src/libs/robottools/rtteammanager.cpp b/src/libs/robottools/rtteammanager.cpp index bc869797e..8d0b268e5 100644 --- a/src/libs/robottools/rtteammanager.cpp +++ b/src/libs/robottools/rtteammanager.cpp @@ -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 // diff --git a/src/libs/robottools/teammanager.h b/src/libs/robottools/teammanager.h index c31a3e670..3c3143f77 100644 --- a/src/libs/robottools/teammanager.h +++ b/src/libs/robottools/teammanager.h @@ -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);