]> granicus.if.org Git - nethack/commitdiff
Safety valve against candelabrum's .age becoming 0
authorAlex Smith <ais523@nethack4.org>
Wed, 18 Mar 2020 23:00:31 +0000 (23:00 +0000)
committerAlex Smith <ais523@nethack4.org>
Wed, 18 Mar 2020 23:00:31 +0000 (23:00 +0000)
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.

src/apply.c

index c4c13d71f07b4e9ed5c081b3df4639add6aad0f7..e65241a238b87d909391aac49c100f28a2021cce 100644 (file)
@@ -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)