From aa0620acee888c321d05435be6fdefe8cde8170b Mon Sep 17 00:00:00 2001 From: Hourier Date: Mon, 18 May 2020 17:14:57 +0900 Subject: [PATCH] [Refactor] #40392 Separated birth-stat.c/h from birth.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 + src/Makefile.am | 1 + src/birth/birth-stat.c | Bin 0 -> 10468 bytes src/birth/birth-stat.h | 6 + src/birth/birth.c | 177 +---------------------------- src/birth/birth.h | 1 - src/cmd/cmd-quaff.c | 2 +- src/player/player-effects.c | 1 + 9 files changed, 18 insertions(+), 178 deletions(-) create mode 100644 src/birth/birth-stat.c create mode 100644 src/birth/birth-stat.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 0000000000000000000000000000000000000000..5cb2b7940f54c913f69e9d6ba89695ad8406ddbf GIT binary patch literal 10468 zcmeHN%THWY7(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QNR;ZV5`1fA? z)9)!BjV{x(S%h51o~Ky5ik0ITlyv#5O-YT(M3ED!blvTy-%{EWUcZ*)DxHQ}VK=mt z1~XEUM%a3-(4b!=Y3zp_+T%(jJQ_KYG@8k=GfqO%UW)%DHc;8vr&Jr=-;hHds`Nl89&)V-X@%YKj zeg3o^!%LP^jzzmQQTk#I)0J6FI-aYWgKXMA&Og1%8BwDN5ziwQz_m;~82Q|Rb7I8( zE${fQggUy4cO8&TW=xzTam}>TCgt|0IIYyB%J$y6l_>}(H=G!eyJ(xsqML)Py4+Ez z<;RW0PCQEtFFT8}qA@$sQ}U=FXWTTQ2maEF=Mgi2YkCZaJcd#)W0s^71!7;pFFI}G z{&EFR0+)(UhL4T*nh9bUsf$5317~;wi+(GT!pMtcpL?>=`rUCN%}% zKL@Q2BO=+Q-NYZew7uZ#2fnJuYndmddDo!R z#u?~YI8EQHsyGHA`vV zMSU;^`e2_S*sTvcfl-%hI3H$IFF^fcSD>dEPDh=XRbQo`OE-Ltq)k3*#$qO^Ni z3&niUgv{Y~_$FX(*5Y!~+Ims0o^YKdU1IYEpt}9}?HTP2nYC4+? z$!KmpW<;YS&Zax(C24*ivU2>tN=a{*D%ZN7b7j4sH}>!lht2YJw%Qb;z!O>BiHO{3 zef|P=EIj?>dA`mo(|T`(<79-H#NRKJ@Fee(-Vn;^`^Pys+AGJte`$WwooCvfPIIna z(_q;HHqLR}Ke8_vaoqrC07dxzDC#56idmm``c+70Y9B^!2rhZvPuowRchsq=#P9!F C_SSv? literal 0 HcmV?d00001 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" -- 2.11.0