From 7962e5eb13aa443775366350c15931ae02436f4f Mon Sep 17 00:00:00 2001 From: torcs-ng Date: Mon, 10 Feb 2020 00:22:14 +0000 Subject: [PATCH] - Fix some warning on GCC (By Robert) git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6823 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 8c9f14fd2904cf6dd4abc423fc49436421e9cc74 Former-commit-id: a57281eb8159c44840daf39a7e76377e66824d1c --- src/drivers/shadow/src/CarModel.cpp | 12 +++++++----- src/drivers/shadow/src/Driver.cpp | 4 ++-- src/drivers/shadow/src/Driver.h | 2 +- src/drivers/shadow/src/Stuck.cpp | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/drivers/shadow/src/CarModel.cpp b/src/drivers/shadow/src/CarModel.cpp index d87c4453..95dd5c81 100644 --- a/src/drivers/shadow/src/CarModel.cpp +++ b/src/drivers/shadow/src/CarModel.cpp @@ -41,10 +41,13 @@ CarModel::CarModel() MASS(0), FUEL(0), DAMAGE(0), + WIDTH(2), TYRE_MU(0), TYRE_MU_F(0), TYRE_MU_R(0), MU_SCALE(1), + KZ_SCALE(0), + KV_SCALE(1), BRAKE_MU_SCALE(0.95), GRIP_SCALE_F(1), GRIP_SCALE_R(1), @@ -60,9 +63,6 @@ CarModel::CarModel() LF_MIN(0.8), LF_MAX(1.6), LF_K(log((1.0f - LF_MIN) / (LF_MAX - LF_MIN))), - KZ_SCALE(0), - KV_SCALE(1), - WIDTH(2), POS_AZ(0), VEL_AZ(0), F_AXLE_X(1.5), @@ -75,11 +75,11 @@ CarModel::CarModel() R_WING_X(-1.5), TARGET_SLIP(0.175), // for defaults of 30, 0.8, 0.7 MAX_SLIP(0.27), - ENGINE_REV_LIMIT(8500 * 2 * PI / 60), GEAR_CHANGE_REVS(8200 * 2 * PI / 60), - ENGINE_MAX_REVS(10000 * 2 * PI / 60), DIFF_RATIO(1), DIFF_EFF(1), + ENGINE_REV_LIMIT(8500 * 2 * PI / 60), + ENGINE_MAX_REVS(10000 * 2 * PI / 60), HASTYC(false), HASABS(false), HASESP(false), @@ -974,6 +974,7 @@ double CarModel::CalcAcceleration( // account for acceleration available from engine. double Facc = AccForceFromSpeed(avgV); + if( Ftanroad > Facc ) Ftanroad = Facc; @@ -984,6 +985,7 @@ double CarModel::CalcAcceleration( double inner = MX(0, u * u + 2 * acc * dist ); double oldV = v; v = sqrt(inner); + if( fabs(v - oldV) < 0.001 ) break; } diff --git a/src/drivers/shadow/src/Driver.cpp b/src/drivers/shadow/src/Driver.cpp index 6a064bdb..8fd27ca4 100644 --- a/src/drivers/shadow/src/Driver.cpp +++ b/src/drivers/shadow/src/Driver.cpp @@ -234,8 +234,8 @@ void Driver::InitTrack( // to come up with so far. it basically gets the name of the car .acc // file, and strips off the ".acc" part, to get the name of the car. yuk. // - char* path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; - char* key = PRM_CAR; + const char* path = SECT_GROBJECTS "/" LST_RANGES "/" "1"; + const char* key = PRM_CAR; strncpy( m_carName, GfParmGetStr(pCarHandle, path, key, ""), sizeof(m_carName) ); char* p = strrchr(m_carName, '.'); if( p ) diff --git a/src/drivers/shadow/src/Driver.h b/src/drivers/shadow/src/Driver.h index ad1fbc09..065ab924 100644 --- a/src/drivers/shadow/src/Driver.h +++ b/src/drivers/shadow/src/Driver.h @@ -237,7 +237,7 @@ private: clear(); return; } - else if( internalBrk = 0.0 ) + else if( internalBrk == 0.0 ) { internalBrk = MN(-targetAcc * 0.1, 0.5); } diff --git a/src/drivers/shadow/src/Stuck.cpp b/src/drivers/shadow/src/Stuck.cpp index ead644b6..7e523a0d 100644 --- a/src/drivers/shadow/src/Stuck.cpp +++ b/src/drivers/shadow/src/Stuck.cpp @@ -415,7 +415,7 @@ void Stuck::init( const MyTrack& track, const tSituation* s, const tCarElt* me ) // make opponent car cells unavailable. makeOpponentsList( s, me, &_opponents ); - for( int i = 0; i < _opponents.size(); i++ ) + for( size_t i = 0; i < _opponents.size(); i++ ) { const OppInfo& oppInfo = _opponents[i]; const tCarElt* other = oppInfo.car; @@ -1099,7 +1099,7 @@ void Stuck::dumpGrid() const { set pts; - for( int i = 0; i < _plan.size(); i++ ) + for( size_t i = 0; i < _plan.size(); i++ ) { const GridPoint& pt = _plan[i]; pts.insert( pt.x() * 256 + pt.y() );