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;
142 int campaignnumlevels;
143 char campaignmapname[50][256];
144 char campaigndescription[50][256];
145 int campaignchoosenext[50];
146 int campaignnumnext[50];
147 int campaignnextlevel[50][10];
148 int campaignchoicesmade;
149 int campaignchoices[5000];
150 int campaignlocationx[50];
151 int campaignlocationy[50];
152 int campaignchoicenum;
153 int campaignchoicewhich[10];
157 int levelorder[5000];
158 int levelvisible[50];
159 int levelhighlight[50];
163 int musictype,oldmusictype,oldoldmusictype;
183 float editorrotation;
184 float editorrotation2;
193 int numpathpointconnect[30];
194 int pathpointconnect[30][30];
195 int pathpointselected;
199 int numchallengelevels;
203 char consoletext[15][256];
204 int consolechars[15];
206 char displaytext[15][256];
207 int displaychars[15];
208 float displaytime[15];
209 float displayblinkdelay;
213 float consoleblinkdelay;
218 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
221 static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
222 static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
223 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
224 bool AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
227 void LoadingScreen();
228 void FadeLoadingScreen(float howmuch);
230 int DrawGLScene(StereoSide side);
232 //factored from Tick() -sf17k
236 void doJumpReversals();
237 void doAerialAcrobatics();
239 void doPlayerCollisions();
244 void TickOnceAfter();
245 void SetUpLighting();
246 void Loadlevel(int which);
247 void Loadlevel(const char *name);
248 void Setenvironment(int which);
249 GLvoid ReSizeGLScene(float fov, float near);
250 int findPathDist(int start,int end);
251 int checkcollide(XYZ startpoint, XYZ endpoint);
252 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
256 void fireSound(int sound=fireendsound);
257 void setKeySelected();
267 float musicvolume[4];
268 float oldmusicvolume[4];
273 for(int i=0;i<10;i++){
274 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
276 glDeleteTextures( 1, &cursortexture );
277 glDeleteTextures( 1, &Maparrowtexture );
278 glDeleteTextures( 1, &Mapboxtexture );
279 glDeleteTextures( 1, &Mapcircletexture );
280 glDeleteTextures( 1, &terraintexture );
281 glDeleteTextures( 1, &terraintexture2 );
282 if(screentexture>0)glDeleteTextures( 1, &screentexture );
283 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
284 glDeleteTextures( 1, &hawktexture );
285 glDeleteTextures( 1, &logotexture );
286 glDeleteTextures( 1, &loadscreentexture );
290 bool isWaiting() { return waiting; };
292 void setKeySelected_thread();
293 static int thread(void *data);
294 void inputText(char* str, int* charselected, int* nb_chars);
298 Account* accountactive;
301 #ifndef __forceinline
303 # define __forceinline inline __attribute__((always_inline))
307 static __forceinline void swap_gl_buffers(void)
309 SDL_GL_SwapBuffers();
312 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
313 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
314 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
317 extern int numplayers;
319 extern int numdialogues;
320 const int max_dialogues = 20;
321 const int max_dialoguelength = 20;
322 extern int numdialogueboxes[max_dialogues];
323 extern int dialoguetype[max_dialogues];
324 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
325 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
326 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
327 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
328 extern char dialoguename[max_dialogues][max_dialoguelength][64];
329 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
330 extern XYZ participantlocation[max_dialogues][10];
331 extern int participantfocus[max_dialogues][max_dialoguelength];
332 extern int participantaction[max_dialogues][max_dialoguelength];
333 extern float participantrotation[max_dialogues][10];
334 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
335 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
336 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
337 extern int indialogue;
338 extern int whichdialogue;
339 extern int directing;
340 extern float dialoguetime;
341 extern int dialoguegonethrough[20];
344 mapkilleveryone, mapgosomewhere,
345 mapkillsomeone, mapkillmost // These two are unused
348 enum pathtypes {wpkeepwalking, wppause};
350 static const char *pathtypenames[] = {"keepwalking", "pause"};
352 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
353 typedead1, typedead2, typedead3, typedead4};
355 static const char *editortypenames[] = {
356 "active", "sitting", "sitting wall", "sleeping",
357 "dead1", "dead2", "dead3", "dead4"