From 02fd1ab39b85c168a63bdf2316ef48f2c145ab6f Mon Sep 17 00:00:00 2001 From: deskull Date: Thu, 10 Sep 2020 02:04:05 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#40514=20player-status-flags.c/h=20?= =?utf8?q?=E3=81=8B=E3=82=89=20player-status-resist.c/h=20=E3=82=92?= =?utf8?q?=E5=88=86=E9=9B=A2=EF=BC=8E=20/=20Separate=20player-status-resis?= =?utf8?q?t.c/h=20from=20player-status-flags.c/h.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 ++ src/Makefile.am | 1 + src/effect/effect-player-resist-hurt.c | 1 + src/object/warning.c | 1 + src/player/player-damage.c | 1 + src/player/player-status-flags.c | 83 --------------------- src/player/player-status-flags.h | 5 -- src/player/player-status-resist.c | 114 +++++++++++++++++++++++++++++ src/player/player-status-resist.h | 7 ++ 10 files changed, 133 insertions(+), 88 deletions(-) create mode 100644 src/player/player-status-resist.c create mode 100644 src/player/player-status-resist.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 194ba03b4..017cb7a28 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -337,6 +337,7 @@ + @@ -991,6 +992,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 19e132221..9b84e494f 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2177,6 +2177,9 @@ monster-floor + + player + @@ -4711,6 +4714,9 @@ spell + + player + diff --git a/src/Makefile.am b/src/Makefile.am index dc778dd19..4f44d87f3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -627,6 +627,7 @@ hengband_SOURCES = \ player/player-status.c player/player-status.h \ player/player-status-flags.c player/player-status-flags.h \ player/player-status-table.c player/player-status-table.h \ + player/player-status-resist.c player/player-status-resist.h \ player/player-personalities-types.h \ player/player-sex.c player/player-sex.h \ player/player-view.c player/player-view.h \ diff --git a/src/effect/effect-player-resist-hurt.c b/src/effect/effect-player-resist-hurt.c index c1feda454..df6671016 100644 --- a/src/effect/effect-player-resist-hurt.c +++ b/src/effect/effect-player-resist-hurt.c @@ -15,6 +15,7 @@ #include "player/player-race-types.h" #include "player/player-race.h" #include "player/player-status-flags.h" +#include "player/player-status-resist.h" #include "spell-kind/spells-equipment.h" #include "spell-kind/spells-teleport.h" #include "spell/spells-status.h" diff --git a/src/object/warning.c b/src/object/warning.c index 901138a30..f69f05517 100644 --- a/src/object/warning.c +++ b/src/object/warning.c @@ -31,6 +31,7 @@ #include "player/player-race-types.h" #include "player/special-defense-types.h" #include "player/player-status-flags.h" +#include "player/player-status-resist.h" #include "spell/spell-types.h" #include "status/element-resistance.h" #include "system/floor-type-definition.h" diff --git a/src/player/player-damage.c b/src/player/player-damage.c index 6a86c434a..9406d3a12 100644 --- a/src/player/player-damage.c +++ b/src/player/player-damage.c @@ -47,6 +47,7 @@ #include "player/race-info-table.h" #include "player/special-defense-types.h" #include "player/player-status-flags.h" +#include "player/player-status-resist.h" #include "racial/racial-android.h" #include "save/save.h" #include "status/base-status.h" diff --git a/src/player/player-status-flags.c b/src/player/player-status-flags.c index 049cbc01f..daca27630 100644 --- a/src/player/player-status-flags.c +++ b/src/player/player-status-flags.c @@ -935,23 +935,6 @@ BIT_FLAGS is_vuln_acid(player_type *creature_ptr) return result; } -PERCENTAGE calc_vuln_acid_rate(player_type *creature_ptr) -{ - PERCENTAGE per = 100; - int i; - BIT_FLAGS flgs = is_vuln_acid(creature_ptr); - for (i = 0; i < FLAG_CAUSE_MAX; i++) { - if (flgs & (0x01 << i)) { - if (i == FLAG_CAUSE_MUTATION) { - per *= 2; - } else { - per += per / 3; - } - } - } - return per; -} - BIT_FLAGS is_resist_elec(player_type *creature_ptr) { BIT_FLAGS result = 0L; @@ -992,23 +975,6 @@ BIT_FLAGS is_vuln_elec(player_type *creature_ptr) return result; } -PERCENTAGE calc_vuln_elec_rate(player_type *creature_ptr) -{ - PERCENTAGE per = 100; - int i; - BIT_FLAGS flgs = is_vuln_elec(creature_ptr); - for (i = 0; i < FLAG_CAUSE_MAX; i++) { - if (flgs & (0x01 << i)) { - if (i == FLAG_CAUSE_MUTATION) { - per *= 2; - } else { - per += per / 3; - } - } - } - return per; -} - BIT_FLAGS is_resist_fire(player_type *creature_ptr) { BIT_FLAGS result = 0L; @@ -1055,23 +1021,6 @@ BIT_FLAGS is_vuln_fire(player_type *creature_ptr) return result; } -PERCENTAGE calc_vuln_fire_rate(player_type *creature_ptr) -{ - PERCENTAGE per = 100; - int i; - BIT_FLAGS flgs = is_vuln_fire(creature_ptr); - for (i = 0; i < FLAG_CAUSE_MAX; i++) { - if (flgs & (0x01 << i)) { - if (i == FLAG_CAUSE_MUTATION) { - per *= 2; - } else { - per += per / 3; - } - } - } - return per; -} - BIT_FLAGS is_resist_cold(player_type *creature_ptr) { BIT_FLAGS result = 0L; @@ -1118,23 +1067,6 @@ BIT_FLAGS is_vuln_cold(player_type *creature_ptr) return result; } -PERCENTAGE calc_vuln_cold_rate(player_type *creature_ptr) -{ - PERCENTAGE per = 100; - int i; - BIT_FLAGS flgs = is_vuln_cold(creature_ptr); - for (i = 0; i < FLAG_CAUSE_MAX; i++) { - if (flgs & (0x01 << i)) { - if (i == FLAG_CAUSE_MUTATION) { - per *= 2; - } else { - per += per / 3; - } - } - } - return per; -} - BIT_FLAGS is_resist_pois(player_type *creature_ptr) { BIT_FLAGS result = 0L; @@ -1258,21 +1190,6 @@ BIT_FLAGS is_vuln_lite(player_type *creature_ptr) return result; } -PERCENTAGE calc_vuln_lite_rate(player_type *creature_ptr) -{ - PERCENTAGE per = 100; - if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) { - per *= 2; - } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) { - per = per * 4 / 3; - } - - if (creature_ptr->wraith_form) - per *= 2; - - return per; -} - BIT_FLAGS is_resist_dark(player_type *creature_ptr) { BIT_FLAGS result = 0L; diff --git a/src/player/player-status-flags.h b/src/player/player-status-flags.h index 98fb1c1bf..2a0748abc 100644 --- a/src/player/player-status-flags.h +++ b/src/player/player-status-flags.h @@ -73,22 +73,17 @@ BIT_FLAGS has_impact(player_type *creature_ptr); void has_extra_blow(player_type *creature_ptr); BIT_FLAGS is_resist_acid(player_type *creature_ptr); BIT_FLAGS is_vuln_acid(player_type *creature_ptr); -PERCENTAGE calc_vuln_acid_rate(player_type *creature_ptr); BIT_FLAGS is_resist_elec(player_type *creature_ptr); BIT_FLAGS is_vuln_elec(player_type *creature_ptr); -PERCENTAGE calc_vuln_elec_rate(player_type *creature_ptr); BIT_FLAGS is_resist_fire(player_type *creature_ptr); BIT_FLAGS is_vuln_fire(player_type *creature_ptr); -PERCENTAGE calc_vuln_fire_rate(player_type *creature_ptr); BIT_FLAGS is_resist_cold(player_type *creature_ptr); BIT_FLAGS is_vuln_cold(player_type *creature_ptr); -PERCENTAGE calc_vuln_cold_rate(player_type *creature_ptr); BIT_FLAGS is_resist_pois(player_type *creature_ptr); BIT_FLAGS is_resist_conf(player_type *creature_ptr); BIT_FLAGS is_resist_sound(player_type *creature_ptr); BIT_FLAGS is_resist_lite(player_type *creature_ptr); BIT_FLAGS is_vuln_lite(player_type *creature_ptr); -PERCENTAGE calc_vuln_lite_rate(player_type *creature_ptr); BIT_FLAGS is_resist_dark(player_type *creature_ptr); BIT_FLAGS is_resist_chaos(player_type *creature_ptr); BIT_FLAGS is_resist_disen(player_type *creature_ptr); diff --git a/src/player/player-status-resist.c b/src/player/player-status-resist.c new file mode 100644 index 000000000..72de34150 --- /dev/null +++ b/src/player/player-status-resist.c @@ -0,0 +1,114 @@ +#include "player/player-status-flags.h" +#include "art-definition/art-sword-types.h" +#include "grid/grid.h" +#include "inventory/inventory-slot-types.h" +#include "monster-race/monster-race.h" +#include "monster-race/race-flags2.h" +#include "monster-race/race-flags7.h" +#include "mutation/mutation-flag-types.h" +#include "object-enchant/object-ego.h" +#include "object-enchant/tr-types.h" +#include "object-enchant/trc-types.h" +#include "object-hook/hook-checker.h" +#include "object-hook/hook-weapon.h" +#include "object/object-flags.h" +#include "player/player-class.h" +#include "player/player-race-types.h" +#include "player/player-race.h" +#include "player/player-skill.h" +#include "player/player-status.h" +#include "player/special-defense-types.h" +#include "realm/realm-hex-numbers.h" +#include "realm/realm-song-numbers.h" +#include "realm/realm-types.h" +#include "spell-realm/spells-hex.h" +#include "sv-definition/sv-weapon-types.h" +#include "system/floor-type-definition.h" +#include "system/monster-type-definition.h" +#include "system/object-type-definition.h" +#include "util/bit-flags-calculator.h" +#include "util/quarks.h" +#include "util/string-processor.h" + +PERCENTAGE calc_vuln_acid_rate(player_type *creature_ptr) +{ + PERCENTAGE per = 100; + int i; + BIT_FLAGS flgs = is_vuln_acid(creature_ptr); + for (i = 0; i < FLAG_CAUSE_MAX; i++) { + if (flgs & (0x01 << i)) { + if (i == FLAG_CAUSE_MUTATION) { + per *= 2; + } else { + per += per / 3; + } + } + } + return per; +} + +PERCENTAGE calc_vuln_elec_rate(player_type *creature_ptr) +{ + PERCENTAGE per = 100; + int i; + BIT_FLAGS flgs = is_vuln_elec(creature_ptr); + for (i = 0; i < FLAG_CAUSE_MAX; i++) { + if (flgs & (0x01 << i)) { + if (i == FLAG_CAUSE_MUTATION) { + per *= 2; + } else { + per += per / 3; + } + } + } + return per; +} + +PERCENTAGE calc_vuln_fire_rate(player_type *creature_ptr) +{ + PERCENTAGE per = 100; + int i; + BIT_FLAGS flgs = is_vuln_fire(creature_ptr); + for (i = 0; i < FLAG_CAUSE_MAX; i++) { + if (flgs & (0x01 << i)) { + if (i == FLAG_CAUSE_MUTATION) { + per *= 2; + } else { + per += per / 3; + } + } + } + return per; +} + +PERCENTAGE calc_vuln_cold_rate(player_type *creature_ptr) +{ + PERCENTAGE per = 100; + int i; + BIT_FLAGS flgs = is_vuln_cold(creature_ptr); + for (i = 0; i < FLAG_CAUSE_MAX; i++) { + if (flgs & (0x01 << i)) { + if (i == FLAG_CAUSE_MUTATION) { + per *= 2; + } else { + per += per / 3; + } + } + } + return per; +} + +PERCENTAGE calc_vuln_lite_rate(player_type *creature_ptr) +{ + PERCENTAGE per = 100; + if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) { + per *= 2; + } else if (is_specific_player_race(creature_ptr, RACE_S_FAIRY)) { + per = per * 4 / 3; + } + + if (creature_ptr->wraith_form) + per *= 2; + + return per; +} diff --git a/src/player/player-status-resist.h b/src/player/player-status-resist.h new file mode 100644 index 000000000..a794af86c --- /dev/null +++ b/src/player/player-status-resist.h @@ -0,0 +1,7 @@ +#include "player/player-status.h" + +PERCENTAGE calc_vuln_acid_rate(player_type *creature_ptr); +PERCENTAGE calc_vuln_elec_rate(player_type *creature_ptr); +PERCENTAGE calc_vuln_fire_rate(player_type *creature_ptr); +PERCENTAGE calc_vuln_cold_rate(player_type *creature_ptr); +PERCENTAGE calc_vuln_lite_rate(player_type *creature_ptr); -- 2.11.0