- fix USR stop pit (part2)
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7131 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f11f6219fa7eb96ce66b9e762e7e03328819b6b5 Former-commit-id: 8e1fe8ffe26e1fe093ba25e9a1a0e7ebbe3d1457
This commit is contained in:
parent
b6b6343619
commit
d5b52b8dab
6 changed files with 31 additions and 14 deletions
|
@ -27,7 +27,7 @@
|
|||
extern GfLogger* PLogUSR;
|
||||
#define LogUSR (*PLogUSR)
|
||||
|
||||
MyParam::MyParam(void** carparmhandle, const std::string& datadir, const std::string& trackname, int weather)
|
||||
MyParam::MyParam(void** carparmhandle, const std::string& datadir, const std::string& trackname, unsigned int weather)
|
||||
{
|
||||
if (weather < 1)
|
||||
{
|
||||
|
@ -42,6 +42,7 @@ MyParam::MyParam(void** carparmhandle, const std::string& datadir, const std::st
|
|||
{
|
||||
LogUSR.info("Couldn't load : %s\n", trackfile.c_str());
|
||||
*carparmhandle = GfParmReadFile(defaultfile.c_str(), GFPARM_RMODE_STD);
|
||||
|
||||
if (*carparmhandle == NULL)
|
||||
LogUSR.fatal("Couldn't load : %s\n", defaultfile.c_str());
|
||||
else
|
||||
|
@ -68,10 +69,12 @@ MyParam::MyParam(void** carparmhandle, const std::string& datadir, const std::st
|
|||
{
|
||||
LogUSR.info("Couldn't load : %s\n", trackfilerain.c_str());
|
||||
*carparmhandle = GfParmReadFile(defaultfilerain.c_str(), GFPARM_RMODE_STD);
|
||||
|
||||
if (*carparmhandle == NULL)
|
||||
{
|
||||
LogUSR.info("Couldn't load : %s\n", defaultfilerain.c_str());
|
||||
*carparmhandle = GfParmReadFile(defaultfile.c_str(), GFPARM_RMODE_STD);
|
||||
|
||||
if (*carparmhandle == NULL)
|
||||
LogUSR.fatal("Couldn't load : %s\n", defaultfile.c_str());
|
||||
else
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
class MyParam
|
||||
{
|
||||
public:
|
||||
MyParam(void** carparmhandle, const std::string &datadir, const std::string &trackname, int weather);
|
||||
MyParam(void** carparmhandle, const std::string &datadir, const std::string &trackname, unsigned int weather);
|
||||
|
||||
double getNum(const std::string& sect, const std::string& att) const;
|
||||
void setNum(const std::string& sect, const std::string& att, double value) const;
|
||||
|
|
|
@ -871,7 +871,8 @@ bool Driver::statePitstop() const
|
|||
float dl, dw;
|
||||
RtDistToPit((CarElt*)mCar.car(), (tTrack*)mTrack.torcsTrack(), &dl, &dw);
|
||||
|
||||
if (fabs(dw) < 1.6 && (dl < 0.5 || dl > mTrack.length() - 0.5)) {
|
||||
if (fabs(dw) < 1.6 && (dl < 0.5 || dl > mTrack.length() - 1.0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1615,7 +1616,7 @@ void Driver::Meteorology(const tTrack *t)
|
|||
//==========================================================================*
|
||||
// Estimate weather
|
||||
//--------------------------------------------------------------------------*
|
||||
int Driver::GetWeather(const tTrack *t)
|
||||
unsigned int Driver::GetWeather(const tTrack *t)
|
||||
{
|
||||
return (t->local.rain << 4) + t->local.water;
|
||||
};
|
||||
|
|
|
@ -95,7 +95,7 @@ private:
|
|||
double controlSpeed(double accelerator, double maxspeed);
|
||||
|
||||
void Meteorology(const tTrack *t);
|
||||
int GetWeather(const tTrack *t);
|
||||
unsigned int GetWeather(const tTrack *t);
|
||||
|
||||
bool CheckPitSharing(tCarElt *car);
|
||||
|
||||
|
@ -196,7 +196,7 @@ private:
|
|||
|
||||
bool rain;
|
||||
double rainintensity;
|
||||
int weathercode; // Track specific weather
|
||||
unsigned int weathercode; // Track specific weather
|
||||
|
||||
double driver_aggression;
|
||||
double SkillGlobal;
|
||||
|
|
|
@ -38,13 +38,13 @@ void Pit::init(const tTrack* track, const tSituation* situation, MyCar* car, int
|
|||
{
|
||||
// Get tires change time
|
||||
void* handle = NULL;
|
||||
std::string tmpstr = std::string(GetLocalDir()) + "config/raceman/endrace.xml";
|
||||
/*std::string tmpstr = std::string(GetLocalDir()) + "config/raceman/endrace.xml";
|
||||
handle = GfParmReadFile(tmpstr.c_str(), GFPARM_RMODE_STD);
|
||||
if (handle)
|
||||
{
|
||||
mTiresChangeTime = GfParmGetNum(handle, "Race", "all tires change time", (char*)NULL, 30.0);
|
||||
GfParmReleaseHandle(handle);
|
||||
}
|
||||
}*/
|
||||
|
||||
if (pitdamage)
|
||||
{
|
||||
|
@ -138,12 +138,12 @@ void Pit::init(const tTrack* track, const tSituation* situation, MyCar* car, int
|
|||
|
||||
for (i = 1; i < PITPOINTS - 1; i++)
|
||||
{
|
||||
mPitp[i].y = sign * (fabs(mPitInfo->driversPits->pos.toMiddle) - 0.5 * mPitInfo->width - 2.5);
|
||||
mPitp[i].y = sign * (fabs(mPitInfo->driversPits->pos.toMiddle) - 0.3 * mPitInfo->width - 2.2);
|
||||
}
|
||||
|
||||
for (i = 1; i < DTPOINTS - 1; i++)
|
||||
{
|
||||
mDtp[i].y = sign * (fabs(mPitInfo->driversPits->pos.toMiddle) - 0.5 * mPitInfo->width - 2.5);
|
||||
mDtp[i].y = sign * (fabs(mPitInfo->driversPits->pos.toMiddle) - 0.3 * mPitInfo->width - 2.2);
|
||||
}
|
||||
|
||||
mPitp[3].y = sign * fabs(mPitInfo->driversPits->pos.toMiddle);
|
||||
|
@ -173,6 +173,7 @@ double Pit::pathToMiddle(double fromstart) const
|
|||
if (mInPitLane || ((mPitstop || mPenalty == RM_PENALTY_DRIVETHROUGH) && isBetween(fromstart)))
|
||||
{
|
||||
fromstart = toSplineCoord(fromstart);
|
||||
|
||||
if (mPenalty == RM_PENALTY_DRIVETHROUGH)
|
||||
{
|
||||
return mDtSpline.evaluate(fromstart);
|
||||
|
@ -292,12 +293,17 @@ void Pit::update()
|
|||
}
|
||||
|
||||
mPenalty = 0; // fuel, damage and tires served before penalty
|
||||
bool pittyres = false;
|
||||
// Check for fuel, damage and tyres
|
||||
bool pitfuel = mCar->_fuel < mAvgFuelPerLap;
|
||||
bool pitdamage = (mCar->_dammage > mPitDamage && remaininglaps * mTrack->length > mMaxDamageDist && mLastFuel > 15.0) || (mCar->_dammage > mMaxDamage);
|
||||
//bool pittyres = (mMyCar->tires()->distLeft() < 1.0 * mTrack->length && mMyCar->tires()->gripFactor() < mPitGripFactor && remaininglaps * mTrack->length > 10000.0);
|
||||
bool pittyres = (mMyCar->tires()->gripFactor() < mPitGripFactor && remaininglaps * mTrack->length > 10000.0 && mMyCar->tires()->distLeft() < 1000);
|
||||
|
||||
if(mMyCar->HASTYC)
|
||||
pittyres = (mMyCar->tires()->gripFactor() < mPitGripFactor && remaininglaps * mTrack->length > 10000.0 && mMyCar->tires()->distLeft() < 1000);
|
||||
else {
|
||||
pittyres = false;
|
||||
}
|
||||
if (fs > mPitEntry - mEntryMargin - mPreEntryMargin - 3.0 && fs < mPitEntry - mEntryMargin - mPreEntryMargin && !mStopChecked)
|
||||
{
|
||||
if (pitBeforeTeammate(remaininglaps))
|
||||
|
|
|
@ -33,14 +33,20 @@ double Spline::evaluate(double z) const
|
|||
int i, a, b;
|
||||
double t, a0, a1, a2, a3, h;
|
||||
a = 0; b = mDim-1;
|
||||
do {
|
||||
|
||||
do
|
||||
{
|
||||
i = (a + b) / 2;
|
||||
if (mSpl[i].x <= z) {
|
||||
if (mSpl[i].x <= z)
|
||||
{
|
||||
a = i;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
b = i;
|
||||
}
|
||||
} while ((a + 1) != b);
|
||||
|
||||
i = a;
|
||||
h = mSpl[i+1].x - mSpl[i].x;
|
||||
t = (z-mSpl[i].x) / h;
|
||||
|
@ -49,5 +55,6 @@ double Spline::evaluate(double z) const
|
|||
a2 = a1 - h*mSpl[i].s;
|
||||
a3 = h * mSpl[i+1].s - a1;
|
||||
a3 -= a2;
|
||||
|
||||
return a0 + (a1 + (a2 + a3*t) * (t-1))*t;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue