2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
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.
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.
15 See the GNU General Public License for more details.
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.
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.
33 #ifdef PLATFORM_MACOSX
35 #include "Quicktime.h"
38 //Jordan included glut.h
41 #include "TGALoader.h"
53 //#include <DrawSprocket.h>
62 extern GLuint rabbittexture;
67 typedef std::map<std::string, GLuint> TextureList;
68 typedef std::map<GLuint, std::string> GLTextureList;
69 typedef TextureList::iterator TexIter;
70 static TextureList textures;
72 GLuint terraintexture;
73 GLuint terraintexture2;
74 GLuint terraintexture3;
76 GLuint screentexture2;
78 GLuint loadscreentexture;
79 GLuint Maparrowtexture;
81 GLuint Mapcircletexture;
83 GLuint Mainmenuitems[10];
90 float selectedlong[100];
106 char menustring[100][256];
107 char registrationname[256];
108 float registrationnumber;
116 int mousecoordh,mousecoordv;
117 int oldmousecoordh,oldmousecoordv;
118 float rotation,rotation2;
121 bool cameratogglekeydown;
122 bool chattogglekeydown;
125 bool drawmodetogglekeydown;
126 bool explodetogglekeydown;
127 bool detailtogglekeydown;
147 int campaignnumlevels;
148 char campaignmapname[50][256];
149 char campaigndescription[50][256];
150 int campaignchoosenext[50];
151 int campaignnumnext[50];
152 int campaignnextlevel[50][10];
153 int campaignchoicesmade;
154 int campaignchoices[5000];
155 int campaignlocationx[50];
156 int campaignlocationy[50];
157 int campaignchoicenum;
158 int campaignchoicewhich[10];
162 int levelorder[5000];
163 int levelvisible[50];
164 int levelhighlight[50];
168 int musictype,oldmusictype,oldoldmusictype;
183 bool envtogglekeydown;
184 bool slomotogglekeydown;
185 bool texturesizetogglekeydown;
186 bool freezetogglekeydown;
192 float editorrotation;
193 float editorrotation2;
202 int numpathpointconnect[30];
203 int pathpointconnect[30][30];
204 int pathpointselected;
208 int numchallengelevels;
212 char consoletext[15][256];
213 int consolechars[15];
215 char displaytext[15][256];
216 int displaychars[15];
217 float displaytime[15];
218 float displayblinkdelay;
222 bool consoletogglekeydown;
223 float consoleblinkdelay;
226 //int togglekey[140];
227 //float togglekeydelay[140];
230 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
233 static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
234 static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
235 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
236 bool AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
239 void LoadingScreen();
240 void FadeLoadingScreen(float howmuch);
242 int DrawGLScene(StereoSide side);
246 void TickOnceAfter();
247 void SetUpLighting();
248 void Loadlevel(int which);
249 void Loadlevel(const char *name);
250 void Setenvironment(int which);
251 GLvoid ReSizeGLScene(float fov, float near);
252 int findPathDist(int start,int end);
253 int checkcollide(XYZ startpoint, XYZ endpoint);
254 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
258 void fireSound(int sound=fireendsound);
259 void setKeySelected();
269 float musicvolume[4];
270 float oldmusicvolume[4];
275 for(int i=0;i<10;i++){
276 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
278 glDeleteTextures( 1, &cursortexture );
279 glDeleteTextures( 1, &Maparrowtexture );
280 glDeleteTextures( 1, &Mapboxtexture );
281 glDeleteTextures( 1, &Mapcircletexture );
282 glDeleteTextures( 1, &terraintexture );
283 glDeleteTextures( 1, &terraintexture2 );
284 if(screentexture>0)glDeleteTextures( 1, &screentexture );
285 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
286 glDeleteTextures( 1, &hawktexture );
287 glDeleteTextures( 1, &logotexture );
288 glDeleteTextures( 1, &loadscreentexture );
292 bool isWaiting() { return waiting; };
294 void setKeySelected_thread();
295 static int thread(void *data);
296 void inputText(char* str, int* charselected, int* nb_chars);
299 bool mainmenutogglekeydown;
301 Account* accountactive;
304 #ifndef __forceinline
306 # define __forceinline inline __attribute__((always_inline))
310 static __forceinline void swap_gl_buffers(void)
312 SDL_GL_SwapBuffers();
315 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
316 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
317 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
320 extern int numplayers;
322 extern int numdialogues;
323 const int max_dialogues = 20;
324 const int max_dialoguelength = 20;
325 extern int numdialogueboxes[max_dialogues];
326 extern int dialoguetype[max_dialogues];
327 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
328 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
329 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
330 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
331 extern char dialoguename[max_dialogues][max_dialoguelength][64];
332 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
333 extern XYZ participantlocation[max_dialogues][10];
334 extern int participantfocus[max_dialogues][max_dialoguelength];
335 extern int participantaction[max_dialogues][max_dialoguelength];
336 extern float participantrotation[max_dialogues][10];
337 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
338 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
339 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
340 extern int indialogue;
341 extern int whichdialogue;
342 extern int directing;
343 extern float dialoguetime;
344 extern int dialoguegonethrough[20];
347 mapkilleveryone, mapgosomewhere,
348 mapkillsomeone, mapkillmost // These two are unused
351 enum pathtypes {wpkeepwalking, wppause};
353 static const char *pathtypenames[] = {"keepwalking", "pause"};
355 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
356 typedead1, typedead2, typedead3, typedead4};
358 static const char *editortypenames[] = {
359 "active", "sitting", "sitting wall", "sleeping",
360 "dead1", "dead2", "dead3", "dead4"