switch source tree from k&r to c99
This commit is contained in:
172
src/dothrow.c
172
src/dothrow.c
@@ -7,27 +7,24 @@
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
static int FDECL(throw_obj, (struct obj *, int));
|
||||
static boolean FDECL(ok_to_throw, (int *));
|
||||
static int FDECL(throw_ok, (struct obj *));
|
||||
static void NDECL(autoquiver);
|
||||
static int FDECL(gem_accept, (struct monst *, struct obj *));
|
||||
static void FDECL(tmiss, (struct obj *, struct monst *, BOOLEAN_P));
|
||||
static int FDECL(throw_gold, (struct obj *));
|
||||
static void FDECL(check_shop_obj, (struct obj *, XCHAR_P, XCHAR_P,
|
||||
BOOLEAN_P));
|
||||
static void FDECL(breakmsg, (struct obj *, BOOLEAN_P));
|
||||
static boolean FDECL(toss_up, (struct obj *, BOOLEAN_P));
|
||||
static void FDECL(sho_obj_return_to_u, (struct obj * obj));
|
||||
static boolean FDECL(mhurtle_step, (genericptr_t, int, int));
|
||||
static int throw_obj(struct obj *, int);
|
||||
static boolean ok_to_throw(int *);
|
||||
static int throw_ok(struct obj *);
|
||||
static void autoquiver(void);
|
||||
static int gem_accept(struct monst *, struct obj *);
|
||||
static void tmiss(struct obj *, struct monst *, boolean);
|
||||
static int throw_gold(struct obj *);
|
||||
static void check_shop_obj(struct obj *, xchar, xchar, boolean);
|
||||
static void breakmsg(struct obj *, boolean);
|
||||
static boolean toss_up(struct obj *, boolean);
|
||||
static void sho_obj_return_to_u(struct obj * obj);
|
||||
static boolean mhurtle_step(genericptr_t, int, int);
|
||||
|
||||
/* g.thrownobj (decl.c) tracks an object until it lands */
|
||||
|
||||
int
|
||||
multishot_class_bonus(pm, ammo, launcher)
|
||||
int pm;
|
||||
struct obj *ammo;
|
||||
struct obj *launcher; /* can be NULL */
|
||||
multishot_class_bonus(int pm, struct obj *ammo,
|
||||
struct obj *launcher) /* can be NULL */
|
||||
{
|
||||
int multishot = 0;
|
||||
schar skill = objects[ammo->otyp].oc_skill;
|
||||
@@ -71,9 +68,7 @@ struct obj *launcher; /* can be NULL */
|
||||
|
||||
/* Throw the selected object, asking for direction */
|
||||
static int
|
||||
throw_obj(obj, shotlimit)
|
||||
struct obj *obj;
|
||||
int shotlimit;
|
||||
throw_obj(struct obj *obj, int shotlimit)
|
||||
{
|
||||
struct obj *otmp, *oldslot;
|
||||
int multishot;
|
||||
@@ -249,8 +244,7 @@ int shotlimit;
|
||||
|
||||
/* common to dothrow() and dofire() */
|
||||
static boolean
|
||||
ok_to_throw(shotlimit_p)
|
||||
int *shotlimit_p; /* (see dothrow()) */
|
||||
ok_to_throw(int *shotlimit_p) /* (see dothrow()) */
|
||||
{
|
||||
/* kludge to work around parse()'s pre-decrement of `multi' */
|
||||
*shotlimit_p = (g.multi || g.save_cm) ? g.multi + 1 : 0;
|
||||
@@ -271,8 +265,7 @@ int *shotlimit_p; /* (see dothrow()) */
|
||||
|
||||
/* getobj callback for object to be thrown */
|
||||
static int
|
||||
throw_ok(obj)
|
||||
struct obj *obj;
|
||||
throw_ok(struct obj *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return GETOBJ_EXCLUDE;
|
||||
@@ -301,7 +294,7 @@ struct obj *obj;
|
||||
|
||||
/* t command - throw */
|
||||
int
|
||||
dothrow()
|
||||
dothrow(void)
|
||||
{
|
||||
register struct obj *obj;
|
||||
int shotlimit;
|
||||
@@ -330,7 +323,7 @@ dothrow()
|
||||
/* KMH -- Automatically fill quiver */
|
||||
/* Suggested by Jeffrey Bay <jbay@convex.hp.com> */
|
||||
static void
|
||||
autoquiver()
|
||||
autoquiver(void)
|
||||
{
|
||||
struct obj *otmp, *oammo = 0, *omissile = 0, *omisc = 0, *altammo = 0;
|
||||
|
||||
@@ -393,7 +386,7 @@ autoquiver()
|
||||
|
||||
/* f command -- fire: throw from the quiver */
|
||||
int
|
||||
dofire()
|
||||
dofire(void)
|
||||
{
|
||||
int shotlimit;
|
||||
struct obj *obj;
|
||||
@@ -450,8 +443,7 @@ dofire()
|
||||
|
||||
/* if in midst of multishot shooting/throwing, stop early */
|
||||
void
|
||||
endmultishot(verbose)
|
||||
boolean verbose;
|
||||
endmultishot(boolean verbose)
|
||||
{
|
||||
if (g.m_shot.i < g.m_shot.n) {
|
||||
if (verbose && !g.context.mon_moving) {
|
||||
@@ -467,9 +459,9 @@ boolean verbose;
|
||||
/* Object hits floor at hero's feet.
|
||||
Called from drop(), throwit(), hold_another_object(), litter(). */
|
||||
void
|
||||
hitfloor(obj, verbosely)
|
||||
struct obj *obj;
|
||||
boolean verbosely; /* usually True; False if caller has given drop message */
|
||||
hitfloor(struct obj *obj,
|
||||
boolean verbosely) /* usually True; False if caller has given
|
||||
drop message */
|
||||
{
|
||||
if (IS_SOFT(levl[u.ux][u.uy].typ) || u.uinwater || u.uswallow) {
|
||||
dropy(obj);
|
||||
@@ -516,11 +508,9 @@ boolean verbosely; /* usually True; False if caller has given drop message */
|
||||
* before the failed callback.
|
||||
*/
|
||||
boolean
|
||||
walk_path(src_cc, dest_cc, check_proc, arg)
|
||||
coord *src_cc;
|
||||
coord *dest_cc;
|
||||
boolean FDECL((*check_proc), (genericptr_t, int, int));
|
||||
genericptr_t arg;
|
||||
walk_path(coord *src_cc, coord *dest_cc,
|
||||
boolean (*check_proc)(genericptr_t, int, int),
|
||||
genericptr_t arg)
|
||||
{
|
||||
int x, y, dx, dy, x_change, y_change, err, i, prev_x, prev_y;
|
||||
boolean keep_going = TRUE;
|
||||
@@ -601,9 +591,7 @@ genericptr_t arg;
|
||||
vs drag-to-dest; original callers use first mode, jumping wants second,
|
||||
grappling hook backfire and thrown chained ball need third */
|
||||
boolean
|
||||
hurtle_jump(arg, x, y)
|
||||
genericptr_t arg;
|
||||
int x, y;
|
||||
hurtle_jump(genericptr_t arg, int x, int y)
|
||||
{
|
||||
boolean res;
|
||||
long save_EWwalking = EWwalking;
|
||||
@@ -634,9 +622,7 @@ int x, y;
|
||||
* o let jumps go over boulders
|
||||
*/
|
||||
boolean
|
||||
hurtle_step(arg, x, y)
|
||||
genericptr_t arg;
|
||||
int x, y;
|
||||
hurtle_step(genericptr_t arg, int x, int y)
|
||||
{
|
||||
int ox, oy, *range = (int *) arg;
|
||||
struct obj *obj;
|
||||
@@ -836,9 +822,7 @@ int x, y;
|
||||
}
|
||||
|
||||
static boolean
|
||||
mhurtle_step(arg, x, y)
|
||||
genericptr_t arg;
|
||||
int x, y;
|
||||
mhurtle_step(genericptr_t arg, int x, int y)
|
||||
{
|
||||
struct monst *mon = (struct monst *) arg;
|
||||
|
||||
@@ -865,9 +849,7 @@ int x, y;
|
||||
* kick or throw and be only.
|
||||
*/
|
||||
void
|
||||
hurtle(dx, dy, range, verbose)
|
||||
int dx, dy, range;
|
||||
boolean verbose;
|
||||
hurtle(int dx, int dy, int range, boolean verbose)
|
||||
{
|
||||
coord uc, cc;
|
||||
|
||||
@@ -921,9 +903,7 @@ boolean verbose;
|
||||
|
||||
/* Move a monster through the air for a few squares. */
|
||||
void
|
||||
mhurtle(mon, dx, dy, range)
|
||||
struct monst *mon;
|
||||
int dx, dy, range;
|
||||
mhurtle(struct monst *mon, int dx, int dy, int range)
|
||||
{
|
||||
coord mc, cc;
|
||||
|
||||
@@ -956,10 +936,7 @@ int dx, dy, range;
|
||||
}
|
||||
|
||||
static void
|
||||
check_shop_obj(obj, x, y, broken)
|
||||
struct obj *obj;
|
||||
xchar x, y;
|
||||
boolean broken;
|
||||
check_shop_obj(struct obj *obj, xchar x, xchar y, boolean broken)
|
||||
{
|
||||
boolean costly_xy;
|
||||
struct monst *shkp = shop_keeper(*u.ushops);
|
||||
@@ -1000,9 +977,7 @@ boolean broken;
|
||||
* Returns FALSE if the object is gone.
|
||||
*/
|
||||
static boolean
|
||||
toss_up(obj, hitsroof)
|
||||
struct obj *obj;
|
||||
boolean hitsroof;
|
||||
toss_up(struct obj *obj, boolean hitsroof)
|
||||
{
|
||||
const char *action;
|
||||
boolean petrifier = ((obj->otyp == EGG || obj->otyp == CORPSE)
|
||||
@@ -1129,8 +1104,7 @@ boolean hitsroof;
|
||||
|
||||
/* return true for weapon meant to be thrown; excludes ammo */
|
||||
boolean
|
||||
throwing_weapon(obj)
|
||||
struct obj *obj;
|
||||
throwing_weapon(struct obj *obj)
|
||||
{
|
||||
return (boolean) (is_missile(obj) || is_spear(obj)
|
||||
/* daggers and knife (excludes scalpel) */
|
||||
@@ -1142,8 +1116,7 @@ struct obj *obj;
|
||||
|
||||
/* the currently thrown object is returning to you (not for boomerangs) */
|
||||
static void
|
||||
sho_obj_return_to_u(obj)
|
||||
struct obj *obj;
|
||||
sho_obj_return_to_u(struct obj *obj)
|
||||
{
|
||||
/* might already be our location (bounced off a wall) */
|
||||
if ((u.dx || u.dy) && (g.bhitpos.x != u.ux || g.bhitpos.y != u.uy)) {
|
||||
@@ -1162,11 +1135,11 @@ struct obj *obj;
|
||||
|
||||
/* throw an object, NB: obj may be consumed in the process */
|
||||
void
|
||||
throwit(obj, wep_mask, twoweap, oldslot)
|
||||
struct obj *obj;
|
||||
long wep_mask; /* used to re-equip returning boomerang */
|
||||
boolean twoweap; /* used to restore twoweapon mode if wielded weapon returns */
|
||||
struct obj *oldslot; /* for thrown-and-return used with !fixinv */
|
||||
throwit(struct obj *obj,
|
||||
long wep_mask, /* used to re-equip returning boomerang */
|
||||
boolean twoweap, /* used to restore twoweapon mode if
|
||||
wielded weapon returns */
|
||||
struct obj *oldslot) /* for thrown-and-return used with !fixinv */
|
||||
{
|
||||
register struct monst *mon;
|
||||
int range, urange;
|
||||
@@ -1332,8 +1305,8 @@ struct obj *oldslot; /* for thrown-and-return used with !fixinv */
|
||||
|
||||
mon = bhit(u.dx, u.dy, range,
|
||||
tethered_weapon ? THROWN_TETHERED_WEAPON : THROWN_WEAPON,
|
||||
(int FDECL((*), (MONST_P, OBJ_P))) 0,
|
||||
(int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
|
||||
(int (*)(MONST_P, OBJ_P)) 0,
|
||||
(int (*)(OBJ_P, OBJ_P)) 0, &obj);
|
||||
g.thrownobj = obj; /* obj may be null now */
|
||||
|
||||
/* have to do this after bhit() so u.ux & u.uy are correct */
|
||||
@@ -1516,10 +1489,7 @@ struct obj *oldslot; /* for thrown-and-return used with !fixinv */
|
||||
|
||||
/* an object may hit a monster; various factors adjust chance of hitting */
|
||||
int
|
||||
omon_adj(mon, obj, mon_notices)
|
||||
struct monst *mon;
|
||||
struct obj *obj;
|
||||
boolean mon_notices;
|
||||
omon_adj(struct monst *mon, struct obj *obj, boolean mon_notices)
|
||||
{
|
||||
int tmp = 0;
|
||||
|
||||
@@ -1559,10 +1529,7 @@ boolean mon_notices;
|
||||
|
||||
/* thrown object misses target monster */
|
||||
static void
|
||||
tmiss(obj, mon, maybe_wakeup)
|
||||
struct obj *obj;
|
||||
struct monst *mon;
|
||||
boolean maybe_wakeup;
|
||||
tmiss(struct obj *obj, struct monst *mon, boolean maybe_wakeup)
|
||||
{
|
||||
const char *missile = mshot_xname(obj);
|
||||
|
||||
@@ -1591,9 +1558,8 @@ boolean maybe_wakeup;
|
||||
* Also used for kicked objects and for polearms/grapnel applied at range.
|
||||
*/
|
||||
int
|
||||
thitmonst(mon, obj)
|
||||
register struct monst *mon;
|
||||
register struct obj *obj; /* g.thrownobj or g.kickedobj or uwep */
|
||||
thitmonst(register struct monst *mon,
|
||||
register struct obj *obj) /* g.thrownobj or g.kickedobj or uwep */
|
||||
{
|
||||
register int tmp; /* Base chance to hit */
|
||||
register int disttmp; /* distance modifier */
|
||||
@@ -1876,9 +1842,7 @@ register struct obj *obj; /* g.thrownobj or g.kickedobj or uwep */
|
||||
}
|
||||
|
||||
static int
|
||||
gem_accept(mon, obj)
|
||||
register struct monst *mon;
|
||||
register struct obj *obj;
|
||||
gem_accept(register struct monst *mon, register struct obj *obj)
|
||||
{
|
||||
static NEARDATA const char
|
||||
nogood[] = " is not interested in your junk.",
|
||||
@@ -1986,10 +1950,10 @@ register struct obj *obj;
|
||||
* Return 0 if the object didn't break, 1 if the object broke.
|
||||
*/
|
||||
int
|
||||
hero_breaks(obj, x, y, from_invent)
|
||||
struct obj *obj;
|
||||
xchar x, y; /* object location (ox, oy may not be right) */
|
||||
boolean from_invent; /* thrown or dropped by player; maybe on shop bill */
|
||||
hero_breaks(struct obj *obj,
|
||||
xchar x, xchar y, /* object location (ox, oy may not be right) */
|
||||
boolean from_invent) /* thrown or dropped by player;
|
||||
maybe on shop bill */
|
||||
{
|
||||
boolean in_view = Blind ? FALSE : (from_invent || cansee(x, y));
|
||||
|
||||
@@ -2006,9 +1970,8 @@ boolean from_invent; /* thrown or dropped by player; maybe on shop bill */
|
||||
* Return 0 if the object doesn't break, 1 if the object broke.
|
||||
*/
|
||||
int
|
||||
breaks(obj, x, y)
|
||||
struct obj *obj;
|
||||
xchar x, y; /* object location (ox, oy may not be right) */
|
||||
breaks(struct obj *obj,
|
||||
xchar x, xchar y) /* object location (ox, oy may not be right) */
|
||||
{
|
||||
boolean in_view = Blind ? FALSE : cansee(x, y);
|
||||
|
||||
@@ -2020,9 +1983,7 @@ xchar x, y; /* object location (ox, oy may not be right) */
|
||||
}
|
||||
|
||||
void
|
||||
release_camera_demon(obj, x, y)
|
||||
struct obj *obj;
|
||||
xchar x, y;
|
||||
release_camera_demon(struct obj *obj, xchar x, xchar y)
|
||||
{
|
||||
struct monst *mtmp;
|
||||
if (!rn2(3)
|
||||
@@ -2042,11 +2003,10 @@ xchar x, y;
|
||||
* and break messages have been delivered prior to getting here.
|
||||
*/
|
||||
void
|
||||
breakobj(obj, x, y, hero_caused, from_invent)
|
||||
struct obj *obj;
|
||||
xchar x, y; /* object location (ox, oy may not be right) */
|
||||
boolean hero_caused; /* is this the hero's fault? */
|
||||
boolean from_invent;
|
||||
breakobj(struct obj *obj,
|
||||
xchar x, xchar y, /* object location (ox, oy may not be right) */
|
||||
boolean hero_caused, /* is this the hero's fault? */
|
||||
boolean from_invent)
|
||||
{
|
||||
boolean fracture = FALSE;
|
||||
|
||||
@@ -2132,8 +2092,7 @@ boolean from_invent;
|
||||
* Return 0 if the object isn't going to break, 1 if it is.
|
||||
*/
|
||||
boolean
|
||||
breaktest(obj)
|
||||
struct obj *obj;
|
||||
breaktest(struct obj *obj)
|
||||
{
|
||||
if (obj_resists(obj, 1, 99))
|
||||
return 0;
|
||||
@@ -2155,9 +2114,7 @@ struct obj *obj;
|
||||
}
|
||||
|
||||
static void
|
||||
breakmsg(obj, in_view)
|
||||
struct obj *obj;
|
||||
boolean in_view;
|
||||
breakmsg(struct obj *obj, boolean in_view)
|
||||
{
|
||||
const char *to_pieces;
|
||||
|
||||
@@ -2197,8 +2154,7 @@ boolean in_view;
|
||||
}
|
||||
|
||||
static int
|
||||
throw_gold(obj)
|
||||
struct obj *obj;
|
||||
throw_gold(struct obj *obj)
|
||||
{
|
||||
int range, odx, ody;
|
||||
register struct monst *mon;
|
||||
@@ -2240,8 +2196,8 @@ struct obj *obj;
|
||||
g.bhitpos.y = u.uy;
|
||||
} else {
|
||||
mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
|
||||
(int FDECL((*), (MONST_P, OBJ_P))) 0,
|
||||
(int FDECL((*), (OBJ_P, OBJ_P))) 0, &obj);
|
||||
(int (*)(MONST_P, OBJ_P)) 0,
|
||||
(int (*)(OBJ_P, OBJ_P)) 0, &obj);
|
||||
if (!obj)
|
||||
return 1; /* object is gone */
|
||||
if (mon) {
|
||||
|
||||
Reference in New Issue
Block a user