|
@@ -25,7 +25,6 @@
|
25
|
25
|
#include "OpenRaider.h"
|
26
|
26
|
|
27
|
27
|
OpenRaider::OpenRaider() {
|
28
|
|
- mInit = false;
|
29
|
28
|
mRunning = false;
|
30
|
29
|
mFPS = false;
|
31
|
30
|
mBaseDir = NULL;
|
|
@@ -34,8 +33,6 @@ OpenRaider::OpenRaider() {
|
34
|
33
|
mDataDir = NULL;
|
35
|
34
|
mMapListFilled = false;
|
36
|
35
|
|
37
|
|
- mSound = new Sound();
|
38
|
|
-
|
39
|
36
|
for (int i = 0; i < ActionEventCount; i++)
|
40
|
37
|
keyBindings[i] = unknown;
|
41
|
38
|
|
|
@@ -44,9 +41,6 @@ OpenRaider::OpenRaider() {
|
44
|
41
|
}
|
45
|
42
|
|
46
|
43
|
OpenRaider::~OpenRaider() {
|
47
|
|
- if (mSound)
|
48
|
|
- delete mSound;
|
49
|
|
-
|
50
|
44
|
if (mBaseDir)
|
51
|
45
|
delete mBaseDir;
|
52
|
46
|
|
|
@@ -307,14 +301,14 @@ int OpenRaider::set(const char *var, const char *value) {
|
307
|
301
|
getConsole().print("set-audio-Error: Invalid value (%s)", value);
|
308
|
302
|
return -4;
|
309
|
303
|
}
|
310
|
|
- mSound->setEnabled(audio);
|
|
304
|
+ getSound().setEnabled(audio);
|
311
|
305
|
} else if (strcmp(var, "volume") == 0) {
|
312
|
306
|
float vol = 1.0f;
|
313
|
307
|
if (sscanf(value, "%f", &vol) != 1) {
|
314
|
308
|
getConsole().print("set-volume-Error: Invalid value (%s)", value);
|
315
|
309
|
return -5;
|
316
|
310
|
}
|
317
|
|
- mSound->setVolume(vol);
|
|
311
|
+ getSound().setVolume(vol);
|
318
|
312
|
} else if (strcmp(var, "mouse_x") == 0) {
|
319
|
313
|
float sense = 1.0f;
|
320
|
314
|
if (sscanf(value, "%f", &sense) != 1) {
|
|
@@ -542,7 +536,6 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
|
542
|
536
|
|
543
|
537
|
assert(dir != NULL);
|
544
|
538
|
assert(dir[0] != '\0');
|
545
|
|
- assert(mInit == true);
|
546
|
539
|
assert(mRunning == true);
|
547
|
540
|
|
548
|
541
|
pakDir = opendir(dir);
|
|
@@ -589,7 +582,6 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
|
589
|
582
|
}
|
590
|
583
|
|
591
|
584
|
void OpenRaider::fillMapList() {
|
592
|
|
- assert(mInit == true);
|
593
|
585
|
assert(mRunning == true);
|
594
|
586
|
|
595
|
587
|
char *tmp = fullPath(mPakDir, '/');
|
|
@@ -598,21 +590,7 @@ void OpenRaider::fillMapList() {
|
598
|
590
|
mMapListFilled = true;
|
599
|
591
|
}
|
600
|
592
|
|
601
|
|
-int OpenRaider::initialize() {
|
602
|
|
- assert(mInit == false);
|
603
|
|
- assert(mRunning == false);
|
604
|
|
-
|
605
|
|
- // Initialize sound
|
606
|
|
- if (mSound->initialize() != 0)
|
607
|
|
- return -1;
|
608
|
|
-
|
609
|
|
- mInit = true;
|
610
|
|
-
|
611
|
|
- return 0;
|
612
|
|
-}
|
613
|
|
-
|
614
|
593
|
void OpenRaider::run() {
|
615
|
|
- assert(mInit == true);
|
616
|
594
|
assert(mRunning == false);
|
617
|
595
|
|
618
|
596
|
static clock_t fpsSum = 0, fpsCount = 0;
|
|
@@ -665,7 +643,6 @@ void OpenRaider::run() {
|
665
|
643
|
|
666
|
644
|
void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
|
667
|
645
|
assert(key < unknown);
|
668
|
|
- assert(mInit == true);
|
669
|
646
|
assert(mRunning == true);
|
670
|
647
|
|
671
|
648
|
if ((keyBindings[menuAction] == key) && pressed) {
|
|
@@ -692,7 +669,6 @@ void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
|
692
|
669
|
void OpenRaider::handleText(char *text, bool notFinished) {
|
693
|
670
|
assert(text != NULL);
|
694
|
671
|
assert(text[0] != '\0');
|
695
|
|
- assert(mInit == true);
|
696
|
672
|
assert(mRunning == true);
|
697
|
673
|
|
698
|
674
|
if ((getConsole().isVisible()) && (!getMenu().isVisible())) {
|
|
@@ -702,7 +678,6 @@ void OpenRaider::handleText(char *text, bool notFinished) {
|
702
|
678
|
|
703
|
679
|
void OpenRaider::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
|
704
|
680
|
assert(button < unknown);
|
705
|
|
- assert(mInit == true);
|
706
|
681
|
assert(mRunning == true);
|
707
|
682
|
|
708
|
683
|
if (getMenu().isVisible()) {
|
|
@@ -718,7 +693,6 @@ void OpenRaider::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton
|
718
|
693
|
|
719
|
694
|
void OpenRaider::handleMouseMotion(int xrel, int yrel) {
|
720
|
695
|
assert((xrel != 0) || (yrel != 0));
|
721
|
|
- assert(mInit == true);
|
722
|
696
|
assert(mRunning == true);
|
723
|
697
|
|
724
|
698
|
if ((!getConsole().isVisible()) && (!getMenu().isVisible())) {
|
|
@@ -728,7 +702,6 @@ void OpenRaider::handleMouseMotion(int xrel, int yrel) {
|
728
|
702
|
|
729
|
703
|
void OpenRaider::handleMouseScroll(int xrel, int yrel) {
|
730
|
704
|
assert((xrel != 0) || (yrel != 0));
|
731
|
|
- assert(mInit == true);
|
732
|
705
|
assert(mRunning == true);
|
733
|
706
|
|
734
|
707
|
if ((getConsole().isVisible()) && (!getMenu().isVisible())) {
|