X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameInitDispose.cpp;h=79d8bd150578f9ff49b39d31471464c6d35f86b9;hb=483f57f7df7e65f1aacbee8dbcef320ede069a95;hp=90ab51e36618fe1b6789a3eb31a03fedff1ca09f;hpb=36cc3af3e5074215817ddee16defde754e2ad67f;p=lugaru.git diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index 90ab51e..79d8bd1 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -1,4 +1,28 @@ -#include "Game.h" +/* +Copyright (C) 2003, 2010 - Wolfire Games + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "Game.h" +#include "openal_wrapper.h" +#include "Animation.h" + extern float screenwidth,screenheight; extern float viewdistance; extern XYZ viewer; @@ -8,17 +32,13 @@ extern float fadestart; extern float texscale; extern float gravity; extern Light light; -extern Animation animation[animation_count]; extern Skeleton testskeleton; extern int numsounds; -extern FSOUND_SAMPLE *samp[100]; -extern int channels[100]; extern Terrain terrain; -extern Sprites sprites; +//extern Sprites sprites; extern int kTextureSize; extern float texdetail; extern float realtexdetail; -extern float terraindetail; extern float volume; extern Objects objects; extern int detail; @@ -27,20 +47,11 @@ extern GLubyte bloodText[512*512*3]; extern GLubyte wolfbloodText[512*512*3]; extern bool ismotionblur; extern bool trilinear; -#ifdef WIN32 -extern HDC hDC; -#else -extern AGLContext gaglContext; -#endif extern bool osx; extern bool musictoggle; -extern Weapons weapons; -extern Person player[maxplayers]; -extern int numplayers; extern int environment; extern bool ambientsound; extern float multiplier; -extern int newnetmessages; extern int netdatanew; extern float mapinfo; extern bool stillloading; @@ -50,7 +61,6 @@ extern long dirID; extern int mainmenu; extern int oldmainmenu; extern bool visibleloading; -extern int loadscreencolor; extern float flashamount,flashr,flashg,flashb; extern int flashdelay; extern int whichjointstartarray[26]; @@ -58,19 +68,8 @@ extern int whichjointendarray[26]; extern int difficulty; extern float tintr,tintg,tintb; extern float slomospeed; -extern char mapname[256]; extern bool gamestarted; -extern int numaccounts; -extern int accountactive; -extern int accountdifficulty[10]; -extern int accountprogress[10]; -extern float accountpoints[10]; -extern float accounthighscore[10][50]; -extern float accountfasttime[10][50]; -extern bool accountunlocked[10][60]; -extern char accountname[10][256]; - extern int numdialogues; extern int numdialogueboxes[20]; extern int dialoguetype[20]; @@ -94,10 +93,11 @@ extern float accountcampaigntime[10]; extern int accountcampaignchoicesmade[10]; extern int accountcampaignchoices[10][5000]; -extern FSOUND_STREAM * strm[10]; +void LOG(const std::string &fmt, ...) +{ + // !!! FIXME: write me. +} -extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); -extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused); Game::TextureList Game::textures; @@ -108,59 +108,11 @@ void Game::Dispose() LOGFUNC; if(endgame==2){ - accountcampaignchoicesmade[accountactive]=0; - accountcampaignscore[accountactive]=0; - accountcampaigntime[accountactive]=0; + accountactive->endGame(); endgame=0; } - - sprintf (mapname, ":Data:Users"); - - FILE *tfile; - tfile=fopen( mapname, "wb" ); - if (tfile) - { - fpackf(tfile, "Bi", numaccounts); - fpackf(tfile, "Bi", accountactive); - if(numaccounts>0) - { - for(i=0;i0) - { - for(j=0;j<(int)strlen(accountname[i]);j++) - { - fpackf(tfile, "Bb", accountname[i][j]); - } - } - } - } - - fclose(tfile); - } + Account::saveFile(":Data:Users", accountactive); TexIter it = textures.begin(); for (; it != textures.end(); ++it) @@ -172,230 +124,28 @@ void Game::Dispose() LOG("Shutting down sound system..."); - FSOUND_StopSound(FSOUND_ALL); + OPENAL_StopSound(OPENAL_ALL); -#define streamcount 20 -#define samplecount 100 - - for (i=0; i < samplecount; ++i) - { - FSOUND_Sample_Free(samp[i]); - } +// this is causing problems on Linux, but we'll force an _exit() a little +// later in the shutdown process. --ryan. +#if !PLATFORM_LINUX - for (i=0; i < streamcount; ++i) + for (i=0; i < sounds_count; ++i) { - FSOUND_Stream_Close(strm[i]); + OPENAL_Sample_Free(samp[i]); } - FSOUND_Close(); + OPENAL_Close(); if (texture.data) { free(texture.data); } texture.data = 0; +#endif } -//void Game::LoadSounds(); -void Game::LoadSounds() -{ - LOGFUNC; - - LOG(std::string("Loading sounds...")); - - FSOUND_3D_SetDopplerFactor(0); - - FSOUND_SetSFXMasterVolume((int)(volume*255)); - - samp[footstepsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow1.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - - samp[footstepsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepsnow2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - - samp[footstepsound3] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone1.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - - samp[footstepsound4] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:footstepstone2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); - - samp[landsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[landsound], 4.0f, 1000.0f); - - samp[jumpsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:jump.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[jumpsound], 4.0f, 1000.0f); - - samp[hawksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:hawk.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[hawksound], 40.0f, 10000.0f); - - samp[whooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:whoosh.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[whooshsound], 4.0f, 1000.0f); - FSOUND_Sample_SetMode(samp[whooshsound], FSOUND_LOOP_NORMAL); - - samp[landsound1] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land1.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[landsound1], 4.0f, 1000.0f); - - - - samp[landsound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:land2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[landsound2], 4.0f, 1000.0f); - - samp[breaksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:broken.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[breaksound], 8.0f, 2000.0f); - - samp[lowwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Lowwhoosh.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[lowwhooshsound], 8.0f, 2000.0f); - - samp[midwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:midwhoosh.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[midwhooshsound], 8.0f, 2000.0f); - - samp[highwhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:highwhoosh.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[highwhooshsound], 8.0f, 2000.0f); - - samp[movewhooshsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:movewhoosh.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[movewhooshsound], 8.0f, 2000.0f); - - samp[heavyimpactsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:heavyimpact.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[heavyimpactsound], 8.0f, 2000.0f); - - samp[whooshhitsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Whooshhit.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[whooshhitsound], 8.0f, 2000.0f); - - samp[thudsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:thud.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[thudsound], 8.0f, 2000.0f); - - samp[alarmsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:alarm.ogg", FSOUND_2D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[alarmsound], 8.0f, 2000.0f); - - samp[breaksound2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:break.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[breaksound2], 8.0f, 2000.0f); - - samp[knifedrawsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifedraw.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[knifedrawsound], 8.0f, 2000.0f); - - samp[knifesheathesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifesheathe.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[knifesheathesound], 8.0f, 2000.0f); - - samp[fleshstabsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Fleshstab.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[fleshstabsound], 8.0f, 2000.0f); - - samp[fleshstabremovesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Fleshstabremove.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[fleshstabremovesound], 8.0f, 2000.0f); - - samp[knifeswishsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifeswish.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[knifeswishsound], 8.0f, 2000.0f); - - samp[knifeslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:knifeslice.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[knifeslicesound], 8.0f, 2000.0f); - - samp[swordslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:swordslice.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[swordslicesound], 8.0f, 2000.0f); - - samp[skidsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:skid.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[skidsound], 8.0f, 2000.0f); - - samp[snowskidsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snowskid.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[snowskidsound], 8.0f, 2000.0f); - - samp[bushrustle] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bushrustle.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[bushrustle], 4.0f, 1000.0f); - - samp[clank1sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank1.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[clank1sound], 8.0f, 2000.0f); - - samp[clank2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[clank2sound], 8.0f, 2000.0f); - - samp[clank3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank3.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[clank3sound], 8.0f, 2000.0f); - - samp[clank4sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clank4.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[clank4sound], 8.0f, 2000.0f); - - samp[consolesuccesssound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:consolesuccess.ogg", FSOUND_2D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[consolesuccesssound], 4.0f, 1000.0f); - - samp[consolefailsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:consolefail.ogg", FSOUND_2D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[consolefailsound], 4.0f, 1000.0f); - - samp[metalhitsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:MetalHit.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[metalhitsound], 8.0f, 2000.0f); - - samp[clawslicesound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:clawslice.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[clawslicesound], 8.0f, 2000.0f); - - samp[splattersound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:splatter.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[splattersound], 8.0f, 2000.0f); - - samp[growlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Growl.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[growlsound], 1000.0f, 2000.0f); - - samp[growl2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:Growl2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[growl2sound], 1000.0f, 2000.0f); - - samp[barksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[barksound], 1000.0f, 2000.0f); - - samp[bark2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[bark2sound], 1000.0f, 2000.0f); - - samp[bark3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:bark3.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[bark3sound], 1000.0f, 2000.0f); - - samp[snarlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snarl.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[snarlsound], 1000.0f, 2000.0f); - - - samp[snarl2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:snarl2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[snarl2sound], 1000.0f, 2000.0f); - - samp[barkgrowlsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:barkgrowl.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[barkgrowlsound], 1000.0f, 2000.0f); - - samp[rabbitattacksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitattacksound], 1000.0f, 2000.0f); - - samp[rabbitattack2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack2sound], 1000.0f, 2000.0f); - - samp[rabbitattack3sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack3.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack3sound], 1000.0f, 2000.0f); - - samp[rabbitattack4sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitattack4.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitattack4sound], 1000.0f, 2000.0f); - - samp[rabbitpainsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitpainsound], 1000.0f, 2000.0f); - - samp[rabbitpain1sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitpain1sound], 1000.0f, 2000.0f); - - /*samp[rabbitpain2sound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitpain2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitpain2sound], 1000.0f, 2000.0f); - */ - samp[rabbitchitter] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitchitter.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitchitter], 1000.0f, 2000.0f); - - samp[rabbitchitter2] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:rabbitchitter2.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[rabbitchitter2], 1000.0f, 2000.0f); - - samp[swordstaffsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:swordstaff.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[swordstaffsound], 8.0f, 2000.0f); - - samp[staffbodysound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffbody.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[staffbodysound], 8.0f, 2000.0f); - - samp[staffheadsound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffhead.ogg", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[staffheadsound], 8.0f, 2000.0f); - - samp[staffbreaksound] = FSOUND_Sample_Load(FSOUND_FREE, ":Data:Sounds:staffbreak.wav", FSOUND_HW3D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;} - FSOUND_Sample_SetMinMaxDistance(samp[staffbreaksound], 8.0f, 2000.0f); - - - -} - -void Game::LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalpha) +void Game::LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha) { GLuint type; @@ -403,10 +153,13 @@ void Game::LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalp LOG(std::string("Loading texture...") + fileName); + // Fix filename so that is os appropreate + char * fixedFN = ConvertFileName(fileName); + unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); + CopyCStringToPascal(fixedFN, fileNamep); //Load Image - upload_image( fileNamep ,hasalpha); + upload_image( fileNamep ,hasalpha); // std::string fname(fileName); // std::transform(fname.begin(), fname.end(), tolower); @@ -424,7 +177,8 @@ void Game::LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalp glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - if(!*textureid)glGenTextures( 1, textureid ); + if(!*textureid) + glGenTextures( 1, textureid ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); glBindTexture( GL_TEXTURE_2D, *textureid); @@ -432,23 +186,12 @@ void Game::LoadTexture(char *fileName, GLuint *textureid,int mipmap, bool hasalp if(trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); if(!trilinear)if(mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); if(!mipmap)glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - - //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture.sizeX, texture.sizeY, 0, - // GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data); - - //gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, texture.data ); - + gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data ); - -// textures.insert(std::make_pair(fname, *textureid)); } -// else -// { -// *textureid = it->second; -// } } -void Game::LoadTextureSave(char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) +void Game::LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize) { GLuint type; int i; @@ -460,10 +203,10 @@ void Game::LoadTextureSave(char *fileName, GLuint *textureid,int mipmap,GLubyte //Load Image unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); + CopyCStringToPascal(ConvertFileName(fileName), fileNamep); //Load Image - upload_image( fileNamep ,0); - //LoadTGA( fileName ); + upload_image( fileNamep ,0); + //LoadTGA( fileName ); // std::string fname(fileName); // std::transform(fname.begin(), fname.end(), tolower); @@ -512,7 +255,7 @@ void Game::LoadTextureSave(char *fileName, GLuint *textureid,int mipmap,GLubyte // } } -void Game::LoadSave(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) +void Game::LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) { int i; int bytesPerPixel; @@ -524,13 +267,17 @@ void Game::LoadSave(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array //Load Image float temptexdetail=texdetail; texdetail=1; - //upload_image( fileName ); - //LoadTGA( fileName ); + //upload_image( fileName ); + //LoadTGA( fileName ); + + // Converting file to something os specific + char * fixedFN = ConvertFileName(fileName); + //Load Image unsigned char fileNamep[256]; - CopyCStringToPascal(fileName,fileNamep); + CopyCStringToPascal(fixedFN, fileNamep); //Load Image - upload_image( fileNamep ,0); + upload_image( fileNamep ,0); texdetail=temptexdetail; //Is it valid? @@ -547,21 +294,21 @@ void Game::LoadSave(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array } } -bool Game::AddClothes(char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) +bool Game::AddClothes(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize) { int i; int bytesPerPixel; LOGFUNC; - //upload_image( fileName ); - //LoadTGA( fileName ); + //upload_image( fileName ); + //LoadTGA( fileName ); //Load Image unsigned char fileNamep[256]; CopyCStringToPascal(fileName,fileNamep); //Load Image bool opened; - opened=upload_image( fileNamep ,1); + opened=upload_image( fileNamep ,1); float alphanum; //Is it valid? @@ -611,11 +358,11 @@ GLvoid Game::ReSizeGLScene(float fov, float pnear) gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,pnear,viewdistance); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); } -void Game::LoadingScreen() +void Game::LoadingScreen() { static float loadprogress,minprogress,maxprogress; static AbsoluteTime time = {0,0}; @@ -670,25 +417,17 @@ void Game::LoadingScreen() glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - //glColor4f(1,1,1,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(.1-loadprogress/100,0+loadprogress/100+.3); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3); glVertex3f(1, 1, 0.0f); glTexCoord2f(.1-loadprogress/100,1+loadprogress/100+.3); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glEnable(GL_BLEND); @@ -696,13 +435,13 @@ void Game::LoadingScreen() //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(.4+loadprogress/100,0+loadprogress/100); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(.4+loadprogress/100,0+loadprogress/100); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(.4+loadprogress/100,1+loadprogress/100); glVertex3f(1, 1, 0.0f); glTexCoord2f(.4+loadprogress/100,1+loadprogress/100); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); @@ -734,24 +473,17 @@ void Game::LoadingScreen() glEnable(GL_BLEND); //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(0+.5,0+.5); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1+.5,0+.5); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1+.5,1+.5); glVertex3f(1, 1, 0.0f); glTexCoord2f(0+.5,1+.5); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); @@ -786,13 +518,13 @@ void Game::LoadingScreen() //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(0+.2,0+.8); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1+.2,0+.8); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1+.2,1+.8); glVertex3f(1, 1, 0.0f); glTexCoord2f(0+.2,1+.8); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); @@ -836,10 +568,10 @@ void Game::LoadingScreen() glEnable(GL_BLEND); glColor4f(flashr,flashg,flashb,flashamount); glBegin(GL_QUADS); - glVertex3f(0, 0, 0.0f); - glVertex3f(256, 0, 0.0f); + glVertex3f(0, 0, 0.0f); + glVertex3f(256, 0, 0.0f); glVertex3f(256, 256, 0.0f); - glVertex3f(0, 256, 0.0f); + glVertex3f(0, 256, 0.0f); glEnd(); glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPopMatrix(); // Restore The Old Projection Matrix @@ -849,19 +581,13 @@ void Game::LoadingScreen() glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDepthMask(1); - } - -#ifdef WIN32 - SwapBuffers( hDC); -#else - aglSwapBuffers(gaglContext); -#endif + } - loadscreencolor=0; + swap_gl_buffers(); } } -void Game::FadeLoadingScreen(float howmuch) +void Game::FadeLoadingScreen(float howmuch) { static float loadprogress,minprogress,maxprogress; @@ -898,24 +624,17 @@ void Game::FadeLoadingScreen(float howmuch) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,0,0,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); glTexCoord2f(0,0); - glVertex3f(-1, -1, 0.0f); + glVertex3f(-1, -1, 0.0f); glTexCoord2f(1,0); - glVertex3f(1, -1, 0.0f); + glVertex3f(1, -1, 0.0f); glTexCoord2f(1,1); glVertex3f(1, 1, 0.0f); glTexCoord2f(0,1); - glVertex3f(-1, 1, 0.0f); + glVertex3f(-1, 1, 0.0f); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D); @@ -935,19 +654,13 @@ void Game::FadeLoadingScreen(float howmuch) glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1); text.glPrint(280,125,string,1,1,640,480); */ -#ifdef WIN32 - SwapBuffers( hDC); -#else - aglSwapBuffers(gaglContext); // send swap command -#endif - - loadscreencolor=0; + swap_gl_buffers(); } -void Game::InitGame() +void Game::InitGame() { -#ifndef WIN32 +#if PLATFORM_MACOSX ProcessSerialNumber PSN; ProcessInfoRec pinfo; FSSpec pspec; @@ -975,114 +688,7 @@ void Game::InitGame() numchallengelevels=14; - registered=0; - - /*char tempstring[256]; - sprintf (tempstring, "%s", registrationname); - long num1; - long num2; - long num3; - long num4; - long long longnum; - longnum = MD5_string ( tempstring); - //longnum = 1111111111111111; - num1 = longnum/100000000; - num2 = longnum%100000000; - sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000); - */ - - FILE *tfile; - tfile=fopen( ":Data:Sounds:flame.ogg", "rb" ); - if(tfile) - { - long num1; - long num2; - long long longnum; - long long longnuma; - long num1a; - long num2a; - - int numchars; - funpackf(tfile, "Bb", ®istered); - if(registered) - { - funpackf(tfile, "Bi", &numchars); - if(numchars>0) - { - for(j=0;j2)registered=1; - else registered=0; - } - } - fclose(tfile); - } - else registered=0; - - accountactive=-1; - - sprintf (mapname, ":Data:Users"); - tfile=fopen( mapname, "rb" ); - if(tfile) - { - funpackf(tfile, "Bi", &numaccounts); - funpackf(tfile, "Bi", &accountactive); - if(numaccounts>0) - { - for(i=0;i= 10) - { - accountcampaignchoices[i][j] = 0; - } - } - funpackf(tfile, "Bf", &accountpoints[i]); - for(j=0;j<50;j++) - { - funpackf(tfile, "Bf", &accounthighscore[i][j]); - funpackf(tfile, "Bf", &accountfasttime[i][j]); - } - for(j=0;j<60;j++) - { - funpackf(tfile, "Bb", &accountunlocked[i][j]); - } - int temp; - funpackf(tfile, "Bi", &temp); - if(temp>0) - { - for(j=0;j