forked from speed-dreams/speed-dreams-code
DanDroid catch negative _distFromStartLine
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6411 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: af834be66b6b1f95b5273fe1cb97ea78b9c3d8f3 Former-commit-id: e2ed63b7907075a35b6da82aaddcec81624e67db
This commit is contained in:
parent
27b8ad05f9
commit
53294d018f
4 changed files with 27 additions and 8 deletions
|
@ -281,7 +281,6 @@ void TDriver::updateTimer()
|
|||
|
||||
void TDriver::updateBasics()
|
||||
{
|
||||
mPit.update();
|
||||
mMass = mCARMASS + mFUELWEIGHTFACTOR * oCar->_fuel;
|
||||
mSpeed = oCar->_speed_x;
|
||||
|
||||
|
@ -304,6 +303,9 @@ void TDriver::updateBasics()
|
|||
}
|
||||
|
||||
mFromStart = oCar->_distFromStartLine;
|
||||
if (mFromStart < 0.0) {
|
||||
mFromStart += mTrack->length;
|
||||
}
|
||||
mToMiddle = oCar->_trkPos.toMiddle;
|
||||
mOnLeftSide = mToMiddle > 0.0 ? true : false;
|
||||
mBorderdist = oCar->_trkPos.seg->width / 2.0 - fabs(mToMiddle) - oCar->_dimension_y / 2.0;
|
||||
|
@ -365,6 +367,7 @@ void TDriver::updateBasics()
|
|||
updateStuck();
|
||||
updateAttackAngle();
|
||||
updateCurveAhead();
|
||||
mPit.update(mFromStart);
|
||||
}
|
||||
|
||||
|
||||
|
@ -562,8 +565,12 @@ double TDriver::getPitSpeed()
|
|||
double brakespeed;
|
||||
if (pitdist < 20.0) {
|
||||
brakespeed = 0.6 * brakeSpeed(pitdist, 0.0);
|
||||
if (IS_DANDROID_TORCS)
|
||||
brakespeed = 1.0 * brakeSpeed(pitdist, 0.0);
|
||||
} else {
|
||||
brakespeed = 1.0 * brakeSpeed(pitdist, 0.0);
|
||||
if (IS_DANDROID_TORCS)
|
||||
brakespeed = 2.0 * brakeSpeed(pitdist, 0.0);
|
||||
}
|
||||
maxspeed = MIN(maxspeed, brakespeed);
|
||||
return maxspeed;
|
||||
|
@ -590,7 +597,7 @@ double TDriver::getMaxSpeed(DanPoint danpoint)
|
|||
if (bumpspeed < nextspeed) {
|
||||
nextspeed = bumpspeed;
|
||||
}
|
||||
maxspeed = brakeSpeed(nextdist, nextspeed);;
|
||||
maxspeed = brakeSpeed(nextdist, nextspeed);
|
||||
if (lowest > maxspeed) {
|
||||
lowest = maxspeed;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ double Pit::getPitOffset(double fromstart)
|
|||
void Pit::setPitstop(bool pitst)
|
||||
{
|
||||
if (mypit == NULL) return;
|
||||
if (!isBetween(car->_distFromStartLine) && !isBetween(car->_distFromStartLine + ENTRY_MARGIN)) {
|
||||
if (!isBetween(mFromStart) && !isBetween(mFromStart + ENTRY_MARGIN)) {
|
||||
if (teamcar != NULL && !(teamcar->_state & RM_CAR_STATE_OUT)) {
|
||||
if (teamcar->_raceCmd == RM_CMD_PIT_ASKED || teamcar->_state & RM_CAR_STATE_PIT) {
|
||||
return;
|
||||
|
@ -185,11 +185,12 @@ bool Pit::isPitlimit(double fromstart)
|
|||
|
||||
|
||||
// update pit data and strategy
|
||||
void Pit::update()
|
||||
void Pit::update(double fromstart)
|
||||
{
|
||||
mFromStart = fromstart;
|
||||
if (mypit != NULL) {
|
||||
int remainingLaps = car->_remainingLaps - car->_lapsBehindLeader;
|
||||
if (isBetween(car->_distFromStartLine)) {
|
||||
if (isBetween(mFromStart)) {
|
||||
if (getPitstop()) {
|
||||
setInPit(true);
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ void Pit::update()
|
|||
// Computes the amount of fuel
|
||||
double Pit::getFuel()
|
||||
{
|
||||
double laps = car->_remainingLaps + (track->length - car->_distFromStartLine) / track->length;
|
||||
double laps = car->_remainingLaps + (track->length - mFromStart) / track->length;
|
||||
double fueltoend = (laps - car->_lapsBehindLeader) * avgfuelperlap;
|
||||
int pitstops = int(floor(fueltoend / car->_tank));
|
||||
double stintfuel = fueltoend / (pitstops + 1) + 2.0;
|
||||
|
@ -256,7 +257,7 @@ double Pit::getFuel()
|
|||
stintfuel = car->_tank;
|
||||
}
|
||||
double fuel = MAX(MIN(stintfuel - car->_fuel, car->_tank - car->_fuel), 0.0);
|
||||
//GfOut("fromStart:%g laps:%g lapsBehindLeader:%d fueltoend:%g pitstops:%d stintfuel:%g fuel:%g\n", car->_distFromStartLine, laps, car->_lapsBehindLeader, fueltoend, pitstops, stintfuel, fuel);
|
||||
//GfOut("fromStart:%g laps:%g lapsBehindLeader:%d fueltoend:%g pitstops:%d stintfuel:%g fuel:%g\n", mFromStart, laps, car->_lapsBehindLeader, fueltoend, pitstops, stintfuel, fuel);
|
||||
return fuel;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class Pit {
|
|||
double getNPitLoc() { return p[3].x; }
|
||||
double getNPitEnd() { return p[5].x; }
|
||||
double toSplineCoord(double x);
|
||||
void update();
|
||||
void update(double fromstart);
|
||||
int getRepair();
|
||||
double getFuel();
|
||||
double getSpeedlimit();
|
||||
|
@ -70,6 +70,7 @@ class Pit {
|
|||
Spline spline; /* spline */
|
||||
bool pitstop; /* pitstop planned */
|
||||
bool inpitlane; /* we are still in the pit lane */
|
||||
double mFromStart;
|
||||
double pitentry; /* distance to start line of the pit entry */
|
||||
double pitexit; /* distance to the start line of the pit exit */
|
||||
double limitentry; /* distance to start line of the pit entry */
|
||||
|
|
|
@ -18,8 +18,18 @@
|
|||
#ifndef _TORCS_OR_SD_H_
|
||||
#define _TORCS_OR_SD_H_
|
||||
|
||||
// Set here TORCS or SPEEDDREAMS manually
|
||||
//#define DANDROID_TORCS
|
||||
#define DANDROID_SPEEDDREAMS
|
||||
|
||||
// The following globals will be set automatically
|
||||
#ifdef DANDROID_TORCS
|
||||
const bool IS_DANDROID_TORCS = true;
|
||||
const bool IS_DANDROID_SPEEDDREAMS = false;
|
||||
#else
|
||||
const bool IS_DANDROID_TORCS = false;
|
||||
const bool IS_DANDROID_SPEEDDREAMS = true;
|
||||
#endif
|
||||
|
||||
#endif // _TORCS_OR_SD_H_
|
||||
|
||||
|
|
Loading…
Reference in a new issue