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 #define NB_CAMPAIGN_MENU_ITEM 7
64 extern GLuint rabbittexture;
71 static std::vector<TextureInfo> textures;
73 GLuint terraintexture;
74 GLuint terraintexture2;
75 GLuint terraintexture3;
77 GLuint screentexture2;
79 GLuint loadscreentexture;
80 GLuint Maparrowtexture;
82 GLuint Mapcircletexture;
84 GLuint Mainmenuitems[10];
91 float selectedlong[100];
102 char menustring[100][256];
103 char registrationname[256];
104 float registrationnumber;
112 int mousecoordh,mousecoordv;
113 int oldmousecoordh,oldmousecoordv;
114 float rotation,rotation2;
138 int campaignnumlevels;
139 char campaignmapname[50][256];
140 char campaigndescription[50][256];
141 int campaignchoosenext[50];
142 int campaignnumnext[50]; // Set this to 0 on final level. As David said: he meant to add story branching, but he eventually hadn't.
143 int campaignnextlevel[50][10];
144 int campaignlocationx[50];
145 int campaignlocationy[50];
146 int campaignchoicenum;
147 int campaignchoicewhich[10];
151 int levelorder[5000];
152 int levelvisible[50];
153 int levelhighlight[50];
157 int musictype,oldmusictype,oldoldmusictype;
177 float editorrotation;
178 float editorrotation2;
187 int numpathpointconnect[30];
188 int pathpointconnect[30][30];
189 int pathpointselected;
193 int numchallengelevels;
197 char consoletext[15][256];
198 int consolechars[15];
200 char displaytext[15][256];
201 int displaychars[15];
202 float displaytime[15];
203 float displayblinkdelay;
207 float consoleblinkdelay;
212 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
215 static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
216 static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
217 static void LoadTextureData(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
218 static void LoadTextureSaveData(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize, bool reload);
219 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
220 bool AddClothes(const char *fileName, GLubyte *array);
222 void LoadScreenTexture();
224 void LoadingScreen();
226 static std::vector<std::string> ListCampaigns();
227 void FadeLoadingScreen(float howmuch);
229 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 //keeps track of which textures are loaded
302 //TODO: delete them properly
306 const char* fileName;
315 Game::LoadTextureSaveData(fileName,ptextureid,mipmap,array,skinsize,isLoaded);
317 Game::LoadTextureData(fileName,ptextureid,mipmap,hasalpha);
320 TextureInfo(const char *_fileName, GLuint *_ptextureid,int _mipmap, bool _hasalpha):
321 isLoaded(false), isSkin(false), array(NULL), skinsize(NULL),
322 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), hasalpha(_hasalpha) { }
323 TextureInfo(const char *_fileName, GLuint *_ptextureid, int _mipmap, GLubyte *_array, int *_skinsize):
324 isLoaded(false), isSkin(true), hasalpha(false),
325 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), array(_array), skinsize(_skinsize) { }
328 #ifndef __forceinline
330 # define __forceinline inline __attribute__((always_inline))
334 static __forceinline void swap_gl_buffers(void)
336 SDL_GL_SwapBuffers();
339 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
340 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
341 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
344 extern int numplayers;
346 extern int numdialogues;
347 const int max_dialogues = 20;
348 const int max_dialoguelength = 20;
349 extern int numdialogueboxes[max_dialogues];
350 extern int dialoguetype[max_dialogues];
351 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
352 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
353 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
354 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
355 extern char dialoguename[max_dialogues][max_dialoguelength][64];
356 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
357 extern XYZ participantlocation[max_dialogues][10];
358 extern int participantfocus[max_dialogues][max_dialoguelength];
359 extern int participantaction[max_dialogues][max_dialoguelength];
360 extern float participantrotation[max_dialogues][10];
361 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
362 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
363 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
364 extern int indialogue;
365 extern int whichdialogue;
366 extern int directing;
367 extern float dialoguetime;
368 extern int dialoguegonethrough[20];
371 mapkilleveryone, mapgosomewhere,
372 mapkillsomeone, mapkillmost // These two are unused
375 enum pathtypes {wpkeepwalking, wppause};
377 static const char *pathtypenames[] = {"keepwalking", "pause"};
379 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
380 typedead1, typedead2, typedead3, typedead4};
382 static const char *editortypenames[] = {
383 "active", "sitting", "sitting wall", "sleeping",
384 "dead1", "dead2", "dead3", "dead4"