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 extern float screenwidth,screenheight;
24 extern float viewdistance;
26 extern XYZ lightlocation;
27 extern float lightambient[3],lightbrightness[3];
28 extern float fadestart;
29 extern float texscale;
32 extern Animation animation[animation_count];
33 extern Skeleton testskeleton;
35 extern FSOUND_SAMPLE *samp[100];
36 extern int channels[100];
37 extern Terrain terrain;
38 extern Sprites sprites;
39 extern int kTextureSize;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern float terraindetail;
44 extern Objects objects;
46 extern bool cellophane;
47 extern GLubyte bloodText[512*512*3];
48 extern GLubyte wolfbloodText[512*512*3];
49 extern bool ismotionblur;
50 extern bool trilinear;
52 extern bool musictoggle;
53 extern Weapons weapons;
54 extern Person player[maxplayers];
55 extern int numplayers;
56 extern int environment;
57 extern bool ambientsound;
58 extern float multiplier;
59 extern int newnetmessages;
60 extern int netdatanew;
62 extern bool stillloading;
63 extern TGAImageRec texture;
67 extern int oldmainmenu;
68 extern bool visibleloading;
69 extern int loadscreencolor;
70 extern float flashamount,flashr,flashg,flashb;
71 extern int flashdelay;
72 extern int whichjointstartarray[26];
73 extern int whichjointendarray[26];
74 extern int difficulty;
75 extern float tintr,tintg,tintb;
76 extern float slomospeed;
77 extern char mapname[256];
78 extern bool gamestarted;
80 extern int numaccounts;
81 extern int accountactive;
82 extern int accountdifficulty[10];
83 extern int accountprogress[10];
84 extern float accountpoints[10];
85 extern float accounthighscore[10][50];
86 extern float accountfasttime[10][50];
87 extern bool accountunlocked[10][60];
88 extern char accountname[10][256];
90 extern int numdialogues;
91 extern int numdialogueboxes[20];
92 extern int dialoguetype[20];
93 extern int dialogueboxlocation[20][20];
94 extern float dialogueboxcolor[20][20][3];
95 extern int dialogueboxsound[20][20];
96 extern char dialoguetext[20][20][128];
97 extern char dialoguename[20][20][64];
98 extern XYZ dialoguecamera[20][20];
99 extern float dialoguecamerarotation[20][20];
100 extern float dialoguecamerarotation2[20][20];
101 extern int indialogue;
102 extern int whichdialogue;
103 extern float dialoguetime;
105 extern float accountcampaignhighscore[10];
106 extern float accountcampaignfasttime[10];
107 extern float accountcampaignscore[10];
108 extern float accountcampaigntime[10];
110 extern int accountcampaignchoicesmade[10];
111 extern int accountcampaignchoices[10][5000];
113 extern FSOUND_STREAM * strm[20];
115 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
116 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
118 void LOG(const std::string &fmt, ...)
120 // !!! FIXME: write me.
124 Game::TextureList Game::textures;
133 accountcampaignchoicesmade[accountactive]=0;
134 accountcampaignscore[accountactive]=0;
135 accountcampaigntime[accountactive]=0;
140 sprintf (mapname, ":Data:Users");
143 tfile=fopen( mapname, "wb" );
146 fpackf(tfile, "Bi", numaccounts);
147 fpackf(tfile, "Bi", accountactive);
150 for(i=0;i<numaccounts;i++)
152 fpackf(tfile, "Bf", accountcampaigntime[i]);
153 fpackf(tfile, "Bf", accountcampaignscore[i]);
154 fpackf(tfile, "Bf", accountcampaignfasttime[i]);
155 fpackf(tfile, "Bf", accountcampaignhighscore[i]);
156 fpackf(tfile, "Bi", accountdifficulty[i]);
157 fpackf(tfile, "Bi", accountprogress[i]);
158 fpackf(tfile, "Bi", accountcampaignchoicesmade[i]);
159 for(j=0;j<accountcampaignchoicesmade[i];j++)
161 fpackf(tfile, "Bi", accountcampaignchoices[i][j]);
163 fpackf(tfile, "Bf", accountpoints[i]);
166 fpackf(tfile, "Bf", accounthighscore[i][j]);
167 fpackf(tfile, "Bf", accountfasttime[i][j]);
171 fpackf(tfile, "Bb", accountunlocked[i][j]);
173 fpackf(tfile, "Bi", strlen(accountname[i]));
174 if(strlen(accountname[i])>0)
176 for(j=0;j<(int)strlen(accountname[i]);j++)
178 fpackf(tfile, "Bb", accountname[i][j]);
187 TexIter it = textures.begin();
188 for (; it != textures.end(); ++it)
190 if (glIsTexture(it->second))
191 glDeleteTextures(1, &it->second);
195 LOG("Shutting down sound system...");
197 FSOUND_StopSound(FSOUND_ALL);
199 // this is causing problems on Linux, but we'll force an _exit() a little
200 // later in the shutdown process. --ryan.
202 #define streamcount 20
203 #define samplecount 100
205 for (i=0; i < samplecount; ++i)
207 FSOUND_Sample_Free(samp[i]);
210 for (i=0; i < streamcount; ++i)
212 FSOUND_Stream_Close(strm[i]);
225 //void Game::LoadSounds();
226 void Game::LoadSounds()
230 LOG(std::string("Loading sounds..."));
232 FSOUND_3D_SetDopplerFactor(0);
234 FSOUND_SetSFXMasterVolume((int)(volume*255));
236 samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
237 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
239 samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
240 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
242 samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
243 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
245 samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
246 FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
248 samp[landsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
249 FSOUND_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f);
251 samp[jumpsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:jump.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
252 FSOUND_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f);
254 samp[hawksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:hawk.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
255 FSOUND_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f);
257 samp[whooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:whoosh.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
258 FSOUND_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f);
259 FSOUND_Sample_SetMode(samp[whooshsound], FSOUND_LOOP_NORMAL);
261 samp[landsound1] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land1.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
262 FSOUND_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f);
266 samp[landsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
267 FSOUND_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f);
269 samp[breaksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:broken.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
270 FSOUND_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f);
272 samp[lowwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Lowwhoosh.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
273 FSOUND_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f);
275 samp[midwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:midwhoosh.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
276 FSOUND_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f);
278 samp[highwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:highwhoosh.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
279 FSOUND_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f);
281 samp[movewhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:movewhoosh.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
282 FSOUND_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f);
284 samp[heavyimpactsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:heavyimpact.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
285 FSOUND_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f);
287 samp[whooshhitsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Whooshhit.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
288 FSOUND_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f);
290 samp[thudsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:thud.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
291 FSOUND_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f);
293 samp[alarmsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:alarm.ogg", FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
294 FSOUND_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f);
296 samp[breaksound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:break.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
297 FSOUND_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f);
299 samp[knifedrawsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifedraw.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
300 FSOUND_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f);
302 samp[knifesheathesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifesheathe.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
303 FSOUND_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f);
305 samp[fleshstabsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Fleshstab.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
306 FSOUND_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f);
308 samp[fleshstabremovesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Fleshstabremove.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
309 FSOUND_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f);
311 samp[knifeswishsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifeswish.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
312 FSOUND_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f);
314 samp[knifeslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifeslice.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
315 FSOUND_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f);
317 samp[swordslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:swordslice.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
318 FSOUND_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f);
320 samp[skidsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:skid.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
321 FSOUND_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f);
323 samp[snowskidsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snowskid.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
324 FSOUND_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f);
326 samp[bushrustle] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bushrustle.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
327 FSOUND_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f);
329 samp[clank1sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank1.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
330 FSOUND_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f);
332 samp[clank2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
333 FSOUND_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f);
335 samp[clank3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank3.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
336 FSOUND_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f);
338 samp[clank4sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank4.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
339 FSOUND_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f);
341 samp[consolesuccesssound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:consolesuccess.ogg", FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
342 FSOUND_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f);
344 samp[consolefailsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:consolefail.ogg", FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
345 FSOUND_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f);
347 samp[metalhitsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:MetalHit.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
348 FSOUND_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f);
350 samp[clawslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clawslice.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
351 FSOUND_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f);
353 samp[splattersound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:splatter.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
354 FSOUND_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f);
356 samp[growlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Growl.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
357 FSOUND_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f);
359 samp[growl2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Growl2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
360 FSOUND_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f);
362 samp[barksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
363 FSOUND_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f);
365 samp[bark2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
366 FSOUND_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f);
368 samp[bark3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark3.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
369 FSOUND_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f);
371 samp[snarlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snarl.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
372 FSOUND_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f);
375 samp[snarl2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snarl2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
376 FSOUND_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f);
378 samp[barkgrowlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:barkgrowl.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
379 FSOUND_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f);
381 samp[rabbitattacksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
382 FSOUND_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f);
384 samp[rabbitattack2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
385 FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f);
387 samp[rabbitattack3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack3.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
388 FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f);
390 samp[rabbitattack4sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack4.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
391 FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f);
393 samp[rabbitpainsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
394 FSOUND_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f);
396 samp[rabbitpain1sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
397 FSOUND_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f);
399 /*samp[rabbitpain2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
400 FSOUND_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f);
402 samp[rabbitchitter] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitchitter.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
403 FSOUND_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f);
405 samp[rabbitchitter2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitchitter2.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
406 FSOUND_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f);
408 samp[swordstaffsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:swordstaff.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
409 FSOUND_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f);
411 samp[staffbodysound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffbody.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
412 FSOUND_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f);
414 samp[staffheadsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffhead.ogg", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
415 FSOUND_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f);
417 samp[staffbreaksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffbreak.wav", FSOUND_HW3D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
418 FSOUND_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f);
424 void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha)
430 LOG(std::string("Loading texture...") + fileName);
432 unsigned char fileNamep[256];
433 CopyCStringToPascal(fileName,fileNamep);
435 upload_image( fileNamep ,hasalpha);
437 // std::string fname(fileName);
438 // std::transform(fname.begin(), fname.end(), tolower);
439 // TexIter it = textures.find(fname);
443 //if(textures.end() == it)
446 if ( texture.bpp == 24 )
451 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
453 if(!*textureid)glGenTextures( 1, textureid );
454 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
456 glBindTexture( GL_TEXTURE_2D, *textureid);
457 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
458 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
459 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
460 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
462 //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0,
463 // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data);
465 //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data );
467 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
469 // textures.insert(std::make_pair(fname, *textureid));
473 // *textureid = it->second;
477 void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize)
485 LOG(std::string("Loading texture (S)...") + fileName);
488 unsigned char fileNamep[256];
489 CopyCStringToPascal(fileName,fileNamep);
491 upload_image( fileNamep ,0);
492 //LoadTGA( fileName );
494 // std::string fname(fileName);
495 // std::transform(fname.begin(), fname.end(), tolower);
496 // TexIter it = textures.find(fname);
500 //if(textures.end() == it)
502 bytesPerPixel=texture.bpp/8;
505 if ( texture.bpp == 24 )
510 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
512 if(!*textureid)glGenTextures( 1, textureid );
513 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
515 glBindTexture( GL_TEXTURE_2D, *textureid);
516 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
517 if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
518 if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
519 if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
522 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
523 if((i+1)%4||type==GL_RGB){
524 array[tempnum]=texture.data[i];
529 *skinsize=texture.sizeX;
531 gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_RGB, GL_UNSIGNED_BYTE, array );
533 // textures.insert(std::make_pair(fname, *textureid));
537 // *textureid = it->second;
541 void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
548 LOG(std::string("Loading (S)...") + fileName);
551 float temptexdetail=texdetail;
553 //upload_image( fileName );
554 //LoadTGA( fileName );
556 unsigned char fileNamep[256];
557 CopyCStringToPascal(fileName,fileNamep);
559 upload_image( fileNamep ,0);
560 texdetail=temptexdetail;
564 bytesPerPixel=texture.bpp/8;
567 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
568 if((i+1)%4||bytesPerPixel==3){
569 array[tempnum]=texture.data[i];
576 bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize)
583 //upload_image( fileName );
584 //LoadTGA( fileName );
586 unsigned char fileNamep[256];
587 CopyCStringToPascal(fileName,fileNamep);
590 opened=upload_image( fileNamep ,1);
603 bytesPerPixel=texture.bpp/8;
607 for(i=0;i<(int)(texture.sizeY*texture.sizeX*bytesPerPixel);i++){
608 if(bytesPerPixel==3)alphanum=255;
609 else if((i+1)%4==0)alphanum=texture.data[i];
611 if((i+1)%4||bytesPerPixel==3){
612 if((i%4)==0)texture.data[i]*=tintr;
613 if((i%4)==1)texture.data[i]*=tintg;
614 if((i%4)==2)texture.data[i]*=tintb;
615 array[tempnum]=(float)array[tempnum]*(1-alphanum/255)+(float)texture.data[i]*(alphanum/255);
625 //***************> ResizeGLScene() <******/
626 GLvoid Game::ReSizeGLScene(float fov, float pnear)
633 glViewport(0,0,screenwidth,screenheight);
635 glMatrixMode(GL_PROJECTION);
638 gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance);
640 glMatrixMode(GL_MODELVIEW);
644 void Game::LoadingScreen()
646 static float loadprogress,minprogress,maxprogress;
647 static AbsoluteTime time = {0,0};
648 static AbsoluteTime frametime = {0,0};
649 AbsoluteTime currTime = UpTime ();
650 double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
652 if (0 > deltaTime) // if negative microseconds
653 deltaTime /= -1000000.0;
654 else // else milliseconds
657 multiplier=deltaTime;
658 if(multiplier<.001)multiplier=.001;
659 if(multiplier>10)multiplier=10;
661 frametime = currTime; // reset for next time interval
666 glClearColor(0,0,0,1);
667 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
670 loadtime+=multiplier*4;
672 loadprogress=loadtime;
673 if(loadprogress>100)loadprogress=100;
675 //loadprogress=abs(Random()%100);
679 glEnable(GL_TEXTURE_2D);
680 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
681 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
682 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
683 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
684 glDisable(GL_CULL_FACE);
685 glDisable(GL_LIGHTING);
687 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
688 glPushMatrix(); // Store The Projection Matrix
689 glLoadIdentity(); // Reset The Projection Matrix
690 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
691 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
692 glPushMatrix(); // Store The Modelview Matrix
693 glLoadIdentity(); // Reset The Modelview Matrix
694 glTranslatef(screenwidth/2,screenheight/2,0);
695 glScalef((float)screenwidth/2,(float)screenheight/2,1);
696 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
698 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
699 //glColor4f(1,1,1,1);
700 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
701 if(loadscreencolor==1)glColor4f(1,0,0,1);
702 if(loadscreencolor==2)glColor4f(0,1,0,1);
703 if(loadscreencolor==3)glColor4f(0,0,1,1);
704 if(loadscreencolor==4)glColor4f(1,1,0,1);
705 if(loadscreencolor==5)glColor4f(1,0,1,1);
708 //glScalef(.25,.25,.25);
710 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
711 glVertex3f(-1, -1, 0.0f);
712 glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3);
713 glVertex3f(1, -1, 0.0f);
714 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
715 glVertex3f(1, 1, 0.0f);
716 glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3);
717 glVertex3f(-1, 1, 0.0f);
722 //glScalef(.25,.25,.25);
724 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
725 glVertex3f(-1, -1, 0.0f);
726 glTexCoord2f(.4+loadprogress/100,0+loadprogress/100);
727 glVertex3f(1, -1, 0.0f);
728 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
729 glVertex3f(1, 1, 0.0f);
730 glTexCoord2f(.4+loadprogress/100,1+loadprogress/100);
731 glVertex3f(-1, 1, 0.0f);
734 glDisable(GL_TEXTURE_2D);
735 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
736 glPopMatrix(); // Restore The Old Projection Matrix
737 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
738 glPopMatrix(); // Restore The Old Projection Matrix
742 glEnable(GL_TEXTURE_2D);
743 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
744 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
745 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
746 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
747 glDisable(GL_CULL_FACE);
748 glDisable(GL_LIGHTING);
750 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
751 glPushMatrix(); // Store The Projection Matrix
752 glLoadIdentity(); // Reset The Projection Matrix
753 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
754 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
755 glPushMatrix(); // Store The Modelview Matrix
756 glLoadIdentity(); // Reset The Modelview Matrix
757 glTranslatef(screenwidth/2,screenheight/2,0);
758 glScalef((float)screenwidth/2*(1.5-(loadprogress)/200),(float)screenheight/2*(1.5-(loadprogress)/200),1);
759 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
761 //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
762 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1);
763 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
764 if(loadscreencolor==1)glColor4f(1,0,0,1);
765 if(loadscreencolor==2)glColor4f(0,1,0,1);
766 if(loadscreencolor==3)glColor4f(0,0,1,1);
767 if(loadscreencolor==4)glColor4f(1,1,0,1);
768 if(loadscreencolor==5)glColor4f(1,0,1,1);
771 //glScalef(.25,.25,.25);
773 glTexCoord2f(0+.5,0+.5);
774 glVertex3f(-1, -1, 0.0f);
775 glTexCoord2f(1+.5,0+.5);
776 glVertex3f(1, -1, 0.0f);
777 glTexCoord2f(1+.5,1+.5);
778 glVertex3f(1, 1, 0.0f);
779 glTexCoord2f(0+.5,1+.5);
780 glVertex3f(-1, 1, 0.0f);
783 glDisable(GL_TEXTURE_2D);
784 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
785 glPopMatrix(); // Restore The Old Projection Matrix
786 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
787 glPopMatrix(); // Restore The Old Projection Matrix
791 glEnable(GL_TEXTURE_2D);
792 glBindTexture( GL_TEXTURE_2D, loadscreentexture);
793 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
794 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
795 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
796 glDisable(GL_CULL_FACE);
797 glDisable(GL_LIGHTING);
799 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
800 glPushMatrix(); // Store The Projection Matrix
801 glLoadIdentity(); // Reset The Projection Matrix
802 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
803 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
804 glPushMatrix(); // Store The Modelview Matrix
805 glLoadIdentity(); // Reset The Modelview Matrix
806 glTranslatef(screenwidth/2,screenheight/2,0);
807 glScalef((float)screenwidth/2*(100+loadprogress)/100,(float)screenheight/2*(100+loadprogress)/100,1);
808 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
810 glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,.4);
812 //glScalef(.25,.25,.25);
814 glTexCoord2f(0+.2,0+.8);
815 glVertex3f(-1, -1, 0.0f);
816 glTexCoord2f(1+.2,0+.8);
817 glVertex3f(1, -1, 0.0f);
818 glTexCoord2f(1+.2,1+.8);
819 glVertex3f(1, 1, 0.0f);
820 glTexCoord2f(0+.2,1+.8);
821 glVertex3f(-1, 1, 0.0f);
824 glDisable(GL_TEXTURE_2D);
825 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
826 glPopMatrix(); // Restore The Old Projection Matrix
827 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
828 glPopMatrix(); // Restore The Old Projection Matrix
834 glEnable(GL_TEXTURE_2D);
835 static char string[256]="";
836 sprintf (string, "LOADING... %d%",(int)loadprogress);
838 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
839 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
840 text.glPrint(280,125,string,1,1,640,480);
844 if(flashamount>1)flashamount=1;
845 if(flashdelay<=0)flashamount-=multiplier;
847 if(flashamount<0)flashamount=0;
848 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
849 glDisable(GL_CULL_FACE);
850 glDisable(GL_LIGHTING);
851 glDisable(GL_TEXTURE_2D);
853 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
854 glPushMatrix(); // Store The Projection Matrix
855 glLoadIdentity(); // Reset The Projection Matrix
856 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
857 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
858 glPushMatrix(); // Store The Modelview Matrix
859 glLoadIdentity(); // Reset The Modelview Matrix
860 glScalef(screenwidth,screenheight,1);
861 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
863 glColor4f(flashr,flashg,flashb,flashamount);
865 glVertex3f(0, 0, 0.0f);
866 glVertex3f(256, 0, 0.0f);
867 glVertex3f(256, 256, 0.0f);
868 glVertex3f(0, 256, 0.0f);
870 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
871 glPopMatrix(); // Restore The Old Projection Matrix
872 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
873 glPopMatrix(); // Restore The Old Projection Matrix
874 glEnable(GL_DEPTH_TEST); // Enables Depth Testing
875 glEnable(GL_CULL_FACE);
885 void Game::FadeLoadingScreen(float howmuch)
887 static float loadprogress,minprogress,maxprogress;
892 glClearColor(0,0,0,1);
893 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
895 loadprogress=howmuch;
897 //loadprogress=abs(Random()%100);
901 //glEnable(GL_TEXTURE_2D);
902 glDisable(GL_TEXTURE_2D);
903 //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
904 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
905 glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
906 glDisable(GL_DEPTH_TEST); // Disables Depth Testing
907 glDisable(GL_CULL_FACE);
908 glDisable(GL_LIGHTING);
910 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
911 glPushMatrix(); // Store The Projection Matrix
912 glLoadIdentity(); // Reset The Projection Matrix
913 glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
914 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
915 glPushMatrix(); // Store The Modelview Matrix
916 glLoadIdentity(); // Reset The Modelview Matrix
917 glTranslatef(screenwidth/2,screenheight/2,0);
918 glScalef((float)screenwidth/2,(float)screenheight/2,1);
919 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
921 glColor4f(loadprogress/100,0,0,1);
922 /*if(loadscreencolor==0)glColor4f(1,1,1,1);
923 if(loadscreencolor==1)glColor4f(1,0,0,1);
924 if(loadscreencolor==2)glColor4f(0,1,0,1);
925 if(loadscreencolor==3)glColor4f(0,0,1,1);
926 if(loadscreencolor==4)glColor4f(1,1,0,1);
927 if(loadscreencolor==5)glColor4f(1,0,1,1);
930 //glScalef(.25,.25,.25);
933 glVertex3f(-1, -1, 0.0f);
935 glVertex3f(1, -1, 0.0f);
937 glVertex3f(1, 1, 0.0f);
939 glVertex3f(-1, 1, 0.0f);
942 glDisable(GL_TEXTURE_2D);
943 glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
944 glPopMatrix(); // Restore The Old Projection Matrix
945 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
946 glPopMatrix(); // Restore The Old Projection Matrix
951 glEnable(GL_TEXTURE_2D);
952 static char string[256]="";
953 sprintf (string, "LOADING... %d%",(int)loadprogress);
955 text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
956 glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
957 text.glPrint(280,125,string,1,1,640,480);
964 void Game::InitGame()
967 ProcessSerialNumber PSN;
968 ProcessInfoRec pinfo;
971 /* set up process serial number */
972 PSN.highLongOfPSN = 0;
973 PSN.lowLongOfPSN = kCurrentProcess;
974 /* set up info block */
975 pinfo.processInfoLength = sizeof(pinfo);
976 pinfo.processName = NULL;
977 pinfo.processAppSpec = &pspec;
978 /* grab the vrefnum and directory */
979 err = GetProcessInformation(&PSN, &pinfo);
981 vRefNum = pspec.vRefNum;
992 numchallengelevels=14;
996 /*char tempstring[256];
997 sprintf (tempstring, "%s", registrationname);
1003 longnum = MD5_string ( tempstring);
1004 //longnum = 1111111111111111;
1005 num1 = longnum/100000000;
1006 num2 = longnum%100000000;
1007 sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
1011 tfile=fopen( ":Data:Sounds:flame.ogg", "rb" );
1022 funpackf(tfile, "Bb", ®istered);
1025 funpackf(tfile, "Bi", &numchars);
1028 for(j=0;j<numchars;j++)
1030 funpackf(tfile, "Bb", ®istrationname[j]);
1032 registrationname[numchars]='\0';
1033 funpackf(tfile, "Bi", &num1);
1034 funpackf(tfile, "Bi", &num2);
1035 longnum=num2+num1*100000000;
1037 char tempstring[256];
1038 #if defined(__APPLE__)
1039 sprintf (tempstring, "%s", registrationname);
1040 #elif defined(_WIN32) || defined(__linux__)
1041 sprintf (tempstring, "%s-windows", registrationname);
1043 #error Please make sure you have the right registration key stuff here!
1045 longnuma = MD5_string ( tempstring);
1046 num1a = longnuma/100000000;
1047 num2a = longnuma%100000000;
1048 //if(num1a==num1&&num2a==num2)registered=1;
1049 if(numchars>2)registered=1;
1059 sprintf (mapname, ":Data:Users");
1060 tfile=fopen( mapname, "rb" );
1063 funpackf(tfile, "Bi", &numaccounts);
1064 funpackf(tfile, "Bi", &accountactive);
1067 for(i=0;i<numaccounts;i++)
1069 funpackf(tfile, "Bf", &accountcampaigntime[i]);
1070 funpackf(tfile, "Bf", &accountcampaignscore[i]);
1071 funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
1072 funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
1073 funpackf(tfile, "Bi", &accountdifficulty[i]);
1074 funpackf(tfile, "Bi", &accountprogress[i]);
1075 funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
1076 for(j=0;j<accountcampaignchoicesmade[i];j++)
1078 funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
1079 if (accountcampaignchoices[i][j] >= 10)
1081 accountcampaignchoices[i][j] = 0;
1084 funpackf(tfile, "Bf", &accountpoints[i]);
1087 funpackf(tfile, "Bf", &accounthighscore[i][j]);
1088 funpackf(tfile, "Bf", &accountfasttime[i][j]);
1092 funpackf(tfile, "Bb", &accountunlocked[i][j]);
1095 funpackf(tfile, "Bi", &temp);
1100 funpackf(tfile, "Bb", &accountname[i][j]);
1113 whichjointstartarray[0]=righthip;
1114 whichjointendarray[0]=rightfoot;
1116 whichjointstartarray[1]=righthip;
1117 whichjointendarray[1]=rightankle;
1119 whichjointstartarray[2]=righthip;
1120 whichjointendarray[2]=rightknee;
1122 whichjointstartarray[3]=rightknee;
1123 whichjointendarray[3]=rightankle;
1125 whichjointstartarray[4]=rightankle;
1126 whichjointendarray[4]=rightfoot;
1128 whichjointstartarray[5]=lefthip;
1129 whichjointendarray[5]=leftfoot;
1131 whichjointstartarray[6]=lefthip;
1132 whichjointendarray[6]=leftankle;
1134 whichjointstartarray[7]=lefthip;
1135 whichjointendarray[7]=leftknee;
1137 whichjointstartarray[8]=leftknee;
1138 whichjointendarray[8]=leftankle;
1140 whichjointstartarray[9]=leftankle;
1141 whichjointendarray[9]=leftfoot;
1143 whichjointstartarray[10]=abdomen;
1144 whichjointendarray[10]=rightshoulder;
1146 whichjointstartarray[11]=abdomen;
1147 whichjointendarray[11]=rightelbow;
1149 whichjointstartarray[12]=abdomen;
1150 whichjointendarray[12]=rightwrist;
1152 whichjointstartarray[13]=abdomen;
1153 whichjointendarray[13]=righthand;
1155 whichjointstartarray[14]=rightshoulder;
1156 whichjointendarray[14]=rightelbow;
1158 whichjointstartarray[15]=rightelbow;
1159 whichjointendarray[15]=rightwrist;
1161 whichjointstartarray[16]=rightwrist;
1162 whichjointendarray[16]=righthand;
1164 whichjointstartarray[17]=abdomen;
1165 whichjointendarray[17]=leftshoulder;
1167 whichjointstartarray[18]=abdomen;
1168 whichjointendarray[18]=leftelbow;
1170 whichjointstartarray[19]=abdomen;
1171 whichjointendarray[19]=leftwrist;
1173 whichjointstartarray[20]=abdomen;
1174 whichjointendarray[20]=lefthand;
1176 whichjointstartarray[21]=leftshoulder;
1177 whichjointendarray[21]=leftelbow;
1179 whichjointstartarray[22]=leftelbow;
1180 whichjointendarray[22]=leftwrist;
1182 whichjointstartarray[23]=leftwrist;
1183 whichjointendarray[23]=lefthand;
1185 whichjointstartarray[24]=abdomen;
1186 whichjointendarray[24]=neck;
1188 whichjointstartarray[25]=neck;
1189 whichjointendarray[25]=head;
1191 FadeLoadingScreen(0);
1195 texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1197 int temptexdetail=texdetail;
1199 text.LoadFontTexture(":Data:Textures:Font.png");
1201 texdetail=temptexdetail;
1203 FadeLoadingScreen(10);
1219 for (int it = 0; it < 100; ++it)
1224 for (int it = 0; it < 20; ++it)
1229 LOG("Initializing sound system...");
1234 extern bool cmdline(const char *cmd);
1235 unsigned char rc = 0;
1236 output = FSOUND_OUTPUT_ALSA; // Try alsa first...
1237 if (cmdline("forceoss")) // ...but let user override that.
1238 output = FSOUND_OUTPUT_OSS;
1239 else if (cmdline("nosound"))
1240 output = FSOUND_OUTPUT_NOSOUND;
1242 FSOUND_SetOutput(output);
1243 if ((rc = FSOUND_Init(44100, 32, 0)) == false)
1245 // if we tried ALSA and failed, fall back to OSS.
1246 if ( (output == FSOUND_OUTPUT_ALSA) && (!cmdline("forcealsa")) )
1249 output = FSOUND_OUTPUT_OSS;
1250 FSOUND_SetOutput(output);
1251 rc = FSOUND_Init(44100, 32, 0);
1258 output = FSOUND_OUTPUT_NOSOUND; // we tried! just do silence.
1259 FSOUND_SetOutput(output);
1260 rc = FSOUND_Init(44100, 32, 0);
1263 FSOUND_Init(44100, 32, 0);
1266 FSOUND_SetSFXMasterVolume((int)(volume*255));
1268 strm[stream_music3] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
1269 // FSOUND_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
1270 FSOUND_Stream_SetMode(strm[stream_music3], FSOUND_LOOP_NORMAL);
1273 // PlaySoundEx( stream_music3, strm[stream_music3], NULL, true);
1274 PlayStreamEx(stream_music3, strm[stream_music3], 0, true);
1275 FSOUND_SetPaused(channels[stream_music3], false);
1276 FSOUND_SetVolume(channels[stream_music3], 256);
1279 FadeLoadingScreen(20);
1282 strm[stream_wind] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1283 // FSOUND_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
1284 FSOUND_Stream_SetMode(strm[stream_wind], FSOUND_LOOP_NORMAL);
1286 FadeLoadingScreen(30);
1288 strm[stream_desertambient] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1289 // FSOUND_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
1290 FSOUND_Stream_SetMode(strm[stream_desertambient], FSOUND_LOOP_NORMAL);
1293 FadeLoadingScreen(40);
1295 samp[firestartsound] = FSOUND_Sample_Load(FSOUND_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1296 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1298 strm[stream_firesound] = FSOUND_Stream_Open(":Data:Sounds:fire.ogg", FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1299 // FSOUND_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
1300 FSOUND_Stream_SetMode(strm[stream_firesound], FSOUND_LOOP_NORMAL);
1302 FadeLoadingScreen(50);
1304 samp[fireendsound] = FSOUND_Sample_Load(FSOUND_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
1305 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1308 strm[stream_music1grass] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
1309 // FSOUND_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
1310 FSOUND_Stream_SetMode(strm[stream_music1grass], FSOUND_LOOP_NORMAL);
1312 strm[stream_music1snow] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
1313 // FSOUND_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
1314 FSOUND_Stream_SetMode(strm[stream_music1snow], FSOUND_LOOP_NORMAL);
1316 FadeLoadingScreen(60);
1318 strm[stream_music1desert] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
1319 // FSOUND_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
1320 FSOUND_Stream_SetMode(strm[stream_music1desert], FSOUND_LOOP_NORMAL);
1322 FadeLoadingScreen(80);
1323 strm[stream_music2] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
1324 // FSOUND_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
1325 FSOUND_Stream_SetMode(strm[stream_music2], FSOUND_LOOP_NORMAL);
1330 FadeLoadingScreen(90);
1333 LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
1335 LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
1336 LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
1337 LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
1339 temptexdetail=texdetail;
1340 if(texdetail>2)texdetail=2;
1341 LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
1342 LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
1343 LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
1344 LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
1345 LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
1346 LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
1347 //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
1348 texdetail=temptexdetail;
1353 FadeLoadingScreen(95);
1364 newscreenwidth=screenwidth;
1365 newscreenheight=screenheight;
1370 float gLoc[3]={0,0,0};
1371 float vel[3]={0,0,0};
1372 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
1373 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
1374 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
1375 FSOUND_SetVolume(channels[firestartsound], 256);
1376 FSOUND_SetPaused(channels[firestartsound], false);
1377 FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
1388 void Game::LoadStuff()
1390 static float temptexdetail;
1391 static float viewdistdetail;
1392 static int i,j,texsize;
1399 /*musicvolume[3]=512;
1400 PlaySoundEx( music4, samp[music4], NULL, true);
1401 FSOUND_SetPaused(channels[music4], false);
1402 FSOUND_SetVolume(channels[music4], 512);
1408 //texture.data = ( GLubyte* )malloc( 1024*1024*4 );
1412 for(i=0;i<maxplayers;i++)
1414 if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
1416 glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
1418 player[i].skeleton.drawmodel.textureptr=0;;
1421 //temptexdetail=texdetail;
1424 LoadTexture(":Data:Textures:fire.jpg",&loadscreentexture,1,0);
1425 //texdetail=temptexdetail;
1427 temptexdetail=texdetail;
1429 text.LoadFontTexture(":Data:Textures:Font.png");
1431 texdetail=temptexdetail;
1436 viewdistance=50*megascale*viewdistdetail;
1456 realtexdetail=texdetail;
1459 if(texdetail<1)texdetail=1;
1460 realtexdetail=texdetail*4;
1466 /*LoadTexture(":Data:Textures:snow.png",&terraintexture,1);
1468 LoadTexture(":Data:Textures:rock.png",&terraintexture2,1);
1470 LoadTexture(":Data:Textures:detail.png",&terraintexture3,1);
1474 LOG("Loading weapon data...");
1476 LoadTexture(":Data:Textures:knife.png",&weapons.knifetextureptr,0,1);
1477 LoadTexture(":Data:Textures:bloodknife.png",&weapons.bloodknifetextureptr,0,1);
1478 LoadTexture(":Data:Textures:lightbloodknife.png",&weapons.lightbloodknifetextureptr,0,1);
1479 LoadTexture(":Data:Textures:sword.jpg",&weapons.swordtextureptr,1,0);
1480 LoadTexture(":Data:Textures:Swordblood.jpg",&weapons.bloodswordtextureptr,1,0);
1481 LoadTexture(":Data:Textures:Swordbloodlight.jpg",&weapons.lightbloodswordtextureptr,1,0);
1482 LoadTexture(":Data:Textures:Staff.jpg",&weapons.stafftextureptr,1,0);
1484 weapons.throwingknifemodel.load((char *)":Data:Models:throwingknife.solid",1);
1485 weapons.throwingknifemodel.Scale(.001,.001,.001);
1486 //weapons.throwingknifemodel.Rotate(0,0,-90);
1487 weapons.throwingknifemodel.Rotate(90,0,0);
1488 weapons.throwingknifemodel.Rotate(0,90,0);
1489 weapons.throwingknifemodel.flat=0;
1490 weapons.throwingknifemodel.CalculateNormals(1);
1491 //weapons.throwingknifemodel.ScaleNormals(-1,-1,-1);
1493 weapons.swordmodel.load((char *)":Data:Models:sword.solid",1);
1494 weapons.swordmodel.Scale(.001,.001,.001);
1495 //weapons.swordmodel.Rotate(0,0,-90);
1496 weapons.swordmodel.Rotate(90,0,0);
1497 weapons.swordmodel.Rotate(0,90,0);
1498 weapons.swordmodel.Rotate(0,0,90);
1499 weapons.swordmodel.flat=1;
1500 weapons.swordmodel.CalculateNormals(1);
1501 //weapons.swordmodel.ScaleNormals(-1,-1,-1);
1503 weapons.staffmodel.load((char *)":Data:Models:staff.solid",1);
1504 weapons.staffmodel.Scale(.005,.005,.005);
1505 //weapons.staffmodel.Rotate(0,0,-90);
1506 weapons.staffmodel.Rotate(90,0,0);
1507 weapons.staffmodel.Rotate(0,90,0);
1508 weapons.staffmodel.Rotate(0,0,90);
1509 weapons.staffmodel.flat=1;
1510 weapons.staffmodel.CalculateNormals(1);
1511 //weapons.staffmodel.ScaleNormals(-1,-1,-1);
1513 //temptexdetail=texdetail;
1514 //if(texdetail>4)texdetail=4;
1515 LoadTexture(":Data:Textures:shadow.png",&terrain.shadowtexture,0,1);
1517 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture,0,1);
1519 LoadTexture(":Data:Textures:break.png",&terrain.breaktexture,0,1);
1521 LoadTexture(":Data:Textures:blood.png",&terrain.bloodtexture2,0,1);
1524 LoadTexture(":Data:Textures:footprint.png",&terrain.footprinttexture,0,1);
1526 LoadTexture(":Data:Textures:bodyprint.png",&terrain.bodyprinttexture,0,1);
1528 /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1);
1530 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1);
1532 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1);
1534 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1);
1536 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1);
1538 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1);
1539 //texdetail=temptexdetail;
1540 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1);*/
1544 LoadTexture(":Data:Textures:hawk.png",&hawktexture,0,1);
1546 LoadTexture(":Data:Textures:logo.png",&logotexture,0,1);
1549 //LoadTexture(":Data:Textures:box.jpg",&objects.boxtextureptr,1,0);
1552 LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1);
1553 LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1);
1554 LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1);
1555 LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1);
1556 LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1);
1557 LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1);
1558 LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1);
1559 LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0);
1560 LoadTexture(":Data:Textures:splinter.png",&sprites.splintertexture,1,1);
1561 LoadTexture(":Data:Textures:leaf.png",&sprites.leaftexture,1,1);
1562 LoadTexture(":Data:Textures:tooth.png",&sprites.toothtexture,1,1);
1566 ReSizeGLScene(90,.01);
1573 if(detail)kTextureSize=1024;
1574 if(detail==1)kTextureSize=512;
1575 if(detail==0)kTextureSize=256;
1578 //drawmode=motionblurmode;
1580 //Set up distant light
1584 light.ambient[0]=.2;
1585 light.ambient[1]=.2;
1586 light.ambient[2]=.24;
1589 light.location.z=-.2;
1590 Normalise(&light.location);
1600 texscale=.2/megascale/viewdistdetail;
1601 terrain.scale=3*megascale*terraindetail*viewdistdetail;
1603 viewer.x=terrain.size/2*terrain.scale;
1604 viewer.z=terrain.size/2*terrain.scale;
1606 hawk.load((char *)":Data:Models:hawk.solid",1);
1607 hawk.Scale(.03,.03,.03);
1608 hawk.Rotate(90,1,1);
1609 hawk.CalculateNormals(0);
1610 hawk.ScaleNormals(-1,-1,-1);
1611 hawkcoords.x=terrain.size/2*terrain.scale-5-7;
1612 hawkcoords.z=terrain.size/2*terrain.scale-5-7;
1613 hawkcoords.y=terrain.getHeight(hawkcoords.x,hawkcoords.z)+25;
1616 eye.load((char *)":Data:Models:eye.solid",1);
1617 eye.Scale(.03,.03,.03);
1618 eye.CalculateNormals(0);
1620 cornea.load((char *)":Data:Models:cornea.solid",1);
1621 cornea.Scale(.03,.03,.03);
1622 cornea.CalculateNormals(0);
1624 iris.load((char *)":Data:Models:iris.solid",1);
1625 iris.Scale(.03,.03,.03);
1626 iris.CalculateNormals(0);
1628 LoadSave(":Data:Textures:Bloodfur.png",0,1,&bloodText[0],0);
1629 LoadSave(":Data:Textures:Wolfbloodfur.png",0,1,&wolfbloodText[0],0);
1637 //if(targetlevel!=7)
1638 Loadlevel(targetlevel);
1641 rabbitcoords=player[0].coords;
1642 rabbitcoords.y=terrain.getHeight(rabbitcoords.x,rabbitcoords.z);
1644 animation[runanim].Load((char *)":Data:Animations:Run",middleheight,neutral);
1646 animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral);
1647 animation[stopanim].Load((char *)":Data:Animations:Stop",middleheight,neutral);
1649 animation[jumpupanim].Load((char *)":Data:Animations:JumpUp",highheight,neutral);
1650 animation[jumpdownanim].Load((char *)":Data:Animations:JumpDown",highheight,neutral);
1652 animation[landanim].Load((char *)":Data:Animations:Landing",lowheight,neutral);
1653 animation[landhardanim].Load((char *)":Data:Animations:Landhard",lowheight,neutral);
1654 animation[climbanim].Load((char *)":Data:Animations:Climb",lowheight,neutral);
1655 animation[hanganim].Load((char *)":Data:Animations:Hangon",lowheight,neutral);
1656 animation[spinkickanim].Load((char *)":Data:Animations:SpinKick",middleheight,normalattack);
1658 animation[getupfromfrontanim].Load((char *)":Data:Animations:GetUpFromFront",lowheight,neutral);
1659 animation[getupfrombackanim].Load((char *)":Data:Animations:GetUpFromBack",lowheight,neutral);
1660 animation[crouchanim].Load((char *)":Data:Animations:Crouch",lowheight,neutral);
1661 animation[sneakanim].Load((char *)":Data:Animations:Sneak",lowheight,neutral);
1662 animation[rollanim].Load((char *)":Data:Animations:Roll",lowheight,neutral);
1663 animation[flipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1664 animation[frontflipanim].Load((char *)":Data:Animations:Flip",highheight,neutral);
1665 animation[spinkickreversedanim].Load((char *)":Data:Animations:SpinKickCaught",middleheight,reversed);
1667 animation[spinkickreversalanim].Load((char *)":Data:Animations:SpinKickCatch",middleheight,reversal);
1668 animation[lowkickanim].Load((char *)":Data:Animations:lowkick",middleheight,normalattack);
1669 animation[sweepanim].Load((char *)":Data:Animations:sweep",lowheight,normalattack);
1670 animation[sweepreversedanim].Load((char *)":Data:Animations:SweepCaught",lowheight,reversed);
1671 animation[sweepreversalanim].Load((char *)":Data:Animations:SweepCatch",middleheight,reversal);
1672 animation[rabbitkickanim].Load((char *)":Data:Animations:RabbitKick",middleheight,normalattack);
1673 animation[rabbitkickreversedanim].Load((char *)":Data:Animations:RabbitKickCaught",middleheight,reversed);
1674 animation[rabbitkickreversalanim].Load((char *)":Data:Animations:RabbitKickCatch",lowheight,reversal);
1675 animation[upunchanim].Load((char *)":Data:Animations:Upunch",middleheight,normalattack);
1676 animation[staggerbackhighanim].Load((char *)":Data:Animations:Staggerbackhigh",middleheight,neutral);
1677 animation[upunchreversedanim].Load((char *)":Data:Animations:UpunchCaught",middleheight,reversed);
1679 animation[upunchreversalanim].Load((char *)":Data:Animations:UpunchCatch",middleheight,reversal);
1680 animation[hurtidleanim].Load((char *)":Data:Animations:Hurtidle",middleheight,neutral);
1681 animation[backhandspringanim].Load((char *)":Data:Animations:Backhandspring",middleheight,neutral);
1682 animation[fightidleanim].Load((char *)":Data:Animations:Fightidle",middleheight,neutral);
1683 animation[walkanim].Load((char *)":Data:Animations:Walk",middleheight,neutral);
1685 animation[fightsidestep].Load((char *)":Data:Animations:Fightsidestep",middleheight,neutral);
1686 animation[killanim].Load((char *)":Data:Animations:Kill",middleheight,normalattack);
1687 animation[sneakattackanim].Load((char *)":Data:Animations:Sneakattack",middleheight,reversal);
1688 animation[sneakattackedanim].Load((char *)":Data:Animations:Sneakattacked",middleheight,reversed);
1689 animation[drawrightanim].Load((char *)":Data:Animations:drawright",middleheight,neutral);
1690 animation[knifeslashstartanim].Load((char *)":Data:Animations:slashstart",middleheight,normalattack);
1691 animation[crouchdrawrightanim].Load((char *)":Data:Animations:crouchdrawright",lowheight,neutral);
1692 animation[crouchstabanim].Load((char *)":Data:Animations:crouchstab",lowheight,normalattack);
1694 animation[knifefollowanim].Load((char *)":Data:Animations:slashfollow",middleheight,reversal);
1695 animation[knifefollowedanim].Load((char *)":Data:Animations:slashfollowed",middleheight,reversed);
1696 animation[knifethrowanim].Load((char *)":Data:Animations:knifethrow",middleheight,normalattack);
1697 animation[removeknifeanim].Load((char *)":Data:Animations:removeknife",middleheight,neutral);
1698 animation[crouchremoveknifeanim].Load((char *)":Data:Animations:crouchremoveknife",lowheight,neutral);
1699 animation[jumpreversedanim].Load((char *)":Data:Animations:JumpCaught",middleheight,reversed);
1700 animation[jumpreversalanim].Load((char *)":Data:Animations:JumpCatch",middleheight,reversal);
1701 animation[staggerbackhardanim].Load((char *)":Data:Animations:Staggerbackhard",middleheight,neutral);
1703 animation[dropkickanim].Load((char *)":Data:Animations:Dropkick",middleheight,normalattack);
1704 animation[winduppunchanim].Load((char *)":Data:Animations:Winduppunch",middleheight,normalattack);
1705 animation[winduppunchblockedanim].Load((char *)":Data:Animations:Winduppunchblocked",middleheight,normalattack);
1706 animation[blockhighleftanim].Load((char *)":Data:Animations:Blockhighleft",middleheight,normalattack);
1707 animation[blockhighleftstrikeanim].Load((char *)":Data:Animations:Blockhighleftstrike",middleheight,normalattack);
1708 animation[backflipanim].Load((char *)":Data:Animations:Backflip",highheight,neutral);
1709 animation[walljumpbackanim].Load((char *)":Data:Animations:Walljumpback",highheight,neutral);
1710 animation[walljumpfrontanim].Load((char *)":Data:Animations:Walljumpfront",highheight,neutral);
1711 animation[rightflipanim].Load((char *)":Data:Animations:Rightflip",highheight,neutral);
1712 animation[walljumprightanim].Load((char *)":Data:Animations:Walljumpright",highheight,neutral);
1713 animation[leftflipanim].Load((char *)":Data:Animations:Leftflip",highheight,neutral);
1714 animation[walljumpleftanim].Load((char *)":Data:Animations:Walljumpleft",highheight,neutral);
1715 animation[walljumprightkickanim].Load((char *)":Data:Animations:Walljumprightkick",highheight,neutral);
1716 animation[walljumpleftkickanim].Load((char *)":Data:Animations:Walljumpleftkick",highheight,neutral);
1717 animation[knifefightidleanim].Load((char *)":Data:Animations:Knifefightidle",middleheight,neutral);
1718 animation[knifesneakattackanim].Load((char *)":Data:Animations:Knifesneakattack",middleheight,reversal);
1719 animation[knifesneakattackedanim].Load((char *)":Data:Animations:Knifesneakattacked",middleheight,reversed);
1720 animation[swordfightidleanim].Load((char *)":Data:Animations:swordfightidle",middleheight,neutral);
1721 animation[drawleftanim].Load((char *)":Data:Animations:drawleft",middleheight,neutral);
1722 animation[swordslashanim].Load((char *)":Data:Animations:swordslash",middleheight,normalattack);
1723 animation[swordgroundstabanim].Load((char *)":Data:Animations:swordgroundstab",lowheight,normalattack);
1724 animation[dodgebackanim].Load((char *)":Data:Animations:dodgeback",middleheight,neutral);
1725 animation[swordsneakattackanim].Load((char *)":Data:Animations:Swordsneakattack",middleheight,reversal);
1726 animation[swordsneakattackedanim].Load((char *)":Data:Animations:Swordsneakattacked",middleheight,reversed);
1727 animation[swordslashreversedanim].Load((char *)":Data:Animations:swordslashCaught",middleheight,reversed);
1728 animation[swordslashreversalanim].Load((char *)":Data:Animations:swordslashCatch",middleheight,reversal);
1729 animation[knifeslashreversedanim].Load((char *)":Data:Animations:knifeslashCaught",middleheight,reversed);
1730 animation[knifeslashreversalanim].Load((char *)":Data:Animations:knifeslashCatch",middleheight,reversal);
1731 animation[swordfightidlebothanim].Load((char *)":Data:Animations:swordfightidleboth",middleheight,neutral);
1732 animation[swordslashparryanim].Load((char *)":Data:Animations:sworduprightparry",middleheight,normalattack);
1733 animation[swordslashparriedanim].Load((char *)":Data:Animations:swordslashparried",middleheight,normalattack);
1734 animation[wolfidle].Load((char *)":Data:Animations:Wolfidle",middleheight,neutral);
1735 animation[wolfcrouchanim].Load((char *)":Data:Animations:Wolfcrouch",lowheight,neutral);
1736 animation[wolflandanim].Load((char *)":Data:Animations:Wolflanding",lowheight,neutral);
1737 animation[wolflandhardanim].Load((char *)":Data:Animations:Wolflandhard",lowheight,neutral);
1738 animation[wolfrunanim].Load((char *)":Data:Animations:Wolfrun",middleheight,neutral);
1739 animation[wolfrunninganim].Load((char *)":Data:Animations:Wolfrunning",middleheight,neutral);
1740 animation[rabbitrunninganim].Load((char *)":Data:Animations:Rabbitrunning",middleheight,neutral);
1741 animation[wolfstopanim].Load((char *)":Data:Animations:Wolfstop",middleheight,neutral);
1742 animation[rabbittackleanim].Load((char *)":Data:Animations:Rabbittackle",middleheight,neutral);
1743 animation[rabbittacklinganim].Load((char *)":Data:Animations:Rabbittackling",middleheight,reversal);
1744 animation[rabbittackledbackanim].Load((char *)":Data:Animations:Rabbittackledback",middleheight,reversed);
1745 animation[rabbittackledfrontanim].Load((char *)":Data:Animations:Rabbittackledfront",middleheight,reversed);
1746 animation[wolfslapanim].Load((char *)":Data:Animations:Wolfslap",middleheight,normalattack);
1747 animation[staffhitanim].Load((char *)":Data:Animations:StaffHit",middleheight,normalattack);
1748 animation[staffgroundsmashanim].Load((char *)":Data:Animations:StaffGroundSmash",lowheight,normalattack);
1749 animation[staffspinhitanim].Load((char *)":Data:Animations:Spinwhack",middleheight,normalattack);
1750 animation[staffhitreversedanim].Load((char *)":Data:Animations:StaffHitCaught",middleheight,reversed);
1751 animation[staffhitreversalanim].Load((char *)":Data:Animations:StaffHitCatch",middleheight,reversal);
1752 animation[staffspinhitreversedanim].Load((char *)":Data:Animations:SpinWhackCaught",middleheight,reversed);
1753 animation[staffspinhitreversalanim].Load((char *)":Data:Animations:SpinWhackCatch",middleheight,reversal);
1755 animation[sitanim].Load((char *)":Data:Animations:Sit",lowheight,neutral);
1756 animation[sleepanim].Load((char *)":Data:Animations:Sleep",lowheight,neutral);
1757 animation[talkidleanim].Load((char *)":Data:Animations:TalkIdle",middleheight,neutral);
1759 animation[sitwallanim].Load((char *)":Data:Animations:Dying",lowheight,neutral);
1760 animation[dead1anim].Load((char *)":Data:Animations:Dead1",lowheight,neutral);
1761 animation[dead2anim].Load((char *)":Data:Animations:Dead2",lowheight,neutral);
1762 animation[dead3anim].Load((char *)":Data:Animations:Dead3",lowheight,neutral);
1763 animation[dead4anim].Load((char *)":Data:Animations:Dead4",lowheight,neutral);
1764 //Fix knife stab, too lazy to do it manually
1768 for(i=0;i<player[0].skeleton.num_joints;i++){
1769 for(j=0;j<animation[knifesneakattackanim].numframes;j++){
1770 animation[knifesneakattackanim].position[i][j]+=moveamount;
1777 for(i=0;i<player[0].skeleton.num_joints;i++){
1778 for(j=0;j<animation[knifesneakattackedanim].numframes;j++){
1779 animation[knifesneakattackedanim].position[i][j]+=moveamount;
1786 for(i=0;i<player[0].skeleton.num_joints;i++){
1787 animation[dead1anim].position[i][1]=animation[dead1anim].position[i][0];
1788 animation[dead2anim].position[i][1]=animation[dead2anim].position[i][0];
1789 animation[dead3anim].position[i][1]=animation[dead3anim].position[i][0];
1790 animation[dead4anim].position[i][1]=animation[dead4anim].position[i][0];
1792 animation[dead1anim].speed[0]=0.001;
1793 animation[dead2anim].speed[0]=0.001;
1794 animation[dead3anim].speed[0]=0.001;
1795 animation[dead4anim].speed[0]=0.001;
1797 animation[dead1anim].speed[1]=0.001;
1798 animation[dead2anim].speed[1]=0.001;
1799 animation[dead3anim].speed[1]=0.001;
1800 animation[dead4anim].speed[1]=0.001;
1802 for(i=0;i<player[0].skeleton.num_joints;i++){
1803 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1804 animation[swordsneakattackanim].position[i][j]+=moveamount;
1809 for(j=0;j<animation[swordsneakattackanim].numframes;j++){
1810 animation[swordsneakattackanim].weapontarget[j]+=moveamount;
1816 for(i=0;i<player[0].skeleton.num_joints;i++){
1817 for(j=0;j<animation[swordsneakattackedanim].numframes;j++){
1818 animation[swordsneakattackedanim].position[i][j]+=moveamount;
1822 for(i=0;i<player[0].skeleton.num_joints;i++){
1823 for(j=0;j<animation[sleepanim].numframes;j++){
1824 animation[sleepanim].position[i][j]=DoRotation(animation[sleepanim].position[i][j],0,180,0);
1830 temptexdetail=texdetail;
1832 texdetail=temptexdetail;
1839 glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
1841 glGenTextures( 1, &screentexture );
1842 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
1845 glEnable(GL_TEXTURE_2D);
1846 glBindTexture( GL_TEXTURE_2D, screentexture);
1847 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
1848 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
1850 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
1856 /*PlaySoundEx( consolesuccesssound, samp[consolesuccesssound], NULL, true);
1857 FSOUND_SetVolume(channels[consolesuccesssound], 256);
1858 FSOUND_SetPaused(channels[consolesuccesssound], false);
1861 float gLoc[3]={0,0,0};
1862 float vel[3]={0,0,0};
1863 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f);
1864 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1865 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1866 FSOUND_SetVolume(channels[fireendsound], 256);
1867 FSOUND_SetPaused(channels[fireendsound], false);
1868 FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
1881 terraintexture2 = 0;
1882 terraintexture3 = 0;
1886 loadscreentexture = 0;
1887 Maparrowtexture = 0;
1889 Mapcircletexture = 0;
1892 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
1896 memset(startx, 0, sizeof(startx));
1897 memset(starty, 0, sizeof(starty));
1898 memset(endx, 0, sizeof(endx));
1899 memset(endy, 0, sizeof(endy));
1901 memset(selectedlong, 0, sizeof(selectedlong));
1902 memset(offsetx, 0, sizeof(offsetx));
1903 memset(offsety, 0, sizeof(offsety));
1904 memset(movex, 0, sizeof(movex));
1905 memset(movey, 0, sizeof(movey));
1906 memset(endy, 0, sizeof(endy));
1920 memset(menustring, 0, sizeof(menustring));
1921 memset(registrationname, 0, sizeof(registrationname));
1922 registrationnumber = 0;
1926 newscreenheight = 0;
1929 deltah = 0,deltav = 0;
1930 mousecoordh = 0,mousecoordv = 0;
1931 oldmousecoordh = 0,oldmousecoordv = 0;
1932 rotation = 0,rotation2 = 0;
1937 cameratogglekeydown = 0;
1938 chattogglekeydown = 0;
1941 drawmodetogglekeydown = 0;
1942 explodetogglekeydown = 0;
1943 detailtogglekeydown = 0;
1953 // XYZ realhawkcoords;
1965 campaignnumlevels = 0;
1967 memset(campaignmapname, 0, sizeof(campaignmapname));
1968 memset(campaigndescription, 0, sizeof(campaigndescription));
1969 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
1970 memset(campaignnumnext, 0, sizeof(campaignnumnext));
1971 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
1972 int campaignchoicesmade;
1973 memset(campaignchoices, 0, sizeof(campaignchoices));
1974 memset(campaignlocationx, 0, sizeof(campaignlocationx));
1975 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1976 memset(campaignlocationy, 0, sizeof(campaignlocationy));
1978 campaignchoicenum = 0;
1980 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
1984 numlevelspassed = 0;
1986 memset(levelorder, 0, sizeof(levelorder));
1987 memset(levelvisible, 0, sizeof(levelvisible));
1988 memset(levelhighlight, 0, sizeof(levelhighlight));
1992 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
1996 // XYZ rabbitcoords;
2007 envtogglekeydown = 0;
2008 slomotogglekeydown = 0;
2009 texturesizetogglekeydown = 0;
2010 freezetogglekeydown = 0;
2017 editorrotation2 = 0;
2024 // XYZ pathpoint[30];
2026 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
2027 memset(pathpointconnect, 0, sizeof(pathpointconnect));
2028 pathpointselected = 0;
2032 numchallengelevels = 0;
2035 archiveselected = 0;
2037 memset(consoletext, 0, sizeof(consoletext));
2038 memset(consolechars, 0, sizeof(consolechars));
2040 memset(displaytext, 0, sizeof(displaytext));
2041 memset(displaychars, 0, sizeof(displaychars));
2042 memset(displaytime, 0, sizeof(displaytime));
2043 displayblinkdelay = 0;
2045 displayselected = 0;
2047 consoletogglekeydown = 0;
2048 consoleblinkdelay = 0;
2050 consoleselected = 0;
2051 memset(togglekey, 0, sizeof(togglekey));
2052 memset(togglekeydelay, 0, sizeof(togglekeydelay));
2056 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
2063 // XYZ boundary[360];
2070 memset(musicvolume, 0, sizeof(musicvolume));
2071 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));