[comp.sources.bugs] nethack fixes

grady@postgres (Steven Grady) (07/31/87)

The following diffs fix two bugs.  The change in wield.c prevents
a core dump from occurring (dereferencing through NULL) when you wield
something if you're currently empty-handed.  The change in invent.c
fixes the prompt for objects when REDO is #defined.  Just run this
article through "patch".

diff -c hack.old/invent.c hack/invent.c
*** hack.old/invent.c	Thu Jul 30 18:18:57 1987
--- hack/invent.c	Thu Jul 30 18:09:35 1987
***************
*** 366,382 ****
  		return(0);
  	}
  	for(;;) {
! 		if(!buf[0])
  #ifdef REDO
  		    if(!in_doagain)
  #endif
  			pline("What do you want to %s [*]? ", word);
! 		else
  #ifdef REDO
  		    if(!in_doagain)
  #endif
  			pline("What do you want to %s [%s or ?*]? ",
  				word, buf);
  
  		cnt = 0;
  		ilet = readchar();
--- 366,383 ----
  		return(0);
  	}
  	for(;;) {
! 		if(!buf[0]) {
  #ifdef REDO
  		    if(!in_doagain)
  #endif
  			pline("What do you want to %s [*]? ", word);
! 		} else {
  #ifdef REDO
  		    if(!in_doagain)
  #endif
  			pline("What do you want to %s [%s or ?*]? ",
  				word, buf);
+ 		}
  
  		cnt = 0;
  		ilet = readchar();
diff -c hack.old/wield.c hack/wield.c
*** hack.old/wield.c	Thu Jul 30 18:18:51 1987
--- hack/wield.c	Thu Jul 30 15:39:29 1987
***************
*** 126,132 ****
  
  int
  welded(obj) register struct obj *obj;  {
! 	return(obj == uwep && obj->cursed &&
  	       (obj->olet == WEAPON_SYM || obj->otyp == HEAVY_IRON_BALL ||
  		obj->otyp == CAN_OPENER || obj->otyp == PICK_AXE));
  }
--- 126,132 ----
  
  int
  welded(obj) register struct obj *obj;  {
! 	return(obj == uwep && (obj != (struct obj *) 0) && obj->cursed &&
  	       (obj->olet == WEAPON_SYM || obj->otyp == HEAVY_IRON_BALL ||
  		obj->otyp == CAN_OPENER || obj->otyp == PICK_AXE));
  }

	Steven
	grady@postgres.berkeley.edu
	...!ucbvax!grady