rnd-20030118-5-src
authorHolger Schemel <info@artsoft.org>
Sat, 18 Jan 2003 13:22:38 +0000 (14:22 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:39:49 +0000 (10:39 +0200)
src/conftime.h
src/game.c
src/init.c
src/main.c
src/main.h

index 15646aa60361214d789ca45e78837a1c138445d6..23667f1d2d95f7d6c6fc18e3819db904551ed098 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-01-18 13:34]"
+#define COMPILE_DATE_STRING "[2003-01-18 14:21]"
index 46a99c8f56a446056158b673ba5fdd1825448696..10e6e2fb5b5471726474958a28037e25ff5b7b2e 100644 (file)
@@ -115,41 +115,8 @@ static void HandleGameButtons(struct GadgetInfo *);
 
 static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS];
 
-#define IS_ANIMATED(g) (graphic_info[g].anim_frames > 1)
-
-
-/* ------------------------------------------------------------------------- */
-/* sound definitions                                                         */
-/* ------------------------------------------------------------------------- */
-
-static struct
-{
-  char *text;
-  int value;
-  boolean is_loop;
-} sound_action_properties[] =
-{
-  /* insert _all_ loop sound actions here */
-  { ".waiting",                ACTION_WAITING,         TRUE },
-  { ".moving",         ACTION_MOVING,          TRUE }, /* continuos moving */
-  { ".active",         ACTION_ACTIVE,          TRUE },
-  { ".growing",                ACTION_GROWING,         TRUE },
-  { ".attacking",      ACTION_ATTACKING,       TRUE },
-
-  /* other (non-loop) sound actions are optional */
-  { ".stepping",       ACTION_MOVING,          FALSE }, /* discrete moving */
-  { ".digging",                ACTION_DIGGING,         FALSE },
-  { ".collecting",     ACTION_COLLECTING,      FALSE },
-  { ".passing",                ACTION_PASSING,         FALSE },
-  { ".impact",         ACTION_IMPACT,          FALSE },
-  { ".pushing",                ACTION_PUSHING,         FALSE },
-  { ".activating",     ACTION_ACTIVATING,      FALSE },
-  { NULL,              0,                      0 },
-};
-static int element_action_sound[MAX_NUM_ELEMENTS][NUM_ACTIONS];
-static boolean is_loop_sound[NUM_SOUND_FILES];
-
-#define IS_LOOP_SOUND(x)       (is_loop_sound[x])
+#define IS_ANIMATED(g)         (graphic_info[g].anim_frames > 1)
+#define IS_LOOP_SOUND(s)       (sound_info[s].loop)
 
 
 /* -------------------------------------------------------------------------
@@ -565,97 +532,6 @@ void DrawGameDoorValues()
 }
 
 
-/*
-  =============================================================================
-  InitGameSound()
-  -----------------------------------------------------------------------------
-  initialize sound effect lookup table for element actions
-  =============================================================================
-*/
-
-void InitGameSound()
-{
-  int sound_effect_properties[NUM_SOUND_FILES];
-  int i, j;
-
-#if 0
-  debug_print_timestamp(0, NULL);
-#endif
-
-  /* initialize sound effect for all elements to "no sound" */
-  for (i=0; i<MAX_NUM_ELEMENTS; i++)
-    for (j=0; j<NUM_ACTIONS; j++)
-      element_action_sound[i][j] = -1;
-
-  for (i=0; i<NUM_SOUND_FILES; i++)
-  {
-    int len_effect_text = strlen(sound_files[i].token);
-
-    sound_effect_properties[i] = ACTION_OTHER;
-    is_loop_sound[i] = FALSE;
-
-    /* determine all loop sounds and identify certain sound classes */
-
-    for (j=0; sound_action_properties[j].text; j++)
-    {
-      int len_action_text = strlen(sound_action_properties[j].text);
-
-      if (len_action_text < len_effect_text &&
-         strcmp(&sound_files[i].token[len_effect_text - len_action_text],
-                sound_action_properties[j].text) == 0)
-      {
-       sound_effect_properties[i] = sound_action_properties[j].value;
-
-       if (sound_action_properties[j].is_loop)
-         is_loop_sound[i] = TRUE;
-      }
-    }
-
-    /* associate elements and some selected sound actions */
-
-    for (j=0; j<MAX_NUM_ELEMENTS; j++)
-    {
-      if (element_info[j].sound_class_name)
-      {
-       int len_class_text = strlen(element_info[j].sound_class_name);
-
-       if (len_class_text + 1 < len_effect_text &&
-           strncmp(sound_files[i].token,
-                   element_info[j].sound_class_name, len_class_text) == 0 &&
-           sound_files[i].token[len_class_text] == '.')
-       {
-         int sound_action_value = sound_effect_properties[i];
-
-         element_action_sound[j][sound_action_value] = i;
-       }
-      }
-    }
-  }
-
-#if 0
-  debug_print_timestamp(0, "InitGameEngine");
-#endif
-
-#if 0
-  /* TEST ONLY */
-  {
-    int element = EL_SAND;
-    int sound_action = ACTION_DIGGING;
-    int j = 0;
-
-    while (sound_action_properties[j].text)
-    {
-      if (sound_action_properties[j].value == sound_action)
-       printf("element %d, sound action '%s'  == %d\n",
-              element, sound_action_properties[j].text,
-              element_action_sound[element][sound_action]);
-      j++;
-    }
-  }
-#endif
-}
-
-
 /*
   =============================================================================
   InitGameEngine()
@@ -7087,9 +6963,9 @@ static void PlaySoundLevelAction(int x, int y, int sound_action)
 static void PlaySoundLevelElementAction(int x, int y, int element,
                                        int sound_action)
 {
-  int sound_effect = element_action_sound[element][sound_action];
+  int sound_effect = element_info[element].sound[sound_action];
 
-  if (sound_effect != -1)
+  if (sound_effect != SND_UNDEFINED)
     PlaySoundLevel(x, y, sound_effect);
 }
 
index b65b671974df1b807c771c082078272a5fa6415a..203d4093d6632e9182fae2af9042c8c2ff26e9ae 100644 (file)
@@ -982,10 +982,78 @@ static void InitGraphicInfo()
 
 static void InitSoundInfo()
 {
+  int sound_effect_properties[NUM_SOUND_FILES];
+  int i, j;
+
   sound_files = getCurrentSoundList();
 
-  /* initialize sound effect lookup table for element actions */
-  InitGameSound();
+  /* initialize sound effect for all elements to "no sound" */
+  for (i=0; i<MAX_NUM_ELEMENTS; i++)
+    for (j=0; j<NUM_ACTIONS; j++)
+      element_info[i].sound[j] = SND_UNDEFINED;
+
+  for (i=0; i<NUM_SOUND_FILES; i++)
+  {
+    int len_effect_text = strlen(sound_files[i].token);
+
+    sound_effect_properties[i] = ACTION_OTHER;
+    sound_info[i].loop = FALSE;
+
+    /* determine all loop sounds and identify certain sound classes */
+
+    for (j=0; sound_action_properties[j].text; j++)
+    {
+      int len_action_text = strlen(sound_action_properties[j].text);
+
+      if (len_action_text < len_effect_text &&
+         strcmp(&sound_files[i].token[len_effect_text - len_action_text],
+                sound_action_properties[j].text) == 0)
+      {
+       sound_effect_properties[i] = sound_action_properties[j].value;
+
+       if (sound_action_properties[j].is_loop)
+         sound_info[i].loop = TRUE;
+      }
+    }
+
+    /* associate elements and some selected sound actions */
+
+    for (j=0; j<MAX_NUM_ELEMENTS; j++)
+    {
+      if (element_info[j].sound_class_name)
+      {
+       int len_class_text = strlen(element_info[j].sound_class_name);
+
+       if (len_class_text + 1 < len_effect_text &&
+           strncmp(sound_files[i].token,
+                   element_info[j].sound_class_name, len_class_text) == 0 &&
+           sound_files[i].token[len_class_text] == '.')
+       {
+         int sound_action_value = sound_effect_properties[i];
+
+         element_info[j].sound[sound_action_value] = i;
+       }
+      }
+    }
+  }
+
+#if 0
+  /* TEST ONLY */
+  {
+    int element = EL_SAND;
+    int sound_action = ACTION_DIGGING;
+    int j = 0;
+
+    while (sound_action_properties[j].text)
+    {
+      if (sound_action_properties[j].value == sound_action)
+       printf("element %d, sound action '%s'  == %d\n",
+              element, sound_action_properties[j].text,
+              element_info_[element].sound[sound_action]);
+      j++;
+    }
+  }
+#endif
 }
 
 void InitElementProperties()
index 5a47e63390dec7f2a52e87435e546772346507f3..730b667fe0f00cd9bb6c35a59b9c73c72067f118 100644 (file)
@@ -2758,7 +2758,34 @@ struct ElementInfo element_info[MAX_NUM_ELEMENTS] =
   }
 };
 
-struct NewGraphicInfo graphic_info[NUM_IMAGE_FILES];
+
+/* ------------------------------------------------------------------------- */
+/* sound definitions                                                         */
+/* ------------------------------------------------------------------------- */
+
+struct SoundActionProperties sound_action_properties[] =
+{
+  /* insert _all_ loop sound actions here */
+  { ".waiting",                ACTION_WAITING,         TRUE },
+  { ".moving",         ACTION_MOVING,          TRUE }, /* continuos moving */
+  { ".active",         ACTION_ACTIVE,          TRUE },
+  { ".growing",                ACTION_GROWING,         TRUE },
+  { ".attacking",      ACTION_ATTACKING,       TRUE },
+
+  /* other (non-loop) sound actions are optional */
+  { ".stepping",       ACTION_MOVING,          FALSE }, /* discrete moving */
+  { ".digging",                ACTION_DIGGING,         FALSE },
+  { ".collecting",     ACTION_COLLECTING,      FALSE },
+  { ".passing",                ACTION_PASSING,         FALSE },
+  { ".impact",         ACTION_IMPACT,          FALSE },
+  { ".pushing",                ACTION_PUSHING,         FALSE },
+  { ".activating",     ACTION_ACTIVATING,      FALSE },
+  { NULL,              0,                      0 },
+};
+
+
+struct GraphicInfo graphic_info[NUM_IMAGE_FILES];
+struct SoundInfo sound_info[NUM_SOUND_FILES];
 
 
 /* ========================================================================= */
index 24fed063142bb606fc7c04342512ac7d1171e6fa..efbb577463a668522c5fed921d37a33244e78c44 100644 (file)
@@ -36,6 +36,8 @@
 #define IMG_CHAR_START         IMG_CHAR_SPACE
 #define IMG_CUSTOM_START       IMG_CUSTOM_1
 
+#define SND_UNDEFINED          (-1)
+
 #define WIN_XSIZE      672
 #define WIN_YSIZE      560
 
@@ -1030,20 +1032,14 @@ struct ElementInfo
   char *sound_class_name;      /* classification for custom sound effects */
   char *editor_description;    /* short description for level editor */
 
-                               /* default graphics for several actions */
-  int graphic[NUM_ACTIONS];
-
+  int graphic[NUM_ACTIONS];    /* default graphics for several actions */
                                /* special graphics for left/right/up/down */
   int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS];
-};
 
-struct GraphicInfo
-{
-  Bitmap *bitmap;
-  int src_x, src_y;
+  int sound[NUM_ACTIONS];      /* default sounds for several actions */
 };
 
-struct NewGraphicInfo
+struct GraphicInfo
 {
   Bitmap *bitmap;
   int src_x, src_y;            /* derived from (tile sized) .xpos/.ypos */
@@ -1060,6 +1056,19 @@ struct NewGraphicInfo
 #endif
 };
 
+struct SoundInfo
+{
+  boolean loop;
+};
+
+struct SoundActionProperties
+{
+  char *text;
+  int value;
+  boolean is_loop;
+};
+
+
 #if 0
 extern GC              tile_clip_gc;
 extern Bitmap         *pix[];
@@ -1127,7 +1136,9 @@ extern struct TapeInfo            tape;
 extern struct GameInfo         game;
 extern struct GlobalInfo       global;
 extern struct ElementInfo      element_info[];
-extern struct NewGraphicInfo   graphic_info[];
+extern struct GraphicInfo      graphic_info[];
+extern struct SoundInfo                sound_info[];
+extern struct SoundActionProperties sound_action_properties[];
 extern struct ConfigInfo       image_config[], sound_config[];
 extern struct ConfigInfo       image_config_suffix[], sound_config_suffix[];
 extern struct FileInfo        *image_files, *sound_files;