2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
24 #include "Animation/Skeleton.hpp"
25 #include "Audio/Sounds.hpp"
26 #include "Environment/Lights.hpp"
27 #include "Environment/Skybox.hpp"
28 #include "Environment/Terrain.hpp"
29 #include "Graphic/gamegl.hpp"
30 #include "Graphic/Models.hpp"
31 #include "Graphic/Sprite.hpp"
32 #include "Graphic/Stereo.hpp"
33 #include "Graphic/Text.hpp"
34 #include "Graphic/Texture.hpp"
35 #include "Objects/Objects.hpp"
36 #include "Objects/Person.hpp"
37 #include "Objects/Weapons.hpp"
38 #include "Thirdparty/optionparser.h"
39 #include "User/Account.hpp"
40 #include "Utils/binio.h"
41 #include "Utils/ImageIO.hpp"
46 #define NB_CAMPAIGN_MENU_ITEM 7
50 extern Texture terraintexture;
51 extern Texture terraintexture2;
52 extern Texture loadscreentexture;
53 extern Texture Maparrowtexture;
54 extern Texture Mapboxtexture;
55 extern Texture Mapcircletexture;
56 extern Texture cursortexture;
57 extern GLuint screentexture;
58 extern GLuint screentexture2;
59 extern Texture Mainmenuitems[10];
65 extern int newscreenwidth;
66 extern int newscreenheight;
69 extern float deltah, deltav;
70 extern int mousecoordh, mousecoordv;
71 extern int oldmousecoordh, oldmousecoordv;
72 extern float yaw, pitch;
73 extern SkyBox *skybox;
74 extern bool cameramode;
75 extern bool firstload;
77 extern float leveltime;
78 extern float wonleveltime;
79 extern float loadtime;
82 extern XYZ hawkcoords;
83 extern XYZ realhawkcoords;
84 extern Texture hawktexture;
86 extern float hawkcalldelay;
92 extern bool stealthloading;
98 extern float mapradius;
103 extern bool editorenabled;
104 extern int editortype;
105 extern float editorsize;
106 extern float editoryaw;
107 extern float editorpitch;
111 extern XYZ pathpoint[30];
112 extern int numpathpoints;
113 extern int numpathpointconnect[30];
114 extern int pathpointconnect[30][30];
115 extern int pathpointselected;
118 extern bool scoreadded;
119 extern int numchallengelevels;
122 extern std::string consoletext[15];
123 extern std::string displaytext[15];
124 extern float displaytime[15];
125 extern float displayblinkdelay;
126 extern bool displayblink;
127 extern unsigned displayselected;
128 extern float consoleblinkdelay;
129 extern bool consoleblink;
130 extern unsigned consoleselected;
132 extern int oldenvironment;
133 extern int targetlevel;
134 extern float changedelay;
138 extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
139 extern unsigned short consolekey;
146 void LoadScreenTexture();
147 void LoadingScreen();
148 int DrawGLScene(StereoSide side);
149 void playdialoguescenesound();
150 int findClosestPlayer();
151 void Loadlevel(int which);
152 void Loadlevel(const std::string& name);
155 void TickOnceAfter();
156 void SetUpLighting();
157 GLvoid ReSizeGLScene(float fov, float near);
158 int checkcollide(XYZ startpoint, XYZ endpoint);
159 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
161 void fireSound(int sound = fireendsound);
163 void inputText(std::string& str, unsigned* charselected);
164 void flash(float amount = 1, int delay = 1);
167 #ifndef __forceinline
169 # define __forceinline inline __attribute__((always_inline))
173 static __forceinline void swap_gl_buffers(void)
175 extern SDL_Window *sdlwindow;
176 SDL_GL_SwapWindow(sdlwindow);
178 // try to limit this to 60fps, even if vsync fails.
180 static Uint32 frameticks = 0;
181 const Uint32 endticks = (frameticks + 16);
182 while ((now = SDL_GetTicks()) < endticks) { /* spin. */ }
187 void UndefinedSymbolToExposeStubbedCode(void);
189 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
190 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
194 mapkilleveryone, mapgosomewhere,
195 mapkillsomeone, mapkillmost // These two are unused
198 enum pathtypes {wpkeepwalking, wppause};
200 extern const char *pathtypenames[2];
202 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
203 typedead1, typedead2, typedead3, typedead4
206 extern const char *editortypenames[8];
208 extern const char *rabbitskin[10];
210 extern const char *wolfskin[3];
212 extern const char **creatureskin[2];
214 SDL_bool sdlEventProc(const SDL_Event &e);
218 enum optionIndex { UNKNOWN, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS, DEVTOOLS };
219 /* Number of options + 1 */
220 const int commandLineOptionsNumber = 9;
222 extern const option::Descriptor usage[13];
224 extern option::Option commandLineOptions[commandLineOptionsNumber];
225 extern option::Option* commandLineOptionsBuffer;