wilson@ji.Berkeley.EDU (James E. Wilson) (04/01/88)
Here are the four patches that I have so far for umoria 4.85.
These have all been posted before, so be careful not to apply a patch
that has already been applied.
1) Randint bug
- no more high level monsters on low levels
- reduces number of items generated
- eliminates high bonuses on weapons, armor, etc.
2) Shop inventory bug
- put food back into the shops
3) Black Ooze bug
- no more disappearing cursors/games crashes while fighting black oozes
4) randint bug 2
- make random number 'more random' at startup
Patches 2 and 3 also can be applied to PC-Moria 4.83
echo x - patch.posted
sed 's/^X//' >patch.posted << 'END-of-patch.posted'
X*** oldsrc/misc1.c Fri Jan 15 10:23:38 1988
X--- moria/misc1.c Thu Jan 14 18:20:27 1988
X***************
X*** 34,40 ****
X #endif
X
X #ifdef USG
X! void srand();
X #else
X long random();
X char *initstate();
X--- 34,42 ----
X #endif
X
X #ifdef USG
X! long lrand48();
X! void srand48();
X! unsigned short *seed48();
X #else
X long random();
X char *initstate();
X***************
X*** 58,64 ****
X clock = time((long *)0);
X clock = clock * getpid() * euid;
X #ifdef USG
X! /* can't do this, sigh */
X #else
X (void) initstate((unsigned int)clock, randes_state, STATE_SIZE);
X #endif
X--- 60,66 ----
X clock = time((long *)0);
X clock = clock * getpid() * euid;
X #ifdef USG
X! /* only uses randes_seed */
X #else
X (void) initstate((unsigned int)clock, randes_state, STATE_SIZE);
X #endif
X***************
X*** 67,73 ****
X clock = time((long *)0);
X clock = clock * getpid() * euid;
X #ifdef USG
X! /* can't do this */
X #else
X (void) initstate((unsigned int)clock, town_state, STATE_SIZE);
X #endif
X--- 69,75 ----
X clock = time((long *)0);
X clock = clock * getpid() * euid;
X #ifdef USG
X! /* only uses town_seed */
X #else
X (void) initstate((unsigned int)clock, town_state, STATE_SIZE);
X #endif
X***************
X*** 76,88 ****
X clock = time((long *)0);
X clock = clock * getpid() * euid * getuid();
X #ifdef USG
X! /* can't do this, do fake it */
X! srand((unsigned int)clock);
X #else
X (void) initstate((unsigned int)clock, norm_state, STATE_SIZE);
X #endif
X }
X
X
X /* change to different random number generator state */
X /*ARGSUSED*/
X--- 78,94 ----
X clock = time((long *)0);
X clock = clock * getpid() * euid * getuid();
X #ifdef USG
X! /* can't do this, so fake it */
X! srand48(clock);
X #else
X (void) initstate((unsigned int)clock, norm_state, STATE_SIZE);
X #endif
X }
X
X+ #ifdef USG
X+ /* special array for restoring the SYS V number generator */
X+ unsigned short oldseed[3];
X+ #endif
X
X /* change to different random number generator state */
X /*ARGSUSED*/
X***************
X*** 91,97 ****
X int seed;
X {
X #ifdef USG
X! srand((unsigned)seed);
X #else
X (void) setstate(state);
X /* want reproducible state here, so call srandom */
X--- 97,113 ----
X int seed;
X {
X #ifdef USG
X! unsigned short *pointer;
X!
X! /* make phony call to get pointer to old value of seed */
X! pointer = seed48(oldseed);
X! /* copy old seed into oldseed */
X! oldseed[0] = pointer[0];
X! oldseed[1] = pointer[1];
X! oldseed[2] = pointer[2];
X!
X! /* want reproducible state here, so call srand48 */
X! srand48((long)seed);
X #else
X (void) setstate(state);
X /* want reproducible state here, so call srandom */
X***************
X*** 104,111 ****
X reset_seed()
X {
X #ifdef USG
X /* can't do this, so just call srand() with the current time */
X! srand((unsigned int)(time ((long *)0)));
X #else
X (void) setstate(norm_state);
X #endif
X--- 120,130 ----
X reset_seed()
X {
X #ifdef USG
X+ (void) seed48(oldseed);
X+ #if 0
X /* can't do this, so just call srand() with the current time */
X! srand48((unsigned int)(time ((long *)0)));
X! #endif
X #else
X (void) setstate(norm_state);
X #endif
X***************
X*** 154,162 ****
X long randval;
X
X #ifdef USG
X! randval = rand(); /* only returns numbers from 0 to 2**15-1 */
X #else
X! randval = random() >> 16;
X #endif
X return ((randval % maxval) + 1);
X }
X--- 173,181 ----
X long randval;
X
X #ifdef USG
X! randval = lrand48();
X #else
X! randval = random();
X #endif
X return ((randval % maxval) + 1);
X }
END-of-patch.posted
echo x - patch.posted2
sed 's/^X//' >patch.posted2 << 'END-of-patch.posted2'
X*** oldsrc/store1.c Sat Feb 13 03:24:09 1988
X--- moria/store1.c Fri Feb 12 18:38:26 1988
X***************
X*** 314,320 ****
X do
X {
X i = store_choice[store_num][randint(STORE_CHOICES)-1];
X! t_list[cur_pos] = inventory_init[i];
X magic_treasure(cur_pos, OBJ_TOWN_LEVEL);
X inventory[INVEN_MAX] = t_list[cur_pos];
X if (store_check_num(store_num))
X--- 314,321 ----
X do
X {
X i = store_choice[store_num][randint(STORE_CHOICES)-1];
X! /* this index is one more than it should be, so subtract one */
X! t_list[cur_pos] = inventory_init[i-1];
X magic_treasure(cur_pos, OBJ_TOWN_LEVEL);
X inventory[INVEN_MAX] = t_list[cur_pos];
X if (store_check_num(store_num))
END-of-patch.posted2
echo x - patch.posted3
sed 's/^X//' >patch.posted3 << 'END-of-patch.posted3'
X*** oldmoria2.c Sat Feb 27 15:23:30 1988
X--- moria2.c Sat Feb 27 15:22:59 1988
X***************
X*** 515,522 ****
X lite_spot((int)m_ptr->fy, (int)m_ptr->fx);
X else
X unlite_spot((int)m_ptr->fy, (int)m_ptr->fx);
X- pushm(j);
X }
X if (mon_tot_mult > 0)
X mon_tot_mult--;
X }
X--- 515,522 ----
X lite_spot((int)m_ptr->fy, (int)m_ptr->fx);
X else
X unlite_spot((int)m_ptr->fy, (int)m_ptr->fx);
X }
X+ pushm(j);
X if (mon_tot_mult > 0)
X mon_tot_mult--;
X }
END-of-patch.posted3
echo x - patch.posted4
sed 's/^X//' >patch.posted4 << 'END-of-patch.posted4'
X*** misc1.c.old Sat Mar 5 18:31:07 1988
X--- misc1.c Sun Feb 28 16:44:46 1988
X***************
X*** 82,87
X #else
X (void) initstate((unsigned int)clock, norm_state, STATE_SIZE);
X #endif
X }
X
X #ifdef USG
X
X--- 82,90 -----
X #else
X (void) initstate((unsigned int)clock, norm_state, STATE_SIZE);
X #endif
X+ /* Help the random number generators avoid sucking dead worms through a
X+ * straw. */
X+ { int spin = randint(31); while (spin-- >0) randint(2); }
X }
X
X #ifdef USG
END-of-patch.posted4
exit
Jim Wilson "If it is only a game, then why keep score?"
wilson@ji.Berkeley.EDU Worf - Star Trek: The Next Generation
ucbvax!ucbji!wilson