Browse Source

No more conversion warnings

Thomas Buck 10 years ago
parent
commit
3fb79ca857
4 changed files with 135 additions and 135 deletions
  1. 26
    26
      src/Matrix.cpp
  2. 21
    21
      src/OpenRaider.cpp
  3. 46
    46
      src/Render.cpp
  4. 42
    42
      src/TombRaider.cpp

+ 26
- 26
src/Matrix.cpp View File

@@ -58,25 +58,25 @@ bool Matrix::getInvert(matrix_t out)
58 58
 
59 59
     r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
60 60
         r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
61
-        r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
61
+        r0[4] = 1.0f, r0[5] = r0[6] = r0[7] = 0.0f,
62 62
 
63 63
         r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
64 64
         r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
65
-        r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
65
+        r1[5] = 1.0f, r1[4] = r1[6] = r1[7] = 0.0f,
66 66
 
67 67
         r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
68 68
         r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
69
-        r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
69
+        r2[6] = 1.0f, r2[4] = r2[5] = r2[7] = 0.0f,
70 70
 
71 71
         r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
72 72
         r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
73
-        r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
73
+        r3[7] = 1.0f, r3[4] = r3[5] = r3[6] = 0.0f;
74 74
 
75 75
     /* choose pivot - or die */
76 76
     if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
77 77
     if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
78 78
     if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
79
-    if (0.0 == r0[0])  return false;
79
+    if (0.0f == r0[0])  return false;
80 80
 
81 81
     /* eliminate first variable     */
82 82
     m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
@@ -84,31 +84,31 @@ bool Matrix::getInvert(matrix_t out)
84 84
     s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
85 85
     s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
86 86
     s = r0[4];
87
-    if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
87
+    if (s != 0.0f) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
88 88
     s = r0[5];
89
-    if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
89
+    if (s != 0.0f) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
90 90
     s = r0[6];
91
-    if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
91
+    if (s != 0.0f) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
92 92
     s = r0[7];
93
-    if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
93
+    if (s != 0.0f) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
94 94
 
95 95
     /* choose pivot - or die */
96 96
     if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
97 97
     if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
98
-    if (0.0 == r1[1])  return false;
98
+    if (0.0f == r1[1])  return false;
99 99
 
100 100
     /* eliminate second variable */
101 101
     m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
102 102
     r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
103 103
     r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
104
-    s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
105
-    s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
106
-    s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
107
-    s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
104
+    s = r1[4]; if (0.0f != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
105
+    s = r1[5]; if (0.0f != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
106
+    s = r1[6]; if (0.0f != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
107
+    s = r1[7]; if (0.0f != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
108 108
 
109 109
     /* choose pivot - or die */
110 110
     if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
111
-    if (0.0 == r2[2])  return false;
111
+    if (0.0f == r2[2])  return false;
112 112
 
113 113
     /* eliminate third variable */
114 114
     m3 = r3[2]/r2[2];
@@ -117,13 +117,13 @@ bool Matrix::getInvert(matrix_t out)
117 117
         r3[7] -= m3 * r2[7];
118 118
 
119 119
     /* last check */
120
-    if (0.0 == r3[3]) return false;
120
+    if (0.0f == r3[3]) return false;
121 121
 
122
-    s = 1.0/r3[3];              /* now back substitute row 3 */
122
+    s = 1.0f/r3[3];              /* now back substitute row 3 */
123 123
     r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
124 124
 
125 125
     m2 = r2[3];                 /* now back substitute row 2 */
126
-    s  = 1.0/r2[2];
126
+    s  = 1.0f/r2[2];
127 127
     r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
128 128
         r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
129 129
     m1 = r1[3];
@@ -134,7 +134,7 @@ bool Matrix::getInvert(matrix_t out)
134 134
         r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
135 135
 
136 136
     m1 = r1[2];                 /* now back substitute row 1 */
137
-    s  = 1.0/r1[1];
137
+    s  = 1.0f/r1[1];
138 138
     r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
139 139
         r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
140 140
     m0 = r0[2];
@@ -142,7 +142,7 @@ bool Matrix::getInvert(matrix_t out)
142 142
         r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
143 143
 
144 144
     m0 = r0[1];                 /* now back substitute row 0 */
145
-    s  = 1.0/r0[0];
145
+    s  = 1.0f/r0[0];
146 146
     r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
147 147
         r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
148 148
 
@@ -306,17 +306,17 @@ void Matrix::rotate(vec_t ax, vec_t ay, vec_t az)
306 306
     matrix_t xmat, ymat, zmat, tmp, tmp2;
307 307
 
308 308
     xmat[ 0]=1;        xmat[ 1]=0;        xmat[ 2]=0;        xmat[ 3]=0;
309
-    xmat[ 4]=0;        xmat[ 5]=cos(ax);  xmat[ 6]=sin(ax);  xmat[ 7]=0;
310
-    xmat[ 8]=0;        xmat[ 9]=-sin(ax); xmat[10]=cos(ax);  xmat[11]=0;
309
+    xmat[ 4]=0;        xmat[ 5]=cosf(ax);  xmat[ 6]=sinf(ax);  xmat[ 7]=0;
310
+    xmat[ 8]=0;        xmat[ 9]=-sinf(ax); xmat[10]=cosf(ax);  xmat[11]=0;
311 311
     xmat[12]=0;        xmat[13]=0;        xmat[14]=0;        xmat[15]=1;
312 312
 
313
-    ymat[ 0]=cos(ay);  ymat[ 1]=0;        ymat[ 2]=-sin(ay); ymat[ 3]=0;
313
+    ymat[ 0]=cosf(ay);  ymat[ 1]=0;        ymat[ 2]=-sinf(ay); ymat[ 3]=0;
314 314
     ymat[ 4]=0;        ymat[ 5]=1;        ymat[ 6]=0;        ymat[ 7]=0;
315
-    ymat[ 8]=sin(ay);  ymat[ 9]=0;        ymat[10]=cos(ay);  ymat[11]=0;
315
+    ymat[ 8]=sinf(ay);  ymat[ 9]=0;        ymat[10]=cosf(ay);  ymat[11]=0;
316 316
     ymat[12]=0;        ymat[13]=0;        ymat[14]=0;        ymat[15]=1;
317 317
 
318
-    zmat[ 0]=cos(az);  zmat[ 1]=sin(az);  zmat[ 2]=0;        zmat[ 3]=0;
319
-    zmat[ 4]=-sin(az); zmat[ 5]=cos(az);  zmat[ 6]=0;        zmat[ 7]=0;
318
+    zmat[ 0]=cosf(az);  zmat[ 1]=sinf(az);  zmat[ 2]=0;        zmat[ 3]=0;
319
+    zmat[ 4]=-sinf(az); zmat[ 5]=cosf(az);  zmat[ 6]=0;        zmat[ 7]=0;
320 320
     zmat[ 8]=0;        zmat[ 9]=0;        zmat[10]=1;        zmat[11]=0;
321 321
     zmat[12]=0;        zmat[13]=0;        zmat[14]=0;        zmat[15]=1;
322 322
 

+ 21
- 21
src/OpenRaider.cpp View File

@@ -634,7 +634,7 @@ void OpenRaider::handleConsoleKeyPressEvent(unsigned int key,unsigned int mod)
634 634
             case '\r':
635 635
             case '\n':
636 636
                 strncpy(lastCmd, buffer, 63);
637
-                lastCmd[0] = i;
637
+                lastCmd[0] = (char)i;
638 638
 
639 639
                 command("[OpenRaider.Console]");
640 640
                 command(buffer);
@@ -648,7 +648,7 @@ void OpenRaider::handleConsoleKeyPressEvent(unsigned int key,unsigned int mod)
648 648
                 if (mod & (SYS_MOD_KEY_RSHIFT | SYS_MOD_KEY_LSHIFT) &&
649 649
                         key > 96 && key < 122)
650 650
                 {
651
-                    buffer[i++] = (key - 32);
651
+                    buffer[i++] = (char)(key - 32);
652 652
                 }
653 653
                 else
654 654
                 {
@@ -658,7 +658,7 @@ void OpenRaider::handleConsoleKeyPressEvent(unsigned int key,unsigned int mod)
658 658
                             key = '_';
659 659
                     }
660 660
 
661
-                    buffer[i++] = key;
661
+                    buffer[i++] = (char)key;
662 662
                 }
663 663
 
664 664
                 buffer[i] = 0;
@@ -1407,12 +1407,12 @@ void OpenRaider::processSprites()
1407 1407
                     r_mesh->sprite[l].pos[2] = item[i].z;
1408 1408
                     r_mesh->sprite[l].texture = sprite->tile + m_texOffset;
1409 1409
 
1410
-                    r_mesh->sprite[l].radius = width2 / 2.0;
1410
+                    r_mesh->sprite[l].radius = width2 / 2.0f;
1411 1411
 
1412
-                    r_mesh->sprite[l].vertex[0].pos[0] = -width2 / 2.0;
1413
-                    r_mesh->sprite[l].vertex[1].pos[0] = -width2 / 2.0;
1414
-                    r_mesh->sprite[l].vertex[2].pos[0] = width2 / 2.0;
1415
-                    r_mesh->sprite[l].vertex[3].pos[0] = width2 / 2.0;
1412
+                    r_mesh->sprite[l].vertex[0].pos[0] = -width2 / 2.0f;
1413
+                    r_mesh->sprite[l].vertex[1].pos[0] = -width2 / 2.0f;
1414
+                    r_mesh->sprite[l].vertex[2].pos[0] = width2 / 2.0f;
1415
+                    r_mesh->sprite[l].vertex[3].pos[0] = width2 / 2.0f;
1416 1416
 
1417 1417
                     r_mesh->sprite[l].vertex[0].pos[1] = 0;
1418 1418
                     r_mesh->sprite[l].vertex[1].pos[1] = -height2;
@@ -1424,17 +1424,17 @@ void OpenRaider::processSprites()
1424 1424
                     r_mesh->sprite[l].vertex[2].pos[2] = 0;
1425 1425
                     r_mesh->sprite[l].vertex[3].pos[2] = 0;
1426 1426
 
1427
-                    r_mesh->sprite[l].texel[3].st[0] = (double)(x+width)/TexelScale;
1428
-                    r_mesh->sprite[l].texel[3].st[1] = (double)(y+height)/TexelScale;
1427
+                    r_mesh->sprite[l].texel[3].st[0] = (vec_t)(x+width)/TexelScale;
1428
+                    r_mesh->sprite[l].texel[3].st[1] = (vec_t)(y+height)/TexelScale;
1429 1429
 
1430
-                    r_mesh->sprite[l].texel[2].st[0] = (double)(x+width)/TexelScale;
1431
-                    r_mesh->sprite[l].texel[2].st[1] = (double)(y)/TexelScale;
1430
+                    r_mesh->sprite[l].texel[2].st[0] = (vec_t)(x+width)/TexelScale;
1431
+                    r_mesh->sprite[l].texel[2].st[1] = (vec_t)(y)/TexelScale;
1432 1432
 
1433
-                    r_mesh->sprite[l].texel[1].st[0] = (double)(x) /TexelScale;
1434
-                    r_mesh->sprite[l].texel[1].st[1] = (double)(y) /TexelScale;
1433
+                    r_mesh->sprite[l].texel[1].st[0] = (vec_t)(x) /TexelScale;
1434
+                    r_mesh->sprite[l].texel[1].st[1] = (vec_t)(y) /TexelScale;
1435 1435
 
1436
-                    r_mesh->sprite[l].texel[0].st[0] = (double)(x) / TexelScale;
1437
-                    r_mesh->sprite[l].texel[0].st[1] = (double)(y+height)/TexelScale;
1436
+                    r_mesh->sprite[l].texel[0].st[0] = (vec_t)(x) / TexelScale;
1437
+                    r_mesh->sprite[l].texel[0].st[1] = (vec_t)(y+height)/TexelScale;
1438 1438
 
1439 1439
                     printf(".");
1440 1440
                     fflush(stdout);
@@ -1964,7 +1964,7 @@ void OpenRaider::processMoveable(int index, int i, int *ent,
1964 1964
                     tag->off[0] = mesh_tree->x;
1965 1965
                     tag->off[1] = mesh_tree->y;
1966 1966
                     tag->off[2] = mesh_tree->z;
1967
-                    tag->flag = mesh_tree->flags;
1967
+                    tag->flag = (char)mesh_tree->flags;
1968 1968
                 }
1969 1969
 
1970 1970
                 // Setup tag rotations
@@ -2957,11 +2957,11 @@ void OpenRaider::consoleCommand(char *cmd)
2957 2957
     }
2958 2958
     else if (rc_command("sensitivity.x", cmd))
2959 2959
     {
2960
-        m_mouseX = atof(cmd);
2960
+        m_mouseX = static_cast<float>(atof(cmd));
2961 2961
     }
2962 2962
     else if (rc_command("sensitivity.y", cmd))
2963 2963
     {
2964
-        m_mouseY = atof(cmd);
2964
+        m_mouseY = static_cast<float>(atof(cmd));
2965 2965
     }
2966 2966
     else if (rc_command("r_pigtails", cmd))
2967 2967
     {
@@ -3543,11 +3543,11 @@ void OpenRaider::handleCommand(char *cmd, unsigned int mode)
3543 3543
         case 3: // [Input.Mouse]
3544 3544
             if (rc_command("SensitivityX", cmd))
3545 3545
             {
3546
-                m_mouseX = atof(cmd);
3546
+                m_mouseX = static_cast<float>(atof(cmd));
3547 3547
             }
3548 3548
             else if (rc_command("SensitivityY", cmd))
3549 3549
             {
3550
-                m_mouseY = atof(cmd);
3550
+                m_mouseY = static_cast<float>(atof(cmd));
3551 3551
             }
3552 3552
             else
3553 3553
             {

+ 46
- 46
src/Render.cpp View File

@@ -44,16 +44,16 @@ extern entity_t *LARA;
44 44
 extern World gWorld;
45 45
 
46 46
 // Colors
47
-const float BLACK[]        = {  0.0,  0.0,  0.0, 1.0 };
48
-const float DIM_WHITE[]    = {  0.5,  0.5,  0.5, 1.0 };
49
-const float WHITE[]        = {  1.0,  1.0,  1.0, 1.0 };
50
-const float RED[]          = {  1.0,  0.0,  0.0, 1.0 };
51
-const float GREEN[]        = {  0.0,  1.0,  0.0, 1.0 };
52
-const float NEXT_PURPLE[]  = {  0.3,  0.3,  0.5, 1.0 };
53
-const float OR_BLUE[]      = {  0.5,  0.7,  1.0, 1.0 };
54
-const float PINK[]         = {  1.0,  0.0,  1.0, 1.0 };
55
-const float YELLOW[]       = {  1.0,  1.0,  0.0, 1.0 };
56
-const float CYAN[]         = {  0.0,  1.0,  1.0, 1.0 };
47
+const float BLACK[]        = {  0.0f,  0.0f,  0.0f, 1.0f };
48
+const float DIM_WHITE[]    = {  0.5f,  0.5f,  0.5f, 1.0f };
49
+const float WHITE[]        = {  1.0f,  1.0f,  1.0f, 1.0f };
50
+const float RED[]          = {  1.0f,  0.0f,  0.0f, 1.0f };
51
+const float GREEN[]        = {  0.0f,  1.0f,  0.0f, 1.0f };
52
+const float NEXT_PURPLE[]  = {  0.3f,  0.3f,  0.5f, 1.0f };
53
+const float OR_BLUE[]      = {  0.5f,  0.7f,  1.0f, 1.0f };
54
+const float PINK[]         = {  1.0f,  0.0f,  1.0f, 1.0f };
55
+const float YELLOW[]       = {  1.0f,  1.0f,  0.0f, 1.0f };
56
+const float CYAN[]         = {  0.0f,  1.0f,  1.0f, 1.0f };
57 57
 
58 58
 ViewVolume gViewVolume; /* View volume for frustum culling */
59 59
 
@@ -377,7 +377,7 @@ void renderTrace(int color, vec3_t start, vec3_t end)
377 377
 {
378 378
     const float widthStart = 10.0f; //5.0f;
379 379
     const float widthEnd = 10.0f;
380
-    float delta = 0.01 + (0.15*rand()/(RAND_MAX+1.0)); // for flicker fx
380
+    float delta = helRandomNum(0.01f, 0.16f); // for flicker fx
381 381
 
382 382
 
383 383
     // Draw two long quads that skrink and fade the they go further out
@@ -386,14 +386,14 @@ void renderTrace(int color, vec3_t start, vec3_t end)
386 386
     switch (color)
387 387
     {
388 388
         case 0:
389
-            glColor3f(0.9 - delta, 0.2, 0.2);
389
+            glColor3f(0.9f - delta, 0.2f, 0.2f);
390 390
             break;
391 391
         case 1:
392
-            glColor3f(0.2, 0.9 - delta, 0.2);
392
+            glColor3f(0.2f, 0.9f - delta, 0.2f);
393 393
             break;
394 394
         case 2:
395 395
         default:
396
-            glColor3f(0.2, 0.2, 0.9 - delta);
396
+            glColor3f(0.2f, 0.2f, 0.9f - delta);
397 397
     }
398 398
 
399 399
     glVertex3f(start[0], start[1], start[2]);
@@ -635,9 +635,9 @@ void Render::setFlags(unsigned int flags)
635 635
     {
636 636
         glEnable(GL_FOG);
637 637
         glFogf(GL_FOG_MODE, GL_EXP2);
638
-        glFogf(GL_FOG_DENSITY, 0.00008);
639
-        glFogf(GL_FOG_START, 30000.0);
640
-        glFogf(GL_FOG_END, 50000.0);
638
+        glFogf(GL_FOG_DENSITY, 0.00008f);
639
+        glFogf(GL_FOG_START, 30000.0f);
640
+        glFogf(GL_FOG_END, 50000.0f);
641 641
         glFogfv(GL_FOG_COLOR, BLACK);
642 642
     }
643 643
 
@@ -710,8 +710,8 @@ void deprecated_gluLookAt(float eyeX, float eyeY, float eyeZ, float lookAtX, flo
710 710
     f[1] = lookAtY - eyeY;
711 711
     f[2] = lookAtZ - eyeZ;
712 712
     float fMag, upMag;
713
-    fMag = sqrt(f[0]*f[0] + f[1]*f[1] + f[2]*f[2]);
714
-    upMag = sqrt(upX*upX + upY*upY + upZ*upZ);
713
+    fMag = sqrtf(f[0]*f[0] + f[1]*f[1] + f[2]*f[2]);
714
+    upMag = sqrtf(upX*upX + upY*upY + upZ*upZ);
715 715
     // normalizing the viewing vector
716 716
     f[0] = f[0]/fMag;
717 717
     f[1] = f[1]/fMag;
@@ -806,17 +806,17 @@ void Render::Display()
806 806
         camPos[1] = curPos[1] - camOffsetH; // UP is lower val
807 807
         camPos[2] = curPos[2];
808 808
 
809
-        camPos[0] -= (1024.0 * sin(yaw));
810
-        camPos[2] -= (1024.0 * cos(yaw));
809
+        camPos[0] -= (1024.0f * sinf(yaw));
810
+        camPos[2] -= (1024.0f * cosf(yaw));
811 811
 
812 812
         sector = gWorld.getSector(index, camPos[0], camPos[2]);
813 813
 
814 814
         // Handle camera out of world
815 815
         if (sector < 0 || gWorld.isWall(index, sector))
816 816
         {
817
-            camPos[0] = curPos[0] + (64.0 * sin(yaw));
818
-            camPos[1] -= 64.0;
819
-            camPos[2] = curPos[2] + (64.0 * cos(yaw));
817
+            camPos[0] = curPos[0] + (64.0f * sinf(yaw));
818
+            camPos[1] -= 64.0f;
819
+            camPos[2] = curPos[2] + (64.0f * cosf(yaw));
820 820
         }
821 821
 
822 822
         mCamera->setPosition(camPos);
@@ -832,7 +832,7 @@ void Render::Display()
832 832
     // Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
833 833
     // gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
834 834
 
835
-    deprecated_gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
835
+    deprecated_gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
836 836
 
837 837
     // Update view volume for vising
838 838
     updateViewVolume();
@@ -852,13 +852,13 @@ void Render::Display()
852 852
 
853 853
             // Center of LARA
854 854
             u[0] = curPos[0];
855
-            u[1] = curPos[1] - 512.0;
855
+            u[1] = curPos[1] - 512.0f;
856 856
             u[2] = curPos[2];
857 857
 
858 858
             // Location LARA is aiming at?  ( Not finished yet )
859
-            v[0] = u[0] + (9000.0 * sin(LARA->angles[1]));
860
-            v[1] = u[1] + (9000.0 * sin(LARA->angles[2]));
861
-            v[2] = u[2] + (9000.0 * cos(LARA->angles[1]));
859
+            v[0] = u[0] + (9000.0f * sinf(LARA->angles[1]));
860
+            v[1] = u[1] + (9000.0f * sinf(LARA->angles[2]));
861
+            v[2] = u[2] + (9000.0f * cosf(LARA->angles[1]));
862 862
 
863 863
             //mtkVectorSubtract(u, v, t);
864 864
             //mtkVectorSubtract(u, curPos, s);
@@ -1212,8 +1212,8 @@ void Render::drawLoadScreen()
1212 1212
         glDisable(GL_LIGHTING);
1213 1213
 
1214 1214
     // Mongoose 2002.01.01, Draw logo/load screen
1215
-    glTranslatef(0.0, 0.0, -2000.0);
1216
-    glRotatef(180.0, 1.0, 0.0, 0.0);
1215
+    glTranslatef(0.0f, 0.0f, -2000.0f);
1216
+    glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
1217 1217
 
1218 1218
     // Mongoose 2002.03.26, Account for particle system not using new binds
1219 1219
     //   by not using them here either
@@ -1223,16 +1223,16 @@ void Render::drawLoadScreen()
1223 1223
         mTexture.bindMultiTexture(1, 3);
1224 1224
 
1225 1225
         glBegin(GL_TRIANGLE_STRIP);
1226
-        mTexture.useMultiTexture(1.0, 1.0, 0.5 - wrap, 1.0);
1226
+        mTexture.useMultiTexture(1.0f, 1.0f, 0.5f - wrap, 1.0f);
1227 1227
         glColor3fv(WHITE);
1228 1228
         glVertex3f(x + w, y + h, z);
1229
-        mTexture.useMultiTexture(0.0, 1.0, 0.0 - wrap, 1.0);
1229
+        mTexture.useMultiTexture(0.0f, 1.0f, 0.0f - wrap, 1.0f);
1230 1230
         glColor3fv(WHITE);
1231 1231
         glVertex3f(x - w, y + h, z);
1232
-        mTexture.useMultiTexture(1.0, 0.0, 0.5 - wrap, 0.5);
1232
+        mTexture.useMultiTexture(1.0f, 0.0f, 0.5f - wrap, 0.5f);
1233 1233
         glColor3fv(WHITE);
1234 1234
         glVertex3f(x + w, y - h, z);
1235
-        mTexture.useMultiTexture(0.0, 0.0, 0.0 - wrap, 0.5);
1235
+        mTexture.useMultiTexture(0.0f, 0.0f, 0.0f - wrap, 0.5f);
1236 1236
         glColor3fv(WHITE);
1237 1237
         glVertex3f(x - w, y - h, z);
1238 1238
         glEnd();
@@ -1241,7 +1241,7 @@ void Render::drawLoadScreen()
1241 1241
         // The Loading Screen sat around for 25s, doing nothing.
1242 1242
         // Incrementing wrap by a much bigger number speeds up the animation
1243 1243
         // thus greatly reducing startup time?! -- xythobuz
1244
-        wrap += 0.05;
1244
+        wrap += 0.075f;
1245 1245
 
1246 1246
         if (wrap > 1.121096f)
1247 1247
             mTexture.disableMultiTexture();
@@ -1435,13 +1435,13 @@ void Render::drawModel(SkeletalModel *model)
1435 1435
 
1436 1436
         if (boneframe->tag.getCurrentIndex() == 0)
1437 1437
         {
1438
-            if (tag->rot[1])
1438
+            if (!equalEpsilon(tag->rot[1], 0.0f)) // was just if (tag->rot[1])
1439 1439
                 glRotatef(tag->rot[1], 0, 1, 0);
1440 1440
 
1441
-            if (tag->rot[0])
1441
+            if (!equalEpsilon(tag->rot[0], 0.0f))
1442 1442
                 glRotatef(tag->rot[0], 1, 0, 0);
1443 1443
 
1444
-            if (tag->rot[2])
1444
+            if (!equalEpsilon(tag->rot[2], 0.0f))
1445 1445
                 glRotatef(tag->rot[2], 0, 0, 1);
1446 1446
         }
1447 1447
         else
@@ -1454,13 +1454,13 @@ void Render::drawModel(SkeletalModel *model)
1454 1454
 
1455 1455
             glTranslatef(tag->off[0], tag->off[1], tag->off[2]);
1456 1456
 
1457
-            if (tag->rot[1])
1457
+            if (!equalEpsilon(tag->rot[1], 0.0f))
1458 1458
                 glRotatef(tag->rot[1], 0, 1, 0);
1459 1459
 
1460
-            if (tag->rot[0])
1460
+            if (!equalEpsilon(tag->rot[0], 0.0f))
1461 1461
                 glRotatef(tag->rot[0], 1, 0, 0);
1462 1462
 
1463
-            if (tag->rot[2])
1463
+            if (!equalEpsilon(tag->rot[2], 0.0f))
1464 1464
                 glRotatef(tag->rot[2], 0, 0, 1);
1465 1465
         }
1466 1466
 
@@ -1495,7 +1495,7 @@ void Render::drawModel(SkeletalModel *model)
1495 1495
                 //   since no vertex welds are implemented yet
1496 1496
                 if (mdl->tr4Overlay == 1)
1497 1497
                 {
1498
-                    glScalef(1.20, 1.20, 1.20);
1498
+                    glScalef(1.20f, 1.20f, 1.20f);
1499 1499
                 }
1500 1500
 
1501 1501
 #ifdef EXPERIMENTAL_NON_ITEM_RENDER
@@ -1507,9 +1507,9 @@ void Render::drawModel(SkeletalModel *model)
1507 1507
 
1508 1508
                     if (i > 0)
1509 1509
                     {
1510
-                        glRotatef(helRandomNum(-8.0, -10.0), 1, 0, 0);
1511
-                        glRotatef(helRandomNum(-5.0, 5.0), 0, 1, 0);
1512
-                        glRotatef(helRandomNum(-5.0, 5.0), 0, 0, 1);
1510
+                        glRotatef(helRandomNum(-8.0f, -10.0f), 1, 0, 0);
1511
+                        glRotatef(helRandomNum(-5.0f, 5.0f), 0, 1, 0);
1512
+                        glRotatef(helRandomNum(-5.0f, 5.0f), 0, 0, 1);
1513 1513
 
1514 1514
                         glTranslatef(0.0, 0.0, mdl->ponyOff);
1515 1515
                     }

+ 42
- 42
src/TombRaider.cpp View File

@@ -1345,7 +1345,7 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1345 1345
             for (j = 0; j < (int)_num_animations; ++j)
1346 1346
             {
1347 1347
                 int fo = _animations[j].frame_offset / 2;
1348
-                _animations[j].frame_size = (_frames[fo + 9] * 2) + 10;
1348
+                _animations[j].frame_size = (unsigned char)(_frames[fo + 9] * 2) + 10;
1349 1349
             }
1350 1350
 
1351 1351
             for (i = 0; i < (int)_num_frames; )
@@ -1556,10 +1556,10 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1556 1556
 
1557 1557
             for (j = 0; j < _num_boxes; ++j)
1558 1558
             {
1559
-                _boxes[j].zmin = tr1box[j].zmin / 1024;
1560
-                _boxes[j].zmax = tr1box[j].zmax / 1024;
1561
-                _boxes[j].xmin = tr1box[j].xmin / 1024;
1562
-                _boxes[j].xmax = tr1box[j].xmax / 1024;
1559
+                _boxes[j].zmin = (unsigned char)(tr1box[j].zmin / 1024);
1560
+                _boxes[j].zmax = (unsigned char)(tr1box[j].zmax / 1024);
1561
+                _boxes[j].xmin = (unsigned char)(tr1box[j].xmin / 1024);
1562
+                _boxes[j].xmax = (unsigned char)(tr1box[j].xmax / 1024);
1563 1563
                 _boxes[j].true_floor = tr1box[j].true_floor;
1564 1564
                 _boxes[j].overlap_index = tr1box[j].overlap_index;
1565 1565
             }
@@ -1738,14 +1738,14 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1738 1738
             {
1739 1739
                 colour_tmp = _palette8[_textile8[i].tile[j]].r & 0x3f;
1740 1740
                 colour_tmp = colour_tmp * 31.0 / 63.0;
1741
-                argb = ((int)colour_tmp) << 10;
1741
+                argb = (unsigned short)(((int)colour_tmp) << 10);
1742 1742
                 colour_tmp = _palette8[_textile8[i].tile[j]].g & 0x3f;
1743 1743
                 colour_tmp = colour_tmp * 31.0 / 63.0;
1744
-                argb |= ((int)colour_tmp) << 5;
1744
+                argb |= (unsigned short)(((int)colour_tmp) << 5);
1745 1745
                 colour_tmp = _palette8[_textile8[i].tile[j]].b & 0x3f;
1746 1746
                 colour_tmp = colour_tmp * 31.0 / 63.0;
1747
-                argb |= ((int)colour_tmp);
1748
-                argb &= 0x7fff;   // ???
1747
+                argb |= (unsigned short)((int)colour_tmp);
1748
+                argb &= 0x7fff; // ???
1749 1749
 
1750 1750
                 if (_textile8[i].tile[j] != 0)
1751 1751
                     argb |= 0x8000;
@@ -2019,7 +2019,7 @@ float TombRaider::adjustTexel(unsigned char texel, char offset)
2019 2019
     else
2020 2020
         texel--;
2021 2021
 
2022
-    return ((float)texel / 255.0);
2022
+    return ((float)texel / 255.0f);
2023 2023
 }
2024 2024
 
2025 2025
 
@@ -2029,7 +2029,7 @@ void TombRaider::computeRotationAngles(unsigned short **frame,
2029 2029
         float *x, float *y, float *z)
2030 2030
 {
2031 2031
     unsigned short itmp, itmp2;
2032
-    double angle;
2032
+    float angle;
2033 2033
 
2034 2034
 
2035 2035
     itmp = (*frame)[(*frame_offset) + (*angle_offset)++];
@@ -2123,8 +2123,8 @@ void TombRaider::computeUV(tr2_object_texture_vert_t *st, float *u, float *v)
2123 2123
     //x += ((char)st->xcoordinate >= 0) ? 1 : -1;
2124 2124
     //y += ((char)st->ycoordinate >= 0) ? 1 : -1;
2125 2125
 
2126
-    *u = (float)x / 255.0;
2127
-    *v = (float)y / 255.0;
2126
+    *u = (float)x / 255.0f;
2127
+    *v = (float)y / 255.0f;
2128 2128
 }
2129 2129
 
2130 2130
 
@@ -2139,12 +2139,12 @@ void TombRaider::getColor(int index, float color[4])
2139 2139
     switch (getEngine())
2140 2140
     {
2141 2141
         case TR_VERSION_1:
2142
-            color[0] = _palette8[index].r / 64.0;
2143
-            color[1] = _palette8[index].g / 64.0;
2144
-            color[2] = _palette8[index].b / 64.0;
2145
-            //color[0] = (_palette8[index].r & 0xfd) / 64.0;
2146
-            //color[1] = (_palette8[index].g & 0xfd) / 64.0;
2147
-            //color[2] = (_palette8[index].b & 0xfd) / 64.0;
2142
+            color[0] = _palette8[index].r / 64.0f;
2143
+            color[1] = _palette8[index].g / 64.0f;
2144
+            color[2] = _palette8[index].b / 64.0f;
2145
+            //color[0] = (_palette8[index].r & 0xfd) / 64.0f;
2146
+            //color[1] = (_palette8[index].g & 0xfd) / 64.0f;
2147
+            //color[2] = (_palette8[index].b & 0xfd) / 64.0f;
2148 2148
             color[3] = 1.0;
2149 2149
             break;
2150 2150
         case TR_VERSION_2:
@@ -2153,9 +2153,9 @@ void TombRaider::getColor(int index, float color[4])
2153 2153
         case TR_VERSION_5:
2154 2154
         case TR_VERSION_UNKNOWN:
2155 2155
         default:
2156
-            color[0] = (float)(_palette16[index] & 0xff) / 256.0;
2157
-            color[1] = (float)((_palette16[index] >> 8) & 0xff) / 256.0;
2158
-            color[2] = (float)((_palette16[index] >> 16) & 0xff) / 256.0;
2156
+            color[0] = (float)(_palette16[index] & 0xff) / 256.0f;
2157
+            color[1] = (float)((_palette16[index] >> 8) & 0xff) / 256.0f;
2158
+            color[2] = (float)((_palette16[index] >> 16) & 0xff) / 256.0f;
2159 2159
             color[3] = 1.0;
2160 2160
     }
2161 2161
 }
@@ -2513,7 +2513,7 @@ void TombRaider::getMeshVertexArrays(unsigned int meshIndex,
2513 2513
                 case TR_VERSION_5:
2514 2514
                 case TR_VERSION_UNKNOWN:
2515 2515
                 default:
2516
-                    colorValue = (1.0 - (colorValue / 8192.0));
2516
+                    colorValue = (1.0f - (colorValue / 8192.0f));
2517 2517
                     break;
2518 2518
             }
2519 2519
 
@@ -2549,21 +2549,21 @@ int TombRaider::getRoomBox(unsigned int roomIndex, unsigned int index,
2549 2549
         case TR_VERSION_3:
2550 2550
         case TR_VERSION_4:
2551 2551
         case TR_VERSION_5:
2552
-            xyzA[0] = (unsigned short)_boxes[index].xmin * 1024.0;
2552
+            xyzA[0] = (unsigned short)_boxes[index].xmin * 1024.0f;
2553 2553
             xyzA[1] = (short)_boxes[index].true_floor;
2554
-            xyzA[2] = (unsigned short)_boxes[index].zmin * 1024.0;
2554
+            xyzA[2] = (unsigned short)_boxes[index].zmin * 1024.0f;
2555 2555
 
2556
-            xyzB[0] = (unsigned short)_boxes[index].xmax * 1024.0;
2556
+            xyzB[0] = (unsigned short)_boxes[index].xmax * 1024.0f;
2557 2557
             xyzB[1] = (short)_boxes[index].true_floor;
2558
-            xyzB[2] = (unsigned short)_boxes[index].zmin * 1024.0;
2558
+            xyzB[2] = (unsigned short)_boxes[index].zmin * 1024.0f;
2559 2559
 
2560
-            xyzC[0] = (unsigned short)_boxes[index].xmax * 1024.0;
2560
+            xyzC[0] = (unsigned short)_boxes[index].xmax * 1024.0f;
2561 2561
             xyzC[1] = (short)_boxes[index].true_floor;
2562
-            xyzC[2] = (unsigned short)_boxes[index].zmax * 1024.0;
2562
+            xyzC[2] = (unsigned short)_boxes[index].zmax * 1024.0f;
2563 2563
 
2564
-            xyzD[0] = (unsigned short)_boxes[index].xmin * 1024.0;
2564
+            xyzD[0] = (unsigned short)_boxes[index].xmin * 1024.0f;
2565 2565
             xyzD[1] = (short)_boxes[index].true_floor;
2566
-            xyzD[2] = (unsigned short)_boxes[index].zmax * 1024.0;
2566
+            xyzD[2] = (unsigned short)_boxes[index].zmax * 1024.0f;
2567 2567
     }
2568 2568
 
2569 2569
     return 0;
@@ -2769,7 +2769,7 @@ int TombRaider::getRoomLight(unsigned int roomIndex, unsigned int index,
2769 2769
             pos[2] = _rooms[roomIndex].lights[index].z;
2770 2770
             pos[3] = 1.0f;
2771 2771
 
2772
-            color[0] = _rooms[roomIndex].lights[index].intensity1 / 409.60;
2772
+            color[0] = _rooms[roomIndex].lights[index].intensity1 / 409.60f;
2773 2773
             color[1] = color[0];
2774 2774
             color[2] = color[0];
2775 2775
             color[3] = 1.0f;
@@ -3309,16 +3309,16 @@ void TombRaider::getRoomSprite(unsigned int roomIndex, unsigned int index,
3309 3309
     height2 = height * scale;
3310 3310
 
3311 3311
     // Quad
3312
-    vertices[0] = -width2 / 2.0;
3312
+    vertices[0] = -width2 / 2.0f;
3313 3313
     vertices[1] = 0;
3314 3314
     vertices[2] = 0;
3315
-    vertices[3] = -width2 / 2.0;
3315
+    vertices[3] = -width2 / 2.0f;
3316 3316
     vertices[4] = -height2;
3317 3317
     vertices[5] = 0;
3318
-    vertices[6] = width2 / 2.0;
3318
+    vertices[6] = width2 / 2.0f;
3319 3319
     vertices[7] = -height2;
3320 3320
     vertices[8] = 0;
3321
-    vertices[9] = width2 / 2.0;
3321
+    vertices[9] = width2 / 2.0f;
3322 3322
     vertices[10] = 0;
3323 3323
     vertices[11] = 0;
3324 3324
 
@@ -3644,7 +3644,7 @@ void TombRaider::getRoomVertex(unsigned int roomIndex,unsigned int vertexIndex,
3644 3644
             {
3645 3645
                 case TR_VERSION_1:
3646 3646
                     color_value = _rooms[index].room_data.vertices[i].attributes;
3647
-                    color_value = (1.1 - (color_value / 8192.0));
3647
+                    color_value = (1.1f - (color_value / 8192.0f));
3648 3648
 
3649 3649
                     rgba[0] = color_value;
3650 3650
                     rgba[1] = color_value;
@@ -3669,7 +3669,7 @@ void TombRaider::getRoomVertex(unsigned int roomIndex,unsigned int vertexIndex,
3669 3669
                 case TR_VERSION_UNKNOWN:
3670 3670
                 default:
3671 3671
                     color_value = _rooms[index].room_data.vertices[i].lighting1;
3672
-                    color_value = (1.1 - (color_value / 8192.0));
3672
+                    color_value = (1.1f - (color_value / 8192.0f));
3673 3673
 
3674 3674
                     rgba[0] = color_value;
3675 3675
                     rgba[1] = color_value;
@@ -3774,7 +3774,7 @@ void TombRaider::getRoomVertexArrays(unsigned int roomIndex,
3774 3774
                 {
3775 3775
                     case TR_VERSION_1:
3776 3776
                         color_value = _rooms[roomIndex].room_data.vertices[i].attributes;
3777
-                        color_value = (1.1 - (color_value / 8192.0));
3777
+                        color_value = (1.1f - (color_value / 8192.0f));
3778 3778
                         break;
3779 3779
                     case TR_VERSION_4:
3780 3780
                     case TR_VERSION_3:
@@ -3786,7 +3786,7 @@ void TombRaider::getRoomVertexArrays(unsigned int roomIndex,
3786 3786
                     case TR_VERSION_UNKNOWN:
3787 3787
                     default:
3788 3788
                         color_value = _rooms[roomIndex].room_data.vertices[i].lighting1;
3789
-                        color_value = (1.1 - (color_value / 8192.0));
3789
+                        color_value = (1.1f - (color_value / 8192.0f));
3790 3790
                 }
3791 3791
 
3792 3792
                 switch (getEngine())
@@ -5065,7 +5065,7 @@ unsigned char *TombRaider::getTexTile(int texture)
5065 5065
                                         k = image[index] + image[index + 1] + image[index + 2];
5066 5066
 
5067 5067
                                         // Set transparency based upon intensity
5068
-                                        image[index + 3] =  (k / 3);
5068
+                                        image[index + 3] = (unsigned char)(k / 3);
5069 5069
                                     }
5070 5070
                                     else
5071 5071
                                     {
@@ -5082,7 +5082,7 @@ unsigned char *TombRaider::getTexTile(int texture)
5082 5082
 
5083 5083
                                         // Set transparency based upon intensity
5084 5084
                                         if (offset & 0x8000)
5085
-                                            image[index + 3] = (k / 3);
5085
+                                            image[index + 3] = (unsigned char)(k / 3);
5086 5086
                                         else
5087 5087
                                             image[index + 3] = 0;
5088 5088
                                     }

Loading…
Cancel
Save