]> granicus.if.org Git - nethack/commitdiff
fix saddle sanity check code
authorPatR <rankin@nethack.org>
Tue, 11 May 2021 22:59:19 +0000 (15:59 -0700)
committerPatR <rankin@nethack.org>
Tue, 11 May 2021 22:59:19 +0000 (15:59 -0700)
Fix some bad code for "no saddle" caused by careless editing that
changed (uncomitted)
  char *ns = 0;
  if (foo)
    ns = "foo";
  else if (bar)
    ns = "bar";
by splicing lines together and accidentally ended up with
  char *ns;
  ns = foo ? ns = "foo" : bar ? ns = "bar" : 0;
when
  char *ns;
  ns = foo ? "foo" : bar ? "bar" : 0;
was intended.

I'm a bit surprised that the intermediate form without any
parentheses around 'ns = "bar"' compiles at all.  C99?  I don't
think that it would have if it had been processed as C90 or pre-ANSI.

src/mon.c

index 0aef9dda5a1d59297c2501307302e5ff1b839124..1297f5d282b8fd441dea54513691e1ea1f899083 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -111,8 +111,8 @@ sanity_check_single_mon(
     if (mtmp == u.usteed) {
         const char *ns, *nt = !mtmp->mtame ? "not tame" : 0;
 
-        ns = !m_carrying(mtmp, SADDLE) ? ns = "no saddle"
-             : !which_armor(mtmp, W_SADDLE) ? ns = "saddle not worn"
+        ns = !m_carrying(mtmp, SADDLE) ? "no saddle"
+             : !which_armor(mtmp, W_SADDLE) ? "saddle not worn"
                : 0;
         if (ns || nt)
             impossible("steed: %s%s%s (%s)",