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