]> granicus.if.org Git - nethack/commitdiff
Fix #H5056/bz1086: Bug in Achievement Recording
authorPasi Kallinen <paxed@alt.org>
Mon, 6 Feb 2017 14:42:33 +0000 (16:42 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 6 Feb 2017 14:52:40 +0000 (16:52 +0200)
Bug report was:

> "Completed sokoban" achievement was logged when picking up
> a randomly generated bag of holding in the gnomish mines.

The picking-up code was missing checks for the branches, so
you could get the achievements outside the correct branches.

doc/fixes36.1
include/obj.h
src/invent.c
src/sp_lev.c

index 56916b68e5f8f57ec5423a00c29de43aaf0e9db8..b2972a89a06d6a82e55507fc58a40d57e3244f11 100644 (file)
@@ -366,6 +366,7 @@ when sitting at a trap spot: You sit down. You step on a level teleporter.
        (likewise for polymorph trap, and similar issue for web)
 show all statusline information in #attributes
 add option status_updates to prevent bottom of screen status line updates
+fix achievement recording bug with mines and sokoban prizes
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index e2dc585d42852874158674253d449b137242ee7f..824ccca39a1f65b7665befe6b32c62eb338f932c 100644 (file)
@@ -342,6 +342,14 @@ struct obj {
          && !undiscovered_artifact(ART_EYES_OF_THE_OVERWORLD)))
 #define pair_of(o) ((o)->otyp == LENSES || is_gloves(o) || is_boots(o))
 
+#define is_mines_prize(o) \
+    ((o)->otyp == LUCKSTONE && Is_mineend_level(&u.uz))
+#define is_soko_prize(o)                \
+    (((o)->otyp == AMULET_OF_REFLECTION \
+      || (o)->otyp == BAG_OF_HOLDING)   \
+     && Is_sokoend_level(&u.uz))
+
+
 /* Flags for get_obj_location(). */
 #define CONTAINED_TOO 0x1
 #define BURIED_TOO 0x2
index fa478b516a2ce18b5d96c89d498f737de64b3c4b..fb0099bb8908e4f2b228a9b020fdc609f2f40aa3 100644 (file)
@@ -513,12 +513,10 @@ struct obj *obj;
         }
         set_artifact_intrinsic(obj, 1, W_ART);
     }
-    if (obj->otyp == LUCKSTONE && obj->record_achieve_special) {
+    if (is_mines_prize(obj) && obj->record_achieve_special) {
         u.uachieve.mines_luckstone = 1;
         obj->record_achieve_special = 0;
-    } else if ((obj->otyp == AMULET_OF_REFLECTION
-                || obj->otyp == BAG_OF_HOLDING)
-               && obj->record_achieve_special) {
+    } else if (is_soko_prize(obj) && obj->record_achieve_special) {
         u.uachieve.finish_sokoban = 1;
         obj->record_achieve_special = 0;
     }
index 6f0445bd5bb4f45daa9cf8ab7eb50ec96285d5f0..179d45fa3d8368709414b0451bbf483ae6173016 100644 (file)
@@ -1951,11 +1951,7 @@ struct mkroom *croom;
      * "prize" and then set record_achieve_special (maps to corpsenm)
      * for the object.  That field will later be checked to find out if
      * the player obtained the prize. */
-    if (otmp->otyp == LUCKSTONE && Is_mineend_level(&u.uz)) {
-        otmp->record_achieve_special = 1;
-    } else if ((otmp->otyp == AMULET_OF_REFLECTION
-                || otmp->otyp == BAG_OF_HOLDING)
-               && Is_sokoend_level(&u.uz)) {
+    if (is_mines_prize(otmp) || is_soko_prize(otmp)) {
         otmp->record_achieve_special = 1;
     }