Browse Source

Removed unnecessary defines

Thomas Buck 11 years ago
parent
commit
b121c33781
10 changed files with 16 additions and 90 deletions
  1. 1
    0
      ChangeLog
  2. 3
    5
      Makefile
  3. 8
    2
      README.md
  4. 1
    5
      include/SDLSystem.h
  5. 0
    12
      src/Network.cpp
  6. 0
    4
      src/SDLSystem.cpp
  7. 0
    30
      src/Sound.cpp
  8. 0
    2
      src/System.cpp
  9. 1
    9
      src/Texture.cpp
  10. 2
    21
      src/TombRaider.cpp

+ 1
- 0
ChangeLog View File

@@ -7,6 +7,7 @@
7 7
 
8 8
 	[ 20140202 ]
9 9
 	* Fixed more cppcheck warnings
10
+	* Removed unnecessary defines (USING_xxx)
10 11
 
11 12
 	[ 20140201 ]
12 13
 	* Rewrote Memory Unit Test using greatest

+ 3
- 5
Makefile View File

@@ -29,9 +29,7 @@ UNAME=$(shell uname -s)
29 29
 # -DUNICODE_SUPPORT			Add unicode/internation keyboard support
30 30
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
31 31
 
32
-BASE_DEFS=$(shell sdl-config --cflags) -Iinclude -DSDL_INTERFACE \
33
-	-DUSING_OPENGL -DZLIB_SUPPORT -DUSING_EMITTER \
34
-	-DUSING_OPENAL -DUSING_TGA -DUSING_PTHREADS \
32
+BASE_DEFS=$(shell sdl-config --cflags) -Iinclude -DUSING_EMITTER
35 33
 
36 34
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
37 35
 	-lpthread -lSDL_ttf
@@ -49,7 +47,7 @@ GL_LIBS += -framework OpenGL
49 47
 GL_LIBS += -L/opt/local/lib
50 48
 GL_DEFS += -I/opt/local/include
51 49
 else
52
-AUDIO_LIBS += -lopenal
50
+AUDIO_LIBS += -lopenal -lalut
53 51
 GL_LIBS += -lGL -lGLU
54 52
 GL_LIBS += -L/usr/local/lib
55 53
 GL_DEFS += -I/usr/local/include
@@ -394,7 +392,7 @@ Network.test:
394 392
 Sound.test:
395 393
 	mkdir -p $(BUILD_TEST_DIR)
396 394
 	$(CC) $(TEST_FLAGS) $(WARNINGS) \
397
-		-DUSING_OPENAL $(AUDIO_LIBS) $(AUDIO_DEFS) \
395
+		$(AUDIO_LIBS) $(AUDIO_DEFS) \
398 396
 		src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
399 397
 
400 398
 #################################################################

+ 8
- 2
README.md View File

@@ -29,6 +29,14 @@ A more or less recent [Doxygen documentation](http://xythobuz.github.io/OpenRaid
29 29
 
30 30
 ## Dependencies
31 31
 
32
+Basically, OpenRaider depends on the following:
33
+
34
+* OpenGL
35
+* SDL & SDL-TTF
36
+* OpenAL & ALUT
37
+* Posix Threads
38
+* zlib
39
+
32 40
 On Mac OS X 10.9 with [XCode](https://developer.apple.com/xcode/) and [MacPorts](http://www.macports.org) installed, the following should be enough to get all dependencies that are available as port:
33 41
 
34 42
     sudo port install zlib cmake libsdl libsdl_ttf
@@ -47,8 +55,6 @@ Get, compile and install freealut like this:
47 55
 
48 56
 Linux Distributions will probably provide an ALUT library ready to install with their package manager, so you won't need to compile freealut.
49 57
 
50
-You'll also need the [XQuartz](http://xquartz.macosforge.org/trac) X11 Server if you're on Mac OS X, as Apple is no longer bundling their own X.
51
-
52 58
 ## Building
53 59
 
54 60
 If you installed the dependencies using MacPorts, you'll need to have `/opt/local/bin` in your `$PATH` before you can execute make.

+ 1
- 5
include/SDLSystem.h View File

@@ -23,11 +23,7 @@
23 23
 #ifndef _SDLSYSTEM_H_
24 24
 #define _SDLSYSTEM_H_
25 25
 
26
-#ifdef SDL_INTERFACE
27
-#   include <SDL/SDL.h>
28
-#else
29
-#   error "SDLSystem requires -DSDL_INTERFACE"
30
-#endif
26
+#include <SDL/SDL.h>
31 27
 
32 28
 #include <System.h>
33 29
 

+ 0
- 12
src/Network.cpp View File

@@ -34,10 +34,8 @@ typedef struct client_s {
34 34
     unsigned int frameExpected;
35 35
 } client_t;
36 36
 
37
-#ifdef USING_PTHREADS
38 37
 #include <pthread.h>
39 38
 pthread_t gPThreadId[3];
40
-#endif
41 39
 
42 40
 unsigned int gUID;
43 41
 client_t gClients[MAX_CLIENTS];
@@ -225,12 +223,7 @@ void Network::spawnServerThread()
225 223
     // For now don't handle shutting down server to start client and vv
226 224
     if (!mSpawnedServer && !mSpawnedClient)
227 225
     {
228
-#ifdef USING_PTHREADS
229 226
         pthread_create(gPThreadId + 0, 0, server_thread, NULL);
230
-#else
231
-        printf("Network::spawnServerThread> Build doesn't support threads\n");
232
-#endif
233
-
234 227
         mSpawnedServer = true;
235 228
     }
236 229
 }
@@ -241,12 +234,7 @@ void Network::spawnClientThread()
241 234
     // For now don't handle shutting down server to start client and vv
242 235
     if (!mSpawnedServer && !mSpawnedClient)
243 236
     {
244
-#ifdef USING_PTHREADS
245 237
         pthread_create(gPThreadId + 1, 0, client_thread, NULL);
246
-#else
247
-        printf("Network::spawnClientThread> Build doesn't support threads\n");
248
-#endif
249
-
250 238
         mSpawnedClient = true;
251 239
     }
252 240
 }

+ 0
- 4
src/SDLSystem.cpp View File

@@ -36,11 +36,7 @@
36 36
 #include <memory_test.h>
37 37
 #endif
38 38
 
39
-#ifdef USING_OPENGL
40 39
 #include <SDL/SDL_opengl.h>
41
-#else
42
-#error "SDLSystem requires -DUSING_OPENGL"
43
-#endif
44 40
 
45 41
 #include <SDLSystem.h>
46 42
 

+ 0
- 30
src/Sound.cpp View File

@@ -6,7 +6,6 @@
6 6
  * \author xythobuz
7 7
  */
8 8
 
9
-#ifdef USING_OPENAL
10 9
 #ifdef __APPLE__
11 10
 #include <OpenAL/al.h>
12 11
 #include <OpenAL/alc.h>
@@ -16,9 +15,6 @@
16 15
 #include <AL/alc.h>
17 16
 #include <AL/alut.h>
18 17
 #endif
19
-#else
20
-#warning "No OpenAL support. Won't play sound!"
21
-#endif
22 18
 
23 19
 #include <time.h>
24 20
 #include <stdio.h>
@@ -51,9 +47,7 @@ Sound::~Sound()
51 47
 {
52 48
     if (mInit)
53 49
     {
54
-#ifdef USING_OPENAL
55 50
         alutExit();
56
-#endif
57 51
     }
58 52
 }
59 53
 
@@ -74,14 +68,10 @@ int Sound::init()
74 68
     close(fd);
75 69
 #endif
76 70
 
77
-#ifdef USING_OPENAL
78 71
     alutInit(NULL, 0);
79 72
 
80 73
     mInit = true;
81 74
     printf("Created OpenAL Context\n");
82
-#else
83
-    printf("Couldn't create sound Context!\n");
84
-#endif
85 75
 
86 76
     return 0;
87 77
 }
@@ -92,10 +82,8 @@ void Sound::listenAt(float pos[3], float angle[3])
92 82
     if (!mInit)
93 83
         return;
94 84
 
95
-#ifdef USING_OPENAL
96 85
     alListenerfv(AL_POSITION, pos);
97 86
     alListenerfv(AL_ORIENTATION, angle);
98
-#endif
99 87
 }
100 88
 
101 89
 
@@ -104,21 +92,17 @@ void Sound::sourceAt(int source, float pos[3])
104 92
     if (!mInit || source < 0)
105 93
         return;
106 94
 
107
-#ifdef USING_OPENAL
108 95
     alSourcefv(mSource[source-1], AL_POSITION, pos);
109
-#endif
110 96
 }
111 97
 
112 98
 
113 99
 //! \fixme Seperate sourcing and buffering, Mongoose 2002.01.04
114 100
 int Sound::addFile(const char *filename, int *source, unsigned int flags)
115 101
 {
116
-#ifdef USING_OPENAL
117 102
     ALsizei size;
118 103
     ALfloat freq;
119 104
     ALenum format;
120 105
     ALvoid *data;
121
-#endif
122 106
 
123 107
 
124 108
     if (!mInit || !filename || !source)
@@ -129,7 +113,6 @@ int Sound::addFile(const char *filename, int *source, unsigned int flags)
129 113
 
130 114
     *source = -1;
131 115
 
132
-#ifdef USING_OPENAL
133 116
     alGetError();
134 117
 
135 118
     alGenBuffers(1, &mBuffer[mNextBuffer]);
@@ -175,19 +158,14 @@ int Sound::addFile(const char *filename, int *source, unsigned int flags)
175 158
     *source = mNextBuffer;
176 159
 
177 160
     return 0;
178
-#else
179
-    return -1;
180
-#endif
181 161
 }
182 162
 
183 163
 int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigned int flags)
184 164
 {
185
-#ifdef USING_OPENAL
186 165
     ALsizei size;
187 166
     ALfloat freq;
188 167
     ALenum format;
189 168
     ALvoid *data;
190
-#endif
191 169
 
192 170
     if (!mInit || !wav || !source)
193 171
     {
@@ -197,7 +175,6 @@ int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigne
197 175
 
198 176
     *source = -1;
199 177
 
200
-#ifdef USING_OPENAL
201 178
     data = wav;
202 179
 
203 180
     alGetError();
@@ -249,9 +226,6 @@ int Sound::addWave(unsigned char *wav, unsigned int length, int *source, unsigne
249 226
     *source = mNextBuffer;
250 227
 
251 228
     return 0;
252
-#else
253
-    return -1;
254
-#endif
255 229
 }
256 230
 
257 231
 
@@ -269,9 +243,7 @@ void Sound::play(int source)
269 243
         return;
270 244
     }
271 245
 
272
-#ifdef USING_OPENAL
273 246
     alSourcePlay(mSource[source-1]);
274
-#endif
275 247
 }
276 248
 
277 249
 
@@ -283,8 +255,6 @@ void Sound::stop(int source)
283 255
         return;
284 256
     }
285 257
 
286
-#ifdef USING_OPENAL
287 258
     alSourceStop(mSource[source-1]);
288
-#endif
289 259
 }
290 260
 

+ 0
- 2
src/System.cpp View File

@@ -15,7 +15,6 @@
15 15
 #include <stdarg.h>
16 16
 #include <cmath>
17 17
 
18
-#ifdef USING_OPENGL
19 18
 #ifdef __APPLE__
20 19
 #include <OpenGL/gl.h>
21 20
 #include <OpenGL/glu.h>
@@ -23,7 +22,6 @@
23 22
 #include <GL/gl.h>
24 23
 #include <GL/glu.h>
25 24
 #endif
26
-#endif
27 25
 
28 26
 #if defined(linux) || defined(__APPLE__)
29 27
 #include <time.h>

+ 1
- 9
src/Texture.cpp View File

@@ -37,10 +37,6 @@
37 37
 #include <memory_test.h>
38 38
 #endif
39 39
 
40
-#ifdef USING_TGA
41
-#include <TGA.h>
42
-#endif
43
-
44 40
 #include <SDL/SDL_ttf.h>
45 41
 
46 42
 #ifdef __APPLE__
@@ -51,6 +47,7 @@
51 47
 #include <GL/glu.h>
52 48
 #endif
53 49
 
50
+#include <TGA.h>
54 51
 #include <Texture.h>
55 52
 
56 53
 //Texture *gTextureManager = 0x0;
@@ -946,7 +943,6 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
946 943
 
947 944
 int Texture::loadTGA(const char *filename)
948 945
 {
949
-#ifdef USING_TGA
950 946
     FILE *f;
951 947
     unsigned char *image = NULL;
952 948
     unsigned char *image2 = NULL;
@@ -993,10 +989,6 @@ int Texture::loadTGA(const char *filename)
993 989
     }
994 990
 
995 991
     return id;
996
-#else
997
-    printf("ERROR: TGA support not enabled in this build (%s)\n", filename);
998
-    return -1;
999
-#endif
1000 992
 }
1001 993
 
1002 994
 

+ 2
- 21
src/TombRaider.cpp View File

@@ -52,11 +52,7 @@
52 52
 
53 53
 #include <TombRaider.h>
54 54
 
55
-#ifdef ZLIB_SUPPORT
56 55
 #include <zlib.h>
57
-#else
58
-#warning "No zlib. Won't support TR4+ files!"
59
-#endif
60 56
 
61 57
 #ifdef __TEST_TR5_DUMP_TGA
62 58
 #include <TGA.h>
@@ -525,7 +521,6 @@ int TombRaider::Load(char *filename, void (*percent)(int))
525 521
 
526 522
     if (mEngineVersion == TR_VERSION_4)
527 523
     {
528
-#ifdef ZLIB_SUPPORT
529 524
         unsigned int sz, usz; // compressed and uncompressed size
530 525
         unsigned char *compressed_data = NULL;
531 526
         int zerr;
@@ -743,11 +738,6 @@ int TombRaider::Load(char *filename, void (*percent)(int))
743 738
 
744 739
         // Toggle Fread mode to read from decompressed data in memory, not diskfile
745 740
         mFreadMode = TR_FREAD_COMPRESSED;
746
-#else
747
-        Print("Load> ERROR: TR4 support not compiled in this build.");
748
-        Print("Load> Try 'make tr4' next build.  Requires zlib.");
749
-        return -1;
750
-#endif
751 741
     }
752 742
 
753 743
     if (mEngineVersion == TR_VERSION_2 || mEngineVersion == TR_VERSION_3)
@@ -1974,7 +1964,6 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1974 1964
             break;
1975 1965
     }
1976 1966
 
1977
-#ifdef ZLIB_SUPPORT
1978 1967
     if (mCompressedLevelData)
1979 1968
     {
1980 1969
         printDebug("Load", "Freeing uncompressed TR4 data");
@@ -1983,7 +1972,6 @@ int TombRaider::Load(char *filename, void (*percent)(int))
1983 1972
 
1984 1973
     //! \fixme memory damage?
1985 1974
     mCompressedLevelData = NULL;
1986
-#endif
1987 1975
 
1988 1976
     fclose(f);
1989 1977
 
@@ -4763,10 +4751,8 @@ void TombRaider::extractMeshes(unsigned char *mesh_data,
4763 4751
 
4764 4752
 int TombRaider::Fread(void *buffer, size_t size, size_t count, FILE *f)
4765 4753
 {
4766
-#ifdef ZLIB_SUPPORT
4767 4754
     int num_read;
4768 4755
 
4769
-
4770 4756
     if (mFreadMode == TR_FREAD_COMPRESSED)
4771 4757
     {
4772 4758
         num_read = count;
@@ -4789,7 +4775,8 @@ int TombRaider::Fread(void *buffer, size_t size, size_t count, FILE *f)
4789 4775
             exit(2);
4790 4776
         }
4791 4777
     }
4792
-#endif
4778
+
4779
+
4793 4780
     unsigned int offset = ftell(f);
4794 4781
 
4795 4782
     if (fread(buffer, size, count, f) != count)
@@ -5111,7 +5098,6 @@ int TombRaider::loadTR5(FILE *f, void (*percent)(int))
5111 5098
     if (mEngineVersion != TR_VERSION_5)
5112 5099
         return -1;
5113 5100
 
5114
-#ifdef ZLIB_SUPPORT
5115 5101
     unsigned int sz, usz; // compressed and uncompressed size
5116 5102
     unsigned char *compressed_data = NULL;
5117 5103
     int zerr;
@@ -5276,11 +5262,6 @@ int TombRaider::loadTR5(FILE *f, void (*percent)(int))
5276 5262
         // Free the temporary buffer
5277 5263
         delete [] compressed_data;
5278 5264
     }
5279
-#else
5280
-    Print("LoadTR5> ERROR: TR5 support not compiled in this build.");
5281
-    Print("LoadTR5> Requires zlib-devel.");
5282
-    return -1;
5283
-#endif
5284 5265
 
5285 5266
     if (percent)
5286 5267
         (*percent)(10);

Loading…
Cancel
Save