]> granicus.if.org Git - nethack/commitdiff
hero location bookkeeping bit
authornethack.rankin <nethack.rankin>
Sat, 25 Feb 2006 06:48:52 +0000 (06:48 +0000)
committernethack.rankin <nethack.rankin>
Sat, 25 Feb 2006 06:48:52 +0000 (06:48 +0000)
     On the first move of the game and the first move after each level
change, the "previous position's coordinates" <u.ux0, u.uy0> had bogus
values:  zero at start, last location on old level otherwise.  They're
never used to undo a level change, so the last location on the old level
isn't interesting.  Set them to match current location, as if you'd just
rested on the new spot.  I'm not aware of any bugs attributable to this.

src/dungeon.c

index ac9e1adb5d11672a816a96e01fcbc2846895b6aa..854639c679cb1b5e69daf9f2927a55ed5358b4c3 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dungeon.c  3.5     1999/10/30      */
+/*     SCCS Id: @(#)dungeon.c  3.5     2006/02/24      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1093,11 +1093,14 @@ int x, y;
        /* ridden steed always shares hero's location */
        if (u.usteed) u.usteed->mx = u.ux, u.usteed->my = u.uy;
 #endif
+       /* when changing levels, don't leave old position set with
+          stale values from previous level */
+       if (!on_level(&u.uz, &u.uz0)) u.ux0 = u.ux, u.uy0 = u.uy;
 }
 
 void
-u_on_sstairs() {       /* place you on the special staircase */
-
+u_on_sstairs()         /* place you on the special staircase */
+{
        if (sstairs.sx) {
            u_on_newpos(sstairs.sx, sstairs.sy);
        } else {