[net.games.hack] Bug when polymorphing rocks

mike@enmasse.UUCP (Mike Schloss) (12/23/85)

Greetings fellow hackers.  I have a question for you.
I think there is a problem with the code dealing with
polymorphing rocks into gems.  The code fragment follows.

	switch(otmp->otyp) {
	case WAN_POLYMORPH:
		/* preserve symbol and quantity, but turn rocks into gems */
		mkobj_at((obj->otyp == ROCK || obj->otyp == ENORMOUS_ROCK)
			? GEM_SYM : obj->olet,
			obj->ox, obj->oy) -> quan = obj->quan;
		delobj(obj);
		break;
	.
	.
	.
	}

What happens is that is turned into a pile of gems with the weight
of one gem.  If you then change the number of items in the pile in
any way (say by adding more or dropping some but not all) the weight
will then be correctly calculated.  This could result in you not being
able to carry what you've already got in your knapsack.  The fix is as
follows:

	register struct	obj	*otmp2;

	.
	.
	.

	switch(otmp->otyp) {
	case WAN_POLYMORPH:
		/* preserve symbol and quantity, but turn rocks into gems */
		otmp2 = mkobj_at((obj->otyp == ROCK ||
			obj->otyp == ENORMOUS_ROCK) ? GEM_SYM : obj->olet,
			obj->ox, obj->oy);
		otmp2->quan = obj->quan;
		otmp2->owt = obj->owt;
		delobj(obj);
		break;
	.
	.
	.
	}

I know this prevents people from collecting millions of Zorkmids worth
of gems but should one be able to do this.  They should weigh something.
It seems though that a gem that weighs the same amount as a rock suitable
as a weapon (without a sling) should be worth alot.  When polymorphing a
rock into a gem does it's size change.  If you polymorph a dragon corpse
into a tripe ration I would expect it's size to change.  Similarly with
other monsters.  Any comments... How about you A.B.

							Mike