Thomas Buck 10 роки тому
джерело
коміт
f5678a561a
3 змінених файлів з 48 додано та 2 видалено
  1. 2
    0
      src/Game.cpp
  2. 44
    1
      src/OpenRaider.cpp
  3. 2
    1
      src/World.cpp

+ 2
- 0
src/Game.cpp Переглянути файл

86
 
86
 
87
     mRender->ClearWorld();
87
     mRender->ClearWorld();
88
     mWorld.destroy();
88
     mWorld.destroy();
89
+    gOpenRaider->mSound->clear(); // Remove all previously loaded sounds
89
 }
90
 }
90
 
91
 
91
 int Game::loadLevel(const char *level) {
92
 int Game::loadLevel(const char *level) {
140
 
141
 
141
     mLoaded = true;
142
     mLoaded = true;
142
     mRender->setMode(Render::modeVertexLight);
143
     mRender->setMode(Render::modeVertexLight);
144
+
143
     return 0;
145
     return 0;
144
 }
146
 }
145
 
147
 

+ 44
- 1
src/OpenRaider.cpp Переглянути файл

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

+ 2
- 1
src/World.cpp Переглянути файл

6
  */
6
  */
7
 
7
 
8
 #include <math.h>
8
 #include <math.h>
9
+#include <assert.h>
9
 
10
 
10
 #include "World.h"
11
 #include "World.h"
11
 
12
 
204
         return true;
205
         return true;
205
     }
206
     }
206
 
207
 
207
-    return (sector > 0 && sect->wall);
208
+    return ((sector > 0) && sect->wall);
208
 }
209
 }
209
 
210
 
210
 
211
 

Завантаження…
Відмінити
Зберегти