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