Bläddra i källkod

More cppcheck warnings

Thomas Buck 10 år sedan
förälder
incheckning
74504d8622
16 ändrade filer med 64 tillägg och 56 borttagningar
  1. 3
    0
      ChangeLog
  2. 2
    1
      Makefile
  3. 10
    11
      include/Camera.h
  4. 2
    2
      include/List.h
  5. 0
    2
      include/OpenRaider.h
  6. 2
    0
      include/Render.h
  7. 6
    6
      src/Network.cpp
  8. 4
    0
      src/OpenRaider.cpp
  9. 13
    2
      src/Render.cpp
  10. 3
    0
      src/SkeletalModel.cpp
  11. 1
    0
      src/System.cpp
  12. 1
    1
      src/Texture.cpp
  13. 2
    0
      src/TombRaider.cpp
  14. 6
    22
      src/ViewVolume.cpp
  15. 8
    8
      src/memory_test.cpp
  16. 1
    1
      test/TombRaider.cpp

+ 3
- 0
ChangeLog Visa fil

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

+ 2
- 1
Makefile Visa fil

@@ -222,7 +222,8 @@ check:
222 222
 		--enable=information,warning,performance,portability .
223 223
 
224 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 Visa fil

@@ -208,17 +208,16 @@ private:
208 208
     unsigned int mId;             //!< Unique id
209 209
     Quaternion mQ;                //!< Quaternion for rotation
210 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 221
     static unsigned int mCounter; //!< Id system use
223 222
 };
224 223
 

+ 2
- 2
include/List.h Visa fil

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

+ 0
- 2
include/OpenRaider.h Visa fil

@@ -466,8 +466,6 @@ class OpenRaider : public SDLSystem
466 466
     char *m_homeDir;             /* Current home directory */
467 467
 
468 468
     Vector<entity_t *> mClients; /* Player entity/clients */
469
-
470
-    unsigned int mMaxClients;    /* Max number of clients */
471 469
 };
472 470
 
473 471
 #endif

+ 2
- 0
include/Render.h Visa fil

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

+ 6
- 6
src/Network.cpp Visa fil

@@ -418,7 +418,7 @@ int Network::runServer()
418 418
                     cip << 16 >> 24, cip << 24 >> 24,
419 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 422
                     f.seq);
423 423
         }
424 424
 
@@ -455,7 +455,7 @@ int Network::runServer()
455 455
 #ifdef UNIT_TEST_NETWORK
456 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 459
             continue;
460 460
         }
461 461
 #endif
@@ -620,7 +620,7 @@ void Network::runClient()
620 620
         {
621 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 626
             cc = sendto(socket_fd, &f, sizeof(f), 0,
@@ -664,7 +664,7 @@ void Network::runClient()
664 664
         {
665 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 669
             timedOut = 1;
670 670
             continue;
@@ -685,7 +685,7 @@ void Network::runClient()
685 685
         {
686 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 689
                 printf("CLIENT> Msg from %u\n", f.uid);
690 690
             }
691 691
 
@@ -696,7 +696,7 @@ void Network::runClient()
696 696
         {
697 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 702
             ++seq;

+ 4
- 0
src/OpenRaider.cpp Visa fil

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

+ 13
- 2
src/Render.cpp Visa fil

@@ -139,6 +139,7 @@ Render::Render()
139 139
 #endif
140 140
     mCamera = 0x0;
141 141
     mSkyMesh = -1;
142
+    mSkyMeshRotation = false;
142 143
     mMode = Render::modeDisabled;
143 144
     mLock = 0;
144 145
     mFlags = (Render::fRoomAlpha | Render::fViewModel | Render::fSprites |
@@ -148,6 +149,12 @@ Render::Render()
148 149
     mModels.setError(0x0);
149 150
     mRooms.setError(0x0);
150 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,13 +1313,13 @@ void Render::drawObjects()
1306 1313
     vec3_t curPos;
1307 1314
 #endif
1308 1315
     sprite_seq_t *sprite;
1316
+    int frame;
1309 1317
 
1310 1318
 
1311 1319
     // Draw lara or other player model ( move to entity rendering method )
1312 1320
     if (mFlags & Render::fViewModel && LARA && LARA->tmpHook)
1313 1321
     {
1314 1322
         SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
1315
-        int frame = mdl->getAnimation();
1316 1323
 
1317 1324
         if (mdl)
1318 1325
         {
@@ -1328,6 +1335,10 @@ void Render::drawObjects()
1328 1335
                     mdl->setFrame(0);
1329 1336
                 }
1330 1337
             }
1338
+            else
1339
+            {
1340
+                frame = mdl->getAnimation();
1341
+            }
1331 1342
 
1332 1343
             animation_frame_t *animation = mdl->model->animation[frame];
1333 1344
 
@@ -1401,7 +1412,7 @@ void Render::drawModel(SkeletalModel *model)
1401 1412
     if (!animation)
1402 1413
     {
1403 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 1416
                 mdl->id, aframe, mdl->animation.size());
1406 1417
 #endif
1407 1418
         return;

+ 3
- 0
src/SkeletalModel.cpp Visa fil

@@ -22,6 +22,9 @@ SkeletalModel::SkeletalModel()
22 22
     mBoneFrame = 0;
23 23
     mAnimationFrame = 0;
24 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 Visa fil

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

+ 1
- 1
src/Texture.cpp Visa fil

@@ -523,7 +523,7 @@ int Texture::loadColorTexture(unsigned char rgba[4],
523 523
         unsigned int width, unsigned int height)
524 524
 {
525 525
     unsigned char *image;
526
-    int id = -1;
526
+    int id;
527 527
 
528 528
     image = generateColorTexture(rgba, width, height);
529 529
     id = loadBuffer(image, width, height, RGBA, 32);

+ 2
- 0
src/TombRaider.cpp Visa fil

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

+ 6
- 22
src/ViewVolume.cpp Visa fil

@@ -32,6 +32,12 @@
32 32
 
33 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,25 +386,3 @@ void ViewVolume::updateFrustum()
380 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 Visa fil

@@ -829,14 +829,14 @@ void display_memory_usage()
829 829
 
830 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 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 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 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 840
             MEMORY_USED + MEMORYA_USED + MEMORYC_USED,
841 841
             (double)(MEMORY_USED + MEMORYA_USED + MEMORYC_USED) / 1048576.0);
842 842
 
@@ -844,14 +844,14 @@ void display_memory_usage()
844 844
 
845 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 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 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 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 855
             MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED,
856 856
             (double)(MAX_MEMORY_USED + MAX_MEMORYA_USED + MAX_MEMORYC_USED) / 1048576.0);
857 857
 

+ 1
- 1
test/TombRaider.cpp Visa fil

@@ -495,7 +495,7 @@ void dump_lara_stuff(char *mapname, TombRaider &tr)
495 495
 
496 496
     fclose(f);
497 497
 
498
-    printf("\nDumping %i audio samples: ", tr.getSoundSamplesCount());
498
+    printf("\nDumping %u audio samples: ", tr.getSoundSamplesCount());
499 499
 
500 500
     for (i = 0, j = 0; i < tr.getSoundSamplesCount(); ++i)
501 501
     {

Laddar…
Avbryt
Spara