From: Hourier Date: Mon, 18 May 2020 08:14:57 +0000 (+0900) Subject: [Refactor] #40392 Separated birth-stat.c/h from birth.c/h X-Git-Tag: vmacos3.0.0-alpha52~1355 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=aa0620acee888c321d05435be6fdefe8cde8170b;p=hengbandforosx%2Fhengbandosx.git [Refactor] #40392 Separated birth-stat.c/h from birth.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 1412720c8..233cd43b7 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -153,6 +153,7 @@ + @@ -371,6 +372,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index f78b9b1ba..662dd40e4 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -893,6 +893,9 @@ birth + + birth + @@ -1837,6 +1840,9 @@ birth + + birth + diff --git a/src/Makefile.am b/src/Makefile.am index cf3610882..f477f332d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,6 +39,7 @@ hengband_SOURCES = \ birth/birth-util.c birth/birth-util.h \ birth/birth-select-realm.c birth/birth-select-realm.h \ birth/quick-start.c birth/quick-start.h \ + birth/stat.c birth/stat.h \ \ main/music-definitions-table.c main/music-definitions-table.h \ main/sound-definitions-table.c main/sound-definitions-table.h \ diff --git a/src/birth/birth-stat.c b/src/birth/birth-stat.c new file mode 100644 index 000000000..5cb2b7940 Binary files /dev/null and b/src/birth/birth-stat.c differ diff --git a/src/birth/birth-stat.h b/src/birth/birth-stat.h new file mode 100644 index 000000000..24c20fa90 --- /dev/null +++ b/src/birth/birth-stat.h @@ -0,0 +1,6 @@ +#pragma once + +int adjust_stat(int value, int amount); +void get_stats(player_type* creature_ptr); +void get_max_stats(player_type* creature_ptr); +void get_extra(player_type* creature_ptr, bool roll_hitdie); diff --git a/src/birth/birth.c b/src/birth/birth.c index 9c6e70c77..1788db57a 100644 --- a/src/birth/birth.c +++ b/src/birth/birth.c @@ -43,9 +43,7 @@ #include "object/object-kind.h" #include "player/patron.h" #include "player/player-class.h" -#include "player/player-personality.h" #include "player/player-sex.h" -#include "player/player-skill.h" #include "player/player-status.h" #include "player/process-name.h" #include "player/race-info-table.h" @@ -53,7 +51,6 @@ #include "realm/realm.h" #include "io/save.h" #include "spell/spells-util.h" -#include "spell/spells-status.h" #include "view/display-main-window.h" // 暫定。後で消す. #include "view/display-player.h" // 暫定。後で消す. #include "floor/wild.h" @@ -61,6 +58,7 @@ #include "birth/birth-util.h" #include "birth/birth-select-realm.h" #include "birth/quick-start.h" +#include "birth/birth-stat.h" /*! * オートローラーの内容を描画する間隔 / @@ -98,179 +96,6 @@ static s32b stat_match[6]; static s32b auto_round; /*! - * @brief プレイヤーの能力値表現に基づいて加減算を行う。 - * @param value 現在の能力値 - * @param amount 加減算する値 - * @return 加減算の結果 - */ -static int adjust_stat(int value, int amount) -{ - if (amount < 0) { - for (int i = 0; i < (0 - amount); i++) { - if (value >= 18 + 10) { - value -= 10; - } else if (value > 18) { - value = 18; - } else if (value > 3) { - value--; - } - } - } - else if (amount > 0) { - for (int i = 0; i < amount; i++) { - if (value < 18) { - value++; - } else { - value += 10; - } - } - } - - return value; -} - -/*! - * @brief プレイヤーの能力値を一通りロールする。 / Roll for a characters stats - * @param creature_ptr プレーヤーへの参照ポインタ - * @return なし - * @details - * calc_bonuses()による、独立ステータスからの副次ステータス算出も行っている。 - * For efficiency, we include a chunk of "calc_bonuses()".\n - */ -static void get_stats(player_type* creature_ptr) -{ - while (TRUE) { - int sum = 0; - for (int i = 0; i < 2; i++) { - s32b tmp = randint0(60 * 60 * 60); - BASE_STATUS val; - - /* Extract 5 + 1d3 + 1d4 + 1d5 */ - val = 5 + 3; - val += tmp % 3; - tmp /= 3; - val += tmp % 4; - tmp /= 4; - val += tmp % 5; - tmp /= 5; - - sum += val; - creature_ptr->stat_cur[3 * i] = creature_ptr->stat_max[3 * i] = val; - - /* Extract 5 + 1d3 + 1d4 + 1d5 */ - val = 5 + 3; - val += tmp % 3; - tmp /= 3; - val += tmp % 4; - tmp /= 4; - val += tmp % 5; - tmp /= 5; - - sum += val; - creature_ptr->stat_cur[3 * i + 1] = creature_ptr->stat_max[3 * i + 1] = val; - - val = 5 + 3; - val += tmp % 3; - tmp /= 3; - val += tmp % 4; - tmp /= 4; - val += (BASE_STATUS)tmp; - - sum += val; - creature_ptr->stat_cur[3 * i + 2] = creature_ptr->stat_max[3 * i + 2] = val; - } - - if ((sum > 42 + 5 * 6) && (sum < 57 + 5 * 6)) - break; - } -} - -/*! - * @brief プレイヤーの限界ステータスを決める。 - * @return なし - */ -void get_max_stats(player_type* creature_ptr) -{ - int dice[6]; - while (TRUE) { - int j = 0; - for (int i = 0; i < A_MAX; i++) { - dice[i] = randint1(7); - j += dice[i]; - } - - if (j == 24) - break; - } - - for (int i = 0; i < A_MAX; i++) { - BASE_STATUS max_max = 18 + 60 + dice[i] * 10; - creature_ptr->stat_max_max[i] = max_max; - if (creature_ptr->stat_max[i] > max_max) - creature_ptr->stat_max[i] = max_max; - if (creature_ptr->stat_cur[i] > max_max) - creature_ptr->stat_cur[i] = max_max; - } - - creature_ptr->knowledge &= ~(KNOW_STAT); - creature_ptr->redraw |= (PR_STATS); -} - -/*! - * @brief その他「オートローラ中は算出の対象にしない」副次ステータスを処理する / Roll for some info that the auto-roller ignores - * @return なし - */ -static void get_extra(player_type* creature_ptr, bool roll_hitdie) -{ - if (creature_ptr->prace == RACE_ANDROID) - creature_ptr->expfact = rp_ptr->r_exp; - else - creature_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp; - - if (((creature_ptr->pclass == CLASS_MONK) || - (creature_ptr->pclass == CLASS_FORCETRAINER) || - (creature_ptr->pclass == CLASS_NINJA)) && ((creature_ptr->prace == RACE_KLACKON) || - (creature_ptr->prace == RACE_SPRITE))) - creature_ptr->expfact -= 15; - - /* Reset record of race/realm changes */ - creature_ptr->start_race = creature_ptr->prace; - creature_ptr->old_race1 = 0L; - creature_ptr->old_race2 = 0L; - creature_ptr->old_realm = 0; - - for (int i = 0; i < 64; i++) { - if (creature_ptr->pclass == CLASS_SORCERER) - creature_ptr->spell_exp[i] = SPELL_EXP_MASTER; - else if (creature_ptr->pclass == CLASS_RED_MAGE) - creature_ptr->spell_exp[i] = SPELL_EXP_SKILLED; - else - creature_ptr->spell_exp[i] = SPELL_EXP_UNSKILLED; - } - - for (int i = 0; i < 5; i++) - for (int j = 0; j < 64; j++) - creature_ptr->weapon_exp[i][j] = s_info[creature_ptr->pclass].w_start[i][j]; - - if ((creature_ptr->pseikaku == SEIKAKU_SEXY) && (creature_ptr->weapon_exp[TV_HAFTED - TV_WEAPON_BEGIN][SV_WHIP] < WEAPON_EXP_BEGINNER)) { - creature_ptr->weapon_exp[TV_HAFTED - TV_WEAPON_BEGIN][SV_WHIP] = WEAPON_EXP_BEGINNER; - } - - for (int i = 0; i < GINOU_MAX; i++) - creature_ptr->skill_exp[i] = s_info[creature_ptr->pclass].s_start[i]; - - if (creature_ptr->pclass == CLASS_SORCERER) - creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp; - else - creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp; - - if (roll_hitdie) - roll_hitdice(creature_ptr, SPOP_NO_UPDATE); - - creature_ptr->mhp = creature_ptr->player_hp[0]; -} - -/*! * @brief プレイヤーの生い立ちの自動生成を行う。 / Get the racial history, and social class, using the "history charts". * @return なし */ diff --git a/src/birth/birth.h b/src/birth/birth.h index c507f2796..2bd621180 100644 --- a/src/birth/birth.h +++ b/src/birth/birth.h @@ -2,7 +2,6 @@ extern void add_history_from_pref_line(concptr t); extern void player_birth(player_type *creature_ptr, void(*process_autopick_file_command)(char*)); -extern void get_max_stats(player_type *creature_ptr); extern void get_height_weight(player_type *creature_ptr); extern void player_outfit(player_type *creature_ptr); extern void dump_yourself(player_type *creature_ptr, FILE *fff); diff --git a/src/cmd/cmd-quaff.c b/src/cmd/cmd-quaff.c index e782df9eb..ed8c8bd3a 100644 --- a/src/cmd/cmd-quaff.c +++ b/src/cmd/cmd-quaff.c @@ -10,7 +10,6 @@ #include "util/util.h" #include "main/sound-definitions-table.h" -#include "birth/birth.h" #include "player/selfinfo.h" #include "object/object-hook.h" #include "mutation/mutation.h" @@ -31,6 +30,7 @@ #include "view/display-main-window.h" #include "player/player-class.h" #include "spell/spells-detection.h" +#include "birth/birth-stat.h" /*! * @brief 薬を飲むコマンドのサブルーチン / diff --git a/src/player/player-effects.c b/src/player/player-effects.c index 47476ecee..35401291b 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -53,6 +53,7 @@ #include "autopick/autopick-reader-writer.h" #include "io/save.h" #include "io/report.h" +#include "birth/birth-stat.h" #include "view/display-main-window.h"