rocksndiamonds-3.0.8
[rocksndiamonds.git] / src / tools.c
index 106d251ed5c7d45d01c0dcde7be7d1324f4e43b7..6b8ae64696af23dee2a8be92a643ba4a6bae91e0 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);
 
@@ -2003,13 +1960,31 @@ void WaitForEventToContinue()
 }
 
 #define MAX_REQUEST_LINES              13
-#define MAX_REQUEST_LINE_LEN           7
+#define MAX_REQUEST_LINE_FONT1_LEN     7
+#define MAX_REQUEST_LINE_FONT2_LEN     10
 
 boolean Request(char *text, unsigned int req_state)
 {
   int mx, my, ty, result = -1;
   unsigned int old_door_state;
   int last_game_status = game_status;  /* save current game status */
+  int max_request_line_len = MAX_REQUEST_LINE_FONT1_LEN;
+  int font_nr = FONT_TEXT_2;
+  int max_word_len = 0;
+  char *text_ptr;
+
+  for (text_ptr = text; *text_ptr; text_ptr++)
+  {
+    max_word_len = (*text_ptr != ' ' ? max_word_len + 1 : 0);
+
+    if (max_word_len > MAX_REQUEST_LINE_FONT1_LEN)
+    {
+      max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN;
+      font_nr = FONT_LEVEL_NUMBER;
+
+      break;
+    }
+  }
 
 #if 1
   SetMouseCursor(CURSOR_DEFAULT);
@@ -2049,13 +2024,13 @@ boolean Request(char *text, unsigned int req_state)
   /* write text for request */
   for (ty = 0; ty < MAX_REQUEST_LINES; ty++)
   {
-    char text_line[MAX_REQUEST_LINE_LEN + 1];
-    int tx, tl, tc;
+    char text_line[max_request_line_len + 1];
+    int tx, tl, tc = 0;
 
     if (!*text)
       break;
 
-    for (tl = 0, tx = 0; tx < MAX_REQUEST_LINE_LEN; tl++, tx++)
+    for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++)
     {
       tc = *(text + tx);
       if (!tc || tc == ' ')
@@ -2072,9 +2047,9 @@ boolean Request(char *text, unsigned int req_state)
     strncpy(text_line, text, tl);
     text_line[tl] = 0;
 
-    DrawText(DX + (DXSIZE - tl * getFontWidth(FONT_TEXT_2)) / 2,
-            DY + 8 + ty * (getFontHeight(FONT_TEXT_2) + 2),
-            text_line, FONT_TEXT_2);
+    DrawText(DX + (DXSIZE - tl * getFontWidth(font_nr)) / 2,
+            DY + 8 + ty * (getFontHeight(font_nr) + 2),
+            text_line, font_nr);
 
     text += tl + (tc == ' ' ? 1 : 0);
   }