2 #include "openal_wrapper.h"
3 #include "SDL_thread.h"
6 extern int channels[100];
7 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
19 loadscreentexture = 0;
25 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
29 memset(startx, 0, sizeof(startx));
30 memset(starty, 0, sizeof(starty));
31 memset(endx, 0, sizeof(endx));
32 memset(endy, 0, sizeof(endy));
34 memset(selectedlong, 0, sizeof(selectedlong));
35 memset(offsetx, 0, sizeof(offsetx));
36 memset(offsety, 0, sizeof(offsety));
37 memset(movex, 0, sizeof(movex));
38 memset(movey, 0, sizeof(movey));
39 memset(endy, 0, sizeof(endy));
52 memset(menustring, 0, sizeof(menustring));
53 memset(registrationname, 0, sizeof(registrationname));
54 registrationnumber = 0;
61 deltah = 0,deltav = 0;
62 mousecoordh = 0,mousecoordv = 0;
63 oldmousecoordh = 0,oldmousecoordv = 0;
64 rotation = 0,rotation2 = 0;
69 cameratogglekeydown = 0;
70 chattogglekeydown = 0;
73 drawmodetogglekeydown = 0;
74 explodetogglekeydown = 0;
75 detailtogglekeydown = 0;
85 // XYZ realhawkcoords;
97 campaignnumlevels = 0;
99 memset(campaignmapname, 0, sizeof(campaignmapname));
100 memset(campaigndescription, 0, sizeof(campaigndescription));
101 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
102 memset(campaignnumnext, 0, sizeof(campaignnumnext));
103 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
104 int campaignchoicesmade;
105 memset(campaignchoices, 0, sizeof(campaignchoices));
106 memset(campaignlocationx, 0, sizeof(campaignlocationx));
107 memset(campaignlocationy, 0, sizeof(campaignlocationy));
108 memset(campaignlocationy, 0, sizeof(campaignlocationy));
110 campaignchoicenum = 0;
112 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
118 memset(levelorder, 0, sizeof(levelorder));
119 memset(levelvisible, 0, sizeof(levelvisible));
120 memset(levelhighlight, 0, sizeof(levelhighlight));
124 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
139 envtogglekeydown = 0;
140 slomotogglekeydown = 0;
141 texturesizetogglekeydown = 0;
142 freezetogglekeydown = 0;
156 // XYZ pathpoint[30];
158 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
159 memset(pathpointconnect, 0, sizeof(pathpointconnect));
160 pathpointselected = 0;
164 numchallengelevels = 0;
169 memset(consoletext, 0, sizeof(consoletext));
170 memset(consolechars, 0, sizeof(consolechars));
172 memset(displaytext, 0, sizeof(displaytext));
173 memset(displaychars, 0, sizeof(displaychars));
174 memset(displaytime, 0, sizeof(displaytime));
175 displayblinkdelay = 0;
179 consoletogglekeydown = 0;
180 consoleblinkdelay = 0;
183 // memset(togglekey, 0, sizeof(togglekey));
184 // memset(togglekeydelay, 0, sizeof(togglekeydelay));
188 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
195 // XYZ boundary[360];
202 memset(musicvolume, 0, sizeof(musicvolume));
203 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
212 accountactive = NULL;
217 void (Game::*method)();
220 void Game::fireSound(int sound) {
221 emit_sound_at(sound);
224 void Game::inputText(char* str, int* charselected, int* nb_chars) {
230 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
231 SDL_EnableUNICODE(true);
234 SDL_PollEvent(&evenement);
236 switch(evenement.type) {
238 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
245 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
246 if((*charselected)!=0) {
247 for(i=(*charselected)-1;i<255;i++){
254 } else if(evenement.key.keysym.sym==SDLK_DELETE){
255 for(i=(*charselected);i<255;i++){
260 } else if(evenement.key.keysym.sym==SDLK_LEFT){
261 if((*charselected)!=0)
263 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
264 if((*charselected)<(*nb_chars))
266 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
268 } else if((evenement.key.keysym.unicode<127)&&((*nb_chars)<60)&&(evenement.key.keysym.sym!=SDLK_LSHIFT)&&(evenement.key.keysym.sym!=SDLK_RSHIFT)) {
269 for(i=255;i>=(*charselected)+1;i--){
272 str[*charselected]=evenement.key.keysym.unicode;
280 SDL_EnableKeyRepeat(0,0); // disable key repeat
281 SDL_EnableUNICODE(false);
285 void Game::setKeySelected() {
287 params_thread* data = new params_thread;
289 data->method = &Game::setKeySelected_thread;
290 printf("launch thread\n");
291 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
292 if ( thread == NULL ) {
293 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
299 void Game::setKeySelected_thread() {
303 SDL_WaitEvent(&evenement);
304 switch(evenement.type) {
306 keycode = evenement.key.keysym.sym;
308 case SDL_MOUSEBUTTONDOWN:
309 keycode = SDLK_LAST+evenement.button.button;
315 if(keycode != SDLK_ESCAPE) {
318 case 0: forwardkey=keycode;
320 case 1: backkey=keycode;
322 case 2: leftkey=keycode;
324 case 3: rightkey=keycode;
326 case 4: crouchkey=keycode;
328 case 5: jumpkey=keycode;
330 case 6: drawkey=keycode;
332 case 7: throwkey=keycode;
334 case 8: attackkey=keycode;
344 int Game::thread(void *data) {
345 params_thread* pt = (params_thread*)data;
347 (pt->game->*(pt->method))();
351 void Game::DrawGL() {
352 if ( stereomode == stereoNone ) {
353 DrawGLScene(stereoCenter);
355 DrawGLScene(stereoLeft);
356 DrawGLScene(stereoRight);