[comp.sources.bugs] Nethack Polymorph objects bug.

tim@banyan.UUCP (Tim Henrion) (09/21/87)

There is a bug in the Polymorph code for objects (i.e. when you zap the
wand of polymorph at a pile of arrows) that causes the code to stack
unstackable objects (i.e. turning 31 +0 arrows into 31 +0 clubs).
I cannot supply diffs because my line numbers are off due to numerous
other fixes and mods, however I simply applied the appropriate stackobj()
code to bhito().

My bhito() code now looks like this
(my fixes are conspicuously commented :-) ):

	switch(otmp->otyp) {
	case WAN_POLYMORPH:
#ifdef SPELLS
	case SPE_POLYMORPH:
#endif
		/* preserve symbol and quantity, but turn rocks into gems */
#ifdef DGKMOD
		otmp2 = mkobj_at((obj->otyp == ROCK
			|| obj->otyp == ENORMOUS_ROCK) ? GEM_SYM : obj->olet,
			obj->ox, obj->oy);

		/* ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR */
		/* ERROR: object quantity unconditionally set to the     */
		/*        quantity of the original stuff.                */
/*		otmp2->quan = obj->quan; */
		/* ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR */

		/* FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX */
		/* The code should use the stackable check from stackobj() */
		/* like this:                                              */
		if (index("%*?!+", otmp2->olet) ||
		    (otmp2->known &&
		     (otmp2->olet == WEAPON_SYM && otmp2->otyp < BOOMERANG)))
		    	otmp2->quan = obj->quan;
		/* FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX FIX */

		/* keep special fields (including charges on wands) */
		/* The DGK modification doesn't allow polymorphing a weapon
		   with enchantments into another one, and doesn't allow 
		   polymorphed rings to have plusses.  KAA*/


[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]

Tim Henrion
Communications Software Engineer	UUCP:  ...!necntc!banyan!tim
Banyan Systems, Inc.			VOICE: (617) 898-1116
115 Flanders Road
Westboro, MA 01581

	   "UNIX?  What do you expect from the phone company..." :-)

[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]