2 #include "openal_wrapper.h"
3 #include "SDL_thread.h"
6 extern OPENAL_SAMPLE *samp[100];
7 extern int channels[100];
8 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
20 loadscreentexture = 0;
26 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
30 memset(startx, 0, sizeof(startx));
31 memset(starty, 0, sizeof(starty));
32 memset(endx, 0, sizeof(endx));
33 memset(endy, 0, sizeof(endy));
35 memset(selectedlong, 0, sizeof(selectedlong));
36 memset(offsetx, 0, sizeof(offsetx));
37 memset(offsety, 0, sizeof(offsety));
38 memset(movex, 0, sizeof(movex));
39 memset(movey, 0, sizeof(movey));
40 memset(endy, 0, sizeof(endy));
53 memset(menustring, 0, sizeof(menustring));
54 memset(registrationname, 0, sizeof(registrationname));
55 registrationnumber = 0;
62 deltah = 0,deltav = 0;
63 mousecoordh = 0,mousecoordv = 0;
64 oldmousecoordh = 0,oldmousecoordv = 0;
65 rotation = 0,rotation2 = 0;
70 cameratogglekeydown = 0;
71 chattogglekeydown = 0;
74 drawmodetogglekeydown = 0;
75 explodetogglekeydown = 0;
76 detailtogglekeydown = 0;
86 // XYZ realhawkcoords;
98 campaignnumlevels = 0;
100 memset(campaignmapname, 0, sizeof(campaignmapname));
101 memset(campaigndescription, 0, sizeof(campaigndescription));
102 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
103 memset(campaignnumnext, 0, sizeof(campaignnumnext));
104 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
105 int campaignchoicesmade;
106 memset(campaignchoices, 0, sizeof(campaignchoices));
107 memset(campaignlocationx, 0, sizeof(campaignlocationx));
108 memset(campaignlocationy, 0, sizeof(campaignlocationy));
109 memset(campaignlocationy, 0, sizeof(campaignlocationy));
111 campaignchoicenum = 0;
113 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
119 memset(levelorder, 0, sizeof(levelorder));
120 memset(levelvisible, 0, sizeof(levelvisible));
121 memset(levelhighlight, 0, sizeof(levelhighlight));
125 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
140 envtogglekeydown = 0;
141 slomotogglekeydown = 0;
142 texturesizetogglekeydown = 0;
143 freezetogglekeydown = 0;
157 // XYZ pathpoint[30];
159 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
160 memset(pathpointconnect, 0, sizeof(pathpointconnect));
161 pathpointselected = 0;
165 numchallengelevels = 0;
170 memset(consoletext, 0, sizeof(consoletext));
171 memset(consolechars, 0, sizeof(consolechars));
173 memset(displaytext, 0, sizeof(displaytext));
174 memset(displaychars, 0, sizeof(displaychars));
175 memset(displaytime, 0, sizeof(displaytime));
176 displayblinkdelay = 0;
180 consoletogglekeydown = 0;
181 consoleblinkdelay = 0;
184 // memset(togglekey, 0, sizeof(togglekey));
185 // memset(togglekeydelay, 0, sizeof(togglekeydelay));
189 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
196 // XYZ boundary[360];
203 memset(musicvolume, 0, sizeof(musicvolume));
204 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
213 accountactive = NULL;
218 void (Game::*method)();
221 void Game::fireSound(int sound) {
222 float gLoc[3]={0,0,0};
223 float vel[3]={0,0,0};
224 OPENAL_Sample_SetMinMaxDistance(samp[sound], 9999.0f, 99999.0f);
225 PlaySoundEx( sound, samp[sound], NULL, true);
226 OPENAL_3D_SetAttributes(channels[sound], gLoc, vel);
227 OPENAL_SetVolume(channels[sound], 256);
228 OPENAL_SetPaused(channels[sound], false);
229 OPENAL_Sample_SetMinMaxDistance(samp[sound], 8.0f, 2000.0f);
232 void Game::inputText(char* str, int* charselected, int* nb_chars) {
238 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
239 SDL_EnableUNICODE(true);
242 SDL_PollEvent(&evenement);
244 switch(evenement.type) {
246 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
253 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
254 if((*charselected)!=0) {
255 for(i=(*charselected)-1;i<255;i++){
262 } else if(evenement.key.keysym.sym==SDLK_DELETE){
263 for(i=(*charselected);i<255;i++){
268 } else if(evenement.key.keysym.sym==SDLK_LEFT){
269 if((*charselected)!=0)
271 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
272 if((*charselected)<(*nb_chars))
274 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
276 } else if((evenement.key.keysym.unicode<127)&&((*nb_chars)<60)&&(evenement.key.keysym.sym!=SDLK_LSHIFT)&&(evenement.key.keysym.sym!=SDLK_RSHIFT)) {
277 for(i=255;i>=(*charselected)+1;i--){
280 str[*charselected]=evenement.key.keysym.unicode;
288 SDL_EnableKeyRepeat(0,0); // disable key repeat
289 SDL_EnableUNICODE(false);
293 void Game::setKeySelected() {
295 params_thread* data = new params_thread;
297 data->method = &Game::setKeySelected_thread;
298 printf("launch thread\n");
299 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
300 if ( thread == NULL ) {
301 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
307 void Game::setKeySelected_thread() {
311 SDL_WaitEvent(&evenement);
312 switch(evenement.type) {
314 keycode = evenement.key.keysym.sym;
316 case SDL_MOUSEBUTTONDOWN:
317 keycode = SDLK_LAST+evenement.button.button;
323 if(keycode != SDLK_ESCAPE) {
326 case 0: forwardkey=keycode;
328 case 1: backkey=keycode;
330 case 2: leftkey=keycode;
332 case 3: rightkey=keycode;
334 case 4: crouchkey=keycode;
336 case 5: jumpkey=keycode;
338 case 6: drawkey=keycode;
340 case 7: throwkey=keycode;
342 case 8: attackkey=keycode;
352 int Game::thread(void *data) {
353 params_thread* pt = (params_thread*)data;
355 (pt->game->*(pt->method))();