]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
ec30c86ae7a00df3267cbe7494830cd63aaa640c
[lugaru.git] / Source / Game.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
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.
10
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.
14
15 See the GNU General Public License for more details.
16
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.
20 */
21
22 #ifndef _GAME_H_
23 #define _GAME_H_
24
25 #include "SDL.h"
26
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.
30 #  endif
31 #endif
32
33 #ifdef PLATFORM_MACOSX
34 #include <Carbon.h>
35 #include "Quicktime.h"
36 #endif
37
38 //Jordan included glut.h
39 //#include <glut.h>
40
41 #include "TGALoader.h"
42
43 #include "Terrain.h"
44 #include "Skybox.h"
45 #include "Skeleton.h"
46 #include "Models.h"
47 #include "Lights.h"
48 #include "Person.h"
49 #include "Sprite.h"
50 //#include <agl.h>
51 #include "Text.h"
52 #include "Objects.h"
53 //#include <DrawSprocket.h>
54 #include "Weapons.h"
55 #include "binio.h"
56 #include <fstream>
57 #include "gamegl.h"
58 #include "Stereo.h"
59 #include "Account.h"
60 #include "Sounds.h"
61
62 #define NB_CAMPAIGN_MENU_ITEM 7
63
64 namespace Game {
65     extern GLuint terraintexture;
66     extern GLuint terraintexture2;
67     extern GLuint terraintexture3;
68     extern GLuint screentexture;
69     extern GLuint screentexture2;
70     extern GLuint logotexture;
71     extern GLuint loadscreentexture;
72     extern GLuint Maparrowtexture;
73     extern GLuint Mapboxtexture;
74     extern GLuint Mapcircletexture;
75     extern GLuint cursortexture;
76     extern GLuint Mainmenuitems[10];
77
78     extern int selected;
79     extern int keyselect;
80
81     extern int newdetail;
82     extern int newscreenwidth;
83     extern int newscreenheight;
84
85     extern bool gameon;
86     extern float deltah,deltav;
87     extern int mousecoordh,mousecoordv;
88     extern int oldmousecoordh,oldmousecoordv;
89     extern float yaw,pitch;
90     extern SkyBox *skybox;
91     extern bool cameramode;
92     extern bool firstload;
93
94     extern float leveltime;
95     extern float loadtime;
96
97     extern Model hawk;
98     extern XYZ hawkcoords;
99     extern XYZ realhawkcoords;
100     extern GLuint hawktexture;
101     extern float hawkyaw;
102     extern float hawkcalldelay;
103
104     extern Model eye;
105     extern Model iris;
106     extern Model cornea;
107
108     extern bool stealthloading;
109     extern int loading;
110
111     extern int musictype;
112
113     extern XYZ mapcenter;
114     extern float mapradius;
115
116     extern Text *text;
117     extern float fps;
118
119     extern bool editorenabled;
120     extern int editortype;
121     extern float editorsize;
122     extern float editoryaw;
123     extern float editorpitch;
124
125     extern int tryquit;
126
127     extern XYZ pathpoint[30];
128     extern int numpathpoints;
129     extern int numpathpointconnect[30];
130     extern int pathpointconnect[30][30];
131     extern int pathpointselected;
132
133     extern int endgame;
134     extern bool scoreadded;
135     extern int numchallengelevels;
136
137     extern bool console;
138     extern char consoletext[15][256];
139     extern int consolechars[15];
140     extern bool chatting;
141     extern char displaytext[15][256];
142     extern int displaychars[15];
143     extern float displaytime[15];
144     extern float displayblinkdelay;
145     extern bool displayblink;
146     extern int displayselected;
147     extern float consoleblinkdelay;
148     extern bool consoleblink;
149     extern int consoleselected;
150
151     extern int oldenvironment;
152     extern int targetlevel;
153     extern float changedelay;
154
155     extern bool waiting;
156     extern Account* accountactive;
157
158     extern unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
159     extern unsigned short consolekey;
160
161     void newGame();
162     void deleteGame();
163
164     void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha);
165     void LoadTextureSave(const string fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize);
166     void InitGame();
167     void LoadStuff();
168     void LoadingScreen();
169     int DrawGLScene(StereoSide side);
170     void LoadMenu();
171     void Tick();
172     void TickOnce();
173     void TickOnceAfter();
174     void SetUpLighting();
175     GLvoid ReSizeGLScene(float fov, float near);
176     int checkcollide(XYZ startpoint, XYZ endpoint);
177     int checkcollide(XYZ startpoint, XYZ endpoint, int what);
178     
179     void fireSound(int sound=fireendsound);
180     void setKeySelected();
181
182     void inputText(char* str, int* charselected, int* nb_chars);
183     void flash();
184 }
185
186 #ifndef __forceinline
187 #  ifdef __GNUC__
188 #    define __forceinline inline __attribute__((always_inline))
189 #  endif
190 #endif
191
192 static __forceinline void swap_gl_buffers(void)
193 {
194     SDL_GL_SwapBuffers();
195 }
196
197 extern "C" { void UndefinedSymbolToExposeStubbedCode(void); }
198 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
199 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
200 //#define STUBBED(x)
201
202 extern int numplayers;
203
204 extern int numdialogues;
205 const int max_dialogues = 20;
206 const int max_dialoguelength = 20;
207 extern int numdialogueboxes[max_dialogues];
208 extern int dialoguetype[max_dialogues];
209 extern int dialogueboxlocation[max_dialogues][max_dialoguelength];
210 extern float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
211 extern int dialogueboxsound[max_dialogues][max_dialoguelength];
212 extern char dialoguetext[max_dialogues][max_dialoguelength][128];
213 extern char dialoguename[max_dialogues][max_dialoguelength][64];
214 extern XYZ dialoguecamera[max_dialogues][max_dialoguelength];
215 extern XYZ participantlocation[max_dialogues][10];
216 extern int participantfocus[max_dialogues][max_dialoguelength];
217 extern int participantaction[max_dialogues][max_dialoguelength];
218 extern float participantyaw[max_dialogues][10];
219 extern XYZ participantfacing[max_dialogues][max_dialoguelength][10];
220 extern float dialoguecamerayaw[max_dialogues][max_dialoguelength];
221 extern float dialoguecamerapitch[max_dialogues][max_dialoguelength];
222 extern int indialogue;
223 extern int whichdialogue;
224 extern int directing;
225 extern float dialoguetime;
226 extern int dialoguegonethrough[20];
227
228 enum maptypes {
229   mapkilleveryone, mapgosomewhere,
230   mapkillsomeone, mapkillmost // These two are unused
231 };
232
233 enum pathtypes {wpkeepwalking, wppause};
234
235 static const char *pathtypenames[] = {"keepwalking", "pause"};
236
237 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
238                   typedead1, typedead2, typedead3, typedead4};
239
240 static const char *editortypenames[] = {
241   "active", "sitting", "sitting wall", "sleeping",
242   "dead1", "dead2", "dead3", "dead4"
243 };
244
245 #endif