From: nethack.rankin Date: Sun, 16 Jan 2011 01:29:18 +0000 (+0000) Subject: thrownobj, kick[ed]obj (trunk only) X-Git-Tag: MOVE2GIT~273 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=363163b0c3d0b6145e2ec3ce94f67f15198e2b95;p=nethack thrownobj, kick[ed]obj (trunk only) Rename ``kickobj'' to ``kickedobj'' so that the tense matches that of ``thrownobj''. Also, move their declarations to decl.h and their definitions to decl.c since usage has spread from dokick.c/dothrow.c to various files and is about to expand to another one. --- diff --git a/include/decl.h b/include/decl.h index 021fa51f3..48043ceaf 100644 --- a/include/decl.h +++ b/include/decl.h @@ -244,7 +244,8 @@ E NEARDATA struct obj *uchain; /* defined only when punished */ E NEARDATA struct obj *uball; E NEARDATA struct obj *migrating_objs; E NEARDATA struct obj *billobjs; -E NEARDATA struct obj *current_wand; +E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj; + E NEARDATA struct obj zeroobj; /* init'd and defined in decl.c */ E NEARDATA anything zeroany; /* init'd and defined in decl.c */ diff --git a/src/decl.c b/src/decl.c index 7009b5da1..6657ea9c5 100644 --- a/src/decl.c +++ b/src/decl.c @@ -162,7 +162,11 @@ NEARDATA struct obj *invent = (struct obj *)0, *ublindf = (struct obj *)0, *uchain = (struct obj *)0, *uball = (struct obj *)0; -NEARDATA struct obj *current_wand = 0; /* wand currently zapped/applied */ +/* some objects need special handling during destruction or placement */ +NEARDATA struct obj + *current_wand = 0, /* wand currently zapped/applied */ + *thrownobj = 0, /* object in flight due to throwing */ + *kickedobj = 0; /* object in flight due to kicking */ #ifdef TEXTCOLOR /* diff --git a/src/dokick.c b/src/dokick.c index dc10164ed..0d4babd3a 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,5 +1,4 @@ /* NetHack 3.5 dokick.c $Date$ $Revision$ */ -/* SCCS Id: @(#)dokick.c 3.5 2008/09/04 */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -12,7 +11,7 @@ static NEARDATA struct rm *maploc, nowhere; static NEARDATA const char *gate_str; -struct obj *kickobj; /* also used by obfree(shk.c) */ +/* kickedobj (decl.c) tracks a kicked object until placed or destroyed */ extern boolean notonhead; /* for long worms */ @@ -418,11 +417,11 @@ xchar x, y; int res = 0; /* if a pile, the "top" object gets kicked */ - kickobj = level.objects[x][y]; - if (kickobj) { - /* kick the object; if doing is fatal, done() will clean up kickobj */ + kickedobj = level.objects[x][y]; + if (kickedobj) { + /* kick object; if doing is fatal, done() will clean up kickedobj */ res = really_kick_object(x, y); - kickobj = (struct obj *)0; + kickedobj = (struct obj *)0; } return res; } @@ -438,10 +437,10 @@ xchar x, y; char bhitroom; boolean costly, isgold, slide = FALSE; - /* kickobj should always be set due to conditions of call */ - if(!kickobj || kickobj->otyp == BOULDER - || kickobj == uball || kickobj == uchain) - return(0); + /* kickedobj should always be set due to conditions of call */ + if (!kickedobj || kickedobj->otyp == BOULDER || + kickedobj == uball || kickedobj == uchain) + return 0; if ((trap = t_at(x,y)) != 0 && (((trap->ttyp == PIT || @@ -459,25 +458,25 @@ xchar x, y; return(1); } - if (!uarmf && kickobj->otyp == CORPSE && - touch_petrifies(&mons[kickobj->corpsenm]) && + if (!uarmf && kickedobj->otyp == CORPSE && + touch_petrifies(&mons[kickedobj->corpsenm]) && !Stone_resistance) { You("kick %s with your bare %s.", - corpse_xname(kickobj, (const char *)0, CXN_PFX_THE), + corpse_xname(kickedobj, (const char *)0, CXN_PFX_THE), makeplural(body_part(FOOT))); if (poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM)) { ; /* hero has been transformed but kick continues */ } else { /* normalize body shape here; foot, not body_part(FOOT) */ Sprintf(killer.name, "kicking %s barefoot", - killer_xname(kickobj)); + killer_xname(kickedobj)); instapetrify(killer.name); } } /* range < 2 means the object will not move. */ /* maybe dexterity should also figure here. */ - range = (int)((ACURRSTR)/2 - kickobj->owt/40); + range = (int)((ACURRSTR) / 2 - kickedobj->owt / 40); if(martial()) range += rnd(3); @@ -489,20 +488,20 @@ xchar x, y; range += rnd(3); } else { if (is_ice(x, y)) range += rnd(3), slide = TRUE; - if (kickobj->greased) range += rnd(3), slide = TRUE; + if (kickedobj->greased) range += rnd(3), slide = TRUE; } /* Mjollnir is magically too heavy to kick */ - if(kickobj->oartifact == ART_MJOLLNIR) range = 1; + if (kickedobj->oartifact == ART_MJOLLNIR) range = 1; /* see if the object has a place to move into */ if(!ZAP_POS(levl[x+u.dx][y+u.dy].typ) || closed_door(x+u.dx, y+u.dy)) range = 1; - costly = (!(kickobj->no_charge && !Has_contents(kickobj)) && + costly = (!(kickedobj->no_charge && !Has_contents(kickedobj)) && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0 && costly_spot(x, y)); - isgold = (kickobj->oclass == COIN_CLASS); + isgold = (kickedobj->oclass == COIN_CLASS); if (IS_ROCK(levl[x][y].typ) || closed_door(x, y)) { if ((!martial() && rn2(20) > ACURR(A_DEX)) || @@ -511,49 +510,47 @@ xchar x, y; pline("It doesn't come loose."); else pline("%s %sn't come loose.", - The(distant_name(kickobj, xname)), - otense(kickobj, "do")); + The(distant_name(kickedobj, xname)), + otense(kickedobj, "do")); return (!rn2(3) || martial()); } if (Blind) pline("It comes loose."); else pline("%s %s loose.", - The(distant_name(kickobj, xname)), - otense(kickobj, "come")); - obj_extract_self(kickobj); + The(distant_name(kickedobj, xname)), + otense(kickedobj, "come")); + obj_extract_self(kickedobj); newsym(x, y); if (costly && (!costly_spot(u.ux, u.uy) || !index(u.urooms, *in_rooms(x, y, SHOPBASE)))) - addtobill(kickobj, FALSE, FALSE, FALSE); - if (!flooreffects(kickobj, u.ux, u.uy, "fall")) { - place_object(kickobj, u.ux, u.uy); - stackobj(kickobj); + addtobill(kickedobj, FALSE, FALSE, FALSE); + if (!flooreffects(kickedobj, u.ux, u.uy, "fall")) { + place_object(kickedobj, u.ux, u.uy); + stackobj(kickedobj); newsym(u.ux, u.uy); } return 1; } /* a box gets a chance of breaking open here */ - if(Is_box(kickobj)) { - boolean otrp = kickobj->otrapped; + if (Is_box(kickedobj)) { + boolean otrp = kickedobj->otrapped; - if(range < 2) pline("THUD!"); - - container_impact_dmg(kickobj); - - if (kickobj->olocked) { + if (range < 2) pline("THUD!"); + container_impact_dmg(kickedobj); + if (kickedobj->olocked) { if (!rn2(5) || (martial() && !rn2(2))) { You("break open the lock!"); - breakchestlock(kickobj, FALSE); - if (otrp) (void) chest_trap(kickobj, LEG, FALSE); + breakchestlock(kickedobj, FALSE); + if (otrp) (void) chest_trap(kickedobj, LEG, FALSE); return(1); } } else { if (!rn2(3) || (martial() && !rn2(2))) { pline_The("lid slams open, then falls shut."); - kickobj->lknown = 1; - if (otrp) (void) chest_trap(kickobj, LEG, FALSE); + kickedobj->lknown = 1; + if (otrp) (void) chest_trap(kickedobj, LEG, FALSE); return(1); } } @@ -562,20 +559,21 @@ xchar x, y; } /* fragile objects should not be kicked */ - if (hero_breaks(kickobj, kickobj->ox, kickobj->oy, FALSE)) return 1; + if (hero_breaks(kickedobj, kickedobj->ox, kickedobj->oy, FALSE)) + return 1; /* too heavy to move. range is calculated as potential distance from * player, so range == 2 means the object may move up to one square * from its current position */ - if(range < 2) { - if(!Is_box(kickobj)) pline("Thump!"); - return(!rn2(3) || martial()); + if (range < 2) { + if (!Is_box(kickedobj)) pline("Thump!"); + return (!rn2(3) || martial()); } - if (kickobj->quan > 1L) { + if (kickedobj->quan > 1L) { if (!isgold) { - kickobj = splitobj(kickobj, 1L); + kickedobj = splitobj(kickedobj, 1L); } else { if (rn2(20)) { static NEARDATA const char * const flyingcoinmsg[] = { @@ -587,11 +585,11 @@ xchar x, y; pline("Thwwpingg!"); You("%s!", flyingcoinmsg[rn2(SIZE(flyingcoinmsg))]); (void)scatter(x, y, rn2(3)+1, - VIS_EFFECTS|MAY_HIT, kickobj); + VIS_EFFECTS|MAY_HIT, kickedobj); newsym(x, y); return 1; } - if (kickobj->quan > 300L) { + if (kickedobj->quan > 300L) { pline("Thump!"); return(!rn2(3) || martial()); } @@ -599,47 +597,48 @@ xchar x, y; } if (slide && !Blind) - pline("Whee! %s %s across the %s.", Doname2(kickobj), - otense(kickobj, "slide"), surface(x,y)); + pline("Whee! %s %s across the %s.", Doname2(kickedobj), + otense(kickedobj, "slide"), surface(x,y)); - if (costly && !isgold) addtobill(kickobj, FALSE, FALSE, TRUE); - obj_extract_self(kickobj); - (void) snuff_candle(kickobj); + if (costly && !isgold) addtobill(kickedobj, FALSE, FALSE, TRUE); + obj_extract_self(kickedobj); + (void) snuff_candle(kickedobj); newsym(x, y); mon = bhit(u.dx, u.dy, range, KICKED_WEAPON, (int FDECL((*),(MONST_P,OBJ_P)))0, (int FDECL((*),(OBJ_P,OBJ_P)))0, - &kickobj); - if (!kickobj) return 1; /* object broken */ + &kickedobj); + if (!kickedobj) return 1; /* object broken */ - if(mon) { + if (mon) { if (mon->isshk && - kickobj->where == OBJ_MINVENT && kickobj->ocarry == mon) + kickedobj->where == OBJ_MINVENT && + kickedobj->ocarry == mon) return 1; /* alert shk caught it */ notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); - if (isgold ? ghitm(mon, kickobj) : /* caught? */ - thitmonst(mon, kickobj)) /* hit && used up? */ + if (isgold ? ghitm(mon, kickedobj) : /* caught? */ + thitmonst(mon, kickedobj)) /* hit && used up? */ return(1); } /* the object might have fallen down a hole; ship_object() will have taken care of shop billing */ - if (kickobj->where == OBJ_MIGRATING) return 1; + if (kickedobj->where == OBJ_MIGRATING) return 1; bhitroom = *in_rooms(bhitpos.x, bhitpos.y, SHOPBASE); if (costly && (!costly_spot(bhitpos.x, bhitpos.y) || *in_rooms(x, y, SHOPBASE) != bhitroom)) { if(isgold) - costly_gold(x, y, kickobj->quan); - else (void)stolen_value(kickobj, x, y, + costly_gold(x, y, kickedobj->quan); + else (void)stolen_value(kickedobj, x, y, (boolean)shkp->mpeaceful, FALSE); } - if(flooreffects(kickobj,bhitpos.x,bhitpos.y,"fall")) return(1); - if (kickobj->unpaid) subfrombill(kickobj, shkp); - place_object(kickobj, bhitpos.x, bhitpos.y); - stackobj(kickobj); - newsym(kickobj->ox, kickobj->oy); + if (flooreffects(kickedobj, bhitpos.x, bhitpos.y, "fall")) return 1; + if (kickedobj->unpaid) subfrombill(kickedobj, shkp); + place_object(kickedobj, bhitpos.x, bhitpos.y); + stackobj(kickedobj); + newsym(kickedobj->ox, kickedobj->oy); return(1); } @@ -650,7 +649,7 @@ char *buf; { const char *what; - if (kickobj) what = killer_xname(kickobj); + if (kickedobj) what = killer_xname(kickedobj); else if (maploc == &nowhere) what = "nothing"; else if (IS_DOOR(maploc->typ)) what = "a door"; else if (IS_TREE(maploc->typ)) what = "a tree"; diff --git a/src/dothrow.c b/src/dothrow.c index fc7af5735..ad5c6a674 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -26,9 +26,8 @@ static NEARDATA const char toss_objs[] = static NEARDATA const char bullets[] = { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, GEM_CLASS, 0 }; -struct obj *thrownobj = 0; /* tracks an object until it lands */ +/* thrownobj (decl.c) tracks an object until it lands */ -extern struct obj *kickobj; /* from dokick.c */ extern boolean notonhead; /* for long worms */ @@ -1265,7 +1264,7 @@ boolean maybe_wakeup; int thitmonst(mon, obj) register struct monst *mon; -register struct obj *obj; /* thrownobj or kickobj or uwep */ +register struct obj *obj; /* thrownobj or kickedobj or uwep */ { register int tmp; /* Base chance to hit */ register int disttmp; /* distance modifier */ @@ -1273,7 +1272,7 @@ register struct obj *obj; /* thrownobj or kickobj or uwep */ boolean guaranteed_hit = (u.uswallow && mon == u.ustuck); hmode = (obj == uwep) ? HMON_APPLIED : - (obj == kickobj) ? HMON_KICKED : HMON_THROWN; + (obj == kickedobj) ? HMON_KICKED : HMON_THROWN; /* Differences from melee weapons: * diff --git a/src/end.c b/src/end.c index 64e05024d..8b51e9e4c 100644 --- a/src/end.c +++ b/src/end.c @@ -21,9 +21,6 @@ #define FIRST_AMULET AMULET_OF_ESP #define LAST_AMULET AMULET_OF_YENDOR -extern struct obj *thrownobj; /* dothrow.c */ -extern struct obj *kickobj; /* dokick.c */ - struct valuable_data { long count; int typ; }; static struct valuable_data @@ -893,7 +890,7 @@ die: /* maybe not on object lists; if an active light source, would cause big trouble (`obj_is_local' panic) for savebones() -> savelev() */ if (thrownobj && thrownobj->where == OBJ_FREE) dealloc_obj(thrownobj); - if (kickobj && kickobj->where == OBJ_FREE) dealloc_obj(kickobj); + if (kickedobj && kickedobj->where == OBJ_FREE) dealloc_obj(kickedobj); /* Sometimes you die on the first move. Life's not fair. * On those rare occasions you get hosed immediately, go out diff --git a/src/mkobj.c b/src/mkobj.c index a6a1b888f..428d0c073 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,5 +1,4 @@ /* NetHack 3.5 mkobj.c $Date$ $Revision$ */ -/* SCCS Id: @(#)mkobj.c 3.5 2009/01/20 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -19,9 +18,6 @@ STATIC_DCL void FDECL(insane_object, STATIC_DCL void FDECL(check_contained, (struct obj *,const char *)); #endif -extern struct obj *thrownobj; /* defined in dothrow.c */ -extern struct obj *kickobj; /* dokick.c */ - /*#define DEBUG_EFFECTS*/ /* show some messages for debugging */ struct icp { @@ -1871,7 +1867,7 @@ dealloc_obj(obj) del_light_source(LS_OBJECT, obj_to_any(obj)); if (obj == thrownobj) thrownobj = 0; - if (obj == kickobj) kickobj = 0; + if (obj == kickedobj) kickedobj = 0; if (obj->oextra) dealloc_oextra(obj->oextra); free((genericptr_t) obj); @@ -2003,8 +1999,8 @@ obj_sanity_check() they should have arrived somewhere by the time we get called */ if (thrownobj) insane_object(thrownobj, ofmt3, "thrownobj sanity", (struct monst *)0); - if (kickobj) - insane_object(kickobj, ofmt3, "kickobj sanity", (struct monst *)0); + if (kickedobj) + insane_object(kickedobj, ofmt3, "kickedobj sanity", (struct monst *)0); /* [how about current_wand too?] */ } diff --git a/src/mon.c b/src/mon.c index 0c7cdf147..12a6ebaed 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,5 +1,4 @@ /* NetHack 3.5 mon.c $Date$ $Revision$ */ -/* SCCS Id: @(#)mon.c 3.5 2009/01/24 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -12,8 +11,6 @@ #include "mfndpos.h" #include -extern struct obj *thrownobj; /* dothrow.c */ - STATIC_DCL boolean FDECL(restrap,(struct monst *)); STATIC_DCL long FDECL(mm_aggression, (struct monst *,struct monst *)); #ifdef BARGETHROUGH diff --git a/src/shk.c b/src/shk.c index 4e625e34e..cf24d3753 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,5 +1,4 @@ /* NetHack 3.5 shk.c $Date$ $Revision$ */ -/* SCCS Id: @(#)shk.c 3.5 2007/03/01 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -27,8 +26,6 @@ STATIC_DCL void FDECL(kops_gone, (BOOLEAN_P)); (shkp)->data->msound <= MS_ANIMAL) extern const struct shclass shtypes[]; /* defined in shknam.c */ -extern struct obj *thrownobj; /* defined in dothrow.c */ -extern struct obj *kickobj; /* dokick.c */ STATIC_VAR NEARDATA long int followmsg; /* last time of follow message */ STATIC_VAR const char and_its_contents[] = " and its contents"; @@ -281,7 +278,7 @@ register struct monst *shkp; clear_unpaid(fobj); clear_unpaid(level.buriedobjlist); if (thrownobj) thrownobj->unpaid = 0; - if (kickobj) kickobj->unpaid = 0; + if (kickedobj) kickedobj->unpaid = 0; for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) clear_unpaid(mtmp->minvent); for(mtmp = migrating_mons; mtmp; mtmp = mtmp->nmon)