OSDN Git Service

[Refactor] #40392 Separated interpret_race_select_key_move() from get_player_race()
authorHourier <hourier@users.sourceforge.jp>
Tue, 19 May 2020 11:50:21 +0000 (20:50 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 19 May 2020 12:01:39 +0000 (21:01 +0900)
src/birth/birth-select-personality.c
src/birth/birth-select-race.c

index 4baa611..2374d1a 100644 (file)
@@ -9,7 +9,7 @@ static void interpret_personality_select_key_move(player_type *creature_ptr, cha
     if (c == '8') {
         if (*cs >= 4)
             *cs -= 4;
-        if (*cs != MAX_SEIKAKU && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
+        if ((*cs != MAX_SEIKAKU) && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
             if ((*cs - 4) > 0)
                 *cs -= 4;
             else
@@ -19,8 +19,8 @@ static void interpret_personality_select_key_move(player_type *creature_ptr, cha
 
     if (c == '4') {
         if (*cs > 0)
-            *cs--;
-        if (*cs != MAX_SEIKAKU && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
+            (*cs)--;
+        if ((*cs != MAX_SEIKAKU) && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
             if ((*cs - 1) > 0)
                 (*cs)--;
             else
@@ -30,8 +30,8 @@ static void interpret_personality_select_key_move(player_type *creature_ptr, cha
 
     if (c == '6') {
         if (*cs < MAX_SEIKAKU)
-            *cs++;
-        if (*cs != MAX_SEIKAKU && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
+            (*cs)++;
+        if ((*cs != MAX_SEIKAKU) && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
             if ((*cs + 1) <= MAX_SEIKAKU)
                 (*cs)++;
             else
@@ -42,7 +42,7 @@ static void interpret_personality_select_key_move(player_type *creature_ptr, cha
     if (c == '2') {
         if ((*cs + 4) <= MAX_SEIKAKU)
             *cs += 4;
-        if (*cs != MAX_SEIKAKU && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
+        if ((*cs != MAX_SEIKAKU) && seikaku_info[*cs].sex && (seikaku_info[*cs].sex != (creature_ptr->psex + 1))) {
             if ((*cs + 4) <= MAX_SEIKAKU)
                 *cs += 4;
             else
index 535bebf..f5b5ba5 100644 (file)
@@ -3,6 +3,29 @@
 #include "term/gameterm.h"
 #include "birth/birth-util.h"
 
+static void interpret_race_select_key_move(char c, int *cs)
+{
+    if (c == '8') {
+        if (*cs >= 5)
+            cs -= 5;
+    }
+
+    if (c == '4') {
+        if (*cs > 0)
+            (*cs)--;
+    }
+
+    if (c == '6') {
+        if (*cs < MAX_RACES)
+            (*cs)++;
+    }
+
+    if (c == '2') {
+        if ((*cs + 5) <= MAX_RACES)
+            *cs += 5;
+    }
+}
+
 /*!
  * @brief プレイヤーの種族選択を行う / Player race
  * @return なし
@@ -56,6 +79,7 @@ bool get_player_race(player_type *creature_ptr)
                     rp_ptr->r_adj[4], rp_ptr->r_adj[5], (rp_ptr->r_exp - 100));
                 c_put_str(TERM_L_BLUE, buf, 5, 40);
             }
+
             c_put_str(TERM_YELLOW, cur, 12 + (cs / 5), 1 + 16 * (cs % 5));
             os = cs;
         }
@@ -88,26 +112,7 @@ bool get_player_race(player_type *creature_ptr)
             continue;
         }
 
-        if (c == '8') {
-            if (cs >= 5)
-                cs -= 5;
-        }
-
-        if (c == '4') {
-            if (cs > 0)
-                cs--;
-        }
-
-        if (c == '6') {
-            if (cs < MAX_RACES)
-                cs++;
-        }
-
-        if (c == '2') {
-            if ((cs + 5) <= MAX_RACES)
-                cs += 5;
-        }
-
+        interpret_race_select_key_move(c, &cs);
         k = (islower(c) ? A2I(c) : -1);
         if ((k >= 0) && (k < MAX_RACES)) {
             cs = k;