From: Alex Smith Date: Wed, 18 Mar 2020 23:00:31 +0000 (+0000) Subject: Safety valve against candelabrum's .age becoming 0 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=564dd1db8d5a8de035b881dfcf75b712f20ab5fd;p=nethack Safety valve against candelabrum's .age becoming 0 This may have happened in a 3.7 game on Hardfought. Even if it didn't, I'm still uncomfortable with the potential for the game to potentially become unwinnable as a consequence of age field corruption. Add an impossible() for when this situation happens, and code after the impossible() to repair the game by removing the candles. --- diff --git a/src/apply.c b/src/apply.c index c4c13d71f..e65241a23 100644 --- a/src/apply.c +++ b/src/apply.c @@ -1188,6 +1188,13 @@ register struct obj *obj; 1 would yield 0, confusing begin_burn() and producing an unlightable, unrefillable candelabrum; round up instead */ obj->age = (obj->age + 1L) / 2L; + + /* to make absolutely sure the game doesn't become unwinnable as + a consequence of a broken candelabrum */ + if (obj->age == 0) { + impossible("Candelabrum with candles but no fuel?"); + obj->age = 1; + } } else { if (obj->spe == 7) { if (Blind)