Переглянути джерело

Silenced some cppcheck warnings

Thomas Buck 10 роки тому
джерело
коміт
232c18bb0e
6 змінених файлів з 37 додано та 39 видалено
  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 Переглянути файл

@@ -203,6 +203,10 @@ $(BUILDDIR)/$(NAME) : $(OBJS)
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 210
 CHECK_INC=-Iinclude
207 211
 #CHECK_INC+=$(GL_DEFS) $(AUDIO_DEFS)
208 212
 #ifeq ($(UNAME),Darwin)
@@ -214,14 +218,20 @@ CHECK_INC=-Iinclude
214 218
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/tr1
215 219
 #CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/backward
216 220
 #endif
221
+CHECK_NORMAL=--enable=information,warning,performance,portability
222
+CHECK_FULL=--enable=all
223
+CHECK_CONFIG=--check-config
217 224
 
218 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 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 Переглянути файл

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

+ 0
- 4
src/GLString.cpp Переглянути файл

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

+ 12
- 13
src/OpenRaider.cpp Переглянути файл

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

+ 3
- 3
src/Quaternion.cpp Переглянути файл

@@ -171,7 +171,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
171 171
      *
172 172
      *******************************************************************/
173 173
 
174
-    vec_t result, scaleA, scaleB, theta, sinTheta;
174
+    vec_t result, scaleA, scaleB;
175 175
     Quaternion i;
176 176
 
177 177
 
@@ -207,8 +207,8 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time) {
207 207
     if (1 - result > 0.1f) {
208 208
         // Get the angle between the 2 quaternions, and then
209 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 213
         // Calculate the scale for qA and qB, according to
214 214
         // the angle and it's sine value

+ 8
- 13
src/SDLSystem.cpp Переглянути файл

@@ -16,6 +16,7 @@
16 16
 
17 17
 #include <SDL/SDL_opengl.h>
18 18
 
19
+#include <MatMath.h>
19 20
 #include <SDLSystem.h>
20 21
 
21 22
 unsigned int *gWidth = 0x0;
@@ -131,7 +132,7 @@ void SDLSystem::resize(unsigned int width, unsigned int height) {
131 132
     // gluPerspective is deprecated!
132 133
     // gluPerspective(m_fovY, aspect, m_clipNear, m_clipFar);
133 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 136
     GLfloat fW = fH * aspect;
136 137
     glFrustum(-fW, fW, -fH, fH, m_clipNear, m_clipFar);
137 138
 
@@ -393,9 +394,10 @@ void SDLSystem::shutdown(int i) {
393 394
 }
394 395
 
395 396
 void SDLSystem::toggleFullscreen() {
397
+    int width = m_width;
398
+    int height = m_height;
396 399
     if (mWindow) {
397 400
         mFullscreen = !mFullscreen;
398
-        SDL_ShowCursor(SDL_DISABLE);
399 401
 
400 402
         // SDL_WM_ToggleFullScreen does not work on all platforms
401 403
         // eg. Mac OS X
@@ -409,26 +411,19 @@ void SDLSystem::toggleFullscreen() {
409 411
         // Now you can see something when switching to Fullscreen,
410 412
         // but it's full of graphical glitches...? I don't know...
411 413
         // -- xythobuz 2013-12-31
412
-        int width = m_width,
413
-            height = m_height;
414
+
414 415
         if (mFullscreen) {
415
-            m_old_width = m_width;
416
-            m_old_height = m_height;
417 416
             SDL_Rect **dimensions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
418 417
             if (dimensions == NULL) {
419 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 421
                 //! \fixme Don't just use first available resolution...
424 422
                 width = dimensions[0]->w;
425 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 427
         resize(width, height);
433 428
     }
434 429
 }

Завантаження…
Відмінити
Зберегти