sleeping vs deafness

Another one from entrez: falling asleep tried to make the hero Deaf,
but was adding a negative value to the timeout.  A negative value
of bigger magnitude that the current timeout could produce weird
values when making that be negative and then stuffing it into an
unsigned field.

This applies a fix to sleep-causes-deafness bug but also disables
that, at least for the time being since nobody seemed to notice that
it wasn't working.  The fix might be noticeable so needs testing.

This also adjusts You_hear() so that if Deaf and sleeping are both
active, it will still yield "You dream that your hear ..." instead
having Deaf override that.
This commit is contained in:
PatR
2022-12-20 15:23:40 -08:00
parent 53a4e3f80a
commit 33a5dbff37
2 changed files with 10 additions and 3 deletions

View File

@@ -351,7 +351,7 @@ You_hear(const char *line, ...)
va_list the_args;
char *tmp;
if (Deaf || !flags.acoustics)
if ((Deaf && !Unaware) || !flags.acoustics)
return;
va_start(the_args, line);
if (Underwater)

View File

@@ -851,14 +851,21 @@ fall_asleep(int how_long, boolean wakeup_msg)
stop_occupation();
nomul(how_long);
gm.multi_reason = "sleeping";
/* generally don't notice sounds while sleeping */
#if 0 /* this was broken; the fix for 'how_long' will result in changed
* behavior for sounds that don't go through You_hear() so needs
* testing */
/* You_hear() produces "You dream that you hear ..." when sleeping;
other sound messages will either honor or ignore Deaf */
if (wakeup_msg && gm.multi == how_long) {
/* caller can follow with a direct call to Hear_again() if
there's a need to override this when wakeup_msg is true */
incr_itimeout(&HDeaf, how_long);
/* 3.7: how_long is negative so wasn't actually incrementing the
deafness timeout when it used to be passed as-is */
incr_itimeout(&HDeaf, abs(how_long));
gc.context.botl = TRUE;
ga.afternmv = Hear_again; /* this won't give any messages */
}
#endif
/* early wakeup from combat won't be possible until next monster turn */
u.usleep = gm.moves;
gn.nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;