From 2783157f95e37a8b339f5c3e6269a964c08fc5cb Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 22 Apr 2015 08:35:14 +0300 Subject: [PATCH] Unify "You are rooted" message --- include/extern.h | 1 + src/do.c | 8 +------- src/hack.c | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/extern.h b/include/extern.h index 98ee61f01..fe22f97e4 100644 --- a/include/extern.h +++ b/include/extern.h @@ -782,6 +782,7 @@ E boolean FDECL(bad_rock, (struct permonst *,XCHAR_P,XCHAR_P)); E int FDECL(cant_squeeze_thru, (struct monst *)); E boolean FDECL(invocation_pos, (XCHAR_P,XCHAR_P)); E boolean FDECL(test_move, (int, int, int, int, int)); +E boolean NDECL(u_rooted); E void NDECL(domove); E boolean NDECL(overexertion); E void NDECL(invocation_message); diff --git a/src/do.c b/src/do.c index 6d908be19..ae941c065 100644 --- a/src/do.c +++ b/src/do.c @@ -840,13 +840,7 @@ dodown() (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)), ladder_down = (u.ux == xdnladder && u.uy == ydnladder); - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return 1; - } + if (u_rooted()) return 1; if (stucksteed(TRUE)) { return 0; diff --git a/src/hack.c b/src/hack.c index cde81937f..ea2a0b3c8 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1111,6 +1111,19 @@ struct trap *desttrap; /* nonnull if another trap at */ return FALSE; } +boolean +u_rooted() +{ + if(!youmonst.data->mmove) { + You("are rooted %s.", + Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? + "in place" : "to the ground"); + nomul(0); + return TRUE; + } + return FALSE; +} + void domove() { @@ -1414,13 +1427,9 @@ domove() nomul(0); return; } - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return; - } + + if (u_rooted()) return; + if(u.utrap) { if (!trapmove(x, y, trap)) return; }