Selaa lähdekoodia

Recursively search for level paks

Thomas Buck 10 vuotta sitten
vanhempi
commit
74b9337201
5 muutettua tiedostoa jossa 59 lisäystä ja 60 poistoa
  1. 5
    0
      ChangeLog
  2. 0
    3
      README.md
  3. 1
    30
      data/OpenRaider.init
  4. 2
    0
      include/OpenRaider.h
  5. 51
    27
      src/OpenRaider.cpp

+ 5
- 0
ChangeLog Näytä tiedosto

@@ -5,6 +5,11 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140221 ]
9
+	* Removed the `Map` command. Now the PakDir command causes
10
+	  a recursive search of the specified directory. Every file found
11
+	  is added to the map list if it validates.
12
+
8 13
 	[ 20140216 ]
9 14
 	* Removed the FastCard option. Not necessary on todays hardware?!
10 15
 	* Removed UNICODE_SUPPORT, not working this way with SDL2

+ 0
- 3
README.md Näytä tiedosto

@@ -82,9 +82,6 @@ The configuration file format is very simple:
82 82
 You can use paks from any Tomb Raider version supported and most user made paks for Tomb Raider.
83 83
 Only PHD, TR1, TR2, TR3, and TR4 paks are supported as of this writing.
84 84
 
85
-Edit 'Map' lines in your OpenRaider.init as needed.
86
-I suggest removing all your Map=... lines to begin with, since no maps are bundled with this release.
87
-
88 85
 ### Sound FXs
89 86
 
90 87
 Setting up external sound SFX, for TR2 and TR3 paks only.

+ 1
- 30
data/OpenRaider.init Näytä tiedosto

@@ -30,40 +30,11 @@ DisplayFPS=false
30 30
 MapDebug=false
31 31
 ModelDebug=false
32 32
 DumpTexture=false
33
+
33 34
 #Script=tr3/tombPC.dat
34 35
 #Music=tr4/039_TR4_Title_Q10.wav
35 36
 #Music=tr4/103_A3_Out_Night.wav
36 37
 #Music=tr4/108_A8_Coastal.wav
37
-#Map=custom/Yvel.tr2
38
-#Map=custom/villa2.phd
39
-#Map=custom/fenician1.phd
40
-#Map=custom/1984.tr2
41
-#Map=custom/bigchamber.tr4
42
-#Map=custom/cleopal.tr4
43
-#Map=custom/khysos.tr4
44
-#Map=custom/Nasa.tr2
45
-#Map=custom/mansionfrost.tr2
46
-#Map=tr1/gym.phd
47
-#Map=tr1/level1.phd
48
-#Map=tr1/level2.phd
49
-#Map=tr2/unwater.tr2
50
-#Map=tr3/willsden.tr2
51
-#Map=tr3/undersea.tr2
52
-#Map=tr3/scotland.tr2
53
-#Map=tr3/HOUSE.TR2
54
-#Map=tr3/zoo.tr2
55
-#Map=tr3/slinc.tr2
56
-#Map=tr3/temple.tr2
57
-#Map=tr3/shore.tr2
58
-#Map=tr3/chunnel.tr2
59
-#Map=tr4/angkor1.tr4
60
-#Map=tr4/ang_race.tr4
61
-#Map=tr4/karnak1.tr4
62
-#Map=tr4/lake.tr4
63
-#Map=tr4/settomb1.tr4
64
-#Map=tr4/settomb2.tr4
65
-#Map=tr4/title.tr4
66
-#Map=tr5/demo.trc
67 38
 
68 39
 [OpenRaider.Console]
69 40
 bind +console 96

+ 2
- 0
include/OpenRaider.h Näytä tiedosto

@@ -197,6 +197,8 @@ private:
197 197
      */
198 198
     void loadLevel(char *filename);
199 199
 
200
+    void loadPakFolderRecursive(const char *dir);
201
+
200 202
     static OpenRaider *mInstance; //!< Singleton use
201 203
     TombRaider m_tombraider;      //!< Tombraider data support
202 204
     Sound mSound;                 //!< 3d Audio support

+ 51
- 27
src/OpenRaider.cpp Näytä tiedosto

@@ -12,6 +12,7 @@
12 12
 #include <unistd.h>
13 13
 #include <math.h>
14 14
 #include <sys/types.h>
15
+#include <dirent.h>
15 16
 
16 17
 #ifdef DEBUG_MEMORY
17 18
 #include <memory_test.h>
@@ -3332,6 +3333,51 @@ void OpenRaider::consoleCommand(char *cmd)
3332 3333
 }
3333 3334
 
3334 3335
 
3336
+void OpenRaider::loadPakFolderRecursive(const char *dir) {
3337
+    struct dirent *ep;
3338
+    DIR *pakDir;
3339
+
3340
+    pakDir = opendir(dir);
3341
+    if (pakDir != NULL) {
3342
+        while ((ep = readdir(pakDir)) != NULL) {
3343
+            if (ep->d_type == DT_DIR) {
3344
+                if ((strcmp(".", ep->d_name) != 0)
3345
+                 && (strcmp("..", ep->d_name) != 0)) {
3346
+                    char *tmp = bufferString("%s%s", dir, ep->d_name);
3347
+                    char *next = fullPath(tmp, '/');
3348
+                    loadPakFolderRecursive(next);
3349
+                    delete next;
3350
+                    delete tmp;
3351
+                }
3352
+            } else {
3353
+                /*!
3354
+                 * \fixme Currently just tries to validate every file
3355
+                 * in the pak folders. Should check the exstension to
3356
+                 * see if it could be a level pak...
3357
+                 */
3358
+
3359
+                char *fullPathMap = bufferString("%s%s", dir, ep->d_name);
3360
+
3361
+                if (m_tombraider.checkMime(fullPathMap) == 0) {
3362
+                    printf("Validated pak: '%s'\n", fullPathMap);
3363
+                    delete [] fullPathMap;
3364
+
3365
+                    // Just load relative filename
3366
+                    mMapList.pushBack(bufferString("%s", (fullPathMap + strlen(m_pakDir))));
3367
+                } else {
3368
+                    printf("ERROR: pak file '%s' not found or invalid\n", fullPathMap);
3369
+
3370
+                    delete [] fullPathMap;
3371
+                }
3372
+            }
3373
+        }
3374
+        closedir(pakDir);
3375
+    } else {
3376
+        printf("Could not open PAK dir %s!\n", dir);
3377
+    }
3378
+}
3379
+
3380
+
3335 3381
 void OpenRaider::handleCommand(char *cmd, unsigned int mode)
3336 3382
 {
3337 3383
     bool b;
@@ -3405,6 +3451,11 @@ void OpenRaider::handleCommand(char *cmd, unsigned int mode)
3405 3451
                 }
3406 3452
 
3407 3453
                 m_pakDir = fullPath(cmd, '/');
3454
+
3455
+                // Recursively search for level paks instead of
3456
+                // naming individual levels 2014-02-21 xythobuz
3457
+
3458
+                loadPakFolderRecursive(m_pakDir);
3408 3459
             }
3409 3460
             else if (rc_command("HomeDir", cmd))
3410 3461
             {
@@ -3437,33 +3488,6 @@ void OpenRaider::handleCommand(char *cmd, unsigned int mode)
3437 3488
                     m_flags ^= OpenRaider_DebugMap;
3438 3489
                 }
3439 3490
             }
3440
-            else if (rc_command("Map", cmd))
3441
-            {
3442
-                if (cmd[0])
3443
-                {
3444
-                    char *fullPathMap;
3445
-
3446
-
3447
-                    fullPathMap = bufferString("%s%s", m_pakDir, cmd);
3448
-
3449
-                    if (m_tombraider.checkMime(fullPathMap) == 0)
3450
-                    {
3451
-                        printf("Validated pak: '%s'\n",
3452
-                                fullPathMap);
3453
-                        delete [] fullPathMap;
3454
-
3455
-                        /* Just load relative filename */
3456
-                        mMapList.pushBack(bufferString("%s", cmd));
3457
-                    }
3458
-                    else
3459
-                    {
3460
-                        printf("ERROR: pak file '%s' not found or invalid\n",
3461
-                                fullPathMap);
3462
-
3463
-                        delete [] fullPathMap;
3464
-                    }
3465
-                }
3466
-            }
3467 3491
             // Mongoose 2001.12.31, Added music list back
3468 3492
             else if (rc_command("Music", cmd))
3469 3493
             {

Loading…
Peruuta
Tallenna