stratagus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Stratagus-CVS] stratagus/src/sound ccl_sound.c unitsound.c wav.c


From: Jimmy Salmon
Subject: [Stratagus-CVS] stratagus/src/sound ccl_sound.c unitsound.c wav.c
Date: Wed, 01 Oct 2003 20:11:35 -0400

CVSROOT:        /cvsroot/stratagus
Module name:    stratagus
Branch:         
Changes by:     Jimmy Salmon <address@hidden>   03/10/01 20:11:35

Modified files:
        src/sound      : ccl_sound.c unitsound.c wav.c 

Log message:
        Cleanup

Patches:
Index: stratagus/src/sound/ccl_sound.c
diff -u stratagus/src/sound/ccl_sound.c:1.51 
stratagus/src/sound/ccl_sound.c:1.52
--- stratagus/src/sound/ccl_sound.c:1.51        Thu Sep 25 23:33:04 2003
+++ stratagus/src/sound/ccl_sound.c     Wed Oct  1 20:11:34 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: ccl_sound.c,v 1.51 2003/09/26 03:33:04 jsalmon3 Exp $
+//     $Id: ccl_sound.c,v 1.52 2003/10/02 00:11:34 jsalmon3 Exp $
 
 //@{
 
@@ -76,6 +76,7 @@
 local SCM sound_id_ccl(SoundId id)
 {
     SCM sound_id;
+
     sound_id = CclMakeSmobObj(SiodSoundTag, id);
     return sound_id;
 }
@@ -91,8 +92,8 @@
     SoundId id;
     char* sound_name;
 
-    sound_name=gh_scm2newstr(name,NULL);
-    id=SoundIdForName(sound_name);
+    sound_name = gh_scm2newstr(name, NULL);
+    id = SoundIdForName(sound_name);
     free(sound_name);
 
     return sound_id_ccl(id);
@@ -156,8 +157,8 @@
        c_name = gh_scm2newstr(name, NULL);
        DebugLevel3("Making sound `%s'\n" _C_ c_name);
        nb = gh_length(file);
-       c_files = (char **)malloc(sizeof(char *) * nb);
-       for (i = 0; i < nb; i++) {
+       c_files = (char**)malloc(sizeof(char*) * nb);
+       for (i = 0; i < nb; ++i) {
            a_file = gh_car(file);
            if (!gh_string_p(name)) {
                fprintf(stderr, "string expected\n");
@@ -170,7 +171,7 @@
        }
        //FIXME: check size before casting
        id = MakeSound(c_name, c_files, (unsigned char)nb);
-       for (i = 0; i < nb; i++) {
+       for (i = 0; i < nb; ++i) {
            free(c_files[i]);
        }
        free(c_name);
@@ -238,8 +239,8 @@
 local SCM CclPlaySound(SCM sound) {
     SoundId id;
 
-    id=CclGetSoundId(sound);
-    PlayGameSound(id,MaxSampleVolume);
+    id = CclGetSoundId(sound);
+    PlayGameSound(id, MaxSampleVolume);
     return SCM_UNSPECIFIED;
 }
 
@@ -289,94 +290,94 @@
     char* str;
     int i;
 
-    while( !gh_null_p(list) ) {
+    while (!gh_null_p(list)) {
 
-       value=gh_car(list);
-       list=gh_cdr(list);
-       if( !gh_symbol_p(value) ) {
+       value = gh_car(list);
+       list = gh_cdr(list);
+       if (!gh_symbol_p(value)) {
            PrintFunction();
-           fprintf(stdout,"Symbol expected\n");
+           fprintf(stdout, "Symbol expected\n");
            return list;
        }
        // prepare for next iteration
 
        // let's handle now the different cases
-       if( gh_eq_p(value,gh_symbol2scm("click")) ) {
-           data=gh_car(list);
-           list=gh_cdr(list);
-           if( !CCL_SOUNDP(data) ) {
-               fprintf(stderr,"Sound id expected\n");
+       if (gh_eq_p(value, gh_symbol2scm("click"))) {
+           data = gh_car(list);
+           list = gh_cdr(list);
+           if (!CCL_SOUNDP(data)) {
+               fprintf(stderr, "Sound id expected\n");
                return list;
            }
-           GameSounds.Click.Sound=CCL_SOUND_ID(data);
-       } else if( gh_eq_p(value,gh_symbol2scm("placement-error")) ) {
-           data=gh_car(list);
-           list=gh_cdr(list);
-           if( !CCL_SOUNDP(data) ) {
-               fprintf(stderr,"Sound id expected\n");
+           GameSounds.Click.Sound = CCL_SOUND_ID(data);
+       } else if (gh_eq_p(value, gh_symbol2scm("placement-error"))) {
+           data = gh_car(list);
+           list = gh_cdr(list);
+           if (!CCL_SOUNDP(data)) {
+               fprintf(stderr, "Sound id expected\n");
                return list;
            }
-           GameSounds.PlacementError.Sound=CCL_SOUND_ID(data);
-       } else if( gh_eq_p(value,gh_symbol2scm("placement-success")) ) {
-           data=gh_car(list);
-           list=gh_cdr(list);
-           if( !CCL_SOUNDP(data) ) {
-               fprintf(stderr,"Sound id expected\n");
+           GameSounds.PlacementError.Sound = CCL_SOUND_ID(data);
+       } else if (gh_eq_p(value, gh_symbol2scm("placement-success"))) {
+           data = gh_car(list);
+           list = gh_cdr(list);
+           if (!CCL_SOUNDP(data)) {
+               fprintf(stderr, "Sound id expected\n");
                return list;
            }
-           GameSounds.PlacementSuccess.Sound=CCL_SOUND_ID(data);
-       } else if( gh_eq_p(value,gh_symbol2scm("work-complete")) ) {
-           sublist=gh_car(list);
-           list=gh_cdr(list);
-           str=gh_scm2newstr(gh_car(sublist),NULL);
-           for( i=0; i<PlayerRaces.Count; ++i ) {
-               if( !strcmp(PlayerRaces.Name[i],str) ) {
+           GameSounds.PlacementSuccess.Sound = CCL_SOUND_ID(data);
+       } else if (gh_eq_p(value,gh_symbol2scm("work-complete"))) {
+           sublist = gh_car(list);
+           list = gh_cdr(list);
+           str = gh_scm2newstr(gh_car(sublist), NULL);
+           for (i = 0; i < PlayerRaces.Count; ++i) {
+               if (!strcmp(PlayerRaces.Name[i], str)) {
                    break;
                }
            }
            free(str);
-           if( i==PlayerRaces.Count ) {
-               fprintf(stderr,"Unknown race: %s\n",str);
+           if (i == PlayerRaces.Count) {
+               fprintf(stderr, "Unknown race: %s\n", str);
                ExitFatal(1);
            }
-           sublist=gh_cdr(sublist);
-           data=gh_car(sublist);
-           if( !CCL_SOUNDP(data) ) {
-               fprintf(stderr,"Sound id expected\n");
+           sublist = gh_cdr(sublist);
+           data = gh_car(sublist);
+           if (!CCL_SOUNDP(data)) {
+               fprintf(stderr, "Sound id expected\n");
                ExitFatal(1);
            }
-           GameSounds.WorkComplete[i].Sound=CCL_SOUND_ID(data);
-       } else if( gh_eq_p(value,gh_symbol2scm("repair")) ) {
-           data=gh_car(list);
-           list=gh_cdr(list);
-           if( !CCL_SOUNDP(data) ) {
-               GameSounds.Repair.Sound=(void*)-1;
+           GameSounds.WorkComplete[i].Sound = CCL_SOUND_ID(data);
+       } else if (gh_eq_p(value,gh_symbol2scm("repair"))) {
+           data = gh_car(list);
+           list = gh_cdr(list);
+           if (!CCL_SOUNDP(data)) {
+               GameSounds.Repair.Sound = (void*)-1;
            } else {
-               GameSounds.Repair.Sound=CCL_SOUND_ID(data);
+               GameSounds.Repair.Sound = CCL_SOUND_ID(data);
            }
-       } else if( gh_eq_p(value,gh_symbol2scm("rescue")) ) {
-           sublist=gh_car(list);
-           list=gh_cdr(list);
-           str=gh_scm2newstr(gh_car(sublist),NULL);
-           for( i=0; i<PlayerRaces.Count; ++i ) {
-               if( !strcmp(PlayerRaces.Name[i],str) ) {
+       } else if (gh_eq_p(value,gh_symbol2scm("rescue"))) {
+           sublist = gh_car(list);
+           list = gh_cdr(list);
+           str = gh_scm2newstr(gh_car(sublist), NULL);
+           for (i = 0; i < PlayerRaces.Count; ++i) {
+               if (!strcmp(PlayerRaces.Name[i], str)) {
                    break;
                }
            }
            free(str);
-           if( i==PlayerRaces.Count ) {
-               fprintf(stderr,"Unknown race: %s\n",str);
+           if (i == PlayerRaces.Count) {
+               fprintf(stderr, "Unknown race: %s\n", str);
                ExitFatal(1);
            }
-           sublist=gh_cdr(sublist);
-           data=gh_car(sublist);
-           if( !CCL_SOUNDP(data) ) {
-               fprintf(stderr,"Sound id expected\n");
+           sublist = gh_cdr(sublist);
+           data = gh_car(sublist);
+           if (!CCL_SOUNDP(data)) {
+               fprintf(stderr, "Sound id expected\n");
                ExitFatal(1);
            }
-           GameSounds.Rescue[i].Sound=CCL_SOUND_ID(data);
+           GameSounds.Rescue[i].Sound = CCL_SOUND_ID(data);
        } else {
-           errl("Unsupported tag",value);
+           errl("Unsupported tag", value);
            return list;
        }
     }
@@ -415,17 +416,17 @@
 #ifdef USE_CDAUDIO
     CDModes cdmode;
 
-    if( gh_eq_p(mode,gh_symbol2scm("all")) ) {
-       cdmode=CDModeAll;
-    } else if( gh_eq_p(mode,gh_symbol2scm("random")) ) {
-       cdmode=CDModeRandom;
-    } else if( gh_eq_p(mode,gh_symbol2scm("defined")) ) {
-       cdmode=CDModeDefined;
-    } else if ( gh_eq_p(mode,gh_symbol2scm("off")) ) {
-       cdmode=CDModeOff;
+    if (gh_eq_p(mode, gh_symbol2scm("all"))) {
+       cdmode = CDModeAll;
+    } else if (gh_eq_p(mode, gh_symbol2scm("random"))) {
+       cdmode = CDModeRandom;
+    } else if (gh_eq_p(mode, gh_symbol2scm("defined"))) {
+       cdmode = CDModeDefined;
+    } else if (gh_eq_p(mode, gh_symbol2scm("off"))) {
+       cdmode = CDModeOff;
     } else {
-       cdmode=CDModeOff;
-       errl("Unsupported tag",mode);
+       cdmode = CDModeOff;
+       errl("Unsupported tag", mode);
     }
 
     PlayCDRom(cdmode);
@@ -440,102 +441,102 @@
 {
     SCM value;
     SCM sublist;
-    PlaySection *p;
+    PlaySection* p;
     int i;
 
     ++NumPlaySections;
-    PlaySections=realloc(PlaySections,NumPlaySections*sizeof(PlaySection));
-    p=PlaySections+NumPlaySections-1;
-    memset(p,0,sizeof(PlaySection));
-
-    while( !gh_null_p(list) ) {
-       value=gh_car(list);
-       list=gh_cdr(list);
-       if( gh_eq_p(value,gh_symbol2scm("race")) ) {
-           value=gh_car(list);
-           list=gh_cdr(list);
-           p->Race=gh_scm2newstr(value,NULL);
-       } else if( gh_eq_p(value,gh_symbol2scm("type")) ) {
-           value=gh_car(list);
-           list=gh_cdr(list);
-           if( gh_eq_p(value, gh_symbol2scm("game")) ) {
-               p->Type=PlaySectionGame;
-           } else if( gh_eq_p(value,gh_symbol2scm("briefing")) ) {
-               p->Type=PlaySectionBriefing;
-           } else if( gh_eq_p(value,gh_symbol2scm("stats-victory")) ) {
-               p->Type=PlaySectionStatsVictory;
-           } else if( gh_eq_p(value,gh_symbol2scm("stats-defeat")) ) {
-               p->Type=PlaySectionStatsDefeat;
-           } else if( gh_eq_p(value,gh_symbol2scm("main-menu")) ) {
-               p->Type=PlaySectionMainMenu;
+    PlaySections = realloc(PlaySections, NumPlaySections * 
sizeof(PlaySection));
+    p = PlaySections + NumPlaySections - 1;
+    memset(p, 0, sizeof(PlaySection));
+
+    while (!gh_null_p(list)) {
+       value = gh_car(list);
+       list = gh_cdr(list);
+       if (gh_eq_p(value, gh_symbol2scm("race"))) {
+           value = gh_car(list);
+           list = gh_cdr(list);
+           p->Race = gh_scm2newstr(value, NULL);
+       } else if (gh_eq_p(value, gh_symbol2scm("type"))) {
+           value = gh_car(list);
+           list = gh_cdr(list);
+           if (gh_eq_p(value, gh_symbol2scm("game"))) {
+               p->Type = PlaySectionGame;
+           } else if (gh_eq_p(value, gh_symbol2scm("briefing"))) {
+               p->Type = PlaySectionBriefing;
+           } else if (gh_eq_p(value, gh_symbol2scm("stats-victory"))) {
+               p->Type = PlaySectionStatsVictory;
+           } else if (gh_eq_p(value, gh_symbol2scm("stats-defeat"))) {
+               p->Type = PlaySectionStatsDefeat;
+           } else if (gh_eq_p(value, gh_symbol2scm("main-menu"))) {
+               p->Type = PlaySectionMainMenu;
            } else {
-               errl("Unsupported tag",value);
+               errl("Unsupported tag", value);
            }
-       } else if( gh_eq_p(value,gh_symbol2scm("cd")) ) {
-           sublist=gh_car(list);
-           list=gh_cdr(list);
-           while( !gh_null_p(sublist) ) {
-               value=gh_car(sublist);
-               sublist=gh_cdr(sublist);
-               if( gh_eq_p(value,gh_symbol2scm("order")) ) {
-                   value=gh_car(sublist);
-                   sublist=gh_cdr(sublist);
-                   if( gh_eq_p(value,gh_symbol2scm("all")) ) {
-                       p->CDOrder=PlaySectionOrderAll;
-                   } else if( gh_eq_p(value,gh_symbol2scm("random")) ) {
-                       p->CDOrder=PlaySectionOrderRandom;
+       } else if (gh_eq_p(value, gh_symbol2scm("cd"))) {
+           sublist = gh_car(list);
+           list = gh_cdr(list);
+           while (!gh_null_p(sublist)) {
+               value = gh_car(sublist);
+               sublist = gh_cdr(sublist);
+               if (gh_eq_p(value, gh_symbol2scm("order"))) {
+                   value = gh_car(sublist);
+                   sublist = gh_cdr(sublist);
+                   if (gh_eq_p(value, gh_symbol2scm("all"))) {
+                       p->CDOrder = PlaySectionOrderAll;
+                   } else if (gh_eq_p(value, gh_symbol2scm("random"))) {
+                       p->CDOrder = PlaySectionOrderRandom;
                    } else {
-                       errl("Unsupported tag",value);
+                       errl("Unsupported tag", value);
                    }
-               } else if( gh_eq_p(value,gh_symbol2scm("tracks")) ) {
+               } else if (gh_eq_p(value, gh_symbol2scm("tracks"))) {
                    SCM temp;
 
-                   value=gh_car(sublist);
-                   sublist=gh_cdr(sublist);
-                   for( i=0; i<gh_vector_length(value); ++i ) {
-                       temp=gh_vector_ref(value,gh_int2scm(i));
-                       p->CDTracks|=(1<<gh_scm2int(temp));
+                   value = gh_car(sublist);
+                   sublist = gh_cdr(sublist);
+                   for (i = 0; i < gh_vector_length(value); ++i) {
+                       temp=gh_vector_ref(value, gh_int2scm(i));
+                       p->CDTracks |= (1 << gh_scm2int(temp));
                    }
                } else {
-                   errl("Unsupported tag",value);
+                   errl("Unsupported tag", value);
                }
            }
-       } else if( gh_eq_p(value,gh_symbol2scm("no-cd")) ) {
-           sublist=gh_car(list);
-           list=gh_cdr(list);
-           while( !gh_null_p(sublist) ) {
-               value=gh_car(sublist);
-               sublist=gh_cdr(sublist);
-               if( gh_eq_p(value,gh_symbol2scm("order")) ) {
-                   value=gh_car(sublist);
-                   sublist=gh_cdr(sublist);
-                   if( gh_eq_p(value,gh_symbol2scm("all")) ) {
-                       p->FileOrder=PlaySectionOrderAll;
-                   } else if( gh_eq_p(value,gh_symbol2scm("random")) ) {
-                       p->FileOrder=PlaySectionOrderRandom;
+       } else if (gh_eq_p(value, gh_symbol2scm("no-cd"))) {
+           sublist = gh_car(list);
+           list = gh_cdr(list);
+           while (!gh_null_p(sublist)) {
+               value = gh_car(sublist);
+               sublist = gh_cdr(sublist);
+               if (gh_eq_p(value, gh_symbol2scm("order"))) {
+                   value = gh_car(sublist);
+                   sublist = gh_cdr(sublist);
+                   if (gh_eq_p(value, gh_symbol2scm("all"))) {
+                       p->FileOrder = PlaySectionOrderAll;
+                   } else if (gh_eq_p(value, gh_symbol2scm("random"))) {
+                       p->FileOrder = PlaySectionOrderRandom;
                    } else {
-                       errl("Unsupported tag",value);
+                       errl("Unsupported tag", value);
                    }
-               } else if( gh_eq_p(value,gh_symbol2scm("files")) ) {
+               } else if (gh_eq_p(value, gh_symbol2scm("files"))) {
                    SCM sublist2;
 
-                   sublist2=gh_car(sublist);
-                   sublist=gh_cdr(sublist);
-                   i=0;
-                   while( !gh_null_p(sublist2) ) {
-                       value=gh_car(sublist2);
-                       sublist2=gh_cdr(sublist2);
+                   sublist2 = gh_car(sublist);
+                   sublist = gh_cdr(sublist);
+                   i = 0;
+                   while (!gh_null_p(sublist2)) {
+                       value = gh_car(sublist2);
+                       sublist2 = gh_cdr(sublist2);
                        ++i;
-                       p->Files=realloc(p->Files,(i+1)*sizeof(char*));
-                       p->Files[i-1]=gh_scm2newstr(value,NULL);
-                       p->Files[i]=NULL;
+                       p->Files = realloc(p->Files, (i + 1) * sizeof(char*));
+                       p->Files[i - 1] = gh_scm2newstr(value, NULL);
+                       p->Files[i] = NULL;
                    }
                } else {
-                   errl("Unsupported tag",value);
+                   errl("Unsupported tag", value);
                }
            }
        } else {
-           errl("Unsupported tag",value);
+           errl("Unsupported tag", value);
        }
     }
 
@@ -547,7 +548,7 @@
 */
 local SCM CclSoundOff(void)
 {
-    SoundOff=1;
+    SoundOff = 1;
     return SCM_UNSPECIFIED;
 }
 
@@ -562,7 +563,7 @@
     if (SoundFildes != -1) {
        return SCM_BOOL_T;
     }
-    SoundOff=0;
+    SoundOff = 0;
     return SCM_BOOL_F;
 }
 
@@ -572,7 +573,7 @@
 local SCM CclMusicOff(void)
 {
     StopMusic();
-    MusicOff=1;
+    MusicOff = 1;
     return SCM_UNSPECIFIED;
 }
 
@@ -584,7 +585,7 @@
 */
 local SCM CclMusicOn(void)
 {
-    MusicOff=0;
+    MusicOff = 0;
     return SCM_UNSPECIFIED;
 }
 
@@ -595,10 +596,11 @@
 */
 local SCM CclSetGlobalSoundRange(SCM distance) {
     int d;
+
     //FIXME check for errors
-    d=gh_scm2int(distance);
-    if (d>0) {
-       DistanceSilent=d;
+    d = gh_scm2int(distance);
+    if (d > 0) {
+       DistanceSilent = d;
     }
     return distance;
 }
@@ -609,7 +611,7 @@
 local SCM CclSoundThread(void)
 {
 #ifdef USE_THREAD
-    WithSoundThread=1;
+    WithSoundThread = 1;
 #endif
     return SCM_UNSPECIFIED;
 }
@@ -620,23 +622,23 @@
 **     @param sound    the sound id or name of the sound
 **     @param range    the new range for this sound
 */
-local SCM CclSetSoundRange(SCM sound,SCM range) {
+local SCM CclSetSoundRange(SCM sound, SCM range) {
     //FIXME check for errors
-    unsigned char TheRange;
+    unsigned char theRange;
     int tmp;
     SoundId id;
 
-    tmp=gh_scm2int(range);
-    if(tmp<0) {
-       TheRange=0;
-    } else if (tmp>255) {
-       TheRange=255;
+    tmp = gh_scm2int(range);
+    if (tmp < 0) {
+       theRange = 0;
+    } else if (tmp > 255) {
+       theRange = 255;
     } else {
-       TheRange=(unsigned char)tmp;
+       theRange = (unsigned char)tmp;
     }
     DebugLevel3("Range: %u (%d)\n" _C_ TheRange _C_ tmp);
-    id=CclGetSoundId(sound);
-    SetSoundRange(id,TheRange);
+    id = CclGetSoundId(sound);
+    SetSoundRange(id, theRange);
     return sound;
 }
 
@@ -649,7 +651,7 @@
 {
     char* music_name;
 
-    music_name=gh_scm2newstr(name,NULL);
+    music_name = gh_scm2newstr(name, NULL);
     PlayMusic(music_name);
     free(music_name);
 
@@ -665,7 +667,7 @@
 {
     char* filename;
 
-    filename=gh_scm2newstr(name,NULL);
+    filename = gh_scm2newstr(name, NULL);
     PlayFile(filename);
     free(filename);
 
@@ -689,30 +691,30 @@
 {
     SiodSoundTag = CclMakeSmobType("Sound");
 
-    gh_new_procedure1_0("set-sound-volume!",CclSetSoundVolume);
-    gh_new_procedure1_0("set-music-volume!",CclSetMusicVolume);
-    gh_new_procedure1_0("set-cd-mode!",CclSetCdMode);
-
-    gh_new_procedureN("define-play-sections",CclDefinePlaySections);
-
-    gh_new_procedure0_0("sound-off",CclSoundOff);
-    gh_new_procedure0_0("sound-on",CclSoundOn);
-    gh_new_procedure0_0("music-off",CclMusicOff);
-    gh_new_procedure0_0("music-on",CclMusicOn);
-    gh_new_procedure0_0("sound-thread",CclSoundThread);
-    gh_new_procedure1_0("set-global-sound-range!",CclSetGlobalSoundRange);
-    gh_new_procedureN("define-game-sounds",CclDefineGameSounds);
-    gh_new_procedure0_0("display-sounds",CclDisplaySounds);
-    gh_new_procedure2_0("map-sound",CclMapSound);
-    gh_new_procedure1_0("sound-for-name",CclSoundForName);
-    gh_new_procedure2_0("set-sound-range!",CclSetSoundRange);
-    gh_new_procedure2_0("make-sound",CclMakeSound);
-    gh_new_procedure3_0("make-sound-group",CclMakeSoundGroup);
-    gh_new_procedure1_0("play-sound",CclPlaySound);
-
-    gh_new_procedure1_0("play-music",CclPlayMusic);
-    gh_new_procedure1_0("play-file",CclPlayFile);
-    gh_new_procedure0_0("stop-music",CclStopMusic);
+    gh_new_procedure1_0("set-sound-volume!", CclSetSoundVolume);
+    gh_new_procedure1_0("set-music-volume!", CclSetMusicVolume);
+    gh_new_procedure1_0("set-cd-mode!", CclSetCdMode);
+
+    gh_new_procedureN("define-play-sections", CclDefinePlaySections);
+
+    gh_new_procedure0_0("sound-off", CclSoundOff);
+    gh_new_procedure0_0("sound-on", CclSoundOn);
+    gh_new_procedure0_0("music-off", CclMusicOff);
+    gh_new_procedure0_0("music-on", CclMusicOn);
+    gh_new_procedure0_0("sound-thread", CclSoundThread);
+    gh_new_procedure1_0("set-global-sound-range!", CclSetGlobalSoundRange);
+    gh_new_procedureN("define-game-sounds", CclDefineGameSounds);
+    gh_new_procedure0_0("display-sounds", CclDisplaySounds);
+    gh_new_procedure2_0("map-sound", CclMapSound);
+    gh_new_procedure1_0("sound-for-name", CclSoundForName);
+    gh_new_procedure2_0("set-sound-range!", CclSetSoundRange);
+    gh_new_procedure2_0("make-sound", CclMakeSound);
+    gh_new_procedure3_0("make-sound-group", CclMakeSoundGroup);
+    gh_new_procedure1_0("play-sound", CclPlaySound);
+
+    gh_new_procedure1_0("play-music", CclPlayMusic);
+    gh_new_procedure1_0("play-file", CclPlayFile);
+    gh_new_procedure0_0("stop-music", CclStopMusic);
 }
 
 #else  // }{ WITH_SOUND
@@ -803,7 +805,7 @@
 **     @param sound    the sound id or name of the sound
 **     @param range    the new range for this sound
 */
-local SCM CclSetSoundRange(SCM sound,SCM range __attribute__((unused)))
+local SCM CclSetSoundRange(SCM sound, SCM range __attribute__((unused)))
 {
     return sound;
 }
@@ -852,7 +854,7 @@
 **
 **     @return         the sound object
 */
-local SCM CclMapSound(SCM name __attribute__((unused)),SCM sound)
+local SCM CclMapSound(SCM name __attribute__((unused)), SCM sound)
 {
     return sound;
 }
@@ -882,23 +884,23 @@
 */
 global void SoundCclRegister(void)
 {
-    gh_new_procedure1_0("set-sound-volume!",CclSetSoundVolume);
-    gh_new_procedure1_0("set-music-volume!",CclSetMusicVolume);
-    gh_new_procedure1_0("set-cd-mode!",CclSetCdMode);
-    gh_new_procedure0_0("sound-off",CclSoundOff);
-    gh_new_procedure0_0("sound-on",CclSoundOn);
-    gh_new_procedure0_0("music-off",CclMusicOff);
-    gh_new_procedure0_0("music-on",CclMusicOn);
-    gh_new_procedure0_0("sound-thread",CclSoundThread);
-    gh_new_procedure1_0("set-global-sound-range!",CclSetGlobalSoundRange);
-    gh_new_procedureN("define-game-sounds",CclDefineGameSounds);
-    gh_new_procedure0_0("display-sounds",CclDisplaySounds);
-    gh_new_procedure2_0("map-sound",CclMapSound);
-    gh_new_procedure1_0("sound-for-name",CclSoundForName);
-    gh_new_procedure2_0("set-sound-range!",CclSetSoundRange);
+    gh_new_procedure1_0("set-sound-volume!", CclSetSoundVolume);
+    gh_new_procedure1_0("set-music-volume!", CclSetMusicVolume);
+    gh_new_procedure1_0("set-cd-mode!", CclSetCdMode);
+    gh_new_procedure0_0("sound-off", CclSoundOff);
+    gh_new_procedure0_0("sound-on", CclSoundOn);
+    gh_new_procedure0_0("music-off", CclMusicOff);
+    gh_new_procedure0_0("music-on", CclMusicOn);
+    gh_new_procedure0_0("sound-thread", CclSoundThread);
+    gh_new_procedure1_0("set-global-sound-range!", CclSetGlobalSoundRange);
+    gh_new_procedureN("define-game-sounds", CclDefineGameSounds);
+    gh_new_procedure0_0("display-sounds", CclDisplaySounds);
+    gh_new_procedure2_0("map-sound", CclMapSound);
+    gh_new_procedure1_0("sound-for-name", CclSoundForName);
+    gh_new_procedure2_0("set-sound-range!", CclSetSoundRange);
 
-    gh_new_procedure1_0("play-music",CclPlayMusic);
-    gh_new_procedure1_0("play-file",CclPlayFile);
+    gh_new_procedure1_0("play-music", CclPlayMusic);
+    gh_new_procedure1_0("play-file", CclPlayFile);
 }
 
 #endif // } !WITH_SOUND
Index: stratagus/src/sound/unitsound.c
diff -u stratagus/src/sound/unitsound.c:1.22 
stratagus/src/sound/unitsound.c:1.23
--- stratagus/src/sound/unitsound.c:1.22        Wed Jul 23 05:02:33 2003
+++ stratagus/src/sound/unitsound.c     Wed Oct  1 20:11:34 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: unitsound.c,v 1.22 2003/07/23 09:02:33 martinxyz Exp $
+//     $Id: unitsound.c,v 1.23 2003/10/02 00:11:34 jsalmon3 Exp $
 
 //@{
 
@@ -62,8 +62,8 @@
 **             sound identifier.
 */
 typedef struct _simple_sound_ {
-    char *Name;                                /// name of the sound
-    char *File;                                /// corresponding sound file
+    char* Name;                                /// name of the sound
+    char* File;                                /// corresponding sound file
 } SimpleSound;
 
 /**
@@ -139,8 +139,8 @@
 {
     int i;
 
-    for(i=0;i<MaxSimpleGroups;i++) {
-       if ( !group[i] ) {
+    for (i = 0;i < MaxSimpleGroups; ++i) {
+       if (!group[i]) {
            return i;
        }
     }
@@ -155,9 +155,9 @@
 {
     int i;
 
-    if( SimpleSounds ) {
-       for(i=0;SimpleSounds[i].Name;i++) {
-           MakeSound(SimpleSounds[i].Name,&(SimpleSounds[i].File),1);
+    if (SimpleSounds) {
+       for (i = 0; SimpleSounds[i].Name; ++i) {
+           MakeSound(SimpleSounds[i].Name, &(SimpleSounds[i].File), 1);
        }
     }
 }
@@ -170,18 +170,18 @@
 {
     int i;
 
-    if( SoundGroups ) {
-       for(i=0;SoundGroups[i].Name;i++) {
-           MakeSound(SoundGroups[i].Name,SoundGroups[i].Sounds,
-                   NbSoundsInGroup(SoundGroups[i].Sounds));
+    if (SoundGroups) {
+       for (i = 0; SoundGroups[i].Name; ++i) {
+           MakeSound(SoundGroups[i].Name, SoundGroups[i].Sounds,
+               NbSoundsInGroup(SoundGroups[i].Sounds));
        }
     }
-    if( SelectionGroups ) {
-       for(i=0;SelectionGroups[i].Name;i++) {
+    if (SelectionGroups) {
+       for (i = 0; SelectionGroups[i].Name; ++i) {
            //FIXME: might be more efficient
            MakeSoundGroup(SelectionGroups[i].Name,
-                   SoundIdForName(SelectionGroups[i].First),
-                   SoundIdForName(SelectionGroups[i].Second));
+               SoundIdForName(SelectionGroups[i].First),
+               SoundIdForName(SelectionGroups[i].Second));
        }
     }
 }
@@ -194,11 +194,11 @@
 {
     int i;
 
-    if( SoundRemaps ) {
-       for(i=0;SoundRemaps[i].NewName;i++) {
+    if (SoundRemaps) {
+       for (i = 0; SoundRemaps[i].NewName; ++i) {
            //FIXME: should be more efficient
            MapSound(SoundRemaps[i].NewName,
-                   SoundIdForName(SoundRemaps[i].BaseName));
+               SoundIdForName(SoundRemaps[i].BaseName));
        }
     }
 
@@ -206,33 +206,33 @@
     // Make some general sounds.
     //
     // FIXME: move to config CCL
-    MapSound("gold-mine-help",SoundIdForName("basic orc voices help 1"));
+    MapSound("gold-mine-help", SoundIdForName("basic orc voices help 1"));
 
     // critter mapping FIXME: must support more terrains.
 
-    switch( TheMap.Terrain ) {
-    case TilesetSummer:
-       MakeSoundGroup("critter-selected",
-                      SoundIdForName("sheep selected"),
-                      SoundIdForName("sheep annoyed"));
-       break;
-    case TilesetWinter:
-       MakeSoundGroup("critter-selected",
-                      SoundIdForName("seal selected"),
-                      SoundIdForName("seal annoyed"));
-       break;
-    case TilesetWasteland:
-       MakeSoundGroup("critter-selected",
-                      SoundIdForName("pig selected"),
-                      SoundIdForName("pig annoyed"));
-       break;
-    case TilesetSwamp:
-       MakeSoundGroup("critter-selected",
-                      SoundIdForName("warthog selected"),
-                      SoundIdForName("warthog annoyed"));
-       break;
-    default:
-       DebugLevel2("Unknown Terrain %d\n" _C_ TheMap.Terrain);
+    switch (TheMap.Terrain) {
+       case TilesetSummer:
+           MakeSoundGroup("critter-selected",
+              SoundIdForName("sheep selected"),
+              SoundIdForName("sheep annoyed"));
+           break;
+       case TilesetWinter:
+           MakeSoundGroup("critter-selected",
+              SoundIdForName("seal selected"),
+              SoundIdForName("seal annoyed"));
+           break;
+       case TilesetWasteland:
+           MakeSoundGroup("critter-selected",
+              SoundIdForName("pig selected"),
+              SoundIdForName("pig annoyed"));
+           break;
+       case TilesetSwamp:
+           MakeSoundGroup("critter-selected",
+              SoundIdForName("warthog selected"),
+              SoundIdForName("warthog annoyed"));
+           break;
+       default:
+           DebugLevel2("Unknown Terrain %d\n" _C_ TheMap.Terrain);
     }
 }
 
@@ -241,7 +241,7 @@
 */
 global void LoadUnitSounds(void)
 {
-    if( SoundFildes!=-1 ) {
+    if (SoundFildes != -1) {
        LoadSimpleSounds();
        LoadSoundGroups();
        RemapSounds();
@@ -258,49 +258,49 @@
     UnitType* type;
     int i;
 
-    if( SoundFildes!=-1 ) {
-       SetSoundRange(SoundIdForName("tree chopping"),32);
+    if (SoundFildes != -1) {
+       SetSoundRange(SoundIdForName("tree chopping"), 32);
 
        //
        //      Parse all units sounds.
        //
-       for( i=0; i<NumUnitTypes; ++i ) {
+       for (i = 0; i < NumUnitTypes; ++i) {
            type = UnitTypes[i];
-           if( type->Sound.Selected.Name ) {
-               type->Sound.Selected.Sound=
-                       SoundIdForName(type->Sound.Selected.Name);
+           if (type->Sound.Selected.Name) {
+               type->Sound.Selected.Sound =
+                   SoundIdForName(type->Sound.Selected.Name);
            }
-           if( type->Sound.Acknowledgement.Name ) {
-               type->Sound.Acknowledgement.Sound=
-                       SoundIdForName(type->Sound.Acknowledgement.Name);
+           if (type->Sound.Acknowledgement.Name) {
+               type->Sound.Acknowledgement.Sound =
+                   SoundIdForName(type->Sound.Acknowledgement.Name);
                /*
                // Acknowledge sounds have infinite range
                SetSoundRange(type->Sound.Acknowledgement.Sound,
-                       INFINITE_SOUND_RANGE);
+                   INFINITE_SOUND_RANGE);
                */
            }
-           if( type->Sound.Ready.Name ) {
-               type->Sound.Ready.Sound=
+           if (type->Sound.Ready.Name) {
+               type->Sound.Ready.Sound =
                    SoundIdForName(type->Sound.Ready.Name);
                // Ready sounds have infinite range
                SetSoundRange(type->Sound.Ready.Sound,
-                       INFINITE_SOUND_RANGE);
+                   INFINITE_SOUND_RANGE);
            }
            // FIXME: will be modified, attack sound be moved to missile/weapon
-           if( type->Weapon.Attack.Name ) {
-               type->Weapon.Attack.Sound=
-                       SoundIdForName(type->Weapon.Attack.Name);
+           if (type->Weapon.Attack.Name) {
+               type->Weapon.Attack.Sound =
+                   SoundIdForName(type->Weapon.Attack.Name);
            }
-           if( type->Sound.Help.Name ) {
-               type->Sound.Help.Sound=
-                       SoundIdForName(type->Sound.Help.Name);
+           if (type->Sound.Help.Name) {
+               type->Sound.Help.Sound =
+                   SoundIdForName(type->Sound.Help.Name);
                // Help sounds have infinite range
                SetSoundRange(type->Sound.Help.Sound,
-                       INFINITE_SOUND_RANGE);
+                   INFINITE_SOUND_RANGE);
            }
-           if( type->Sound.Dead.Name ) {
-               type->Sound.Dead.Sound=
-                       SoundIdForName(type->Sound.Dead.Name);
+           if (type->Sound.Dead.Name) {
+               type->Sound.Dead.Sound =
+                   SoundIdForName(type->Sound.Dead.Name);
            }
        }
     }
Index: stratagus/src/sound/wav.c
diff -u stratagus/src/sound/wav.c:1.32 stratagus/src/sound/wav.c:1.33
--- stratagus/src/sound/wav.c:1.32      Mon Sep 29 18:25:44 2003
+++ stratagus/src/sound/wav.c   Wed Oct  1 20:11:34 2003
@@ -26,7 +26,7 @@
 //      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //      02111-1307, USA.
 //
-//     $Id: wav.c,v 1.32 2003/09/29 22:25:44 jsalmon3 Exp $
+//     $Id: wav.c,v 1.33 2003/10/02 00:11:34 jsalmon3 Exp $
 
 //@{
 
@@ -66,7 +66,7 @@
 --     Functions
 ----------------------------------------------------------------------------*/
 
-local int WavReadStream(Sample *sample, void *buf, int len)
+local int WavReadStream(Sample* sample, void* buf, int len)
 {
     WavData* data;
     char sndbuf[WAV_BUFFER_SIZE];
@@ -78,7 +78,7 @@
     int samplesize;    // number of bytes per sample
     int divide;
 
-    data = (WavData*) sample->User;
+    data = (WavData*)sample->User;
 
     if (data->PointerInBuffer - sample->Data + len > sample->Length) {
        // need to read new data
@@ -92,7 +92,7 @@
        samplesize = sample->SampleSize / 8;
        brratio = 4 / (samplesize * sample->Channels);
        chanratio = 2 / sample->Channels;
-       divide = freqratio*brratio/chanratio;
+       divide = freqratio * brratio / chanratio;
 
        comp = CLread(data->WavFile, sndbuf, unc/divide);
 
@@ -111,11 +111,13 @@
     return len;
 }
 
-local void WavFreeStream(Sample *sample)
+local void WavFreeStream(Sample* sample)
 {
     WavData* data;
     
-    IfDebug( AllocatedSoundMemory -= sizeof(*sample) + WAV_BUFFER_SIZE);
+#ifdef DEBUG
+    AllocatedSoundMemory -= sizeof(*sample) + WAV_BUFFER_SIZE;
+#endif
        
     data = (WavData*)sample->User;
 
@@ -276,12 +278,14 @@
        CLread(f, &chunk, sizeof(chunk));
 
        DebugLevel0Fn(" %d\n" _C_ sizeof(*sample) + WAV_BUFFER_SIZE);
-       IfDebug( AllocatedSoundMemory += sizeof(*sample) + WAV_BUFFER_SIZE);
+#ifdef DEBUG
+       AllocatedSoundMemory += sizeof(*sample) + WAV_BUFFER_SIZE;
+#endif
     } else {
        for (;;) {
            if ((i = CLread(f, &chunk, sizeof(chunk))) != sizeof(chunk)) {
                // FIXME: have 1 byte remaining, wrong wav or wrong code?
-               // if( i ) printf("Rest: %d\n",i);
+               // if (i) { printf("Rest: %d\n", i); }
                break;
            }
            chunk.Magic = ConvertLE32(chunk.Magic);
@@ -316,7 +320,9 @@
 
        CLclose(f);
 
-       IfDebug( AllocatedSoundMemory += sample->Length; );
+#ifdef DEBUG
+       AllocatedSoundMemory += sample->Length;
+#endif
     }
 
     return sample;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]