|
@@ -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
|
{
|