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;
995 /*char tempstring[256];
996 sprintf (tempstring, "%s", registrationname);
1002 longnum = MD5_string ( tempstring);
1003 //longnum = 1111111111111111;
1004 num1 = longnum/100000000;
1005 num2 = longnum%100000000;
1006 sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
1010 tfile=fopen( ":Data:Sounds:flame.ogg", "rb" );
1021 funpackf(tfile, "Bb", ®istered);
1024 funpackf(tfile, "Bi", &numchars);
1027 for(j=0;j<numchars;j++)
1029 funpackf(tfile, "Bb", ®istrationname[j]);
1031 registrationname[numchars]='\0';
1032 funpackf(tfile, "Bi", &num1);
1033 funpackf(tfile, "Bi", &num2);
1034 longnum=num2+num1*100000000;
1036 char tempstring[256];
1037 #if defined(__APPLE__)
1038 sprintf (tempstring, "%s", registrationname);
1039 #elif defined(_WIN32) || defined(__linux__)
1040 sprintf (tempstring, "%s-windows", registrationname);
1042 #error Please make sure you have the right registration key stuff here!
1044 longnuma = MD5_string ( tempstring);
1045 num1a = longnuma/100000000;
1046 num2a = longnuma%100000000;
1047 //if(num1a==num1&&num2a==num2)registered=1;
1048 if(numchars>2)registered=1;
1058 sprintf (mapname, ":Data:Users");
1059 tfile=fopen( mapname, "rb" );
1062 funpackf(tfile, "Bi", &numaccounts);
1063 funpackf(tfile, "Bi", &accountactive);
1066 for(i=0;i<numaccounts;i++)
1068 funpackf(tfile, "Bf", &accountcampaigntime[i]);
1069 funpackf(tfile, "Bf", &accountcampaignscore[i]);
1070 funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
1071 funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
1072 funpackf(tfile, "Bi", &accountdifficulty[i]);
1073 funpackf(tfile, "Bi", &accountprogress[i]);
1074 funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
1075 for(j=0;j<accountcampaignchoicesmade[i];j++)
1077 funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
1078 if (accountcampaignchoices[i][j] >= 10)
1080 accountcampaignchoices[i][j] = 0;
1083 funpackf(tfile, "Bf", &accountpoints[i]);
1086 funpackf(tfile, "Bf", &accounthighscore[i][j]);
1087 funpackf(tfile, "Bf", &accountfasttime[i][j]);
1091 funpackf(tfile, "Bb", &accountunlocked[i][j]);
1094 funpackf(tfile, "Bi", &temp);
1099 funpackf(tfile, "Bb", &accountname[i][j]);
1112 whichjointstartarray[0]=righthip;
1113 whichjointendarray[0]=rightfoot;
1115 whichjointstartarray[1]=righthip;
1116 whichjointendarray[1]=rightankle;
1118 whichjointstartarray[2]=righthip;
1119 whichjointendarray[2]=rightknee;
1121 whichjointstartarray[3]=rightknee;
1122 whichjointendarray[3]=rightankle;
1124 whichjointstartarray[4]=rightankle;
1125 whichjointendarray[4]=rightfoot;
1127 whichjointstartarray[5]=lefthip;
1128 whichjointendarray[5]=leftfoot;
1130 whichjointstartarray[6]=lefthip;
1131 whichjointendarray[6]=leftankle;
1133 whichjointstartarray[7]=lefthip;
1134 whichjointendarray[7]=leftknee;
1136 whichjointstartarray[8]=leftknee;
1137 whichjointendarray[8]=leftankle;
1139 whichjointstartarray[9]=leftankle;
1140 whichjointendarray[9]=leftfoot;
1142 whichjointstartarray[10]=abdomen;
1143 whichjointendarray[10]=rightshoulder;
1145 whichjointstartarray[11]=abdomen;
1146 whichjointendarray[11]=rightelbow;
1148 whichjointstartarray[12]=abdomen;
1149 whichjointendarray[12]=rightwrist;
1151 whichjointstartarray[13]=abdomen;
1152 whichjointendarray[13]=righthand;
1154 whichjointstartarray[14]=rightshoulder;
1155 whichjointendarray[14]=rightelbow;
1157 whichjointstartarray[15]=rightelbow;
1158 whichjointendarray[15]=rightwrist;
1160 whichjointstartarray[16]=rightwrist;
1161 whichjointendarray[16]=righthand;
1163 whichjointstartarray[17]=abdomen;
1164 whichjointendarray[17]=leftshoulder;
1166 whichjointstartarray[18]=abdomen;
1167 whichjointendarray[18]=leftelbow;
1169 whichjointstartarray[19]=abdomen;
1170 whichjointendarray[19]=leftwrist;
1172 whichjointstartarray[20]=abdomen;
1173 whichjointendarray[20]=lefthand;
1175 whichjointstartarray[21]=leftshoulder;
1176 whichjointendarray[21]=leftelbow;
1178 whichjointstartarray[22]=leftelbow;
1179 whichjointendarray[22]=leftwrist;
1181 whichjointstartarray[23]=leftwrist;
1182 whichjointendarray[23]=lefthand;
1184 whichjointstartarray[24]=abdomen;
1185 whichjointendarray[24]=neck;
1187 whichjointstartarray[25]=neck;
1188 whichjointendarray[25]=head;
1190 FadeLoadingScreen(0);
1194 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1196 int temptexdetail=texdetail;
1198 text.LoadFontTexture(":Data:Textures:Font.png");
1200 texdetail=temptexdetail;
1202 FadeLoadingScreen(10);
1218 for (int it = 0; it < 100; ++it)
1223 for (int it = 0; it < 20; ++it)
1228 LOG("Initializing sound system...");
1233 extern bool cmdline(const char *cmd);
1234 unsigned char rc = 0;
1235 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
1236 if (cmdline("forceoss")) // ...but let user override that.
1237 output = OPENAL_OUTPUT_OSS;
1238 else if (cmdline("nosound"))
1239 output = OPENAL_OUTPUT_NOSOUND;
1241 OPENAL_SetOutput(output);
1242 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
1244 // if we tried ALSA and failed, fall back to OSS.
1245 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
1248 output = OPENAL_OUTPUT_OSS;
1249 OPENAL_SetOutput(output);
1250 rc = OPENAL_Init(44100, 32, 0);
1257 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
1258 OPENAL_SetOutput(output);
1259 rc = OPENAL_Init(44100, 32, 0);
1262 OPENAL_Init(44100, 32, 0);
1265 OPENAL_SetSFXMasterVolume((int)(volume*255));
1267 strm[stream_music3] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
1268 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
1269 OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL);
1272 // PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
1273 PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
1274 OPENAL_SetPaused(channels[stream_music3], false);
1275 OPENAL_SetVolume(channels[stream_music3], 256);
1278 FadeLoadingScreen(20);
1281 strm[stream_wind] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1282 // OPENAL_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
1283 OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL);
1285 FadeLoadingScreen(30);
1287 strm[stream_desertambient] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1288 // OPENAL_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
1289 OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL);
1292 FadeLoadingScreen(40);
1294 samp[firestartsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1295 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1297 strm[stream_firesound] = OPENAL_Stream_Open(":Data:Sounds:fire.ogg", OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1298 // OPENAL_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
1299 OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL);
1301 FadeLoadingScreen(50);
1303 samp[fireendsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1304 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1307 strm[stream_music1grass] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
1308 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
1309 OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL);
1311 strm[stream_music1snow] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
1312 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
1313 OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL);
1315 FadeLoadingScreen(60);
1317 strm[stream_music1desert] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
1318 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
1319 OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL);
1321 FadeLoadingScreen(80);
1322 strm[stream_music2] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
1323 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
1324 OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL);
1329 FadeLoadingScreen(90);
1332 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
1334 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
1335 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
1336 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
1338 temptexdetail=texdetail;
1339 if(texdetail>2)texdetail=2;
1340 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
1341 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1342 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
1343 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1344 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
1345 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
1346 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
1347 texdetail=temptexdetail;
1352 FadeLoadingScreen(95);
1363 newscreenwidth=screenwidth;
1364 newscreenheight=screenheight;
1369 float gLoc[3]={0,0,0};
1370 float vel[3]={0,0,0};
1371 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1372 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1373 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1374 OPENAL_SetVolume(channels[firestartsound], 256);
1375 OPENAL_SetPaused(channels[firestartsound], false);
1376 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1387 void Game::LoadStuff()
1389 static float temptexdetail;
1390 static float viewdistdetail;
1391 static int i,j,texsize;
1398 /*musicvolume[3]=512;
1399 PlaySoundEx( music4, samp[music4], NULL, true);
1400 OPENAL_SetPaused(channels[music4], false);
1401 OPENAL_SetVolume(channels[music4], 512);
1407 //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1411 for(i=0;i<maxplayers;i++)
1413 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
1415 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
1417 player[i].skeleton.drawmodel.textureptr=0;;
1420 //temptexdetail=texdetail;
1423 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
1424 //texdetail=temptexdetail;
1426 temptexdetail=texdetail;
1428 text.LoadFontTexture(":Data:Textures:Font.png");
1430 texdetail=temptexdetail;
1435 viewdistance=50*megascale*viewdistdetail;
1455 realtexdetail=texdetail;
1458 if(texdetail<1)texdetail=1;
1459 realtexdetail=texdetail*4;
1465 /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1);
1467 LoadTexture(":Data:Textures:rock.png",&terraintexture2,1);
1469 LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1473 LOG("Loading weapon data...");
1475 LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1);
1476 LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1);
1477 LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1);
1478 LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0);
1479 LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0);
1480 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0);
1481 LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0);
1483 weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
1484 weapons.throwingknifemodel.Scale(.001,.001,.001);
1485 //weapons.throwingknifemodel.Rotate(0,0,-90);
1486 weapons.throwingknifemodel.Rotate(90,0,0);
1487 weapons.throwingknifemodel.Rotate(0,90,0);
1488 weapons.throwingknifemodel.flat=0;
1489 weapons.throwingknifemodel.CalculateNormals(1);
1490 //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1);
1492 weapons.swordmodel.load((char *)":Data:Models:sword.solid",1);
1493 weapons.swordmodel.Scale(.001,.001,.001);
1494 //weapons.swordmodel.Rotate(0,0,-90);
1495 weapons.swordmodel.Rotate(90,0,0);
1496 weapons.swordmodel.Rotate(0,90,0);
1497 weapons.swordmodel.Rotate(0,0,90);
1498 weapons.swordmodel.flat=1;
1499 weapons.swordmodel.CalculateNormals(1);
1500 //weapons.swordmodel.ScaleNormals(-1,-1,-1);
1502 weapons.staffmodel.load((char *)":Data:Models:staff.solid",1);
1503 weapons.staffmodel.Scale(.005,.005,.005);
1504 //weapons.staffmodel.Rotate(0,0,-90);
1505 weapons.staffmodel.Rotate(90,0,0);
1506 weapons.staffmodel.Rotate(0,90,0);
1507 weapons.staffmodel.Rotate(0,0,90);
1508 weapons.staffmodel.flat=1;
1509 weapons.staffmodel.CalculateNormals(1);
1510 //weapons.staffmodel.ScaleNormals(-1,-1,-1);
1512 //temptexdetail=texdetail;
1513 //if(texdetail>4)texdetail=4;
1514 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
1516 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
1518 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
1520 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
1523 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
1525 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
1527 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
1529 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
1531 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
1533 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
1535 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
1537 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
1538 //texdetail=temptexdetail;
1539 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
1543 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
1545 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
1548 //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
1551 LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1552 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1553 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1554 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1555 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1556 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1557 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1558 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1559 LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
1560 LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
1561 LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
1565 ReSizeGLScene(90,.01);
1572 if(detail)kTextureSize=1024;
1573 if(detail==1)kTextureSize=512;
1574 if(detail==0)kTextureSize=256;
1577 //drawmode=motionblurmode;
1579 //Set up distant light
1583 light.ambient[0]=.2;
1584 light.ambient[1]=.2;
1585 light.ambient[2]=.24;
1588 light.location.z=-.2;
1589 Normalise(&light.location);
1599 texscale=.2/megascale/viewdistdetail;
1600 terrain.scale=3*megascale*terraindetail*viewdistdetail;
1602 viewer.x=terrain.size/2*terrain.scale;
1603 viewer.z=terrain.size/2*terrain.scale;
1605 hawk.load((char *)":Data:Models:hawk.solid",1);
1606 hawk.Scale(.03,.03,.03);
1607 hawk.Rotate(90,1,1);
1608 hawk.CalculateNormals(0);
1609 hawk.ScaleNormals(-1,-1,-1);
1610 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
1611 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
1612 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
1615 eye.load((char *)":Data:Models:eye.solid",1);
1616 eye.Scale(.03,.03,.03);
1617 eye.CalculateNormals(0);
1619 cornea.load((char *)":Data:Models:cornea.solid",1);
1620 cornea.Scale(.03,.03,.03);
1621 cornea.CalculateNormals(0);
1623 iris.load((char *)":Data:Models:iris.solid",1);
1624 iris.Scale(.03,.03,.03);
1625 iris.CalculateNormals(0);
1627 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
1628 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
1636 //if(targetlevel!=7)
1637 Loadlevel(targetlevel);
1640 rabbitcoords=player[0].coords;
1641 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
1643 animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
1645 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
1646 animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
1648 animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
1649 animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
1651 animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
1652 animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
1653 animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
1654 animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
1655 animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
1657 animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
1658 animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
1659 animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
1660 animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
1661 animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
1662 animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1663 animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1664 animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
1666 animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
1667 animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
1668 animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
1669 animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
1670 animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
1671 animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
1672 animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
1673 animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
1674 animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
1675 animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
1676 animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
1678 animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
1679 animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
1680 animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
1681 animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
1682 animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
1684 animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
1685 animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
1686 animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
1687 animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
1688 animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
1689 animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
1690 animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
1691 animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
1693 animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
1694 animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
1695 animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
1696 animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
1697 animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
1698 animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
1699 animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
1700 animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
1702 animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
1703 animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
1704 animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
1705 animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
1706 animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
1707 animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
1708 animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
1709 animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
1710 animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
1711 animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
1712 animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
1713 animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
1714 animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
1715 animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
1716 animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
1717 animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
1718 animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
1719 animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
1720 animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
1721 animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
1722 animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
1723 animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
1724 animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
1725 animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
1726 animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
1727 animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
1728 animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
1729 animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
1730 animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
1731 animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
1732 animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
1733 animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
1734 animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
1735 animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
1736 animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
1737 animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
1738 animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
1739 animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
1740 animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
1741 animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
1742 animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
1743 animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
1744 animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
1745 animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
1746 animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
1747 animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
1748 animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
1749 animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
1750 animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
1751 animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
1752 animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
1754 animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
1755 animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
1756 animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
1758 animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
1759 animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
1760 animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
1761 animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
1762 animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
1763 //Fix knife stab, too lazy to do it manually
1767 for(i=0;i<player[0].skeleton.num_joints;i++){
1768 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
1769 animation[knifesneakattackanim].position[i][j]+=moveamount;
1776 for(i=0;i<player[0].skeleton.num_joints;i++){
1777 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
1778 animation[knifesneakattackedanim].position[i][j]+=moveamount;
1785 for(i=0;i<player[0].skeleton.num_joints;i++){
1786 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
1787 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
1788 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
1789 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
1791 animation[dead1anim].speed[0]=0.001;
1792 animation[dead2anim].speed[0]=0.001;
1793 animation[dead3anim].speed[0]=0.001;
1794 animation[dead4anim].speed[0]=0.001;
1796 animation[dead1anim].speed[1]=0.001;
1797 animation[dead2anim].speed[1]=0.001;
1798 animation[dead3anim].speed[1]=0.001;
1799 animation[dead4anim].speed[1]=0.001;
1801 for(i=0;i<player[0].skeleton.num_joints;i++){
1802 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1803 animation[swordsneakattackanim].position[i][j]+=moveamount;
1808 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1809 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1815 for(i=0;i<player[0].skeleton.num_joints;i++){
1816 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1817 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1821 for(i=0;i<player[0].skeleton.num_joints;i++){
1822 for(j=0;j<animation[sleepanim].numframes;j++){
1823 animation[sleepanim].position[i][j]=DoRotation(animation[sleepanim].position[i][j],0,180,0);
1829 temptexdetail=texdetail;
1831 texdetail=temptexdetail;
1838 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1840 glGenTextures( 1, &screentexture );
1841 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1844 glEnable(GL_TEXTURE_2D);
1845 glBindTexture( GL_TEXTURE_2D, screentexture);
1846 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1847 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1849 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1855 /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1856 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1857 OPENAL_SetPaused(channels[consolesuccesssound], false);
1860 float gLoc[3]={0,0,0};
1861 float vel[3]={0,0,0};
1862 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1863 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1864 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1865 OPENAL_SetVolume(channels[fireendsound], 256);
1866 OPENAL_SetPaused(channels[fireendsound], false);
1867 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1880 terraintexture2 = 0;
1881 terraintexture3 = 0;
1885 loadscreentexture = 0;
1886 Maparrowtexture = 0;
1888 Mapcircletexture = 0;
1891 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
1895 memset(startx, 0, sizeof(startx));
1896 memset(starty, 0, sizeof(starty));
1897 memset(endx, 0, sizeof(endx));
1898 memset(endy, 0, sizeof(endy));
1900 memset(selectedlong, 0, sizeof(selectedlong));
1901 memset(offsetx, 0, sizeof(offsetx));
1902 memset(offsety, 0, sizeof(offsety));
1903 memset(movex, 0, sizeof(movex));
1904 memset(movey, 0, sizeof(movey));
1905 memset(endy, 0, sizeof(endy));
1919 memset(menustring, 0, sizeof(menustring));
1920 memset(registrationname, 0, sizeof(registrationname));
1921 registrationnumber = 0;
1925 newscreenheight = 0;
1928 deltah = 0,deltav = 0;
1929 mousecoordh = 0,mousecoordv = 0;
1930 oldmousecoordh = 0,oldmousecoordv = 0;
1931 rotation = 0,rotation2 = 0;
1936 cameratogglekeydown = 0;
1937 chattogglekeydown = 0;
1940 drawmodetogglekeydown = 0;
1941 explodetogglekeydown = 0;
1942 detailtogglekeydown = 0;
1952 // XYZ realhawkcoords;
1964 campaignnumlevels = 0;
1966 memset(campaignmapname, 0, sizeof(campaignmapname));
1967 memset(campaigndescription, 0, sizeof(campaigndescription));
1968 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
1969 memset(campaignnumnext, 0, sizeof(campaignnumnext));
1970 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
1971 int campaignchoicesmade;
1972 memset(campaignchoices, 0, sizeof(campaignchoices));
1973 memset(campaignlocationx, 0, sizeof(campaignlocationx));
1974 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1975 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1977 campaignchoicenum = 0;
1979 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
1983 numlevelspassed = 0;
1985 memset(levelorder, 0, sizeof(levelorder));
1986 memset(levelvisible, 0, sizeof(levelvisible));
1987 memset(levelhighlight, 0, sizeof(levelhighlight));
1991 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
1995 // XYZ rabbitcoords;
2006 envtogglekeydown = 0;
2007 slomotogglekeydown = 0;
2008 texturesizetogglekeydown = 0;
2009 freezetogglekeydown = 0;
2016 editorrotation2 = 0;
2023 // XYZ pathpoint[30];
2025 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
2026 memset(pathpointconnect, 0, sizeof(pathpointconnect));
2027 pathpointselected = 0;
2031 numchallengelevels = 0;
2034 archiveselected = 0;
2036 memset(consoletext, 0, sizeof(consoletext));
2037 memset(consolechars, 0, sizeof(consolechars));
2039 memset(displaytext, 0, sizeof(displaytext));
2040 memset(displaychars, 0, sizeof(displaychars));
2041 memset(displaytime, 0, sizeof(displaytime));
2042 displayblinkdelay = 0;
2044 displayselected = 0;
2046 consoletogglekeydown = 0;
2047 consoleblinkdelay = 0;
2049 consoleselected = 0;
2050 memset(togglekey, 0, sizeof(togglekey));
2051 memset(togglekeydelay, 0, sizeof(togglekeydelay));
2055 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
2062 // XYZ boundary[360];
2069 memset(musicvolume, 0, sizeof(musicvolume));
2070 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));