rnd-20031210-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 10 Dec 2003 17:55:42 +0000 (18:55 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:45:02 +0000 (10:45 +0200)
src/conftime.h
src/game.c
src/game.h
src/main.h
src/screens.c
src/tools.c

index b31b5061f3c647c20dcb538343c85a630294a7f8..3533a548e6a355f7e74865778c5d23f6e171151f 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-12-08 02:04]"
+#define COMPILE_DATE_STRING "[2003-12-10 18:54]"
index 06ec792cab37203c118dfb216c6899e5507e519a..455599f51cf88d923d8d76a8fce8dc9b71f690eb 100644 (file)
@@ -1076,6 +1076,7 @@ void InitGame()
     player->post_delay_counter = 0;
 
     player->action_waiting = ACTION_DEFAULT;
+    player->last_action_waiting = ACTION_DEFAULT;
     player->special_action_bored = ACTION_DEFAULT;
     player->special_action_sleeping = ACTION_DEFAULT;
 
@@ -6175,125 +6176,49 @@ static boolean CheckElementChange(int x, int y, int element, int trigger_event)
   return CheckElementSideChange(x, y, element, CH_SIDE_ANY, trigger_event, -1);
 }
 
-int GetPlayerAction(struct PlayerInfo *player, int move_dir)
+static void PlayPlayerSound(struct PlayerInfo *player)
 {
   int jx = player->jx, jy = player->jy;
   int element = player->element_nr;
-  int action = (player->is_pushing    ? ACTION_PUSHING    :
-               player->is_digging    ? ACTION_DIGGING    :
-               player->is_collecting ? ACTION_COLLECTING :
-               player->is_moving     ? ACTION_MOVING     :
-               player->is_snapping   ? ACTION_SNAPPING   :
-               player->is_sleeping   ? ACTION_SLEEPING   :
-               player->is_bored      ? ACTION_BORING     :
-               player->is_waiting    ? ACTION_WAITING    : ACTION_DEFAULT);
+  int last_action = player->last_action_waiting;
+  int action = player->action_waiting;
 
-  if (player->is_sleeping)
+  if (player->is_waiting)
   {
-    if (player->num_special_action_sleeping > 0)
-    {
-      int last_action = player->action_waiting;
-
-      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
-      {
-       int last_special_action = player->special_action_sleeping;
-       int num_special_action = player->num_special_action_sleeping;
-       int special_action =
-         (last_special_action == ACTION_DEFAULT ? ACTION_SLEEPING_1 :
-          last_special_action == ACTION_SLEEPING ? ACTION_SLEEPING :
-          last_special_action < ACTION_SLEEPING_1 + num_special_action - 1 ?
-          last_special_action + 1 : ACTION_SLEEPING);
-       int special_graphic =
-         el_act_dir2img(player->element_nr, special_action, move_dir);
-
-       player->anim_delay_counter =
-         graphic_info[special_graphic].anim_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].anim_delay_random);
-       player->post_delay_counter =
-         graphic_info[special_graphic].post_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].post_delay_random);
-
-       player->special_action_sleeping = special_action;
-      }
-
-      if (player->anim_delay_counter > 0)
-      {
-       action = player->special_action_sleeping;
-       player->anim_delay_counter--;
-      }
-      else if (player->post_delay_counter > 0)
-      {
-       player->post_delay_counter--;
-      }
-
-      player->action_waiting = action;
-
-      if (last_action != action)
-       PlayLevelSoundElementAction(jx, jy, element, action);
-      else
-       PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
-    }
+    if (action != last_action)
+      PlayLevelSoundElementAction(jx, jy, element, action);
+    else
+      PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
   }
-  else if (player->is_bored)
+  else
   {
-    if (player->num_special_action_bored > 0)
-    {
-      int last_action = player->action_waiting;
-
-      if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
-      {
-       int special_action =
-         ACTION_BORING_1 + SimpleRND(player->num_special_action_bored);
-       int special_graphic =
-         el_act_dir2img(player->element_nr, special_action, move_dir);
-
-       player->anim_delay_counter =
-         graphic_info[special_graphic].anim_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].anim_delay_random);
-       player->post_delay_counter =
-         graphic_info[special_graphic].post_delay_fixed +
-         SimpleRND(graphic_info[special_graphic].post_delay_random);
-
-       player->special_action_bored = special_action;
-      }
+    if (action != last_action)
+      StopSound(element_info[element].sound[last_action]);
 
-      if (player->anim_delay_counter > 0)
-      {
-       action = player->special_action_bored;
-       player->anim_delay_counter--;
-      }
-      else if (player->post_delay_counter > 0)
-      {
-       player->post_delay_counter--;
-      }
-
-      player->action_waiting = action;
-
-      if (last_action != action)
-       PlayLevelSoundElementAction(jx, jy, element, action);
-      else
-       PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
-    }
+    if (last_action == ACTION_SLEEPING)
+      PlayLevelSoundElementAction(jx, jy, element, ACTION_AWAKENING);
   }
+}
+
+static void PlayAllPlayersSound()
+{
+  int i;
 
-  return action;
+  for (i = 0; i < MAX_PLAYERS; i++)
+    if (stored_player[i].active)
+      PlayPlayerSound(&stored_player[i]);
 }
 
 static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
 {
-  int jx = player->jx, jy = player->jy;
-  int element = player->element_nr;
-  boolean was_waiting = player->is_waiting;
+  boolean last_waiting = player->is_waiting;
+  int move_dir = player->MovDir;
+
+  player->last_action_waiting = player->action_waiting;
 
   if (is_waiting)
   {
-    int last_action, action;
-    boolean play_sound;
-
-    last_action = (player->is_sleeping ? ACTION_SLEEPING :
-                  player->is_bored ? ACTION_BORING : ACTION_WAITING);
-
-    if (!was_waiting)          /* not waiting -> waiting */
+    if (!last_waiting)         /* not waiting -> waiting */
     {
       player->is_waiting = TRUE;
 
@@ -6320,24 +6245,82 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
             FrameCounter >= player->frame_counter_bored)
       player->is_bored = TRUE;
 
-    action = (player->is_sleeping ? ACTION_SLEEPING :
-             player->is_bored ? ACTION_BORING : ACTION_WAITING);
+    player->action_waiting = (player->is_sleeping ? ACTION_SLEEPING :
+                             player->is_bored ? ACTION_BORING :
+                             ACTION_WAITING);
 
-    play_sound =
-      ((player->is_sleeping && player->num_special_action_sleeping == 0) ||
-       (player->is_bored    && player->num_special_action_bored == 0) ||
-       (player->is_waiting && !player->is_sleeping && !player->is_bored));
+    if (player->is_sleeping)
+    {
+      if (player->num_special_action_sleeping > 0)
+      {
+       if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
+       {
+         int last_special_action = player->special_action_sleeping;
+         int num_special_action = player->num_special_action_sleeping;
+         int special_action =
+           (last_special_action == ACTION_DEFAULT ? ACTION_SLEEPING_1 :
+            last_special_action == ACTION_SLEEPING ? ACTION_SLEEPING :
+            last_special_action < ACTION_SLEEPING_1 + num_special_action - 1 ?
+            last_special_action + 1 : ACTION_SLEEPING);
+         int special_graphic =
+           el_act_dir2img(player->element_nr, special_action, move_dir);
+
+         player->anim_delay_counter =
+           graphic_info[special_graphic].anim_delay_fixed +
+           SimpleRND(graphic_info[special_graphic].anim_delay_random);
+         player->post_delay_counter =
+           graphic_info[special_graphic].post_delay_fixed +
+           SimpleRND(graphic_info[special_graphic].post_delay_random);
+
+         player->special_action_sleeping = special_action;
+       }
 
-    if (play_sound && action != last_action)
-      PlayLevelSoundElementAction(jx, jy, element, action);
-    else
-      PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
+       if (player->anim_delay_counter > 0)
+       {
+         player->action_waiting = player->special_action_sleeping;
+         player->anim_delay_counter--;
+       }
+       else if (player->post_delay_counter > 0)
+       {
+         player->post_delay_counter--;
+       }
+      }
+    }
+    else if (player->is_bored)
+    {
+      if (player->num_special_action_bored > 0)
+      {
+       if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
+       {
+         int special_action =
+           ACTION_BORING_1 + SimpleRND(player->num_special_action_bored);
+         int special_graphic =
+           el_act_dir2img(player->element_nr, special_action, move_dir);
+
+         player->anim_delay_counter =
+           graphic_info[special_graphic].anim_delay_fixed +
+           SimpleRND(graphic_info[special_graphic].anim_delay_random);
+         player->post_delay_counter =
+           graphic_info[special_graphic].post_delay_fixed +
+           SimpleRND(graphic_info[special_graphic].post_delay_random);
+
+         player->special_action_bored = special_action;
+       }
+
+       if (player->anim_delay_counter > 0)
+       {
+         player->action_waiting = player->special_action_bored;
+         player->anim_delay_counter--;
+       }
+       else if (player->post_delay_counter > 0)
+       {
+         player->post_delay_counter--;
+       }
+      }
+    }
   }
-  else if (was_waiting)                /* waiting -> not waiting */
+  else if (last_waiting)       /* waiting -> not waiting */
   {
-    if (player->is_sleeping)
-      PlayLevelSoundElementAction(jx, jy, element, ACTION_AWAKENING);
-
     player->is_waiting = FALSE;
     player->is_bored = FALSE;
     player->is_sleeping = FALSE;
@@ -6348,6 +6331,8 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
     player->anim_delay_counter = 0;
     player->post_delay_counter = 0;
 
+    player->action_waiting = ACTION_DEFAULT;
+
     player->special_action_bored = ACTION_DEFAULT;
     player->special_action_sleeping = ACTION_DEFAULT;
   }
@@ -7058,6 +7043,7 @@ void GameActions()
   }
 
   DrawAllPlayers();
+  PlayAllPlayersSound();
 
   if (options.debug)                   /* calculate frames per second */
   {
@@ -9031,7 +9017,7 @@ static void StopLevelSoundActionIfLoop(int x, int y, int action)
   int sound_effect = element_info[Feld[x][y]].sound[action];
 
   if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect))
-    StopSoundExt(sound_effect, SND_CTRL_STOP_SOUND);
+    StopSound(sound_effect);
 }
 
 static void PlayLevelMusic()
index 554fc952787d18500c8b91877d380dd80385ca15..40470ea723b0c30d559c982ac2d2cb2b965aef9e 100644 (file)
@@ -73,8 +73,6 @@ void EdelsteinFunkeln(int, int);
 void MauerWaechst(int, int);
 void MauerAbleger(int, int);
 
-int GetPlayerAction(struct PlayerInfo *, int);
-
 void GameActions(void);
 void ScrollLevel(int, int);
 
index 32e7e3a779968528d7e5fb443dde5425e402f443..186b7ef936979df5ad9e6aeb79ec0f2e757466d2 100644 (file)
 #define PROGRAM_VERSION_MAJOR  3
 #define PROGRAM_VERSION_MINOR  0
 #define PROGRAM_VERSION_PATCH  8
-#define PROGRAM_VERSION_BUILD  1
+#define PROGRAM_VERSION_BUILD  2
 
 #define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING  "Holger Schemel"
@@ -1217,7 +1217,7 @@ struct PlayerInfo
   int anim_delay_counter;
   int post_delay_counter;
 
-  int action_waiting;
+  int action_waiting, last_action_waiting;
   int special_action_bored;
   int special_action_sleeping;
 
index cc8b70356353ec958517582da0f9d18fcd7326dc..7952e8b8b1d4ef286dff3603d0b3bae03301341e 100644 (file)
@@ -201,13 +201,8 @@ static void PlayMenuMusic()
 
 void DrawHeadline()
 {
-  int text1_width = getTextWidth(PROGRAM_TITLE_STRING,     FONT_TITLE_1);
-  int text2_width = getTextWidth(PROGRAM_COPYRIGHT_STRING, FONT_TITLE_2);
-  int x1 = SX + (SXSIZE - text1_width) / 2;
-  int x2 = SX + (SXSIZE - text2_width) / 2;
-
-  DrawText(x1, SY + 8,  PROGRAM_TITLE_STRING,     FONT_TITLE_1);
-  DrawText(x2, SY + 46, PROGRAM_COPYRIGHT_STRING, FONT_TITLE_2);
+  DrawTextSCentered(8,  FONT_TITLE_1, PROGRAM_TITLE_STRING);
+  DrawTextSCentered(46, FONT_TITLE_2, PROGRAM_COPYRIGHT_STRING);
 }
 
 static void ToggleFullscreenIfNeeded()
@@ -238,8 +233,7 @@ void DrawMainMenu()
 {
   static LevelDirTree *leveldir_last_valid = NULL;
   char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:");
-  int name_width  = getTextWidth("Name:",  FONT_MENU_1);
-  int level_width = getTextWidth("Level:", FONT_MENU_1);
+  int name_width, level_width;
   int i;
 
   UnmapAllGadgets();
@@ -306,6 +300,10 @@ void DrawMainMenu()
   DrawText(mSX + 32, mSY + 8*32, "Setup", FONT_MENU_1);
   DrawText(mSX + 32, mSY + 9*32, "Quit", FONT_MENU_1);
 
+  /* calculated after (possible) reload of custom artwork */
+  name_width = getTextWidth(name_text, FONT_MENU_1);
+  level_width = getTextWidth("Level:", FONT_MENU_1);
+
   DrawText(mSX + 32 + name_width, mSY + 2*32, setup.player_name, FONT_INPUT_1);
   DrawText(mSX + level_width + 5 * 32, mSY + 3*32, int2str(level_nr,3),
           FONT_VALUE_1);
@@ -330,7 +328,7 @@ void DrawMainMenu()
   drawCursorXY(level_width/32 + 4, 1, IMG_MENU_BUTTON_LEFT);
   drawCursorXY(level_width/32 + 8, 1, IMG_MENU_BUTTON_RIGHT);
 
-  DrawText(SX + 56, SY + 326, "A Game by Artsoft Entertainment", FONT_TITLE_2);
+  DrawTextSCentered(326, FONT_TITLE_2, "A Game by Artsoft Entertainment");
 
   FadeToFront();
   InitAnimation();
@@ -997,7 +995,8 @@ void HandleInfoScreen_Music(int button)
     int y = 0;
 
     if (button != MB_MENU_INITIALIZE)
-      list = list->next;
+      if (list != NULL)
+       list = list->next;
 
     if (list == NULL)
     {
@@ -1072,7 +1071,7 @@ void HandleInfoScreen_Music(int button)
                      "Press any key or button for next page");
   }
 
-  if (list->is_sound && sound_info[list->music].loop)
+  if (list != NULL && list->is_sound && sound_info[list->music].loop)
     PlaySoundLoop(list->music);
 }
 
index cb473ce77e96463fa140c24d7da0bf2ac276036a..a54b64d4e06cfe2fe4acb81a243f9f7c3d2dc5b1 100644 (file)
@@ -628,55 +628,12 @@ void DrawPlayer(struct PlayerInfo *player)
   if (element == EL_EXPLOSION)
     return;
 
-#if 1
-
-  action = GetPlayerAction(player, move_dir);
-
-#else
-
-  action = (player->is_pushing   ? ACTION_PUSHING    :
-           player->is_digging    ? ACTION_DIGGING    :
-           player->is_collecting ? ACTION_COLLECTING :
-           player->is_moving     ? ACTION_MOVING     :
-           player->is_snapping   ? ACTION_SNAPPING   :
-           player->is_sleeping   ? ACTION_SLEEPING   :
-           player->is_bored      ? ACTION_BORING     :
-           player->is_waiting    ? ACTION_WAITING    : ACTION_DEFAULT);
-
-  if (player->is_bored && player->num_special_action_bored > 0)
-  {
-    if (player->anim_delay_counter == 0 && player->post_delay_counter == 0)
-    {
-      int graphic_waiting;
-
-      action = ACTION_BORING_1 + SimpleRND(player->num_special_action_bored);
-      special_graphic = el_act_dir2img(EL_SP_MURPHY, action, move_dir);
-
-      player->anim_delay_counter =
-       graphic_info[special_graphic].anim_delay_fixed +
-       SimpleRND(graphic_info[special_graphic].anim_delay_random);
-      player->post_delay_counter =
-       graphic_info[special_graphic].post_delay_fixed +
-       SimpleRND(graphic_info[special_graphic].post_delay_random);
-      player->special_action_bored = action;
-    }
-
-    if (player->anim_delay_counter > 0)
-    {
-      action = player->special_action_bored;
-      player->anim_delay_counter--;
-    }
-
-    if (player->post_delay_counter > 0)
-    {
-      player->post_delay_counter--;
-    }
-  }
-#endif
-
-#if 0
-  printf("::: '%s'\n", element_action_info[action].suffix);
-#endif
+  action = (player->is_pushing    ? ACTION_PUSHING         :
+           player->is_digging    ? ACTION_DIGGING         :
+           player->is_collecting ? ACTION_COLLECTING      :
+           player->is_moving     ? ACTION_MOVING          :
+           player->is_snapping   ? ACTION_SNAPPING        :
+           player->is_waiting    ? player->action_waiting : ACTION_DEFAULT);
 
   InitPlayerGfxAnimation(player, action, move_dir);