From 95fc6f318c8daaab440f8eca9586b244798ae3b4 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 8 Oct 2002 10:54:36 +0000 Subject: [PATCH] steed fixes A relatively recent change to prevent #ride letting you move in a way you could walk (squeeze through a tight a gap or enter doorway diagonally) resulted in crashing due to access violation or segfault if you tried to mount toward a spot that didn't contain any monster. Noticed while testing saddle cursing; tried to mount while stunned.... Also, if the character had a saddle "worn" in weapon, alternate weapon, or quiver slot, it didn't get unworn when applying the saddle to a mount. The next time the player tried to equip something in the same slot there'd be a warning message; I don't know whether any more serious symptoms could occur. --- src/steed.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/steed.c b/src/steed.c index a2b8d0409..c224f4943 100644 --- a/src/steed.c +++ b/src/steed.c @@ -132,6 +132,7 @@ use_saddle(otmp) /* Make the attempt */ if (rn2(100) < chance) { You("put the saddle on %s.", mon_nam(mtmp)); + if (otmp->owornmask) remove_worn_item(otmp, FALSE); freeinv(otmp); /* mpickobj may free otmp it if merges, but we have already checked for a saddle above, so no merger should happen */ @@ -230,6 +231,13 @@ mount_steed(mtmp, force) } /* Can the player reach and see the monster? */ + if (!mtmp || (!force && ((Blind && !Blind_telepat) || + mtmp->mundetected || + mtmp->m_ap_type == M_AP_FURNITURE || + mtmp->m_ap_type == M_AP_OBJECT))) { + pline("I see nobody there."); + return (FALSE); + } if (u.uswallow || u.ustuck || u.utrap || Punished || !test_move(u.ux, u.uy, mtmp->mx-u.ux, mtmp->my-u.uy, TEST_MOVE)) { if (Punished || !(u.uswallow || u.ustuck || u.utrap)) @@ -238,13 +246,6 @@ mount_steed(mtmp, force) You("are stuck here for now."); return (FALSE); } - if (!mtmp || (!force && ((Blind && !Blind_telepat) || - mtmp->mundetected || - mtmp->m_ap_type == M_AP_FURNITURE || - mtmp->m_ap_type == M_AP_OBJECT))) { - pline("I see nobody there."); - return (FALSE); - } /* Is this a valid monster? */ otmp = which_armor(mtmp, W_SADDLE); @@ -487,7 +488,8 @@ dismount_steed(reason) case DISMOUNT_BYCHOICE: default: if (otmp && otmp->cursed) { - You("can't. The saddle seems to be cursed."); + You("can't. The saddle %s cursed.", + otmp->bknown ? "is" : "seems to be"); otmp->bknown = TRUE; return; } -- 2.40.0