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 netdatanew;
63 extern bool stillloading;
64 extern TGAImageRec texture;
68 extern int oldmainmenu;
69 extern bool visibleloading;
70 extern int loadscreencolor;
71 extern float flashamount,flashr,flashg,flashb;
72 extern int flashdelay;
73 extern int whichjointstartarray[26];
74 extern int whichjointendarray[26];
75 extern int difficulty;
76 extern float tintr,tintg,tintb;
77 extern float slomospeed;
78 extern char mapname[256];
79 extern bool gamestarted;
81 extern int numaccounts;
82 extern int accountactive;
83 extern int accountdifficulty[10];
84 extern int accountprogress[10];
85 extern float accountpoints[10];
86 extern float accounthighscore[10][50];
87 extern float accountfasttime[10][50];
88 extern bool accountunlocked[10][60];
89 extern char accountname[10][256];
91 extern int numdialogues;
92 extern int numdialogueboxes[20];
93 extern int dialoguetype[20];
94 extern int dialogueboxlocation[20][20];
95 extern float dialogueboxcolor[20][20][3];
96 extern int dialogueboxsound[20][20];
97 extern char dialoguetext[20][20][128];
98 extern char dialoguename[20][20][64];
99 extern XYZ dialoguecamera[20][20];
100 extern float dialoguecamerarotation[20][20];
101 extern float dialoguecamerarotation2[20][20];
102 extern int indialogue;
103 extern int whichdialogue;
104 extern float dialoguetime;
106 extern float accountcampaignhighscore[10];
107 extern float accountcampaignfasttime[10];
108 extern float accountcampaignscore[10];
109 extern float accountcampaigntime[10];
111 extern int accountcampaignchoicesmade[10];
112 extern int accountcampaignchoices[10][5000];
114 extern OPENAL_STREAM * strm[20];
116 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
117 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
119 void LOG(const std::string &fmt, ...)
121 // !!! FIXME: write me.
125 Game::TextureList Game::textures;
134 accountcampaignchoicesmade[accountactive]=0;
135 accountcampaignscore[accountactive]=0;
136 accountcampaigntime[accountactive]=0;
141 sprintf (mapname, ":Data:Users");
144 tfile=fopen( ConvertFileName(mapname), "wb" );
147 fpackf(tfile, "Bi", numaccounts);
148 fpackf(tfile, "Bi", accountactive);
151 for(i=0;i<numaccounts;i++)
153 fpackf(tfile, "Bf", accountcampaigntime[i]);
154 fpackf(tfile, "Bf", accountcampaignscore[i]);
155 fpackf(tfile, "Bf", accountcampaignfasttime[i]);
156 fpackf(tfile, "Bf", accountcampaignhighscore[i]);
157 fpackf(tfile, "Bi", accountdifficulty[i]);
158 fpackf(tfile, "Bi", accountprogress[i]);
159 fpackf(tfile, "Bi", accountcampaignchoicesmade[i]);
160 for(j=0;j<accountcampaignchoicesmade[i];j++)
162 fpackf(tfile, "Bi", accountcampaignchoices[i][j]);
164 fpackf(tfile, "Bf", accountpoints[i]);
167 fpackf(tfile, "Bf", accounthighscore[i][j]);
168 fpackf(tfile, "Bf", accountfasttime[i][j]);
172 fpackf(tfile, "Bb", accountunlocked[i][j]);
174 fpackf(tfile, "Bi", strlen(accountname[i]));
175 if(strlen(accountname[i])>0)
177 for(j=0;j<(int)strlen(accountname[i]);j++)
179 fpackf(tfile, "Bb", accountname[i][j]);
188 TexIter it = textures.begin();
189 for (; it != textures.end(); ++it)
191 if (glIsTexture(it->second))
192 glDeleteTextures(1, &it->second);
196 LOG("Shutting down sound system...");
198 OPENAL_StopSound(OPENAL_ALL);
200 // this is causing problems on Linux, but we'll force an _exit() a little
201 // later in the shutdown process. --ryan.
203 #define streamcount 20
204 #define samplecount 100
206 for (i=0; i < samplecount; ++i)
208 OPENAL_Sample_Free(samp[i]);
211 for (i=0; i < streamcount; ++i)
213 OPENAL_Stream_Close(strm[i]);
226 //void Game::LoadSounds();
227 void Game::LoadSounds()
231 LOG(std::string("Loading sounds..."));
233 OPENAL_3D_SetDopplerFactor(0);
235 OPENAL_SetSFXMasterVolume((int)(volume*255));
237 samp[footstepsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
238 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
240 samp[footstepsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
241 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
243 samp[footstepsound3] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
244 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
246 samp[footstepsound4] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
247 OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
249 samp[landsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
250 OPENAL_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f);
252 samp[jumpsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:jump.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
253 OPENAL_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f);
255 samp[hawksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:hawk.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
256 OPENAL_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f);
258 samp[whooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:whoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
259 OPENAL_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f);
260 OPENAL_Sample_SetMode(samp[whooshsound], OPENAL_LOOP_NORMAL);
262 samp[landsound1] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
263 OPENAL_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f);
267 samp[landsound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:land2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
268 OPENAL_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f);
270 samp[breaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:broken.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
271 OPENAL_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f);
273 samp[lowwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Lowwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
274 OPENAL_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f);
276 samp[midwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:midwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
277 OPENAL_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f);
279 samp[highwhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:highwhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
280 OPENAL_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f);
282 samp[movewhooshsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:movewhoosh.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
283 OPENAL_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f);
285 samp[heavyimpactsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:heavyimpact.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
286 OPENAL_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f);
288 samp[whooshhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Whooshhit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
289 OPENAL_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f);
291 samp[thudsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:thud.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
292 OPENAL_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f);
294 samp[alarmsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:alarm.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
295 OPENAL_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f);
297 samp[breaksound2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:break.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
298 OPENAL_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f);
300 samp[knifedrawsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifedraw.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
301 OPENAL_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f);
303 samp[knifesheathesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifesheathe.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
304 OPENAL_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f);
306 samp[fleshstabsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstab.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
307 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f);
309 samp[fleshstabremovesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Fleshstabremove.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
310 OPENAL_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f);
312 samp[knifeswishsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeswish.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
313 OPENAL_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f);
315 samp[knifeslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:knifeslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
316 OPENAL_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f);
318 samp[swordslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
319 OPENAL_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f);
321 samp[skidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:skid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
322 OPENAL_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f);
324 samp[snowskidsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snowskid.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
325 OPENAL_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f);
327 samp[bushrustle] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bushrustle.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
328 OPENAL_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f);
330 samp[clank1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank1.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
331 OPENAL_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f);
333 samp[clank2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
334 OPENAL_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f);
336 samp[clank3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
337 OPENAL_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f);
339 samp[clank4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clank4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
340 OPENAL_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f);
342 samp[consolesuccesssound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolesuccess.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
343 OPENAL_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f);
345 samp[consolefailsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:consolefail.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
346 OPENAL_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f);
348 samp[metalhitsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:MetalHit.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
349 OPENAL_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f);
351 samp[clawslicesound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:clawslice.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
352 OPENAL_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f);
354 samp[splattersound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:splatter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
355 OPENAL_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f);
357 samp[growlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
358 OPENAL_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f);
360 samp[growl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:Growl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
361 OPENAL_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f);
363 samp[barksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
364 OPENAL_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f);
366 samp[bark2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
367 OPENAL_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f);
369 samp[bark3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:bark3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
370 OPENAL_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f);
372 samp[snarlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
373 OPENAL_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f);
376 samp[snarl2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:snarl2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
377 OPENAL_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f);
379 samp[barkgrowlsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:barkgrowl.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
380 OPENAL_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f);
382 samp[rabbitattacksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
383 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f);
385 samp[rabbitattack2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
386 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f);
388 samp[rabbitattack3sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack3.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
389 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f);
391 samp[rabbitattack4sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitattack4.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
392 OPENAL_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f);
394 samp[rabbitpainsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
395 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f);
397 samp[rabbitpain1sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
398 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f);
400 /*samp[rabbitpain2sound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitpain2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
401 OPENAL_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f);
403 samp[rabbitchitter] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
404 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f);
406 samp[rabbitchitter2] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:rabbitchitter2.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
407 OPENAL_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f);
409 samp[swordstaffsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:swordstaff.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
410 OPENAL_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f);
412 samp[staffbodysound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbody.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
413 OPENAL_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f);
415 samp[staffheadsound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffhead.ogg"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
416 OPENAL_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f);
418 samp[staffbreaksound] = OPENAL_Sample_LoadEx(OPENAL_FREE, ConvertFileName(":Data:Sounds:staffbreak.wav"), OPENAL_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
419 OPENAL_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f);
422 void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
428 LOG(std::string("Loading texture...") + fileName);
430 // Fix filename so that is os appropreate
431 char * fixedFN = ConvertFileName(fileName);
433 unsigned char fileNamep[256];
434 CopyCStringToPascal(fixedFN, fileNamep);
436 upload_image( fileNamep ,hasalpha);
438 // std::string fname(fileName);
439 // std::transform(fname.begin(), fname.end(), tolower);
440 // TexIter it = textures.find(fname);
444 //if(textures.end() == it)
447 if ( texture.bpp == 24 )
452 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
454 if(!*textureid)glGenTextures( 1, textureid );
455 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
457 glBindTexture( GL_TEXTURE_2D, *textureid);
458 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
459 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
460 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
461 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
463 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0,
464 // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data);
466 //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data );
468 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
470 // textures.insert(std::make_pair(fname, *textureid));
474 // *textureid = it->second;
478 void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
486 LOG(std::string("Loading texture (S)...") + fileName);
489 unsigned char fileNamep[256];
490 CopyCStringToPascal(ConvertFileName(fileName), fileNamep);
492 upload_image( fileNamep ,0);
493 //LoadTGA( fileName );
495 // std::string fname(fileName);
496 // std::transform(fname.begin(), fname.end(), tolower);
497 // TexIter it = textures.find(fname);
501 //if(textures.end() == it)
503 bytesPerPixel=texture.bpp/8;
506 if ( texture.bpp == 24 )
511 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
513 if(!*textureid)glGenTextures( 1, textureid );
514 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
516 glBindTexture( GL_TEXTURE_2D, *textureid);
517 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
518 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
519 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
520 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
523 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
524 if((i+1)%4||type==GL_RGB){
525 array[tempnum]=texture.data[i];
530 *skinsize=texture.sizeX;
532 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_RGB, GL_UNSIGNED_BYTE, array );
534 // textures.insert(std::make_pair(fname, *textureid));
538 // *textureid = it->second;
542 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
549 LOG(std::string("Loading (S)...") + fileName);
552 float temptexdetail=texdetail;
554 //upload_image( fileName );
555 //LoadTGA( fileName );
557 // Converting file to something os specific
558 char * fixedFN = ConvertFileName(fileName);
561 unsigned char fileNamep[256];
562 CopyCStringToPascal(fixedFN, fileNamep);
564 upload_image( fileNamep ,0);
565 texdetail=temptexdetail;
569 bytesPerPixel=texture.bpp/8;
572 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
573 if((i+1)%4||bytesPerPixel==3){
574 array[tempnum]=texture.data[i];
581 bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
588 //upload_image( fileName );
589 //LoadTGA( fileName );
591 unsigned char fileNamep[256];
592 CopyCStringToPascal(fileName,fileNamep);
595 opened=upload_image( fileNamep ,1);
608 bytesPerPixel=texture.bpp/8;
612 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
613 if(bytesPerPixel==3)alphanum=255;
614 else if((i+1)%4==0)alphanum=texture.data[i];
616 if((i+1)%4||bytesPerPixel==3){
617 if((i%4)==0)texture.data[i]*=tintr;
618 if((i%4)==1)texture.data[i]*=tintg;
619 if((i%4)==2)texture.data[i]*=tintb;
620 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
630 //***************> ResizeGLScene() <******/
631 GLvoid Game::ReSizeGLScene(float fov, float pnear)
638 glViewport(0,0,screenwidth,screenheight);
640 glMatrixMode(GL_PROJECTION);
643 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
645 glMatrixMode(GL_MODELVIEW);
649 void Game::LoadingScreen()
651 static float loadprogress,minprogress,maxprogress;
652 static AbsoluteTime time = {0,0};
653 static AbsoluteTime frametime = {0,0};
654 AbsoluteTime currTime = UpTime ();
655 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
657 if (0 > deltaTime) // if negative microseconds
658 deltaTime /= -1000000.0;
659 else // else milliseconds
662 multiplier=deltaTime;
663 if(multiplier<.001)multiplier=.001;
664 if(multiplier>10)multiplier=10;
666 frametime = currTime; // reset for next time interval
671 glClearColor(0,0,0,1);
672 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
675 loadtime+=multiplier*4;
677 loadprogress=loadtime;
678 if(loadprogress>100)loadprogress=100;
680 //loadprogress=abs(Random()%100);
684 glEnable(GL_TEXTURE_2D);
685 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
686 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
687 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
688 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
689 glDisable(GL_CULL_FACE);
690 glDisable(GL_LIGHTING);
692 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
693 glPushMatrix(); // Store The Projection Matrix
694 glLoadIdentity(); // Reset The Projection Matrix
695 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
696 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
697 glPushMatrix(); // Store The Modelview Matrix
698 glLoadIdentity(); // Reset The Modelview Matrix
699 glTranslatef(screenwidth/2,screenheight/2,0);
700 glScalef((float)screenwidth/2,(float)screenheight/2,1);
701 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
703 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
704 //glColor4f(1,1,1,1);
705 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
706 if(loadscreencolor==1)glColor4f(1,0,0,1);
707 if(loadscreencolor==2)glColor4f(0,1,0,1);
708 if(loadscreencolor==3)glColor4f(0,0,1,1);
709 if(loadscreencolor==4)glColor4f(1,1,0,1);
710 if(loadscreencolor==5)glColor4f(1,0,1,1);
713 //glScalef(.25,.25,.25);
715 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
716 glVertex3f(-1, -1, 0.0f);
717 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
718 glVertex3f(1, -1, 0.0f);
719 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
720 glVertex3f(1, 1, 0.0f);
721 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
722 glVertex3f(-1, 1, 0.0f);
727 //glScalef(.25,.25,.25);
729 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
730 glVertex3f(-1, -1, 0.0f);
731 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
732 glVertex3f(1, -1, 0.0f);
733 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
734 glVertex3f(1, 1, 0.0f);
735 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
736 glVertex3f(-1, 1, 0.0f);
739 glDisable(GL_TEXTURE_2D);
740 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
741 glPopMatrix(); // Restore The Old Projection Matrix
742 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
743 glPopMatrix(); // Restore The Old Projection Matrix
747 glEnable(GL_TEXTURE_2D);
748 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
749 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
750 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
751 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
752 glDisable(GL_CULL_FACE);
753 glDisable(GL_LIGHTING);
755 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
756 glPushMatrix(); // Store The Projection Matrix
757 glLoadIdentity(); // Reset The Projection Matrix
758 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
759 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
760 glPushMatrix(); // Store The Modelview Matrix
761 glLoadIdentity(); // Reset The Modelview Matrix
762 glTranslatef(screenwidth/2,screenheight/2,0);
763 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
764 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
766 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
767 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
768 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
769 if(loadscreencolor==1)glColor4f(1,0,0,1);
770 if(loadscreencolor==2)glColor4f(0,1,0,1);
771 if(loadscreencolor==3)glColor4f(0,0,1,1);
772 if(loadscreencolor==4)glColor4f(1,1,0,1);
773 if(loadscreencolor==5)glColor4f(1,0,1,1);
776 //glScalef(.25,.25,.25);
778 glTexCoord2f(0+.5,0+.5);
779 glVertex3f(-1, -1, 0.0f);
780 glTexCoord2f(1+.5,0+.5);
781 glVertex3f(1, -1, 0.0f);
782 glTexCoord2f(1+.5,1+.5);
783 glVertex3f(1, 1, 0.0f);
784 glTexCoord2f(0+.5,1+.5);
785 glVertex3f(-1, 1, 0.0f);
788 glDisable(GL_TEXTURE_2D);
789 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
790 glPopMatrix(); // Restore The Old Projection Matrix
791 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
792 glPopMatrix(); // Restore The Old Projection Matrix
796 glEnable(GL_TEXTURE_2D);
797 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
798 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
799 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
800 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
801 glDisable(GL_CULL_FACE);
802 glDisable(GL_LIGHTING);
804 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
805 glPushMatrix(); // Store The Projection Matrix
806 glLoadIdentity(); // Reset The Projection Matrix
807 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
808 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
809 glPushMatrix(); // Store The Modelview Matrix
810 glLoadIdentity(); // Reset The Modelview Matrix
811 glTranslatef(screenwidth/2,screenheight/2,0);
812 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
813 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
815 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
817 //glScalef(.25,.25,.25);
819 glTexCoord2f(0+.2,0+.8);
820 glVertex3f(-1, -1, 0.0f);
821 glTexCoord2f(1+.2,0+.8);
822 glVertex3f(1, -1, 0.0f);
823 glTexCoord2f(1+.2,1+.8);
824 glVertex3f(1, 1, 0.0f);
825 glTexCoord2f(0+.2,1+.8);
826 glVertex3f(-1, 1, 0.0f);
829 glDisable(GL_TEXTURE_2D);
830 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
831 glPopMatrix(); // Restore The Old Projection Matrix
832 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
833 glPopMatrix(); // Restore The Old Projection Matrix
839 glEnable(GL_TEXTURE_2D);
840 static char string[256]="";
841 sprintf (string, "LOADING... %d%",(int)loadprogress);
843 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
844 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
845 text.glPrint(280,125,string,1,1,640,480);
849 if(flashamount>1)flashamount=1;
850 if(flashdelay<=0)flashamount-=multiplier;
852 if(flashamount<0)flashamount=0;
853 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
854 glDisable(GL_CULL_FACE);
855 glDisable(GL_LIGHTING);
856 glDisable(GL_TEXTURE_2D);
858 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
859 glPushMatrix(); // Store The Projection Matrix
860 glLoadIdentity(); // Reset The Projection Matrix
861 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
862 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
863 glPushMatrix(); // Store The Modelview Matrix
864 glLoadIdentity(); // Reset The Modelview Matrix
865 glScalef(screenwidth,screenheight,1);
866 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
868 glColor4f(flashr,flashg,flashb,flashamount);
870 glVertex3f(0, 0, 0.0f);
871 glVertex3f(256, 0, 0.0f);
872 glVertex3f(256, 256, 0.0f);
873 glVertex3f(0, 256, 0.0f);
875 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
876 glPopMatrix(); // Restore The Old Projection Matrix
877 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
878 glPopMatrix(); // Restore The Old Projection Matrix
879 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
880 glEnable(GL_CULL_FACE);
890 void Game::FadeLoadingScreen(float howmuch)
892 static float loadprogress,minprogress,maxprogress;
897 glClearColor(0,0,0,1);
898 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
900 loadprogress=howmuch;
902 //loadprogress=abs(Random()%100);
906 //glEnable(GL_TEXTURE_2D);
907 glDisable(GL_TEXTURE_2D);
908 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
909 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
910 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
911 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
912 glDisable(GL_CULL_FACE);
913 glDisable(GL_LIGHTING);
915 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
916 glPushMatrix(); // Store The Projection Matrix
917 glLoadIdentity(); // Reset The Projection Matrix
918 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
919 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
920 glPushMatrix(); // Store The Modelview Matrix
921 glLoadIdentity(); // Reset The Modelview Matrix
922 glTranslatef(screenwidth/2,screenheight/2,0);
923 glScalef((float)screenwidth/2,(float)screenheight/2,1);
924 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
926 glColor4f(loadprogress/100,0,0,1);
927 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
928 if(loadscreencolor==1)glColor4f(1,0,0,1);
929 if(loadscreencolor==2)glColor4f(0,1,0,1);
930 if(loadscreencolor==3)glColor4f(0,0,1,1);
931 if(loadscreencolor==4)glColor4f(1,1,0,1);
932 if(loadscreencolor==5)glColor4f(1,0,1,1);
935 //glScalef(.25,.25,.25);
938 glVertex3f(-1, -1, 0.0f);
940 glVertex3f(1, -1, 0.0f);
942 glVertex3f(1, 1, 0.0f);
944 glVertex3f(-1, 1, 0.0f);
947 glDisable(GL_TEXTURE_2D);
948 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
949 glPopMatrix(); // Restore The Old Projection Matrix
950 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
951 glPopMatrix(); // Restore The Old Projection Matrix
956 glEnable(GL_TEXTURE_2D);
957 static char string[256]="";
958 sprintf (string, "LOADING... %d%",(int)loadprogress);
960 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
961 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
962 text.glPrint(280,125,string,1,1,640,480);
969 void Game::InitGame()
972 ProcessSerialNumber PSN;
973 ProcessInfoRec pinfo;
976 /* set up process serial number */
977 PSN.highLongOfPSN = 0;
978 PSN.lowLongOfPSN = kCurrentProcess;
979 /* set up info block */
980 pinfo.processInfoLength = sizeof(pinfo);
981 pinfo.processName = NULL;
982 pinfo.processAppSpec = &pspec;
983 /* grab the vrefnum and directory */
984 err = GetProcessInformation(&PSN, &pinfo);
986 vRefNum = pspec.vRefNum;
997 numchallengelevels=14;
1004 sprintf (mapname, ":Data:Users");
1005 tfile=fopen( ConvertFileName(mapname), "rb" );
1008 funpackf(tfile, "Bi", &numaccounts);
1009 funpackf(tfile, "Bi", &accountactive);
1012 for(i=0;i<numaccounts;i++)
1014 funpackf(tfile, "Bf", &accountcampaigntime[i]);
1015 funpackf(tfile, "Bf", &accountcampaignscore[i]);
1016 funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
1017 funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
1018 funpackf(tfile, "Bi", &accountdifficulty[i]);
1019 funpackf(tfile, "Bi", &accountprogress[i]);
1020 funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
1021 for(j=0;j<accountcampaignchoicesmade[i];j++)
1023 funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
1024 if (accountcampaignchoices[i][j] >= 10)
1026 accountcampaignchoices[i][j] = 0;
1029 funpackf(tfile, "Bf", &accountpoints[i]);
1032 funpackf(tfile, "Bf", &accounthighscore[i][j]);
1033 funpackf(tfile, "Bf", &accountfasttime[i][j]);
1037 funpackf(tfile, "Bb", &accountunlocked[i][j]);
1040 funpackf(tfile, "Bi", &temp);
1045 funpackf(tfile, "Bb", &accountname[i][j]);
1058 whichjointstartarray[0]=righthip;
1059 whichjointendarray[0]=rightfoot;
1061 whichjointstartarray[1]=righthip;
1062 whichjointendarray[1]=rightankle;
1064 whichjointstartarray[2]=righthip;
1065 whichjointendarray[2]=rightknee;
1067 whichjointstartarray[3]=rightknee;
1068 whichjointendarray[3]=rightankle;
1070 whichjointstartarray[4]=rightankle;
1071 whichjointendarray[4]=rightfoot;
1073 whichjointstartarray[5]=lefthip;
1074 whichjointendarray[5]=leftfoot;
1076 whichjointstartarray[6]=lefthip;
1077 whichjointendarray[6]=leftankle;
1079 whichjointstartarray[7]=lefthip;
1080 whichjointendarray[7]=leftknee;
1082 whichjointstartarray[8]=leftknee;
1083 whichjointendarray[8]=leftankle;
1085 whichjointstartarray[9]=leftankle;
1086 whichjointendarray[9]=leftfoot;
1088 whichjointstartarray[10]=abdomen;
1089 whichjointendarray[10]=rightshoulder;
1091 whichjointstartarray[11]=abdomen;
1092 whichjointendarray[11]=rightelbow;
1094 whichjointstartarray[12]=abdomen;
1095 whichjointendarray[12]=rightwrist;
1097 whichjointstartarray[13]=abdomen;
1098 whichjointendarray[13]=righthand;
1100 whichjointstartarray[14]=rightshoulder;
1101 whichjointendarray[14]=rightelbow;
1103 whichjointstartarray[15]=rightelbow;
1104 whichjointendarray[15]=rightwrist;
1106 whichjointstartarray[16]=rightwrist;
1107 whichjointendarray[16]=righthand;
1109 whichjointstartarray[17]=abdomen;
1110 whichjointendarray[17]=leftshoulder;
1112 whichjointstartarray[18]=abdomen;
1113 whichjointendarray[18]=leftelbow;
1115 whichjointstartarray[19]=abdomen;
1116 whichjointendarray[19]=leftwrist;
1118 whichjointstartarray[20]=abdomen;
1119 whichjointendarray[20]=lefthand;
1121 whichjointstartarray[21]=leftshoulder;
1122 whichjointendarray[21]=leftelbow;
1124 whichjointstartarray[22]=leftelbow;
1125 whichjointendarray[22]=leftwrist;
1127 whichjointstartarray[23]=leftwrist;
1128 whichjointendarray[23]=lefthand;
1130 whichjointstartarray[24]=abdomen;
1131 whichjointendarray[24]=neck;
1133 whichjointstartarray[25]=neck;
1134 whichjointendarray[25]=head;
1136 FadeLoadingScreen(0);
1140 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1142 int temptexdetail=texdetail;
1144 text.LoadFontTexture(":Data:Textures:Font.png");
1146 texdetail=temptexdetail;
1148 FadeLoadingScreen(10);
1164 for (int it = 0; it < 100; ++it)
1169 for (int it = 0; it < 20; ++it)
1174 LOG("Initializing sound system...");
1179 extern bool cmdline(const char *cmd);
1180 unsigned char rc = 0;
1181 output = OPENAL_OUTPUT_ALSA; // Try alsa first...
1182 if (cmdline("forceoss")) // ...but let user override that.
1183 output = OPENAL_OUTPUT_OSS;
1184 else if (cmdline("nosound"))
1185 output = OPENAL_OUTPUT_NOSOUND;
1187 OPENAL_SetOutput(output);
1188 if ((rc = OPENAL_Init(44100, 32, 0)) == false)
1190 // if we tried ALSA and failed, fall back to OSS.
1191 if ( (output == OPENAL_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
1194 output = OPENAL_OUTPUT_OSS;
1195 OPENAL_SetOutput(output);
1196 rc = OPENAL_Init(44100, 32, 0);
1203 output = OPENAL_OUTPUT_NOSOUND; // we tried! just do silence.
1204 OPENAL_SetOutput(output);
1205 rc = OPENAL_Init(44100, 32, 0);
1208 OPENAL_Init(44100, 32, 0);
1211 OPENAL_SetSFXMasterVolume((int)(volume*255));
1213 strm[stream_music3] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
1214 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
1215 OPENAL_Stream_SetMode(strm[stream_music3], OPENAL_LOOP_NORMAL);
1218 // PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
1219 PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
1220 OPENAL_SetPaused(channels[stream_music3], false);
1221 OPENAL_SetVolume(channels[stream_music3], 256);
1224 FadeLoadingScreen(20);
1227 strm[stream_wind] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1228 // OPENAL_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
1229 OPENAL_Stream_SetMode(strm[stream_wind], OPENAL_LOOP_NORMAL);
1231 FadeLoadingScreen(30);
1233 strm[stream_desertambient] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1234 // OPENAL_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
1235 OPENAL_Stream_SetMode(strm[stream_desertambient], OPENAL_LOOP_NORMAL);
1238 FadeLoadingScreen(40);
1240 samp[firestartsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1241 OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1243 strm[stream_firesound] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:fire.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1244 // OPENAL_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
1245 OPENAL_Stream_SetMode(strm[stream_firesound], OPENAL_LOOP_NORMAL);
1247 FadeLoadingScreen(50);
1249 samp[fireendsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1250 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1253 strm[stream_music1grass] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
1254 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
1255 OPENAL_Stream_SetMode(strm[stream_music1grass], OPENAL_LOOP_NORMAL);
1257 strm[stream_music1snow] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
1258 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
1259 OPENAL_Stream_SetMode(strm[stream_music1snow], OPENAL_LOOP_NORMAL);
1261 FadeLoadingScreen(60);
1263 strm[stream_music1desert] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
1264 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
1265 OPENAL_Stream_SetMode(strm[stream_music1desert], OPENAL_LOOP_NORMAL);
1267 FadeLoadingScreen(80);
1268 strm[stream_music2] = OPENAL_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), OPENAL_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
1269 // OPENAL_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
1270 OPENAL_Stream_SetMode(strm[stream_music2], OPENAL_LOOP_NORMAL);
1275 FadeLoadingScreen(90);
1278 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
1280 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
1281 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
1282 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
1284 temptexdetail=texdetail;
1285 if(texdetail>2)texdetail=2;
1286 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
1287 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1288 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
1289 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1290 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
1291 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
1292 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
1293 texdetail=temptexdetail;
1298 FadeLoadingScreen(95);
1309 newscreenwidth=screenwidth;
1310 newscreenheight=screenheight;
1314 void Game::LoadStuff()
1316 static float temptexdetail;
1317 static float viewdistdetail;
1318 static int i,j,texsize;
1325 /*musicvolume[3]=512;
1326 PlaySoundEx( music4, samp[music4], NULL, true);
1327 OPENAL_SetPaused(channels[music4], false);
1328 OPENAL_SetVolume(channels[music4], 512);
1334 //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1336 for(i=0;i<maxplayers;i++)
1338 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
1340 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
1342 player[i].skeleton.drawmodel.textureptr=0;;
1345 //temptexdetail=texdetail;
1348 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
1349 //texdetail=temptexdetail;
1351 temptexdetail=texdetail;
1353 text.LoadFontTexture(":Data:Textures:Font.png");
1355 texdetail=temptexdetail;
1360 viewdistance=50*megascale*viewdistdetail;
1380 realtexdetail=texdetail;
1383 if(texdetail<1)texdetail=1;
1384 realtexdetail=texdetail*4;
1390 /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1);
1392 LoadTexture(":Data:Textures:rock.png",&terraintexture2,1);
1394 LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1398 LOG("Loading weapon data...");
1400 LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1);
1401 LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1);
1402 LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1);
1403 LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0);
1404 LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0);
1405 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0);
1406 LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0);
1408 weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
1409 weapons.throwingknifemodel.Scale(.001,.001,.001);
1410 //weapons.throwingknifemodel.Rotate(0,0,-90);
1411 weapons.throwingknifemodel.Rotate(90,0,0);
1412 weapons.throwingknifemodel.Rotate(0,90,0);
1413 weapons.throwingknifemodel.flat=0;
1414 weapons.throwingknifemodel.CalculateNormals(1);
1415 //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1);
1417 weapons.swordmodel.load((char *)":Data:Models:sword.solid",1);
1418 weapons.swordmodel.Scale(.001,.001,.001);
1419 //weapons.swordmodel.Rotate(0,0,-90);
1420 weapons.swordmodel.Rotate(90,0,0);
1421 weapons.swordmodel.Rotate(0,90,0);
1422 weapons.swordmodel.Rotate(0,0,90);
1423 weapons.swordmodel.flat=1;
1424 weapons.swordmodel.CalculateNormals(1);
1425 //weapons.swordmodel.ScaleNormals(-1,-1,-1);
1427 weapons.staffmodel.load((char *)":Data:Models:staff.solid",1);
1428 weapons.staffmodel.Scale(.005,.005,.005);
1429 //weapons.staffmodel.Rotate(0,0,-90);
1430 weapons.staffmodel.Rotate(90,0,0);
1431 weapons.staffmodel.Rotate(0,90,0);
1432 weapons.staffmodel.Rotate(0,0,90);
1433 weapons.staffmodel.flat=1;
1434 weapons.staffmodel.CalculateNormals(1);
1435 //weapons.staffmodel.ScaleNormals(-1,-1,-1);
1437 //temptexdetail=texdetail;
1438 //if(texdetail>4)texdetail=4;
1439 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
1441 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
1443 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
1445 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
1448 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
1450 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
1452 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
1454 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
1456 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
1458 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
1460 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
1462 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
1463 //texdetail=temptexdetail;
1464 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
1468 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
1470 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
1473 //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
1476 LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1477 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1478 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1479 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1480 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1481 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1482 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1483 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1484 LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
1485 LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
1486 LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
1490 ReSizeGLScene(90,.01);
1497 if(detail)kTextureSize=1024;
1498 if(detail==1)kTextureSize=512;
1499 if(detail==0)kTextureSize=256;
1502 //drawmode=motionblurmode;
1504 //Set up distant light
1508 light.ambient[0]=.2;
1509 light.ambient[1]=.2;
1510 light.ambient[2]=.24;
1513 light.location.z=-.2;
1514 Normalise(&light.location);
1524 texscale=.2/megascale/viewdistdetail;
1525 terrain.scale=3*megascale*terraindetail*viewdistdetail;
1527 viewer.x=terrain.size/2*terrain.scale;
1528 viewer.z=terrain.size/2*terrain.scale;
1530 hawk.load((char *)":Data:Models:hawk.solid",1);
1531 hawk.Scale(.03,.03,.03);
1532 hawk.Rotate(90,1,1);
1533 hawk.CalculateNormals(0);
1534 hawk.ScaleNormals(-1,-1,-1);
1535 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
1536 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
1537 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
1540 eye.load((char *)":Data:Models:eye.solid",1);
1541 eye.Scale(.03,.03,.03);
1542 eye.CalculateNormals(0);
1544 cornea.load((char *)":Data:Models:cornea.solid",1);
1545 cornea.Scale(.03,.03,.03);
1546 cornea.CalculateNormals(0);
1548 iris.load((char *)":Data:Models:iris.solid",1);
1549 iris.Scale(.03,.03,.03);
1550 iris.CalculateNormals(0);
1552 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
1553 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
1561 //if(targetlevel!=7)
1562 Loadlevel(targetlevel);
1565 rabbitcoords=player[0].coords;
1566 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
1568 animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
1570 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
1571 animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
1573 animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
1574 animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
1576 animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
1577 animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
1578 animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
1579 animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
1580 animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
1582 animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
1583 animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
1584 animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
1585 animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
1586 animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
1587 animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1588 animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1589 animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
1591 animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
1592 animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
1593 animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
1594 animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
1595 animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
1596 animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
1597 animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
1598 animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
1599 animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
1600 animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
1601 animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
1603 animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
1604 animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
1605 animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
1606 animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
1607 animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
1609 animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
1610 animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
1611 animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
1612 animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
1613 animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
1614 animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
1615 animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
1616 animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
1618 animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
1619 animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
1620 animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
1621 animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
1622 animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
1623 animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
1624 animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
1625 animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
1627 animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
1628 animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
1629 animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
1630 animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
1631 animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
1632 animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
1633 animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
1634 animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
1635 animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
1636 animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
1637 animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
1638 animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
1639 animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
1640 animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
1641 animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
1642 animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
1643 animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
1644 animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
1645 animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
1646 animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
1647 animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
1648 animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
1649 animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
1650 animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
1651 animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
1652 animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
1653 animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
1654 animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
1655 animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
1656 animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
1657 animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
1658 animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
1659 animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
1660 animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
1661 animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
1662 animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
1663 animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
1664 animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
1665 animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
1666 animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
1667 animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
1668 animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
1669 animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
1670 animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
1671 animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
1672 animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
1673 animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
1674 animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
1675 animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
1676 animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
1677 animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
1679 animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
1680 animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
1681 animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
1683 animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
1684 animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
1685 animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
1686 animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
1687 animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
1688 //Fix knife stab, too lazy to do it manually
1692 for(i=0;i<player[0].skeleton.num_joints;i++){
1693 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
1694 animation[knifesneakattackanim].position[i][j]+=moveamount;
1701 for(i=0;i<player[0].skeleton.num_joints;i++){
1702 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
1703 animation[knifesneakattackedanim].position[i][j]+=moveamount;
1710 for(i=0;i<player[0].skeleton.num_joints;i++){
1711 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
1712 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
1713 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
1714 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
1716 animation[dead1anim].speed[0]=0.001;
1717 animation[dead2anim].speed[0]=0.001;
1718 animation[dead3anim].speed[0]=0.001;
1719 animation[dead4anim].speed[0]=0.001;
1721 animation[dead1anim].speed[1]=0.001;
1722 animation[dead2anim].speed[1]=0.001;
1723 animation[dead3anim].speed[1]=0.001;
1724 animation[dead4anim].speed[1]=0.001;
1726 for(i=0;i<player[0].skeleton.num_joints;i++){
1727 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1728 animation[swordsneakattackanim].position[i][j]+=moveamount;
1733 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1734 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1740 for(i=0;i<player[0].skeleton.num_joints;i++){
1741 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1742 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1746 for(i=0;i<player[0].skeleton.num_joints;i++){
1747 for(j=0;j<animation[sleepanim].numframes;j++){
1748 animation[sleepanim].position[i][j]=DoRotation(animation[sleepanim].position[i][j],0,180,0);
1754 temptexdetail=texdetail;
1756 texdetail=temptexdetail;
1763 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1765 glGenTextures( 1, &screentexture );
1766 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1769 glEnable(GL_TEXTURE_2D);
1770 glBindTexture( GL_TEXTURE_2D, screentexture);
1771 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1772 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1774 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1780 /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1781 OPENAL_SetVolume(channels[consolesuccesssound], 256);
1782 OPENAL_SetPaused(channels[consolesuccesssound], false);
1785 float gLoc[3]={0,0,0};
1786 float vel[3]={0,0,0};
1787 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1788 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1789 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1790 OPENAL_SetVolume(channels[fireendsound], 256);
1791 OPENAL_SetPaused(channels[fireendsound], false);
1792 OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1805 terraintexture2 = 0;
1806 terraintexture3 = 0;
1810 loadscreentexture = 0;
1811 Maparrowtexture = 0;
1813 Mapcircletexture = 0;
1816 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
1820 memset(startx, 0, sizeof(startx));
1821 memset(starty, 0, sizeof(starty));
1822 memset(endx, 0, sizeof(endx));
1823 memset(endy, 0, sizeof(endy));
1825 memset(selectedlong, 0, sizeof(selectedlong));
1826 memset(offsetx, 0, sizeof(offsetx));
1827 memset(offsety, 0, sizeof(offsety));
1828 memset(movex, 0, sizeof(movex));
1829 memset(movey, 0, sizeof(movey));
1830 memset(endy, 0, sizeof(endy));
1843 memset(menustring, 0, sizeof(menustring));
1844 memset(registrationname, 0, sizeof(registrationname));
1845 registrationnumber = 0;
1849 newscreenheight = 0;
1852 deltah = 0,deltav = 0;
1853 mousecoordh = 0,mousecoordv = 0;
1854 oldmousecoordh = 0,oldmousecoordv = 0;
1855 rotation = 0,rotation2 = 0;
1860 cameratogglekeydown = 0;
1861 chattogglekeydown = 0;
1864 drawmodetogglekeydown = 0;
1865 explodetogglekeydown = 0;
1866 detailtogglekeydown = 0;
1876 // XYZ realhawkcoords;
1888 campaignnumlevels = 0;
1890 memset(campaignmapname, 0, sizeof(campaignmapname));
1891 memset(campaigndescription, 0, sizeof(campaigndescription));
1892 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
1893 memset(campaignnumnext, 0, sizeof(campaignnumnext));
1894 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
1895 int campaignchoicesmade;
1896 memset(campaignchoices, 0, sizeof(campaignchoices));
1897 memset(campaignlocationx, 0, sizeof(campaignlocationx));
1898 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1899 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1901 campaignchoicenum = 0;
1903 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
1907 numlevelspassed = 0;
1909 memset(levelorder, 0, sizeof(levelorder));
1910 memset(levelvisible, 0, sizeof(levelvisible));
1911 memset(levelhighlight, 0, sizeof(levelhighlight));
1915 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
1919 // XYZ rabbitcoords;
1930 envtogglekeydown = 0;
1931 slomotogglekeydown = 0;
1932 texturesizetogglekeydown = 0;
1933 freezetogglekeydown = 0;
1940 editorrotation2 = 0;
1947 // XYZ pathpoint[30];
1949 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
1950 memset(pathpointconnect, 0, sizeof(pathpointconnect));
1951 pathpointselected = 0;
1955 numchallengelevels = 0;
1958 archiveselected = 0;
1960 memset(consoletext, 0, sizeof(consoletext));
1961 memset(consolechars, 0, sizeof(consolechars));
1963 memset(displaytext, 0, sizeof(displaytext));
1964 memset(displaychars, 0, sizeof(displaychars));
1965 memset(displaytime, 0, sizeof(displaytime));
1966 displayblinkdelay = 0;
1968 displayselected = 0;
1970 consoletogglekeydown = 0;
1971 consoleblinkdelay = 0;
1973 consoleselected = 0;
1974 memset(togglekey, 0, sizeof(togglekey));
1975 memset(togglekeydelay, 0, sizeof(togglekeydelay));
1979 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
1986 // XYZ boundary[360];
1993 memset(musicvolume, 0, sizeof(musicvolume));
1994 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));