ソースを参照

TR3 level loader, assert macros

Thomas Buck 9年前
コミット
dfbc01cc42

+ 1
- 0
ChangeLog.md ファイルの表示

6
     * The menu can be navigated using a controller
6
     * The menu can be navigated using a controller
7
     * Vertical camera rotation is now also clamped when using a controller
7
     * Vertical camera rotation is now also clamped when using a controller
8
     * Worked on rendering SkeletalModels, not yet working correctly
8
     * Worked on rendering SkeletalModels, not yet working correctly
9
+    * Implemented level loader for TR3, but tries to access invalid textiles
9
 
10
 
10
     [ 20140211 ]
11
     [ 20140211 ]
11
     * Updated imgui to version 1.32
12
     * Updated imgui to version 1.32

+ 8
- 2
include/RoomData.h ファイルの表示

35
     }
35
     }
36
 
36
 
37
     glm::vec3 getCorner(int i) {
37
     glm::vec3 getCorner(int i) {
38
-        assert((i >= 0) && (i < 8));
38
+        assertGreaterThanEqual(i, 0);
39
+        assertLessThan(i, 8);
39
         return corner[i];
40
         return corner[i];
40
     }
41
     }
41
 
42
 
81
     }
82
     }
82
     int getAdjoiningRoom() { return adjoiningRoom; }
83
     int getAdjoiningRoom() { return adjoiningRoom; }
83
     glm::vec3 getNormal() { return normal; }
84
     glm::vec3 getNormal() { return normal; }
84
-    glm::vec3 getVertex(int i) { assert((i >= 0) && (i < 4)); return vert[i]; }
85
+
86
+    glm::vec3 getVertex(int i) {
87
+        assertGreaterThanEqual(i, 0);
88
+        assertLessThan(i, 4);
89
+        return vert[i];
90
+    }
85
 
91
 
86
   private:
92
   private:
87
     int adjoiningRoom;
93
     int adjoiningRoom;

+ 41
- 1
include/global.h ファイルの表示

115
     std::cout << std::endl << "assertion failed:" << std::endl;
115
     std::cout << std::endl << "assertion failed:" << std::endl;
116
     std::cout << "\t" << exp << std::endl;
116
     std::cout << "\t" << exp << std::endl;
117
     if (print)
117
     if (print)
118
-        std::cout << "\t (" << a << " " << str << " " << b << ")" << std::endl;
118
+        std::cout << "\t(" << a << " " << str << " " << b << ")" << std::endl;
119
     std::cout << "in " << file << ":" << line << std::endl << std::endl;
119
     std::cout << "in " << file << ":" << line << std::endl << std::endl;
120
 
120
 
121
     for (int i = 0; i < frames; i++)
121
     for (int i = 0; i < frames; i++)
150
                                   __FILE__, __LINE__, true, "=="); \
150
                                   __FILE__, __LINE__, true, "=="); \
151
 }
151
 }
152
 
152
 
153
+#define assertLessThan(x, y) { \
154
+    auto assertEvalTemp = x; \
155
+    auto assertEvalTemp2 = y; \
156
+    if (assertEvalTemp >= assertEvalTemp2) \
157
+        assertEqualImplementation(#x " < " #y, assertEvalTemp, assertEvalTemp2, \
158
+                                  __FILE__, __LINE__, true, ">="); \
159
+}
160
+
161
+#define assertLessThanEqual(x, y) { \
162
+    auto assertEvalTemp = x; \
163
+    auto assertEvalTemp2 = y; \
164
+    if (assertEvalTemp > assertEvalTemp2) \
165
+        assertEqualImplementation(#x " <= " #y, assertEvalTemp, assertEvalTemp2, \
166
+                                  __FILE__, __LINE__, true, ">"); \
167
+}
168
+
169
+#define assertGreaterThan(x, y) { \
170
+    auto assertEvalTemp = x; \
171
+    auto assertEvalTemp2 = y; \
172
+    if (assertEvalTemp <= assertEvalTemp2) \
173
+        assertEqualImplementation(#x " > " #y, assertEvalTemp, assertEvalTemp2, \
174
+                                  __FILE__, __LINE__, true, "<="); \
175
+}
176
+
177
+#define assertGreaterThanEqual(x, y) { \
178
+    auto assertEvalTemp = x; \
179
+    auto assertEvalTemp2 = y; \
180
+    if (assertEvalTemp < assertEvalTemp2) \
181
+        assertEqualImplementation(#x " >= " #y, assertEvalTemp, assertEvalTemp2, \
182
+                                  __FILE__, __LINE__, true, "<"); \
183
+}
184
+
153
 #else // NODEBUG
185
 #else // NODEBUG
154
 
186
 
155
 #define assert(x)
187
 #define assert(x)
156
 #define assertEqual(x, y)
188
 #define assertEqual(x, y)
157
 #define assertNotEqual(x, y)
189
 #define assertNotEqual(x, y)
190
+#define assertLessThan(x, y)
191
+#define assertLessThanEqual(x, y)
192
+#define assertGreaterThan(x, y)
193
+#define assertGreaterThanEqual(x, y)
158
 
194
 
159
 #endif // NODEBUG
195
 #endif // NODEBUG
160
 
196
 
164
 #include <cassert>
200
 #include <cassert>
165
 #define assertEqual(x, y) assert((x) == (y))
201
 #define assertEqual(x, y) assert((x) == (y))
166
 #define assertNotEqual(x, y) assert((x) != (y))
202
 #define assertNotEqual(x, y) assert((x) != (y))
203
+#define assertLessThan(x, y) assert((x) < (y))
204
+#define assertLessThanEqual(x, y) assert((x) <= (y))
205
+#define assertGreaterThan(x, y) assert((x) > (y))
206
+#define assertGreaterThanEqual(x, y) assert((x) >= (y))
167
 
207
 
168
 #endif // EXECINFO
208
 #endif // EXECINFO
169
 
209
 

+ 0
- 4
include/loader/Loader.h ファイルの表示

16
 
16
 
17
 class Loader {
17
 class Loader {
18
   public:
18
   public:
19
-
20
     typedef enum {
19
     typedef enum {
21
         TR_UNKNOWN = 0,
20
         TR_UNKNOWN = 0,
22
         TR_1 = 1,
21
         TR_1 = 1,
27
     } LoaderVersion;
26
     } LoaderVersion;
28
 
27
 
29
     static LoaderVersion checkFile(std::string f);
28
     static LoaderVersion checkFile(std::string f);
30
-
31
     static std::unique_ptr<Loader> createLoader(std::string f);
29
     static std::unique_ptr<Loader> createLoader(std::string f);
32
 
30
 
33
-    virtual ~Loader();
34
-
35
     virtual int load(std::string f) = 0;
31
     virtual int load(std::string f) = 0;
36
 
32
 
37
   protected:
33
   protected:

+ 23
- 24
include/loader/LoaderTR2.h ファイルの表示

15
 
15
 
16
 class LoaderTR2 : public Loader {
16
 class LoaderTR2 : public Loader {
17
   public:
17
   public:
18
-    LoaderTR2();
19
-    virtual ~LoaderTR2();
20
-
21
     virtual int load(std::string f);
18
     virtual int load(std::string f);
22
 
19
 
23
-  private:
24
-    void loadPaletteTextiles();
25
-    void loadRooms();
26
-    void loadFloorData();
27
-    void loadMeshes();
28
-    void loadMoveables();
29
-    void loadStaticMeshes();
30
-    void loadTextures();
31
-    void loadSprites();
32
-    void loadCameras();
33
-    void loadSoundSources();
34
-    void loadBoxesOverlapsZones();
35
-    void loadAnimatedTextures();
36
-    void loadItems();
37
-    void loadCinematicFrames();
38
-    void loadDemoData();
39
-    void loadSoundMap();
40
-    void loadSoundDetails();
41
-    void loadSampleIndices();
42
-
43
-    void loadExternalSoundFile(std::string f);
20
+  protected:
21
+    virtual void loadPaletteTextiles();
22
+    virtual void loadRoomLights();
23
+    virtual void loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags);
24
+    virtual void loadRooms();
25
+    virtual void loadFloorData();
26
+    virtual void loadMeshes();
27
+    virtual void loadMoveables();
28
+    virtual void loadStaticMeshes();
29
+    virtual void loadTextures();
30
+    virtual void loadSprites();
31
+    virtual void loadCameras();
32
+    virtual void loadSoundSources();
33
+    virtual void loadBoxesOverlapsZones();
34
+    virtual void loadAnimatedTextures();
35
+    virtual void loadItems();
36
+    virtual void loadCinematicFrames();
37
+    virtual void loadDemoData();
38
+    virtual void loadSoundMap();
39
+    virtual void loadSoundDetails();
40
+    virtual void loadSampleIndices();
41
+
42
+    virtual void loadExternalSoundFile(std::string f);
44
 
43
 
45
     std::array<uint32_t, 256> palette;
44
     std::array<uint32_t, 256> palette;
46
 };
45
 };

+ 5
- 7
include/loader/LoaderTR3.h ファイルの表示

8
 #ifndef _LOADER_LOADER_TR3_H_
8
 #ifndef _LOADER_LOADER_TR3_H_
9
 #define _LOADER_LOADER_TR3_H_
9
 #define _LOADER_LOADER_TR3_H_
10
 
10
 
11
-#include "loader/Loader.h"
11
+#include "loader/LoaderTR2.h"
12
 
12
 
13
-class LoaderTR3 : public Loader {
13
+class LoaderTR3 : public LoaderTR2 {
14
   public:
14
   public:
15
-    LoaderTR3();
16
-    virtual ~LoaderTR3();
17
-
18
     virtual int load(std::string f);
15
     virtual int load(std::string f);
19
 
16
 
20
-  private:
21
-
17
+  protected:
18
+    virtual void loadRoomLights();
19
+    virtual void loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags);
22
 };
20
 };
23
 
21
 
24
 #endif
22
 #endif

+ 1
- 1
src/Console.cpp ファイルの表示

110
         for (unsigned long i = 0; i < Log::size(); i++) {
110
         for (unsigned long i = 0; i < Log::size(); i++) {
111
             auto& entry = Log::getEntry(i);
111
             auto& entry = Log::getEntry(i);
112
 
112
 
113
-            assert(entry.level < LOG_COUNT);
113
+            assertLessThan(entry.level, LOG_COUNT);
114
             if (!visibleLogs[entry.level]) {
114
             if (!visibleLogs[entry.level]) {
115
                 continue;
115
                 continue;
116
             }
116
             }

+ 2
- 2
src/Entity.cpp ファイルの表示

50
             }
50
             }
51
         }
51
         }
52
 
52
 
53
-        assert(cache > -1);
54
-        assert(cacheType > -1);
53
+        assertGreaterThan(cache, -1);
54
+        assertGreaterThan(cacheType, -1);
55
     }
55
     }
56
 
56
 
57
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));
57
     glm::mat4 translate = glm::translate(glm::mat4(1.0f), glm::vec3(pos.x, -pos.y, pos.z));

+ 5
- 5
src/Game.cpp ファイルの表示

81
 }
81
 }
82
 
82
 
83
 void Game::handleAction(ActionEvents action, bool isFinished) {
83
 void Game::handleAction(ActionEvents action, bool isFinished) {
84
-    assert(action < ActionEventCount);
84
+    assertLessThan(action, ActionEventCount);
85
 
85
 
86
     if (!mLoaded)
86
     if (!mLoaded)
87
         return;
87
         return;
112
 }
112
 }
113
 
113
 
114
 Entity& Game::getLara() {
114
 Entity& Game::getLara() {
115
-    assert(mLara >= 0);
116
-    assert(mLara < (int)getWorld().sizeEntity());
115
+    assertGreaterThanEqual(mLara, 0);
116
+    assertLessThan(mLara, getWorld().sizeEntity());
117
     return getWorld().getEntity(mLara);
117
     return getWorld().getEntity(mLara);
118
 }
118
 }
119
 
119
 
120
 void Game::setLara(long lara) {
120
 void Game::setLara(long lara) {
121
-    assert(lara >= 0);
122
-    assert(lara < getWorld().sizeEntity());
121
+    assertGreaterThanEqual(lara, 0);
122
+    assertLessThan(lara, getWorld().sizeEntity());
123
     mLara = lara;
123
     mLara = lara;
124
 }
124
 }
125
 
125
 

+ 2
- 2
src/Log.cpp ファイルの表示

12
 std::vector<LogEntry> Log::wholeLog;
12
 std::vector<LogEntry> Log::wholeLog;
13
 
13
 
14
 LogLevel& Log::get(int level) {
14
 LogLevel& Log::get(int level) {
15
-    assert(level >= 0);
16
-    assert(level < LOG_COUNT);
15
+    assertGreaterThanEqual(level, 0);
16
+    assertLessThan(level, LOG_COUNT);
17
     return logs[level];
17
     return logs[level];
18
 }
18
 }
19
 
19
 

+ 6
- 6
src/Menu.cpp ファイルの表示

14
 void Menu::showDialog(std::string msg, std::string btn1, std::string btn2,
14
 void Menu::showDialog(std::string msg, std::string btn1, std::string btn2,
15
                       std::function<int (bool state)> callback) {
15
                       std::function<int (bool state)> callback) {
16
     // Only show one dialog at a time
16
     // Only show one dialog at a time
17
-    assert(dialogText.length() == 0);
18
-    assert(dialogButton1.length() == 0);
19
-    assert(dialogButton2.length() == 0);
17
+    assertEqual(dialogText.length(), 0);
18
+    assertEqual(dialogButton1.length(), 0);
19
+    assertEqual(dialogButton2.length(), 0);
20
 
20
 
21
-    assert(msg.length() > 0);
22
-    assert(btn1.length() > 0);
21
+    assertGreaterThan(msg.length(), 0);
22
+    assertGreaterThan(btn1.length(), 0);
23
 
23
 
24
     dialogText = msg;
24
     dialogText = msg;
25
     dialogButton1 = btn1;
25
     dialogButton1 = btn1;
93
             w0 = wMax;
93
             w0 = wMax;
94
         unsigned int h0 =  Font::heightText(1.0f, w0, dialogText) + 10;
94
         unsigned int h0 =  Font::heightText(1.0f, w0, dialogText) + 10;
95
 
95
 
96
-        assert(dialogButton1.length() > 0);
96
+        assertGreaterThan(dialogButton1.length(), 0);
97
         unsigned int w1 = Font::widthText(1.0f, dialogButton1) + 20;
97
         unsigned int w1 = Font::widthText(1.0f, dialogButton1) + 20;
98
         if (w1 > wMax)
98
         if (w1 > wMax)
99
             w1 = wMax;
99
             w1 = wMax;

+ 5
- 5
src/Mesh.cpp ファイルの表示

78
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
78
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
79
     }
79
     }
80
 
80
 
81
-    assert((ind.size() % 3) == 0);
82
-    assert(vert.size() == tex.size());
83
-    assert(vert.size() == uvBuff.size());
81
+    assertEqual(ind.size() % 3, 0);
82
+    assertEqual(vert.size(), tex.size());
83
+    assertEqual(vert.size(), uvBuff.size());
84
 
84
 
85
     indicesBuff = std::move(ind);
85
     indicesBuff = std::move(ind);
86
     vertices.bufferData(vert);
86
     vertices.bufferData(vert);
112
         vertIndex += (indicesColorBuff.at(i) == 0) ? 4 : 3;
112
         vertIndex += (indicesColorBuff.at(i) == 0) ? 4 : 3;
113
     }
113
     }
114
 
114
 
115
-    assert((indCol.size() % 3) == 0);
116
-    assert(vertCol.size() == cols.size());
115
+    assertEqual(indCol.size() % 3, 0);
116
+    assertEqual(vertCol.size(), cols.size());
117
 
117
 
118
     indicesColor.bufferData(indCol);
118
     indicesColor.bufferData(indCol);
119
     verticesColor.bufferData(vertCol);
119
     verticesColor.bufferData(vertCol);

+ 1
- 1
src/Room.cpp ファイルの表示

46
 }
46
 }
47
 
47
 
48
 bool Room::isWall(unsigned long sector) {
48
 bool Room::isWall(unsigned long sector) {
49
-    assert(sector < sectors.size());
49
+    assertLessThan(sector, sectors.size());
50
 
50
 
51
     //! \fixme is (sector > 0) correct??
51
     //! \fixme is (sector > 0) correct??
52
     return ((sector > 0) && sectors.at(sector)->isWall());
52
     return ((sector > 0) && sectors.at(sector)->isWall());

+ 1
- 1
src/RoomData.cpp ファイルの表示

76
                 cache = i;
76
                 cache = i;
77
             }
77
             }
78
         }
78
         }
79
-        assert(cache >= 0);
79
+        assertGreaterThanEqual(cache, 0);
80
     }
80
     }
81
 
81
 
82
     getWorld().getStaticMesh(cache).display(VP * model);
82
     getWorld().getStaticMesh(cache).display(VP * model);

+ 3
- 3
src/RoomMesh.cpp ファイルの表示

59
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
59
         vertIndex += (indicesBuff.at(i) == 0) ? 4 : 3;
60
     }
60
     }
61
 
61
 
62
-    assert((ind.size() % 3) == 0);
63
-    assert(vert.size() == tex.size());
64
-    assert(vert.size() == uvBuff.size());
62
+    assertEqual(ind.size() % 3, 0);
63
+    assertEqual(vert.size(), tex.size());
64
+    assertEqual(vert.size(), uvBuff.size());
65
 
65
 
66
     indicesBuff = std::move(ind);
66
     indicesBuff = std::move(ind);
67
     vertices.bufferData(vert);
67
     vertices.bufferData(vert);

+ 2
- 2
src/RunTime.cpp ファイルの表示

54
 }
54
 }
55
 
55
 
56
 KeyboardButton RunTime::getKeyBinding(ActionEvents event) {
56
 KeyboardButton RunTime::getKeyBinding(ActionEvents event) {
57
-    assert(event < ActionEventCount);
57
+    assertLessThan(event, ActionEventCount);
58
     return keyBindings[event];
58
     return keyBindings[event];
59
 }
59
 }
60
 
60
 
61
 void RunTime::setKeyBinding(ActionEvents event, KeyboardButton button) {
61
 void RunTime::setKeyBinding(ActionEvents event, KeyboardButton button) {
62
-    assert(event < ActionEventCount);
62
+    assertLessThan(event, ActionEventCount);
63
     keyBindings[event] = button;
63
     keyBindings[event] = button;
64
 }
64
 }
65
 
65
 

+ 16
- 16
src/Script.cpp ファイルの表示

228
 }
228
 }
229
 
229
 
230
 std::string Script::getLevelName(unsigned int i) {
230
 std::string Script::getLevelName(unsigned int i) {
231
-    assert(i < numLevels);
231
+    assertLessThan(i, numLevels);
232
     return levelNames.at(i);
232
     return levelNames.at(i);
233
 }
233
 }
234
 
234
 
235
 std::string Script::getLevelFilename(unsigned int i) {
235
 std::string Script::getLevelFilename(unsigned int i) {
236
-    assert(i < numLevels);
236
+    assertLessThan(i, numLevels);
237
     return levelFilenames.at(i);
237
     return levelFilenames.at(i);
238
 }
238
 }
239
 
239
 
242
 }
242
 }
243
 
243
 
244
 std::string Script::getPictureFilename(unsigned int i) {
244
 std::string Script::getPictureFilename(unsigned int i) {
245
-    assert(i < numPictures);
245
+    assertLessThan(i, numPictures);
246
     return pictureFilenames.at(i);
246
     return pictureFilenames.at(i);
247
 }
247
 }
248
 
248
 
251
 }
251
 }
252
 
252
 
253
 std::string Script::getCutsceneFilename(unsigned int i) {
253
 std::string Script::getCutsceneFilename(unsigned int i) {
254
-    assert(i < numCutscenes);
254
+    assertLessThan(i, numCutscenes);
255
     return cutsceneFilenames.at(i);
255
     return cutsceneFilenames.at(i);
256
 }
256
 }
257
 
257
 
260
 }
260
 }
261
 
261
 
262
 std::string Script::getTitleFilename(unsigned int i) {
262
 std::string Script::getTitleFilename(unsigned int i) {
263
-    assert(i < numTitles);
263
+    assertLessThan(i, numTitles);
264
     return titleFilenames.at(i);
264
     return titleFilenames.at(i);
265
 }
265
 }
266
 
266
 
269
 }
269
 }
270
 
270
 
271
 std::string Script::getVideoFilename(unsigned int i) {
271
 std::string Script::getVideoFilename(unsigned int i) {
272
-    assert(i < numFMVs);
272
+    assertLessThan(i, numFMVs);
273
     return fmvFilenames.at(i);
273
     return fmvFilenames.at(i);
274
 }
274
 }
275
 
275
 
278
 }
278
 }
279
 
279
 
280
 std::string Script::getGameString(unsigned int i) {
280
 std::string Script::getGameString(unsigned int i) {
281
-    assert(i < numGameStrings);
281
+    assertLessThan(i, numGameStrings);
282
     return gameStrings.at(i);
282
     return gameStrings.at(i);
283
 }
283
 }
284
 
284
 
287
 }
287
 }
288
 
288
 
289
 std::string Script::getPCString(unsigned int i) {
289
 std::string Script::getPCString(unsigned int i) {
290
-    assert(i < numPCStrings);
290
+    assertLessThan(i, numPCStrings);
291
     return pcStrings.at(i);
291
     return pcStrings.at(i);
292
 }
292
 }
293
 
293
 
294
 std::string Script::getPuzzleString(unsigned int i, unsigned int j) {
294
 std::string Script::getPuzzleString(unsigned int i, unsigned int j) {
295
-    assert(i < 4);
296
-    assert(j < numLevels);
295
+    assertLessThan(i, 4);
296
+    assertLessThan(j, numLevels);
297
     return puzzles.at(i).at(j);
297
     return puzzles.at(i).at(j);
298
 }
298
 }
299
 
299
 
300
 std::string Script::getPickupString(unsigned int i, unsigned int j) {
300
 std::string Script::getPickupString(unsigned int i, unsigned int j) {
301
-    assert(i < 2);
302
-    assert(j < numLevels);
301
+    assertLessThan(i, 2);
302
+    assertLessThan(j, numLevels);
303
     return pickups.at(i).at(j);
303
     return pickups.at(i).at(j);
304
 }
304
 }
305
 
305
 
306
 std::string Script::getKeyString(unsigned int i, unsigned int j) {
306
 std::string Script::getKeyString(unsigned int i, unsigned int j) {
307
-    assert(i < 4);
308
-    assert(j < numLevels);
307
+    assertLessThan(i, 4);
308
+    assertLessThan(j, numLevels);
309
     return keys.at(i).at(j);
309
     return keys.at(i).at(j);
310
 }
310
 }
311
 
311
 
312
 void Script::registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func) {
312
 void Script::registerScriptHandler(ScriptOpCode op, std::function<int (bool, uint16_t)> func) {
313
-    assert(op < OP_UNKNOWN);
313
+    assertLessThan(op, OP_UNKNOWN);
314
     scriptHandlers[op] = func;
314
     scriptHandlers[op] = func;
315
 }
315
 }
316
 
316
 
317
 int Script::runScript(unsigned int level) {
317
 int Script::runScript(unsigned int level) {
318
-    assert(level < (numLevels + 1));
318
+    assertLessThan(level, (numLevels + 1));
319
     std::vector<uint16_t> s = script.at(level);
319
     std::vector<uint16_t> s = script.at(level);
320
 
320
 
321
     for (unsigned int i = 0; i < s.size(); i++) {
321
     for (unsigned int i = 0; i < s.size(); i++) {

+ 8
- 8
src/SkeletalModel.cpp ファイルの表示

29
 }
29
 }
30
 
30
 
31
 BoneTag& BoneFrame::get(unsigned long i) {
31
 BoneTag& BoneFrame::get(unsigned long i) {
32
-    assert(i < tag.size());
32
+    assertLessThan(i, tag.size());
33
     return *tag.at(i);
33
     return *tag.at(i);
34
 }
34
 }
35
 
35
 
49
 }
49
 }
50
 
50
 
51
 BoneFrame& AnimationFrame::get(unsigned long i) {
51
 BoneFrame& AnimationFrame::get(unsigned long i) {
52
-    assert(i < frame.size());
52
+    assertLessThan(i, frame.size());
53
     return *frame.at(i);
53
     return *frame.at(i);
54
 }
54
 }
55
 
55
 
64
     MatrixStack(glm::mat4 start) : startVal(start) { stack.push_back(startVal); }
64
     MatrixStack(glm::mat4 start) : startVal(start) { stack.push_back(startVal); }
65
 
65
 
66
     void push() {
66
     void push() {
67
-        //assert(stack.size() > 0);
67
+        //assertGreaterThan(stack.size(), 0);
68
         if (stack.size() > 0)
68
         if (stack.size() > 0)
69
             stack.push_back(stack.at(stack.size() - 1));
69
             stack.push_back(stack.at(stack.size() - 1));
70
     }
70
     }
71
 
71
 
72
     void pop() {
72
     void pop() {
73
-        //assert(stack.size() > 0);
73
+        //assertGreaterThan(stack.size(), 0);
74
         if (stack.size() > 0)
74
         if (stack.size() > 0)
75
             stack.pop_back();
75
             stack.pop_back();
76
     }
76
     }
77
 
77
 
78
     glm::mat4 get() {
78
     glm::mat4 get() {
79
-        //assert(stack.size() > 0);
79
+        //assertGreaterThan(stack.size(), 0);
80
         if (stack.size() > 0)
80
         if (stack.size() > 0)
81
             return stack.at(stack.size() - 1);
81
             return stack.at(stack.size() - 1);
82
         return startVal;
82
         return startVal;
101
 #endif
101
 #endif
102
 
102
 
103
 void SkeletalModel::display(glm::mat4 MVP, int aframe, int bframe) {
103
 void SkeletalModel::display(glm::mat4 MVP, int aframe, int bframe) {
104
-    assert(aframe < size());
105
-    assert(bframe < get(aframe).size());
104
+    assertLessThan(aframe, size());
105
+    assertLessThan(bframe, get(aframe).size());
106
 
106
 
107
     AnimationFrame& anim = get(aframe);
107
     AnimationFrame& anim = get(aframe);
108
     BoneFrame& boneframe = anim.get(bframe);
108
     BoneFrame& boneframe = anim.get(bframe);
173
 }
173
 }
174
 
174
 
175
 AnimationFrame& SkeletalModel::get(unsigned long i) {
175
 AnimationFrame& SkeletalModel::get(unsigned long i) {
176
-    assert(i < animation.size());
176
+    assertLessThan(i, animation.size());
177
     return *animation.at(i);
177
     return *animation.at(i);
178
 }
178
 }
179
 
179
 

+ 3
- 3
src/SoundManager.cpp ファイルの表示

30
         float vol;
30
         float vol;
31
         int index = getIndex(soundSources.at(i).id, &vol);
31
         int index = getIndex(soundSources.at(i).id, &vol);
32
         int ret = Sound::addSource(index, vol, false, true);
32
         int ret = Sound::addSource(index, vol, false, true);
33
-        assert(ret == i);
33
+        assertEqual(ret, i);
34
         float pos[3] = { soundSources.at(i).x, soundSources.at(i).y, soundSources.at(i).z };
34
         float pos[3] = { soundSources.at(i).x, soundSources.at(i).y, soundSources.at(i).z };
35
         ret = Sound::sourceAt(i, pos);
35
         ret = Sound::sourceAt(i, pos);
36
-        assert(ret == 0);
36
+        assertEqual(ret, 0);
37
         Sound::play(i, false);
37
         Sound::play(i, false);
38
     }
38
     }
39
 
39
 
42
         int index = getIndex(i, &vol);
42
         int index = getIndex(i, &vol);
43
         if ((index >= 0) && (index < Sound::numBuffers())) {
43
         if ((index >= 0) && (index < Sound::numBuffers())) {
44
             int ret = Sound::addSource(index, vol, true, false);
44
             int ret = Sound::addSource(index, vol, true, false);
45
-            assert(ret >= 0);
45
+            assertGreaterThanEqual(ret, 0);
46
         }
46
         }
47
     }
47
     }
48
 }
48
 }

+ 2
- 2
src/Sprite.cpp ファイルの表示

52
 // ----------------------------------------------------------------------------
52
 // ----------------------------------------------------------------------------
53
 
53
 
54
 void SpriteSequence::display(glm::mat4 MVP, int index) {
54
 void SpriteSequence::display(glm::mat4 MVP, int index) {
55
-    assert(index >= 0);
56
-    assert(index < length);
55
+    assertGreaterThanEqual(index, 0);
56
+    assertLessThan(index, length);
57
     getWorld().getSprite(start + index).display(MVP);
57
     getWorld().getSprite(start + index).display(MVP);
58
 }
58
 }
59
 
59
 

+ 12
- 12
src/TextureManager.cpp ファイルの表示

56
 std::vector<BufferManager> TextureManager::systemBuffers;
56
 std::vector<BufferManager> TextureManager::systemBuffers;
57
 
57
 
58
 int TextureManager::initialize() {
58
 int TextureManager::initialize() {
59
-    assert(mTextureIdsGame.size() == 0);
60
-    assert(mTextureIdsSystem.size() == 0);
59
+    assertEqual(mTextureIdsGame.size(), 0);
60
+    assertEqual(mTextureIdsSystem.size(), 0);
61
 
61
 
62
     while (mTextureIdsSystem.size() < 2) {
62
     while (mTextureIdsSystem.size() < 2) {
63
         unsigned int id;
63
         unsigned int id;
132
                                    unsigned int width, unsigned int height,
132
                                    unsigned int width, unsigned int height,
133
                                    ColorMode mode, unsigned int bpp,
133
                                    ColorMode mode, unsigned int bpp,
134
                                    TextureStorage s, int slot, bool filter) {
134
                                    TextureStorage s, int slot, bool filter) {
135
-    assert(width > 0);
136
-    assert(height > 0);
135
+    assertGreaterThan(width, 0);
136
+    assertGreaterThan(height, 0);
137
     assert((mode == ColorMode::RGB)
137
     assert((mode == ColorMode::RGB)
138
            || (mode == ColorMode::BGR)
138
            || (mode == ColorMode::BGR)
139
            || (mode == ColorMode::ARGB)
139
            || (mode == ColorMode::ARGB)
201
 }
201
 }
202
 
202
 
203
 void TextureManager::bindTextureId(unsigned int n, TextureStorage s, unsigned int unit) {
203
 void TextureManager::bindTextureId(unsigned int n, TextureStorage s, unsigned int unit) {
204
-    assert(n < getIds(s).size());
205
-    assert(unit < 80); //! \todo Query GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
204
+    assertLessThan(n, getIds(s).size());
205
+    assertLessThan(unit, 80); //! \todo Query GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
206
 
206
 
207
     glActiveTexture(GL_TEXTURE0 + unit);
207
     glActiveTexture(GL_TEXTURE0 + unit);
208
     glBindTexture(GL_TEXTURE_2D, getIds(s).at(n));
208
     glBindTexture(GL_TEXTURE_2D, getIds(s).at(n));
209
 }
209
 }
210
 
210
 
211
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
211
 int TextureManager::bindTexture(unsigned int n, TextureStorage s) {
212
-    assert(n < getIds(s).size());
212
+    assertLessThan(n, getIds(s).size());
213
 
213
 
214
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
214
     if ((n < getUnits(s).size()) && (getUnits(s).at(n) >= 0)) {
215
         bindTextureId(n, s, getUnits(s).at(n));
215
         bindTextureId(n, s, getUnits(s).at(n));
233
 }
233
 }
234
 
234
 
235
 TextureTile& TextureManager::getTile(int index) {
235
 TextureTile& TextureManager::getTile(int index) {
236
-    assert(index >= 0);
237
-    assert(index < tiles.size());
236
+    assertGreaterThanEqual(index, 0);
237
+    assertLessThan(index, tiles.size());
238
     return *tiles.at(index);
238
     return *tiles.at(index);
239
 }
239
 }
240
 
240
 
250
 }
250
 }
251
 
251
 
252
 int TextureManager::getFirstTileAnimation(int index) {
252
 int TextureManager::getFirstTileAnimation(int index) {
253
-    assert(index < animations.size());
254
-    assert(animations.at(index).size() > 0);
253
+    assertLessThan(index, animations.size());
254
+    assertGreaterThan(animations.at(index).size(), 0);
255
     return animations.at(index).at(0);
255
     return animations.at(index).at(0);
256
 }
256
 }
257
 
257
 
258
 int TextureManager::getNextTileAnimation(int index, int tile) {
258
 int TextureManager::getNextTileAnimation(int index, int tile) {
259
-    assert(index < animations.size());
259
+    assertLessThan(index, animations.size());
260
     for (int i = 0; i < animations.at(index).size(); i++) {
260
     for (int i = 0; i < animations.at(index).size(); i++) {
261
         if (animations.at(index).at(i) == tile) {
261
         if (animations.at(index).at(i) == tile) {
262
             if (i < (animations.at(index).size() - 1))
262
             if (i < (animations.at(index).size() - 1))

+ 7
- 7
src/World.cpp ファイルの表示

31
 }
31
 }
32
 
32
 
33
 Room& World::getRoom(unsigned long index) {
33
 Room& World::getRoom(unsigned long index) {
34
-    assert(index < mRooms.size());
34
+    assertLessThan(index, mRooms.size());
35
     return *mRooms.at(index);
35
     return *mRooms.at(index);
36
 }
36
 }
37
 
37
 
44
 }
44
 }
45
 
45
 
46
 Sprite& World::getSprite(unsigned long index) {
46
 Sprite& World::getSprite(unsigned long index) {
47
-    assert(index < mSprites.size());
47
+    assertLessThan(index, mSprites.size());
48
     return *mSprites.at(index);
48
     return *mSprites.at(index);
49
 }
49
 }
50
 
50
 
57
 }
57
 }
58
 
58
 
59
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
59
 SpriteSequence& World::getSpriteSequence(unsigned long index) {
60
-    assert(index < mSpriteSequences.size());
60
+    assertLessThan(index, mSpriteSequences.size());
61
     return *mSpriteSequences.at(index);
61
     return *mSpriteSequences.at(index);
62
 }
62
 }
63
 
63
 
70
 }
70
 }
71
 
71
 
72
 Entity& World::getEntity(unsigned long index) {
72
 Entity& World::getEntity(unsigned long index) {
73
-    assert(index < mEntities.size());
73
+    assertLessThan(index, mEntities.size());
74
     return *mEntities.at(index);
74
     return *mEntities.at(index);
75
 }
75
 }
76
 
76
 
83
 }
83
 }
84
 
84
 
85
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
85
 SkeletalModel& World::getSkeletalModel(unsigned long index) {
86
-    assert(index < mModels.size());
86
+    assertLessThan(index, mModels.size());
87
     return *mModels.at(index);
87
     return *mModels.at(index);
88
 }
88
 }
89
 
89
 
96
 }
96
 }
97
 
97
 
98
 StaticMesh& World::getStaticMesh(unsigned long index) {
98
 StaticMesh& World::getStaticMesh(unsigned long index) {
99
-    assert(index < mStaticMeshes.size());
99
+    assertLessThan(index, mStaticMeshes.size());
100
     return *mStaticMeshes.at(index);
100
     return *mStaticMeshes.at(index);
101
 }
101
 }
102
 
102
 
109
 }
109
 }
110
 
110
 
111
 Mesh& World::getMesh(unsigned long index) {
111
 Mesh& World::getMesh(unsigned long index) {
112
-    assert(index < mMeshes.size());
112
+    assertLessThan(index, mMeshes.size());
113
     return *mMeshes.at(index);
113
     return *mMeshes.at(index);
114
 }
114
 }
115
 
115
 

+ 0
- 2
src/commands/Command.cpp ファイルの表示

36
 }
36
 }
37
 
37
 
38
 int Command::command(std::string c) {
38
 int Command::command(std::string c) {
39
-    assert(commands.size() > 0);
40
-
41
     // Remove comment, if any
39
     // Remove comment, if any
42
     size_t comment = c.find_first_of('#');
40
     size_t comment = c.find_first_of('#');
43
     if (comment != std::string::npos)
41
     if (comment != std::string::npos)

+ 4
- 5
src/loader/Loader.cpp ファイルの表示

8
 #include "global.h"
8
 #include "global.h"
9
 #include "loader/Loader.h"
9
 #include "loader/Loader.h"
10
 #include "loader/LoaderTR2.h"
10
 #include "loader/LoaderTR2.h"
11
+#include "loader/LoaderTR3.h"
11
 
12
 
12
 Loader::LoaderVersion Loader::checkFile(std::string f) {
13
 Loader::LoaderVersion Loader::checkFile(std::string f) {
13
     BinaryFile file;
14
     BinaryFile file;
38
     LoaderVersion v = checkFile(f);
39
     LoaderVersion v = checkFile(f);
39
     switch (v) {
40
     switch (v) {
40
         case TR_1:
41
         case TR_1:
41
-        case TR_3:
42
         case TR_4:
42
         case TR_4:
43
         case TR_5:
43
         case TR_5:
44
         case TR_UNKNOWN:
44
         case TR_UNKNOWN:
46
 
46
 
47
         case TR_2:
47
         case TR_2:
48
             return std::unique_ptr<Loader>(new LoaderTR2());
48
             return std::unique_ptr<Loader>(new LoaderTR2());
49
-    }
50
-}
51
-
52
-Loader::~Loader() {
53
 
49
 
50
+        case TR_3:
51
+            return std::unique_ptr<Loader>(new LoaderTR3());
52
+    }
54
 }
53
 }
55
 
54
 

+ 49
- 36
src/loader/LoaderTR2.cpp ファイルの表示

21
 
21
 
22
 #include <glm/gtc/matrix_transform.hpp>
22
 #include <glm/gtc/matrix_transform.hpp>
23
 
23
 
24
-LoaderTR2::LoaderTR2() {
25
-}
26
-
27
-LoaderTR2::~LoaderTR2() {
28
-}
29
-
30
 int LoaderTR2::load(std::string f) {
24
 int LoaderTR2::load(std::string f) {
31
     if (file.open(f) != 0) {
25
     if (file.open(f) != 0) {
32
         return 1; // Could not open file
26
         return 1; // Could not open file
91
         int r = TextureManager::loadBufferSlot(img, 256, 256,
85
         int r = TextureManager::loadBufferSlot(img, 256, 256,
92
                                                ColorMode::ARGB, 32,
86
                                                ColorMode::ARGB, 32,
93
                                                TextureStorage::GAME, i);
87
                                                TextureStorage::GAME, i);
94
-        assert(r >= 0); //! \fixme properly handle error when texture could not be loaded!
88
+        assertGreaterThanEqual(r, 0); //! \fixme properly handle error when texture could not be loaded!
95
         delete [] img;
89
         delete [] img;
96
     }
90
     }
97
 
91
 
106
     for (unsigned int o = 0; o < numObjectTextures; o++) {
100
     for (unsigned int o = 0; o < numObjectTextures; o++) {
107
         // 0 means that a texture is all-opaque, and that transparency
101
         // 0 means that a texture is all-opaque, and that transparency
108
         // information is ignored.
102
         // information is ignored.
103
+        //
109
         // 1 means that transparency information is used. In 8-bit color,
104
         // 1 means that transparency information is used. In 8-bit color,
110
         // index 0 is the transparent color, while in 16-bit color, the
105
         // index 0 is the transparent color, while in 16-bit color, the
111
         // top bit (0x8000) is the alpha channel (1 = opaque, 0 = transparent)
106
         // top bit (0x8000) is the alpha channel (1 = opaque, 0 = transparent)
107
+        //
108
+        // 2 (TR3 only) means that the opacity (alpha) is equal to the intensity;
109
+        // the brighter the color, the more opaque it is. The intensity is probably
110
+        // calculated as the maximum of the individual color values.
112
         uint16_t attribute = file.readU16();
111
         uint16_t attribute = file.readU16();
113
 
112
 
114
         // Index into the textile list
113
         // Index into the textile list
179
 
178
 
180
 // ---- Rooms ----
179
 // ---- Rooms ----
181
 
180
 
181
+void LoaderTR2::loadRoomLights() {
182
+    int16_t intensity1 = file.read16();
183
+    int16_t intensity2 = file.read16();
184
+    int16_t lightMode = file.read16();
185
+
186
+    uint16_t numLights = file.readU16();
187
+    for (unsigned int l = 0; l < numLights; l++) {
188
+        // Position of light, in world coordinates
189
+        int32_t x = file.read32();
190
+        int32_t y = file.read32();
191
+        int32_t z = file.read32();
192
+
193
+        uint16_t intensity1 = file.readU16();
194
+        uint16_t intensity2 = file.readU16(); // Almost always equal to intensity1
195
+
196
+        uint32_t fade1 = file.readU32(); // Falloff value?
197
+        uint32_t fade2 = file.readU32(); // Falloff value?
198
+
199
+        // TODO store light somewhere
200
+    }
201
+}
202
+
203
+void LoaderTR2::loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags) {
204
+    alternateRoom = file.read16();
205
+
206
+    uint16_t flags = file.readU16();
207
+    roomFlags = 0;
208
+    if (flags & 0x0001) {
209
+        roomFlags |= RoomFlagUnderWater;
210
+    }
211
+}
212
+
182
 void LoaderTR2::loadRooms() {
213
 void LoaderTR2::loadRooms() {
183
     uint16_t numRooms = file.readU16();
214
     uint16_t numRooms = file.readU16();
184
     for (unsigned int i = 0; i < numRooms; i++) {
215
     for (unsigned int i = 0; i < numRooms; i++) {
332
             uint8_t roomAbove = file.readU8(); // 0xFF if none
363
             uint8_t roomAbove = file.readU8(); // 0xFF if none
333
             int8_t ceiling = file.read8(); // Absolute height of ceiling (/ 256)
364
             int8_t ceiling = file.read8(); // Absolute height of ceiling (/ 256)
334
 
365
 
366
+            // In TR3 indexBox is more complicated. Only bits 4-14 are the 'real' index.
367
+            // Bits 0-3 are most likely some kind of flag (footstep sound?).
368
+            // There is a special value of the 'real' index, 2047 or 0x7FF.
369
+
335
             bool wall = false;
370
             bool wall = false;
336
             if ((((uint8_t)floor) == 0x81) || (((uint8_t)ceiling) == 0x81)) {
371
             if ((((uint8_t)floor) == 0x81) || (((uint8_t)ceiling) == 0x81)) {
337
                 wall = true;
372
                 wall = true;
341
             // TODO store sectors
376
             // TODO store sectors
342
         }
377
         }
343
 
378
 
344
-        int16_t intensity1 = file.read16();
345
-        int16_t intensity2 = file.read16();
346
-        int16_t lightMode = file.read16();
347
-
348
-        uint16_t numLights = file.readU16();
349
-        for (unsigned int l = 0; l < numLights; l++) {
350
-            // Position of light, in world coordinates
351
-            int32_t x = file.read32();
352
-            int32_t y = file.read32();
353
-            int32_t z = file.read32();
354
-
355
-            uint16_t intensity1 = file.readU16();
356
-            uint16_t intensity2 = file.readU16(); // Almost always equal to intensity1
357
-
358
-            uint32_t fade1 = file.readU32(); // Falloff value?
359
-            uint32_t fade2 = file.readU32(); // Falloff value?
360
-
361
-            // TODO store light somewhere
362
-        }
379
+        loadRoomLights();
363
 
380
 
364
         uint16_t numStaticMeshes = file.readU16();
381
         uint16_t numStaticMeshes = file.readU16();
365
         std::vector<StaticModel*> staticModels;
382
         std::vector<StaticModel*> staticModels;
385
                                                    objectID));
402
                                                    objectID));
386
         }
403
         }
387
 
404
 
388
-        int16_t alternateRoom = file.read16();
389
-
390
-        uint16_t flags = file.readU16();
405
+        int16_t alternateRoom = -1;
391
         unsigned int roomFlags = 0;
406
         unsigned int roomFlags = 0;
392
-        if (flags & 0x0001) {
393
-            roomFlags |= RoomFlagUnderWater;
394
-        }
407
+        loadRoomDataEnd(alternateRoom, roomFlags);
395
 
408
 
396
         BoundingBox* boundingbox = new BoundingBox(bbox[0], bbox[1]);
409
         BoundingBox* boundingbox = new BoundingBox(bbox[0], bbox[1]);
397
         RoomMesh* mesh = new RoomMesh(vertices, rectangles, triangles);
410
         RoomMesh* mesh = new RoomMesh(vertices, rectangles, triangles);
463
         int16_t negativeLength = file.read16(); // Negative sprite count
476
         int16_t negativeLength = file.read16(); // Negative sprite count
464
         int16_t offset = file.read16(); // Where sequence starts in sprite texture list
477
         int16_t offset = file.read16(); // Where sequence starts in sprite texture list
465
 
478
 
466
-        assert(negativeLength < 0);
467
-        assert(offset >= 0);
468
-        assert((offset + (negativeLength * -1)) <= numSpriteTextures);
479
+        assertLessThan(negativeLength, 0);
480
+        assertGreaterThanEqual(offset, 0);
481
+        assertLessThanEqual(offset + (negativeLength * -1), numSpriteTextures);
469
 
482
 
470
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
483
         SpriteSequence* ss = new SpriteSequence(objectID, offset, (negativeLength * -1));
471
         getWorld().addSpriteSequence(ss);
484
         getWorld().addSpriteSequence(ss);
1106
             buff[i] = sfx.readU8();
1119
             buff[i] = sfx.readU8();
1107
 
1120
 
1108
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1121
         int ret = Sound::loadBuffer(buff, riffSize + 8);
1109
-        assert(ret >= 0);
1122
+        assertGreaterThanEqual(ret, 0);
1110
 
1123
 
1111
         riffCount++;
1124
         riffCount++;
1112
     }
1125
     }

+ 65
- 7
src/loader/LoaderTR3.cpp ファイルの表示

8
 #include "global.h"
8
 #include "global.h"
9
 #include "loader/LoaderTR3.h"
9
 #include "loader/LoaderTR3.h"
10
 
10
 
11
-LoaderTR3::LoaderTR3() {
12
-}
11
+int LoaderTR3::load(std::string f) {
12
+    if (file.open(f) != 0) {
13
+        return 1; // Could not open file
14
+    }
15
+
16
+    uint32_t version = file.readU32();
17
+    if ((version != 0xFF080038) && (version != 0xFF180038)) {
18
+        return 2; // Not a TR3 level?!
19
+    }
20
+
21
+    loadPaletteTextiles();
22
+
23
+    file.seek(file.tell() + 4); // Unused value?
24
+
25
+    loadRooms();
26
+    loadFloorData();
27
+    loadMeshes();
28
+    loadMoveables();
29
+    loadStaticMeshes();
30
+    loadSprites();
31
+    loadCameras();
32
+    loadSoundSources();
33
+    loadBoxesOverlapsZones();
34
+    loadAnimatedTextures();
35
+    loadTextures();
36
+    loadItems();
37
+
38
+    file.seek(file.tell() + 8192); // Skip Light map, only for 8bit coloring
13
 
39
 
14
-LoaderTR3::~LoaderTR3() {
40
+    loadCinematicFrames();
41
+    loadDemoData();
42
+    loadSoundMap();
43
+    loadSoundDetails();
44
+    loadSampleIndices();
45
+
46
+    loadExternalSoundFile(f);
47
+
48
+    // TODO load TR3 PC version CDAUDIO.WAD file
49
+    // TODO load TR3 Mac version CDAudio.db and WAV files
50
+
51
+    return 0;
15
 }
52
 }
16
 
53
 
17
-int LoaderTR3::load(std::string f) {
18
-    if (file.open(f.c_str()) != 0) {
19
-        return 1; // Could not open file
54
+void LoaderTR3::loadRoomLights() {
55
+    int16_t intensity1 = file.read16();
56
+    int16_t intensity2 = file.read16();
57
+
58
+    uint16_t numLights = file.readU16();
59
+    for (unsigned int l = 0; l < numLights; l++) {
60
+        // Position of light, in world coordinates
61
+        int32_t x = file.read32();
62
+        int32_t y = file.read32();
63
+        int32_t z = file.read32();
64
+
65
+        uint16_t intensity1 = file.readU16();
66
+        uint16_t intensity2 = file.readU16(); // Almost always equal to intensity1
67
+
68
+        uint32_t fade1 = file.readU32(); // Falloff value?
69
+        uint32_t fade2 = file.readU32(); // Falloff value?
70
+
71
+        // TODO store light somewhere
20
     }
72
     }
73
+}
21
 
74
 
75
+void LoaderTR3::loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags) {
76
+    LoaderTR2::loadRoomDataEnd(alternateRoom, roomFlags);
22
 
77
 
78
+    uint8_t r = file.readU8();
79
+    uint8_t g = file.readU8();
80
+    uint8_t b = file.readU8();
23
 
81
 
24
-    return 1; // stub
82
+    // TODO store room-light color (?) somewhere
25
 }
83
 }
26
 
84
 

+ 1
- 1
src/utils/random.cpp ファイルの表示

21
     if (max == min)
21
     if (max == min)
22
         return max;
22
         return max;
23
 
23
 
24
-    assert(max > min);
24
+    assertGreaterThan(max, min);
25
 
25
 
26
     if (!engineIsSeeded) {
26
     if (!engineIsSeeded) {
27
         engine.seed(std::chrono::system_clock::now().time_since_epoch().count());
27
         engine.seed(std::chrono::system_clock::now().time_since_epoch().count());

読み込み中…
キャンセル
保存