OSDN Git Service

[Refactor] #40414 Separated display_monster_drop_quality() from process_monster_lore...
authorHourier <hourier@users.sourceforge.jp>
Fri, 12 Jun 2020 13:59:31 +0000 (22:59 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 12 Jun 2020 13:59:31 +0000 (22:59 +0900)
src/lore/lore-util.c
src/lore/lore-util.h
src/lore/monster-lore.c
src/view/display-lore-drops.c
src/view/display-lore-drops.h
src/view/display-lore.c

index ee25da3..80bc7fe 100644 (file)
@@ -11,6 +11,10 @@ hook_c_roff_pf hook_c_roff = c_roff;
 
 lore_type *initialize_lore_type(lore_type *lore_ptr, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
+#ifdef JP
+#else
+    lore_ptr->sin = FALSE;
+#endif
     lore_ptr->r_idx = r_idx;
     lore_ptr->nightmare = ironman_nightmare && !(mode & 0x02);
     lore_ptr->r_ptr = &r_info[r_idx];
index a55af63..ae0a75a 100644 (file)
@@ -13,7 +13,7 @@ typedef struct lore_type {
 #ifdef JP
     char jverb_buf[64];
 #else
-    bool sin = FALSE;
+    bool sin;
 #endif
     bool nightmare;
     monster_race *r_ptr;
@@ -40,6 +40,8 @@ typedef struct lore_type {
     char tmp_msg[96][96];
     bool breath;
     bool magic;
+    int drop_quantity;
+    concptr drop_quality;
 } lore_type;
 
 typedef void (*hook_c_roff_pf)(TERM_COLOR attr, concptr str);
index a682f41..b315ccb 100644 (file)
 #include "view/display-lore-status.h"
 #include "view/display-lore.h"
 
-/*!
- * 英語の複数系記述用マクロ / Pluralizer.  Args(count, singular, plural)
- */
-#define plural(c, s, p) (((c) == 1) ? (s) : (p))
-
 static void set_msex_flags(lore_type *lore_ptr)
 {
     lore_ptr->msex = MSEX_NONE;
@@ -226,20 +221,8 @@ void process_monster_lore(player_type *player_ptr, MONRACE_IDX r_idx, BIT_FLAGS
         lore_ptr->sin = FALSE;
 #endif
 
-        display_monster_drop_numbers(lore_ptr);
-        concptr p;
-        if (lore_ptr->flags1 & RF1_DROP_GREAT) {
-            p = _("特別な", " exceptional");
-        } else if (lore_ptr->flags1 & RF1_DROP_GOOD) {
-            p = _("上質な", " good");
-#ifdef JP
-#else
-            lore_ptr->sin = FALSE;
-#endif
-        } else {
-            p = NULL;
-        }
-
+        display_monster_drop_quantity(lore_ptr);
+        display_monster_drop_quality(lore_ptr);
         if (lore_ptr->drop_item) {
 #ifdef JP
 #else
@@ -248,21 +231,22 @@ void process_monster_lore(player_type *player_ptr, MONRACE_IDX r_idx, BIT_FLAGS
 
             lore_ptr->sin = FALSE;
 #endif
-            if (p)
-                hooked_roff(p);
+            if (lore_ptr->drop_quality != NULL)
+                hooked_roff(lore_ptr->drop_quality);
+
             hooked_roff(_("アイテム", " object"));
 #ifdef JP
 #else
-            if (n != 1)
+            if (lore_ptr->drop_quantity != 1)
                 hooked_roff("s");
 #endif
-            p = _("や", " or");
+            lore_ptr->drop_quality = _("や", " or");
         }
 
         if (lore_ptr->drop_gold) {
 #ifdef JP
 #else
-            if (!p)
+            if (lore_ptr->drop_quality == NULL)
                 lore_ptr->sin = FALSE;
 
             if (lore_ptr->sin)
@@ -270,12 +254,13 @@ void process_monster_lore(player_type *player_ptr, MONRACE_IDX r_idx, BIT_FLAGS
 
             lore_ptr->sin = FALSE;
 #endif
-            if (p)
-                hooked_roff(p);
+            if (lore_ptr->drop_quality != NULL)
+                hooked_roff(lore_ptr->drop_quality);
+
             hooked_roff(_("財宝", " treasure"));
 #ifdef JP
 #else
-            if (n != 1)
+            if (lore_ptr->drop_quantity != 1)
                 hooked_roff("s");
 #endif
         }
index b67d9e7..c97e667 100644 (file)
@@ -1,17 +1,33 @@
 #include "view/display-lore-drops.h"
+#include "monster-race/race-flags1.h"
 
-void display_monster_drop_numbers(lore_type *lore_ptr)
+void display_monster_drop_quantity(lore_type *lore_ptr)
 {
-    int n = MAX(lore_ptr->drop_gold, lore_ptr->drop_item);
-    if (n == 1) {
+    lore_ptr->drop_quantity = MAX(lore_ptr->drop_gold, lore_ptr->drop_item);
+    if (lore_ptr->drop_quantity == 1) {
         hooked_roff(_("一つの", " a"));
 #ifdef JP
 #else
         lore_ptr->sin = TRUE;
 #endif
-    } else if (n == 2) {
+    } else if (lore_ptr->drop_quantity == 2) {
         hooked_roff(_("一つか二つの", " one or two"));
     } else {
-        hooked_roff(format(_(" %d 個までの", " up to %d"), n));
+        hooked_roff(format(_(" %d 個までの", " up to %d"), lore_ptr->drop_quantity));
+    }
+}
+
+void display_monster_drop_quality(lore_type* lore_ptr)
+{
+    if (lore_ptr->flags1 & RF1_DROP_GREAT) {
+        lore_ptr->drop_quality = _("特別な", " exceptional");
+    } else if (lore_ptr->flags1 & RF1_DROP_GOOD) {
+        lore_ptr->drop_quality = _("上質な", " good");
+#ifdef JP
+#else
+        lore_ptr->sin = FALSE;
+#endif
+    } else {
+        lore_ptr->drop_quality = NULL;
     }
 }
index de61f19..5506457 100644 (file)
@@ -3,4 +3,5 @@
 #include "system/angband.h"
 #include "lore/lore-util.h"
 
-void display_monster_drop_numbers(lore_type *lore_ptr);
+void display_monster_drop_quantity(lore_type *lore_ptr);
+void display_monster_drop_quality(lore_type *lore_ptr);
index 7934c11..f44bb7c 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include "view/display-lore.h"
+#include "locale/english.h"
 #include "locale/japanese.h"
 #include "lore/lore-calculator.h"
 #include "lore/monster-lore.h"
 #include "world/world.h"
 
 /*!
+ * 英語の複数系記述用マクロ / Pluralizer.  Args(count, singular, plural)
+ */
+#define plural(c, s, p) (((c) == 1) ? (s) : (p))
+
+/*!
  * @brief モンスター情報のヘッダを記述する
  * Hack -- Display the "name" and "attr/chars" of a monster race
  * @param r_idx モンスターの種族ID