Explorar el Código

Fixed more cppcheck warnings

Thomas Buck hace 10 años
padre
commit
497f6a692b
Se han modificado 16 ficheros con 142 adiciones y 96 borrados
  1. 17
    4
      Makefile
  2. 4
    4
      include/List.h
  3. 1
    1
      include/Map.h
  4. 1
    1
      include/Quaternion.h
  5. 7
    4
      include/Tree.h
  6. 3
    0
      include/Vector.h
  7. 4
    4
      include/Vector3d.h
  8. 2
    1
      src/Emitter.cpp
  9. 1
    2
      src/MatMath.cpp
  10. 56
    19
      src/Network.cpp
  11. 8
    8
      src/OpenRaider.cpp
  12. 2
    3
      src/Quaternion.cpp
  13. 21
    18
      src/Render.cpp
  14. 3
    19
      src/TombRaider.cpp
  15. 8
    4
      src/Vector3d.cpp
  16. 4
    4
      test/TombRaider.cpp

+ 17
- 4
Makefile Ver fichero

@@ -205,17 +205,30 @@ $(BUILDDIR)/$(NAME) : $(OBJS)
205 205
 
206 206
 #################################################################
207 207
 
208
+CHECK_INC=-Iinclude
209
+#CHECK_INC+=$(GL_DEFS) $(AUDIO_DEFS)
210
+#ifeq ($(UNAME),Darwin)
211
+#SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
212
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include
213
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include/malloc
214
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include/machine
215
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1
216
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/tr1
217
+#CHECK_INC+=-I$(SDK_ROOT)/usr/include/c++/4.2.1/backward
218
+#endif
219
+
208 220
 check:
209
-	cppcheck -Iinclude $(GL_DEFS) $(AUDIO_DEFS) --enable=information .
221
+	cppcheck --quiet $(CHECK_INC) --force \
222
+		--enable=information,warning,performance,portability .
210 223
 
211
-fullCheck:
212
-	cppcheck -Iinclude $(GL_DEFS) $(AUDIO_DEFS) --enable=all --inconclusive --std=posix .
224
+checkFull:
225
+	cppcheck --quiet $(CHECK_INC) --enable=all --std=posix --force .
213 226
 
214 227
 #################################################################
215 228
 
216 229
 clean: clean-small clean-dep clean-doc
217 230
 
218
-clean-small: clean-build clean-test clean-obj 
231
+clean-small: clean-build clean-test clean-obj
219 232
 	@-rm -rf bin/OpenRaider.app
220 233
 	@-rm -rf bin/OpenRaider.dmg
221 234
 	@-rm -rf bin/OpenRaider.zip

+ 4
- 4
include/List.h Ver fichero

@@ -95,7 +95,7 @@ public:
95 95
      * \brief Print this ListNode
96 96
      */
97 97
     void Print() {
98
-        printf("(%i, %p)",  _id, _data);
98
+        printf("(%u, %p)",  _id, _data);
99 99
     }
100 100
 
101 101
 private:
@@ -216,7 +216,7 @@ public:
216 216
             return SearchId(i);
217 217
         } else {
218 218
 #ifdef DEBUG_INDEX_EMPTY_LIST
219
-            printf("List[%i] = NULL\n", i);
219
+            printf("List[%u] = NULL\n", i);
220 220
 #endif
221 221
         }
222 222
         return 0;
@@ -296,7 +296,7 @@ public:
296 296
      */
297 297
     void Print(void (*print_func)(T)) {
298 298
         ListNode<T> *current = _head;
299
-        printf(" [%i] {\n", _num_items);
299
+        printf(" [%u] {\n", _num_items);
300 300
         while (current) {
301 301
             printf("#%i, ", current->Id());
302 302
             if (print_func)
@@ -312,7 +312,7 @@ public:
312 312
      */
313 313
     void Print() {
314 314
         ListNode<T> *current = _head;
315
-        printf("List %i {\n", _num_items);
315
+        printf("List %u {\n", _num_items);
316 316
         while (current) {
317 317
             //current->Print();
318 318
             printf("%i", current->Id());

+ 1
- 1
include/Map.h Ver fichero

@@ -466,7 +466,7 @@ public:
466 466
             return;
467 467
         }
468 468
 
469
-        printf(" [%i] {\n", _num_items);
469
+        printf(" [%u] {\n", _num_items);
470 470
 
471 471
         while (current) {
472 472
             printf("(");

+ 1
- 1
include/Quaternion.h Ver fichero

@@ -97,7 +97,7 @@ class Quaternion
97 97
      * Mongoose - Created
98 98
      ------------------------------------------------------*/
99 99
 
100
-    Quaternion operator =(const Quaternion &q);
100
+    Quaternion &operator =(const Quaternion &q);
101 101
     /*------------------------------------------------------
102 102
      * Pre  :
103 103
      * Post : Asigns Q to this quaternion

+ 7
- 4
include/Tree.h Ver fichero

@@ -456,7 +456,7 @@ public:
456 456
      * \sa Tree::Remove()
457 457
      */
458 458
     bool RemoveByData(Data data) {
459
-        bool error;
459
+        bool error = true;
460 460
         if (_root)
461 461
             Remove(_root->SearchByData(data, &error));
462 462
         return error;
@@ -470,11 +470,11 @@ public:
470 470
      * \sa Tree::Remove()
471 471
      */
472 472
     bool RemoveByKey(Key key) {
473
-        bool error;
473
+        bool error = true;
474 474
         if (_root) {
475 475
 #ifdef OBSOLETE
476 476
             // Mongoose 2002.02.18, To remove duplicates
477
-            erorr = false;
477
+            error = false;
478 478
             while (!error) {
479 479
 #endif
480 480
                 Remove(_root->SearchByKey(key, &error));
@@ -623,7 +623,7 @@ public:
623 623
      * \sa TreeNode::PrintInorderSpecial()
624 624
      */
625 625
     void PrintSpecial(void (*print_func_k)(Key), void (*print_func_d)(Data)) {
626
-        printf("Tree: %i elements {\n", _num_elements);
626
+        printf("Tree: %u elements {\n", _num_elements);
627 627
         if (_root && print_func_k && print_func_d) {
628 628
             printf("Root: ");
629 629
             _root->PrintNodeSpecial(print_func_k, print_func_d);
@@ -954,6 +954,9 @@ private:
954 954
             prev = GetSuccessor(tree);
955 955
         }
956 956
 
957
+        if (!prev)
958
+            return; // Probably a good idea, as there's a check if(prev) later
959
+
957 960
         if (prev->GetLeft())
958 961
         {
959 962
             cur = prev->GetLeft();

+ 3
- 0
include/Vector.h Ver fichero

@@ -44,6 +44,7 @@ public:
44 44
         mReserve = 0;
45 45
         mStart = 0;
46 46
         mEnd = 0;
47
+        mIndex = 0;
47 48
         copy(vector);
48 49
     }
49 50
 
@@ -201,6 +202,8 @@ public:
201 202
         }
202 203
         mStart = vector.begin();
203 204
         mEnd = vector.end();
205
+        mError = vector.Error();
206
+        mIndex = vector.getCurrentIndex();
204 207
         for (i = vector.begin(); i < vector.end(); ++i) {
205 208
             mData[i] = vector[i];
206 209
         }

+ 4
- 4
include/Vector3d.h Ver fichero

@@ -235,7 +235,7 @@ class Vector3d
235 235
      * Mongoose - Created
236 236
      ------------------------------------------------------*/
237 237
 
238
-    void operator =(const Vector3d &v);
238
+    Vector3d &operator =(const Vector3d &v);
239 239
     /*------------------------------------------------------
240 240
      * Pre  :
241 241
      * Post : this = v, values are assigned   =)
@@ -246,7 +246,7 @@ class Vector3d
246 246
      * Mongoose - Created
247 247
      ------------------------------------------------------*/
248 248
 
249
-    void operator +=(const Vector3d &v);
249
+    Vector3d &operator +=(const Vector3d &v);
250 250
     /*------------------------------------------------------
251 251
      * Pre  :
252 252
      * Post : this += v, values are sumed, assigned   =)
@@ -257,7 +257,7 @@ class Vector3d
257 257
      * Mongoose - Created
258 258
      ------------------------------------------------------*/
259 259
 
260
-    void operator -=(const Vector3d &v);
260
+    Vector3d &operator -=(const Vector3d &v);
261 261
     /*------------------------------------------------------
262 262
      * Pre  :
263 263
      * Post : this -= v, values are diffed, assigned   =)
@@ -268,7 +268,7 @@ class Vector3d
268 268
      * Mongoose - Created
269 269
      ------------------------------------------------------*/
270 270
 
271
-    void operator *=(vec_t s);
271
+    Vector3d &operator *=(vec_t s);
272 272
     /*------------------------------------------------------
273 273
      * Pre  :
274 274
      * Post : this *= s, values are scaled, assigned   =)

+ 2
- 1
src/Emitter.cpp Ver fichero

@@ -25,7 +25,8 @@
25 25
 vec_t Emitter::mFrustum[6][4];
26 26
 
27 27
 int Emitter::compareParticleDist(const void *voidA, const void *voidB) {
28
-    Particle *a = (Particle *)voidA, *b = (Particle *)voidB;
28
+    Particle *a = const_cast<Particle *>(static_cast<const Particle *>(voidA));
29
+    Particle *b = const_cast<Particle *>(static_cast<const Particle *>(voidB));
29 30
     float x, y, z, distA, distB;
30 31
 
31 32
     if (!a || !b)

+ 1
- 2
src/MatMath.cpp Ver fichero

@@ -111,7 +111,6 @@ int helIntersectionLineAndPolygon(vec3_t intersect,
111 111
     //  vec3_t normal, a, b;
112 112
     Vector3d a, b, normal, pA, pB;
113 113
     vec_t d, denominator, mu;
114
-    double theta;
115 114
 
116 115
 
117 116
     pA = Vector3d(p1);
@@ -184,7 +183,7 @@ int helIntersectionLineAndPolygon(vec3_t intersect,
184 183
 #else // assume convex polygons here for sure
185 184
     //mtkVectorSubtract(intersect, polygon[0], a);
186 185
     //theta = mtkVectorDotProduct(a, normal);
187
-    theta = Vector3d::dot(b - Vector3d(polygon[0]), normal); // b = intersect
186
+    double theta = Vector3d::dot(b - Vector3d(polygon[0]), normal); // b = intersect
188 187
 
189 188
     if (theta >= 90.0) // Yeah I know
190 189
         return 0;

+ 56
- 19
src/Network.cpp Ver fichero

@@ -166,7 +166,7 @@ void *server_thread(void *v)
166 166
 
167 167
 void Network::setBindHost(char *s)
168 168
 {
169
-    if (!s && !s[0])
169
+    if (!s || !s[0])
170 170
         return;
171 171
 
172 172
     strncpy(mBindHost, s, BIND_HOST_STR_SZ);
@@ -175,7 +175,7 @@ void Network::setBindHost(char *s)
175 175
 
176 176
 void Network::setRemoteHost(char *s)
177 177
 {
178
-    if (!s && !s[0])
178
+    if (!s || !s[0])
179 179
         return;
180 180
 
181 181
     strncpy(mRemoteHost, s, REMOTE_HOST_STR_SZ);
@@ -295,15 +295,33 @@ int Network::runServer()
295 295
     memset(&s_in, 0, sizeof(s_in));
296 296
     s_in.sin_family = AF_INET;
297 297
 #ifdef LOCAL_BCAST
298
-    struct hostent *hostptr;
299
-
300
-    if ((hostptr = gethostbyname(hostid)) == NULL)
301
-    {
302
-        fprintf(stderr, "Server: recv_udp, Invalid host name '%s'\n", hostid);
298
+    // Replace deprecated gethostbyname() with getaddrinfo()
299
+    //struct hostent *hostptr;
300
+    //if ((hostptr = gethostbyname(hostid)) == NULL)
301
+    //{
302
+    //    fprintf(stderr, "Server: recv_udp, Invalid host name '%s'\n", hostid);
303
+    //    return -1;
304
+    //}
305
+    //memcpy((void *)(&s_in.sin_addr), hostptr->h_addr, hostptr->h_length);
306
+    struct addrinfo *result, *res;
307
+    bool found = false;
308
+    int error = getaddrinfo(hostid, NULL, NULL, &result);
309
+    if (error != 0) {
310
+        fprintf(stderr, "Server: %s\n", gai_strerror(error));
311
+        return -1;
312
+    }
313
+    for (res = result; res != NULL; res = res->ai_next) {
314
+        if (res->ss_family == AF_INET) {
315
+            found = true;
316
+            memcpy((void *)&s_in, res->ai_addr, res->ai_addrlen);
317
+            break; // Found something suitable
318
+        }
319
+    }
320
+    freeaddrinfo(result);
321
+    if (!found) {
322
+        fprintf(stderr, "Server: Can't bind to %s\n", hostid);
303 323
         return -1;
304 324
     }
305
-
306
-    memcpy((void *)(&s_in.sin_addr), hostptr->h_addr, hostptr->h_length);
307 325
 #else
308 326
     s_in.sin_addr.s_addr = htonl(INADDR_ANY);
309 327
 #endif
@@ -348,7 +366,7 @@ int Network::runServer()
348 366
         if (mDebug)
349 367
         {
350 368
             printf("=====================================================\n");
351
-            printf("Packet %i\n", packetsRecieved);
369
+            printf("Packet %u\n", packetsRecieved);
352 370
             printf("Server: Recieved packet from %u\n",
353 371
                     f.uid);
354 372
         }
@@ -374,7 +392,7 @@ int Network::runServer()
374 392
                     gClients[i].frameExpected = 0;
375 393
                     ++gNumClients;
376 394
 
377
-                    printf("Server: %u made connection, as client %i\n",
395
+                    printf("Server: %u made connection, as client %u\n",
378 396
                             gClients[i].uid, i);
379 397
                     break;
380 398
                 }
@@ -491,10 +509,10 @@ void Network::runClient()
491 509
     unsigned int fsize, last_frame_sent = 0;
492 510
     int socket_fd, cc, done;
493 511
     struct sockaddr_in dest;
494
-    struct hostent *hostptr;
512
+    struct addrinfo *addr;
495 513
     network_frame_t f;
496 514
     struct timeval timeout;
497
-    fd_set  readfds;
515
+    fd_set readfds;
498 516
     unsigned int packetsSent = 0;
499 517
     unsigned int seq = 0;
500 518
     char timedOut = 1;
@@ -515,10 +533,16 @@ void Network::runClient()
515 533
         exit(0);
516 534
     }
517 535
 
518
-    if ((hostptr = gethostbyname(mRemoteHost)) == NULL)
519
-    {
520
-        fprintf(stderr, "Client: send_udp: invalid host name, %s\n",
521
-                mRemoteHost);
536
+    //if ((hostptr = gethostbyname(mRemoteHost)) == NULL)
537
+    //{
538
+    //    fprintf(stderr, "Client: send_udp: invalid host name, %s\n",
539
+    //            mRemoteHost);
540
+    //    exit(0);
541
+    //}
542
+
543
+    int error = getaddrinfo(mRemoteHost, NULL, NULL, &addr);
544
+    if (error != 0) {
545
+        fprintf(stderr, "Client: %s\n", gai_strerror(error));
522 546
         exit(0);
523 547
     }
524 548
 
@@ -528,7 +552,20 @@ void Network::runClient()
528 552
     int port = getPort();
529 553
     dest.sin_port = htons(port);
530 554
 #ifdef LOCAL_BCAST
531
-    memcpy(hostptr->h_addr, (char *) &dest.sin_addr, hostptr->h_length);
555
+    //memcpy(hostptr->h_addr, (char *) &dest.sin_addr, hostptr->h_length);
556
+    bool found = false;
557
+    for (struct addrinfo *res = addr; res != NULL; res = res->ai_next) {
558
+        if (res->ss_family == AF_INET) {
559
+            found = true;
560
+            memcpy((void *)&dest.sin_addr, res->ai_addr.sin_addr, sizeof(res->ai_addr.sin_addr));
561
+            break; // Found something suitable
562
+        }
563
+    }
564
+    freeaddrinfo(addr);
565
+    if (!found) {
566
+        fprintf(stderr, "Client: Can't connect to %s\n", hostid);
567
+        return;
568
+    }
532 569
 #else
533 570
     if (inet_pton(AF_INET, mRemoteHost, &dest.sin_addr) < 0)
534 571
     {
@@ -549,7 +586,7 @@ void Network::runClient()
549 586
         if (mDebug)
550 587
         {
551 588
             printf("=====================================================\n");
552
-            printf("Packet %i\n", packetsSent);
589
+            printf("Packet %u\n", packetsSent);
553 590
         }
554 591
 
555 592
         // 1. Get packet to send over wire

+ 8
- 8
src/OpenRaider.cpp Ver fichero

@@ -191,7 +191,7 @@ void eventAnimTest(int anim)
191 191
 {
192 192
     if (LARA)
193 193
     {
194
-        SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
194
+        SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
195 195
 
196 196
         if (mdl)
197 197
         {
@@ -252,7 +252,7 @@ void from_network_layer(network_packet_t *p, unsigned int *last_id)
252 252
         p->pitch = LARA->angles[1];
253 253
         p->view_model = LARA->modelId;
254 254
 
255
-        SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
255
+        SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
256 256
 
257 257
         if (mdl)
258 258
         {
@@ -329,7 +329,7 @@ void to_network_layer(network_packet_t p)
329 329
         gPiggyBack.data.pitch = LARA->angles[2];
330 330
         gPiggyBack.data.view_model = LARA->modelId;
331 331
 
332
-        SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
332
+        SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
333 333
 
334 334
         if (mdl)
335 335
         {
@@ -769,7 +769,7 @@ void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
769 769
         case '[':
770 770
             if (LARA)
771 771
             {
772
-                SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
772
+                SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
773 773
 
774 774
                 if (mdl)
775 775
                 {
@@ -782,7 +782,7 @@ void OpenRaider::handleKeyPressEvent(unsigned int key, unsigned int mod)
782 782
         case ']':
783 783
             if (LARA)
784 784
             {
785
-                SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
785
+                SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
786 786
 
787 787
                 if (mdl)
788 788
                 {
@@ -1199,7 +1199,7 @@ void OpenRaider::gameFrame()
1199 1199
         default:
1200 1200
             if (LARA)
1201 1201
             {
1202
-                mdl = (SkeletalModel *)LARA->tmpHook;
1202
+                mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
1203 1203
 
1204 1204
                 if (mdl)
1205 1205
                 {
@@ -3099,7 +3099,7 @@ void OpenRaider::consoleCommand(char *cmd)
3099 3099
     {
3100 3100
         if (LARA)
3101 3101
         {
3102
-            SkeletalModel *smdl = (SkeletalModel *)LARA->tmpHook;
3102
+            SkeletalModel *smdl = static_cast<SkeletalModel *>(LARA->tmpHook);
3103 3103
             skeletal_model_t *mdl = gWorld.getModel(atoi(cmd));
3104 3104
 
3105 3105
             if (smdl)
@@ -3182,7 +3182,7 @@ void OpenRaider::consoleCommand(char *cmd)
3182 3182
     {
3183 3183
         if (atoi(cmd))
3184 3184
         {
3185
-            m_render.clearFlags(Render::fUsePortals);
3185
+            m_render.setFlags(Render::fUsePortals);
3186 3186
         }
3187 3187
         else
3188 3188
         {

+ 2
- 3
src/Quaternion.cpp Ver fichero

@@ -88,14 +88,13 @@ void Quaternion::getMatrix(matrix_t m)
88 88
 }
89 89
 
90 90
 
91
-Quaternion Quaternion::operator =(const Quaternion &q)
91
+Quaternion &Quaternion::operator =(const Quaternion &q)
92 92
 {
93 93
     mW  = q.mW;
94 94
     mX = q.mX;
95 95
     mY = q.mY;
96 96
     mZ = q.mZ;
97
-
98
-    return (*this);
97
+    return *this;
99 98
 }
100 99
 
101 100
 

+ 21
- 18
src/Render.cpp Ver fichero

@@ -112,7 +112,8 @@ int compareStaticModels(const void *voidA, const void *voidB)
112 112
 
113 113
 int compareRoomDist(const void *voidA, const void *voidB)
114 114
 {
115
-    RenderRoom *a = (RenderRoom *)voidA, *b = (RenderRoom *)voidB;
115
+    const RenderRoom *a = static_cast<const RenderRoom *>(voidA);
116
+    const RenderRoom *b = static_cast<const RenderRoom *>(voidB);
116 117
 
117 118
 
118 119
     if (!a || !b || !a->room || !b->room)
@@ -329,6 +330,9 @@ void Render::initEmitter(const char *name, unsigned int size,
329 330
         unsigned int snowTex1, unsigned int snowTex2)
330 331
 {
331 332
 #ifdef USING_EMITTER
333
+    if (mEmitter)
334
+        delete mEmitter; // Public, so avoid possible leak
335
+
332 336
     // Mongoose 2002.01.01, Screwing around with particle emitter test
333 337
     //   note this is backwards b/c load screen is rendered upsidedown
334 338
     //mEmitter = new Emitter(/*name*/"snow", size);
@@ -929,7 +933,7 @@ void Render::Display()
929 933
             // Mongoose 2002.12.24, Some entities have no animation  =p
930 934
             if (e->tmpHook)
931 935
             {
932
-                SkeletalModel *mdl = (SkeletalModel *)e->tmpHook;
936
+                SkeletalModel *mdl = static_cast<SkeletalModel *>(e->tmpHook);
933 937
 
934 938
                 if (mdl->model->animation.empty())
935 939
                     continue;
@@ -964,7 +968,7 @@ void Render::Display()
964 968
             glPushMatrix();
965 969
             glTranslatef(e->pos[0], e->pos[1], e->pos[2]);
966 970
             glRotatef(e->angles[1], 0, 1, 0);
967
-            drawModel((SkeletalModel *)e->tmpHook);
971
+            drawModel(static_cast<SkeletalModel *>(e->tmpHook));
968 972
             glPopMatrix();
969 973
         }
970 974
     }
@@ -1307,24 +1311,24 @@ void Render::drawObjects()
1307 1311
     // Draw lara or other player model ( move to entity rendering method )
1308 1312
     if (mFlags & Render::fViewModel && LARA && LARA->tmpHook)
1309 1313
     {
1310
-        SkeletalModel *mdl = (SkeletalModel *)LARA->tmpHook;
1314
+        SkeletalModel *mdl = static_cast<SkeletalModel *>(LARA->tmpHook);
1311 1315
         int frame = mdl->getAnimation();
1312 1316
 
1313
-
1314
-        // Mongoose 2002.03.22, Test 'idle' aniamtions
1315
-        if (!LARA->moving)
1317
+        if (mdl)
1316 1318
         {
1317
-            frame = mdl->getIdleAnimation();
1318 1319
 
1319
-            // Mongoose 2002.08.15, Stop flickering of idle lara here
1320
-            if (frame == 11)
1320
+            // Mongoose 2002.03.22, Test 'idle' aniamtions
1321
+            if (!LARA->moving)
1321 1322
             {
1322
-                mdl->setFrame(0);
1323
+                frame = mdl->getIdleAnimation();
1324
+
1325
+                // Mongoose 2002.08.15, Stop flickering of idle lara here
1326
+                if (frame == 11)
1327
+                {
1328
+                    mdl->setFrame(0);
1329
+                }
1323 1330
             }
1324
-        }
1325 1331
 
1326
-        if (mdl)
1327
-        {
1328 1332
             animation_frame_t *animation = mdl->model->animation[frame];
1329 1333
 
1330 1334
             if (animation && mdl->getFrame() > (int)animation->frame.size()-1)
@@ -1345,7 +1349,7 @@ void Render::drawObjects()
1345 1349
         glRotated(mCamera->getYaw(), 0, 1, 0);
1346 1350
 #endif
1347 1351
 
1348
-        drawModel((SkeletalModel *)LARA->tmpHook);
1352
+        drawModel(static_cast<SkeletalModel *>(LARA->tmpHook));
1349 1353
         glPopMatrix();
1350 1354
     }
1351 1355
 
@@ -1382,7 +1386,6 @@ void Render::drawModel(SkeletalModel *model)
1382 1386
     bone_frame_t *boneframe2 = 0x0;
1383 1387
     bone_tag_t *tag;
1384 1388
     bone_tag_t *tag2;
1385
-    unsigned int i;
1386 1389
     int bframe, aframe;
1387 1390
     skeletal_model_t *mdl;
1388 1391
 
@@ -1501,7 +1504,7 @@ void Render::drawModel(SkeletalModel *model)
1501 1504
 #ifdef EXPERIMENTAL_NON_ITEM_RENDER
1502 1505
                 drawModel(mModels[mdl->ponytail], 0, 0);
1503 1506
 #else
1504
-                for (i = 0; i < mdl->ponytailNumMeshes; ++i)
1507
+                for (unsigned int i = 0; i < mdl->ponytailNumMeshes; ++i)
1505 1508
                 {
1506 1509
                     glPushMatrix();
1507 1510
 
@@ -1535,7 +1538,7 @@ void Render::drawModel(SkeletalModel *model)
1535 1538
                     }
1536 1539
                 }
1537 1540
 
1538
-                for (i = 0; i < mdl->ponytailNumMeshes; ++i)
1541
+                for (unsigned int i = 0; i < mdl->ponytailNumMeshes; ++i)
1539 1542
                 {
1540 1543
                     glPopMatrix();
1541 1544
                 }

+ 3
- 19
src/TombRaider.cpp Ver fichero

@@ -1500,17 +1500,8 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1500 1500
         _sound_sources =
1501 1501
             (tr2_sound_source_t*) new unsigned char[_num_sound_sources*40];
1502 1502
 
1503
-        if (mEngineVersion == TR_VERSION_4)
1504
-        {
1505
-            // Mongoose 2002.04.04, was 40 sized reads before extra_camera
1506
-            Fread(_sound_sources, sizeof(tr2_sound_source_t),
1507
-                    _num_sound_sources, f);
1508
-        }
1509
-        else
1510
-        {
1511
-            Fread(_sound_sources, sizeof(tr2_sound_source_t),
1512
-                    _num_sound_sources, f);
1513
-        }
1503
+        Fread(_sound_sources, sizeof(tr2_sound_source_t),
1504
+                _num_sound_sources, f);
1514 1505
         //! \fixme endian
1515 1506
     }
1516 1507
 
@@ -1823,14 +1814,7 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1823 1814
     }
1824 1815
     else
1825 1816
     {
1826
-        if (mEngineVersion == TR_VERSION_4)
1827
-        {
1828
-            Fread(mSoundMap, sizeof(short), 370, f);
1829
-        }
1830
-        else
1831
-        {
1832
-            Fread(mSoundMap, sizeof(short), 370, f);
1833
-        }
1817
+        Fread(mSoundMap, sizeof(short), 370, f);
1834 1818
     }
1835 1819
     //! \fixme endian
1836 1820
 

+ 8
- 4
src/Vector3d.cpp Ver fichero

@@ -171,35 +171,39 @@ void Vector3d::zero()
171 171
 }
172 172
 
173 173
 
174
-void Vector3d::operator =(const Vector3d &v)
174
+Vector3d &Vector3d::operator =(const Vector3d &v)
175 175
 {
176 176
     mVec[0] = v.mVec[0];
177 177
     mVec[1] = v.mVec[1];
178 178
     mVec[2] = v.mVec[2];
179
+    return *this;
179 180
 }
180 181
 
181 182
 
182
-void Vector3d::operator +=(const Vector3d &v)
183
+Vector3d &Vector3d::operator +=(const Vector3d &v)
183 184
 {
184 185
     mVec[0] += v.mVec[0];
185 186
     mVec[1] += v.mVec[1];
186 187
     mVec[2] += v.mVec[2];
188
+    return *this;
187 189
 }
188 190
 
189 191
 
190
-void Vector3d::operator -=(const Vector3d &v)
192
+Vector3d &Vector3d::operator -=(const Vector3d &v)
191 193
 {
192 194
     mVec[0] -= v.mVec[0];
193 195
     mVec[1] -= v.mVec[1];
194 196
     mVec[2] -= v.mVec[2];
197
+    return *this;
195 198
 }
196 199
 
197 200
 
198
-void Vector3d::operator *=(vec_t s)
201
+Vector3d &Vector3d::operator *=(vec_t s)
199 202
 {
200 203
     mVec[0] *= s;
201 204
     mVec[1] *= s;
202 205
     mVec[2] *= s;
206
+    return *this;
203 207
 }
204 208
 
205 209
 

+ 4
- 4
test/TombRaider.cpp Ver fichero

@@ -466,7 +466,7 @@ void dump_lara_stuff(char *mapname, TombRaider &tr)
466 466
             j = moveable[i].starting_mesh;
467 467
             n = moveable[i].num_meshes + j;
468 468
 
469
-            fprintf(f, "Lara (%i)\n", i);
469
+            fprintf(f, "Lara (%u)\n", i);
470 470
         }
471 471
         else if (moveable[i].object_id == 30)
472 472
         {
@@ -481,7 +481,7 @@ void dump_lara_stuff(char *mapname, TombRaider &tr)
481 481
             {
482 482
                 case 8: // Joints, ( interconnecting skin/ploys )
483 483
                 case 9:
484
-                    fprintf(f, "TR4 lara joints (%i)\n", i);
484
+                    fprintf(f, "TR4 lara joints (%u)\n", i);
485 485
                     j = moveable[i].starting_mesh;
486 486
                     n = moveable[i].num_meshes + j;
487 487
             }
@@ -489,7 +489,7 @@ void dump_lara_stuff(char *mapname, TombRaider &tr)
489 489
 
490 490
         for (k = j; j < n; ++j)
491 491
         {
492
-            fprintf(f, "\tMesh[%i] = %i\n", (j - k), j);
492
+            fprintf(f, "\tMesh[%i] = %u\n", (j - k), j);
493 493
         }
494 494
     }
495 495
 
@@ -525,7 +525,7 @@ void dump_lara_stuff(char *mapname, TombRaider &tr)
525 525
 
526 526
     if (total)
527 527
     {
528
-        printf("Dumped %ibytes (%.2f MB) of audio samples\n",
528
+        printf("Dumped %ubytes (%.2f MB) of audio samples\n",
529 529
                 total, (float)total/1024000.0);
530 530
     }
531 531
 }

Loading…
Cancelar
Guardar