|
@@ -196,6 +196,7 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
|
196
|
196
|
|
197
|
197
|
int OpenRaider::help(const char *cmd) {
|
198
|
198
|
assert(cmd != NULL);
|
|
199
|
+ assert(cmd[0] != '\0');
|
199
|
200
|
|
200
|
201
|
if (strcmp(cmd, "set") == 0) {
|
201
|
202
|
mConsole->print("set-Command Usage:");
|
|
@@ -251,6 +252,9 @@ char *OpenRaider::expandDirectoryNames(const char *s) {
|
251
|
252
|
const char *audio = "$(audiodir)";
|
252
|
253
|
const char *data = "$(datadir)";
|
253
|
254
|
|
|
255
|
+ assert(s != NULL);
|
|
256
|
+ assert(s[0] != '\0');
|
|
257
|
+
|
254
|
258
|
if (mBaseDir != NULL) {
|
255
|
259
|
if (strstr(s, base) != NULL) {
|
256
|
260
|
return stringReplace(s, base, mBaseDir);
|
|
@@ -291,6 +295,11 @@ char *OpenRaider::expandDirectoryNames(const char *s) {
|
291
|
295
|
} while(false)
|
292
|
296
|
|
293
|
297
|
int OpenRaider::set(const char *var, const char *value) {
|
|
298
|
+ assert(var != NULL);
|
|
299
|
+ assert(var[0] != '\0');
|
|
300
|
+ assert(value != NULL);
|
|
301
|
+ assert(value[0] != '\0');
|
|
302
|
+
|
294
|
303
|
if (strcmp(var, "size") == 0) {
|
295
|
304
|
// value has format like "\"1024x768\""
|
296
|
305
|
unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
|
|
@@ -363,6 +372,11 @@ int OpenRaider::set(const char *var, const char *value) {
|
363
|
372
|
}
|
364
|
373
|
|
365
|
374
|
int OpenRaider::bind(const char *action, const char *key) {
|
|
375
|
+ assert(action != NULL);
|
|
376
|
+ assert(action[0] != '\0');
|
|
377
|
+ assert(key != NULL);
|
|
378
|
+ assert(key[0] != '\0');
|
|
379
|
+
|
366
|
380
|
const char *tmp = action;
|
367
|
381
|
if (action[0] == '+')
|
368
|
382
|
tmp++;
|
|
@@ -394,7 +408,7 @@ int OpenRaider::bind(const char *action, const char *key) {
|
394
|
408
|
}
|
395
|
409
|
|
396
|
410
|
int OpenRaider::bind(ActionEvents action, const char *key) {
|
397
|
|
- assert(action != ActionEventCount);
|
|
411
|
+ assert(action < ActionEventCount);
|
398
|
412
|
assert(key != NULL);
|
399
|
413
|
assert(key[0] != '\0');
|
400
|
414
|
|
|
@@ -535,6 +549,11 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
|
535
|
549
|
struct dirent *ep;
|
536
|
550
|
DIR *pakDir;
|
537
|
551
|
|
|
552
|
+ assert(dir != NULL);
|
|
553
|
+ assert(dir[0] != '\0');
|
|
554
|
+ assert(mInit == true);
|
|
555
|
+ assert(mRunning == true);
|
|
556
|
+
|
538
|
557
|
pakDir = opendir(dir);
|
539
|
558
|
if (pakDir != NULL) {
|
540
|
559
|
while ((ep = readdir(pakDir)) != NULL) {
|
|
@@ -579,6 +598,9 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
|
579
|
598
|
}
|
580
|
599
|
|
581
|
600
|
void OpenRaider::fillMapList() {
|
|
601
|
+ assert(mInit == true);
|
|
602
|
+ assert(mRunning == true);
|
|
603
|
+
|
582
|
604
|
char *tmp = fullPath(mPakDir, '/');
|
583
|
605
|
loadPakFolderRecursive(tmp);
|
584
|
606
|
delete [] tmp;
|
|
@@ -657,6 +679,10 @@ void OpenRaider::run() {
|
657
|
679
|
}
|
658
|
680
|
|
659
|
681
|
void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
|
|
682
|
+ assert(key < unknown);
|
|
683
|
+ assert(mInit == true);
|
|
684
|
+ assert(mRunning == true);
|
|
685
|
+
|
660
|
686
|
if ((keyBindings[menuAction] == key) && pressed) {
|
661
|
687
|
mMenu->setVisible(!mMenu->isVisible());
|
662
|
688
|
} else if (!mMenu->isVisible()) {
|
|
@@ -679,12 +705,21 @@ void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
|
679
|
705
|
}
|
680
|
706
|
|
681
|
707
|
void OpenRaider::handleText(char *text, bool notFinished) {
|
|
708
|
+ assert(text != NULL);
|
|
709
|
+ assert(text[0] != '\0');
|
|
710
|
+ assert(mInit == true);
|
|
711
|
+ assert(mRunning == true);
|
|
712
|
+
|
682
|
713
|
if ((mConsole->isVisible()) && (!mMenu->isVisible())) {
|
683
|
714
|
mConsole->handleText(text, notFinished);
|
684
|
715
|
}
|
685
|
716
|
}
|
686
|
717
|
|
687
|
718
|
void OpenRaider::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
|
|
719
|
+ assert(button < unknown);
|
|
720
|
+ assert(mInit == true);
|
|
721
|
+ assert(mRunning == true);
|
|
722
|
+
|
688
|
723
|
if (mMenu->isVisible()) {
|
689
|
724
|
mMenu->handleMouseClick(x, y, button, released);
|
690
|
725
|
} else if (!mConsole->isVisible()) {
|
|
@@ -697,12 +732,20 @@ void OpenRaider::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton
|
697
|
732
|
}
|
698
|
733
|
|
699
|
734
|
void OpenRaider::handleMouseMotion(int xrel, int yrel) {
|
|
735
|
+ assert((xrel != 0) || (yrel != 0));
|
|
736
|
+ assert(mInit == true);
|
|
737
|
+ assert(mRunning == true);
|
|
738
|
+
|
700
|
739
|
if ((!mConsole->isVisible()) && (!mMenu->isVisible())) {
|
701
|
740
|
mGame->handleMouseMotion(xrel, yrel);
|
702
|
741
|
}
|
703
|
742
|
}
|
704
|
743
|
|
705
|
744
|
void OpenRaider::handleMouseScroll(int xrel, int yrel) {
|
|
745
|
+ assert((xrel != 0) || (yrel != 0));
|
|
746
|
+ assert(mInit == true);
|
|
747
|
+ assert(mRunning == true);
|
|
748
|
+
|
706
|
749
|
if ((mConsole->isVisible()) && (!mMenu->isVisible())) {
|
707
|
750
|
mConsole->handleMouseScroll(xrel, yrel);
|
708
|
751
|
}
|