浏览代码

Load external sound effect files

Thomas Buck 10 年前
父节点
当前提交
afc11f2c5a
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20
    0
      src/Game.cpp

+ 20
- 0
src/Game.cpp 查看文件

@@ -31,11 +31,31 @@ void Game::percentCallback(int percent) {
31 31
 Game::Game(const char *level) {
32 32
     mName = bufferString("%s", level);
33 33
 
34
+    // Load the level pak into TombRaider
34 35
     gOpenRaider->mConsole->print("Loading %s", mName);
35 36
     int error = mTombRaider.Load(mName, percentCallbackTrampoline, this);
36 37
     if (error != 0) {
37 38
         throw error;
38 39
     }
40
+
41
+    // If required, load the external sound effect file MAIN.SFX into TombRaider
42
+    if ((mTombRaider.getEngine() == TR_VERSION_2) || (mTombRaider.getEngine() == TR_VERSION_3)) {
43
+        char *tmp = bufferString("%sMAIN.SFX", level); // Ensure theres enough space
44
+        size_t length = strlen(tmp);
45
+        size_t dir = 0;
46
+        for (int i = length - 1; i >= 0; i--) {
47
+            if ((tmp[i] == '/') || (tmp[i] == '\\')) {
48
+                dir = i + 1; // Find where the filename (bla.tr2) starts
49
+                break;
50
+            }
51
+        }
52
+        strcpy(tmp + dir, "MAIN.SFX\0"); // overwrite the name itself with MAIN.SFX
53
+        error = mTombRaider.loadSFX(tmp);
54
+        if (error != 0) {
55
+            gOpenRaider->mConsole->print("Could not load %s", tmp);
56
+        }
57
+        delete [] tmp;
58
+    }
39 59
 }
40 60
 
41 61
 Game::~Game() {

正在加载...
取消
保存