rnd-20020425-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 24 Apr 2002 22:15:10 +0000 (00:15 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:37:04 +0000 (10:37 +0200)
src/init.c
src/libgame/setup.c
src/libgame/sound.c
src/libgame/x11.c
src/timestamp.h

index 0a52cc63033eaf3e247f49abfdc2f7ee60e7d4b8..ef6586f701c4f6465f59766db271a4c1a7fb0555 100644 (file)
@@ -45,6 +45,7 @@ static void InitPlayerInfo(void);
 static void InitLevelInfo(void);
 static void InitArtworkInfo(void);
 static void InitNetworkServer(void);
+static void InitSoundServer(void);
 static void InitSound(void);
 static void InitGfx(void);
 static void InitGfxBackground(void);
@@ -74,7 +75,7 @@ void OpenAll(void)
   InitArtworkInfo();           /* needed before loading gfx, sound & music */
 
   InitCounter();
-  InitSound();
+  InitSoundServer();
   InitJoysticks();
   InitRND(NEW_RANDOMIZE);
 
@@ -89,6 +90,7 @@ void OpenAll(void)
 
   InitLevelInfo();
   InitGadgets();               /* needs to know number of level series */
+  InitSound();                 /* needs to know current level directory */
 
   InitGfxBackground();
   InitToons();
@@ -155,62 +157,51 @@ static void ReloadCustomSounds()
 {
   int i;
 
-  printf("DEBUG: reloading sounds '%s' [%d] ...\n",
-        artwork.sounds_set_current, audio.soundserver_pid);
-
 #if 1
+  printf("DEBUG: reloading sounds '%s' ...\n", artwork.sounds_set_current);
+#endif
+
   FreeAllSounds();
 
   InitSoundList(NUM_SOUNDS);
   for(i=0; i<NUM_SOUNDS; i++)
     LoadSoundToList(sound_name[i], i);
-#endif
 }
 
 static void ReloadCustomMusic()
 {
-  printf("DEBUG: reloading music '%s' [%d] ...\n",
-        artwork.music_set_current, audio.soundserver_pid);
-
 #if 1
+  printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
+#endif
+
   FreeAllMusic();
 
   LoadCustomMusic();
-#endif
 }
 
-void InitSound()
+static void InitSoundServer()
 {
-  int i;
-
   OpenAudio();
   SetAudioReloadFunctions(ReloadCustomSounds, ReloadCustomMusic);
 
-#if 1
-  InitSoundList(NUM_SOUNDS);
-
-  for(i=0; i<NUM_SOUNDS; i++)
-    LoadSoundToList(sound_name[i], i);
-
-  LoadCustomMusic();
-#endif
-
   StartSoundserver();
+}
 
-#if 0
+static void InitSound()
+{
   InitReloadSounds(artwork.snd_current->name);
   InitReloadMusic(artwork.mus_current->name);
-#endif
 }
 
-void InitTileClipmasks()
+static void InitTileClipmasks()
 {
 #if defined(TARGET_X11)
-  GC copy_clipmask_gc;
   XGCValues clip_gc_values;
   unsigned long clip_gc_valuemask;
 
 #if defined(TARGET_X11_NATIVE)
+  GC copy_clipmask_gc;
+
   static struct
   {
     int start;
@@ -1629,9 +1620,9 @@ void CloseAllAndExit(int exit_value)
   int i;
 
   StopSounds();
-  CloseAudio();
   FreeAllSounds();
   FreeAllMusic();
+  CloseAudio();                /* called after freeing sounds (needed for SDL) */
 
   FreeTileClipmasks();
   for(i=0; i<NUM_BITMAPS; i++)
index fefe33dfbd0dfa074578769eb7d865371ce4b9ee..f7d30d6431a9d28f66fe6954feddcb4b44d28577 100644 (file)
@@ -1649,12 +1649,12 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first,
 
   if (node_parent == NULL)             /* top level group */
   {
-    artwork_new->basepath = base_directory;
-    artwork_new->fullpath = artwork_new->filename;
+    artwork_new->basepath = getStringCopy(base_directory);
+    artwork_new->fullpath = getStringCopy(artwork_new->filename);
   }
   else                                 /* sub level group */
   {
-    artwork_new->basepath = node_parent->basepath;
+    artwork_new->basepath = getStringCopy(node_parent->basepath);
     artwork_new->fullpath = getPath2(node_parent->fullpath, directory_name);
   }
 
index 57e61c7093f37c939a99e29f614c78dad6de4f59..3b938200021f40a52504a665a164b3d65b66b99b 100644 (file)
@@ -66,7 +66,7 @@ static boolean InitAudioDevice_NetBSD();
 static boolean InitAudioDevice_HPUX();
 #elif defined(PLATFORM_MSDOS)
 static void SoundServer_InsertNewSound(struct SoundControl);
-static void SoundServer_StopSound(int);
+static void SoundServer_StopSound(struct SoundControl);
 static void SoundServer_StopAllSounds();
 #endif
 
@@ -233,27 +233,16 @@ void SoundServer(void)
       TreeInfo *ti = *ti_ptr;
       unsigned long str_size1, str_size2, str_size3;
 
-      printf("B\n");
-
       if (leveldir_current == NULL)
        leveldir_current = checked_calloc(sizeof(TreeInfo));
-      printf("B.1\n");
       if (ti == NULL)
        ti = *ti_ptr = checked_calloc(sizeof(TreeInfo));
-      printf("B.2\n");
       if (leveldir_current->fullpath != NULL)
        free(leveldir_current->fullpath);
-      printf("B.3 ['%s']\n", ti->basepath);
-#if 0
       if (ti->basepath != NULL)
        free(ti->basepath);
-#endif
-      printf("B.4\n");
       if (ti->fullpath != NULL)
        free(ti->fullpath);
-      printf("B.5\n");
-
-      printf("C\n");
 
       if (read(audio.soundserver_pipe[0], set_name,
               snd_ctrl.data_len) != snd_ctrl.data_len ||
@@ -269,8 +258,6 @@ void SoundServer(void)
               sizeof(unsigned long)) != sizeof(unsigned long))
        Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
 
-      printf("D\n");
-
       leveldir_current->fullpath = checked_calloc(str_size1);
       ti->basepath = checked_calloc(str_size2);
       ti->fullpath = checked_calloc(str_size3);
@@ -283,14 +270,10 @@ void SoundServer(void)
               str_size3) != str_size3)
        Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
 
-      printf("E\n");
-
       InitPlaylist();
 
       close(audio.device_fd);
 
-      printf("X\n");
-
       if (snd_ctrl.reload_sounds)
       {
        artwork.sounds_set_current = set_name;
@@ -718,7 +701,7 @@ static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
       playing_sounds++;
 
 #if defined(PLATFORM_MSDOS)
-      playlist[i].voice = allocate_voice(playlist[i].data_ptr);
+      playlist[i].voice = allocate_voice((SAMPLE *)playlist[i].data_ptr);
 
       if (snd_ctrl.loop)
         voice_set_playmode(playlist[i].voice, PLAYMODE_LOOP);
@@ -1153,8 +1136,6 @@ SoundInfo *LoadCustomSound(char *basename)
     return FALSE;
   }
 
-  printf("-> '%s'\n", filename);
-
   return Load_WAV(filename);
 }
 
@@ -1223,9 +1204,9 @@ void LoadCustomMusic(void)
     char *filename = getPath2(music_directory, basename);
     MusicInfo *mus_info = NULL;
 
-    if (FileIsSound(filename))
+    if (FileIsSound(basename))
       mus_info = Load_WAV(filename);
-    else if (FileIsMusic(filename))
+    else if (FileIsMusic(basename))
       mus_info = Load_MOD(filename);
 
     free(filename);
@@ -1252,6 +1233,8 @@ void PlayMusic(int nr)
 
 #if defined(TARGET_SDL)
 
+  nr = nr % num_music;
+
   if (Music[nr]->type == MUS_TYPE_MOD)
   {
     Mix_PlayMusic(Music[nr]->data_ptr, -1);
@@ -1448,32 +1431,34 @@ void StopSoundExt(int nr, int method)
 
 static void InitReloadSoundsOrMusic(char *set_name, int type)
 {
+#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL)
   struct SoundControl snd_ctrl = emptySoundControl;
   TreeInfo *ti =
     (type == SND_RELOAD_SOUNDS ? artwork.snd_current : artwork.mus_current);
   unsigned long str_size1 = strlen(leveldir_current->fullpath) + 1;
   unsigned long str_size2 = strlen(ti->basepath) + 1;
   unsigned long str_size3 = strlen(ti->fullpath) + 1;
+#endif
 
   if (!audio.sound_available)
     return;
 
-  if (leveldir_current == NULL)
-    Error(ERR_EXIT, "leveldir_current == NULL");
-
-  snd_ctrl.reload_sounds = (type == SND_RELOAD_SOUNDS);
-  snd_ctrl.reload_music  = (type == SND_RELOAD_MUSIC);
-  snd_ctrl.data_len = strlen(set_name) + 1;
-
 #if defined(TARGET_SDL) || defined(TARGET_ALLEGRO)
   if (type == SND_RELOAD_SOUNDS)
-    audio.audio.func_reload_sounds();
+    audio.func_reload_sounds();
   else
-    audio.audio.func_reload_music();
+    audio.func_reload_music();
 #elif defined(PLATFORM_UNIX)
   if (audio.soundserver_pid == 0)      /* we are child process */
     return;
 
+  if (leveldir_current == NULL)                /* should never happen */
+    Error(ERR_EXIT, "leveldir_current == NULL");
+
+  snd_ctrl.reload_sounds = (type == SND_RELOAD_SOUNDS);
+  snd_ctrl.reload_music  = (type == SND_RELOAD_MUSIC);
+  snd_ctrl.data_len = strlen(set_name) + 1;
+
   if (write(audio.soundserver_pipe[1], &snd_ctrl,
            sizeof(snd_ctrl)) < 0 ||
       write(audio.soundserver_pipe[1], set_name,
@@ -1499,9 +1484,6 @@ static void InitReloadSoundsOrMusic(char *set_name, int type)
     audio.sound_available = audio.sound_enabled = FALSE;
     return;
   }
-
-  printf("A\n");
-
 #endif
 }
 
@@ -1567,7 +1549,9 @@ void FreeAllSounds()
     FreeSound(Sound[i]);
 
   free(Sound);
+
   Sound = NULL;
+  num_sounds = 0;
 }
 
 void FreeAllMusic()
@@ -1581,7 +1565,9 @@ void FreeAllMusic()
     FreeMusic(Music[i]);
 
   free(Music);
+
   Music = NULL;
+  num_music = 0;
 }
 
 /* THE STUFF ABOVE IS ONLY USED BY THE MAIN PROCESS                          */
index cfa0ce78857abc3ee46afc846e42bd63b201cf45..394350a6f17f33768a1efbc056662178c002e7f1 100644 (file)
@@ -234,12 +234,19 @@ static DrawWindow *X11InitWindow()
 
 static void SetImageDimensions(Bitmap *bitmap)
 {
+#if defined(TARGET_ALLEGRO)
+  BITMAP *allegro_bitmap = (BITMAP *)(bitmap->drawable);
+
+  bitmap->width  = allegro_bitmap->w;
+  bitmap->height = allegro_bitmap->h;
+#else
   Window root;
   int x, y;
   unsigned int border_width, depth;
 
   XGetGeometry(display, bitmap->drawable, &root, &x, &y,
               &bitmap->width, &bitmap->height, &border_width, &depth);
+#endif
 }
 
 Bitmap *X11LoadImage(char *filename)
index 9f01cb6d5d2466103e282f131810d6d631547947..ccf2e49c5cd59117d222bdc1e1ade13c1e8ebdc3 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-04-24 03:21]"
+#define COMPILE_DATE_STRING "[2002-04-25 00:14]"