2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
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.
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.
15 See the GNU General Public License for more details.
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.
23 #include "openal_wrapper.h"
25 extern float screenwidth,screenheight;
26 extern float viewdistance;
28 extern XYZ lightlocation;
29 extern float lightambient[3],lightbrightness[3];
30 extern float fadestart;
31 extern float texscale;
34 extern Animation animation[animation_count];
35 extern Skeleton testskeleton;
37 extern OPENAL_SAMPLE *samp[100];
38 extern int channels[100];
39 extern Terrain terrain;
40 extern Sprites sprites;
41 extern int kTextureSize;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern float terraindetail;
46 extern Objects objects;
48 extern bool cellophane;
49 extern GLubyte bloodText[512*512*3];
50 extern GLubyte wolfbloodText[512*512*3];
51 extern bool ismotionblur;
52 extern bool trilinear;
54 extern bool musictoggle;
55 extern Weapons weapons;
56 extern Person player[maxplayers];
57 extern int numplayers;
58 extern int environment;
59 extern bool ambientsound;
60 extern float multiplier;
61 extern int newnetmessages;
62 extern int netdatanew;
64 extern bool stillloading;
65 extern TGAImageRec texture;
69 extern int oldmainmenu;
70 extern bool visibleloading;
71 extern int loadscreencolor;
72 extern float flashamount,flashr,flashg,flashb;
73 extern int flashdelay;
74 extern int whichjointstartarray[26];
75 extern int whichjointendarray[26];
76 extern int difficulty;
77 extern float tintr,tintg,tintb;
78 extern float slomospeed;
79 extern char mapname[256];
80 extern bool gamestarted;
82 extern int numaccounts;
83 extern int accountactive;
84 extern int accountdifficulty[10];
85 extern int accountprogress[10];
86 extern float accountpoints[10];
87 extern float accounthighscore[10][50];
88 extern float accountfasttime[10][50];
89 extern bool accountunlocked[10][60];
90 extern char accountname[10][256];
92 extern int numdialogues;
93 extern int numdialogueboxes[20];
94 extern int dialoguetype[20];
95 extern int dialogueboxlocation[20][20];
96 extern float dialogueboxcolor[20][20][3];
97 extern int dialogueboxsound[20][20];
98 extern char dialoguetext[20][20][128];
99 extern char dialoguename[20][20][64];
100 extern XYZ dialoguecamera[20][20];
101 extern float dialoguecamerarotation[20][20];
102 extern float dialoguecamerarotation2[20][20];
103 extern int indialogue;
104 extern int whichdialogue;
105 extern float dialoguetime;
107 extern float accountcampaignhighscore[10];
108 extern float accountcampaignfasttime[10];
109 extern float accountcampaignscore[10];
110 extern float accountcampaigntime[10];
112 extern int accountcampaignchoicesmade[10];
113 extern int accountcampaignchoices[10][5000];
115 extern OPENAL_STREAM * strm[20];
117 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
118 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
120 void LOG(const std::string &fmt, ...)
122 // !!! FIXME: write me.
126 Game::TextureList Game::textures;
135 accountcampaignchoicesmade[accountactive]=0;
136 accountcampaignscore[accountactive]=0;
137 accountcampaigntime[accountactive]=0;
142 sprintf (mapname, ":Data:Users");
145 tfile=fopen( mapname, "wb" );
148 fpackf(tfile, "Bi", numaccounts);
149 fpackf(tfile, "Bi", accountactive);
152 for(i=0;i<numaccounts;i++)
154 fpackf(tfile, "Bf", accountcampaigntime[i]);
155 fpackf(tfile, "Bf", accountcampaignscore[i]);
156 fpackf(tfile, "Bf", accountcampaignfasttime[i]);
157 fpackf(tfile, "Bf", accountcampaignhighscore[i]);
158 fpackf(tfile, "Bi", accountdifficulty[i]);
159 fpackf(tfile, "Bi", accountprogress[i]);
160 fpackf(tfile, "Bi", accountcampaignchoicesmade[i]);
161 for(j=0;j<accountcampaignchoicesmade[i];j++)
163 fpackf(tfile, "Bi", accountcampaignchoices[i][j]);
165 fpackf(tfile, "Bf", accountpoints[i]);
168 fpackf(tfile, "Bf", accounthighscore[i][j]);
169 fpackf(tfile, "Bf", accountfasttime[i][j]);
173 fpackf(tfile, "Bb", accountunlocked[i][j]);
175 fpackf(tfile, "Bi", strlen(accountname[i]));
176 if(strlen(accountname[i])>0)
178 for(j=0;j<(int)strlen(accountname[i]);j++)
180 fpackf(tfile, "Bb", accountname[i][j]);
189 TexIter it = textures.begin();
190 for (; it != textures.end(); ++it)
192 if (glIsTexture(it->second))
193 glDeleteTextures(1, &it->second);
197 LOG("Shutting down sound system...");
199 OPENAL_StopSound(OPENAL_ALL);
201 // this is causing problems on Linux, but we'll force an _exit() a little
202 // later in the shutdown process. --ryan.
204 #define streamcount 20
205 #define samplecount 100
207 for (i=0; i < samplecount; ++i)
209 OPENAL_Sample_Free(samp[i]);
212 for (i=0; i < streamcount; ++i)
214 OPENAL_Stream_Close(strm[i]);
227 //void Game::LoadSounds();
228 void Game::LoadSounds()
232 LOG(std::string("Loading sounds..."));
234 OPENAL_3D_SetDopplerFactor(0);
236 OPENAL_SetSFXMasterVolume((int)(volume*255));
238 samp[footstepsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:footstepsnow1.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
239 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
241 samp[footstepsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:footstepsnow2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
242 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
244 samp[footstepsound3] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:footstepstone1.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
245 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
247 samp[footstepsound4] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:footstepstone2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
248 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
250 samp[landsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:land.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
251 OPENAL_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f);
253 samp[jumpsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:jump.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
254 OPENAL_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f);
256 samp[hawksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:hawk.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
257 OPENAL_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f);
259 samp[whooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:whoosh.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
260 OPENAL_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f);
261 OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
263 samp[landsound1] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:land1.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
264 OPENAL_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f);
268 samp[landsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:land2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
269 OPENAL_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f);
271 samp[breaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:broken.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
272 OPENAL_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f);
274 samp[lowwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Lowwhoosh.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
275 OPENAL_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f);
277 samp[midwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:midwhoosh.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
278 OPENAL_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f);
280 samp[highwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:highwhoosh.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
281 OPENAL_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f);
283 samp[movewhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:movewhoosh.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
284 OPENAL_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f);
286 samp[heavyimpactsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:heavyimpact.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
287 OPENAL_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f);
289 samp[whooshhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Whooshhit.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
290 OPENAL_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f);
292 samp[thudsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:thud.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
293 OPENAL_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f);
295 samp[alarmsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:alarm.ogg", OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
296 OPENAL_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f);
298 samp[breaksound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:break.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
299 OPENAL_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f);
301 samp[knifedrawsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:knifedraw.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
302 OPENAL_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f);
304 samp[knifesheathesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:knifesheathe.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
305 OPENAL_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f);
307 samp[fleshstabsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Fleshstab.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
308 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f);
310 samp[fleshstabremovesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Fleshstabremove.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
311 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f);
313 samp[knifeswishsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:knifeswish.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
314 OPENAL_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f);
316 samp[knifeslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:knifeslice.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
317 OPENAL_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f);
319 samp[swordslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:swordslice.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
320 OPENAL_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f);
322 samp[skidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:skid.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
323 OPENAL_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f);
325 samp[snowskidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:snowskid.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
326 OPENAL_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f);
328 samp[bushrustle] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:bushrustle.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
329 OPENAL_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f);
331 samp[clank1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:clank1.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
332 OPENAL_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f);
334 samp[clank2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:clank2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
335 OPENAL_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f);
337 samp[clank3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:clank3.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
338 OPENAL_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f);
340 samp[clank4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:clank4.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
341 OPENAL_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f);
343 samp[consolesuccesssound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:consolesuccess.ogg", OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
344 OPENAL_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f);
346 samp[consolefailsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:consolefail.ogg", OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
347 OPENAL_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f);
349 samp[metalhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:MetalHit.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
350 OPENAL_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f);
352 samp[clawslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:clawslice.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
353 OPENAL_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f);
355 samp[splattersound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:splatter.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
356 OPENAL_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f);
358 samp[growlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Growl.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
359 OPENAL_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f);
361 samp[growl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:Growl2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
362 OPENAL_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f);
364 samp[barksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:bark.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
365 OPENAL_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f);
367 samp[bark2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:bark2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
368 OPENAL_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f);
370 samp[bark3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:bark3.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
371 OPENAL_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f);
373 samp[snarlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:snarl.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
374 OPENAL_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f);
377 samp[snarl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:snarl2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
378 OPENAL_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f);
380 samp[barkgrowlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:barkgrowl.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
381 OPENAL_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f);
383 samp[rabbitattacksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitattack.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
384 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f);
386 samp[rabbitattack2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitattack2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
387 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f);
389 samp[rabbitattack3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitattack3.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
390 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f);
392 samp[rabbitattack4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitattack4.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
393 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f);
395 samp[rabbitpainsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitpain.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
396 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f);
398 samp[rabbitpain1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitpain2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
399 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f);
401 /*samp[rabbitpain2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitpain2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
402 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f);
404 samp[rabbitchitter] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitchitter.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
405 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f);
407 samp[rabbitchitter2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:rabbitchitter2.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
408 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f);
410 samp[swordstaffsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:swordstaff.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
411 OPENAL_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f);
413 samp[staffbodysound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:staffbody.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
414 OPENAL_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f);
416 samp[staffheadsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:staffhead.ogg", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
417 OPENAL_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f);
419 samp[staffbreaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ":Data:Sounds:staffbreak.wav", OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
420 OPENAL_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f);
423 void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
429 LOG(std::string("Loading texture...") + fileName);
431 unsigned char fileNamep[256];
432 CopyCStringToPascal(fileName,fileNamep);
434 upload_image( fileNamep ,hasalpha);
436 // std::string fname(fileName);
437 // std::transform(fname.begin(), fname.end(), tolower);
438 // TexIter it = textures.find(fname);
442 //if(textures.end() == it)
445 if ( texture.bpp == 24 )
450 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
452 if(!*textureid)glGenTextures( 1, textureid );
453 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
455 glBindTexture( GL_TEXTURE_2D, *textureid);
456 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
457 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
458 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
459 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
461 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0,
462 // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data);
464 //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data );
466 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
468 // textures.insert(std::make_pair(fname, *textureid));
472 // *textureid = it->second;
476 void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
484 LOG(std::string("Loading texture (S)...") + fileName);
487 unsigned char fileNamep[256];
488 CopyCStringToPascal(fileName,fileNamep);
490 upload_image( fileNamep ,0);
491 //LoadTGA( fileName );
493 // std::string fname(fileName);
494 // std::transform(fname.begin(), fname.end(), tolower);
495 // TexIter it = textures.find(fname);
499 //if(textures.end() == it)
501 bytesPerPixel=texture.bpp/8;
504 if ( texture.bpp == 24 )
509 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
511 if(!*textureid)glGenTextures( 1, textureid );
512 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
514 glBindTexture( GL_TEXTURE_2D, *textureid);
515 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
516 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
517 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
518 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
521 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
522 if((i+1)%4||type==GL_RGB){
523 array[tempnum]=texture.data[i];
528 *skinsize=texture.sizeX;
530 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_RGB, GL_UNSIGNED_BYTE, array );
532 // textures.insert(std::make_pair(fname, *textureid));
536 // *textureid = it->second;
540 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
547 LOG(std::string("Loading (S)...") + fileName);
550 float temptexdetail=texdetail;
552 //upload_image( fileName );
553 //LoadTGA( fileName );
555 unsigned char fileNamep[256];
556 CopyCStringToPascal(fileName,fileNamep);
558 upload_image( fileNamep ,0);
559 texdetail=temptexdetail;
563 bytesPerPixel=texture.bpp/8;
566 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
567 if((i+1)%4||bytesPerPixel==3){
568 array[tempnum]=texture.data[i];
575 bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
582 //upload_image( fileName );
583 //LoadTGA( fileName );
585 unsigned char fileNamep[256];
586 CopyCStringToPascal(fileName,fileNamep);
589 opened=upload_image( fileNamep ,1);
602 bytesPerPixel=texture.bpp/8;
606 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
607 if(bytesPerPixel==3)alphanum=255;
608 else if((i+1)%4==0)alphanum=texture.data[i];
610 if((i+1)%4||bytesPerPixel==3){
611 if((i%4)==0)texture.data[i]*=tintr;
612 if((i%4)==1)texture.data[i]*=tintg;
613 if((i%4)==2)texture.data[i]*=tintb;
614 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
624 //***************> ResizeGLScene() <******/
625 GLvoid Game::ReSizeGLScene(float fov, float pnear)
632 glViewport(0,0,screenwidth,screenheight);
634 glMatrixMode(GL_PROJECTION);
637 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
639 glMatrixMode(GL_MODELVIEW);
643 void Game::LoadingScreen()
645 static float loadprogress,minprogress,maxprogress;
646 static AbsoluteTime time = {0,0};
647 static AbsoluteTime frametime = {0,0};
648 AbsoluteTime currTime = UpTime ();
649 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
651 if (0 > deltaTime) // if negative microseconds
652 deltaTime /= -1000000.0;
653 else // else milliseconds
656 multiplier=deltaTime;
657 if(multiplier<.001)multiplier=.001;
658 if(multiplier>10)multiplier=10;
660 frametime = currTime; // reset for next time interval
665 glClearColor(0,0,0,1);
666 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
669 loadtime+=multiplier*4;
671 loadprogress=loadtime;
672 if(loadprogress>100)loadprogress=100;
674 //loadprogress=abs(Random()%100);
678 glEnable(GL_TEXTURE_2D);
679 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
680 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
681 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
682 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
683 glDisable(GL_CULL_FACE);
684 glDisable(GL_LIGHTING);
686 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
687 glPushMatrix(); // Store The Projection Matrix
688 glLoadIdentity(); // Reset The Projection Matrix
689 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
690 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
691 glPushMatrix(); // Store The Modelview Matrix
692 glLoadIdentity(); // Reset The Modelview Matrix
693 glTranslatef(screenwidth/2,screenheight/2,0);
694 glScalef((float)screenwidth/2,(float)screenheight/2,1);
695 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
697 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
698 //glColor4f(1,1,1,1);
699 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
700 if(loadscreencolor==1)glColor4f(1,0,0,1);
701 if(loadscreencolor==2)glColor4f(0,1,0,1);
702 if(loadscreencolor==3)glColor4f(0,0,1,1);
703 if(loadscreencolor==4)glColor4f(1,1,0,1);
704 if(loadscreencolor==5)glColor4f(1,0,1,1);
707 //glScalef(.25,.25,.25);
709 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
710 glVertex3f(-1, -1, 0.0f);
711 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
712 glVertex3f(1, -1, 0.0f);
713 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
714 glVertex3f(1, 1, 0.0f);
715 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
716 glVertex3f(-1, 1, 0.0f);
721 //glScalef(.25,.25,.25);
723 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
724 glVertex3f(-1, -1, 0.0f);
725 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
726 glVertex3f(1, -1, 0.0f);
727 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
728 glVertex3f(1, 1, 0.0f);
729 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
730 glVertex3f(-1, 1, 0.0f);
733 glDisable(GL_TEXTURE_2D);
734 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
735 glPopMatrix(); // Restore The Old Projection Matrix
736 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
737 glPopMatrix(); // Restore The Old Projection Matrix
741 glEnable(GL_TEXTURE_2D);
742 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
743 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
744 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
745 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
746 glDisable(GL_CULL_FACE);
747 glDisable(GL_LIGHTING);
749 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
750 glPushMatrix(); // Store The Projection Matrix
751 glLoadIdentity(); // Reset The Projection Matrix
752 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
753 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
754 glPushMatrix(); // Store The Modelview Matrix
755 glLoadIdentity(); // Reset The Modelview Matrix
756 glTranslatef(screenwidth/2,screenheight/2,0);
757 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
758 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
760 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
761 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
762 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
763 if(loadscreencolor==1)glColor4f(1,0,0,1);
764 if(loadscreencolor==2)glColor4f(0,1,0,1);
765 if(loadscreencolor==3)glColor4f(0,0,1,1);
766 if(loadscreencolor==4)glColor4f(1,1,0,1);
767 if(loadscreencolor==5)glColor4f(1,0,1,1);
770 //glScalef(.25,.25,.25);
772 glTexCoord2f(0+.5,0+.5);
773 glVertex3f(-1, -1, 0.0f);
774 glTexCoord2f(1+.5,0+.5);
775 glVertex3f(1, -1, 0.0f);
776 glTexCoord2f(1+.5,1+.5);
777 glVertex3f(1, 1, 0.0f);
778 glTexCoord2f(0+.5,1+.5);
779 glVertex3f(-1, 1, 0.0f);
782 glDisable(GL_TEXTURE_2D);
783 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
784 glPopMatrix(); // Restore The Old Projection Matrix
785 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
786 glPopMatrix(); // Restore The Old Projection Matrix
790 glEnable(GL_TEXTURE_2D);
791 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
792 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
793 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
794 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
795 glDisable(GL_CULL_FACE);
796 glDisable(GL_LIGHTING);
798 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
799 glPushMatrix(); // Store The Projection Matrix
800 glLoadIdentity(); // Reset The Projection Matrix
801 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
802 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
803 glPushMatrix(); // Store The Modelview Matrix
804 glLoadIdentity(); // Reset The Modelview Matrix
805 glTranslatef(screenwidth/2,screenheight/2,0);
806 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
807 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
809 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
811 //glScalef(.25,.25,.25);
813 glTexCoord2f(0+.2,0+.8);
814 glVertex3f(-1, -1, 0.0f);
815 glTexCoord2f(1+.2,0+.8);
816 glVertex3f(1, -1, 0.0f);
817 glTexCoord2f(1+.2,1+.8);
818 glVertex3f(1, 1, 0.0f);
819 glTexCoord2f(0+.2,1+.8);
820 glVertex3f(-1, 1, 0.0f);
823 glDisable(GL_TEXTURE_2D);
824 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
825 glPopMatrix(); // Restore The Old Projection Matrix
826 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
827 glPopMatrix(); // Restore The Old Projection Matrix
833 glEnable(GL_TEXTURE_2D);
834 static char string[256]="";
835 sprintf (string, "LOADING... %d%",(int)loadprogress);
837 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
838 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
839 text.glPrint(280,125,string,1,1,640,480);
843 if(flashamount>1)flashamount=1;
844 if(flashdelay<=0)flashamount-=multiplier;
846 if(flashamount<0)flashamount=0;
847 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
848 glDisable(GL_CULL_FACE);
849 glDisable(GL_LIGHTING);
850 glDisable(GL_TEXTURE_2D);
852 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
853 glPushMatrix(); // Store The Projection Matrix
854 glLoadIdentity(); // Reset The Projection Matrix
855 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
856 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
857 glPushMatrix(); // Store The Modelview Matrix
858 glLoadIdentity(); // Reset The Modelview Matrix
859 glScalef(screenwidth,screenheight,1);
860 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
862 glColor4f(flashr,flashg,flashb,flashamount);
864 glVertex3f(0, 0, 0.0f);
865 glVertex3f(256, 0, 0.0f);
866 glVertex3f(256, 256, 0.0f);
867 glVertex3f(0, 256, 0.0f);
869 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
870 glPopMatrix(); // Restore The Old Projection Matrix
871 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
872 glPopMatrix(); // Restore The Old Projection Matrix
873 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
874 glEnable(GL_CULL_FACE);
884 void Game::FadeLoadingScreen(float howmuch)
886 static float loadprogress,minprogress,maxprogress;
891 glClearColor(0,0,0,1);
892 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
894 loadprogress=howmuch;
896 //loadprogress=abs(Random()%100);
900 //glEnable(GL_TEXTURE_2D);
901 glDisable(GL_TEXTURE_2D);
902 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
903 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
904 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
905 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
906 glDisable(GL_CULL_FACE);
907 glDisable(GL_LIGHTING);
909 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
910 glPushMatrix(); // Store The Projection Matrix
911 glLoadIdentity(); // Reset The Projection Matrix
912 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
913 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
914 glPushMatrix(); // Store The Modelview Matrix
915 glLoadIdentity(); // Reset The Modelview Matrix
916 glTranslatef(screenwidth/2,screenheight/2,0);
917 glScalef((float)screenwidth/2,(float)screenheight/2,1);
918 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
920 glColor4f(loadprogress/100,0,0,1);
921 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
922 if(loadscreencolor==1)glColor4f(1,0,0,1);
923 if(loadscreencolor==2)glColor4f(0,1,0,1);
924 if(loadscreencolor==3)glColor4f(0,0,1,1);
925 if(loadscreencolor==4)glColor4f(1,1,0,1);
926 if(loadscreencolor==5)glColor4f(1,0,1,1);
929 //glScalef(.25,.25,.25);
932 glVertex3f(-1, -1, 0.0f);
934 glVertex3f(1, -1, 0.0f);
936 glVertex3f(1, 1, 0.0f);
938 glVertex3f(-1, 1, 0.0f);
941 glDisable(GL_TEXTURE_2D);
942 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
943 glPopMatrix(); // Restore The Old Projection Matrix
944 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
945 glPopMatrix(); // Restore The Old Projection Matrix
950 glEnable(GL_TEXTURE_2D);
951 static char string[256]="";
952 sprintf (string, "LOADING... %d%",(int)loadprogress);
954 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
955 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
956 text.glPrint(280,125,string,1,1,640,480);
963 void Game::InitGame()
966 ProcessSerialNumber PSN;
967 ProcessInfoRec pinfo;
970 /* set up process serial number */
971 PSN.highLongOfPSN = 0;
972 PSN.lowLongOfPSN = kCurrentProcess;
973 /* set up info block */
974 pinfo.processInfoLength = sizeof(pinfo);
975 pinfo.processName = NULL;
976 pinfo.processAppSpec = &pspec;
977 /* grab the vrefnum and directory */
978 err = GetProcessInformation(&PSN, &pinfo);
980 vRefNum = pspec.vRefNum;
991 numchallengelevels=14;
993 /*char tempstring[256];
994 sprintf (tempstring, "%s", registrationname);
1000 longnum = MD5_string ( tempstring);
1001 //longnum = 1111111111111111;
1002 num1 = longnum/100000000;
1003 num2 = longnum%100000000;
1004 sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
1011 sprintf (mapname, ":Data:Users");
1012 tfile=fopen( mapname, "rb" );
1015 funpackf(tfile, "Bi", &numaccounts);
1016 funpackf(tfile, "Bi", &accountactive);
1019 for(i=0;i<numaccounts;i++)
1021 funpackf(tfile, "Bf", &accountcampaigntime[i]);
1022 funpackf(tfile, "Bf", &accountcampaignscore[i]);
1023 funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
1024 funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
1025 funpackf(tfile, "Bi", &accountdifficulty[i]);
1026 funpackf(tfile, "Bi", &accountprogress[i]);
1027 funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
1028 for(j=0;j<accountcampaignchoicesmade[i];j++)
1030 funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
1031 if (accountcampaignchoices[i][j] >= 10)
1033 accountcampaignchoices[i][j] = 0;
1036 funpackf(tfile, "Bf", &accountpoints[i]);
1039 funpackf(tfile, "Bf", &accounthighscore[i][j]);
1040 funpackf(tfile, "Bf", &accountfasttime[i][j]);
1044 funpackf(tfile, "Bb", &accountunlocked[i][j]);
1047 funpackf(tfile, "Bi", &temp);
1052 funpackf(tfile, "Bb", &accountname[i][j]);
1065 whichjointstartarray[0]=righthip;
1066 whichjointendarray[0]=rightfoot;
1068 whichjointstartarray[1]=righthip;
1069 whichjointendarray[1]=rightankle;
1071 whichjointstartarray[2]=righthip;
1072 whichjointendarray[2]=rightknee;
1074 whichjointstartarray[3]=rightknee;
1075 whichjointendarray[3]=rightankle;
1077 whichjointstartarray[4]=rightankle;
1078 whichjointendarray[4]=rightfoot;
1080 whichjointstartarray[5]=lefthip;
1081 whichjointendarray[5]=leftfoot;
1083 whichjointstartarray[6]=lefthip;
1084 whichjointendarray[6]=leftankle;
1086 whichjointstartarray[7]=lefthip;
1087 whichjointendarray[7]=leftknee;
1089 whichjointstartarray[8]=leftknee;
1090 whichjointendarray[8]=leftankle;
1092 whichjointstartarray[9]=leftankle;
1093 whichjointendarray[9]=leftfoot;
1095 whichjointstartarray[10]=abdomen;
1096 whichjointendarray[10]=rightshoulder;
1098 whichjointstartarray[11]=abdomen;
1099 whichjointendarray[11]=rightelbow;
1101 whichjointstartarray[12]=abdomen;
1102 whichjointendarray[12]=rightwrist;
1104 whichjointstartarray[13]=abdomen;
1105 whichjointendarray[13]=righthand;
1107 whichjointstartarray[14]=rightshoulder;
1108 whichjointendarray[14]=rightelbow;
1110 whichjointstartarray[15]=rightelbow;
1111 whichjointendarray[15]=rightwrist;
1113 whichjointstartarray[16]=rightwrist;
1114 whichjointendarray[16]=righthand;
1116 whichjointstartarray[17]=abdomen;
1117 whichjointendarray[17]=leftshoulder;
1119 whichjointstartarray[18]=abdomen;
1120 whichjointendarray[18]=leftelbow;
1122 whichjointstartarray[19]=abdomen;
1123 whichjointendarray[19]=leftwrist;
1125 whichjointstartarray[20]=abdomen;
1126 whichjointendarray[20]=lefthand;
1128 whichjointstartarray[21]=leftshoulder;
1129 whichjointendarray[21]=leftelbow;
1131 whichjointstartarray[22]=leftelbow;
1132 whichjointendarray[22]=leftwrist;
1134 whichjointstartarray[23]=leftwrist;
1135 whichjointendarray[23]=lefthand;
1137 whichjointstartarray[24]=abdomen;
1138 whichjointendarray[24]=neck;
1140 whichjointstartarray[25]=neck;
1141 whichjointendarray[25]=head;
1143 FadeLoadingScreen(0);
1147 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1149 int temptexdetail=texdetail;
1151 text.LoadFontTexture(":Data:Textures:Font.png");
1153 texdetail=temptexdetail;
1155 FadeLoadingScreen(10);
1171 for (int it = 0; it < 100; ++it)
1176 for (int it = 0; it < 20; ++it)
1181 LOG("Initializing sound system...");
1186 extern bool cmdline(const char *cmd);
1187 unsigned char rc = 0;
1188 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
1189 if (cmdline("forceoss")) // ...but let user override that.
1190 output = OPENAL_OUTPUT_OSS;
1191 else if (cmdline("nosound"))
1192 output = OPENAL_OUTPUT_NOSOUND;
1194 OPENAL_SetOutput(output);
1195 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
1197 // if we tried ALSA and failed, fall back to OSS.
1198 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
1201 output = OPENAL_OUTPUT_OSS;
1202 OPENAL_SetOutput(output);
1203 rc = OPENAL_Init(44100, 32, 0);
1210 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
1211 OPENAL_SetOutput(output);
1212 rc = OPENAL_Init(44100, 32, 0);
1215 OPENAL_Init(44100, 32, 0);
1218 OPENAL_SetSFXMasterVolume((int)(volume*255));
1220 strm[stream_music3] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
1221 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
1222 OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL);
1225 // PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
1226 PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
1227 OPENAL_SetPaused(channels[stream_music3], false);
1228 OPENAL_SetVolume(channels[stream_music3], 256);
1231 FadeLoadingScreen(20);
1234 strm[stream_wind] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1235 // OPENAL_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
1236 OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL);
1238 FadeLoadingScreen(30);
1240 strm[stream_desertambient] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1241 // OPENAL_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
1242 OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL);
1245 FadeLoadingScreen(40);
1247 samp[firestartsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1248 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1250 strm[stream_firesound] = OPENAL_Stream_Open(":Data:Sounds:fire.ogg", OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1251 // OPENAL_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
1252 OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL);
1254 FadeLoadingScreen(50);
1256 samp[fireendsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1257 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1260 strm[stream_music1grass] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
1261 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
1262 OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL);
1264 strm[stream_music1snow] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
1265 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
1266 OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL);
1268 FadeLoadingScreen(60);
1270 strm[stream_music1desert] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
1271 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
1272 OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL);
1274 FadeLoadingScreen(80);
1275 strm[stream_music2] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
1276 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
1277 OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL);
1282 FadeLoadingScreen(90);
1285 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
1287 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
1288 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
1289 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
1291 temptexdetail=texdetail;
1292 if(texdetail>2)texdetail=2;
1293 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
1294 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1295 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
1296 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1297 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
1298 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
1299 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
1300 texdetail=temptexdetail;
1305 FadeLoadingScreen(95);
1316 newscreenwidth=screenwidth;
1317 newscreenheight=screenheight;
1322 float gLoc[3]={0,0,0};
1323 float vel[3]={0,0,0};
1324 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1325 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1326 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1327 OPENAL_SetVolume(channels[firestartsound], 256);
1328 OPENAL_SetPaused(channels[firestartsound], false);
1329 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1340 void Game::LoadStuff()
1342 static float temptexdetail;
1343 static float viewdistdetail;
1344 static int i,j,texsize;
1351 /*musicvolume[3]=512;
1352 PlaySoundEx( music4, samp[music4], NULL, true);
1353 OPENAL_SetPaused(channels[music4], false);
1354 OPENAL_SetVolume(channels[music4], 512);
1360 //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1364 for(i=0;i<maxplayers;i++)
1366 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
1368 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
1370 player[i].skeleton.drawmodel.textureptr=0;;
1373 //temptexdetail=texdetail;
1376 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
1377 //texdetail=temptexdetail;
1379 temptexdetail=texdetail;
1381 text.LoadFontTexture(":Data:Textures:Font.png");
1383 texdetail=temptexdetail;
1388 viewdistance=50*megascale*viewdistdetail;
1408 realtexdetail=texdetail;
1411 if(texdetail<1)texdetail=1;
1412 realtexdetail=texdetail*4;
1418 /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1);
1420 LoadTexture(":Data:Textures:rock.png",&terraintexture2,1);
1422 LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1426 LOG("Loading weapon data...");
1428 LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1);
1429 LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1);
1430 LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1);
1431 LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0);
1432 LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0);
1433 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0);
1434 LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0);
1436 weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
1437 weapons.throwingknifemodel.Scale(.001,.001,.001);
1438 //weapons.throwingknifemodel.Rotate(0,0,-90);
1439 weapons.throwingknifemodel.Rotate(90,0,0);
1440 weapons.throwingknifemodel.Rotate(0,90,0);
1441 weapons.throwingknifemodel.flat=0;
1442 weapons.throwingknifemodel.CalculateNormals(1);
1443 //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1);
1445 weapons.swordmodel.load((char *)":Data:Models:sword.solid",1);
1446 weapons.swordmodel.Scale(.001,.001,.001);
1447 //weapons.swordmodel.Rotate(0,0,-90);
1448 weapons.swordmodel.Rotate(90,0,0);
1449 weapons.swordmodel.Rotate(0,90,0);
1450 weapons.swordmodel.Rotate(0,0,90);
1451 weapons.swordmodel.flat=1;
1452 weapons.swordmodel.CalculateNormals(1);
1453 //weapons.swordmodel.ScaleNormals(-1,-1,-1);
1455 weapons.staffmodel.load((char *)":Data:Models:staff.solid",1);
1456 weapons.staffmodel.Scale(.005,.005,.005);
1457 //weapons.staffmodel.Rotate(0,0,-90);
1458 weapons.staffmodel.Rotate(90,0,0);
1459 weapons.staffmodel.Rotate(0,90,0);
1460 weapons.staffmodel.Rotate(0,0,90);
1461 weapons.staffmodel.flat=1;
1462 weapons.staffmodel.CalculateNormals(1);
1463 //weapons.staffmodel.ScaleNormals(-1,-1,-1);
1465 //temptexdetail=texdetail;
1466 //if(texdetail>4)texdetail=4;
1467 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
1469 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
1471 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
1473 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
1476 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
1478 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
1480 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
1482 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
1484 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
1486 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
1488 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
1490 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
1491 //texdetail=temptexdetail;
1492 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
1496 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
1498 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
1501 //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
1504 LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1505 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1506 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1507 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1508 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1509 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1510 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1511 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1512 LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
1513 LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
1514 LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
1518 ReSizeGLScene(90,.01);
1525 if(detail)kTextureSize=1024;
1526 if(detail==1)kTextureSize=512;
1527 if(detail==0)kTextureSize=256;
1530 //drawmode=motionblurmode;
1532 //Set up distant light
1536 light.ambient[0]=.2;
1537 light.ambient[1]=.2;
1538 light.ambient[2]=.24;
1541 light.location.z=-.2;
1542 Normalise(&light.location);
1552 texscale=.2/megascale/viewdistdetail;
1553 terrain.scale=3*megascale*terraindetail*viewdistdetail;
1555 viewer.x=terrain.size/2*terrain.scale;
1556 viewer.z=terrain.size/2*terrain.scale;
1558 hawk.load((char *)":Data:Models:hawk.solid",1);
1559 hawk.Scale(.03,.03,.03);
1560 hawk.Rotate(90,1,1);
1561 hawk.CalculateNormals(0);
1562 hawk.ScaleNormals(-1,-1,-1);
1563 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
1564 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
1565 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
1568 eye.load((char *)":Data:Models:eye.solid",1);
1569 eye.Scale(.03,.03,.03);
1570 eye.CalculateNormals(0);
1572 cornea.load((char *)":Data:Models:cornea.solid",1);
1573 cornea.Scale(.03,.03,.03);
1574 cornea.CalculateNormals(0);
1576 iris.load((char *)":Data:Models:iris.solid",1);
1577 iris.Scale(.03,.03,.03);
1578 iris.CalculateNormals(0);
1580 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
1581 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
1589 //if(targetlevel!=7)
1590 Loadlevel(targetlevel);
1593 rabbitcoords=player[0].coords;
1594 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
1596 animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
1598 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
1599 animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
1601 animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
1602 animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
1604 animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
1605 animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
1606 animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
1607 animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
1608 animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
1610 animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
1611 animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
1612 animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
1613 animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
1614 animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
1615 animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1616 animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1617 animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
1619 animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
1620 animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
1621 animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
1622 animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
1623 animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
1624 animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
1625 animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
1626 animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
1627 animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
1628 animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
1629 animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
1631 animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
1632 animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
1633 animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
1634 animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
1635 animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
1637 animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
1638 animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
1639 animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
1640 animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
1641 animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
1642 animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
1643 animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
1644 animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
1646 animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
1647 animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
1648 animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
1649 animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
1650 animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
1651 animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
1652 animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
1653 animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
1655 animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
1656 animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
1657 animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
1658 animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
1659 animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
1660 animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
1661 animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
1662 animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
1663 animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
1664 animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
1665 animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
1666 animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
1667 animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
1668 animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
1669 animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
1670 animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
1671 animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
1672 animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
1673 animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
1674 animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
1675 animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
1676 animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
1677 animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
1678 animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
1679 animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
1680 animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
1681 animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
1682 animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
1683 animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
1684 animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
1685 animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
1686 animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
1687 animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
1688 animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
1689 animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
1690 animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
1691 animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
1692 animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
1693 animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
1694 animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
1695 animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
1696 animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
1697 animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
1698 animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
1699 animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
1700 animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
1701 animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
1702 animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
1703 animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
1704 animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
1705 animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
1707 animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
1708 animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
1709 animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
1711 animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
1712 animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
1713 animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
1714 animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
1715 animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
1716 //Fix knife stab, too lazy to do it manually
1720 for(i=0;i<player[0].skeleton.num_joints;i++){
1721 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
1722 animation[knifesneakattackanim].position[i][j]+=moveamount;
1729 for(i=0;i<player[0].skeleton.num_joints;i++){
1730 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
1731 animation[knifesneakattackedanim].position[i][j]+=moveamount;
1738 for(i=0;i<player[0].skeleton.num_joints;i++){
1739 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
1740 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
1741 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
1742 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
1744 animation[dead1anim].speed[0]=0.001;
1745 animation[dead2anim].speed[0]=0.001;
1746 animation[dead3anim].speed[0]=0.001;
1747 animation[dead4anim].speed[0]=0.001;
1749 animation[dead1anim].speed[1]=0.001;
1750 animation[dead2anim].speed[1]=0.001;
1751 animation[dead3anim].speed[1]=0.001;
1752 animation[dead4anim].speed[1]=0.001;
1754 for(i=0;i<player[0].skeleton.num_joints;i++){
1755 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1756 animation[swordsneakattackanim].position[i][j]+=moveamount;
1761 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1762 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1768 for(i=0;i<player[0].skeleton.num_joints;i++){
1769 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1770 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1774 for(i=0;i<player[0].skeleton.num_joints;i++){
1775 for(j=0;j<animation[sleepanim].numframes;j++){
1776 animation[sleepanim].position[i][j]=DoRotation(animation[sleepanim].position[i][j],0,180,0);
1782 temptexdetail=texdetail;
1784 texdetail=temptexdetail;
1791 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1793 glGenTextures( 1, &screentexture );
1794 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1797 glEnable(GL_TEXTURE_2D);
1798 glBindTexture( GL_TEXTURE_2D, screentexture);
1799 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1800 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1802 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1808 /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1809 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1810 OPENAL_SetPaused(channels[consolesuccesssound], false);
1813 float gLoc[3]={0,0,0};
1814 float vel[3]={0,0,0};
1815 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1816 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1817 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1818 OPENAL_SetVolume(channels[fireendsound], 256);
1819 OPENAL_SetPaused(channels[fireendsound], false);
1820 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1833 terraintexture2 = 0;
1834 terraintexture3 = 0;
1838 loadscreentexture = 0;
1839 Maparrowtexture = 0;
1841 Mapcircletexture = 0;
1844 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
1848 memset(startx, 0, sizeof(startx));
1849 memset(starty, 0, sizeof(starty));
1850 memset(endx, 0, sizeof(endx));
1851 memset(endy, 0, sizeof(endy));
1853 memset(selectedlong, 0, sizeof(selectedlong));
1854 memset(offsetx, 0, sizeof(offsetx));
1855 memset(offsety, 0, sizeof(offsety));
1856 memset(movex, 0, sizeof(movex));
1857 memset(movey, 0, sizeof(movey));
1858 memset(endy, 0, sizeof(endy));
1871 memset(menustring, 0, sizeof(menustring));
1872 memset(registrationname, 0, sizeof(registrationname));
1873 registrationnumber = 0;
1877 newscreenheight = 0;
1880 deltah = 0,deltav = 0;
1881 mousecoordh = 0,mousecoordv = 0;
1882 oldmousecoordh = 0,oldmousecoordv = 0;
1883 rotation = 0,rotation2 = 0;
1888 cameratogglekeydown = 0;
1889 chattogglekeydown = 0;
1892 drawmodetogglekeydown = 0;
1893 explodetogglekeydown = 0;
1894 detailtogglekeydown = 0;
1904 // XYZ realhawkcoords;
1916 campaignnumlevels = 0;
1918 memset(campaignmapname, 0, sizeof(campaignmapname));
1919 memset(campaigndescription, 0, sizeof(campaigndescription));
1920 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
1921 memset(campaignnumnext, 0, sizeof(campaignnumnext));
1922 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
1923 int campaignchoicesmade;
1924 memset(campaignchoices, 0, sizeof(campaignchoices));
1925 memset(campaignlocationx, 0, sizeof(campaignlocationx));
1926 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1927 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1929 campaignchoicenum = 0;
1931 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
1935 numlevelspassed = 0;
1937 memset(levelorder, 0, sizeof(levelorder));
1938 memset(levelvisible, 0, sizeof(levelvisible));
1939 memset(levelhighlight, 0, sizeof(levelhighlight));
1943 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
1947 // XYZ rabbitcoords;
1958 envtogglekeydown = 0;
1959 slomotogglekeydown = 0;
1960 texturesizetogglekeydown = 0;
1961 freezetogglekeydown = 0;
1968 editorrotation2 = 0;
1975 // XYZ pathpoint[30];
1977 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
1978 memset(pathpointconnect, 0, sizeof(pathpointconnect));
1979 pathpointselected = 0;
1983 numchallengelevels = 0;
1986 archiveselected = 0;
1988 memset(consoletext, 0, sizeof(consoletext));
1989 memset(consolechars, 0, sizeof(consolechars));
1991 memset(displaytext, 0, sizeof(displaytext));
1992 memset(displaychars, 0, sizeof(displaychars));
1993 memset(displaytime, 0, sizeof(displaytime));
1994 displayblinkdelay = 0;
1996 displayselected = 0;
1998 consoletogglekeydown = 0;
1999 consoleblinkdelay = 0;
2001 consoleselected = 0;
2002 memset(togglekey, 0, sizeof(togglekey));
2003 memset(togglekeydelay, 0, sizeof(togglekeydelay));
2007 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
2014 // XYZ boundary[360];
2021 memset(musicvolume, 0, sizeof(musicvolume));
2022 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));