Browse Source

Many small fixes

Thomas Buck 10 years ago
parent
commit
5032172fee
13 changed files with 229 additions and 221 deletions
  1. 1
    1
      include/Config.h.in
  2. 10
    0
      include/Window.h
  3. 21
    39
      include/global.h
  4. 4
    4
      src/Console.cpp
  5. 2
    0
      src/Game.cpp
  6. 8
    8
      src/Menu.cpp
  7. 72
    69
      src/OpenRaider.cpp
  8. 2
    2
      src/Render.cpp
  9. 0
    1
      src/Texture.cpp
  10. 7
    0
      src/TombRaider.cpp
  11. 90
    90
      src/WindowSDL.cpp
  12. 9
    4
      src/main.cpp
  13. 3
    3
      src/utils/strings.cpp

+ 1
- 1
include/Config.h.in View File

@@ -1,7 +1,7 @@
1 1
 #define VERSION "OpenRaider-@OpenRaider_VERSION_MAJOR@.@OpenRaider_VERSION_MINOR@.@OpenRaider_VERSION_MICRO@@OpenRaider_VERSION_RELEASE@ (@CMAKE_BUILD_TYPE@)"
2 2
 #define BUILD_HOST "@OpenRaider_BUILD_HOST@ @OpenRaider_HOSTNAME@"
3 3
 
4
-#define DEFAULT_CONFIG_PATH "~/.OpenRaider/"
4
+#define DEFAULT_CONFIG_PATH "~/.OpenRaider"
5 5
 #define DEFAULT_CONFIG_FILE "OpenRaider.ini"
6 6
 #define DEFAULT_WIDTH 640
7 7
 #define DEFAULT_HEIGHT 480

+ 10
- 0
include/Window.h View File

@@ -12,6 +12,16 @@
12 12
 
13 13
 #include "global.h"
14 14
 
15
+typedef struct {
16
+    char *text;
17
+    unsigned int x;
18
+    unsigned int y;
19
+    int w;
20
+    int h;
21
+    float scale;
22
+    float color[4];
23
+} WindowString;
24
+
15 25
 /*!
16 26
  * \brief Windowing interface
17 27
  */

+ 21
- 39
include/global.h View File

@@ -34,46 +34,28 @@ typedef enum {
34 34
 } ActionEvents;
35 35
 
36 36
 typedef enum {
37
-    zero = '0', one = '1',
38
-    two = '2', three = '3',
39
-    four = '4', five = '5',
40
-    six = '6', seven = '7',
41
-    eight = '8', nine = '9',
42
-    a = 'a', b = 'b',
43
-    c = 'c', d = 'd',
44
-    e = 'e', f = 'f',
45
-    g = 'g', h = 'h',
46
-    i = 'i', j = 'j',
47
-    k = 'k', l = 'l',
48
-    m = 'm', n = 'n',
49
-    o = 'o', p = 'p',
50
-    q = 'q', r = 'r',
51
-    s = 's', t = 't',
52
-    u = 'u', v = 'v',
53
-    w = 'w', x = 'x',
54
-    y = 'y', z = 'z',
55
-    quote, backslash, backspace, capslock,
56
-    comma, del, up, down, left, right,
57
-    end, equals, escape, f1, f2, f3, f4, f5,
58
-    f6, f7, f8, f9, f10, f11, f12, backquote,
59
-    home, insert, leftalt, leftctrl, leftbracket,
60
-    leftgui, leftshift, minus, numlock, pagedown,
61
-    pageup, pause, dot, rightalt, rightctrl, enter,
62
-    rightgui, rightbracket, rightshift, scrolllock,
63
-    semicolon, slash, space, tab,
64
-    leftmouse, middlemouse, rightmouse,
65
-    unknown
37
+    zeroKey = '0', oneKey = '1', twoKey = '2',
38
+    threeKey = '3', fourKey = '4', fiveKey = '5',
39
+    sixKey = '6', sevenKey = '7', eightKey = '8',
40
+    nineKey = '9', aKey = 'a', bKey = 'b',
41
+    cKey = 'c', dKey = 'd', eKey = 'e', fKey = 'f',
42
+    gKey = 'g', hKey = 'h', iKey = 'i', jKey = 'j',
43
+    kKey = 'k', lKey = 'l', mKey = 'm', nKey = 'n',
44
+    oKey = 'o', pKey = 'p', qKey = 'q', rKey = 'r',
45
+    sKey = 's', tKey = 't', uKey = 'u', vKey = 'v',
46
+    wKey = 'w', xKey = 'x', yKey = 'y', zKey = 'z',
47
+    quoteKey, backslashKey, backspaceKey, capslockKey,
48
+    commaKey, delKey, upKey, downKey, leftKey, rightKey,
49
+    endKey, equalsKey, escapeKey, f1Key, f2Key, f3Key, f4Key, f5Key,
50
+    f6Key, f7Key, f8Key, f9Key, f10Key, f11Key, f12Key, backquoteKey,
51
+    homeKey, insertKey, leftaltKey, leftctrlKey, leftbracketKey,
52
+    leftguiKey, leftshiftKey, minusKey, numlockKey, pagedownKey,
53
+    pageupKey, pauseKey, dotKey, rightaltKey, rightctrlKey, enterKey,
54
+    rightguiKey, rightbracketKey, rightshiftKey, scrolllockKey,
55
+    semicolonKey, slashKey, spaceKey, tabKey,
56
+    leftmouseKey, middlemouseKey, rightmouseKey,
57
+    unknownKey
66 58
 } KeyboardButton;
67 59
 
68
-typedef struct {
69
-    char *text;
70
-    unsigned int x;
71
-    unsigned int y;
72
-    int w;
73
-    int h;
74
-    float scale;
75
-    float color[4];
76
-} WindowString;
77
-
78 60
 #endif
79 61
 

+ 4
- 4
src/Console.cpp View File

@@ -138,7 +138,7 @@ void Console::display() {
138 138
 }
139 139
 
140 140
 void Console::handleKeyboard(KeyboardButton key, bool pressed) {
141
-    if (pressed && (key == enter)) {
141
+    if (pressed && (key == enterKey)) {
142 142
         // Execute entered command
143 143
         if ((mInputBufferPointer > 0) && (mInputBuffer[0] != '\0')) {
144 144
             print("> %s", mInputBuffer);
@@ -163,15 +163,15 @@ void Console::handleKeyboard(KeyboardButton key, bool pressed) {
163 163
     }
164 164
 
165 165
     //! \fixme only deleting the last byte is not valid for non-ASCII UTF-8 strings
166
-    if (pressed && (key == backspace)) {
166
+    if (pressed && (key == backspaceKey)) {
167 167
         if (mInputBufferPointer > 0) {
168 168
             mInputBufferPointer--;
169 169
             mInputBuffer[mInputBufferPointer] = '\0';
170 170
         }
171 171
     }
172 172
 
173
-    if (pressed && ((key == up) || (key == down))) {
174
-        moveInHistory(key == up);
173
+    if (pressed && ((key == upKey) || (key == downKey))) {
174
+        moveInHistory(key == upKey);
175 175
     }
176 176
 }
177 177
 

+ 2
- 0
src/Game.cpp View File

@@ -623,6 +623,8 @@ void Game::processMoveable(int index, int i, int *ent,
623 623
     if (a < 0)
624 624
     {
625 625
         //continue;
626
+        getConsole().print("Invalid animation data for model %d", index);
627
+        delete r_model;
626 628
         return;
627 629
     }
628 630
 

+ 8
- 8
src/Menu.cpp View File

@@ -116,29 +116,29 @@ void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
116 116
     if (!pressed)
117 117
         return;
118 118
 
119
-    if (key == up) {
119
+    if (key == upKey) {
120 120
         if (mCursor > 0)
121 121
             mCursor--;
122 122
         else
123 123
             mCursor = getOpenRaider().mMapList.size() - 1;
124
-    } else if (key == down) {
124
+    } else if (key == downKey) {
125 125
         if (mCursor < (getOpenRaider().mMapList.size() - 1))
126 126
             mCursor++;
127 127
         else
128 128
             mCursor = 0;
129
-    } else if (key == right) {
129
+    } else if (key == rightKey) {
130 130
         int i = 10;
131 131
         if (mCursor > (getOpenRaider().mMapList.size() - 11))
132 132
             i = getOpenRaider().mMapList.size() - 1 - mCursor;
133 133
         while (i-- > 0)
134
-            handleKeyboard(down, true);
135
-    } else if (key == left) {
134
+            handleKeyboard(downKey, true);
135
+    } else if (key == leftKey) {
136 136
         int i = 10;
137 137
         if (mCursor < 10)
138 138
             i = mCursor;
139 139
         while (i-- > 0)
140
-            handleKeyboard(up, true);
141
-    } else if (key == enter) {
140
+            handleKeyboard(upKey, true);
141
+    } else if (key == enterKey) {
142 142
         char *tmp = bufferString("load %s", getOpenRaider().mMapList[mCursor]);
143 143
         if (getOpenRaider().command(tmp) == 0) {
144 144
             setVisible(false);
@@ -152,7 +152,7 @@ void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
152 152
 void Menu::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
153 153
     int items = (getWindow().mHeight - 110) / 25;
154 154
 
155
-    if ((!released) || (button != leftmouse))
155
+    if ((!released) || (button != leftmouseKey))
156 156
         return;
157 157
 
158 158
     if ((y >= 100) && (y <= (unsigned int)(100 + (25 * items)))) {

+ 72
- 69
src/OpenRaider.cpp View File

@@ -34,7 +34,7 @@ OpenRaider::OpenRaider() {
34 34
     mMapListFilled = false;
35 35
 
36 36
     for (int i = 0; i < ActionEventCount; i++)
37
-        keyBindings[i] = unknown;
37
+        keyBindings[i] = unknownKey;
38 38
 }
39 39
 
40 40
 OpenRaider::~OpenRaider() {
@@ -98,13 +98,14 @@ int OpenRaider::command(const char *command) {
98 98
         }
99 99
     }
100 100
 
101
-    char *token = strtok(cmd, " \t");
101
+    char *strtokState;
102
+    char *token = strtok_r(cmd, " \t", &strtokState);
102 103
     if (token != NULL) {
103 104
         // token is the command to execute
104 105
         // get arguments
105 106
         std::vector<char *> args;
106 107
         char *next;
107
-        while ((next = strtok(NULL, " \t")) != NULL) {
108
+        while ((next = strtok_r(NULL, " \t", &strtokState)) != NULL) {
108 109
             args.push_back(next);
109 110
         }
110 111
 
@@ -725,33 +726,32 @@ int OpenRaider::help(const char *cmd) {
725 726
 }
726 727
 
727 728
 char *OpenRaider::expandDirectoryNames(const char *s) {
728
-    const char *base = "$(basedir)";
729
-    const char *pak = "$(pakdir)";
730
-    const char *audio = "$(audiodir)";
731
-    const char *data = "$(datadir)";
732
-
733 729
     assert(s != NULL);
734 730
     assert(s[0] != '\0');
735 731
 
736 732
     if (mBaseDir != NULL) {
733
+        const char *base = "$(basedir)";
737 734
         if (strstr(s, base) != NULL) {
738 735
             return stringReplace(s, base, mBaseDir);
739 736
         }
740 737
     }
741 738
 
742 739
     if (mPakDir != NULL) {
740
+        const char *pak = "$(pakdir)";
743 741
         if (strstr(s, pak) != NULL) {
744 742
             return stringReplace(s, pak, mPakDir);
745 743
         }
746 744
     }
747 745
 
748 746
     if (mAudioDir != NULL) {
747
+        const char *audio = "$(audiodir)";
749 748
         if (strstr(s, audio) != NULL) {
750 749
             return stringReplace(s, audio, mAudioDir);
751 750
         }
752 751
     }
753 752
 
754 753
     if (mDataDir != NULL) {
754
+        const char *data = "$(datadir)";
755 755
         if (strstr(s, data) != NULL) {
756 756
             return stringReplace(s, data, mDataDir);
757 757
         }
@@ -781,7 +781,7 @@ int OpenRaider::set(const char *var, const char *value) {
781 781
     if (strcmp(var, "size") == 0) {
782 782
         // value has format like "\"1024x768\""
783 783
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
784
-        if (sscanf(value, "\"%dx%d\"", &w, &h) != 2) {
784
+        if (sscanf(value, "\"%5dx%5d\"", &w, &h) != 2) {
785 785
             getConsole().print("set-size-Error: Invalid value (%s)", value);
786 786
             return -2;
787 787
         }
@@ -804,21 +804,21 @@ int OpenRaider::set(const char *var, const char *value) {
804 804
         getSound().setEnabled(audio);
805 805
     } else if (strcmp(var, "volume") == 0) {
806 806
         float vol = 1.0f;
807
-        if (sscanf(value, "%f", &vol) != 1) {
807
+        if (sscanf(value, "%5f", &vol) != 1) {
808 808
             getConsole().print("set-volume-Error: Invalid value (%s)", value);
809 809
             return -5;
810 810
         }
811 811
         getSound().setVolume(vol);
812 812
     } else if (strcmp(var, "mouse_x") == 0) {
813 813
         float sense = 1.0f;
814
-        if (sscanf(value, "%f", &sense) != 1) {
814
+        if (sscanf(value, "%5f", &sense) != 1) {
815 815
             getConsole().print("set-mouse_x-Error: Invalid value (%s)", value);
816 816
             return -6;
817 817
         }
818 818
         getCamera().setSensitivityX(OR_DEG_TO_RAD(sense));
819 819
     } else if (strcmp(var, "mouse_y") == 0) {
820 820
         float sense = 1.0f;
821
-        if (sscanf(value, "%f", &sense) != 1) {
821
+        if (sscanf(value, "%5f", &sense) != 1) {
822 822
             getConsole().print("set-mouse_y-Error: Invalid value (%s)", value);
823 823
             return -7;
824 824
         }
@@ -912,111 +912,111 @@ int OpenRaider::bind(ActionEvents action, const char *key) {
912 912
         // Special characters like tilde, esc, quote...
913 913
         char *tmp = stringRemoveQuotes(key);
914 914
         if (strcmp(tmp, "quote") == 0) {
915
-            keyBindings[action] = quote;
915
+            keyBindings[action] = quoteKey;
916 916
         } else if (strcmp(tmp, "backslash") == 0) {
917
-            keyBindings[action] = quote;
917
+            keyBindings[action] = backslashKey;
918 918
         } else if (strcmp(tmp, "backspace") == 0) {
919
-            keyBindings[action] = backspace;
919
+            keyBindings[action] = backspaceKey;
920 920
         } else if (strcmp(tmp, "capslock") == 0) {
921
-            keyBindings[action] = capslock;
921
+            keyBindings[action] = capslockKey;
922 922
         } else if (strcmp(tmp, "comma") == 0) {
923
-            keyBindings[action] = comma;
923
+            keyBindings[action] = commaKey;
924 924
         } else if (strcmp(tmp, "del") == 0) {
925
-            keyBindings[action] = del;
925
+            keyBindings[action] = delKey;
926 926
         } else if (strcmp(tmp, "up") == 0) {
927
-            keyBindings[action] = up;
927
+            keyBindings[action] = upKey;
928 928
         } else if (strcmp(tmp, "down") == 0) {
929
-            keyBindings[action] = down;
929
+            keyBindings[action] = downKey;
930 930
         } else if (strcmp(tmp, "left") == 0) {
931
-            keyBindings[action] = left;
931
+            keyBindings[action] = leftKey;
932 932
         } else if (strcmp(tmp, "right") == 0) {
933
-            keyBindings[action] = right;
933
+            keyBindings[action] = rightKey;
934 934
         } else if (strcmp(tmp, "end") == 0) {
935
-            keyBindings[action] = end;
935
+            keyBindings[action] = endKey;
936 936
         } else if (strcmp(tmp, "equals") == 0) {
937
-            keyBindings[action] = equals;
937
+            keyBindings[action] = equalsKey;
938 938
         } else if (strcmp(tmp, "escape") == 0) {
939
-            keyBindings[action] = escape;
939
+            keyBindings[action] = escapeKey;
940 940
         } else if (strcmp(tmp, "f1") == 0) {
941
-            keyBindings[action] = f1;
941
+            keyBindings[action] = f1Key;
942 942
         } else if (strcmp(tmp, "f2") == 0) {
943
-            keyBindings[action] = f2;
943
+            keyBindings[action] = f2Key;
944 944
         } else if (strcmp(tmp, "f3") == 0) {
945
-            keyBindings[action] = f3;
945
+            keyBindings[action] = f3Key;
946 946
         } else if (strcmp(tmp, "f4") == 0) {
947
-            keyBindings[action] = f4;
947
+            keyBindings[action] = f4Key;
948 948
         } else if (strcmp(tmp, "f5") == 0) {
949
-            keyBindings[action] = f5;
949
+            keyBindings[action] = f5Key;
950 950
         } else if (strcmp(tmp, "f6") == 0) {
951
-            keyBindings[action] = f6;
951
+            keyBindings[action] = f6Key;
952 952
         } else if (strcmp(tmp, "f7") == 0) {
953
-            keyBindings[action] = f7;
953
+            keyBindings[action] = f7Key;
954 954
         } else if (strcmp(tmp, "f8") == 0) {
955
-            keyBindings[action] = f8;
955
+            keyBindings[action] = f8Key;
956 956
         } else if (strcmp(tmp, "f9") == 0) {
957
-            keyBindings[action] = f9;
957
+            keyBindings[action] = f9Key;
958 958
         } else if (strcmp(tmp, "f10") == 0) {
959
-            keyBindings[action] = f10;
959
+            keyBindings[action] = f10Key;
960 960
         } else if (strcmp(tmp, "f11") == 0) {
961
-            keyBindings[action] = f11;
961
+            keyBindings[action] = f11Key;
962 962
         } else if (strcmp(tmp, "f12") == 0) {
963
-            keyBindings[action] = f12;
963
+            keyBindings[action] = f12Key;
964 964
         } else if (strcmp(tmp, "backquote") == 0) {
965
-            keyBindings[action] = backquote;
965
+            keyBindings[action] = backquoteKey;
966 966
         } else if (strcmp(tmp, "home") == 0) {
967
-            keyBindings[action] = home;
967
+            keyBindings[action] = homeKey;
968 968
         } else if (strcmp(tmp, "insert") == 0) {
969
-            keyBindings[action] = insert;
969
+            keyBindings[action] = insertKey;
970 970
         } else if (strcmp(tmp, "leftalt") == 0) {
971
-            keyBindings[action] = leftalt;
971
+            keyBindings[action] = leftaltKey;
972 972
         } else if (strcmp(tmp, "leftctrl") == 0) {
973
-            keyBindings[action] = leftctrl;
973
+            keyBindings[action] = leftctrlKey;
974 974
         } else if (strcmp(tmp, "leftbracket") == 0) {
975
-            keyBindings[action] = leftbracket;
975
+            keyBindings[action] = leftbracketKey;
976 976
         } else if (strcmp(tmp, "leftgui") == 0) {
977
-            keyBindings[action] = leftgui;
977
+            keyBindings[action] = leftguiKey;
978 978
         } else if (strcmp(tmp, "leftshift") == 0) {
979
-            keyBindings[action] = leftshift;
979
+            keyBindings[action] = leftshiftKey;
980 980
         } else if (strcmp(tmp, "minus") == 0) {
981
-            keyBindings[action] = minus;
981
+            keyBindings[action] = minusKey;
982 982
         } else if (strcmp(tmp, "numlock") == 0) {
983
-            keyBindings[action] = numlock;
983
+            keyBindings[action] = numlockKey;
984 984
         } else if (strcmp(tmp, "pagedown") == 0) {
985
-            keyBindings[action] = pagedown;
985
+            keyBindings[action] = pagedownKey;
986 986
         } else if (strcmp(tmp, "pageup") == 0) {
987
-            keyBindings[action] = pageup;
987
+            keyBindings[action] = pageupKey;
988 988
         } else if (strcmp(tmp, "pause") == 0) {
989
-            keyBindings[action] = pause;
989
+            keyBindings[action] = pauseKey;
990 990
         } else if (strcmp(tmp, "dot") == 0) {
991
-            keyBindings[action] = dot;
991
+            keyBindings[action] = dotKey;
992 992
         } else if (strcmp(tmp, "rightalt") == 0) {
993
-            keyBindings[action] = rightalt;
993
+            keyBindings[action] = rightaltKey;
994 994
         } else if (strcmp(tmp, "rightctrl") == 0) {
995
-            keyBindings[action] = rightctrl;
995
+            keyBindings[action] = rightctrlKey;
996 996
         } else if (strcmp(tmp, "enter") == 0) {
997
-            keyBindings[action] = enter;
997
+            keyBindings[action] = enterKey;
998 998
         } else if (strcmp(tmp, "rightgui") == 0) {
999
-            keyBindings[action] = rightgui;
999
+            keyBindings[action] = rightguiKey;
1000 1000
         } else if (strcmp(tmp, "rightbracket") == 0) {
1001
-            keyBindings[action] = rightbracket;
1001
+            keyBindings[action] = rightbracketKey;
1002 1002
         } else if (strcmp(tmp, "rightshift") == 0) {
1003
-            keyBindings[action] = rightshift;
1003
+            keyBindings[action] = rightshiftKey;
1004 1004
         } else if (strcmp(tmp, "scrolllock") == 0) {
1005
-            keyBindings[action] = scrolllock;
1005
+            keyBindings[action] = scrolllockKey;
1006 1006
         } else if (strcmp(tmp, "semicolon") == 0) {
1007
-            keyBindings[action] = semicolon;
1007
+            keyBindings[action] = semicolonKey;
1008 1008
         } else if (strcmp(tmp, "slash") == 0) {
1009
-            keyBindings[action] = slash;
1009
+            keyBindings[action] = slashKey;
1010 1010
         } else if (strcmp(tmp, "space") == 0) {
1011
-            keyBindings[action] = space;
1011
+            keyBindings[action] = spaceKey;
1012 1012
         } else if (strcmp(tmp, "tab") == 0) {
1013
-            keyBindings[action] = tab;
1013
+            keyBindings[action] = tabKey;
1014 1014
         } else if (strcmp(tmp, "leftmouse") == 0) {
1015
-            keyBindings[action] = leftmouse;
1015
+            keyBindings[action] = leftmouseKey;
1016 1016
         } else if (strcmp(tmp, "middlemouse") == 0) {
1017
-            keyBindings[action] = middlemouse;
1017
+            keyBindings[action] = middlemouseKey;
1018 1018
         } else if (strcmp(tmp, "rightmouse") == 0) {
1019
-            keyBindings[action] = rightmouse;
1019
+            keyBindings[action] = rightmouseKey;
1020 1020
         } else {
1021 1021
             getConsole().print("bind-\"\"-Error: Unknown key (%s)", key);
1022 1022
             delete [] tmp;
@@ -1031,7 +1031,8 @@ int OpenRaider::bind(ActionEvents action, const char *key) {
1031 1031
 }
1032 1032
 
1033 1033
 void OpenRaider::loadPakFolderRecursive(const char *dir) {
1034
-    struct dirent *ep;
1034
+    struct dirent entry;
1035
+    struct dirent *ep = NULL;
1035 1036
     DIR *pakDir;
1036 1037
 
1037 1038
     assert(dir != NULL);
@@ -1040,7 +1041,8 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
1040 1041
 
1041 1042
     pakDir = opendir(dir);
1042 1043
     if (pakDir != NULL) {
1043
-        while ((ep = readdir(pakDir)) != NULL) {
1044
+        readdir_r(pakDir, &entry, &ep);
1045
+        while (ep != NULL) {
1044 1046
             if (ep->d_type == DT_DIR) {
1045 1047
                 if ((strcmp(".", ep->d_name) != 0)
1046 1048
                  && (strcmp("..", ep->d_name) != 0)) {
@@ -1074,6 +1076,7 @@ void OpenRaider::loadPakFolderRecursive(const char *dir) {
1074 1076
                 delete [] lowerPath;
1075 1077
                 delete [] fullPathMap;
1076 1078
             }
1079
+            readdir_r(pakDir, &entry, &ep);
1077 1080
         }
1078 1081
         closedir(pakDir);
1079 1082
     } else {
@@ -1147,7 +1150,7 @@ void OpenRaider::frame() {
1147 1150
 }
1148 1151
 
1149 1152
 void OpenRaider::handleKeyboard(KeyboardButton key, bool pressed) {
1150
-    assert(key < unknown);
1153
+    assert(key < unknownKey);
1151 1154
     assert(mRunning == true);
1152 1155
 
1153 1156
     if ((keyBindings[menuAction] == key) && pressed) {
@@ -1182,7 +1185,7 @@ void OpenRaider::handleText(char *text, bool notFinished) {
1182 1185
 }
1183 1186
 
1184 1187
 void OpenRaider::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton button, bool released) {
1185
-    assert(button < unknown);
1188
+    assert(button < unknownKey);
1186 1189
     assert(mRunning == true);
1187 1190
 
1188 1191
     if (getMenu().isVisible()) {

+ 2
- 2
src/Render.cpp View File

@@ -677,7 +677,7 @@ void Render::drawLoadScreen()
677 677
     glTranslatef(0.0f, 0.0f, -2000.0f);
678 678
     glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
679 679
 
680
-    glBindTexture(GL_TEXTURE_2D, 3); //! \fixme store texture id somewhere
680
+    mTexture.bindTextureId(1); //! \fixme store texture id somewhere
681 681
 
682 682
     glBegin(GL_TRIANGLE_STRIP);
683 683
     glTexCoord2f(1.0, 1.0);
@@ -1290,7 +1290,7 @@ void Render::drawRoom(RenderRoom *rRoom, bool draw_alpha)
1290 1290
     glPushMatrix();
1291 1291
     //LightingSetup();
1292 1292
 
1293
-    glBindTexture(GL_TEXTURE_2D, 1);  // WHITE texture
1293
+    mTexture.bindTextureId(0); // WHITE texture
1294 1294
 
1295 1295
     if (!draw_alpha &&
1296 1296
             (mFlags & Render::fPortals || mMode == Render::modeWireframe))

+ 0
- 1
src/Texture.cpp View File

@@ -273,7 +273,6 @@ int Texture::loadBufferSlot(unsigned char *image,
273 273
 
274 274
 void Texture::bindTextureId(unsigned int n) {
275 275
     assert(mTextureIds != NULL);
276
-    assert((int)n != mTextureId);
277 276
     assert(n <= mTextureCount);
278 277
 
279 278
     mTextureId = n;

+ 7
- 0
src/TombRaider.cpp View File

@@ -74,6 +74,13 @@ TombRaider::TombRaider()
74 74
     mTexelScale = 256.0f;
75 75
     mRiffDataSz = 0;
76 76
 
77
+    for (int i = 0; i < 256; i++) {
78
+        _palette8[i].r = 0;
79
+        _palette8[i].g = 0;
80
+        _palette8[i].b = 0;
81
+        _palette16[i] = 0;
82
+    }
83
+
77 84
     reset();
78 85
 }
79 86
 

+ 90
- 90
src/WindowSDL.cpp View File

@@ -189,11 +189,11 @@ void WindowSDL::eventHandling() {
189 189
             case SDL_MOUSEBUTTONUP:
190 190
                 KeyboardButton button;
191 191
                 if (event.button.button == SDL_BUTTON_LEFT)
192
-                    button = leftmouse;
192
+                    button = leftmouseKey;
193 193
                 else if (event.button.button == SDL_BUTTON_RIGHT)
194
-                    button = rightmouse;
194
+                    button = rightmouseKey;
195 195
                 else
196
-                    button = middlemouse;
196
+                    button = middlemouseKey;
197 197
                 getOpenRaider().handleMouseClick(event.button.x, event.button.y, button, (event.type == SDL_MOUSEBUTTONUP));
198 198
                 break;
199 199
 
@@ -211,266 +211,266 @@ void WindowSDL::eventHandling() {
211 211
                 KeyboardButton key;
212 212
                 switch (event.key.keysym.sym) {
213 213
                     case SDLK_0:
214
-                        key = zero;
214
+                        key = zeroKey;
215 215
                         break;
216 216
                     case SDLK_1:
217
-                        key = one;
217
+                        key = oneKey;
218 218
                         break;
219 219
                     case SDLK_2:
220
-                        key = two;
220
+                        key = twoKey;
221 221
                         break;
222 222
                     case SDLK_3:
223
-                        key = three;
223
+                        key = threeKey;
224 224
                         break;
225 225
                     case SDLK_4:
226
-                        key = four;
226
+                        key = fourKey;
227 227
                         break;
228 228
                     case SDLK_5:
229
-                        key = five;
229
+                        key = fiveKey;
230 230
                         break;
231 231
                     case SDLK_6:
232
-                        key = six;
232
+                        key = sixKey;
233 233
                         break;
234 234
                     case SDLK_7:
235
-                        key = seven;
235
+                        key = sevenKey;
236 236
                         break;
237 237
                     case SDLK_8:
238
-                        key = eight;
238
+                        key = eightKey;
239 239
                         break;
240 240
                     case SDLK_9:
241
-                        key = nine;
241
+                        key = nineKey;
242 242
                         break;
243 243
                     case SDLK_a:
244
-                        key = a;
244
+                        key = aKey;
245 245
                         break;
246 246
                     case SDLK_b:
247
-                        key = b;
247
+                        key = bKey;
248 248
                         break;
249 249
                     case SDLK_c:
250
-                        key = c;
250
+                        key = cKey;
251 251
                         break;
252 252
                     case SDLK_d:
253
-                        key = d;
253
+                        key = dKey;
254 254
                         break;
255 255
                     case SDLK_e:
256
-                        key = e;
256
+                        key = eKey;
257 257
                         break;
258 258
                     case SDLK_f:
259
-                        key = f;
259
+                        key = fKey;
260 260
                         break;
261 261
                     case SDLK_g:
262
-                        key = g;
262
+                        key = gKey;
263 263
                         break;
264 264
                     case SDLK_h:
265
-                        key = h;
265
+                        key = hKey;
266 266
                         break;
267 267
                     case SDLK_i:
268
-                        key = i;
268
+                        key = iKey;
269 269
                         break;
270 270
                     case SDLK_j:
271
-                        key = j;
271
+                        key = jKey;
272 272
                         break;
273 273
                     case SDLK_k:
274
-                        key = k;
274
+                        key = kKey;
275 275
                         break;
276 276
                     case SDLK_l:
277
-                        key = l;
277
+                        key = lKey;
278 278
                         break;
279 279
                     case SDLK_m:
280
-                        key = m;
280
+                        key = mKey;
281 281
                         break;
282 282
                     case SDLK_n:
283
-                        key = n;
283
+                        key = nKey;
284 284
                         break;
285 285
                     case SDLK_o:
286
-                        key = o;
286
+                        key = oKey;
287 287
                         break;
288 288
                     case SDLK_p:
289
-                        key = p;
289
+                        key = pKey;
290 290
                         break;
291 291
                     case SDLK_q:
292
-                        key = q;
292
+                        key = qKey;
293 293
                         break;
294 294
                     case SDLK_r:
295
-                        key = r;
295
+                        key = rKey;
296 296
                         break;
297 297
                     case SDLK_s:
298
-                        key = s;
298
+                        key = sKey;
299 299
                         break;
300 300
                     case SDLK_t:
301
-                        key = t;
301
+                        key = tKey;
302 302
                         break;
303 303
                     case SDLK_u:
304
-                        key = u;
304
+                        key = uKey;
305 305
                         break;
306 306
                     case SDLK_v:
307
-                        key = v;
307
+                        key = vKey;
308 308
                         break;
309 309
                     case SDLK_w:
310
-                        key = w;
310
+                        key = wKey;
311 311
                         break;
312 312
                     case SDLK_x:
313
-                        key = x;
313
+                        key = xKey;
314 314
                         break;
315 315
                     case SDLK_y:
316
-                        key = y;
316
+                        key = yKey;
317 317
                         break;
318 318
                     case SDLK_z:
319
-                        key = z;
319
+                        key = zKey;
320 320
                         break;
321 321
                     case SDLK_QUOTE:
322
-                        key = quote;
322
+                        key = quoteKey;
323 323
                         break;
324 324
                     case SDLK_BACKSLASH:
325
-                        key = backslash;
325
+                        key = backslashKey;
326 326
                         break;
327 327
                     case SDLK_BACKSPACE:
328
-                        key = backspace;
328
+                        key = backspaceKey;
329 329
                         break;
330 330
                     case SDLK_CAPSLOCK:
331
-                        key = capslock;
331
+                        key = capslockKey;
332 332
                         break;
333 333
                     case SDLK_COMMA:
334
-                        key = comma;
334
+                        key = commaKey;
335 335
                         break;
336 336
                     case SDLK_DELETE:
337
-                        key = del;
337
+                        key = delKey;
338 338
                         break;
339 339
                     case SDLK_UP:
340
-                        key = up;
340
+                        key = upKey;
341 341
                         break;
342 342
                     case SDLK_DOWN:
343
-                        key = down;
343
+                        key = downKey;
344 344
                         break;
345 345
                     case SDLK_LEFT:
346
-                        key = left;
346
+                        key = leftKey;
347 347
                         break;
348 348
                     case SDLK_RIGHT:
349
-                        key = right;
349
+                        key = rightKey;
350 350
                         break;
351 351
                     case SDLK_END:
352
-                        key = end;
352
+                        key = endKey;
353 353
                         break;
354 354
                     case SDLK_EQUALS:
355
-                        key = equals;
355
+                        key = equalsKey;
356 356
                         break;
357 357
                     case SDLK_ESCAPE:
358
-                        key = escape;
358
+                        key = escapeKey;
359 359
                         break;
360 360
                     case SDLK_F1:
361
-                        key = f1;
361
+                        key = f1Key;
362 362
                         break;
363 363
                     case SDLK_F2:
364
-                        key = f2;
364
+                        key = f2Key;
365 365
                         break;
366 366
                     case SDLK_F3:
367
-                        key = f3;
367
+                        key = f3Key;
368 368
                         break;
369 369
                     case SDLK_F4:
370
-                        key = f4;
370
+                        key = f4Key;
371 371
                         break;
372 372
                     case SDLK_F5:
373
-                        key = f5;
373
+                        key = f5Key;
374 374
                         break;
375 375
                     case SDLK_F6:
376
-                        key = f6;
376
+                        key = f6Key;
377 377
                         break;
378 378
                     case SDLK_F7:
379
-                        key = f7;
379
+                        key = f7Key;
380 380
                         break;
381 381
                     case SDLK_F8:
382
-                        key = f8;
382
+                        key = f8Key;
383 383
                         break;
384 384
                     case SDLK_F9:
385
-                        key = f9;
385
+                        key = f9Key;
386 386
                         break;
387 387
                     case SDLK_F10:
388
-                        key = f10;
388
+                        key = f10Key;
389 389
                         break;
390 390
                     case SDLK_F11:
391
-                        key = f11;
391
+                        key = f11Key;
392 392
                         break;
393 393
                     case SDLK_F12:
394
-                        key = f12;
394
+                        key = f12Key;
395 395
                         break;
396 396
                     case SDLK_BACKQUOTE:
397
-                        key = backquote;
397
+                        key = backquoteKey;
398 398
                         break;
399 399
                     case SDLK_HOME:
400
-                        key = home;
400
+                        key = homeKey;
401 401
                         break;
402 402
                     case SDLK_INSERT:
403
-                        key = insert;
403
+                        key = insertKey;
404 404
                         break;
405 405
                     case SDLK_LALT:
406
-                        key = leftalt;
406
+                        key = leftaltKey;
407 407
                         break;
408 408
                     case SDLK_LCTRL:
409
-                        key = leftctrl;
409
+                        key = leftctrlKey;
410 410
                         break;
411 411
                     case SDLK_LEFTBRACKET:
412
-                        key = leftbracket;
412
+                        key = leftbracketKey;
413 413
                         break;
414 414
                     case SDLK_LGUI:
415
-                        key = leftgui;
415
+                        key = leftguiKey;
416 416
                         break;
417 417
                     case SDLK_LSHIFT:
418
-                        key = leftshift;
418
+                        key = leftshiftKey;
419 419
                         break;
420 420
                     case SDLK_MINUS:
421
-                        key = minus;
421
+                        key = minusKey;
422 422
                         break;
423 423
                     case SDLK_NUMLOCKCLEAR:
424
-                        key = numlock;
424
+                        key = numlockKey;
425 425
                         break;
426 426
                     case SDLK_PAGEDOWN:
427
-                        key = pagedown;
427
+                        key = pagedownKey;
428 428
                         break;
429 429
                     case SDLK_PAGEUP:
430
-                        key = pageup;
430
+                        key = pageupKey;
431 431
                         break;
432 432
                     case SDLK_PAUSE:
433
-                        key = pause;
433
+                        key = pauseKey;
434 434
                         break;
435 435
                     case SDLK_PERIOD:
436
-                        key = dot;
436
+                        key = dotKey;
437 437
                         break;
438 438
                     case SDLK_RALT:
439
-                        key = rightalt;
439
+                        key = rightaltKey;
440 440
                         break;
441 441
                     case SDLK_RCTRL:
442
-                        key = rightctrl;
442
+                        key = rightctrlKey;
443 443
                         break;
444 444
                     case SDLK_RETURN:
445 445
                     case SDLK_RETURN2:
446
-                        key = enter;
446
+                        key = enterKey;
447 447
                         break;
448 448
                     case SDLK_RGUI:
449
-                        key = rightgui;
449
+                        key = rightguiKey;
450 450
                         break;
451 451
                     case SDLK_RIGHTBRACKET:
452
-                        key = rightbracket;
452
+                        key = rightbracketKey;
453 453
                         break;
454 454
                     case SDLK_RSHIFT:
455
-                        key = rightshift;
455
+                        key = rightshiftKey;
456 456
                         break;
457 457
                     case SDLK_SCROLLLOCK:
458
-                        key = scrolllock;
458
+                        key = scrolllockKey;
459 459
                         break;
460 460
                     case SDLK_SEMICOLON:
461
-                        key = semicolon;
461
+                        key = semicolonKey;
462 462
                         break;
463 463
                     case SDLK_SLASH:
464
-                        key = slash;
464
+                        key = slashKey;
465 465
                         break;
466 466
                     case SDLK_SPACE:
467
-                        key = space;
467
+                        key = spaceKey;
468 468
                         break;
469 469
                     case SDLK_TAB:
470
-                        key = tab;
470
+                        key = tabKey;
471 471
                         break;
472 472
                     default:
473
-                        key = unknown;
473
+                        key = unknownKey;
474 474
                         break;
475 475
 
476 476
                 }

+ 9
- 4
src/main.cpp View File

@@ -100,11 +100,13 @@ void cleanupHandler(void) {
100 100
     if (gWindow)
101 101
         delete gWindow;
102 102
 
103
+#ifdef DEBUG
103 104
     printf("\nThanks for testing %s\n", VERSION);
104 105
     printf("Build date: %s @ %s\n", __DATE__, __TIME__);
105 106
     printf("Build host: %s\n", BUILD_HOST);
106 107
     printf("Web site  : http://github.com/xythobuz/OpenRaider\n");
107 108
     printf("Contact   : xythobuz@xythobuz.de\n");
109
+#endif
108 110
 }
109 111
 
110 112
 int main(int argc, char *argv[]) {
@@ -113,7 +115,7 @@ int main(int argc, char *argv[]) {
113 115
     // Handle arguments
114 116
     if (argc == 1) {
115 117
         // Use default rc file path
116
-        config = DEFAULT_CONFIG_PATH DEFAULT_CONFIG_FILE;
118
+        config = DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE;
117 119
     } else if (argc == 2) {
118 120
         // Check for command line switches
119 121
         if ((strcmp("-h", argv[1]) == 0)
@@ -124,7 +126,7 @@ int main(int argc, char *argv[]) {
124 126
                     "\t--help\n\t-h\tDisplay this help text\n"
125 127
                     "\t--version\n\t-v\tDisplay version information\n"
126 128
                     "If no options are given, the default config will be loaded from:\n"
127
-                    "\t" DEFAULT_CONFIG_PATH DEFAULT_CONFIG_FILE "\n", argv[0]);
129
+                    "\t" DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE "\n", argv[0]);
128 130
             return 0;
129 131
         } else if ((strcmp("-v", argv[1]) == 0)
130 132
                 || (strcmp("--version", argv[1]) == 0)) {
@@ -140,8 +142,11 @@ int main(int argc, char *argv[]) {
140 142
         return 1;
141 143
     }
142 144
 
143
-    // Create globals
145
+#ifdef DEBUG
144 146
     printf("Initializing %s\n", VERSION);
147
+#endif
148
+
149
+    // Create globals
145 150
     atexit(cleanupHandler);
146 151
     gOpenRaider = new OpenRaider();
147 152
     gWindow = new WindowSDL();
@@ -155,7 +160,7 @@ int main(int argc, char *argv[]) {
155 160
 
156 161
     // Try to load a configuration
157 162
     if (gOpenRaider->loadConfig(config) != 0) {
158
-        if (gOpenRaider->loadConfig(DEFAULT_CONFIG_PATH DEFAULT_CONFIG_FILE) != 0) {
163
+        if (gOpenRaider->loadConfig(DEFAULT_CONFIG_PATH "/" DEFAULT_CONFIG_FILE) != 0) {
159 164
             if (gOpenRaider->loadConfig(DEFAULT_CONFIG_FILE) != 0) {
160 165
                 printf("Could not find a config file. Aborting...\n");
161 166
                 return 2;

+ 3
- 3
src/utils/strings.cpp View File

@@ -106,7 +106,7 @@ char *bufferString(const char *string, va_list args) {
106 106
         delete [] text;
107 107
         text = new char[sz + 1];
108 108
         va_copy(tmp, args);
109
-        n = vsnprintf(text, sz, string, tmp);
109
+        vsnprintf(text, sz, string, tmp);
110 110
         va_end(tmp);
111 111
     }
112 112
 
@@ -122,7 +122,7 @@ char *bufferString(const char *string, ...) {
122 122
 }
123 123
 
124 124
 char *fullPath(const char *path, char end) {
125
-    unsigned int lenPath, offset;
125
+    unsigned int lenPath;
126 126
     wordexp_t word;
127 127
     char *dir;
128 128
 
@@ -160,7 +160,7 @@ char *fullPath(const char *path, char end) {
160 160
         dir = new char[lenPath + 2]; // space for end char
161 161
 
162 162
         // Copy segments into new string
163
-        offset = 0;
163
+        unsigned int offset = 0;
164 164
         for (unsigned int i = 0; i < word.we_wordc; i++) {
165 165
             unsigned int len = strlen(word.we_wordv[i]);
166 166
             strncpy(dir + offset, word.we_wordv[i], len);

Loading…
Cancel
Save