]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
More problems with Apple's compiler.
[lugaru.git] / Source / Game.h
1 #ifndef _GAME_H_
2 #define _GAME_H_
3
4 #ifdef PLATFORM_MACOSX
5 #include <Carbon.h>
6 #include "Quicktime.h"
7 #endif
8
9 //Jordan included glut.h
10 //#include <glut.h>
11
12 #include "TGALoader.h"
13
14 #if USE_SDL
15 #include "SDL.h"
16 #endif
17
18 #if !PLATFORM_MACOSX
19 #include "WinInput.h"
20 #else
21 #include "Macinput.h"
22 #endif
23
24 #include "Terrain.h"
25 #include "Skybox.h"
26 #include "Skeleton.h"
27 #include "Models.h"   
28 #include "Lights.h"
29 #include "Person.h"
30 #include "Constants.h"
31 #include "fmod.h"
32 #include "Sprites.h"
33 //#include <agl.h>
34 #include "Text.h"
35 #include "Objects.h"
36 //#include <DrawSprocket.h>
37 #include "Weapons.h"
38 #include "binio.h"
39 #include <fstream>
40 #include "gamegl.h"
41
42 extern GLuint rabbittexture;
43
44 class Game              
45 {
46 public:
47
48         typedef std::map<std::string, GLuint> TextureList;
49         typedef std::map<GLuint, std::string> GLTextureList;
50         typedef TextureList::iterator TexIter;
51         static TextureList textures;
52
53         GLuint terraintexture;
54         GLuint terraintexture2;
55         GLuint terraintexture3;
56         GLuint screentexture;
57         GLuint screentexture2;
58         GLuint logotexture;
59         GLuint loadscreentexture;
60         GLuint Maparrowtexture;
61         GLuint Mapboxtexture;
62         GLuint Mapcircletexture;
63         GLuint cursortexture;
64         GLuint Mainmenuitems[10];
65
66         int nummenuitems;
67         int startx[100];
68         int starty[100];
69         int endx[100];
70         int endy[100];
71         float selectedlong[100];
72         float offsetx[100];
73         float offsety[100];
74         float movex[100];
75         float movey[100];
76         float transition;
77         int anim;
78         int selected;
79         int loaddistrib;
80         int keyselect;
81         int indemo;
82         int registered;
83
84         bool won;
85
86         bool entername;
87
88         char menustring[100][256];
89         char registrationname[256];
90         float registrationnumber;
91
92         int newdetail;
93         int newscreenwidth;
94         int newscreenheight;
95
96         bool gameon;
97         float deltah,deltav;
98         int mousecoordh,mousecoordv;
99         int oldmousecoordh,oldmousecoordv;
100         float rotation,rotation2;
101         SkyBox skybox;
102         bool cameramode;
103         bool cameratogglekeydown;
104         bool chattogglekeydown;
105         int olddrawmode;
106         int drawmode;
107         bool drawmodetogglekeydown;
108         bool explodetogglekeydown;
109         bool detailtogglekeydown;
110         bool firstload;
111         bool oldbutton;
112
113         float leveltime;
114         float loadtime;
115
116         Model hawk;
117         XYZ hawkcoords;
118         XYZ realhawkcoords;
119         GLuint hawktexture;
120         float hawkrotation;
121         float hawkcalldelay;
122
123         Model eye;
124         Model iris;
125         Model cornea;
126
127         bool stealthloading;
128
129         int campaignnumlevels;
130         char campaignmapname[50][256];
131         char campaigndescription[50][256];
132         int campaignchoosenext[50];
133         int campaignnumnext[50];
134         int campaignnextlevel[50][10];
135         int campaignchoicesmade;
136         int campaignchoices[5000];
137         int campaignlocationx[50];
138         int campaignlocationy[50];
139         int campaignchoicenum;
140         int campaignchoicewhich[10];
141         int whichchoice;
142
143         int numlevelspassed;
144         int levelorder[5000];
145         int levelvisible[50];
146         int levelhighlight[50];
147
148         bool minimap;
149
150         int musictype,oldmusictype,oldoldmusictype;
151         bool realthreat;
152
153         Model rabbit;
154         XYZ rabbitcoords;
155
156         XYZ mapcenter;
157         float mapradius;
158
159         Text text;
160         float fps;
161
162         XYZ cameraloc;
163         float cameradist;
164
165         bool envtogglekeydown;
166         bool slomotogglekeydown;
167         bool texturesizetogglekeydown;
168         bool freezetogglekeydown;
169         int drawtoggle;
170
171         bool editorenabled;
172         int editortype;
173         float editorsize;
174         float editorrotation;
175         float editorrotation2;
176
177         float brightness;
178
179         int quit;
180         int tryquit;
181
182         XYZ pathpoint[30];
183         int numpathpoints;
184         int numpathpointconnect[30];
185         int pathpointconnect[30][30];
186         int pathpointselected;
187
188         int endgame;
189         bool scoreadded;
190         int numchallengelevels;
191
192         bool console;
193         int archiveselected;
194         char consoletext[15][256];
195         int consolechars[15];
196         bool chatting;
197         char displaytext[15][256];
198         int displaychars[15];
199         float displaytime[15];
200         float displayblinkdelay;
201         bool displayblink;
202         int displayselected;
203         bool consolekeydown;
204         bool consoletogglekeydown;
205         float consoleblinkdelay;
206         bool consoleblink;
207         int consoleselected;
208         int togglekey[140];
209         float togglekeydelay[140];
210         bool registernow;
211         bool autocam;
212
213         unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
214         bool oldattackkey;
215
216         long long MD5_string (char *string);
217         static void LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
218         static void LoadTextureSave(char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
219         void LoadSave(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
220         bool AddClothes(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
221         void InitGame();
222         void LoadStuff();
223         void LoadingScreen();
224         void FadeLoadingScreen(float howmuch);
225         void Dispose();
226         int DrawGLScene(void);
227         void Tick();
228         void TickOnce();
229         void TickOnceAfter();
230         void SetUpLighting();
231         void Loadlevel(int which);
232         void Loadlevel(char *name);
233         void LoadSounds();
234         void Setenvironment(int which);
235         GLvoid ReSizeGLScene(float fov, float near);
236         int findPathDist(int start,int end);
237         int checkcollide(XYZ startpoint, XYZ endpoint);
238         int checkcollide(XYZ startpoint, XYZ endpoint, int what);
239         int loading;
240         float talkdelay;
241
242         int numboundaries;
243         XYZ boundary[360];
244
245         int whichlevel;
246         int oldenvironment;
247         int targetlevel;
248         float changedelay;
249
250         float musicvolume[4];
251         float oldmusicvolume[4];
252         int musicselected;
253         int change;
254         Game();
255         ~Game() {               
256                 for(int i=0;i<10;i++){
257                         if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
258                 }
259                 glDeleteTextures( 1, &cursortexture );
260                 glDeleteTextures( 1, &Maparrowtexture );
261                 glDeleteTextures( 1, &Mapboxtexture );
262                 glDeleteTextures( 1, &Mapcircletexture );
263                 glDeleteTextures( 1, &terraintexture );
264                 glDeleteTextures( 1, &terraintexture2 );
265                 if(screentexture>0)glDeleteTextures( 1, &screentexture );
266                 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
267                 glDeleteTextures( 1, &hawktexture );
268                 glDeleteTextures( 1, &logotexture );
269                 glDeleteTextures( 1, &loadscreentexture );
270
271                 Dispose();
272         }
273
274 };
275
276 #ifndef __forceinline
277 #  ifdef __GNUC__
278 #    define __forceinline inline __attribute__((always_inline))
279 #  endif
280 #endif
281
282 static __forceinline void swap_gl_buffers(void)
283 {
284 #ifdef WIN32
285     extern HDC hDC;
286     SwapBuffers( hDC);
287 #elif USE_SDL
288     SDL_GL_SwapBuffers();
289 #elif PLATFORM_MACOSX
290     extern AGLContext gaglContext;
291     aglSwapBuffers(gaglContext);
292 #else
293     #error define your platform.
294 #endif
295 }
296
297 #ifdef __GNUC__
298 #define LONGLONGCONST(x) (x##ll)
299 #else
300 #define LONGLONGCONST(x) (x)
301 #endif
302
303 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
304 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
305 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
306 //#define STUBBED(x)
307
308 #endif