Browse Source

Silenced some cppcheck warnings

Thomas Buck 11 years ago
parent
commit
232c18bb0e
6 changed files with 37 additions and 39 deletions
  1. 14
    4
      Makefile
  2. 0
    2
      include/SDLSystem.h
  3. 0
    4
      src/GLString.cpp
  4. 12
    13
      src/OpenRaider.cpp
  5. 3
    3
      src/Quaternion.cpp
  6. 8
    13
      src/SDLSystem.cpp

+ 14
- 4
Makefile View File

203
 
203
 
204
 #################################################################
204
 #################################################################
205
 
205
 
206
+CHECK_BIN=cppcheck
207
+CHECK_DIR=.
208
+CHECK_STD=--std=c++11 --std=posix
209
+CHECK_FLAGS=--quiet --force
206
 CHECK_INC=-Iinclude
210
 CHECK_INC=-Iinclude
207
 #CHECK_INC+=$(GL_DEFS) $(AUDIO_DEFS)
211
 #CHECK_INC+=$(GL_DEFS) $(AUDIO_DEFS)
208
 #ifeq ($(UNAME),Darwin)
212
 #ifeq ($(UNAME),Darwin)
214
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/tr1
218
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/tr1
215
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/backward
219
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/backward
216
 #endif
220
 #endif
221
+CHECK_NORMAL=--enable=information,warning,performance,portability
222
+CHECK_FULL=--enable=all
223
+CHECK_CONFIG=--check-config
217
 
224
 
218
 check:
225
 check:
219
-	cppcheck --quiet $(CHECK_INC) --force \
220
-		--enable=information,warning,performance,portability .
226
+	$(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_STD) \
227
+		$(CHECK_NORMAL) $(CHECK_DIR)
221
 
228
 
222
 checkFull:
229
 checkFull:
223
-	cppcheck --quiet $(CHECK_INC) --enable=all --force \
224
-		--std=c++11 --std=posix .
230
+	$(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_STD) \
231
+		$(CHECK_FULL) $(CHECK_DIR)
232
+
233
+checkConfig:
234
+	$(CHECK_BIN) $(CHECK_FLAGS) $(CHECK_INC) $(CHECK_CONFIG) $(CHECK_DIR)
225
 
235
 
226
 #################################################################
236
 #################################################################
227
 
237
 

+ 0
- 2
include/SDLSystem.h View File

117
     void toggleFullscreen();
117
     void toggleFullscreen();
118
 
118
 
119
 protected:
119
 protected:
120
-    int m_old_width;
121
-    int m_old_height;
122
     bool mFirstMouseEvent; //!< Filter first mouse event (SDL bug)
120
     bool mFirstMouseEvent; //!< Filter first mouse event (SDL bug)
123
     bool mFullscreen;      //!< Current Fullscreen/Windowed mode
121
     bool mFullscreen;      //!< Current Fullscreen/Windowed mode
124
 
122
 

+ 0
- 4
src/GLString.cpp View File

85
 void GLString::SetString(unsigned int string, const char *s, ...) {
85
 void GLString::SetString(unsigned int string, const char *s, ...) {
86
     va_list args;
86
     va_list args;
87
     gl_string_t *str;
87
     gl_string_t *str;
88
-    unsigned int len;
89
 
88
 
90
     str = GetString(string);
89
     str = GetString(string);
91
 
90
 
92
     if (s && s[0] && str) {
91
     if (s && s[0] && str) {
93
         str->active = true;
92
         str->active = true;
94
-        len = strlen(s);
95
-        if (len > str->len)
96
-            len = str->len - 1;
97
 
93
 
98
         va_start(args, s);
94
         va_start(args, s);
99
         vsnprintf(str->text, str->len-2, s, args);
95
         vsnprintf(str->text, str->len-2, s, args);

+ 12
- 13
src/OpenRaider.cpp View File

916
 
916
 
917
 void OpenRaider::initSound()
917
 void OpenRaider::initSound()
918
 {
918
 {
919
-    //char filename[128];
920
-    //unsigned int len;
921
-    //int id;
922
-
923
-
924
     if (!(m_flags & OpenRaider_EnableSound) || mSound.init() < 0)
919
     if (!(m_flags & OpenRaider_EnableSound) || mSound.init() < 0)
925
     {
920
     {
926
         print(true, "Disabling sound...\n");
921
         print(true, "Disabling sound...\n");
927
-        m_flags |= OpenRaider_EnableSound;
928
-        m_flags ^= OpenRaider_EnableSound;
922
+        m_flags &= ~OpenRaider_EnableSound;
929
         return;
923
         return;
930
     }
924
     }
931
 
925
 
932
 #ifdef OBSOLETE
926
 #ifdef OBSOLETE
927
+    char filename[128];
928
+    int id;
929
+
933
     printf("Processing external sound files: ");
930
     printf("Processing external sound files: ");
934
 
931
 
935
     // Mongoose 2001.12.31, Use music list from init script
932
     // Mongoose 2001.12.31, Use music list from init script
1828
                     a, animation[a].frame_rate);
1825
                     a, animation[a].frame_rate);
1829
             printf("animation[%i].next_animation = %i\n",
1826
             printf("animation[%i].next_animation = %i\n",
1830
                     a, animation[a].next_animation);
1827
                     a, animation[a].next_animation);
1831
-            printf("animation[%i].frame_offset = %i\n",
1828
+            printf("animation[%i].frame_offset = %u\n",
1832
                     a, animation[a].frame_offset);
1829
                     a, animation[a].frame_offset);
1833
             printf("animation[%i].anim_command = %i\n",
1830
             printf("animation[%i].anim_command = %i\n",
1834
                     a, animation[a].anim_command);
1831
                     a, animation[a].anim_command);
1836
                     a, animation[a].num_anim_commands);
1833
                     a, animation[a].num_anim_commands);
1837
             printf("animation[%i].state_change_offset = %i\n",
1834
             printf("animation[%i].state_change_offset = %i\n",
1838
                     a, animation[a].state_change_offset);
1835
                     a, animation[a].state_change_offset);
1839
-            printf("              frame_offset = %i\n",
1836
+            printf("              frame_offset = %u\n",
1840
                     frame_offset);
1837
                     frame_offset);
1841
         }
1838
         }
1842
 #endif
1839
 #endif
1884
 #ifdef DEBUG
1881
 #ifdef DEBUG
1885
             if (m_flags & OpenRaider_DebugModel)
1882
             if (m_flags & OpenRaider_DebugModel)
1886
             {
1883
             {
1887
-                printf("animation[%i].boneframe[%i] = offset %i, step %i\n",
1884
+                printf("animation[%i].boneframe[%u] = offset %u, step %i\n",
1888
                         a, f, frame_offset, frame_step);
1885
                         a, f, frame_offset, frame_step);
1889
             }
1886
             }
1890
 #endif
1887
 #endif
2017
                 r_tri->texture);
2014
                 r_tri->texture);
2018
 
2015
 
2019
 #ifdef DEBUG_COLOR_TEXTURE_GEN
2016
 #ifdef DEBUG_COLOR_TEXTURE_GEN
2020
-        printf("Color 0x%02x%02x%02x%02x | 0x%08xto texture[%i]?\n",
2017
+        printf("Color 0x%02x%02x%02x%02x | 0x%08xto texture[%u]?\n",
2021
                 color[0], color[1], color[2], color[3], colorI,
2018
                 color[0], color[1], color[2], color[3], colorI,
2022
                 gColorTextureHACK.size());
2019
                 gColorTextureHACK.size());
2023
 #endif
2020
 #endif
2037
 
2034
 
2038
 void OpenRaider::processModel(int index)
2035
 void OpenRaider::processModel(int index)
2039
 {
2036
 {
2040
-    int i, j, count, texture, white;
2037
+    int i, j, count, texture;
2041
     int vertexIndices[6];
2038
     int vertexIndices[6];
2042
     float st[12];
2039
     float st[12];
2043
     float color[4];
2040
     float color[4];
2055
         return;
2052
         return;
2056
     }
2053
     }
2057
 
2054
 
2055
+#ifndef EXPERIMENTAL
2058
     // WHITE texture id
2056
     // WHITE texture id
2059
-    white = 0;
2057
+    int white = 0;
2058
+#endif
2060
 
2059
 
2061
     model_mesh_t *mesh = new model_mesh_t;
2060
     model_mesh_t *mesh = new model_mesh_t;
2062
 
2061
 

+ 3
- 3
src/Quaternion.cpp View File

171
      *
171
      *
172
      *******************************************************************/
172
      *******************************************************************/
173
 
173
 
174
-    vec_t result, scaleA, scaleB, theta, sinTheta;
174
+    vec_t result, scaleA, scaleB;
175
     Quaternion i;
175
     Quaternion i;
176
 
176
 
177
 
177
 
207
     if (1 - result > 0.1f) {
207
     if (1 - result > 0.1f) {
208
         // Get the angle between the 2 quaternions, and then
208
         // Get the angle between the 2 quaternions, and then
209
         // store the sin() of that angle
209
         // store the sin() of that angle
210
-        theta = (float)acos(result);
211
-        sinTheta = (float)sin(theta);
210
+        vec_t theta = (float)acos(result);
211
+        vec_t sinTheta = (float)sin(theta);
212
 
212
 
213
         // Calculate the scale for qA and qB, according to
213
         // Calculate the scale for qA and qB, according to
214
         // the angle and it's sine value
214
         // the angle and it's sine value

+ 8
- 13
src/SDLSystem.cpp View File

16
 
16
 
17
 #include <SDL/SDL_opengl.h>
17
 #include <SDL/SDL_opengl.h>
18
 
18
 
19
+#include <MatMath.h>
19
 #include <SDLSystem.h>
20
 #include <SDLSystem.h>
20
 
21
 
21
 unsigned int *gWidth = 0x0;
22
 unsigned int *gWidth = 0x0;
131
     // gluPerspective is deprecated!
132
     // gluPerspective is deprecated!
132
     // gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
133
     // gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
133
     // fix: http://stackoverflow.com/a/2417756
134
     // fix: http://stackoverflow.com/a/2417756
134
-    GLfloat fH = tanf(m_fovY / 360.0f * 3.14159f) * m_clipNear;
135
+    GLfloat fH = tanf(m_fovY * HEL_PI / 360.0f) * m_clipNear;
135
     GLfloat fW = fH * aspect;
136
     GLfloat fW = fH * aspect;
136
     glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
137
     glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
137
 
138
 
393
 }
394
 }
394
 
395
 
395
 void SDLSystem::toggleFullscreen() {
396
 void SDLSystem::toggleFullscreen() {
397
+    int width = m_width;
398
+    int height = m_height;
396
     if (mWindow) {
399
     if (mWindow) {
397
         mFullscreen = !mFullscreen;
400
         mFullscreen = !mFullscreen;
398
-        SDL_ShowCursor(SDL_DISABLE);
399
 
401
 
400
         // SDL_WM_ToggleFullScreen does not work on all platforms
402
         // SDL_WM_ToggleFullScreen does not work on all platforms
401
         // eg. Mac OS X
403
         // eg. Mac OS X
409
         // Now you can see something when switching to Fullscreen,
411
         // Now you can see something when switching to Fullscreen,
410
         // but it's full of graphical glitches...? I don't know...
412
         // but it's full of graphical glitches...? I don't know...
411
         // -- xythobuz 2013-12-31
413
         // -- xythobuz 2013-12-31
412
-        int width = m_width,
413
-            height = m_height;
414
+
414
         if (mFullscreen) {
415
         if (mFullscreen) {
415
-            m_old_width = m_width;
416
-            m_old_height = m_height;
417
             SDL_Rect **dimensions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
416
             SDL_Rect **dimensions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
418
             if (dimensions == NULL) {
417
             if (dimensions == NULL) {
419
                 printf("Can't enter fullscreen!\n");
418
                 printf("Can't enter fullscreen!\n");
420
-                mFullscreen = !mFullscreen;
421
-            }
422
-            if (dimensions != (SDL_Rect **)-1) {
419
+                mFullscreen = false;
420
+            } else if (dimensions != (SDL_Rect **)-1) {
423
                 //! \fixme Don't just use first available resolution...
421
                 //! \fixme Don't just use first available resolution...
424
                 width = dimensions[0]->w;
422
                 width = dimensions[0]->w;
425
                 height = dimensions[0]->h;
423
                 height = dimensions[0]->h;
426
             }
424
             }
427
         }
425
         }
428
-        if (!mFullscreen) {
429
-            width = m_old_width;
430
-            height = m_old_height;
431
-        }
426
+
432
         resize(width, height);
427
         resize(width, height);
433
     }
428
     }
434
 }
429
 }

Loading…
Cancel
Save