#endif
#define plur(x) (((x) == 1) ? "" : "s")
+/* Cast to int, but limit value to range. */
+#define LIMIT_TO_RANGE_INT(lo, hi, var) \
+ (int) ( \
+ (var) < (lo) ? (lo) : ( \
+ (var) > (hi) ? (hi) : \
+ (var) \
+ ) \
+ )
+
#define ARM_BONUS(obj) \
(objects[(obj)->otyp].a_ac + (obj)->spe \
- min((int) greatest_erosion(obj), objects[(obj)->otyp].a_ac))
thesimpleoname(otmp));
} else {
buf[0] = '\0'; /* silently stop doffing stolenobj */
- result = -g.multi; /* remember this before calling unmul() */
+ result = (int) -g.multi; /* remember this before calling unmul() */
}
unmul(buf);
/* while putting on, item becomes worn immediately but side-effects are
static boolean
ok_to_throw(int *shotlimit_p) /* (see dothrow()) */
{
- *shotlimit_p = g.command_count;
+ *shotlimit_p = LIMIT_TO_RANGE_INT(0, LARGEST_INT, g.command_count);
g.multi = 0; /* reset; it's been used up */
if (notake(g.youmonst.data)) {
{
int count, tmpcount, ret;
- count = g.command_count;
+ count = (int) g.command_count;
g.multi = 0; /* always reset */
if ((ret = pickup_checks()) >= 0) {
char *bufp = str;
char *tmpp;
- d->quan = 1 + ((g.multi > 0) ? g.multi : 0);
+ d->quan = 1 + ((g.multi > 0) ? (int) g.multi : 0);
d->monclass = MAXMCLASSES;
d->which = g.urole.mnum; /* an arbitrary index into mons[] */
d->fem = -1; /* gender not specified */