Sfoglia il codice sorgente

Removed unnecessary defines

Thomas Buck 11 anni fa
parent
commit
b121c33781
10 ha cambiato i file con 16 aggiunte e 90 eliminazioni
  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 Vedi File

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

+ 3
- 5
Makefile Vedi File

29
 # -DUNICODE_SUPPORT			Add unicode/internation keyboard support
29
 # -DUNICODE_SUPPORT			Add unicode/internation keyboard support
30
 # -DUSING_EMITTER_IN_GAME	Run particle test in game
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
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
34
 BASE_LIBS=$(shell sdl-config --libs) -lz -lstdc++ \
37
 	-lpthread -lSDL_ttf
35
 	-lpthread -lSDL_ttf
49
 GL_LIBS += -L/opt/local/lib
47
 GL_LIBS += -L/opt/local/lib
50
 GL_DEFS += -I/opt/local/include
48
 GL_DEFS += -I/opt/local/include
51
 else
49
 else
52
-AUDIO_LIBS += -lopenal
50
+AUDIO_LIBS += -lopenal -lalut
53
 GL_LIBS += -lGL -lGLU
51
 GL_LIBS += -lGL -lGLU
54
 GL_LIBS += -L/usr/local/lib
52
 GL_LIBS += -L/usr/local/lib
55
 GL_DEFS += -I/usr/local/include
53
 GL_DEFS += -I/usr/local/include
394
 Sound.test:
392
 Sound.test:
395
 	mkdir -p $(BUILD_TEST_DIR)
393
 	mkdir -p $(BUILD_TEST_DIR)
396
 	$(CC) $(TEST_FLAGS) $(WARNINGS) \
394
 	$(CC) $(TEST_FLAGS) $(WARNINGS) \
397
-		-DUSING_OPENAL $(AUDIO_LIBS) $(AUDIO_DEFS) \
395
+		$(AUDIO_LIBS) $(AUDIO_DEFS) \
398
 		src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
396
 		src/Sound.cpp test/Sound.cpp -o $(BUILD_TEST_DIR)/Sound.test
399
 
397
 
400
 #################################################################
398
 #################################################################

+ 8
- 2
README.md Vedi File

29
 
29
 
30
 ## Dependencies
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
 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:
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
     sudo port install zlib cmake libsdl libsdl_ttf
42
     sudo port install zlib cmake libsdl libsdl_ttf
47
 
55
 
48
 Linux Distributions will probably provide an ALUT library ready to install with their package manager, so you won't need to compile freealut.
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
 ## Building
58
 ## Building
53
 
59
 
54
 If you installed the dependencies using MacPorts, you'll need to have `/opt/local/bin` in your `$PATH` before you can execute make.
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 Vedi File

23
 #ifndef _SDLSYSTEM_H_
23
 #ifndef _SDLSYSTEM_H_
24
 #define _SDLSYSTEM_H_
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
 #include <System.h>
28
 #include <System.h>
33
 
29
 

+ 0
- 12
src/Network.cpp Vedi File

34
     unsigned int frameExpected;
34
     unsigned int frameExpected;
35
 } client_t;
35
 } client_t;
36
 
36
 
37
-#ifdef USING_PTHREADS
38
 #include <pthread.h>
37
 #include <pthread.h>
39
 pthread_t gPThreadId[3];
38
 pthread_t gPThreadId[3];
40
-#endif
41
 
39
 
42
 unsigned int gUID;
40
 unsigned int gUID;
43
 client_t gClients[MAX_CLIENTS];
41
 client_t gClients[MAX_CLIENTS];
225
     // For now don't handle shutting down server to start client and vv
223
     // For now don't handle shutting down server to start client and vv
226
     if (!mSpawnedServer && !mSpawnedClient)
224
     if (!mSpawnedServer && !mSpawnedClient)
227
     {
225
     {
228
-#ifdef USING_PTHREADS
229
         pthread_create(gPThreadId + 0, 0, server_thread, NULL);
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
         mSpawnedServer = true;
227
         mSpawnedServer = true;
235
     }
228
     }
236
 }
229
 }
241
     // For now don't handle shutting down server to start client and vv
234
     // For now don't handle shutting down server to start client and vv
242
     if (!mSpawnedServer && !mSpawnedClient)
235
     if (!mSpawnedServer && !mSpawnedClient)
243
     {
236
     {
244
-#ifdef USING_PTHREADS
245
         pthread_create(gPThreadId + 1, 0, client_thread, NULL);
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
         mSpawnedClient = true;
238
         mSpawnedClient = true;
251
     }
239
     }
252
 }
240
 }

+ 0
- 4
src/SDLSystem.cpp Vedi File

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

+ 0
- 30
src/Sound.cpp Vedi File

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

+ 0
- 2
src/System.cpp Vedi File

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

+ 1
- 9
src/Texture.cpp Vedi File

37
 #include <memory_test.h>
37
 #include <memory_test.h>
38
 #endif
38
 #endif
39
 
39
 
40
-#ifdef USING_TGA
41
-#include <TGA.h>
42
-#endif
43
-
44
 #include <SDL/SDL_ttf.h>
40
 #include <SDL/SDL_ttf.h>
45
 
41
 
46
 #ifdef __APPLE__
42
 #ifdef __APPLE__
51
 #include <GL/glu.h>
47
 #include <GL/glu.h>
52
 #endif
48
 #endif
53
 
49
 
50
+#include <TGA.h>
54
 #include <Texture.h>
51
 #include <Texture.h>
55
 
52
 
56
 //Texture *gTextureManager = 0x0;
53
 //Texture *gTextureManager = 0x0;
946
 
943
 
947
 int Texture::loadTGA(const char *filename)
944
 int Texture::loadTGA(const char *filename)
948
 {
945
 {
949
-#ifdef USING_TGA
950
     FILE *f;
946
     FILE *f;
951
     unsigned char *image = NULL;
947
     unsigned char *image = NULL;
952
     unsigned char *image2 = NULL;
948
     unsigned char *image2 = NULL;
993
     }
989
     }
994
 
990
 
995
     return id;
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 Vedi File

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

Loading…
Annulla
Salva