[rec.games.moria] patch for umoria 4.87

wilson@ji.Berkeley.EDU.UUCP (06/04/88)

The new umoria 4.87 version sources have been updated to fix a problem with
the wear/wield command.  I still consider this a beta release.
Use at your own risk, and send in those bug reports.

The game is available via anonymous ftp from ucbarpa.Berkeley.EDU in the
directory pub/wilson.  Just get the files moria487.tar.Z.*

There is a diff below for those of you who already have 4.87

Jim Wilson
wilson@ji.Berkeley.EDU
ucbvax!ucbji!wilson

*** moria1.c.orig	Fri Jun  3 14:45:45 1988
--- moria1.c	Fri Jun  3 14:55:26 1988
***************
*** 627,641 ****
  	      }
  	  if (test_flag)
  	    {
! 	      /* completely remove old object first */
  	      unwear_obj = inventory[i];
- 	      if (unwear_obj.tval != 0)
- 		{
- 		  inventory[INVEN_MAX] = unwear_obj;
- 		  tmp = remove(INVEN_MAX);
- 		  if (tmp < com_val)
- 		    com_val = tmp;
- 		}
  	      /* now wear/wield new object */
  	      inventory[i] = inventory[com_val];
  	      i_ptr = &inventory[i];
--- 627,634 ----
  	      }
  	  if (test_flag)
  	    {
! 	      /* save old item */
  	      unwear_obj = inventory[i];
  	      /* now wear/wield new object */
  	      inventory[i] = inventory[com_val];
  	      i_ptr = &inventory[i];
***************
*** 649,654 ****
--- 642,658 ----
  	      inven_weight += i_ptr->weight*i_ptr->number;
  	      inven_destroy(com_val);     /* Subtracts weight      */
  	      equip_ctr++;
+ 	      /* subtract bonuses for old item before add bonuses for new */
+ 	      /* must do this after inven_destroy, otherwise inventory
+ 		 may increase to 23 items thus destroying INVEN_WIELD */
+ 	      if (unwear_obj.tval != 0)
+ 		{
+ 		  inventory[INVEN_MAX] = unwear_obj;
+ 		  /* decrements equip_ctr, and calls py_bonuses with -1 */
+ 		  tmp = remove(INVEN_MAX);
+ 		  if (tmp < com_val)
+ 		    com_val = tmp;
+ 		}
  	      py_bonuses(inventory[i], 1);
  	      switch(i)
  		{

Jim Wilson                  "If winning is not important, then why keep score?"
wilson@ji.Berkeley.EDU          Worf - Star Trek: The Next Generation
ucbvax!ucbji!wilson