]> granicus.if.org Git - nethack/commitdiff
fix [part of] #H103 - misleading prompt when choosing role,&c
authornethack.rankin <nethack.rankin>
Thu, 25 May 2006 05:43:49 +0000 (05:43 +0000)
committernethack.rankin <nethack.rankin>
Thu, 25 May 2006 05:43:49 +0000 (05:43 +0000)
     From a bug report, specifying role and race
along with invalid alignment for that role/race combination resulted in a
prompt of "pick the alignment of your chaotic human Valkyrie".  This fixes
that particular problem, but the role selection code is incomprehensible
and I don't have a lot of confidence about whether other combinations have
similar trouble.

     This also fixes an obvious typo in ok_align().  Unfortunately I can't
figure out what to do with the if-then-else block in root_plselection_prompt
which has identical code for its `then' and `else' halves (in the alignment
code that the new ok_align() test skips).

doc/fixes34.4
src/role.c

index 479ab274b8c8ac875e7e250578746b7a3d5bbba9..b1a2c3e29164dad02a27289d2e00c0985fd79c01 100644 (file)
@@ -226,6 +226,9 @@ fix message handling when multiple shopkeepers are present at end of game
 'C' command can't name shopkeepers or temple priests and other minions
 when "of <deity>" is intentionally being suppressed, an aligned or high
        priestess would be described as an aligned or high priest
+specifying role and/or race along with an invalid alignment for it/them in
+       NETHACKOPTIONS or config file would yield a prompt which misleadingly
+       mentioned the rejected alignment when asking player to pick alignment
 
 
 Platform- and/or Interface-Specific Fixes
index b6c1637932fc363765aaa1b5ac86dcbf668420ab..4614748c097659ac80fccf9252ceee624ab1ac86 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)role.c     3.5     2003/01/08      */
+/*     SCCS Id: @(#)role.c     3.5     2006/05/24      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -982,7 +982,7 @@ int rolenum, racenum, gendnum, alignnum;
        return TRUE;
     } else {
        for (i = 0; i < ROLE_ALIGNS; i++) {
-           allow = races[i].allow;
+           allow = aligns[i].allow;
            if (rolenum >= 0 && rolenum < SIZE(roles)-1 &&
                    !(allow & roles[rolenum].allow & ROLE_ALIGNMASK))
                continue;
@@ -1150,7 +1150,8 @@ int buflen, rolenum, racenum, gendnum, alignnum;
        if (racenum != ROLE_NONE && racenum != ROLE_RANDOM)
                aligncount = race_alignmentcount(racenum);
 
-       if (alignnum != ROLE_NONE && alignnum != ROLE_RANDOM) {
+       if (alignnum != ROLE_NONE && alignnum != ROLE_RANDOM &&
+           ok_align(rolenum, racenum, gendnum, alignnum)) {
                /* if race specified, and multiple choice of alignments for it */
                if ((racenum >= 0) && (aligncount > 1)) {
                        if (donefirst) Strcat(buf, " ");
@@ -1162,6 +1163,8 @@ int buflen, rolenum, racenum, gendnum, alignnum;
                        donefirst = TRUE;
                }
        } else {
+               /* in case we got here by failing the ok_align() test */
+               if (alignnum != ROLE_RANDOM) alignnum = ROLE_NONE;
                /* if alignment not specified, but race is specified
                        and only one choice of alignment for that race then
                        don't include it in the later list */