fix some cppcheck warnings

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@7945 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 9df8f4ba42386c3137349ca580e4f99d7f59e1fb
Former-commit-id: a0e2d041a1ef12d35e7335a35027e2063389bfe2
This commit is contained in:
iobyte 2022-01-26 01:02:33 +00:00
parent 23c1e38f76
commit ffdc13799e
8 changed files with 25 additions and 21 deletions

View file

@ -25,9 +25,9 @@
#include "OsgBrake.h" #include "OsgBrake.h"
#include "OsgMath.h" #include "OsgMath.h"
void SDBrakes::setCar(tCarElt * car) void SDBrakes::setCar(tCarElt * car_elt)
{ {
this->car = car; this->car = car_elt;
} }
osg::Node *SDBrakes::initBrake(int wheelIndex) osg::Node *SDBrakes::initBrake(int wheelIndex)

View file

@ -30,7 +30,8 @@ private :
osg::ref_ptr<osg::Vec4Array> brake_colors[4]; osg::ref_ptr<osg::Vec4Array> brake_colors[4];
public : public :
void setCar(tCarElt * car); SDBrakes() : car(nullptr) { }
void setCar(tCarElt * car_elt);
osg::Node *initBrake(int wheelIndex); osg::Node *initBrake(int wheelIndex);
void updateBrakes(); void updateBrakes();
}; };

View file

@ -68,8 +68,8 @@ SDCar::SDCar(void) :
steerMovt(0.0), steerMovt(0.0),
car(NULL), car(NULL),
shader(NULL), shader(NULL),
reflectionMapping(NULL) reflectionMapping(NULL),
reflectionMappingMethod(REFLECTIONMAPPING_OFF)
{ {
_cockpit = false; _cockpit = false;
_driver = false; _driver = false;
@ -616,7 +616,7 @@ osg::ref_ptr<osg::Node> SDCar::loadCar(tCarElt *Car, bool tracktype, bool subcat
return this->carEntity; return this->carEntity;
} }
bool SDCar::isCar(tCarElt*c) const bool SDCar::isCar(const tCarElt*c) const
{ {
return c == car; return c == car;
} }
@ -713,7 +713,7 @@ osg::ref_ptr<osg::Node> SDCar::initOcclusionQuad(tCarElt *car)
return root.get(); return root.get();
}*/ }*/
void SDCar::markCarCurrent(tCarElt *Car) void SDCar::markCarCurrent(const tCarElt *Car)
{ {
if(this->car == Car) if(this->car == Car)
{ {
@ -904,7 +904,9 @@ void SDCar::setReflectionMap(osg::ref_ptr<osg::Texture> map)
} }
SDCars::SDCars(void) : SDCars::SDCars(void) :
cars_branch(NULL) cars_branch(nullptr),
shadow_branch(nullptr),
situation(nullptr)
{ {
} }
@ -968,7 +970,7 @@ void SDCars::updateCars(tSituation *s, tCarElt *CurCar, int current, int driver)
} }
} }
void SDCars::markCarCurrent(tCarElt *car) void SDCars::markCarCurrent(const tCarElt *car)
{ {
std::vector<SDCar *>::iterator it; std::vector<SDCar *>::iterator it;

View file

@ -78,7 +78,7 @@ public :
SDCar(void); SDCar(void);
~SDCar(void); ~SDCar(void);
osg::ref_ptr<osg::Node> loadCar(tCarElt *Car, bool tracktype, bool subcat, int carshader); osg::ref_ptr<osg::Node> loadCar(tCarElt *Car, bool tracktype, bool subcat, int carshader);
bool isCar(tCarElt*c) const; bool isCar(const tCarElt*c) const;
bool _cockpit; bool _cockpit;
bool _driver; bool _driver;
@ -96,7 +96,7 @@ public :
tCarElt *getCar() { return car; } tCarElt *getCar() { return car; }
const tCarElt *getCar() const { return car; } const tCarElt *getCar() const { return car; }
void markCarCurrent(tCarElt *Car); void markCarCurrent(const tCarElt *Car);
void updateCar(tSituation *s, tCarElt *CurCar, int current, int driver); void updateCar(tSituation *s, tCarElt *CurCar, int current, int driver);
void updateShadingParameters(const osg::Matrixf &modelview); void updateShadingParameters(const osg::Matrixf &modelview);
}; };
@ -117,7 +117,7 @@ public :
void loadCars(tSituation * pSituation, bool trackType, bool subCat); void loadCars(tSituation * pSituation, bool trackType, bool subCat);
void updateCars(tSituation *s, tCarElt *CurCar, int current, int driver); void updateCars(tSituation *s, tCarElt *CurCar, int current, int driver);
void markCarCurrent(tCarElt*car); void markCarCurrent(const tCarElt*car);
SDCar *getCar(tCarElt*car); SDCar *getCar(tCarElt*car);
void unLoad(); void unLoad();
void updateShadingParameters(const osg::Matrixf &modelview); void updateShadingParameters(const osg::Matrixf &modelview);

View file

@ -29,7 +29,7 @@
osg::ref_ptr<osg::Node> SDCarLight::init( osg::ref_ptr<osg::Node> SDCarLight::init(
CarLightType type, CarLightType car_light_type,
osg::ref_ptr<osg::StateSet> state_set, osg::ref_ptr<osg::StateSet> state_set,
const osg::Vec3d &position, const osg::Vec3d &position,
const osg::Vec3d &normal, const osg::Vec3d &normal,
@ -38,7 +38,7 @@ osg::ref_ptr<osg::Node> SDCarLight::init(
{ {
if (layers < 0) layers = 0; if (layers < 0) layers = 0;
this->type = type; this->type = car_light_type;
osg::ref_ptr<SDLightTransform> transform = new SDLightTransform; osg::ref_ptr<SDLightTransform> transform = new SDLightTransform;
transform->setPosition(position); transform->setPosition(position);

View file

@ -48,13 +48,13 @@ private:
osg::ref_ptr<osg::Node> node; osg::ref_ptr<osg::Node> node;
public: public:
SDCarLight() {} SDCarLight() : type(CAR_LIGHT_TYPE_NONE) {}
~SDCarLight() {} ~SDCarLight() {}
CarLightType get_type() const { return type; } CarLightType get_type() const { return type; }
osg::ref_ptr<osg::Node> init( osg::ref_ptr<osg::Node> init(
CarLightType type, CarLightType car_light_type,
osg::ref_ptr<osg::StateSet> state_set, osg::ref_ptr<osg::StateSet> state_set,
const osg::Vec3d &position, const osg::Vec3d &position,
const osg::Vec3d &normal, const osg::Vec3d &normal,

View file

@ -27,9 +27,9 @@
#include <osgDB/WriteFile> #include <osgDB/WriteFile>
#include <osgDB/FileUtils> #include <osgDB/FileUtils>
osg::ref_ptr<osg::Node> SDWheels::initWheels(tCarElt *car,void *handle) osg::ref_ptr<osg::Node> SDWheels::initWheels(tCarElt *car_elt,void *handle)
{ {
this->car = car; this->car = car_elt;
this->brakes.setCar(car); this->brakes.setCar(car);
@ -166,7 +166,7 @@ osg::ref_ptr<osg::MatrixTransform> SDWheels::initWheel(int wheelIndex, const cha
void SDWheels::updateWheels() void SDWheels::updateWheels()
{ {
int j; int j;
static float maxVel[3] = { 20.0, 40.0, 70.0 }; static const float maxVel[3] = { 20.0, 40.0, 70.0 };
brakes.updateBrakes(); brakes.updateBrakes();

View file

@ -37,10 +37,11 @@ private :
osg::ref_ptr<osg::Switch> wheels_switches[4]; osg::ref_ptr<osg::Switch> wheels_switches[4];
osg::ref_ptr<osg::MatrixTransform> wheels[4]; osg::ref_ptr<osg::MatrixTransform> wheels[4];
SDBrakes brakes; SDBrakes brakes;
osg::ref_ptr<osg::MatrixTransform> initWheel(int wheelIndec, const char *wheel_mod_name); osg::ref_ptr<osg::MatrixTransform> initWheel(int wheelIndex, const char *wheel_mod_name);
public : public :
osg::ref_ptr<osg::Node> initWheels(tCarElt *car,void * handle); SDWheels() : car(nullptr) { }
osg::ref_ptr<osg::Node> initWheels(tCarElt *car_elt,void * handle);
void updateWheels(); void updateWheels();
}; };