Fix to disable sound if not local.
authorlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Wed, 27 May 2009 19:13:59 +0000 (19:13 +0000)
committerlimb <limb@bc5cbbab-a4ec-0310-bb52-ff3d296db539>
Wed, 27 May 2009 19:13:59 +0000 (19:13 +0000)
git-svn-id: svn+ssh://svn/var/repos/curfender@801 bc5cbbab-a4ec-0310-bb52-ff3d296db539

main.cpp

index 27d6d2b..c68fd55 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -44,6 +44,7 @@ int pause_game = 0;
 int shieldsleft = 400;
 int tripshot = 0;
 int laser = 0;
+int sound = 1;
 struct game_object {
   int number; //object number
   int active; //object active, 1 or 0
@@ -1213,25 +1214,32 @@ int main(){
     //halfdelay(1);
   };
 
-  Mix_Chunk *shotsound = NULL;
-  int shotchannel = -1;
-  Mix_Chunk *boomsound = NULL;
-  int boomchannel = -1;
+    Mix_Chunk *shotsound = NULL;
+    int shotchannel = -1;
+    Mix_Chunk *boomsound = NULL;
+    int boomchannel = -1;
 
-  int audio_rate = 22050;
-  Uint16 audio_format = AUDIO_S16; 
-  int audio_channels = 4;
-  int audio_buffers = 4096;
+    int audio_rate = 22050;
+    Uint16 audio_format = AUDIO_S16; 
+    int audio_channels = 4;
+    int audio_buffers = 4096;
 
-  SDL_Init(SDL_INIT_AUDIO);
+    char *env_tty;
+    env_tty = getenv("SSH_TTY");
+    if(env_tty == NULL){
 
-  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
-    printf("Unable to open audio!\n");
-    exit(1);
-  }
+      SDL_Init(SDL_INIT_AUDIO);
+
+      if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
+        printf("Unable to open audio!\n");
+        exit(1);
+      }
   
-  shotsound = Mix_LoadWAV("shot.ogg");
-  boomsound = Mix_LoadWAV("boom.ogg");
+      shotsound = Mix_LoadWAV("shot.ogg");
+      boomsound = Mix_LoadWAV("boom.ogg");
+    } else {
+      sound = 0;
+  }
   
   while(loopvar == 0){
     
@@ -1480,10 +1488,12 @@ int main(){
     if(quit=='y'){
       printw("\nBye Bye!\n");
       loopvar=1;
-       Mix_FreeChunk(shotsound);
-       Mix_FreeChunk(boomsound);
-       Mix_CloseAudio();
-       SDL_Quit();
+       if(sound==1){
+         Mix_FreeChunk(shotsound);
+         Mix_FreeChunk(boomsound);
+         Mix_CloseAudio();
+         SDL_Quit();
+      };
     };
     halfdelay(1);
     };
@@ -1629,7 +1639,7 @@ int main(){
        laser--;
       } else {
         //shot sound
-        shotchannel = play_sound_effect(shotsound);
+        if(sound==1){shotchannel = play_sound_effect(shotsound);};
        //get next inactive bullet, give it player's direction, speed, height, location +speed in direction, active, set vtime=1.
        for(int bulletloop = 0; bulletloop<bulletmax; bulletloop++){ 
          if(bullets[bulletloop].active==0){ 
@@ -1738,7 +1748,7 @@ int main(){
            if(check_collision(bullets[bulletloop], landers[landerloop])==1){
              //kill lander and bullet
              determine_powerup(powerups, landers[landerloop], 800);
-             boomchannel = play_sound_effect(boomsound);           
+             if(sound==1){boomchannel = play_sound_effect(boomsound);};
              boom_object(boomstuff, landers[landerloop]);
              landers[landerloop] = object_out(landers[landerloop]);
              bullets[bulletloop].vtime = 100;