Skip to content

Commit

Permalink
In smithing add flag or ability menus for artefacts, don't add invali…
Browse files Browse the repository at this point in the history
…d option if valid option is highlighted and a letter is pressed for an invalid option. Plugs exploit reported here, http://angband.oook.cz/forum/showthread.php?t=11375 . (#102)
  • Loading branch information
backwardsEric authored Nov 17, 2022
1 parent 5c1a5aa commit 2710b11
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/cmd4.c
Original file line number Diff line number Diff line change
Expand Up @@ -4890,9 +4890,11 @@ int artefact_flag_menu_aux(int category, int* highlight)
/* Choose by letter */
if ((ch >= 'a') && (ch <= (char)'a' + num - 1))
{
if (flag_valid[*highlight - 1])
int new_highlight = (int)ch - 'a' + 1;

if (flag_valid[new_highlight - 1])
{
if ((int)ch - 'a' + 1 == *highlight)
if (new_highlight == *highlight)
{
// remove a flag if it already existed
if (flag_present[*highlight - 1])
Expand All @@ -4904,7 +4906,7 @@ int artefact_flag_menu_aux(int category, int* highlight)
// restore the artefact from backup
artefact_copy(smith_a_ptr, smith2_a_ptr);

*highlight = (int)ch - 'a' + 1;
*highlight = new_highlight;

// remove a flag if it already existed
if (flag_present[*highlight - 1])
Expand Down Expand Up @@ -5278,9 +5280,11 @@ int artefact_ability_menu_aux(int skill, int* highlight)
/* Choose by letter */
if ((ch >= 'a') && (ch <= (char)'a' + num - 1))
{
if (ability_valid[*highlight - 1])
int new_highlight = (int)ch - 'a' + 1;

if (ability_valid[new_highlight - 1])
{
if ((int)ch - 'a' + 1 == *highlight)
if (new_highlight == *highlight)
{
// remove an ability if it already existed
if (ability_present[*highlight - 1])
Expand All @@ -5291,7 +5295,7 @@ int artefact_ability_menu_aux(int skill, int* highlight)
// restore the artefact from backup
artefact_copy(smith_a_ptr, smith2_a_ptr);

*highlight = (int)ch - 'a' + 1;
*highlight = new_highlight;

// remove an ability if it already existed
if (ability_present[*highlight - 1])
Expand Down

0 comments on commit 2710b11

Please sign in to comment.