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;
79 std::string description;
82 0 = Immediately load next level at the end of this one.
83 1 = Go back to the world map.
84 2 = Don't bring up the Fiery loading screen. Maybe other things, I've not investigated.
86 //int numnext; // 0 on final level. As David said: he meant to add story branching, but he eventually hadn't.
87 std::vector<int> nextlevel;
90 CampaignLevel() : width(10) {
97 return 30+120+location.x*400/512;
101 return 30+30+(512-location.y)*400/512;
105 return getStartX()+width;
109 return getStartY()+width;
114 center.x=getStartX()+width/2;
115 center.y=getStartY()+width/2;
123 istream& operator<< (istream& is) {
130 for(int pos = description.find('_');pos!=string::npos;pos = description.find('_',pos)) {
131 description.replace(pos,1,1,' ');
138 for(int j=0;j<numnext;j++) {
141 nextlevel.push_back(next-1);
150 friend istream& operator>> (istream& is, CampaignLevel& cl) {
158 static std::vector<TextureInfo> textures;
160 GLuint terraintexture;
161 GLuint terraintexture2;
162 GLuint terraintexture3;
163 GLuint screentexture;
164 GLuint screentexture2;
166 GLuint loadscreentexture;
167 GLuint Maparrowtexture;
168 GLuint Mapboxtexture;
169 GLuint Mapcircletexture;
170 GLuint cursortexture;
171 GLuint Mainmenuitems[10];
178 float selectedlong[100];
187 char menustring[100][256];
188 char registrationname[256];
189 float registrationnumber;
197 int mousecoordh,mousecoordv;
198 int oldmousecoordh,oldmousecoordv;
199 float rotation,rotation2;
223 std::vector<CampaignLevel> campaignlevels;
229 int musictype,oldmusictype,oldoldmusictype;
249 float editorrotation;
250 float editorrotation2;
259 int numpathpointconnect[30];
260 int pathpointconnect[30][30];
261 int pathpointselected;
265 int numchallengelevels;
269 char consoletext[15][256];
270 int consolechars[15];
272 char displaytext[15][256];
273 int displaychars[15];
274 float displaytime[15];
275 float displayblinkdelay;
279 float consoleblinkdelay;
284 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
287 static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
288 static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
289 static void LoadTextureData(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha);
290 static void LoadTextureSaveData(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize, bool reload);
291 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
292 bool AddClothes(const char *fileName, GLubyte *array);
294 void LoadScreenTexture();
296 void LoadingScreen();
298 static std::vector<std::string> ListCampaigns();
299 void FadeLoadingScreen(float howmuch);
301 int DrawGLScene(StereoSide side);
304 //factored from Tick() -sf17k
308 void doJumpReversals();
309 void doAerialAcrobatics();
311 void doPlayerCollisions();
316 void TickOnceAfter();
317 void SetUpLighting();
318 void Loadlevel(int which);
319 void Loadlevel(const char *name);
320 void Setenvironment(int which);
321 GLvoid ReSizeGLScene(float fov, float near);
322 int findPathDist(int start,int end);
323 int checkcollide(XYZ startpoint, XYZ endpoint);
324 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
328 void fireSound(int sound=fireendsound);
329 void setKeySelected();
339 float musicvolume[4];
340 float oldmusicvolume[4];
345 for(int i=0;i<10;i++){
346 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
348 glDeleteTextures( 1, &cursortexture );
349 glDeleteTextures( 1, &Maparrowtexture );
350 glDeleteTextures( 1, &Mapboxtexture );
351 glDeleteTextures( 1, &Mapcircletexture );
352 glDeleteTextures( 1, &terraintexture );
353 glDeleteTextures( 1, &terraintexture2 );
354 if(screentexture>0)glDeleteTextures( 1, &screentexture );
355 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
356 glDeleteTextures( 1, &hawktexture );
357 glDeleteTextures( 1, &logotexture );
358 glDeleteTextures( 1, &loadscreentexture );
362 bool isWaiting() { return waiting; };
364 void setKeySelected_thread();
365 static int thread(void *data);
366 void inputText(char* str, int* charselected, int* nb_chars);
370 Account* accountactive;
373 //keeps track of which textures are loaded
374 //TODO: delete them properly
378 const char* fileName;
387 Game::LoadTextureSaveData(fileName,ptextureid,mipmap,array,skinsize,isLoaded);
389 Game::LoadTextureData(fileName,ptextureid,mipmap,hasalpha);
392 TextureInfo(const char *_fileName, GLuint *_ptextureid,int _mipmap, bool _hasalpha):
393 isLoaded(false), isSkin(false), array(NULL), skinsize(NULL),
394 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), hasalpha(_hasalpha) { }
395 TextureInfo(const char *_fileName, GLuint *_ptextureid, int _mipmap, GLubyte *_array, int *_skinsize):
396 isLoaded(false), isSkin(true), hasalpha(false),
397 fileName(_fileName), ptextureid(_ptextureid), mipmap(_mipmap), array(_array), skinsize(_skinsize) { }
400 #ifndef __forceinline
402 # define __forceinline inline __attribute__((always_inline))
406 static __forceinline void swap_gl_buffers(void)
408 SDL_GL_SwapBuffers();
411 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
412 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
413 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
416 extern int numplayers;
418 extern int numdialogues;
419 const int max_dialogues = 20;
420 const int max_dialoguelength = 20;
421 extern int numdialogueboxes[max_dialogues];
422 extern int dialoguetype[max_dialogues];
423 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
424 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
425 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
426 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
427 extern char dialoguename[max_dialogues][max_dialoguelength][64];
428 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
429 extern XYZ participantlocation[max_dialogues][10];
430 extern int participantfocus[max_dialogues][max_dialoguelength];
431 extern int participantaction[max_dialogues][max_dialoguelength];
432 extern float participantrotation[max_dialogues][10];
433 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
434 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
435 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
436 extern int indialogue;
437 extern int whichdialogue;
438 extern int directing;
439 extern float dialoguetime;
440 extern int dialoguegonethrough[20];
443 mapkilleveryone, mapgosomewhere,
444 mapkillsomeone, mapkillmost // These two are unused
447 enum pathtypes {wpkeepwalking, wppause};
449 static const char *pathtypenames[] = {"keepwalking", "pause"};
451 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
452 typedead1, typedead2, typedead3, typedead4};
454 static const char *editortypenames[] = {
455 "active", "sitting", "sitting wall", "sleeping",
456 "dead1", "dead2", "dead3", "dead4"