Skip to content

Commit

Permalink
Merge branch 'develop' into macos-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
backwardsEric committed Jul 25, 2024
2 parents 275652d + 22f0659 commit dcf51a0
Show file tree
Hide file tree
Showing 30 changed files with 358 additions and 383 deletions.
4 changes: 2 additions & 2 deletions VisualStudio/Hengband/Hengband.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@
<ClCompile Include="..\..\src\load\info-loader.cpp" />
<ClCompile Include="..\..\src\locale\utf-8.cpp" />
<ClCompile Include="..\..\src\main-win\main-win-cfg-reader.cpp" />
<ClCompile Include="..\..\src\main-win\main-win-file-utils.cpp" />
<ClCompile Include="..\..\src\main-win\main-win-mci.cpp" />
<ClCompile Include="..\..\src\main-win\main-win-music.cpp" />
<ClCompile Include="..\..\src\main-win\main-win-sound.cpp" />
Expand Down Expand Up @@ -518,6 +517,7 @@
<ClCompile Include="..\..\src\object-use\read\read-execution.cpp" />
<ClCompile Include="..\..\src\player\player-status-flags.cpp" />
<ClCompile Include="..\..\src\player\player-status-table.cpp" />
<ClCompile Include="..\..\src\player\player-spell-status.cpp" />
<ClCompile Include="..\..\src\player\player-view.cpp" />
<ClCompile Include="..\..\src\racial\class-racial-switcher.cpp" />
<ClCompile Include="..\..\src\racial\mutation-racial-selector.cpp" />
Expand Down Expand Up @@ -1228,7 +1228,6 @@
<ClInclude Include="..\..\src\locale\language-switcher.h" />
<ClInclude Include="..\..\src\locale\utf-8.h" />
<ClInclude Include="..\..\src\main-win\main-win-cfg-reader.h" />
<ClInclude Include="..\..\src\main-win\main-win-file-utils.h" />
<ClInclude Include="..\..\src\main-win\main-win-mci.h" />
<ClInclude Include="..\..\src\main-win\main-win-menuitem.h" />
<ClInclude Include="..\..\src\main-win\main-win-mmsystem.h" />
Expand Down Expand Up @@ -1320,6 +1319,7 @@
<ClInclude Include="..\..\src\object-use\read\read-execution.h" />
<ClInclude Include="..\..\src\player\player-status-flags.h" />
<ClInclude Include="..\..\src\player\player-status-table.h" />
<ClInclude Include="..\..\src\player\player-spell-status.h" />
<ClInclude Include="..\..\src\player\player-view.h" />
<ClInclude Include="..\..\src\racial\class-racial-switcher.h" />
<ClInclude Include="..\..\src\racial\mutation-racial-selector.h" />
Expand Down
12 changes: 6 additions & 6 deletions VisualStudio/Hengband/Hengband.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,9 @@
<ClCompile Include="..\..\src\player\player-status-table.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\player\player-spell-status.cpp">
<Filter>player</Filter>
</ClCompile>
<ClCompile Include="..\..\src\monster-floor\monster-lite-util.cpp">
<Filter>monster-floor</Filter>
</ClCompile>
Expand Down Expand Up @@ -2111,9 +2114,6 @@
<ClCompile Include="..\..\src\main-win\main-win-tokenizer.cpp">
<Filter>main-win</Filter>
</ClCompile>
<ClCompile Include="..\..\src\main-win\main-win-file-utils.cpp">
<Filter>main-win</Filter>
</ClCompile>
<ClCompile Include="..\..\src\stdafx.cpp" />
<ClCompile Include="..\..\src\main\scene-table.cpp">
<Filter>main</Filter>
Expand Down Expand Up @@ -4640,6 +4640,9 @@
<ClInclude Include="..\..\src\player\player-status-table.h">
<Filter>player</Filter>
</ClInclude>
<ClInclude Include="..\..\src\player\player-spell-status.h">
<Filter>player</Filter>
</ClInclude>
<ClInclude Include="..\..\src\monster-floor\monster-lite-util.h">
<Filter>monster-floor</Filter>
</ClInclude>
Expand Down Expand Up @@ -4913,9 +4916,6 @@
<ClInclude Include="..\..\src\main-win\main-win-tokenizer.h">
<Filter>main-win</Filter>
</ClInclude>
<ClInclude Include="..\..\src\main-win\main-win-file-utils.h">
<Filter>main-win</Filter>
</ClInclude>
<ClInclude Include="..\..\src\stdafx.h" />
<ClInclude Include="..\..\src\main\scene-table.h">
<Filter>main</Filter>
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ hengband_SOURCES = \
player/player-personality.cpp player/player-personality.h \
player/player-realm.cpp player/player-realm.h \
player/player-skill.cpp player/player-skill.h \
player/player-spell-status.cpp player/player-spell-status.h \
player/player-status.cpp player/player-status.h \
player/player-status-flags.cpp player/player-status-flags.h \
player/player-status-table.cpp player/player-status-table.h \
Expand Down Expand Up @@ -1052,7 +1053,6 @@ EXTRA_hengband_SOURCES = \
main-win/main-win-cfg-reader.cpp main-win/main-win-cfg-reader.h \
main-win/main-win-define.h \
main-win/main-win-exception.cpp main-win/main-win-exception.h \
main-win/main-win-file-utils.cpp main-win/main-win-file-utils.h \
main-win/main-win-mci.cpp main-win/main-win-mci.h \
main-win/main-win-menuitem.h \
main-win/main-win-mmsystem.h \
Expand Down
15 changes: 4 additions & 11 deletions src/birth/game-play-initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "player-info/race-info.h"
#include "player-info/race-types.h"
#include "player/digestion-processor.h"
#include "player/player-spell-status.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem-info.h"
#include "system/dungeon-info.h"
Expand Down Expand Up @@ -82,18 +83,10 @@ void player_wipe_without_name(PlayerType *player_ptr)
}

player_ptr->food = PY_FOOD_FULL - 1;
if (PlayerClass(player_ptr).equals(PlayerClassType::SORCERER)) {
player_ptr->spell_learned1 = player_ptr->spell_learned2 = 0xffffffffL;
player_ptr->spell_worked1 = player_ptr->spell_worked2 = 0xffffffffL;
} else {
player_ptr->spell_learned1 = player_ptr->spell_learned2 = 0L;
player_ptr->spell_worked1 = player_ptr->spell_worked2 = 0L;
}

player_ptr->spell_forgotten1 = player_ptr->spell_forgotten2 = 0L;
for (int i = 0; i < 64; i++) {
player_ptr->spell_order[i] = 99;
}
PlayerSpellStatus pss(player_ptr);
pss.realm1().initialize();
pss.realm2().initialize();

player_ptr->learned_spells = 0;
player_ptr->add_spells = 0;
Expand Down
34 changes: 13 additions & 21 deletions src/cmd-action/cmd-hissatsu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "player-status/player-energy.h"
#include "player/attack-defense-types.h"
#include "player/player-realm.h"
#include "player/player-spell-status.h"
#include "player/special-defense-types.h"
#include "spell/spells-execution.h"
#include "spell/technic-info-table.h"
Expand Down Expand Up @@ -105,6 +106,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
}
choice = always_show_list ? ESCAPE : 1;

const auto realm_status = PlayerSpellStatus(player_ptr).realm1();
while (!flag) {
if (choice == ESCAPE) {
choice = ' ';
Expand Down Expand Up @@ -133,7 +135,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
if (menu_line > 32) {
menu_line -= 32;
}
} while (!(player_ptr->spell_learned1 & (1UL << (menu_line - 1))));
} while (!realm_status.is_learned(menu_line - 1));
break;
}

Expand All @@ -145,7 +147,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
if (menu_line > 32) {
menu_line -= 32;
}
} while (!(player_ptr->spell_learned1 & (1UL << (menu_line - 1))));
} while (!realm_status.is_learned(menu_line - 1));
break;
}

Expand All @@ -165,7 +167,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
} else {
menu_line += 16;
}
while (!(player_ptr->spell_learned1 & (1UL << (menu_line - 1)))) {
while (!realm_status.is_learned(menu_line - 1)) {
if (reverse) {
menu_line--;
if (menu_line < 2) {
Expand Down Expand Up @@ -213,15 +215,12 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
continue;
}
line++;
if (!(player_ptr->spell_learned1 >> i)) {
break;
}

/* Access the spell */
if (spell.slevel > plev) {
continue;
}
if (!(player_ptr->spell_learned1 & (1UL << i))) {
if (!realm_status.is_learned(i)) {
continue;
}
std::string psi_desc;
Expand Down Expand Up @@ -270,7 +269,7 @@ static int get_hissatsu_power(PlayerType *player_ptr, SPELL_IDX *sn)
}

/* Totally Illegal */
if ((i < 0) || (i >= 32) || !(player_ptr->spell_learned1 & (1U << selections[i]))) {
if ((i < 0) || (i >= 32) || !realm_status.is_learned(selections[i])) {
bell();
continue;
}
Expand Down Expand Up @@ -318,7 +317,7 @@ void do_cmd_hissatsu(PlayerType *player_ptr)
msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
return;
}
if (!player_ptr->spell_learned1) {
if (PlayerSpellStatus(player_ptr).realm1().is_nothing_learned()) {
msg_print(_("何も技を知らない。", "You don't know any special attacks."));
return;
}
Expand Down Expand Up @@ -395,28 +394,21 @@ void do_cmd_gain_hissatsu(PlayerType *player_ptr)

const auto sval = *o_ptr->bi_key.sval();
auto gain = false;
auto realm_status = PlayerSpellStatus(player_ptr).realm1();
for (auto i = sval * 8; i < sval * 8 + 8; i++) {
if (player_ptr->spell_learned1 & (1UL << i)) {
if (realm_status.is_learned(i)) {
continue;
}

if (PlayerRealm::get_spell_info(RealmType::HISSATSU, i).slevel > player_ptr->lev) {
continue;
}

player_ptr->spell_learned1 |= (1UL << i);
player_ptr->spell_worked1 |= (1UL << i);
realm_status.set_learned(i);
realm_status.set_worked(i);
const auto &spell_name = PlayerRealm::get_spell_name(RealmType::HISSATSU, i);
msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), spell_name.data());
int j;
for (j = 0; j < 64; j++) {
/* Stop at the first empty space */
if (player_ptr->spell_order[j] == 99) {
break;
}
}

player_ptr->spell_order[j] = i;
player_ptr->spell_order_learned.push_back(i);
gain = true;
}

Expand Down
63 changes: 17 additions & 46 deletions src/cmd-action/cmd-spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "player/player-damage.h"
#include "player/player-realm.h"
#include "player/player-skill.h"
#include "player/player-spell-status.h"
#include "player/player-status.h"
#include "player/special-defense-types.h"
#include "spell-kind/spells-random.h"
Expand Down Expand Up @@ -69,6 +70,7 @@
#include "view/display-messages.h"
#include "view/display-util.h"
#include <string_view>
#include <vector>

concptr KWD_DAM = _("損傷:", "dam ");
concptr KWD_RANGE = _("射程:", "rng ");
Expand Down Expand Up @@ -273,7 +275,9 @@ static bool spell_okay(PlayerType *player_ptr, int spell_id, bool learned, bool

/* Spell is forgotten */
PlayerRealm pr(player_ptr);
if (pr.realm2().equals(use_realm) ? (player_ptr->spell_forgotten2 & (1UL << spell_id)) : (player_ptr->spell_forgotten1 & (1UL << spell_id))) {
PlayerSpellStatus pss(player_ptr);
const auto realm_status = pr.realm2().equals(use_realm) ? pss.realm2() : pss.realm1();
if (realm_status.is_forgotten(spell_id)) {
/* Never okay */
return false;
}
Expand All @@ -283,7 +287,7 @@ static bool spell_okay(PlayerType *player_ptr, int spell_id, bool learned, bool
}

/* Spell is learned */
if (pr.realm2().equals(use_realm) ? (player_ptr->spell_learned2 & (1UL << spell_id)) : (player_ptr->spell_learned1 & (1UL << spell_id))) {
if (realm_status.is_learned(spell_id)) {
/* Always true */
return !study_pray;
}
Expand Down Expand Up @@ -682,23 +686,11 @@ void do_cmd_browse(PlayerType *player_ptr)
*/
static void change_realm2(PlayerType *player_ptr, PlayerRealm &pr, RealmType next_realm)
{
int i, j = 0;
for (i = 0; i < 64; i++) {
player_ptr->spell_order[j] = player_ptr->spell_order[i];
if (player_ptr->spell_order[i] < 32) {
j++;
}
}
for (; j < 64; j++) {
player_ptr->spell_order[j] = 99;
}
PlayerSpellStatus(player_ptr).realm2().initialize();

for (i = 32; i < 64; i++) {
for (auto i = 32; i < 64; i++) {
player_ptr->spell_exp[i] = PlayerSkill::spell_exp_at(PlayerSkillRank::UNSKILLED);
}
player_ptr->spell_learned2 = 0L;
player_ptr->spell_worked2 = 0L;
player_ptr->spell_forgotten2 = 0L;

constexpr auto fmt_realm = _("魔法の領域を%sから%sに変更した。", "changed magic realm from %s to %s.");
const auto mes = format(fmt_realm, pr.realm2().get_name().data(), PlayerRealm::get_name(next_realm).data());
Expand All @@ -724,7 +716,6 @@ static void change_realm2(PlayerType *player_ptr, PlayerRealm &pr, RealmType nex
void do_cmd_study(PlayerType *player_ptr)
{
auto increment = 0;
auto learned = false;

/* Spells of realm2 will have an increment of +32 */
SPELL_IDX spell = -1;
Expand Down Expand Up @@ -837,21 +828,10 @@ void do_cmd_study(PlayerType *player_ptr)
}

/* Learn the spell */
if (spell < 32) {
if (player_ptr->spell_learned1 & (1UL << spell)) {
learned = true;
} else {
player_ptr->spell_learned1 |= (1UL << spell);
}
} else {
if (player_ptr->spell_learned2 & (1UL << (spell - 32))) {
learned = true;
} else {
player_ptr->spell_learned2 |= (1UL << (spell - 32));
}
}
PlayerSpellStatus pss(player_ptr);
auto realm_status = increment ? pss.realm2() : pss.realm1();

if (learned) {
if (realm_status.is_learned(spell % 32)) {
auto max_exp = PlayerSkill::spell_exp_at((spell < 32) ? PlayerSkillRank::MASTER : PlayerSkillRank::EXPERT);
const auto old_exp = player_ptr->spell_exp[spell];
const auto &realm = increment ? pr.realm2() : pr.realm1();
Expand All @@ -874,17 +854,10 @@ void do_cmd_study(PlayerType *player_ptr)
auto new_rank_str = PlayerSkill::skill_rank_str(new_rank);
msg_format(_("%sの熟練度が%sに上がった。", "Your proficiency of %s is now %s rank."), spell_name.data(), new_rank_str);
} else {
/* Find the next open entry in "player_ptr->spell_order[]" */
int i;
for (i = 0; i < 64; i++) {
/* Stop at the first empty space */
if (player_ptr->spell_order[i] == 99) {
break;
}
}
realm_status.set_learned(spell % 32);

/* Add the spell to the known list */
player_ptr->spell_order[i++] = spell;
player_ptr->spell_order_learned.push_back(spell);

/* Mention the result */
const auto &realm = increment ? pr.realm2() : pr.realm1();
Expand Down Expand Up @@ -1162,15 +1135,13 @@ bool do_cmd_cast(PlayerType *player_ptr)
}

/* A spell was cast */
if (!(increment ? (player_ptr->spell_worked2 & (1UL << spell_id)) : (player_ptr->spell_worked1 & (1UL << spell_id))) && !is_every_magic) {
PlayerSpellStatus pss(player_ptr);
auto realm_status = increment ? pss.realm2() : pss.realm1();
if (!realm_status.is_worked(spell_id) && !is_every_magic) {
int e = spell.sexp;

/* The spell worked */
if (pr.realm1().equals(use_realm)) {
player_ptr->spell_worked1 |= (1UL << spell_id);
} else {
player_ptr->spell_worked2 |= (1UL << spell_id);
}
realm_status.set_worked(spell_id);

gain_exp(player_ptr, e * spell.slevel);
RedrawingFlagsUpdater::get_instance().set_flag(SubWindowRedrawingFlag::ITEM_KNOWLEDGE);
Expand Down
6 changes: 4 additions & 2 deletions src/load/inventory-loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ static errr rd_inventory(PlayerType *player_ptr)

errr load_inventory(PlayerType *player_ptr)
{
for (int i = 0; i < 64; i++) {
player_ptr->spell_order[i] = rd_byte();
for (auto i = 0; i < 64; i++) {
if (const auto spell_id = rd_byte(); spell_id < 64) {
player_ptr->spell_order_learned.push_back(spell_id);
}
}

if (!rd_inventory(player_ptr)) {
Expand Down
Loading

0 comments on commit dcf51a0

Please sign in to comment.