Browse Source

More cppcheck warnings

Thomas Buck 11 years ago
parent
commit
74504d8622

+ 3
- 0
ChangeLog View File

5
 
5
 
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7
 
7
 
8
+	[ 20140202 ]
9
+	* Fixed more cppcheck warnings
10
+
8
 	[ 20140201 ]
11
 	[ 20140201 ]
9
 	* Rewrote Memory Unit Test using greatest
12
 	* Rewrote Memory Unit Test using greatest
10
 	* Used C++ static analysis tool cppcheck and tried to fix
13
 	* Used C++ static analysis tool cppcheck and tried to fix

+ 2
- 1
Makefile View File

222
 		--enable=information,warning,performance,portability .
222
 		--enable=information,warning,performance,portability .
223
 
223
 
224
 checkFull:
224
 checkFull:
225
-	cppcheck --quiet $(CHECK_INC) --enable=all --std=posix --force .
225
+	cppcheck --quiet $(CHECK_INC) --enable=all --force \
226
+		--std=c++11 --std=posix .
226
 
227
 
227
 #################################################################
228
 #################################################################
228
 
229
 

+ 10
- 11
include/Camera.h View File

208
     unsigned int mId;             //!< Unique id
208
     unsigned int mId;             //!< Unique id
209
     Quaternion mQ;                //!< Quaternion for rotation
209
     Quaternion mQ;                //!< Quaternion for rotation
210
     unsigned int mFlags;          //!< For testing with flags
210
     unsigned int mFlags;          //!< For testing with flags
211
-    vec_t mPos[4];               //!< Location in 3 space (aka eye)
212
-    vec_t mTarget[4];            //!< Postition we're looking at
213
-    vec_t mUp[4];                //!< Up vector
214
-    vec_t mSide[4];              //!< Side vector
215
-    vec_t mViewDistance;         //!< Distance from target
216
-    vec_t mTranslateDelta;       //!< Step size to move
217
-    vec_t mRotateDelta;          //!< Radians to rotate Y
218
-    vec_t mTheta;                //!< View angle Y
219
-    vec_t mRotateDelta2;         //!< Radians to rotate Z
220
-    vec_t mTheta2;               //!< View angle Z
221
-    bool mUpdate;                 //!< Check to see if view needs updating
211
+    vec_t mPos[4];                //!< Location in 3 space (aka eye)
212
+    vec_t mTarget[4];             //!< Postition we're looking at
213
+    vec_t mUp[4];                 //!< Up vector
214
+    vec_t mSide[4];               //!< Side vector
215
+    vec_t mViewDistance;          //!< Distance from target
216
+    vec_t mTranslateDelta;        //!< Step size to move
217
+    vec_t mRotateDelta;           //!< Radians to rotate Y
218
+    vec_t mTheta;                 //!< View angle Y
219
+    vec_t mRotateDelta2;          //!< Radians to rotate Z
220
+    vec_t mTheta2;                //!< View angle Z
222
     static unsigned int mCounter; //!< Id system use
221
     static unsigned int mCounter; //!< Id system use
223
 };
222
 };
224
 
223
 

+ 2
- 2
include/List.h View File

298
         ListNode<T> *current = _head;
298
         ListNode<T> *current = _head;
299
         printf(" [%u] {\n", _num_items);
299
         printf(" [%u] {\n", _num_items);
300
         while (current) {
300
         while (current) {
301
-            printf("#%i, ", current->Id());
301
+            printf("#%u, ", current->Id());
302
             if (print_func)
302
             if (print_func)
303
                 (*print_func)(current->Data());
303
                 (*print_func)(current->Data());
304
             current = current->Next();
304
             current = current->Next();
315
         printf("List %u {\n", _num_items);
315
         printf("List %u {\n", _num_items);
316
         while (current) {
316
         while (current) {
317
             //current->Print();
317
             //current->Print();
318
-            printf("%i", current->Id());
318
+            printf("%u", current->Id());
319
             current = current->Next();
319
             current = current->Next();
320
             if (current)
320
             if (current)
321
                 printf(", ");
321
                 printf(", ");

+ 0
- 2
include/OpenRaider.h View File

466
     char *m_homeDir;             /* Current home directory */
466
     char *m_homeDir;             /* Current home directory */
467
 
467
 
468
     Vector<entity_t *> mClients; /* Player entity/clients */
468
     Vector<entity_t *> mClients; /* Player entity/clients */
469
-
470
-    unsigned int mMaxClients;    /* Max number of clients */
471
 };
469
 };
472
 
470
 
473
 #endif
471
 #endif

+ 2
- 0
include/Render.h View File

46
     RenderRoom()
46
     RenderRoom()
47
     {
47
     {
48
         room = 0x0;
48
         room = 0x0;
49
+        dist = 0.0f;
50
+        center[0] = center[1] = center[2] = 0.0f;
49
     }
51
     }
50
 
52
 
51
     ~RenderRoom()
53
     ~RenderRoom()

+ 6
- 6
src/Network.cpp View File

418
                     cip << 16 >> 24, cip << 24 >> 24,
418
                     cip << 16 >> 24, cip << 24 >> 24,
419
                     ntohs(from.sin_port));
419
                     ntohs(from.sin_port));
420
 
420
 
421
-            printf("Server: Datalink layer recieved: packet seq %i\n",
421
+            printf("Server: Datalink layer recieved: packet seq %u\n",
422
                     f.seq);
422
                     f.seq);
423
         }
423
         }
424
 
424
 
455
 #ifdef UNIT_TEST_NETWORK
455
 #ifdef UNIT_TEST_NETWORK
456
         if ((rand() % 10 == 0))
456
         if ((rand() % 10 == 0))
457
         {
457
         {
458
-            printf("Server: Simulating a lost ack %i\n", f.seq);
458
+            printf("Server: Simulating a lost ack %u\n", f.seq);
459
             continue;
459
             continue;
460
         }
460
         }
461
 #endif
461
 #endif
620
         {
620
         {
621
             if (mDebug)
621
             if (mDebug)
622
             {
622
             {
623
-                printf("Client: Sending packet %i\n", f.seq);
623
+                printf("Client: Sending packet %u\n", f.seq);
624
             }
624
             }
625
 
625
 
626
             cc = sendto(socket_fd, &f, sizeof(f), 0,
626
             cc = sendto(socket_fd, &f, sizeof(f), 0,
664
         {
664
         {
665
             if (mDebug)
665
             if (mDebug)
666
             {
666
             {
667
-                printf("Client: Timeout detected on packet %i\n", f.seq);
667
+                printf("Client: Timeout detected on packet %u\n", f.seq);
668
             }
668
             }
669
             timedOut = 1;
669
             timedOut = 1;
670
             continue;
670
             continue;
685
         {
685
         {
686
             if (mDebug)
686
             if (mDebug)
687
             {
687
             {
688
-                printf("Client: Datalink layer recieved: packet seq %i\n", f.seq);
688
+                printf("Client: Datalink layer recieved: packet seq %u\n", f.seq);
689
                 printf("CLIENT> Msg from %u\n", f.uid);
689
                 printf("CLIENT> Msg from %u\n", f.uid);
690
             }
690
             }
691
 
691
 
696
         {
696
         {
697
             if (mDebug)
697
             if (mDebug)
698
             {
698
             {
699
-                printf("Client: Recieved ack %i\n", f.seq);
699
+                printf("Client: Recieved ack %u\n", f.seq);
700
             }
700
             }
701
 
701
 
702
             ++seq;
702
             ++seq;

+ 4
- 0
src/OpenRaider.cpp View File

123
     m_testSFX = -1;
123
     m_testSFX = -1;
124
     mNoClipping = 0;
124
     mNoClipping = 0;
125
 
125
 
126
+    mText = NULL;
127
+    m_flags = 0;
128
+    m_mapName[0] = '\0';
129
+
126
     /*! \todo Replace numbers with enum modes.
130
     /*! \todo Replace numbers with enum modes.
127
      * Only do this when you know the amount of commands + 1 (0 reserved)
131
      * Only do this when you know the amount of commands + 1 (0 reserved)
128
      */
132
      */

+ 13
- 2
src/Render.cpp View File

139
 #endif
139
 #endif
140
     mCamera = 0x0;
140
     mCamera = 0x0;
141
     mSkyMesh = -1;
141
     mSkyMesh = -1;
142
+    mSkyMeshRotation = false;
142
     mMode = Render::modeDisabled;
143
     mMode = Render::modeDisabled;
143
     mLock = 0;
144
     mLock = 0;
144
     mFlags = (Render::fRoomAlpha | Render::fViewModel | Render::fSprites |
145
     mFlags = (Render::fRoomAlpha | Render::fViewModel | Render::fSprites |
148
     mModels.setError(0x0);
149
     mModels.setError(0x0);
149
     mRooms.setError(0x0);
150
     mRooms.setError(0x0);
150
     mRoomRenderList.setError(0x0);
151
     mRoomRenderList.setError(0x0);
152
+
153
+    mNextTextureId = NULL;
154
+    mNumTexturesLoaded = NULL;
155
+
156
+    mWidth = 640;
157
+    mHeight = 480;
151
 }
158
 }
152
 
159
 
153
 
160
 
1306
     vec3_t curPos;
1313
     vec3_t curPos;
1307
 #endif
1314
 #endif
1308
     sprite_seq_t *sprite;
1315
     sprite_seq_t *sprite;
1316
+    int frame;
1309
 
1317
 
1310
 
1318
 
1311
     // Draw lara or other player model ( move to entity rendering method )
1319
     // Draw lara or other player model ( move to entity rendering method )
1312
     if (mFlags & Render::fViewModel && LARA && LARA->tmpHook)
1320
     if (mFlags & Render::fViewModel && LARA && LARA->tmpHook)
1313
     {
1321
     {
1314
         SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
1322
         SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
1315
-        int frame = mdl->getAnimation();
1316
 
1323
 
1317
         if (mdl)
1324
         if (mdl)
1318
         {
1325
         {
1328
                     mdl->setFrame(0);
1335
                     mdl->setFrame(0);
1329
                 }
1336
                 }
1330
             }
1337
             }
1338
+            else
1339
+            {
1340
+                frame = mdl->getAnimation();
1341
+            }
1331
 
1342
 
1332
             animation_frame_t *animation = mdl->model->animation[frame];
1343
             animation_frame_t *animation = mdl->model->animation[frame];
1333
 
1344
 
1401
     if (!animation)
1412
     if (!animation)
1402
     {
1413
     {
1403
 #ifdef DEBUG
1414
 #ifdef DEBUG
1404
-        printf("ERROR: No animation for model[%i].aframe[%i] %i\n",
1415
+        printf("ERROR: No animation for model[%i].aframe[%i] %u\n",
1405
                 mdl->id, aframe, mdl->animation.size());
1416
                 mdl->id, aframe, mdl->animation.size());
1406
 #endif
1417
 #endif
1407
         return;
1418
         return;

+ 3
- 0
src/SkeletalModel.cpp View File

22
     mBoneFrame = 0;
22
     mBoneFrame = 0;
23
     mAnimationFrame = 0;
23
     mAnimationFrame = 0;
24
     mIdleAnimation = 0;
24
     mIdleAnimation = 0;
25
+    time = 0.0f;
26
+    lastTime = 0.0f;
27
+    rate = 0.0f;
25
 }
28
 }
26
 
29
 
27
 
30
 

+ 1
- 0
src/System.cpp View File

53
     m_fovY     = 45.0f;
53
     m_fovY     = 45.0f;
54
 
54
 
55
     mConsoleMode = false;
55
     mConsoleMode = false;
56
+    mCommandMode = 0;
56
 
57
 
57
     printf("[System.Core]\n");
58
     printf("[System.Core]\n");
58
 
59
 

+ 1
- 1
src/Texture.cpp View File

523
         unsigned int width, unsigned int height)
523
         unsigned int width, unsigned int height)
524
 {
524
 {
525
     unsigned char *image;
525
     unsigned char *image;
526
-    int id = -1;
526
+    int id;
527
 
527
 
528
     image = generateColorTexture(rgba, width, height);
528
     image = generateColorTexture(rgba, width, height);
529
     id = loadBuffer(image, width, height, RGBA, 32);
529
     id = loadBuffer(image, width, height, RGBA, 32);

+ 2
- 0
src/TombRaider.cpp View File

103
     mSoundMap = 0x0;
103
     mSoundMap = 0x0;
104
     mSoundDetails = 0x0;
104
     mSoundDetails = 0x0;
105
     mSampleIndices = 0x0;
105
     mSampleIndices = 0x0;
106
+    mSampleIndicesTR5 = 0x0;
106
     mRiffData = 0x0;
107
     mRiffData = 0x0;
107
     mTR4Samples = 0x0;
108
     mTR4Samples = 0x0;
108
     mTR4SamplesSz = 0x0;
109
     mTR4SamplesSz = 0x0;
120
     mRiffAlternateLoaded = false;
121
     mRiffAlternateLoaded = false;
121
     mRoomVertexLightingFactor = 50.0f;
122
     mRoomVertexLightingFactor = 50.0f;
122
     mTexelScale = 256.0f;
123
     mTexelScale = 256.0f;
124
+    mRiffDataSz = 0;
123
 
125
 
124
     reset();
126
     reset();
125
 }
127
 }

+ 6
- 22
src/ViewVolume.cpp View File

32
 
32
 
33
 ViewVolume::ViewVolume()
33
 ViewVolume::ViewVolume()
34
 {
34
 {
35
+    mFrustum[0][0] = mFrustum[0][1] = mFrustum[0][2] = mFrustum[0][3] = 0.0f;
36
+    mFrustum[1][0] = mFrustum[1][1] = mFrustum[1][2] = mFrustum[1][3] = 0.0f;
37
+    mFrustum[2][0] = mFrustum[2][1] = mFrustum[2][2] = mFrustum[2][3] = 0.0f;
38
+    mFrustum[3][0] = mFrustum[3][1] = mFrustum[3][2] = mFrustum[3][3] = 0.0f;
39
+    mFrustum[4][0] = mFrustum[4][1] = mFrustum[4][2] = mFrustum[4][3] = 0.0f;
40
+    mFrustum[5][0] = mFrustum[5][1] = mFrustum[5][2] = mFrustum[5][3] = 0.0f;
35
 }
41
 }
36
 
42
 
37
 
43
 
380
     mFrustum[5][3] /= t;
386
     mFrustum[5][3] /= t;
381
 }
387
 }
382
 
388
 
383
-
384
-////////////////////////////////////////////////////////////
385
-// Unit Test code
386
-////////////////////////////////////////////////////////////
387
-
388
-#ifdef UNIT_TEST_VIEWVOLUME
389
-int runViewVolumeUnitTest(int argc, char *argv[])
390
-{
391
-    return 0;
392
-}
393
-
394
-
395
-int main(int argc, char *argv[])
396
-{
397
-    ViewVolume test;
398
-
399
-
400
-    printf("[ViewVolume class test]\n");
401
-
402
-    return runViewVolumeUnitTest(argc, argv);
403
-}
404
-#endif

+ 8
- 8
src/memory_test.cpp View File

829
 
829
 
830
     printf("Memory usage summary:\n");
830
     printf("Memory usage summary:\n");
831
 
831
 
832
-    printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
832
+    printf(" Tracked program memory    : %li bytes \t(%.2f MB)\n",
833
             MEMORY_USED, (double)MEMORY_USED / 1048576.0);
833
             MEMORY_USED, (double)MEMORY_USED / 1048576.0);
834
-    printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
834
+    printf(" Untracked overhead memory : %li bytes \t(%.2f MB)\n",
835
             MEMORYA_USED, (double)MEMORYA_USED / 1048576.0);
835
             MEMORYA_USED, (double)MEMORYA_USED / 1048576.0);
836
-    printf(" Untracked m-string memory : %lu bytes\n",
836
+    printf(" Untracked m-string memory : %li bytes\n",
837
             MEMORYC_USED);
837
             MEMORYC_USED);
838
 
838
 
839
-    printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
839
+    printf("\n Total accounted memory    : %li bytes \t(%.2f MB)\n",
840
             MEMORY_USED + MEMORYA_USED + MEMORYC_USED,
840
             MEMORY_USED + MEMORYA_USED + MEMORYC_USED,
841
             (double)(MEMORY_USED + MEMORYA_USED + MEMORYC_USED) / 1048576.0);
841
             (double)(MEMORY_USED + MEMORYA_USED + MEMORYC_USED) / 1048576.0);
842
 
842
 
844
 
844
 
845
     printf("Memory max usage summary:\n");
845
     printf("Memory max usage summary:\n");
846
 
846
 
847
-    printf(" Tracked program memory    : %lu bytes \t(%.2f MB)\n",
847
+    printf(" Tracked program memory    : %li bytes \t(%.2f MB)\n",
848
             MAX_MEMORY_USED, (double)MAX_MEMORY_USED / 1048576.0);
848
             MAX_MEMORY_USED, (double)MAX_MEMORY_USED / 1048576.0);
849
-    printf(" Untracked overhead memory : %lu bytes \t(%.2f MB)\n",
849
+    printf(" Untracked overhead memory : %li bytes \t(%.2f MB)\n",
850
             MAX_MEMORYA_USED, (double)MAX_MEMORYA_USED / 1048576.0);
850
             MAX_MEMORYA_USED, (double)MAX_MEMORYA_USED / 1048576.0);
851
-    printf(" Untracked m-string memory : %lu bytes\n",
851
+    printf(" Untracked m-string memory : %li bytes\n",
852
             MAX_MEMORYC_USED);
852
             MAX_MEMORYC_USED);
853
 
853
 
854
-    printf("\n Total accounted memory    : %lu bytes \t(%.2f MB)\n",
854
+    printf("\n Total accounted memory    : %li bytes \t(%.2f MB)\n",
855
             MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED,
855
             MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED,
856
             (double)(MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED) / 1048576.0);
856
             (double)(MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED) / 1048576.0);
857
 
857
 

+ 1
- 1
test/TombRaider.cpp View File

495
 
495
 
496
     fclose(f);
496
     fclose(f);
497
 
497
 
498
-    printf("\nDumping %i audio samples: ", tr.getSoundSamplesCount());
498
+    printf("\nDumping %u audio samples: ", tr.getSoundSamplesCount());
499
 
499
 
500
     for (i = 0, j = 0; i < tr.getSoundSamplesCount(); ++i)
500
     for (i = 0, j = 0; i < tr.getSoundSamplesCount(); ++i)
501
     {
501
     {

Loading…
Cancel
Save