minetown guards outside the town proper

Pat forwarded a message from the newsgroup in March that the town guards
enforce rules even outside the town proper.  Fix: On room-based town levels,
check if the location is in a room containing subrooms (roomno will often
have a subroom id instead).  On the other levels (e.g. minetn-5), there are
no subrooms, so the whole level is fair game.  Currently, this is valid.
If fancier towns are added in the future, more flags or use of regions may
be required to tell where the town border actually is.  These checks are done
in a new in_town function.
This commit is contained in:
cohrs
2002-07-15 04:17:13 +00:00
parent b440613866
commit a21ddbb2bf
7 changed files with 34 additions and 13 deletions

View File

@@ -1576,6 +1576,31 @@ register int typewanted;
return(ptr);
}
/* is (x,y) in a town? */
boolean
in_town(x, y)
register int x, y;
{
s_level *slev = Is_special(&u.uz);
register struct mkroom *sroom;
boolean has_subrooms = FALSE;
if (!slev || !slev->flags.town) return FALSE;
/*
* See if (x,y) is in a room with subrooms, if so, assume it's the
* town. If there are no subrooms, the whole level is in town.
*/
for (sroom = &rooms[0]; sroom->hx > 0; sroom++) {
if (sroom->nsubrooms > 0) {
has_subrooms = TRUE;
if (inside_room(sroom, x, y)) return TRUE;
}
}
return !has_subrooms;
}
STATIC_OVL void
move_update(newlev)
register boolean newlev;