Przeglądaj źródła

Now segfaults somwhere else in Render

Thomas Buck 10 lat temu
rodzic
commit
1b8d5f6694
3 zmienionych plików z 15 dodań i 36 usunięć
  1. 6
    10
      src/Game.cpp
  2. 9
    24
      src/Render.cpp
  3. 0
    2
      src/World.cpp

+ 6
- 10
src/Game.cpp Wyświetl plik

@@ -132,8 +132,9 @@ int Game::loadLevel(const char *level) {
132 132
         processRoom(i);
133 133
     printf("Done! Found %d rooms.\n", mTombRaider.NumRooms());
134 134
     printf("Processing meshes: ");
135
-    for (int i = 0; i < mTombRaider.getMeshCount(); i++)
135
+    for (int i = 0; i < mTombRaider.getMeshCount(); i++) {
136 136
         processModel(i);
137
+    }
137 138
     printf("Done! Found %d meshes.\n", mTombRaider.getMeshCount());
138 139
     processSprites();
139 140
     processMoveables();
@@ -633,7 +634,7 @@ void Game::processMoveable(int index, int i, int *ent,
633 634
             break;
634 635
         }
635 636
     }
636
-    if (cache.empty() || (!found))
637
+    if (!found)
637 638
     {
638 639
         sModel->model = r_model;
639 640
         mWorld.addEntity(thing);
@@ -892,19 +893,14 @@ void Game::processMoveable(int index, int i, int *ent,
892 893
     //fflush(stdout);
893 894
 }
894 895
 
895
-int compareFaceTextureId(const void *voidA, const void *voidB)
896
+bool compareFaceTextureId(const void *voidA, const void *voidB)
896 897
 {
897 898
     texture_tri_t *a = (texture_tri_t *)voidA, *b = (texture_tri_t *)voidB;
898 899
 
899 900
     if (!a || !b)
900
-        return -1; // error really
901
-
902
-    // less than
903
-    if (a->texture < b->texture)
904
-        return -1;
901
+        return false; // error really
905 902
 
906
-    // greater than ( no need for equal )
907
-    return 1;
903
+    return (a->texture < b->texture);
908 904
 }
909 905
 
910 906
 #ifdef EXPERIMENTAL

+ 9
- 24
src/Render.cpp Wyświetl plik

@@ -112,13 +112,13 @@ void Render::drawLoadScreen()
112 112
 }
113 113
 
114 114
 
115
-int compareEntites(const void *voidA, const void *voidB)
115
+bool compareEntites(const void *voidA, const void *voidB)
116 116
 {
117 117
     entity_t *a = (entity_t *)voidA, *b = (entity_t *)voidB;
118 118
     vec_t distA, distB;
119 119
 
120 120
     if (!a || !b)
121
-        return -1; // error really
121
+        return false; // error really
122 122
 
123 123
     distA = gViewVolume.getDistToSphereFromNear(a->pos[0],
124 124
             a->pos[1],
@@ -129,22 +129,17 @@ int compareEntites(const void *voidA, const void *voidB)
129 129
             b->pos[2],
130 130
             1.0f);
131 131
 
132
-    // less than
133
-    if (distA < distB)
134
-        return -1;
135
-
136
-    // greater than ( no need for equal )
137
-    return 1;
132
+    return (distA < distB);
138 133
 }
139 134
 
140 135
 
141
-int compareStaticModels(const void *voidA, const void *voidB)
136
+bool compareStaticModels(const void *voidA, const void *voidB)
142 137
 {
143 138
     static_model_t *a = (static_model_t *)voidA, *b = (static_model_t *)voidB;
144 139
     vec_t distA, distB;
145 140
 
146 141
     if (!a || !b)
147
-        return -1; // error really
142
+        return false; // error really
148 143
 
149 144
     distA = gViewVolume.getDistToSphereFromNear(a->pos[0],
150 145
             a->pos[1],
@@ -155,30 +150,20 @@ int compareStaticModels(const void *voidA, const void *voidB)
155 150
             b->pos[2],
156 151
             128.0f);
157 152
 
158
-    // less than
159
-    if (distA < distB)
160
-        return -1;
161
-
162
-    // greater than ( no need for equal )
163
-    return 1;
153
+    return (distA < distB);
164 154
 }
165 155
 
166 156
 
167
-int compareRoomDist(const void *voidA, const void *voidB)
157
+bool compareRoomDist(const void *voidA, const void *voidB)
168 158
 {
169 159
     const RenderRoom *a = static_cast<const RenderRoom *>(voidA);
170 160
     const RenderRoom *b = static_cast<const RenderRoom *>(voidB);
171 161
 
172 162
 
173 163
     if (!a || !b || !a->room || !b->room)
174
-        return -1; // error really
175
-
176
-    // less than
177
-    if (a->dist < b->dist)
178
-        return -1;
164
+        return false; // error really
179 165
 
180
-    // greater than ( no need for equal )
181
-    return 1;
166
+    return (a->dist < b->dist);
182 167
 }
183 168
 
184 169
 

+ 0
- 2
src/World.cpp Wyświetl plik

@@ -121,7 +121,6 @@ int World::getSector(int room, float x, float z, float *floor, float *ceiling)
121 121
     sector_t * s;
122 122
     int sector;
123 123
 
124
-
125 124
     r = mRooms[room];
126 125
 
127 126
     if (!r)
@@ -150,7 +149,6 @@ int World::getSector(int room, float x, float z)
150 149
     int sector;
151 150
     room_mesh_t *r;
152 151
 
153
-
154 152
     r = mRooms[room];
155 153
 
156 154
     if (!r)

Ładowanie…
Anuluj
Zapisz