Просмотр исходного кода

Fixed some minor warnings found by cppcheck

Darryl Gough 12 лет назад
Родитель
Сommit
ac21fb83df

+ 1 - 2
gameplay/src/AIStateMachine.cpp

@@ -71,10 +71,9 @@ AIState* AIStateMachine::getState(const char* id) const
 {
     GP_ASSERT(id);
 
-    AIState* state;
     for (std::list<AIState*>::const_iterator itr = _states.begin(); itr != _states.end(); ++itr)
     {
-        state = (*itr);
+        AIState* state = (*itr);
 
         if (strcmp(id, state->getId()) == 0)
             return state;

+ 1 - 2
gameplay/src/Animation.cpp

@@ -298,11 +298,10 @@ AnimationClip* Animation::findClip(const char* id) const
 {
     if (_clips)
     {
-        AnimationClip* clip = NULL;
         size_t clipCount = _clips->size();
         for (size_t i = 0; i < clipCount; i++)
         {
-            clip = _clips->at(i);
+            AnimationClip* clip = _clips->at(i);
             GP_ASSERT(clip);
             if (clip->_id.compare(id) == 0)
             {

+ 1 - 1
gameplay/src/Joystick.cpp

@@ -4,7 +4,7 @@
 namespace gameplay
 {
 
-Joystick::Joystick() : _radius(1.0f), _relative(true), _innerSize(NULL), _outerSize(NULL)
+Joystick::Joystick() : _radius(1.0f), _relative(true), _innerSize(NULL), _outerSize(NULL), _index(0)
 {
 }
 

+ 2 - 4
gameplay/src/ParticleEmitter.cpp

@@ -685,8 +685,6 @@ void ParticleEmitter::setSpriteFrameCoords(unsigned int frameCount, int width, i
     GP_ASSERT(width);
     GP_ASSERT(height);
 
-    int x;
-    int y;
     Rectangle* frameCoords = new Rectangle[frameCount];
     unsigned int cols = _spriteTextureWidth / width;
     unsigned int rows = _spriteTextureHeight / height;
@@ -694,10 +692,10 @@ void ParticleEmitter::setSpriteFrameCoords(unsigned int frameCount, int width, i
     unsigned int n = 0;
     for (unsigned int i = 0; i < rows; ++i)
     {
-        y = i * height;
+        int y = i * height;
         for (unsigned int j = 0; j < cols; ++j)
         {
-            x = j * width;
+            int x = j * width;
             frameCoords[i*cols + j] = Rectangle(x, y, width, height);
             if (++n == frameCount)
             {

+ 1 - 1
gameplay/src/SceneLoader.cpp

@@ -1224,7 +1224,7 @@ void splitURL(const std::string& url, std::string* file, std::string* id)
 }
 
 SceneLoader::SceneNode::SceneNode()
-    : _nodeID(""), _exactMatch(true)
+    : _nodeID(""), _exactMatch(true), _namespace(NULL)
 {
 }
 

+ 0 - 2
gameplay/src/Slider.cpp

@@ -278,8 +278,6 @@ bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 
 bool Slider::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
 {
-    bool eventConsumed = false;
-
     switch (evt)
     {
         case Gamepad::JOYSTICK_EVENT:

+ 1 - 1
gameplay/src/TextBox.cpp

@@ -334,7 +334,7 @@ unsigned int TextBox::drawImages(Form* form, const Rectangle& clip)
         const Rectangle& region = _caretImage->getRegion();
         if (!region.isEmpty())
         {
-            const Theme::UVs uvs = _caretImage->getUVs();
+            const Theme::UVs& uvs = _caretImage->getUVs();
             Vector4 color = _caretImage->getColor();
             color.w *= _opacity;