]> granicus.if.org Git - nethack/commitdiff
github pull request #628 - duplicate code
authorPatR <rankin@nethack.org>
Thu, 22 Sep 2022 00:02:45 +0000 (17:02 -0700)
committerPatR <rankin@nethack.org>
Thu, 22 Sep 2022 00:02:45 +0000 (17:02 -0700)
Pull request from argrath nearly a year ago: an 'if' and corresponding
'else' have the same code so there's no point in testing for if/else.

I'm still not convinced that simply removing the if/else is the right
fix here but nothing else is going on.  I've put part of the removed
code back inside '#if 0' in case it needs to be resurrected someday.

Closes #628

src/role.c

index d8bc060b071773c4708ed9d3e23e7309c3d15998..a83e45706f5855c1d3a73b22d471d82eb4ce3735 100644 (file)
@@ -1387,7 +1387,15 @@ root_plselection_prompt(
 
     if (alignnum != ROLE_NONE && alignnum != ROLE_RANDOM
         && ok_align(rolenum, racenum, gendnum, alignnum)) {
+#if 0   /* 'if' and 'else' had duplicate code here; probably a copy+parse
+         * oversight; if a problem with filtering of random role selection
+         * crops up, this is probably the place to start looking */
+
         /* if race specified, and multiple choice of alignments for it */
+        if ((racenum >= 0) && (aligncount > 1)) {
+        } else {
+        }
+#endif  /* the four lines of code below were in both 'if' and 'else' above */
         if (donefirst)
             Strcat(buf, " ");
         Strcat(buf, aligns[alignnum].adj);