#include "player-base/player-race.h"
#include "player-info/class-info.h"
#include "player/player-realm.h"
+#include "realm/realm-names-table.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
void PlayerSkill::gain_spell_skill_exp(int realm, int spell_idx)
{
- if ((realm < 1) || ((static_cast<int>(std::size(mp_ptr->info)) < realm) && (realm != REALM_MUSIC) && (realm != REALM_HEX))) {
- return;
- }
+ auto is_valid_realm = is_magic(realm) ||
+ (realm == REALM_MUSIC) || (realm == REALM_HEX);
+ is_valid_realm &= (realm == this->player_ptr->realm1) || (realm == this->player_ptr->realm2);
+ const auto is_valid_spell_idx = (0 <= spell_idx) && (spell_idx < 32);
- if (((spell_idx < 0) || (32 <= spell_idx)) ||
- ((realm != this->player_ptr->realm1) && (realm != this->player_ptr->realm2))) {
+ if (!is_valid_realm || !is_valid_spell_idx) {
return;
}
constexpr GainAmountList gain_amount_list_second{ { 60, 8, 2, 0 } };
const auto is_first_realm = (realm == this->player_ptr->realm1);
- const auto *s_ptr = &mp_ptr->info[realm - 1][spell_idx];
+ const auto *s_ptr = is_magic(realm) ? &mp_ptr->info[realm - 1][spell_idx] : &technic_info[realm - MIN_TECHNIC][spell_idx];
gain_spell_skill_exp_aux(this->player_ptr, this->player_ptr->spell_exp[spell_idx + (is_first_realm ? 0 : 32)],
(is_first_realm ? gain_amount_list_first : gain_amount_list_second), s_ptr->slevel);