]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
Move stats vars and award computation to Awards.cpp
[lugaru.git] / Source / GameTick.cpp
index 0a6d464d221d1e551ce1cc7cfdb6617d8f506acf..466da3ed7f5cae785acc2b96faf596baf2dfa50b 100644 (file)
@@ -33,6 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Settings.h"
 #include "Input.h"
 #include "Animation.h"
+#include "Awards.h"
 
 using namespace std;
 
@@ -70,9 +71,6 @@ extern float blackout;
 extern bool cellophane;
 extern bool musictoggle;
 extern int difficulty;
-extern Weapons weapons;
-extern Person player[maxplayers];
-extern int numplayers;
 extern int bloodtoggle;
 extern bool invertmouse;
 extern float windvar;
@@ -143,7 +141,6 @@ extern bool reversaltrain;
 extern bool canattack;
 extern bool cananger;
 extern float damagedealt;
-extern float damagetaken;
 extern int maptype;
 extern int editoractive;
 extern int editorpathtype;
@@ -168,23 +165,6 @@ extern int hostile;
 extern bool stillloading;
 extern bool winfreeze;
 
-extern int numfalls;
-extern int numflipfail;
-extern int numseen;
-extern int numstaffattack;
-extern int numswordattack;
-extern int numknifeattack;
-extern int numunarmedattack;
-extern int numescaped;
-extern int numflipped;
-extern int numwallflipped;
-extern int numthrowkill;
-extern int numafterkill;
-extern int numreversals;
-extern int numattacks;
-extern int maxalarmed;
-extern int numresponded;
-
 extern int numdialogues;
 extern int numdialogueboxes[max_dialogues];
 extern int dialoguetype[max_dialogues];
@@ -241,7 +221,6 @@ static bool stripfx(const char *str, const char *pfx)
   return !strncasecmp(str, pfx, strlen(pfx));
 }
 
-extern OPENAL_STREAM * strm[20];
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
 
@@ -1388,7 +1367,7 @@ void      Game::Setenvironment(int which)
                windvector.z=3;
                if(ambientsound){
                        //PlaySoundEx( wind, samp[wind], NULL, true);
-                       PlayStreamEx(stream_wind, strm[stream_wind], 0, true);
+                       PlayStreamEx(stream_wind, samp[stream_wind], 0, true);
                        OPENAL_SetPaused(channels[stream_wind], false);
                        OPENAL_SetVolume(channels[stream_wind], 256);
                }
@@ -1398,18 +1377,10 @@ void    Game::Setenvironment(int which)
                LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0);
                LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0);
 
-               OPENAL_Sample_Free(samp[footstepsound]);
-               OPENAL_Sample_Free(samp[footstepsound2]);
-               OPENAL_Sample_Free(samp[footstepsound3]);
-               OPENAL_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
+               footstepsound = footstepsn1;
+               footstepsound2 = footstepsn2;
+               footstepsound3 = footstepst1;
+               footstepsound4 = footstepst2;
 
                LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0);
 
@@ -1447,23 +1418,15 @@ void    Game::Setenvironment(int which)
 
                if(ambientsound){
                        //PlaySoundEx( desertambient, samp[desertambient], NULL, true);
-                       PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true);
+                       PlayStreamEx( stream_desertambient, samp[stream_desertambient], NULL, true);
                        OPENAL_SetPaused(channels[stream_desertambient], false);
                        OPENAL_SetVolume(channels[stream_desertambient], 256);
                }
 
-               OPENAL_Sample_Free(samp[footstepsound]);
-               OPENAL_Sample_Free(samp[footstepsound2]);
-               OPENAL_Sample_Free(samp[footstepsound3]);
-               OPENAL_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
+               footstepsound = footstepsn1;
+               footstepsound2 = footstepsn2;
+               footstepsound3 = footstepsn1;
+               footstepsound4 = footstepsn2;
 
                LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0);
 
@@ -1498,23 +1461,15 @@ void    Game::Setenvironment(int which)
                LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0);
 
                if(ambientsound){
-                       PlayStreamEx( stream_wind, strm[stream_wind], NULL, true);
+                       PlayStreamEx( stream_wind, samp[stream_wind], NULL, true);
                        OPENAL_SetPaused(channels[stream_wind], false);
                        OPENAL_SetVolume(channels[stream_wind], 100);
                }
 
-               OPENAL_Sample_Free(samp[footstepsound]);
-               OPENAL_Sample_Free(samp[footstepsound2]);
-               OPENAL_Sample_Free(samp[footstepsound3]);
-               OPENAL_Sample_Free(samp[footstepsound4]);
-               samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0);
-               samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f);
-               OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f);
+               footstepsound = footstepgr1;
+               footstepsound2 = footstepgr2;
+               footstepsound3 = footstepst1;
+               footstepsound4 = footstepst2;
 
                LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0);
 
@@ -2295,7 +2250,7 @@ void      Game::Loadlevel(char *name){
                {
                        if(ambientsound)
                        {
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
                                OPENAL_SetPaused(channels[stream_wind], false);
                                OPENAL_SetVolume(channels[stream_wind], 256);
                        }
@@ -2307,7 +2262,7 @@ void      Game::Loadlevel(char *name){
                                //PlaySoundEx(desertambient,
                                //      samp[desertambient], NULL, true);
                                PlayStreamEx(stream_desertambient,
-                                       strm[stream_desertambient], NULL, true);
+                                       samp[stream_desertambient], NULL, true);
                                OPENAL_SetPaused(channels[stream_desertambient], false);
                                OPENAL_SetVolume(channels[stream_desertambient], 256);
                        }
@@ -2317,7 +2272,7 @@ void      Game::Loadlevel(char *name){
                        if(ambientsound)
                        {
                                //PlaySoundEx(wind, samp[wind], NULL, true);
-                               PlayStreamEx(stream_wind, strm[stream_wind], NULL, true);
+                               PlayStreamEx(stream_wind, samp[stream_wind], NULL, true);
                                OPENAL_SetPaused(channels[stream_wind], false);
                                OPENAL_SetVolume(channels[stream_wind], 100);
                        }
@@ -2415,7 +2370,7 @@ void      Game::Tick()
                                if(mainmenu&&musictoggle){
                                        if(mainmenu==1||mainmenu==2||mainmenu==100){
                                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
-                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                                OPENAL_SetPaused(channels[stream_music3], false);
                                                OPENAL_SetVolume(channels[stream_music3], 256);
                                                OPENAL_SetPaused(channels[music1], true);
@@ -2622,7 +2577,7 @@ void      Game::Tick()
                                }
 
                                if(musictoggle){
-                                       PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                       PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                        OPENAL_SetPaused(channels[stream_music3], false);
                                        OPENAL_SetVolume(channels[stream_music3], 256);
                                }
@@ -2792,7 +2747,7 @@ void      Game::Tick()
                                mainmenu=9;
                        }
                }
-               if(mainmenu==9){
+               else if(mainmenu==9){
                        if(Input::Button()&&!oldbutton&&selected<numchallengelevels&&selected>=0&&selected<=accountactive->getProgress()){
                                fireSound();
 
@@ -7691,7 +7646,7 @@ void      Game::Tick()
                                                                                OPENAL_StopSound(OPENAL_ALL);  // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
                                                                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
 
-                                                                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                                                                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                                                                OPENAL_SetPaused(channels[stream_music3], false);
                                                                                OPENAL_SetVolume(channels[stream_music3], 256);
 
@@ -7905,15 +7860,15 @@ void    Game::TickOnceAfter(){
 
                if(musictoggle){
                        if(musicvolume[0]>0&&oldmusicvolume[0]<=0){
-                               PlayStreamEx( music1, strm[music1], NULL, true);
+                               PlayStreamEx( music1, samp[music1], NULL, true);
                                OPENAL_SetPaused(channels[music1], false);
                        }
                        if(musicvolume[1]>0&&oldmusicvolume[1]<=0){
-                               PlayStreamEx( stream_music2, strm[stream_music2], NULL, true);
+                               PlayStreamEx( stream_music2, samp[stream_music2], NULL, true);
                                OPENAL_SetPaused(channels[stream_music2], false);
                        }
                        if(musicvolume[2]>0&&oldmusicvolume[2]<=0){
-                               PlayStreamEx( stream_music3, strm[stream_music3], NULL, true);
+                               PlayStreamEx( stream_music3, samp[stream_music3], NULL, true);
                                OPENAL_SetPaused(channels[stream_music3], false);
                        }
                        if(musicvolume[0]<=0&&oldmusicvolume[0]>0){