OSDN Git Service

[Refactor] #3264 BASE_STATUS 型エイリアスを削除した
authorHourier <66951241+Hourier@users.noreply.github.com>
Mon, 15 May 2023 11:51:28 +0000 (20:51 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Tue, 16 May 2023 11:23:27 +0000 (20:23 +0900)
src/action/racial-execution.cpp
src/birth/birth-stat.cpp
src/birth/quick-start.h
src/spell/spells-status.cpp
src/status/base-status.cpp
src/system/h-type.h
src/system/player-type-definition.h
src/wizard/wizard-special-process.cpp

index 4aebfbc..00e933c 100644 (file)
@@ -81,9 +81,9 @@ PERCENTAGE racial_chance(PlayerType *player_ptr, rpi_type *rpi_ptr)
     }
 
     difficulty = difficulty / 2;
-    const BASE_STATUS stat = player_ptr->stat_cur[rpi_ptr->stat];
-    int sum = 0;
-    for (int i = 1; i <= stat; i++) {
+    const auto stat = player_ptr->stat_cur[rpi_ptr->stat];
+    auto sum = 0;
+    for (auto i = 1; i <= stat; i++) {
         int val = i - difficulty;
         if (val > 0) {
             sum += (val <= difficulty) ? val : difficulty;
index b967459..80c4e21 100644 (file)
@@ -14,7 +14,7 @@
 #include "system/player-type-definition.h"
 
 /*! オートロール能力値の乱数分布 / emulate 5 + 1d3 + 1d4 + 1d5 by randint0(60) */
-BASE_STATUS rand3_4_5[60] = {
+short rand3_4_5[60] = {
     8, 9, 9, 9, 10, 10, 10, 10, 10, 10, /*00-09*/
     11, 11, 11, 11, 11, 11, 11, 11, 11, 12, /*10-19*/
     12, 12, 12, 12, 12, 12, 12, 12, 12, 12, /*20-29*/
@@ -66,14 +66,12 @@ void get_stats(PlayerType *player_ptr)
     while (true) {
         int sum = 0;
         for (int i = 0; i < 2; i++) {
-            int32_t tmp = randint0(60 * 60 * 60);
-            BASE_STATUS val;
-
+            auto tmp = randint0(60 * 60 * 60);
             for (int j = 0; j < 3; j++) {
                 int stat = i * 3 + j;
 
                 /* Extract 5 + 1d3 + 1d4 + 1d5 */
-                val = rand3_4_5[tmp % 60];
+                auto val = rand3_4_5[tmp % 60];
 
                 sum += val;
                 player_ptr->stat_cur[stat] = player_ptr->stat_max[stat] = val;
@@ -163,10 +161,10 @@ void get_extra(PlayerType *player_ptr, bool roll_hitdie)
  */
 void get_max_stats(PlayerType *player_ptr)
 {
-    int dice[6];
+    int dice[6]{};
     while (true) {
-        int j = 0;
-        for (int i = 0; i < A_MAX; i++) {
+        auto j = 0;
+        for (auto i = 0; i < A_MAX; i++) {
             dice[i] = randint1(7);
             j += dice[i];
         }
@@ -176,8 +174,8 @@ void get_max_stats(PlayerType *player_ptr)
         }
     }
 
-    for (int i = 0; i < A_MAX; i++) {
-        BASE_STATUS max_max = 18 + 60 + dice[i] * 10;
+    for (auto i = 0; i < A_MAX; i++) {
+        short max_max = 18 + 60 + dice[i] * 10;
         player_ptr->stat_max_max[i] = max_max;
         if (player_ptr->stat_max[i] > max_max) {
             player_ptr->stat_max[i] = max_max;
index 8370c9b..e5a3df4 100644 (file)
@@ -26,8 +26,8 @@ struct birther {
 
     PRICE au{}; /*!< 初期の所持金 */
 
-    BASE_STATUS stat_max[6]{}; /* Current "maximal" stat values */
-    BASE_STATUS stat_max_max[6]{}; /* Maximal "maximal" stat values */
+    short stat_max[6]{}; /* Current "maximal" stat values */
+    short stat_max_max[6]{}; /* Maximal "maximal" stat values */
     int player_hp[PY_MAX_LEVEL]{};
 
     int16_t chaos_patron{}; /*! カオスパトロンのID */
index 6ff5c7f..ad19541 100644 (file)
@@ -666,10 +666,10 @@ void status_shuffle(PlayerType *player_ptr)
         ;
     }
 
-    BASE_STATUS max1 = player_ptr->stat_max[i];
-    BASE_STATUS cur1 = player_ptr->stat_cur[i];
-    BASE_STATUS max2 = player_ptr->stat_max[j];
-    BASE_STATUS cur2 = player_ptr->stat_cur[j];
+    const auto max1 = player_ptr->stat_max[i];
+    const auto cur1 = player_ptr->stat_cur[i];
+    const auto max2 = player_ptr->stat_max[j];
+    const auto cur2 = player_ptr->stat_cur[j];
 
     player_ptr->stat_max[i] = max2;
     player_ptr->stat_cur[i] = cur2;
index 77deb6d..a175719 100644 (file)
@@ -45,17 +45,15 @@ static concptr desc_stat_neg[] = {
  */
 bool inc_stat(PlayerType *player_ptr, int stat)
 {
-    BASE_STATUS gain;
-    BASE_STATUS value = player_ptr->stat_cur[stat];
+    auto value = player_ptr->stat_cur[stat];
     if (value >= player_ptr->stat_max_max[stat]) {
         return false;
     }
 
     if (value < 18) {
-        gain = ((randint0(100) < 75) ? 1 : 2);
-        value += gain;
+        value += (randint0(100) < 75) ? 1 : 2;
     } else if (value < (player_ptr->stat_max_max[stat] - 2)) {
-        gain = (((player_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
+        auto gain = (((player_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
         if (gain < 1) {
             gain = 1;
         }
@@ -96,9 +94,9 @@ bool inc_stat(PlayerType *player_ptr, int stat)
  */
 bool dec_stat(PlayerType *player_ptr, int stat, int amount, int permanent)
 {
-    bool res = false;
-    BASE_STATUS cur = player_ptr->stat_cur[stat];
-    BASE_STATUS max = player_ptr->stat_max[stat];
+    auto res = false;
+    auto cur = player_ptr->stat_cur[stat];
+    auto max = player_ptr->stat_max[stat];
     int same = (cur == max);
     if (cur > 3) {
         if (cur <= 18) {
index a173e2b..e826d46 100644 (file)
@@ -104,7 +104,6 @@ typedef char GAME_TEXT; /*!< ゲーム中のテキスト型定義 */
 typedef int32_t MANA_POINT; /*!< ゲーム中のMP型を定義 */
 
 typedef int16_t HIT_PROB; /*!< ゲーム中の装備命中修正値を定義 */
-typedef int16_t BASE_STATUS; /*!< ゲーム中の基礎能力値型を定義 */
 
 typedef int32_t MONSTER_NUMBER; /*!< ゲーム中のモンスター数型を定義 */
 typedef int32_t ITEM_NUMBER; /*!< ゲーム中のアイテム数型を定義 */
index b31f549..e01cd7c 100644 (file)
@@ -86,9 +86,9 @@ public:
 
     int16_t max_plv{}; /* Max Player Level */
 
-    BASE_STATUS stat_max[A_MAX]{}; /* Current "maximal" stat values */
-    BASE_STATUS stat_max_max[A_MAX]{}; /* Maximal "maximal" stat values */
-    BASE_STATUS stat_cur[A_MAX]{}; /* Current "natural" stat values */
+    short stat_max[A_MAX]{}; /* Current "maximal" stat values */
+    short stat_max_max[A_MAX]{}; /* Maximal "maximal" stat values */
+    short stat_cur[A_MAX]{}; /* Current "natural" stat values */
 
     int16_t learned_spells{};
     int16_t add_spells{};
index 45a2778..cfd5f96 100644 (file)
@@ -402,7 +402,7 @@ void wiz_create_named_art(PlayerType *player_ptr)
  */
 void wiz_change_status(PlayerType *player_ptr)
 {
-    int tmp_int;
+    short stat;
     char tmp_val[160];
     char ppp[80];
     for (int i = 0; i < A_MAX; i++) {
@@ -412,14 +412,14 @@ void wiz_change_status(PlayerType *player_ptr)
             return;
         }
 
-        tmp_int = atoi(tmp_val);
-        if (tmp_int > player_ptr->stat_max_max[i]) {
-            tmp_int = player_ptr->stat_max_max[i];
-        } else if (tmp_int < 3) {
-            tmp_int = 3;
+        stat = static_cast<short>(atoi(tmp_val));
+        if (stat > player_ptr->stat_max_max[i]) {
+            stat = player_ptr->stat_max_max[i];
+        } else if (stat < 3) {
+            stat = 3;
         }
 
-        player_ptr->stat_cur[i] = player_ptr->stat_max[i] = (BASE_STATUS)tmp_int;
+        player_ptr->stat_cur[i] = player_ptr->stat_max[i] = stat;
     }
 
     strnfmt(tmp_val, sizeof(tmp_val), "%d", PlayerSkill::weapon_exp_at(PlayerSkillRank::MASTER));