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 GLuint terraintexture;
159 GLuint terraintexture2;
160 GLuint terraintexture3;
161 GLuint screentexture;
162 GLuint screentexture2;
164 GLuint loadscreentexture;
165 GLuint Maparrowtexture;
166 GLuint Mapboxtexture;
167 GLuint Mapcircletexture;
168 GLuint cursortexture;
169 GLuint Mainmenuitems[10];
176 float selectedlong[100];
185 char menustring[100][256];
186 char registrationname[256];
187 float registrationnumber;
195 int mousecoordh,mousecoordv;
196 int oldmousecoordh,oldmousecoordv;
197 float rotation,rotation2;
221 std::vector<CampaignLevel> campaignlevels;
227 int musictype,oldmusictype,oldoldmusictype;
247 float editorrotation;
248 float editorrotation2;
257 int numpathpointconnect[30];
258 int pathpointconnect[30][30];
259 int pathpointselected;
263 int numchallengelevels;
267 char consoletext[15][256];
268 int consolechars[15];
270 char displaytext[15][256];
271 int displaychars[15];
272 float displaytime[15];
273 float displayblinkdelay;
277 float consoleblinkdelay;
282 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
283 unsigned short consolekey;
286 static void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha);
287 static void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
288 void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize);
289 bool AddClothes(const char *fileName, GLubyte *array);
291 void LoadScreenTexture();
293 void LoadingScreen();
295 static std::vector<std::string> ListCampaigns();
296 void FadeLoadingScreen(float howmuch);
298 int DrawGLScene(StereoSide side);
301 //factored from Tick() -sf17k
305 void doJumpReversals();
306 void doAerialAcrobatics();
308 void doPlayerCollisions();
313 void TickOnceAfter();
314 void SetUpLighting();
315 void Loadlevel(int which);
316 void Loadlevel(const char *name);
317 void Setenvironment(int which);
318 GLvoid ReSizeGLScene(float fov, float near);
319 int findPathDist(int start,int end);
320 int checkcollide(XYZ startpoint, XYZ endpoint);
321 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
325 void fireSound(int sound=fireendsound);
326 void setKeySelected();
336 float musicvolume[4];
337 float oldmusicvolume[4];
342 for(int i=0;i<10;i++){
343 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
345 glDeleteTextures( 1, &cursortexture );
346 glDeleteTextures( 1, &Maparrowtexture );
347 glDeleteTextures( 1, &Mapboxtexture );
348 glDeleteTextures( 1, &Mapcircletexture );
349 glDeleteTextures( 1, &terraintexture );
350 glDeleteTextures( 1, &terraintexture2 );
351 if(screentexture>0)glDeleteTextures( 1, &screentexture );
352 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
353 glDeleteTextures( 1, &hawktexture );
354 glDeleteTextures( 1, &logotexture );
355 glDeleteTextures( 1, &loadscreentexture );
359 bool isWaiting() { return waiting; };
361 void setKeySelected_thread();
362 static int thread(void *data);
363 void inputText(char* str, int* charselected, int* nb_chars);
367 Account* accountactive;
370 #ifndef __forceinline
372 # define __forceinline inline __attribute__((always_inline))
376 static __forceinline void swap_gl_buffers(void)
378 SDL_GL_SwapBuffers();
381 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
382 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
383 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
386 extern int numplayers;
388 extern int numdialogues;
389 const int max_dialogues = 20;
390 const int max_dialoguelength = 20;
391 extern int numdialogueboxes[max_dialogues];
392 extern int dialoguetype[max_dialogues];
393 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
394 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
395 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
396 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
397 extern char dialoguename[max_dialogues][max_dialoguelength][64];
398 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
399 extern XYZ participantlocation[max_dialogues][10];
400 extern int participantfocus[max_dialogues][max_dialoguelength];
401 extern int participantaction[max_dialogues][max_dialoguelength];
402 extern float participantrotation[max_dialogues][10];
403 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
404 extern float dialoguecamerarotation[max_dialogues][max_dialoguelength];
405 extern float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
406 extern int indialogue;
407 extern int whichdialogue;
408 extern int directing;
409 extern float dialoguetime;
410 extern int dialoguegonethrough[20];
413 mapkilleveryone, mapgosomewhere,
414 mapkillsomeone, mapkillmost // These two are unused
417 enum pathtypes {wpkeepwalking, wppause};
419 static const char *pathtypenames[] = {"keepwalking", "pause"};
421 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
422 typedead1, typedead2, typedead3, typedead4};
424 static const char *editortypenames[] = {
425 "active", "sitting", "sitting wall", "sleeping",
426 "dead1", "dead2", "dead3", "dead4"