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