From a579d5f336cbf0c4664af9ac063211db983134fb Mon Sep 17 00:00:00 2001 From: martkelder Date: Tue, 13 Oct 2009 09:09:29 +0000 Subject: [PATCH] Remove compiler warnings git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@1578 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 6079371160f293aebaf00908a3dc6247c5bb62c5 Former-commit-id: d3aabbfb8efd051555edf6269499270141861903 --- src/drivers/simplix/src/unitdriver.cpp | 20 ++--- src/drivers/simplix/src/unitdriver.h | 8 +- src/drivers/simplix/src/unitfixcarparam.cpp | 2 +- src/drivers/simplix/src/unitmain.cpp | 8 +- src/drivers/simplix/src/unitopponent.cpp | 2 +- src/drivers/usr_36GP/driver.cpp | 52 ++++++------- src/drivers/usr_36GP/opponent.cpp | 28 +++---- src/drivers/usr_36GP/raceline.cpp | 74 +++++++++---------- src/drivers/usr_36GP/strategy.cpp | 4 +- src/drivers/usr_36GP/strategy.h | 2 + src/drivers/usr_36GP/usr_36GP.cpp | 6 +- src/drivers/usr_sc/driver.cpp | 52 ++++++------- src/drivers/usr_sc/opponent.cpp | 28 +++---- src/drivers/usr_sc/raceline.cpp | 74 +++++++++---------- src/drivers/usr_sc/strategy.cpp | 4 +- src/drivers/usr_sc/strategy.h | 2 + src/drivers/usr_sc/usr_sc.cpp | 6 +- src/drivers/usr_trb1/driver.cpp | 52 ++++++------- src/drivers/usr_trb1/opponent.cpp | 28 +++---- src/drivers/usr_trb1/raceline.cpp | 74 +++++++++---------- src/drivers/usr_trb1/strategy.cpp | 4 +- src/drivers/usr_trb1/strategy.h | 2 + src/drivers/usr_trb1/usr_trb1.cpp | 6 +- src/libs/client/credits.cpp | 2 +- src/libs/robottools/rtteammanager.cpp | 2 +- src/libs/robottools/rttimeanalysis.cpp | 1 + src/libs/tgfclient/guiscrollist.cpp | 2 +- src/libs/tgfclient/screen.cpp | 2 +- src/libs/tgfclient/tgfclient.h | 2 +- src/modules/simu/simuv3/SimulationOptions.cpp | 4 +- src/modules/simu/simuv3/car.cpp | 6 +- src/tools/trackgen/track.cpp | 4 +- 32 files changed, 286 insertions(+), 277 deletions(-) diff --git a/src/drivers/simplix/src/unitdriver.cpp b/src/drivers/simplix/src/unitdriver.cpp index 8d3bbe4a7..54f2c7029 100644 --- a/src/drivers/simplix/src/unitdriver.cpp +++ b/src/drivers/simplix/src/unitdriver.cpp @@ -81,10 +81,10 @@ //--------------------------------------------------------------------------* int TDriver::NBBOTS = MAX_NBBOTS; // Nbr of drivers/robots double TDriver::CurrSimTime = 0; // Current simulation time -char* TDriver::MyBotName = "simplix"; // Name of this bot -char* TDriver::ROBOT_DIR = "drivers/simplix"; // Sub path to dll -char* TDriver::SECT_PRIV = "simplix private"; // Private section -char* TDriver::DEFAULTCARTYPE = "car1-trb1"; // Default car type +char const* TDriver::MyBotName = "simplix"; // Name of this bot +char const* TDriver::ROBOT_DIR = "drivers/simplix"; // Sub path to dll +char const* TDriver::SECT_PRIV = "simplix private"; // Private section +char const* TDriver::DEFAULTCARTYPE = "car1-trb1"; // Default car type bool TDriver::AdvancedParameters = false; // Advanced parameters bool TDriver::UseOldSkilling = false; // Use old skilling bool TDriver::UseSCSkilling = false; // Use supercar skilling @@ -97,10 +97,10 @@ float TDriver::SpeedLimitScale = 25; // Speed limit scale double TDriver::LengthMargin; // safety margin long. bool TDriver::Qualification; // Global flag -static char *WheelSect[4] = // TORCS defined sections +static char const *WheelSect[4] = // TORCS defined sections {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; -static double (TDriver::*CalcCrv)(double Crv); +//static double (TDriver::*CalcCrv)(double Crv); //static double cTimeSum[7] = {0,0,0,0,0,0,0}; //==========================================================================* @@ -431,11 +431,11 @@ void TDriver::InitTrack oSkillGlobal = oSkill = oDecelAdjustPerc = oDriverAggression = 0.0; // Initialize race type array - char* RaceType[] = + char const* RaceType[] = {"practice", "qualify", "race"}; // Initialize the base param path - char* BaseParamPath = TDriver::ROBOT_DIR; + char const* BaseParamPath = TDriver::ROBOT_DIR; char* PathFilename = PathFilenameBuffer; // Global skilling from Andrew Sumner ... @@ -490,7 +490,7 @@ void TDriver::InitTrack } // Get individual skilling - int SkillEnabled = 0; + //int SkillEnabled = 0; snprintf(PathFilenameBuffer,BUFLEN,"%s/%d/skill.xml", BaseParamPath,oIndex); GfOut("#PathFilename: %s\n", PathFilenameBuffer); // itself @@ -1075,7 +1075,7 @@ void TDriver::Drive() oAccel = 1.0; // Assume full throttle oBrake = 0.0; // Assume no braking - double StartTimeStamp = RtTimeStamp(); + //double StartTimeStamp = RtTimeStamp(); double Pos = oTrackDesc.CalcPos(oCar); // Get current pos on track diff --git a/src/drivers/simplix/src/unitdriver.h b/src/drivers/simplix/src/unitdriver.h index a4e879190..371f8edd3 100644 --- a/src/drivers/simplix/src/unitdriver.h +++ b/src/drivers/simplix/src/unitdriver.h @@ -387,10 +387,10 @@ private: static int NBBOTS; // Nbr of cars static double CurrSimTime; // Current simulation time - static char* MyBotName; // Name of this bot - static char* ROBOT_DIR; // Sub path to dll - static char* SECT_PRIV; // Private section - static char* DEFAULTCARTYPE; // Default car type + static char const* MyBotName; // Name of this bot + static char const* ROBOT_DIR; // Sub path to dll + static char const* SECT_PRIV; // Private section + static char const* DEFAULTCARTYPE; // Default car type static bool AdvancedParameters; static bool UseOldSkilling; diff --git a/src/drivers/simplix/src/unitfixcarparam.cpp b/src/drivers/simplix/src/unitfixcarparam.cpp index 360aaa8f6..42b08f487 100644 --- a/src/drivers/simplix/src/unitfixcarparam.cpp +++ b/src/drivers/simplix/src/unitfixcarparam.cpp @@ -380,7 +380,7 @@ double TFixCarParam::CalcMaxSpeed if (oStrategy->OutOfPitlane()) factor *= 1.0 - MAX(0.0,TDriver::SpeedLimitScale * (AbsCrv - TDriver::SpeedLimitBase)); } -/**/ +*//**/ double Den; double ScaleBump; diff --git a/src/drivers/simplix/src/unitmain.cpp b/src/drivers/simplix/src/unitmain.cpp index 71796b917..e329be831 100644 --- a/src/drivers/simplix/src/unitmain.cpp +++ b/src/drivers/simplix/src/unitmain.cpp @@ -107,7 +107,7 @@ static const int MAXNBBOTS = MAX_NBBOTS; // Number of drivers/robots static const int BUFSIZE = 256; // Default driver names -static char* defaultBotName[MAXNBBOTS] = { +static char const* defaultBotName[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", @@ -115,7 +115,7 @@ static char* defaultBotName[MAXNBBOTS] = { }; // Default driver descriptions -static char* defaultBotDesc[MAXNBBOTS] = { +static char const* defaultBotDesc[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", @@ -161,7 +161,7 @@ char undefined[] = "undefined"; // Robot of this modul // Roboter des Moduls //--------------------------------------------------------------------------* -static char** BotDesc = defaultBotDesc; +static char const** BotDesc = defaultBotDesc; static TDriver *cRobot[MAXNBBOTS]; static TCommonData gCommonData; @@ -211,7 +211,7 @@ void* GetFileHandle(const char* RobotName) //==========================================================================* // Set parameters //--------------------------------------------------------------------------* -void SetParameters(int N, char* DefaultCarType) +void SetParameters(int N, char const* DefaultCarType) { NBBOTS = N; TDriver::NBBOTS = N; // Used nbr of cars diff --git a/src/drivers/simplix/src/unitopponent.cpp b/src/drivers/simplix/src/unitopponent.cpp index fca5c5251..bf35eb57b 100644 --- a/src/drivers/simplix/src/unitopponent.cpp +++ b/src/drivers/simplix/src/unitopponent.cpp @@ -485,7 +485,7 @@ bool TOpponent::Classify( double T = (fabs(OpState.CarDistLat) - OpState.MinDistLat) / fabs(OpState.CarDiffVelLat); - double CollX = OpState.CarDiffVelLong * T - OpState.CarDistLong; + //double CollX = OpState.CarDiffVelLong * T - OpState.CarDistLong; // if ((CollX > AheadDist) // && (CollX < OpState.MinDistLong)) diff --git a/src/drivers/usr_36GP/driver.cpp b/src/drivers/usr_36GP/driver.cpp index 8733b78b4..b30abbe86 100644 --- a/src/drivers/usr_36GP/driver.cpp +++ b/src/drivers/usr_36GP/driver.cpp @@ -301,8 +301,8 @@ void Driver::initTrack(tTrack* t, void *carHandle, void **carParmHandle, tSituat char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -587,8 +587,8 @@ void Driver::newRace(tCarElt* car, tSituation *s) char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(car->_carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -1034,7 +1034,7 @@ float Driver::getAccel() if (pit->getInPit() && car->_brakeCmd == 0.0f) { - float s = pit->toSplineCoord( car->_distFromStartLine ); + //float s = pit->toSplineCoord( car->_distFromStartLine ); #if 0 if (pit->needPitstop()) @@ -1376,7 +1376,7 @@ float Driver::getSteer(tSituation *s) bool yr_ok = (fabs(car->_yaw_rate) < 0.1 || (car->_yaw_rate > rldata->rInverse*100-0.1 && car->_yaw_rate < rldata->rInverse*100+0.1)); bool angle_ok = (angle > rldata->rlangle-0.06 && angle < rldata->rlangle+0.06); - double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); + //double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); bool steer_ok = (racesteerlaststeer-0.05); double skid = (car->_skid[0] + car->_skid[1] + car->_skid[2] + car->_skid[3]) / 2; @@ -1543,7 +1543,7 @@ double Driver::calcSteer( double targetAngle, int rl ) if (fabs(nextangle) > fabs(speedangle)) { // steer into the skid - double sa = MAX(-0.3, MIN(0.3, speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, speedangle/3)); //double anglediff = (sa - angle) * (0.3 + fabs(angle)/6); double anglediff = (speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += (float) (anglediff*SkidSteer); @@ -1647,7 +1647,7 @@ float Driver::correctSteering( float avoidsteer, float racesteer ) return avoidsteer; float steer = avoidsteer; - float accel = MIN(0.0f, car->_accel_x); + //float accel = MIN(0.0f, car->_accel_x); double speed = 50.0; //MAX(50.0, currentspeed); double changelimit = MIN(raceline->correctLimit(avoidsteer, racesteer), (((120.0-currentspeed)/6000) * (0.1 + fabs(rldata->mInverse/4)))) * SmoothSteer; @@ -2023,7 +2023,7 @@ vec2f Driver::getTargetPoint(bool use_lookahead, double targetoffset) // all the BT code below is for steering into pits only. s.x = (seg->vertex[TR_SL].x + seg->vertex[TR_SR].x)/2; s.y = (seg->vertex[TR_SL].y + seg->vertex[TR_SR].y)/2; - double dx, dy; + //double dx, dy; vec2f t, rt; if ( seg->type == TR_STR) { @@ -2059,9 +2059,9 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool if (!o) return false; #if 1 - int segid = car->_trkPos.seg->id; + //int segid = car->_trkPos.seg->id; tCarElt *ocar = o->getCarPtr(); - int osegid = ocar->_trkPos.seg->id; + //int osegid = ocar->_trkPos.seg->id; double otry_factor = (lenient ? (0.2 + MAX(0.0, 1.0 - ((simtime-frontavoidtime)/7.0)) * 0.8) : 1.0); double overtakecaution = MAX(0.0, rldata->overtakecaution + (outside ? MIN(0.0, car->_accel_x/8) : 0.0)) - driver_aggression/2; double orInv=0.0, oAspeed=0.0; @@ -2166,7 +2166,7 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool float Driver::getOffset() { int i, avoidmovt = 0; - double catchdist, mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; + double /*catchdist,*/ mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; Opponent *o = NULL; double lane2left = rldata->lane * car->_trkPos.seg->width; double lane2right = car->_trkPos.seg->width-lane2left; @@ -2179,7 +2179,7 @@ float Driver::getOffset() // Increment speed dependent. //double incspeed = MIN(40.0, MAX(30.0, currentspeed)); //double incfactor = (MAX_INC_FACTOR*0.5 - MIN(incspeed/10, MAX_INC_FACTOR*0.5-0.5)) * 60 * IncFactor; - double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; + //double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; //double incfactor = (MAX_INC_FACTOR - MIN(fabs(incspeed)/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; double incfactor = (MAX_INC_FACTOR - MIN(40.0/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; @@ -2204,7 +2204,7 @@ float Driver::getOffset() double moffset = car->_trkPos.toMiddle; - double origoffset = moffset; + //double origoffset = moffset; double Width = car->_trkPos.seg->width; #if 1 @@ -2235,8 +2235,8 @@ float Driver::getOffset() { // reduce amount we deviate from the raceline according to how long we've been avoiding, and also // how fast we're going. - double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; - double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; + //double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; + //double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; // instead of toMiddle just aiming at where the car currently is, we move it in the direction // the car's travelling ... but less so if the speedangle is different from the car's angle. @@ -2524,13 +2524,13 @@ fprintf(stderr,"%s -> %s CANCEL 1 (%.1f > %.1f || %.1f < %.1f || %.3f > %.3f)\n" tCarElt *ocar = o->getCarPtr(); // Compute the width around the middle which we can use for overtaking. - float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; + //float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; // Compute the opponents distance to the middle. - float otm = ocar->_trkPos.toMiddle; + //float otm = ocar->_trkPos.toMiddle; // Define the with of the middle range. - float wm = ocar->_trkPos.seg->width*CENTERDIV; + //float wm = ocar->_trkPos.seg->width*CENTERDIV; float sidedist = fabs(car->_trkPos.toMiddle-ocar->_trkPos.toMiddle); - double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); + //double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); //int avoidingside = (otm > wm && myoffset > -w) ? TR_RGT : ((otm < -wm && myoffset < w) ? TR_LFT : TR_STR); int avoidingside = (car->_trkPos.toLeft > ocar->_trkPos.toLeft ? TR_LFT : TR_RGT); @@ -2878,7 +2878,7 @@ fprintf(stderr,"%s BEHIND %s (%d %d %d %d)\n",car->_name,ocar->_name,((o->getSta double factor = 0.25;//(fabs(car->_trkPos.toMiddle) < car->_trkPos.seg->width/2 + 2.0 ? 0.25 : 1.0); if (fabs(myoffset) > fabs(rldata->offset)) { - double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; + //double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; if (myoffset < rldata->offset && myoffset < 2.0) myoffset += (float) (MIN(rldata->offset-myoffset, OVERTAKE_OFFSET_INC * rgtinc/3 * factor)); else if (myoffset > rldata->offset && myoffset > 2.0) @@ -3060,7 +3060,7 @@ void Driver::update(tSituation *s) for (int i=0; igetNOpponents(); i++) { - int idx = opponent[i].getIndex(); + //int idx = opponent[i].getIndex(); if (opponent[i].getTeam() != TEAM_FRIEND) continue; if (opponent[i].getCarPtr() == car) continue; if (opponent[i].getCarPtr()->_state > RM_CAR_STATE_PIT) @@ -3449,7 +3449,7 @@ void Driver::initWheelPos() { for (int i=0; i<4; i++) { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rh = 0.0; rh = GfParmGetNum(car->_carHandle,WheelSect[i],PRM_RIDEHEIGHT,(char *)NULL, 0.10f); wheelz[i] = (-rh / 1.0 + car->info.wheel[i].wheelRadius) - 0.01; @@ -3458,7 +3458,7 @@ void Driver::initWheelPos() void Driver::initCa() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rearwingarea = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGAREA, (char*) NULL, 0.0f); float rearwingangle = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGANGLE, (char*) NULL, 0.0f); float wingca = 1.23f*rearwingarea*sin(rearwingangle); @@ -3486,7 +3486,7 @@ void Driver::initCw() // Init the friction coefficient of the the tires. void Driver::initTireMu() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float tm = FLT_MAX; int i; @@ -3616,7 +3616,7 @@ float Driver::filterABS(float brake) { if (car->_speed_x < ABS_MINSPEED) return brake; float origbrake = brake; - float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); + //float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); int i; float slip = 0.0f; for (i = 0; i < 4; i++) { diff --git a/src/drivers/usr_36GP/opponent.cpp b/src/drivers/usr_36GP/opponent.cpp index 2a08b2c11..9d722f35e 100644 --- a/src/drivers/usr_36GP/opponent.cpp +++ b/src/drivers/usr_36GP/opponent.cpp @@ -214,15 +214,15 @@ fprintf(stderr," FRONTSLOW\n"); double max = MAX(lane, MAX(mycar->_trkPos.seg->width-mycar->_dimension_y/2, driver->getNextLeft())); double min = MIN(lane, MIN(mycar->_dimension_y/2, driver->getNextLeft())); //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(driver->getNextLeft()-mycar->_trkPos.toLeft) * (t_impact*deltamult)))) - driver->getAngle(); - double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); + //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); max = MAX(nextleft, car->_trkPos.seg->width-car->_dimension_y/2); min = MIN(nextleft, car->_dimension_y/2); //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(nextleft-car->_trkPos.toLeft) * (t_impact*deltamult)))) - angle; - double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); + //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); //double sepdist = fabs(mleft - oleft); double sepdist = fabs(car->_trkPos.toLeft - mycar->_trkPos.toLeft) + driver->getAngle()*2; - int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); + //int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); //t_impact = MIN(mspeed/7, t_impact); @@ -234,7 +234,7 @@ fprintf(stderr," FRONTSLOW\n"); float cardist = car->_trkPos.toMiddle - mycar->_trkPos.toMiddle; sidedist = cardist; cardist = sepdist - fabs(getWidth()/2.0f) - mycar->_dimension_y/2.0f; - double deduction = t_impact / MAX(1.0, distance); + //double deduction = t_impact / MAX(1.0, distance); if (cardist < SIDE_MARGIN) { if (DebugMsg & debug_brake) fprintf(stderr,"FRONTCOLLIDE %s cardist=%.3f sepdist=%.3f\n",car->_name,cardist,sepdist); @@ -394,7 +394,7 @@ fprintf(stderr," FRONTFAST\n"); if (team == TEAM_FRIEND && car->_dammage-1000 < mycar->_dammage) state |= OPP_FRONT_FOLLOW; - double dSpeed = mspeed;//driver->getSpeed(); + //double dSpeed = mspeed;//driver->getSpeed(); //if (distance < 20.0 - (getSpeed()-driver->getSpeed())*4) if (distance < 20.0 - (ospeed-mspeed)*4) state |= OPP_FRONT; @@ -527,15 +527,15 @@ int Opponent::polyOverlap( tPosd *op, tPosd *dp ) int Opponent::testCollision(Driver *driver, double impact, double sizefactor, vec2f *targ ) { tCarElt *mycar = driver->getCarPtr(); - int collide = 0, i, j; - double nSlices = MAX(1.0, (impact * deltamult)); + int /*collide = 0,*/ i/*, j*/; + //double nSlices = MAX(1.0, (impact * deltamult)); tCarElt *dcar = driver->getCarPtr(); double o_speedX = car->_speed_X;// + (cardata->getSpeedDeltaX()) * (impact * deltamult) / 2; double o_speedY = car->_speed_Y;// + (cardata->getSpeedDeltaY()) * (impact * deltamult) / 2; double d_speedX = dcar->_speed_X;// + driver->getSpeedDeltaX() * (impact * deltamult) / 2; double d_speedY = dcar->_speed_Y;// + driver->getSpeedDeltaY() * (impact * deltamult) / 2; - tPosd o_cur[4], d_cur[4], o_curp[4], d_curp[4], o_new[4], d_new[4], o_new2[4], d_new2[4]; + tPosd o_cur[4], d_cur[4], /*o_curp[4], d_curp[4],*/ o_new[4], d_new[4], o_new2[4], d_new2[4]; // set up car current positions for (i=0; i<4; i++) @@ -558,8 +558,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve else { // position driver's car according to velocity angle - double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); - double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); + //double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); + //double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -572,8 +572,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve #if 1 { // position opponent car according to velocity angle - double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); - double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); + //double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); + //double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -698,8 +698,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve double ti = MAX(0.001, impact) + 0.1; tPosd *o_old1 = cardata->getCorner1(); tPosd *d_old1 = driver->getCorner1(); - tPosd *o_old2 = cardata->getCorner2(); - tPosd *d_old2 = driver->getCorner2(); + //tPosd *o_old2 = cardata->getCorner2(); + //tPosd *d_old2 = driver->getCorner2(); for (i=0; i<4; i++) { diff --git a/src/drivers/usr_36GP/raceline.cpp b/src/drivers/usr_36GP/raceline.cpp index a8e3dead3..2aa674890 100644 --- a/src/drivers/usr_36GP/raceline.cpp +++ b/src/drivers/usr_36GP/raceline.cpp @@ -32,7 +32,7 @@ // Structures and Statics //////////////////////////////////////////////////////////////////////////// -static SRaceLine SRL[5] = { 0 }; +static SRaceLine SRL[5] = { { 0 } }; static int SRLinit = 0; //////////////////////////////////////////////////////////////////////////// @@ -45,8 +45,8 @@ static int SRLinit = 0; //static const int Iterations = 100; // Number of smoothing operations static const double SecurityR = 100.0; // Security radius -static double SideDistExt = 2.0; // Security distance wrt outside -static double SideDistInt = 1.0; // Security distance wrt inside +//static double SideDistExt = 2.0; // Security distance wrt outside +//static double SideDistInt = 1.0; // Security distance wrt inside ///////////////////////////////////////////////////////////////////////////// // Some utility macros and functions @@ -865,7 +865,7 @@ void LRaceLine::StepInterpolate(int iMin, int iMax, int Step, int rl) } } -static void ClosestPointOnLineFromPoint( +/*static void ClosestPointOnLineFromPoint( vec2f *lp1, vec2f *lp2, vec2f *p, vec2f *r ) { @@ -880,7 +880,7 @@ static void ClosestPointOnLineFromPoint( r->x = lp1->x + ratio * vx; r->y = lp1->y + ratio * vy; -} +}*/ static double PointDist(vec2f *p1, vec2f *p2) { @@ -1077,8 +1077,8 @@ void LRaceLine::ComputeSpeed(int rl) } int nnext = (i + 5) % Divs; - int next = (i + 1) % Divs; - int prev = (i - 1 + Divs) % Divs; + //int next = (i + 1) % Divs; + //int prev = (i - 1 + Divs) % Divs; double rInverse = SRL[rl].tRInverse[i]; double rI = fabs(rInverse); @@ -1437,8 +1437,8 @@ void LRaceLine::GetRLSteerPoint( vec2f *rt, double *offset, double time ) dist *= car->_trkPos.seg->radius; int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time); { @@ -1476,7 +1476,7 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl int maxcount = int(lookahead / DivLength + 1); int count = 0; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = 0.0;//car->_trkPos.toStart; #if 0 @@ -1487,8 +1487,8 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl #endif int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time/2); double carspeed = Mag(car->_speed_X, car->_speed_Y); double offlane = (offset > -90 ? ((track->width/2) - offset) / track->width : SRL[SRLidx].tLane[next]); @@ -1587,8 +1587,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (famI > 0.0) { double toMid = car->_trkPos.toMiddle + data->speedangle * 20; - double toLeft = car->_trkPos.toLeft - data->speedangle * 20; - double toRight = car->_trkPos.toRight + data->speedangle * 20; + //double toLeft = car->_trkPos.toLeft - data->speedangle * 20; + //double toRight = car->_trkPos.toRight + data->speedangle * 20; double modfactor = (car->_speed_x / data->avspeed); modfactor *= modfactor; @@ -1612,12 +1612,12 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) //if (data->collision) // timefactor *= 1.0 + MAX(0.0, (5.0-data->collision) / 5.0); double Time = timefactor; // + CornerAccel/80; - double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; - double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; + //double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; + //double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; double X = car->_pos_X + car->_speed_X * Time / 2; double Y = car->_pos_Y + car->_speed_Y * Time / 2; - double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; - double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; + //double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; + //double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; data->lookahead = 0.0f; data->aInverse = SRL[LINE_MID].tRInverse[Index]; double divcount = 1.0; @@ -1647,7 +1647,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (data->followdist <= 5.0) { - int snext = SNext; + //int snext = SNext; //Next = (Next + int((car->_dimension_x + (5.0 - data->followdist)*1.2) / DivLength)) % Divs; SNext = (Next + int((car->_dimension_x + (5.0 - data->followdist)*6) / DivLength)) % Divs; if (car->_accel_x > 0.0 && data->followdist <= 2.0) @@ -1741,7 +1741,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->offset = laneoffset; //fprintf(stderr,"GetRLData: offset=%.2f Next=%d lane=%.4f Width=%.2f\n",laneoffset,Next,tLane[Next],Width); - double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); + //double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); //CalcAvoidSpeed( Next, data, sa ); #if 1 @@ -1826,7 +1826,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) vec2f target; double carspeed = Mag(car->_speed_X, car->_speed_Y); double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; // an idea to implement soon... //if (car->_accel_x < 0.0) @@ -1846,7 +1846,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); k1999steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -1856,8 +1856,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) double dx = SRL[SRLidx].tx[NextNext] - SRL[SRLidx].tx[Prev]; double dy = SRL[SRLidx].ty[NextNext] - SRL[SRLidx].ty[Prev]; - double vx = car->_speed_X; - double vy = car->_speed_Y; + //double vx = car->_speed_X; + //double vy = car->_speed_Y; double dirx = cos(car->_yaw); double diry = sin(car->_yaw); double SinAngleError = dx * diry - dy * dirx; @@ -1951,7 +1951,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->NSsteer = lastNksteer = k1999steer; int Prev = (KIndex + Divs - 1) % Divs; - int PrevPrev = (KIndex + Divs - 5) % Divs; + //int PrevPrev = (KIndex + Divs - 5) % Divs; int NextNext = (KNext + 1) % Divs; // @@ -2103,7 +2103,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); if (data->followdist < 5.0) steertime = MIN(MaxSteerTime*1.1, steertime * 1.0 + (5.0 - data->followdist)/20); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; double amI = MIN(0.05, MAX(-0.05, SRL[SRLidx].tRInverse[Next])); double famI = fabs(amI); @@ -2151,7 +2151,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -2175,7 +2175,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) double offlane = ((track->width/2) - offset) / track->width; double off2lft = track->width/2 - offset; double off2rgt = track->width - off2lft; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = car->_trkPos.toStart; if (dist < 0) @@ -2183,7 +2183,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) if (car->_trkPos.seg->type != TR_STR) dist *= car->_trkPos.seg->radius; int Index = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); - double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); + //double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); double rInv = SRL[LINE_MID].tRInverse[Index]; Index = This; #if 1 @@ -2216,8 +2216,8 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) next = (Index + 1) % Divs; txNext = offlane * SRL[SRLidx].txRight[next] + (1 - offlane) * SRL[SRLidx].txLeft[next]; tyNext = offlane * SRL[SRLidx].tyRight[next] + (1 - offlane) * SRL[SRLidx].tyLeft[next]; - double dx = txNext - car->_pos_X; - double dy = tyNext - car->_pos_Y; + //double dx = txNext - car->_pos_X; + //double dy = tyNext - car->_pos_Y; if ((txNext - txIndex) * (X - txNext) + (tyNext - tyIndex) * (Y - tyNext) < -0.1) { @@ -2248,12 +2248,12 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) int LRaceLine::findNextCorner( double *nextCRinverse ) { - tTrackSeg *seg = car->_trkPos.seg;; + //tTrackSeg *seg = car->_trkPos.seg;; int prefer_side = ((SRL[SRLidx].tRInverse[Next] > 0.001) ? TR_LFT : ((SRL[SRLidx].tRInverse[Next]) < -0.001 ? TR_RGT : TR_STR)); - double curlane = car->_trkPos.toLeft / track->width; - int next = (Next+5) % Divs, i = 1, div; - double distance = 0.0; + //double curlane = car->_trkPos.toLeft / track->width; + int /*next = (Next+5) % Divs,*/ i = 1, div; + //double distance = 0.0; double CR = SRL[SRLidx].tRInverse[Next]; if (car->_speed_x < 5.0) @@ -2297,7 +2297,7 @@ int LRaceLine::findNextCorner( double *nextCRinverse ) double LRaceLine::correctLimit(double avoidsteer, double racesteer) { - double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; + //double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; double tbump = BumpCaution;//GetModD( tBump, This ) * 4; // correct would take us in the opposite direction to a corner - correct less! @@ -2307,7 +2307,7 @@ double LRaceLine::correctLimit(double avoidsteer, double racesteer) // correct would take us in the opposite direction to a corner - correct less (but not as much as above) int nnext = (Next + (int) (car->_speed_x/3)) % Divs; - double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; + //double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; if ((SRL[SRLidx].tRInverse[nnext] > 0.001 && avoidsteer > racesteer) || (SRL[SRLidx].tRInverse[nnext] < -0.001 && avoidsteer < racesteer)) return MAX(0.3, MIN(1.0, 1.0 - fabs(SRL[SRLidx].tRInverse[nnext]) * 40.0 - tbump)); diff --git a/src/drivers/usr_36GP/strategy.cpp b/src/drivers/usr_36GP/strategy.cpp index d01e03e88..c570e9fcf 100644 --- a/src/drivers/usr_36GP/strategy.cpp +++ b/src/drivers/usr_36GP/strategy.cpp @@ -35,12 +35,12 @@ SimpleStrategy::SimpleStrategy() : m_lastfuel(0.0f), m_expectedfuelperlap(0.0f), m_fuelsum(0.0f), + PitDamage(5000), pit_damage(0), min_damage(0), is_pitting(0), remainlaps(0), pit_reason(0), - PitDamage(5000), track(NULL) { #ifdef SPEED_DREAMS @@ -179,7 +179,7 @@ bool SimpleStrategy::needPitstop(tCarElt* car, tSituation *s, Opponents *opp) { // Do we need to refuel? int remainlaps = car->_remainingLaps;//-car->_lapsBehindLeader; - int this_pit_dammage = PitDamage; + //int this_pit_dammage = PitDamage; if (!car->_pit) return false; diff --git a/src/drivers/usr_36GP/strategy.h b/src/drivers/usr_36GP/strategy.h index f66e98aea..b1def3ede 100644 --- a/src/drivers/usr_36GP/strategy.h +++ b/src/drivers/usr_36GP/strategy.h @@ -37,7 +37,9 @@ #include #include +#ifndef SPEED_DREAMS #define SPEED_DREAMS +#endif //SPEED_DREAMS #ifdef SPEED_DREAMS #include diff --git a/src/drivers/usr_36GP/usr_36GP.cpp b/src/drivers/usr_36GP/usr_36GP.cpp index 77a838591..0d0f88856 100644 --- a/src/drivers/usr_36GP/usr_36GP.cpp +++ b/src/drivers/usr_36GP/usr_36GP.cpp @@ -47,14 +47,14 @@ static void endRace(int index, tCarElt *car, tSituation *s); // TORCS-NG-Interface static const int BUFSIZE = 256; // Buffer size for path/filename buffers static const int MAXNBBOTS = 20; // Set value to max capacity you want to use here -static char* defaultBotName[MAXNBBOTS] = { +static char const* defaultBotName[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", "driver 16", "driver 17", "driver 18", "driver 19", "driver 20" }; -static char* defaultBotDesc[MAXNBBOTS] = { +static char const* defaultBotDesc[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", @@ -96,7 +96,7 @@ void SetUpUSR_36GP() // Set robots's name and xml file pathname static void setRobotName(const char *name) { - char* c; + //char* c; strcpy(nameBuffer, name); snprintf(pathBuffer, BUFSIZE, "drivers/%s/%s.xml", name, name); diff --git a/src/drivers/usr_sc/driver.cpp b/src/drivers/usr_sc/driver.cpp index 5b9a7486f..f2d25d28c 100644 --- a/src/drivers/usr_sc/driver.cpp +++ b/src/drivers/usr_sc/driver.cpp @@ -301,8 +301,8 @@ void Driver::initTrack(tTrack* t, void *carHandle, void **carParmHandle, tSituat char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -587,8 +587,8 @@ void Driver::newRace(tCarElt* car, tSituation *s) char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(car->_carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -1034,7 +1034,7 @@ float Driver::getAccel() if (pit->getInPit() && car->_brakeCmd == 0.0f) { - float s = pit->toSplineCoord( car->_distFromStartLine ); + //float s = pit->toSplineCoord( car->_distFromStartLine ); #if 0 if (pit->needPitstop()) @@ -1376,7 +1376,7 @@ float Driver::getSteer(tSituation *s) bool yr_ok = (fabs(car->_yaw_rate) < 0.1 || (car->_yaw_rate > rldata->rInverse*100-0.1 && car->_yaw_rate < rldata->rInverse*100+0.1)); bool angle_ok = (angle > rldata->rlangle-0.06 && angle < rldata->rlangle+0.06); - double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); + //double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); bool steer_ok = (racesteerlaststeer-0.05); double skid = (car->_skid[0] + car->_skid[1] + car->_skid[2] + car->_skid[3]) / 2; @@ -1543,7 +1543,7 @@ double Driver::calcSteer( double targetAngle, int rl ) if (fabs(nextangle) > fabs(speedangle)) { // steer into the skid - double sa = MAX(-0.3, MIN(0.3, speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, speedangle/3)); //double anglediff = (sa - angle) * (0.3 + fabs(angle)/6); double anglediff = (speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += (float) (anglediff*SkidSteer); @@ -1647,7 +1647,7 @@ float Driver::correctSteering( float avoidsteer, float racesteer ) return avoidsteer; float steer = avoidsteer; - float accel = MIN(0.0f, car->_accel_x); + //float accel = MIN(0.0f, car->_accel_x); double speed = 50.0; //MAX(50.0, currentspeed); double changelimit = MIN(raceline->correctLimit(avoidsteer, racesteer), (((120.0-currentspeed)/6000) * (0.1 + fabs(rldata->mInverse/4)))) * SmoothSteer; @@ -2023,7 +2023,7 @@ vec2f Driver::getTargetPoint(bool use_lookahead, double targetoffset) // all the BT code below is for steering into pits only. s.x = (seg->vertex[TR_SL].x + seg->vertex[TR_SR].x)/2; s.y = (seg->vertex[TR_SL].y + seg->vertex[TR_SR].y)/2; - double dx, dy; + //double dx, dy; vec2f t, rt; if ( seg->type == TR_STR) { @@ -2059,9 +2059,9 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool if (!o) return false; #if 1 - int segid = car->_trkPos.seg->id; + //int segid = car->_trkPos.seg->id; tCarElt *ocar = o->getCarPtr(); - int osegid = ocar->_trkPos.seg->id; + //int osegid = ocar->_trkPos.seg->id; double otry_factor = (lenient ? (0.2 + MAX(0.0, 1.0 - ((simtime-frontavoidtime)/7.0)) * 0.8) : 1.0); double overtakecaution = MAX(0.0, rldata->overtakecaution + (outside ? MIN(0.0, car->_accel_x/8) : 0.0)) - driver_aggression/2; double orInv=0.0, oAspeed=0.0; @@ -2166,7 +2166,7 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool float Driver::getOffset() { int i, avoidmovt = 0; - double catchdist, mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; + double /*catchdist,*/ mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; Opponent *o = NULL; double lane2left = rldata->lane * car->_trkPos.seg->width; double lane2right = car->_trkPos.seg->width-lane2left; @@ -2179,7 +2179,7 @@ float Driver::getOffset() // Increment speed dependent. //double incspeed = MIN(40.0, MAX(30.0, currentspeed)); //double incfactor = (MAX_INC_FACTOR*0.5 - MIN(incspeed/10, MAX_INC_FACTOR*0.5-0.5)) * 60 * IncFactor; - double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; + //double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; //double incfactor = (MAX_INC_FACTOR - MIN(fabs(incspeed)/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; double incfactor = (MAX_INC_FACTOR - MIN(40.0/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; @@ -2204,7 +2204,7 @@ float Driver::getOffset() double moffset = car->_trkPos.toMiddle; - double origoffset = moffset; + //double origoffset = moffset; double Width = car->_trkPos.seg->width; #if 1 @@ -2235,8 +2235,8 @@ float Driver::getOffset() { // reduce amount we deviate from the raceline according to how long we've been avoiding, and also // how fast we're going. - double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; - double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; + //double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; + //double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; // instead of toMiddle just aiming at where the car currently is, we move it in the direction // the car's travelling ... but less so if the speedangle is different from the car's angle. @@ -2524,13 +2524,13 @@ fprintf(stderr,"%s -> %s CANCEL 1 (%.1f > %.1f || %.1f < %.1f || %.3f > %.3f)\n" tCarElt *ocar = o->getCarPtr(); // Compute the width around the middle which we can use for overtaking. - float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; + //float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; // Compute the opponents distance to the middle. - float otm = ocar->_trkPos.toMiddle; + //float otm = ocar->_trkPos.toMiddle; // Define the with of the middle range. - float wm = ocar->_trkPos.seg->width*CENTERDIV; + //float wm = ocar->_trkPos.seg->width*CENTERDIV; float sidedist = fabs(car->_trkPos.toMiddle-ocar->_trkPos.toMiddle); - double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); + //double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); //int avoidingside = (otm > wm && myoffset > -w) ? TR_RGT : ((otm < -wm && myoffset < w) ? TR_LFT : TR_STR); int avoidingside = (car->_trkPos.toLeft > ocar->_trkPos.toLeft ? TR_LFT : TR_RGT); @@ -2878,7 +2878,7 @@ fprintf(stderr,"%s BEHIND %s (%d %d %d %d)\n",car->_name,ocar->_name,((o->getSta double factor = 0.25;//(fabs(car->_trkPos.toMiddle) < car->_trkPos.seg->width/2 + 2.0 ? 0.25 : 1.0); if (fabs(myoffset) > fabs(rldata->offset)) { - double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; + //double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; if (myoffset < rldata->offset && myoffset < 2.0) myoffset += (float) (MIN(rldata->offset-myoffset, OVERTAKE_OFFSET_INC * rgtinc/3 * factor)); else if (myoffset > rldata->offset && myoffset > 2.0) @@ -3060,7 +3060,7 @@ void Driver::update(tSituation *s) for (int i=0; igetNOpponents(); i++) { - int idx = opponent[i].getIndex(); + //int idx = opponent[i].getIndex(); if (opponent[i].getTeam() != TEAM_FRIEND) continue; if (opponent[i].getCarPtr() == car) continue; if (opponent[i].getCarPtr()->_state > RM_CAR_STATE_PIT) @@ -3449,7 +3449,7 @@ void Driver::initWheelPos() { for (int i=0; i<4; i++) { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rh = 0.0; rh = GfParmGetNum(car->_carHandle,WheelSect[i],PRM_RIDEHEIGHT,(char *)NULL, 0.10f); wheelz[i] = (-rh / 1.0 + car->info.wheel[i].wheelRadius) - 0.01; @@ -3458,7 +3458,7 @@ void Driver::initWheelPos() void Driver::initCa() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rearwingarea = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGAREA, (char*) NULL, 0.0f); float rearwingangle = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGANGLE, (char*) NULL, 0.0f); float wingca = 1.23f*rearwingarea*sin(rearwingangle); @@ -3486,7 +3486,7 @@ void Driver::initCw() // Init the friction coefficient of the the tires. void Driver::initTireMu() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float tm = FLT_MAX; int i; @@ -3616,7 +3616,7 @@ float Driver::filterABS(float brake) { if (car->_speed_x < ABS_MINSPEED) return brake; float origbrake = brake; - float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); + //float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); int i; float slip = 0.0f; for (i = 0; i < 4; i++) { diff --git a/src/drivers/usr_sc/opponent.cpp b/src/drivers/usr_sc/opponent.cpp index 2a08b2c11..9d722f35e 100644 --- a/src/drivers/usr_sc/opponent.cpp +++ b/src/drivers/usr_sc/opponent.cpp @@ -214,15 +214,15 @@ fprintf(stderr," FRONTSLOW\n"); double max = MAX(lane, MAX(mycar->_trkPos.seg->width-mycar->_dimension_y/2, driver->getNextLeft())); double min = MIN(lane, MIN(mycar->_dimension_y/2, driver->getNextLeft())); //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(driver->getNextLeft()-mycar->_trkPos.toLeft) * (t_impact*deltamult)))) - driver->getAngle(); - double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); + //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); max = MAX(nextleft, car->_trkPos.seg->width-car->_dimension_y/2); min = MIN(nextleft, car->_dimension_y/2); //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(nextleft-car->_trkPos.toLeft) * (t_impact*deltamult)))) - angle; - double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); + //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); //double sepdist = fabs(mleft - oleft); double sepdist = fabs(car->_trkPos.toLeft - mycar->_trkPos.toLeft) + driver->getAngle()*2; - int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); + //int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); //t_impact = MIN(mspeed/7, t_impact); @@ -234,7 +234,7 @@ fprintf(stderr," FRONTSLOW\n"); float cardist = car->_trkPos.toMiddle - mycar->_trkPos.toMiddle; sidedist = cardist; cardist = sepdist - fabs(getWidth()/2.0f) - mycar->_dimension_y/2.0f; - double deduction = t_impact / MAX(1.0, distance); + //double deduction = t_impact / MAX(1.0, distance); if (cardist < SIDE_MARGIN) { if (DebugMsg & debug_brake) fprintf(stderr,"FRONTCOLLIDE %s cardist=%.3f sepdist=%.3f\n",car->_name,cardist,sepdist); @@ -394,7 +394,7 @@ fprintf(stderr," FRONTFAST\n"); if (team == TEAM_FRIEND && car->_dammage-1000 < mycar->_dammage) state |= OPP_FRONT_FOLLOW; - double dSpeed = mspeed;//driver->getSpeed(); + //double dSpeed = mspeed;//driver->getSpeed(); //if (distance < 20.0 - (getSpeed()-driver->getSpeed())*4) if (distance < 20.0 - (ospeed-mspeed)*4) state |= OPP_FRONT; @@ -527,15 +527,15 @@ int Opponent::polyOverlap( tPosd *op, tPosd *dp ) int Opponent::testCollision(Driver *driver, double impact, double sizefactor, vec2f *targ ) { tCarElt *mycar = driver->getCarPtr(); - int collide = 0, i, j; - double nSlices = MAX(1.0, (impact * deltamult)); + int /*collide = 0,*/ i/*, j*/; + //double nSlices = MAX(1.0, (impact * deltamult)); tCarElt *dcar = driver->getCarPtr(); double o_speedX = car->_speed_X;// + (cardata->getSpeedDeltaX()) * (impact * deltamult) / 2; double o_speedY = car->_speed_Y;// + (cardata->getSpeedDeltaY()) * (impact * deltamult) / 2; double d_speedX = dcar->_speed_X;// + driver->getSpeedDeltaX() * (impact * deltamult) / 2; double d_speedY = dcar->_speed_Y;// + driver->getSpeedDeltaY() * (impact * deltamult) / 2; - tPosd o_cur[4], d_cur[4], o_curp[4], d_curp[4], o_new[4], d_new[4], o_new2[4], d_new2[4]; + tPosd o_cur[4], d_cur[4], /*o_curp[4], d_curp[4],*/ o_new[4], d_new[4], o_new2[4], d_new2[4]; // set up car current positions for (i=0; i<4; i++) @@ -558,8 +558,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve else { // position driver's car according to velocity angle - double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); - double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); + //double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); + //double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -572,8 +572,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve #if 1 { // position opponent car according to velocity angle - double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); - double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); + //double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); + //double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -698,8 +698,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve double ti = MAX(0.001, impact) + 0.1; tPosd *o_old1 = cardata->getCorner1(); tPosd *d_old1 = driver->getCorner1(); - tPosd *o_old2 = cardata->getCorner2(); - tPosd *d_old2 = driver->getCorner2(); + //tPosd *o_old2 = cardata->getCorner2(); + //tPosd *d_old2 = driver->getCorner2(); for (i=0; i<4; i++) { diff --git a/src/drivers/usr_sc/raceline.cpp b/src/drivers/usr_sc/raceline.cpp index a8e3dead3..2aa674890 100644 --- a/src/drivers/usr_sc/raceline.cpp +++ b/src/drivers/usr_sc/raceline.cpp @@ -32,7 +32,7 @@ // Structures and Statics //////////////////////////////////////////////////////////////////////////// -static SRaceLine SRL[5] = { 0 }; +static SRaceLine SRL[5] = { { 0 } }; static int SRLinit = 0; //////////////////////////////////////////////////////////////////////////// @@ -45,8 +45,8 @@ static int SRLinit = 0; //static const int Iterations = 100; // Number of smoothing operations static const double SecurityR = 100.0; // Security radius -static double SideDistExt = 2.0; // Security distance wrt outside -static double SideDistInt = 1.0; // Security distance wrt inside +//static double SideDistExt = 2.0; // Security distance wrt outside +//static double SideDistInt = 1.0; // Security distance wrt inside ///////////////////////////////////////////////////////////////////////////// // Some utility macros and functions @@ -865,7 +865,7 @@ void LRaceLine::StepInterpolate(int iMin, int iMax, int Step, int rl) } } -static void ClosestPointOnLineFromPoint( +/*static void ClosestPointOnLineFromPoint( vec2f *lp1, vec2f *lp2, vec2f *p, vec2f *r ) { @@ -880,7 +880,7 @@ static void ClosestPointOnLineFromPoint( r->x = lp1->x + ratio * vx; r->y = lp1->y + ratio * vy; -} +}*/ static double PointDist(vec2f *p1, vec2f *p2) { @@ -1077,8 +1077,8 @@ void LRaceLine::ComputeSpeed(int rl) } int nnext = (i + 5) % Divs; - int next = (i + 1) % Divs; - int prev = (i - 1 + Divs) % Divs; + //int next = (i + 1) % Divs; + //int prev = (i - 1 + Divs) % Divs; double rInverse = SRL[rl].tRInverse[i]; double rI = fabs(rInverse); @@ -1437,8 +1437,8 @@ void LRaceLine::GetRLSteerPoint( vec2f *rt, double *offset, double time ) dist *= car->_trkPos.seg->radius; int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time); { @@ -1476,7 +1476,7 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl int maxcount = int(lookahead / DivLength + 1); int count = 0; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = 0.0;//car->_trkPos.toStart; #if 0 @@ -1487,8 +1487,8 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl #endif int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time/2); double carspeed = Mag(car->_speed_X, car->_speed_Y); double offlane = (offset > -90 ? ((track->width/2) - offset) / track->width : SRL[SRLidx].tLane[next]); @@ -1587,8 +1587,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (famI > 0.0) { double toMid = car->_trkPos.toMiddle + data->speedangle * 20; - double toLeft = car->_trkPos.toLeft - data->speedangle * 20; - double toRight = car->_trkPos.toRight + data->speedangle * 20; + //double toLeft = car->_trkPos.toLeft - data->speedangle * 20; + //double toRight = car->_trkPos.toRight + data->speedangle * 20; double modfactor = (car->_speed_x / data->avspeed); modfactor *= modfactor; @@ -1612,12 +1612,12 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) //if (data->collision) // timefactor *= 1.0 + MAX(0.0, (5.0-data->collision) / 5.0); double Time = timefactor; // + CornerAccel/80; - double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; - double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; + //double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; + //double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; double X = car->_pos_X + car->_speed_X * Time / 2; double Y = car->_pos_Y + car->_speed_Y * Time / 2; - double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; - double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; + //double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; + //double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; data->lookahead = 0.0f; data->aInverse = SRL[LINE_MID].tRInverse[Index]; double divcount = 1.0; @@ -1647,7 +1647,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (data->followdist <= 5.0) { - int snext = SNext; + //int snext = SNext; //Next = (Next + int((car->_dimension_x + (5.0 - data->followdist)*1.2) / DivLength)) % Divs; SNext = (Next + int((car->_dimension_x + (5.0 - data->followdist)*6) / DivLength)) % Divs; if (car->_accel_x > 0.0 && data->followdist <= 2.0) @@ -1741,7 +1741,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->offset = laneoffset; //fprintf(stderr,"GetRLData: offset=%.2f Next=%d lane=%.4f Width=%.2f\n",laneoffset,Next,tLane[Next],Width); - double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); + //double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); //CalcAvoidSpeed( Next, data, sa ); #if 1 @@ -1826,7 +1826,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) vec2f target; double carspeed = Mag(car->_speed_X, car->_speed_Y); double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; // an idea to implement soon... //if (car->_accel_x < 0.0) @@ -1846,7 +1846,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); k1999steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -1856,8 +1856,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) double dx = SRL[SRLidx].tx[NextNext] - SRL[SRLidx].tx[Prev]; double dy = SRL[SRLidx].ty[NextNext] - SRL[SRLidx].ty[Prev]; - double vx = car->_speed_X; - double vy = car->_speed_Y; + //double vx = car->_speed_X; + //double vy = car->_speed_Y; double dirx = cos(car->_yaw); double diry = sin(car->_yaw); double SinAngleError = dx * diry - dy * dirx; @@ -1951,7 +1951,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->NSsteer = lastNksteer = k1999steer; int Prev = (KIndex + Divs - 1) % Divs; - int PrevPrev = (KIndex + Divs - 5) % Divs; + //int PrevPrev = (KIndex + Divs - 5) % Divs; int NextNext = (KNext + 1) % Divs; // @@ -2103,7 +2103,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); if (data->followdist < 5.0) steertime = MIN(MaxSteerTime*1.1, steertime * 1.0 + (5.0 - data->followdist)/20); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; double amI = MIN(0.05, MAX(-0.05, SRL[SRLidx].tRInverse[Next])); double famI = fabs(amI); @@ -2151,7 +2151,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -2175,7 +2175,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) double offlane = ((track->width/2) - offset) / track->width; double off2lft = track->width/2 - offset; double off2rgt = track->width - off2lft; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = car->_trkPos.toStart; if (dist < 0) @@ -2183,7 +2183,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) if (car->_trkPos.seg->type != TR_STR) dist *= car->_trkPos.seg->radius; int Index = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); - double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); + //double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); double rInv = SRL[LINE_MID].tRInverse[Index]; Index = This; #if 1 @@ -2216,8 +2216,8 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) next = (Index + 1) % Divs; txNext = offlane * SRL[SRLidx].txRight[next] + (1 - offlane) * SRL[SRLidx].txLeft[next]; tyNext = offlane * SRL[SRLidx].tyRight[next] + (1 - offlane) * SRL[SRLidx].tyLeft[next]; - double dx = txNext - car->_pos_X; - double dy = tyNext - car->_pos_Y; + //double dx = txNext - car->_pos_X; + //double dy = tyNext - car->_pos_Y; if ((txNext - txIndex) * (X - txNext) + (tyNext - tyIndex) * (Y - tyNext) < -0.1) { @@ -2248,12 +2248,12 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) int LRaceLine::findNextCorner( double *nextCRinverse ) { - tTrackSeg *seg = car->_trkPos.seg;; + //tTrackSeg *seg = car->_trkPos.seg;; int prefer_side = ((SRL[SRLidx].tRInverse[Next] > 0.001) ? TR_LFT : ((SRL[SRLidx].tRInverse[Next]) < -0.001 ? TR_RGT : TR_STR)); - double curlane = car->_trkPos.toLeft / track->width; - int next = (Next+5) % Divs, i = 1, div; - double distance = 0.0; + //double curlane = car->_trkPos.toLeft / track->width; + int /*next = (Next+5) % Divs,*/ i = 1, div; + //double distance = 0.0; double CR = SRL[SRLidx].tRInverse[Next]; if (car->_speed_x < 5.0) @@ -2297,7 +2297,7 @@ int LRaceLine::findNextCorner( double *nextCRinverse ) double LRaceLine::correctLimit(double avoidsteer, double racesteer) { - double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; + //double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; double tbump = BumpCaution;//GetModD( tBump, This ) * 4; // correct would take us in the opposite direction to a corner - correct less! @@ -2307,7 +2307,7 @@ double LRaceLine::correctLimit(double avoidsteer, double racesteer) // correct would take us in the opposite direction to a corner - correct less (but not as much as above) int nnext = (Next + (int) (car->_speed_x/3)) % Divs; - double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; + //double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; if ((SRL[SRLidx].tRInverse[nnext] > 0.001 && avoidsteer > racesteer) || (SRL[SRLidx].tRInverse[nnext] < -0.001 && avoidsteer < racesteer)) return MAX(0.3, MIN(1.0, 1.0 - fabs(SRL[SRLidx].tRInverse[nnext]) * 40.0 - tbump)); diff --git a/src/drivers/usr_sc/strategy.cpp b/src/drivers/usr_sc/strategy.cpp index 418534681..3c17db795 100644 --- a/src/drivers/usr_sc/strategy.cpp +++ b/src/drivers/usr_sc/strategy.cpp @@ -35,12 +35,12 @@ SimpleStrategy::SimpleStrategy() : m_lastfuel(0.0f), m_expectedfuelperlap(0.0f), m_fuelsum(0.0f), + PitDamage(5000), pit_damage(0), min_damage(0), is_pitting(0), remainlaps(0), pit_reason(0), - PitDamage(5000), track(NULL) { #ifdef SPEED_DREAMS @@ -178,7 +178,7 @@ bool SimpleStrategy::needPitstop(tCarElt* car, tSituation *s, Opponents *opp) { // Do we need to refuel? int remainlaps = car->_remainingLaps;//-car->_lapsBehindLeader; - int this_pit_dammage = PitDamage; + //int this_pit_dammage = PitDamage; if (!car->_pit) return false; diff --git a/src/drivers/usr_sc/strategy.h b/src/drivers/usr_sc/strategy.h index f66e98aea..b1def3ede 100644 --- a/src/drivers/usr_sc/strategy.h +++ b/src/drivers/usr_sc/strategy.h @@ -37,7 +37,9 @@ #include #include +#ifndef SPEED_DREAMS #define SPEED_DREAMS +#endif //SPEED_DREAMS #ifdef SPEED_DREAMS #include diff --git a/src/drivers/usr_sc/usr_sc.cpp b/src/drivers/usr_sc/usr_sc.cpp index 216e63ff2..cc8e5ead5 100644 --- a/src/drivers/usr_sc/usr_sc.cpp +++ b/src/drivers/usr_sc/usr_sc.cpp @@ -47,14 +47,14 @@ static void endRace(int index, tCarElt *car, tSituation *s); // TORCS-NG-Interface static const int BUFSIZE = 256; // Buffer size for path/filename buffers static const int MAXNBBOTS = 20; // Set value to max capacity you want to use here -static char* defaultBotName[MAXNBBOTS] = { +static char const* defaultBotName[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", "driver 16", "driver 17", "driver 18", "driver 19", "driver 20" }; -static char* defaultBotDesc[MAXNBBOTS] = { +static char const* defaultBotDesc[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", @@ -96,7 +96,7 @@ void SetUpUSR_sc() // Set robots's name and xml file pathname static void setRobotName(const char *name) { - char* c; + //char* c; strcpy(nameBuffer, name); snprintf(pathBuffer, BUFSIZE, "drivers/%s/%s.xml", name, name); diff --git a/src/drivers/usr_trb1/driver.cpp b/src/drivers/usr_trb1/driver.cpp index d00615536..4d38b719a 100644 --- a/src/drivers/usr_trb1/driver.cpp +++ b/src/drivers/usr_trb1/driver.cpp @@ -301,8 +301,8 @@ void Driver::initTrack(tTrack* t, void *carHandle, void **carParmHandle, tSituat char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -587,8 +587,8 @@ void Driver::newRace(tCarElt* car, tSituation *s) char carName[256]; { - char *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char *key = PRM_CAR; + char const *path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + char const *key = PRM_CAR; strncpy( carName, GfParmGetStr(car->_carHandle, path, key, ""), sizeof(carName) ); char *p = strrchr(carName, '.'); if (p) *p = '\0'; @@ -1034,7 +1034,7 @@ float Driver::getAccel() if (pit->getInPit() && car->_brakeCmd == 0.0f) { - float s = pit->toSplineCoord( car->_distFromStartLine ); + //float s = pit->toSplineCoord( car->_distFromStartLine ); #if 0 if (pit->needPitstop()) @@ -1376,7 +1376,7 @@ float Driver::getSteer(tSituation *s) bool yr_ok = (fabs(car->_yaw_rate) < 0.1 || (car->_yaw_rate > rldata->rInverse*100-0.1 && car->_yaw_rate < rldata->rInverse*100+0.1)); bool angle_ok = (angle > rldata->rlangle-0.06 && angle < rldata->rlangle+0.06); - double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); + //double rlsteer = (fabs(rldata->rInverse) >= 0.004 ? rldata->rInverse * 12 : 0.0); bool steer_ok = (racesteerlaststeer-0.05); double skid = (car->_skid[0] + car->_skid[1] + car->_skid[2] + car->_skid[3]) / 2; @@ -1543,7 +1543,7 @@ double Driver::calcSteer( double targetAngle, int rl ) if (fabs(nextangle) > fabs(speedangle)) { // steer into the skid - double sa = MAX(-0.3, MIN(0.3, speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, speedangle/3)); //double anglediff = (sa - angle) * (0.3 + fabs(angle)/6); double anglediff = (speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += (float) (anglediff*SkidSteer); @@ -1647,7 +1647,7 @@ float Driver::correctSteering( float avoidsteer, float racesteer ) return avoidsteer; float steer = avoidsteer; - float accel = MIN(0.0f, car->_accel_x); + //float accel = MIN(0.0f, car->_accel_x); double speed = 50.0; //MAX(50.0, currentspeed); double changelimit = MIN(raceline->correctLimit(avoidsteer, racesteer), (((120.0-currentspeed)/6000) * (0.1 + fabs(rldata->mInverse/4)))) * SmoothSteer; @@ -2023,7 +2023,7 @@ vec2f Driver::getTargetPoint(bool use_lookahead, double targetoffset) // all the BT code below is for steering into pits only. s.x = (seg->vertex[TR_SL].x + seg->vertex[TR_SR].x)/2; s.y = (seg->vertex[TR_SL].y + seg->vertex[TR_SR].y)/2; - double dx, dy; + //double dx, dy; vec2f t, rt; if ( seg->type == TR_STR) { @@ -2059,9 +2059,9 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool if (!o) return false; #if 1 - int segid = car->_trkPos.seg->id; + //int segid = car->_trkPos.seg->id; tCarElt *ocar = o->getCarPtr(); - int osegid = ocar->_trkPos.seg->id; + //int osegid = ocar->_trkPos.seg->id; double otry_factor = (lenient ? (0.2 + MAX(0.0, 1.0 - ((simtime-frontavoidtime)/7.0)) * 0.8) : 1.0); double overtakecaution = MAX(0.0, rldata->overtakecaution + (outside ? MIN(0.0, car->_accel_x/8) : 0.0)) - driver_aggression/2; double orInv=0.0, oAspeed=0.0; @@ -2166,7 +2166,7 @@ bool Driver::canOvertake( Opponent *o, double *mincatchdist, bool outside, bool float Driver::getOffset() { int i, avoidmovt = 0; - double catchdist, mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; + double /*catchdist,*/ mincatchdist = MAX(100.0, car->_speed_x * 5), mindist = -1000.0; Opponent *o = NULL; double lane2left = rldata->lane * car->_trkPos.seg->width; double lane2right = car->_trkPos.seg->width-lane2left; @@ -2179,7 +2179,7 @@ float Driver::getOffset() // Increment speed dependent. //double incspeed = MIN(40.0, MAX(30.0, currentspeed)); //double incfactor = (MAX_INC_FACTOR*0.5 - MIN(incspeed/10, MAX_INC_FACTOR*0.5-0.5)) * 60 * IncFactor; - double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; + //double incspeed = MIN(60.0, MAX(40.0, currentspeed)) - 10.0; //double incfactor = (MAX_INC_FACTOR - MIN(fabs(incspeed)/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; double incfactor = (MAX_INC_FACTOR - MIN(40.0/MAX_INC_FACTOR, (MAX_INC_FACTOR - 1.0f))) * (10.0f + MAX(0.0, (CA-1.9)*10)) * IncFactor; @@ -2204,7 +2204,7 @@ float Driver::getOffset() double moffset = car->_trkPos.toMiddle; - double origoffset = moffset; + //double origoffset = moffset; double Width = car->_trkPos.seg->width; #if 1 @@ -2235,8 +2235,8 @@ float Driver::getOffset() { // reduce amount we deviate from the raceline according to how long we've been avoiding, and also // how fast we're going. - double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; - double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; + //double dspeed = MAX(0.0, rldata->speed - currentspeed) * 4; + //double pspeed = MAX(1.0, 60.0 - (currentspeed - (30.0 + MAX(0.0, car->_accel_x) + dspeed))) / 10; // instead of toMiddle just aiming at where the car currently is, we move it in the direction // the car's travelling ... but less so if the speedangle is different from the car's angle. @@ -2524,13 +2524,13 @@ fprintf(stderr,"%s -> %s CANCEL 1 (%.1f > %.1f || %.1f < %.1f || %.3f > %.3f)\n" tCarElt *ocar = o->getCarPtr(); // Compute the width around the middle which we can use for overtaking. - float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; + //float w = ocar->_trkPos.seg->width/WIDTHDIV-BORDER_OVERTAKE_MARGIN; // Compute the opponents distance to the middle. - float otm = ocar->_trkPos.toMiddle; + //float otm = ocar->_trkPos.toMiddle; // Define the with of the middle range. - float wm = ocar->_trkPos.seg->width*CENTERDIV; + //float wm = ocar->_trkPos.seg->width*CENTERDIV; float sidedist = fabs(car->_trkPos.toMiddle-ocar->_trkPos.toMiddle); - double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); + //double sdist = (rInverse > 0.0 ? (-sidedist - 3.0) : (sidedist - 3.0)); //int avoidingside = (otm > wm && myoffset > -w) ? TR_RGT : ((otm < -wm && myoffset < w) ? TR_LFT : TR_STR); int avoidingside = (car->_trkPos.toLeft > ocar->_trkPos.toLeft ? TR_LFT : TR_RGT); @@ -2878,7 +2878,7 @@ fprintf(stderr,"%s BEHIND %s (%d %d %d %d)\n",car->_name,ocar->_name,((o->getSta double factor = 0.25;//(fabs(car->_trkPos.toMiddle) < car->_trkPos.seg->width/2 + 2.0 ? 0.25 : 1.0); if (fabs(myoffset) > fabs(rldata->offset)) { - double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; + //double inc = OVERTAKE_OFFSET_INC * MIN(lftinc, rgtinc) * factor; if (myoffset < rldata->offset && myoffset < 2.0) myoffset += (float) (MIN(rldata->offset-myoffset, OVERTAKE_OFFSET_INC * rgtinc/3 * factor)); else if (myoffset > rldata->offset && myoffset > 2.0) @@ -3060,7 +3060,7 @@ void Driver::update(tSituation *s) for (int i=0; igetNOpponents(); i++) { - int idx = opponent[i].getIndex(); + //int idx = opponent[i].getIndex(); if (opponent[i].getTeam() != TEAM_FRIEND) continue; if (opponent[i].getCarPtr() == car) continue; if (opponent[i].getCarPtr()->_state > RM_CAR_STATE_PIT) @@ -3449,7 +3449,7 @@ void Driver::initWheelPos() { for (int i=0; i<4; i++) { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rh = 0.0; rh = GfParmGetNum(car->_carHandle,WheelSect[i],PRM_RIDEHEIGHT,(char *)NULL, 0.10f); wheelz[i] = (-rh / 1.0 + car->info.wheel[i].wheelRadius) - 0.01; @@ -3458,7 +3458,7 @@ void Driver::initWheelPos() void Driver::initCa() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float rearwingarea = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGAREA, (char*) NULL, 0.0f); float rearwingangle = GfParmGetNum(car->_carHandle, SECT_REARWING, PRM_WINGANGLE, (char*) NULL, 0.0f); float wingca = 1.23f*rearwingarea*sin(rearwingangle); @@ -3486,7 +3486,7 @@ void Driver::initCw() // Init the friction coefficient of the the tires. void Driver::initTireMu() { - char *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; + char const *WheelSect[4] = {SECT_FRNTRGTWHEEL, SECT_FRNTLFTWHEEL, SECT_REARRGTWHEEL, SECT_REARLFTWHEEL}; float tm = FLT_MAX; int i; @@ -3616,7 +3616,7 @@ float Driver::filterABS(float brake) { if (car->_speed_x < ABS_MINSPEED) return brake; float origbrake = brake; - float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); + //float rearskid = MAX(0.0f, MAX(car->_skid[2], car->_skid[3]) - MAX(car->_skid[0], car->_skid[1])); int i; float slip = 0.0f; for (i = 0; i < 4; i++) { diff --git a/src/drivers/usr_trb1/opponent.cpp b/src/drivers/usr_trb1/opponent.cpp index 2a08b2c11..9d722f35e 100644 --- a/src/drivers/usr_trb1/opponent.cpp +++ b/src/drivers/usr_trb1/opponent.cpp @@ -214,15 +214,15 @@ fprintf(stderr," FRONTSLOW\n"); double max = MAX(lane, MAX(mycar->_trkPos.seg->width-mycar->_dimension_y/2, driver->getNextLeft())); double min = MIN(lane, MIN(mycar->_dimension_y/2, driver->getNextLeft())); //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(driver->getNextLeft()-mycar->_trkPos.toLeft) * (t_impact*deltamult)))) - driver->getAngle(); - double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); + //double mleft = MIN(max, MAX(min, (mycar->_trkPos.toLeft+(t_impact*driver->getSpeedAngle())) + driver->getAngle())); max = MAX(nextleft, car->_trkPos.seg->width-car->_dimension_y/2); min = MIN(nextleft, car->_dimension_y/2); //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(nextleft-car->_trkPos.toLeft) * (t_impact*deltamult)))) - angle; - double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); + //double oleft = MIN(max, MAX(min, (car->_trkPos.toLeft+(t_impact*speedangle)) + angle)); //double sepdist = fabs(mleft - oleft); double sepdist = fabs(car->_trkPos.toLeft - mycar->_trkPos.toLeft) + driver->getAngle()*2; - int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); + //int diverging = 0; //(sepdist > (fabs(getWidth()/2.0f) + mycar->_dimension_y/3.0f) + 0.3); //t_impact = MIN(mspeed/7, t_impact); @@ -234,7 +234,7 @@ fprintf(stderr," FRONTSLOW\n"); float cardist = car->_trkPos.toMiddle - mycar->_trkPos.toMiddle; sidedist = cardist; cardist = sepdist - fabs(getWidth()/2.0f) - mycar->_dimension_y/2.0f; - double deduction = t_impact / MAX(1.0, distance); + //double deduction = t_impact / MAX(1.0, distance); if (cardist < SIDE_MARGIN) { if (DebugMsg & debug_brake) fprintf(stderr,"FRONTCOLLIDE %s cardist=%.3f sepdist=%.3f\n",car->_name,cardist,sepdist); @@ -394,7 +394,7 @@ fprintf(stderr," FRONTFAST\n"); if (team == TEAM_FRIEND && car->_dammage-1000 < mycar->_dammage) state |= OPP_FRONT_FOLLOW; - double dSpeed = mspeed;//driver->getSpeed(); + //double dSpeed = mspeed;//driver->getSpeed(); //if (distance < 20.0 - (getSpeed()-driver->getSpeed())*4) if (distance < 20.0 - (ospeed-mspeed)*4) state |= OPP_FRONT; @@ -527,15 +527,15 @@ int Opponent::polyOverlap( tPosd *op, tPosd *dp ) int Opponent::testCollision(Driver *driver, double impact, double sizefactor, vec2f *targ ) { tCarElt *mycar = driver->getCarPtr(); - int collide = 0, i, j; - double nSlices = MAX(1.0, (impact * deltamult)); + int /*collide = 0,*/ i/*, j*/; + //double nSlices = MAX(1.0, (impact * deltamult)); tCarElt *dcar = driver->getCarPtr(); double o_speedX = car->_speed_X;// + (cardata->getSpeedDeltaX()) * (impact * deltamult) / 2; double o_speedY = car->_speed_Y;// + (cardata->getSpeedDeltaY()) * (impact * deltamult) / 2; double d_speedX = dcar->_speed_X;// + driver->getSpeedDeltaX() * (impact * deltamult) / 2; double d_speedY = dcar->_speed_Y;// + driver->getSpeedDeltaY() * (impact * deltamult) / 2; - tPosd o_cur[4], d_cur[4], o_curp[4], d_curp[4], o_new[4], d_new[4], o_new2[4], d_new2[4]; + tPosd o_cur[4], d_cur[4], /*o_curp[4], d_curp[4],*/ o_new[4], d_new[4], o_new2[4], d_new2[4]; // set up car current positions for (i=0; i<4; i++) @@ -558,8 +558,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve else { // position driver's car according to velocity angle - double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); - double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); + //double d_newPos_x = dcar->pub.DynGC.pos.x + (d_speedX*impact); + //double d_newPos_y = dcar->pub.DynGC.pos.y + (d_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -572,8 +572,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve #if 1 { // position opponent car according to velocity angle - double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); - double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); + //double o_newPos_x = car->pub.DynGC.pos.x + (o_speedX*impact); + //double o_newPos_y = car->pub.DynGC.pos.y + (o_speedY*impact); // correct corner positions for (i=0; i<4; i++) @@ -698,8 +698,8 @@ int Opponent::testCollision(Driver *driver, double impact, double sizefactor, ve double ti = MAX(0.001, impact) + 0.1; tPosd *o_old1 = cardata->getCorner1(); tPosd *d_old1 = driver->getCorner1(); - tPosd *o_old2 = cardata->getCorner2(); - tPosd *d_old2 = driver->getCorner2(); + //tPosd *o_old2 = cardata->getCorner2(); + //tPosd *d_old2 = driver->getCorner2(); for (i=0; i<4; i++) { diff --git a/src/drivers/usr_trb1/raceline.cpp b/src/drivers/usr_trb1/raceline.cpp index a8e3dead3..2aa674890 100644 --- a/src/drivers/usr_trb1/raceline.cpp +++ b/src/drivers/usr_trb1/raceline.cpp @@ -32,7 +32,7 @@ // Structures and Statics //////////////////////////////////////////////////////////////////////////// -static SRaceLine SRL[5] = { 0 }; +static SRaceLine SRL[5] = { { 0 } }; static int SRLinit = 0; //////////////////////////////////////////////////////////////////////////// @@ -45,8 +45,8 @@ static int SRLinit = 0; //static const int Iterations = 100; // Number of smoothing operations static const double SecurityR = 100.0; // Security radius -static double SideDistExt = 2.0; // Security distance wrt outside -static double SideDistInt = 1.0; // Security distance wrt inside +//static double SideDistExt = 2.0; // Security distance wrt outside +//static double SideDistInt = 1.0; // Security distance wrt inside ///////////////////////////////////////////////////////////////////////////// // Some utility macros and functions @@ -865,7 +865,7 @@ void LRaceLine::StepInterpolate(int iMin, int iMax, int Step, int rl) } } -static void ClosestPointOnLineFromPoint( +/*static void ClosestPointOnLineFromPoint( vec2f *lp1, vec2f *lp2, vec2f *p, vec2f *r ) { @@ -880,7 +880,7 @@ static void ClosestPointOnLineFromPoint( r->x = lp1->x + ratio * vx; r->y = lp1->y + ratio * vy; -} +}*/ static double PointDist(vec2f *p1, vec2f *p2) { @@ -1077,8 +1077,8 @@ void LRaceLine::ComputeSpeed(int rl) } int nnext = (i + 5) % Divs; - int next = (i + 1) % Divs; - int prev = (i - 1 + Divs) % Divs; + //int next = (i + 1) % Divs; + //int prev = (i - 1 + Divs) % Divs; double rInverse = SRL[rl].tRInverse[i]; double rI = fabs(rInverse); @@ -1437,8 +1437,8 @@ void LRaceLine::GetRLSteerPoint( vec2f *rt, double *offset, double time ) dist *= car->_trkPos.seg->radius; int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time); { @@ -1476,7 +1476,7 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl int maxcount = int(lookahead / DivLength + 1); int count = 0; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = 0.0;//car->_trkPos.toStart; #if 0 @@ -1487,8 +1487,8 @@ void LRaceLine::GetSteerPoint( double lookahead, vec2f *rt, double offset, doubl #endif int next = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); dist = 0.0; - double txLast = car->_pos_X; - double tyLast = car->_pos_Y; + //double txLast = car->_pos_X; + //double tyLast = car->_pos_Y; double Time = deltaTime*3 + MAX(0.0, time/2); double carspeed = Mag(car->_speed_X, car->_speed_Y); double offlane = (offset > -90 ? ((track->width/2) - offset) / track->width : SRL[SRLidx].tLane[next]); @@ -1587,8 +1587,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (famI > 0.0) { double toMid = car->_trkPos.toMiddle + data->speedangle * 20; - double toLeft = car->_trkPos.toLeft - data->speedangle * 20; - double toRight = car->_trkPos.toRight + data->speedangle * 20; + //double toLeft = car->_trkPos.toLeft - data->speedangle * 20; + //double toRight = car->_trkPos.toRight + data->speedangle * 20; double modfactor = (car->_speed_x / data->avspeed); modfactor *= modfactor; @@ -1612,12 +1612,12 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) //if (data->collision) // timefactor *= 1.0 + MAX(0.0, (5.0-data->collision) / 5.0); double Time = timefactor; // + CornerAccel/80; - double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; - double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; + //double X4 = car->_pos_X + car->_speed_X * 0.5 / 2; + //double Y4 = car->_pos_Y + car->_speed_Y * 0.5 / 2; double X = car->_pos_X + car->_speed_X * Time / 2; double Y = car->_pos_Y + car->_speed_Y * Time / 2; - double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; - double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; + //double Xk = car->_pos_X + car->_speed_X * 0.1 / 2; + //double Yk = car->_pos_Y + car->_speed_Y * 0.1 / 2; data->lookahead = 0.0f; data->aInverse = SRL[LINE_MID].tRInverse[Index]; double divcount = 1.0; @@ -1647,7 +1647,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (data->followdist <= 5.0) { - int snext = SNext; + //int snext = SNext; //Next = (Next + int((car->_dimension_x + (5.0 - data->followdist)*1.2) / DivLength)) % Divs; SNext = (Next + int((car->_dimension_x + (5.0 - data->followdist)*6) / DivLength)) % Divs; if (car->_accel_x > 0.0 && data->followdist <= 2.0) @@ -1741,7 +1741,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->offset = laneoffset; //fprintf(stderr,"GetRLData: offset=%.2f Next=%d lane=%.4f Width=%.2f\n",laneoffset,Next,tLane[Next],Width); - double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); + //double sa = (data->angle > 0.0 ? MIN(data->angle, data->angle+data->speedangle/2) : MAX(data->angle, data->angle+data->speedangle/2)); //CalcAvoidSpeed( Next, data, sa ); #if 1 @@ -1826,7 +1826,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) vec2f target; double carspeed = Mag(car->_speed_X, car->_speed_Y); double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; // an idea to implement soon... //if (car->_accel_x < 0.0) @@ -1846,7 +1846,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); k1999steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -1856,8 +1856,8 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) double dx = SRL[SRLidx].tx[NextNext] - SRL[SRLidx].tx[Prev]; double dy = SRL[SRLidx].ty[NextNext] - SRL[SRLidx].ty[Prev]; - double vx = car->_speed_X; - double vy = car->_speed_Y; + //double vx = car->_speed_X; + //double vy = car->_speed_Y; double dirx = cos(car->_yaw); double diry = sin(car->_yaw); double SinAngleError = dx * diry - dy * dirx; @@ -1951,7 +1951,7 @@ void LRaceLine::GetRaceLineData(tSituation *s, LRaceLineData *pdata) data->NSsteer = lastNksteer = k1999steer; int Prev = (KIndex + Divs - 1) % Divs; - int PrevPrev = (KIndex + Divs - 5) % Divs; + //int PrevPrev = (KIndex + Divs - 5) % Divs; int NextNext = (KNext + 1) % Divs; // @@ -2103,7 +2103,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) double steertime = MIN(MaxSteerTime, MinSteerTime + MAX(0.0, carspeed-20.0)/30.0); if (data->followdist < 5.0) steertime = MIN(MaxSteerTime*1.1, steertime * 1.0 + (5.0 - data->followdist)/20); - double lane2left = track->width * SRL[SRLidx].tLane[Next]; + //double lane2left = track->width * SRL[SRLidx].tLane[Next]; double amI = MIN(0.05, MAX(-0.05, SRL[SRLidx].tRInverse[Next])); double famI = fabs(amI); @@ -2151,7 +2151,7 @@ double LRaceLine::getAvoidSteer(double offset, LRaceLineData *data) if (fabs(nextangle) > fabs(data->speedangle)) { - double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); + //double sa = MAX(-0.3, MIN(0.3, data->speedangle/3)); double anglediff = (data->speedangle - nextangle) * (0.1 + fabs(nextangle)/6); steer += anglediff * (1.0 + MAX(1.0, 1.0 - car->_accel_x/5)); } @@ -2175,7 +2175,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) double offlane = ((track->width/2) - offset) / track->width; double off2lft = track->width/2 - offset; double off2rgt = track->width - off2lft; - tTrackSeg *seg = car->_trkPos.seg; + //tTrackSeg *seg = car->_trkPos.seg; int SegId = car->_trkPos.seg->id; double dist = car->_trkPos.toStart; if (dist < 0) @@ -2183,7 +2183,7 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) if (car->_trkPos.seg->type != TR_STR) dist *= car->_trkPos.seg->radius; int Index = SRL[SRLidx].tSegIndex[SegId] + int(dist / SRL[SRLidx].tElemLength[SegId]); - double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); + //double laneoffset = SRL[SRLidx].Width/2 - (SRL[SRLidx].tLane[Index] * SRL[SRLidx].Width); double rInv = SRL[LINE_MID].tRInverse[Index]; Index = This; #if 1 @@ -2216,8 +2216,8 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) next = (Index + 1) % Divs; txNext = offlane * SRL[SRLidx].txRight[next] + (1 - offlane) * SRL[SRLidx].txLeft[next]; tyNext = offlane * SRL[SRLidx].tyRight[next] + (1 - offlane) * SRL[SRLidx].tyLeft[next]; - double dx = txNext - car->_pos_X; - double dy = tyNext - car->_pos_Y; + //double dx = txNext - car->_pos_X; + //double dy = tyNext - car->_pos_Y; if ((txNext - txIndex) * (X - txNext) + (tyNext - tyIndex) * (Y - tyNext) < -0.1) { @@ -2248,12 +2248,12 @@ void LRaceLine::GetPoint( double offset, vec2f *rt, double *mInverse ) int LRaceLine::findNextCorner( double *nextCRinverse ) { - tTrackSeg *seg = car->_trkPos.seg;; + //tTrackSeg *seg = car->_trkPos.seg;; int prefer_side = ((SRL[SRLidx].tRInverse[Next] > 0.001) ? TR_LFT : ((SRL[SRLidx].tRInverse[Next]) < -0.001 ? TR_RGT : TR_STR)); - double curlane = car->_trkPos.toLeft / track->width; - int next = (Next+5) % Divs, i = 1, div; - double distance = 0.0; + //double curlane = car->_trkPos.toLeft / track->width; + int /*next = (Next+5) % Divs,*/ i = 1, div; + //double distance = 0.0; double CR = SRL[SRLidx].tRInverse[Next]; if (car->_speed_x < 5.0) @@ -2297,7 +2297,7 @@ int LRaceLine::findNextCorner( double *nextCRinverse ) double LRaceLine::correctLimit(double avoidsteer, double racesteer) { - double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; + //double nlane2left = SRL[SRLidx].tLane[Next] * SRL[SRLidx].Width; double tbump = BumpCaution;//GetModD( tBump, This ) * 4; // correct would take us in the opposite direction to a corner - correct less! @@ -2307,7 +2307,7 @@ double LRaceLine::correctLimit(double avoidsteer, double racesteer) // correct would take us in the opposite direction to a corner - correct less (but not as much as above) int nnext = (Next + (int) (car->_speed_x/3)) % Divs; - double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; + //double nnlane2left = SRL[SRLidx].tLane[nnext] * SRL[SRLidx].Width; if ((SRL[SRLidx].tRInverse[nnext] > 0.001 && avoidsteer > racesteer) || (SRL[SRLidx].tRInverse[nnext] < -0.001 && avoidsteer < racesteer)) return MAX(0.3, MIN(1.0, 1.0 - fabs(SRL[SRLidx].tRInverse[nnext]) * 40.0 - tbump)); diff --git a/src/drivers/usr_trb1/strategy.cpp b/src/drivers/usr_trb1/strategy.cpp index 418534681..3c17db795 100644 --- a/src/drivers/usr_trb1/strategy.cpp +++ b/src/drivers/usr_trb1/strategy.cpp @@ -35,12 +35,12 @@ SimpleStrategy::SimpleStrategy() : m_lastfuel(0.0f), m_expectedfuelperlap(0.0f), m_fuelsum(0.0f), + PitDamage(5000), pit_damage(0), min_damage(0), is_pitting(0), remainlaps(0), pit_reason(0), - PitDamage(5000), track(NULL) { #ifdef SPEED_DREAMS @@ -178,7 +178,7 @@ bool SimpleStrategy::needPitstop(tCarElt* car, tSituation *s, Opponents *opp) { // Do we need to refuel? int remainlaps = car->_remainingLaps;//-car->_lapsBehindLeader; - int this_pit_dammage = PitDamage; + //int this_pit_dammage = PitDamage; if (!car->_pit) return false; diff --git a/src/drivers/usr_trb1/strategy.h b/src/drivers/usr_trb1/strategy.h index f66e98aea..b1def3ede 100644 --- a/src/drivers/usr_trb1/strategy.h +++ b/src/drivers/usr_trb1/strategy.h @@ -37,7 +37,9 @@ #include #include +#ifndef SPEED_DREAMS #define SPEED_DREAMS +#endif //SPEED_DREAMS #ifdef SPEED_DREAMS #include diff --git a/src/drivers/usr_trb1/usr_trb1.cpp b/src/drivers/usr_trb1/usr_trb1.cpp index 43ca40705..9c6a97f9f 100644 --- a/src/drivers/usr_trb1/usr_trb1.cpp +++ b/src/drivers/usr_trb1/usr_trb1.cpp @@ -47,14 +47,14 @@ static void endRace(int index, tCarElt *car, tSituation *s); // TORCS-NG-Interface static const int BUFSIZE = 256; // Buffer size for path/filename buffers static const int MAXNBBOTS = 20; // Set value to max capacity you want to use here -static char* defaultBotName[MAXNBBOTS] = { +static char const* defaultBotName[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", "driver 16", "driver 17", "driver 18", "driver 19", "driver 20" }; -static char* defaultBotDesc[MAXNBBOTS] = { +static char const* defaultBotDesc[MAXNBBOTS] = { "driver 1", "driver 2", "driver 3", "driver 4", "driver 5", "driver 6", "driver 7", "driver 8", "driver 9", "driver 10", "driver 11", "driver 12", "driver 13", "driver 14", "driver 15", @@ -96,7 +96,7 @@ void SetUpUSR_trb1() // Set robots's name and xml file pathname static void setRobotName(const char *name) { - char* c; + //char* c; strcpy(nameBuffer, name); snprintf(pathBuffer, BUFSIZE, "drivers/%s/%s.xml", name, name); diff --git a/src/libs/client/credits.cpp b/src/libs/client/credits.cpp index b4519d64c..bafc85b43 100644 --- a/src/libs/client/credits.cpp +++ b/src/libs/client/credits.cpp @@ -82,7 +82,7 @@ static void* creditsPageCreate(int startChapterIndex, int startLineIndex) { static const unsigned maxBufSize = 256; static char buf[maxBufSize]; - static char bufColInd[4]; + //static char bufColInd[4]; static float colNameColor[4] = {1.0, 0.0, 1.0, 1.0}; diff --git a/src/libs/robottools/rtteammanager.cpp b/src/libs/robottools/rtteammanager.cpp index a0d3a6e21..33eca2ca0 100644 --- a/src/libs/robottools/rtteammanager.cpp +++ b/src/libs/robottools/rtteammanager.cpp @@ -762,7 +762,7 @@ void RtTeamManagerDump(int DumpMode) GfOut("TM: TeamPit %d:\n",TeamPit->Count); // GfOut("TM: Header : V%d.%d (%d Bytes): x%p\n",TeamPit->Header.MajorVersion,TeamPit->Header.MinorVersion,TeamPit->Header.Size,TeamPit); GfOut("TM: Name : %s\n",TeamPit->Name); - GfOut("TM: PitState : %d\n",TeamPit->PitState); + GfOut("TM: PitState : %p\n",TeamPit->PitState); GfOut("TM: Pit : x%p\n",TeamPit->Pit); // GfOut("TM: Teammates : x%p\n",TeamPit->Teammates); // GfOut("TM: Next : x%p\n",TeamPit->Next); diff --git a/src/libs/robottools/rttimeanalysis.cpp b/src/libs/robottools/rttimeanalysis.cpp index 22d1e2b72..956de2dc1 100644 --- a/src/libs/robottools/rttimeanalysis.cpp +++ b/src/libs/robottools/rttimeanalysis.cpp @@ -54,6 +54,7 @@ bool RtInitTimer() return true; } #endif + return false; } // Get timer frequency [Hz] diff --git a/src/libs/tgfclient/guiscrollist.cpp b/src/libs/tgfclient/guiscrollist.cpp index 1a3fbab2e..2d5d19ad1 100644 --- a/src/libs/tgfclient/guiscrollist.cpp +++ b/src/libs/tgfclient/guiscrollist.cpp @@ -483,7 +483,7 @@ void GfuiScrollListShowElement(void *scr, int Id, int index) { tGfuiObject *object; tGfuiScrollList *scrollist; - tGfuiListElement *elt; + //tGfuiListElement *elt; int oldFirstVisible; object = gfuiGetObject(scr, Id); diff --git a/src/libs/tgfclient/screen.cpp b/src/libs/tgfclient/screen.cpp index 09cbdeaee..e0d5f66f5 100644 --- a/src/libs/tgfclient/screen.cpp +++ b/src/libs/tgfclient/screen.cpp @@ -969,7 +969,7 @@ GfScrMenuInit(void *precMenu) -int GfuiGlutExtensionSupported(char *str) +int GfuiGlutExtensionSupported(char const *str) { return glutExtensionSupported(str); } diff --git a/src/libs/tgfclient/tgfclient.h b/src/libs/tgfclient/tgfclient.h index 863e51339..932c2d523 100644 --- a/src/libs/tgfclient/tgfclient.h +++ b/src/libs/tgfclient/tgfclient.h @@ -303,7 +303,7 @@ extern void GfctrlMouseInitCenter(void); extern tCtrlRef *GfctrlGetRefByName(const char *name); extern const char *GfctrlGetNameByRef(int type, int index); -extern int GfuiGlutExtensionSupported(char *str); +extern int GfuiGlutExtensionSupported(char const *str); #endif /* __TGFCLIENT__H__ */ diff --git a/src/modules/simu/simuv3/SimulationOptions.cpp b/src/modules/simu/simuv3/SimulationOptions.cpp index 00af53e16..7c7c247a8 100644 --- a/src/modules/simu/simuv3/SimulationOptions.cpp +++ b/src/modules/simu/simuv3/SimulationOptions.cpp @@ -76,14 +76,14 @@ void SimulationOptions::LoadFromFile(void* handle) { } void SimulationOptions::SetFloatFromGfParm(void* handle, const char* name) { - float v; + float v = 0.0f; option_list.Get(name, v); v = GfParmGetNum (handle, SECT_SIMU_SETTINGS, name, (char*) NULL, v); option_list.Set(name, v); } void SimulationOptions::SetBoolFromGfParm(void* handle, const char* name) { - bool v; + bool v = false; option_list.Get(name, v); const char* s = GfParmGetStr (handle, SECT_SIMU_SETTINGS, name, "none"); v = StrToBool (s, v); diff --git a/src/modules/simu/simuv3/car.cpp b/src/modules/simu/simuv3/car.cpp index 22e829259..bf9c761ac 100644 --- a/src/modules/simu/simuv3/car.cpp +++ b/src/modules/simu/simuv3/car.cpp @@ -580,9 +580,9 @@ SimCarUpdateCornerPos(tCar *car) void SimTelemetryOut(tCar *car) { - int i; - tdble Fzf, Fzr; + //int i; #if 0 + tdble Fzf, Fzr; printf("-----------------------------\nCar: %d %s ---\n", car->carElt->index, car->carElt->_name); printf("Seg: %d (%s) Ts:%f Tr:%f\n", car->trkPos.seg->id, car->trkPos.seg->name, car->trkPos.toStart, car->trkPos.toRight); @@ -632,7 +632,9 @@ SimCarUpdate(tCar *car, tSituation * /* s */) void SimCarUpdate2(tCar *car, tSituation * /* s */) { +#if 0 static int cnt = 10; +#endif //0 if (SimTelemetry == car->carElt->index) SimTelemetryOut(car); #if 0 cnt--; diff --git a/src/tools/trackgen/track.cpp b/src/tools/trackgen/track.cpp index 8d5195661..a5965d8a2 100644 --- a/src/tools/trackgen/track.cpp +++ b/src/tools/trackgen/track.cpp @@ -204,7 +204,7 @@ InitScene(tTrack *Track, void *TrackHandle, int bump) int i, j; tTrackSeg *seg; - tTrackSeg *lastSeg; + tTrackSeg *lastSeg = NULL; tTrackSeg *mseg; int nbvert; tdble width, wi2; @@ -244,7 +244,7 @@ InitScene(tTrack *Track, void *TrackHandle, int bump) int hasBorder; tDispElt *theCurDispElt = NULL; char sname[256]; - float dmax = 0; + //float dmax = 0; #define LG_STEP_MAX 50.0