#ifndef _UTIL_H_e07286a3_ #define _UTIL_H_e07286a3_ /* * APIs exported by util.c. Assorted utility routines that didn't seem * to me to fall into other categories. */ #include "structs.h" /* * Always returns false, and has the calling signature of an object ops * `collapsible' function. */ extern int never_collapsible(OBJ *, OBJ *); /* * Always returns false, and has the calling signature of an object ops * `identical' function. */ extern int never_identical(OBJ *, OBJ *); /* * Returns the square of the (Euclidean) distance between two cells on * the same level. This knows about LVF_WRAPAROUND. This panics if * handed LOCs that aren't on the same level. */ extern int distance2(LOC *, LOC *); /* * Returns the L-infinity distance between two cells on the same level, * that is, the larger of the difference in X coordinates and the * difference in Y coordinates. This knows about LVF_WRAPAROUND. * This panics if handed LOCs that aren't on the same level. */ extern int distancei(LOC *, LOC *); /* * Return true iff the argument is a vowel. This is specific to ASCII * and English...but so is much of the rest of the game. */ extern int vowel(char); /* * movecell(c,dx,dy,wrap) moves a distance (dx,dy) from c, returning * the cell reached. If wrap is true or if the level has * LVF_WRAPAROUND set, the delta can wrap. Panics if asked to move * off the edge of a level when not wrapping. */ extern LOC *movecell(LOC *, int, int, int); /* * dirkey(key,dxp,dyp,dxyp,oflagsp,iflags) takes key as a motion * command (one of hjklyubn, possibly uppercase or control-modified) * and some flags. iflags can include zero or more of DK_NOCTL and * DK_NOCAPS; these suppress recognition of, respectively, * control-modified and uppercase motion commands. If key is a valid * motion command, taking iflags into account, then up to four things * are written through the remaining arguments: the corresponding X * delta through dxp, the Y delta through dyp, both deltas as an XY * through dxyp, and a flags value with 0, DK_CTL, or DK_CAPS through * oflagsp. If any of these last four are nil, that write is skipped. */ extern int dirkey(int, int *, int *, XY *, int *, int); #define DK_CTL 0x00000001 #define DK_CAPS 0x00000002 #define DK_NOCTL 0x00000004 #define DK_NOCAPS 0x00000008 /* * These take an (X,Y) delta and rotate it clockwise 90° (turn_r), * counterclockwise 90° (turn_l), clockwise 45° (turn_r45), or * counterclockwise 45° (turn_l45). The 45° turns, of course, switch * between both-coordinate steps and single-coordinate steps, meaning * their Euclidean length switches betwen 1 and sqrt(2). */ extern XY turn_r(XY); extern XY turn_l(XY); extern XY turn_r45(XY); extern XY turn_l45(XY); /* * This returns its second or third argument depending on whether the * monster is the player avatar (second arg) or not (third arg). */ extern const char *pickverb(MONST *, const char *, const char *); #endif