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