rnd-20020519-2-src
[rocksndiamonds.git] / src / init.c
index ef6586f701c4f6465f59766db271a4c1a7fb0555..8393c629d76d5c7adbb5540dbb9cd0942fd16ddd 100644 (file)
@@ -45,15 +45,23 @@ static void InitPlayerInfo(void);
 static void InitLevelInfo(void);
 static void InitArtworkInfo(void);
 static void InitNetworkServer(void);
-static void InitSoundServer(void);
+static void InitMixer(void);
 static void InitSound(void);
 static void InitGfx(void);
 static void InitGfxBackground(void);
 static void InitGadgets(void);
 static void InitElementProperties(void);
+static void Execute_Debug_Command(char *);
 
 void OpenAll(void)
 {
+  if (options.debug_command)
+  {
+    Execute_Debug_Command(options.debug_command);
+
+    exit(0);
+  }
+
   if (options.serveronly)
   {
 #if defined(PLATFORM_UNIX)
@@ -75,7 +83,7 @@ void OpenAll(void)
   InitArtworkInfo();           /* needed before loading gfx, sound & music */
 
   InitCounter();
-  InitSoundServer();
+  InitMixer();
   InitJoysticks();
   InitRND(NEW_RANDOMIZE);
 
@@ -153,38 +161,12 @@ void InitNetworkServer()
 #endif
 }
 
-static void ReloadCustomSounds()
-{
-  int i;
-
-#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);
-}
-
-static void ReloadCustomMusic()
-{
-#if 1
-  printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
-#endif
-
-  FreeAllMusic();
-
-  LoadCustomMusic();
-}
-
-static void InitSoundServer()
+static void InitMixer()
 {
   OpenAudio();
-  SetAudioReloadFunctions(ReloadCustomSounds, ReloadCustomMusic);
+  InitSoundList(sound_effects, NUM_SOUND_EFFECTS);
 
-  StartSoundserver();
+  StartMixer();
 }
 
 static void InitSound()
@@ -344,7 +326,7 @@ void FreeTileClipmasks()
 
   for(i=0; i<NUM_BITMAPS; i++)
   {
-    if (pix[i]->stored_clip_gc)
+    if (pix[i] != NULL && pix[i]->stored_clip_gc)
     {
       XFreeGC(display, pix[i]->stored_clip_gc);
       pix[i]->stored_clip_gc = None;
@@ -379,11 +361,8 @@ void InitGfx()
 
   DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
   DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
-#if defined(PLATFORM_MSDOS)
-  DrawInitText(PROGRAM_DOS_PORT_STRING, 210, FC_BLUE);
-  rest(200);
-#endif
-  DrawInitText("Loading graphics:",120,FC_GREEN);
+
+  DrawInitText("Loading graphics:", 120, FC_GREEN);
 
   for(i=0; i<NUM_PICTURES; i++)
   {
@@ -1615,6 +1594,23 @@ void InitElementProperties()
     Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
 }
 
+void Execute_Debug_Command(char *command)
+{
+  if (strcmp(command, "create soundinfo.conf") == 0)
+  {
+    int i;
+
+    printf("# You can configure additional/alternative sound effects here\n");
+    printf("# (The sounds below are default and therefore commented out.)\n");
+    printf("\n");
+
+    for (i=0; i<NUM_SOUND_EFFECTS; i++)
+      printf("# %s\n",
+            getFormattedSetupEntry(sound_effects[i].text,
+                                   sound_effects[i].default_filename));
+  }
+}
+
 void CloseAllAndExit(int exit_value)
 {
   int i;