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]; // 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];
151 int musictype,oldmusictype,oldoldmusictype;
171 float editorrotation;
172 float editorrotation2;
181 int numpathpointconnect[30];
182 int pathpointconnect[30][30];
183 int pathpointselected;
187 int numchallengelevels;
191 char consoletext[15][256];
192 int consolechars[15];
194 char displaytext[15][256];
195 int displaychars[15];
196 float displaytime[15];
197 float displayblinkdelay;
201 float consoleblinkdelay;
206 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
209 static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
210 static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
211 static void LoadTextureData(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
212 static void LoadTextureSaveData(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize, bool reload);
213 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
214 bool AddClothes(const char *fileName, GLubyte *array);
216 void LoadScreenTexture();
218 void LoadingScreen();
220 static std::vector<std::string> ListCampaigns();
221 void FadeLoadingScreen(float howmuch);
223 int DrawGLScene(StereoSide side);
226 //factored from Tick() -sf17k
230 void doJumpReversals();
231 void doAerialAcrobatics();
233 void doPlayerCollisions();
238 void TickOnceAfter();
239 void SetUpLighting();
240 void Loadlevel(int which);
241 void Loadlevel(const char *name);
242 void Setenvironment(int which);
243 GLvoid ReSizeGLScene(float fov, float near);
244 int findPathDist(int start,int end);
245 int checkcollide(XYZ startpoint, XYZ endpoint);
246 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
250 void fireSound(int sound=fireendsound);
251 void setKeySelected();
261 float musicvolume[4];
262 float oldmusicvolume[4];
267 for(int i=0;i<10;i++){
268 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
270 glDeleteTextures( 1, &cursortexture );
271 glDeleteTextures( 1, &Maparrowtexture );
272 glDeleteTextures( 1, &Mapboxtexture );
273 glDeleteTextures( 1, &Mapcircletexture );
274 glDeleteTextures( 1, &terraintexture );
275 glDeleteTextures( 1, &terraintexture2 );
276 if(screentexture>0)glDeleteTextures( 1, &screentexture );
277 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
278 glDeleteTextures( 1, &hawktexture );
279 glDeleteTextures( 1, &logotexture );
280 glDeleteTextures( 1, &loadscreentexture );
284 bool isWaiting() { return waiting; };
286 void setKeySelected_thread();
287 static int thread(void *data);
288 void inputText(char* str, int* charselected, int* nb_chars);
292 Account* accountactive;
295 //keeps track of which textures are loaded
296 //TODO: delete them properly
300 const char* fileName;
309 Game::LoadTextureSaveData(fileName,ptextureid,mipmap,array,skinsize,isLoaded);
311 Game::LoadTextureData(fileName,ptextureid,mipmap,hasalpha);
314 TextureInfo(const char *_fileName, GLuint *_ptextureid,int _mipmap, bool _hasalpha):
315 isLoaded(false), isSkin(false), array(NULL), skinsize(NULL),
316 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), hasalpha(_hasalpha) { }
317 TextureInfo(const char *_fileName, GLuint *_ptextureid, int _mipmap, GLubyte *_array, int *_skinsize):
318 isLoaded(false), isSkin(true), hasalpha(false),
319 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), array(_array), skinsize(_skinsize) { }
322 #ifndef __forceinline
324 # define __forceinline inline __attribute__((always_inline))
328 static __forceinline void swap_gl_buffers(void)
330 SDL_GL_SwapBuffers();
333 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
334 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
335 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
338 extern int numplayers;
340 extern int numdialogues;
341 const int max_dialogues = 20;
342 const int max_dialoguelength = 20;
343 extern int numdialogueboxes[max_dialogues];
344 extern int dialoguetype[max_dialogues];
345 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
346 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
347 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
348 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
349 extern char dialoguename[max_dialogues][max_dialoguelength][64];
350 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
351 extern XYZ participantlocation[max_dialogues][10];
352 extern int participantfocus[max_dialogues][max_dialoguelength];
353 extern int participantaction[max_dialogues][max_dialoguelength];
354 extern float participantrotation[max_dialogues][10];
355 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
356 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
357 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
358 extern int indialogue;
359 extern int whichdialogue;
360 extern int directing;
361 extern float dialoguetime;
362 extern int dialoguegonethrough[20];
365 mapkilleveryone, mapgosomewhere,
366 mapkillsomeone, mapkillmost // These two are unused
369 enum pathtypes {wpkeepwalking, wppause};
371 static const char *pathtypenames[] = {"keepwalking", "pause"};
373 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
374 typedead1, typedead2, typedead3, typedead4};
376 static const char *editortypenames[] = {
377 "active", "sitting", "sitting wall", "sleeping",
378 "dead1", "dead2", "dead3", "dead4"