]> git.jsancho.org Git - lugaru.git/blob - Source/Game.hpp
Fix mismatched usage length, build fail on g++
[lugaru.git] / Source / Game.hpp
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
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.
11
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.
16
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/>.
19 */
20
21 #ifndef _GAME_HPP_
22 #define _GAME_HPP_
23
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/Models.hpp"
30 #include "Graphic/Sprite.hpp"
31 #include "Graphic/Stereo.hpp"
32 #include "Graphic/Text.hpp"
33 #include "Graphic/Texture.hpp"
34 #include "Graphic/gamegl.hpp"
35 #include "Objects/Object.hpp"
36 #include "Objects/Person.hpp"
37 #include "Objects/Weapons.hpp"
38 #include "Thirdparty/optionparser.h"
39 #include "User/Account.hpp"
40 #include "Utils/ImageIO.hpp"
41 #include "Utils/binio.h"
42
43 #include <SDL.h>
44 #include <fstream>
45
46 #define NB_CAMPAIGN_MENU_ITEM 7
47
48 namespace Game
49 {
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];
60
61 extern int selected;
62 extern int keyselect;
63
64 extern int newdetail;
65 extern int newscreenwidth;
66 extern int newscreenheight;
67
68 extern bool gameon;
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 firstLoadDone;
76
77 extern float leveltime;
78 extern float wonleveltime;
79 extern float loadtime;
80
81 extern Model hawk;
82 extern XYZ hawkcoords;
83 extern XYZ realhawkcoords;
84 extern Texture hawktexture;
85 extern float hawkyaw;
86 extern float hawkcalldelay;
87
88 extern Model eye;
89 extern Model iris;
90 extern Model cornea;
91
92 extern bool stealthloading;
93 extern int loading;
94
95 extern int musictype;
96
97 extern XYZ mapcenter;
98 extern float mapradius;
99
100 extern Text* text;
101 extern Text* textmono;
102 extern float fps;
103
104 extern bool editorenabled;
105 extern int editortype;
106 extern float editorsize;
107 extern float editoryaw;
108 extern float editorpitch;
109
110 extern int tryquit;
111
112 extern XYZ pathpoint[30];
113 extern int numpathpoints;
114 extern int numpathpointconnect[30];
115 extern int pathpointconnect[30][30];
116 extern int pathpointselected;
117
118 extern int endgame;
119 extern bool scoreadded;
120 extern int numchallengelevels;
121
122 extern bool console;
123 extern std::string consoletext[15];
124 extern float consoleblinkdelay;
125 extern bool consoleblink;
126 extern unsigned consoleselected;
127
128 extern int oldenvironment;
129 extern int targetlevel;
130 extern float changedelay;
131
132 extern bool waiting;
133
134 extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
135 extern unsigned short consolekey;
136
137 void newGame();
138 void deleteGame();
139
140 void InitGame();
141 void LoadStuff();
142 void LoadScreenTexture();
143 void LoadingScreen();
144 int DrawGLScene(StereoSide side);
145 void playdialoguescenesound();
146 int findClosestPlayer();
147 bool LoadLevel(int which);
148 bool LoadLevel(const std::string& name, bool tutorial = false);
149
150 void ProcessInput();
151 void ProcessDevInput();
152
153 void Tick();
154 void TickOnce();
155 void TickOnceAfter();
156
157 void SetUpLighting();
158 GLvoid ReSizeGLScene(float fov, float near);
159
160 void fireSound(int sound = fireendsound);
161
162 void inputText(std::string& str, unsigned* charselected);
163 void flash(float amount = 1, int delay = 1);
164 }
165 float roughDirection(XYZ vec);
166 float roughDirectionTo(XYZ start, XYZ end);
167 float pitchTo(XYZ start, XYZ end);
168 float sq(float n);
169
170 #ifndef __forceinline
171 #ifdef __GNUC__
172 #define __forceinline inline __attribute__((always_inline))
173 #endif
174 #endif
175
176 static __forceinline void swap_gl_buffers(void)
177 {
178     extern SDL_Window* sdlwindow;
179     SDL_GL_SwapWindow(sdlwindow);
180
181     // try to limit this to 60fps, even if vsync fails.
182     Uint32 now;
183     static Uint32 frameticks = 0;
184     const Uint32 endticks = (frameticks + 16);
185     while ((now = SDL_GetTicks()) < endticks) { /* spin. */
186     }
187     frameticks = now;
188 }
189
190 enum maptypes
191 {
192     mapkilleveryone,
193     mapgosomewhere,
194     mapkillsomeone,
195     mapkillmost // These two are unused
196 };
197
198 enum pathtypes
199 {
200     wpkeepwalking,
201     wppause
202 };
203
204 extern const char* pathtypenames[2];
205
206 enum editortypes
207 {
208     typeactive,
209     typesitting,
210     typesittingwall,
211     typesleeping,
212     typedead1,
213     typedead2,
214     typedead3,
215     typedead4
216 };
217
218 extern const char* editortypenames[8];
219
220 SDL_bool sdlEventProc(const SDL_Event& e);
221
222 enum optionIndex
223 {
224     UNKNOWN,
225     VERSION,
226     HELP,
227     FULLSCREEN,
228     NOMOUSEGRAB,
229     SOUND,
230     OPENALINFO,
231     SHOWRESOLUTIONS,
232     DEVTOOLS
233 };
234 /* Number of options + 1 */
235 const int commandLineOptionsNumber = 10;
236
237 extern const option::Descriptor usage[];
238
239 extern option::Option commandLineOptions[commandLineOptionsNumber];
240 extern option::Option* commandLineOptionsBuffer;
241
242 #endif