diff --git a/DEVEL/code_features.txt b/DEVEL/code_features.txt index 414a51dbf..d771f7cec 100644 --- a/DEVEL/code_features.txt +++ b/DEVEL/code_features.txt @@ -7,7 +7,7 @@ rationale, etc. ============================================== FEATURE_NOTICE Alerts for a Release -There is a code mechanism for alterting players to a change in behavior +There is a code mechanism for alerting players to a change in behavior over prior versions of the game. Here's how to do it: diff --git a/Files b/Files index 756fcfb7a..b898e19e4 100644 --- a/Files +++ b/Files @@ -1,4 +1,4 @@ -This is a listing of all files in a full NetHack 3.5 distribution, organized +This is a listing of all files in a full NetHack 3.6 distribution, organized in their standard manner on a UNIX system. It indicates which files are necessary for which versions, so that you can tell which files may be deleted from or not transferred to your system if you wish. @@ -17,7 +17,8 @@ cmdhelp data.base dungeon.def endgame.des gehennom.des help hh history knox.des license medusa.des mines.des opthelp oracle.des oracles.txt quest.txt rumors.fal rumors.tru sokoban.des symbols -tower.des wizhelp yendor.des +tower.des wizhelp yendor.des tribute bogusmon.txt +engrave.txt epitaph.txt doc: (files for all versions) @@ -265,8 +266,8 @@ petmark.uu resource.h rip.uu splash.uu tiles.mak winMS.h winhack.c winhack.rc (files for Visual Studio 2010 Express Edition builds) dgncomp.vcxproj dgnstuff.vcxproj dgnstuff.mak dlb_main.vcxproj levcomp.vcxproj -levstuff.vcxproj levstuff.mak makedefs.vcxproj nethack.sln uudecode.vcxproj -nethackw.vcxproj tile2bmp.vcxproj recover.vcxproj tilemap.vcxproj tiles.vcxproj +levstuff.vcxproj levstuff.mak makedefs.vcxproj NetHack.sln uudecode.vcxproj +NetHackW.vcxproj tile2bmp.vcxproj recover.vcxproj tilemap.vcxproj tiles.vcxproj This is a list of files produced by auxiliary programs. They can all be regenerated from the files in the distribution. diff --git a/dat/history b/dat/history index 060982446..efe565f7b 100644 --- a/dat/history +++ b/dat/history @@ -186,8 +186,8 @@ as well as maintaining the X11 interface. Ken Lorber, Haoyang Wang, Pat Rankin, and Dean Luick maintained the port of NetHack 3.6.0 for Mac. -Michael Allison, Derek S. Ray, Yitzhak Sapir, Alex Kompel, and David Cohrs -maintained the port of NetHack 3.6.0 for Microsoft Windows. +Michael Allison, Derek S. Ray, Yitzhak Sapir, Alex Kompel, Dion Nicolaas, +and David Cohrs maintained the port of NetHack 3.6.0 for Microsoft Windows. Jeff Bailey created and maintained a port of NetHack 3.6.0 for Chrome. diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 66b27f5bf..a62cfd02a 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -6,7 +6,7 @@ .ds vr "NetHack 3.6 .ds f0 "\*(vr .ds f1 -.ds f2 "March 27, 2015 +.ds f2 "April 12, 2015 .\" labeled paragraph start (should be part of tmac.n, but I don't want to .\" make changes to that file) .\" .PS word @@ -3007,6 +3007,9 @@ A string explaining how to recover a game on this system (no default value). SEDUCE 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source for details on this function). +.lp +CHECK_SAVE_UID +0 or 1 to disable or enable, respectively, the UID checking for savefiles. .pg The following options affect the score file: .pg @@ -3281,16 +3284,6 @@ successors originally by \fBDaniel Thaler\fP and then by \fBAlex Smith\fP, and Dynahack by \fBTung Nguyen\fP. Some of those variants continue to be developed, maintained, and enjoyed by the community to this day. .pg -In September 2014, an interim snapshot of the code under development was -released publicly by other parties. Since that code was a work-in-progress -and had not gone through a period of debugging, it was decided that the -version numbers present on that code snapshot would be retired and never -used in an official NetHack release. An announcement was posted on the -devteam's official nethack.org website to that effect, stating that there -would never be a 3.4.4, 3.5, or 3.5.0 official release version. -.pg -In January 2015, preparation began for the release of NetHack 3.6 -.pg At the beginning of development for what would eventually get released as 3.6.0, the development team consisted of \fBWarwick Allison\fP, \fBMichael Allison\fP, \fBKen Arromdee\fP, @@ -3299,25 +3292,34 @@ as 3.6.0, the development team consisted of \fBWarwick Allison\fP, \fBMike Stephenson\fP, \fBJanet Walz\fP, and \fBPaul Winner\fP. Leading up to the release of 3.6.0 in early 2015, new members \fBSean Hunt\fP, \fBPasi Kallinen\fP, and \fBDerek S. Ray\fP -joined the NetHack development team, +joined the NetHack development team. .pg -\fB3.6.0 TODO insert apprpriate description of 3.6.0 here +In September 2014, an interim snapshot of the code under development was +released publicly by other parties. Since that code was a work-in-progress +and had not gone through a period of debugging, it was decided that the +version numbers present on that code snapshot would be retired and never +used in an official NetHack release. An announcement was posted on the +devteam's official nethack.org website to that effect, stating that there +would never be a 3.4.4, 3.5, or 3.5.0 official release version. +.pg +In January 2015, preparation began for the release of NetHack 3.6. The 3.6 +version merges work done by the development team since the previous release with +some of the beloved community patches. Many bugs were fixed and some code was +restructured. .pg \fBThe development team, as well as \fBSteve VanDevender\fP and \fBKevin Smolkowski\fP ensured that NetHack 3.6.0 continued to operate on -various Unix flavors as well as maintaining the X11 interface. +various Unix flavors and maintained the X11 interface. .pg \fBKen Lorber\fP, \fBHaoyang Wang\fP, \fBPat Rankin\fP, and \fBDean Luick\fP maintained the port of NetHack 3.6.0 for Mac. .pg \fBMichael Allison\fP, \fBDerek S. Ray\fP, \fBYitzhak Sapir\fP, -\fBAlex Kompel\fP, and \fBDavid Cohrs\fP maintained the port of +\fBAlex Kompel\fP, and \fBDion Nicolaas\fP maintained the port of NetHack 3.6.0 for Microsoft Windows. .pg \fBJeff Bailey\fP created and maintained a port of NetHack 3.6.0 for Chrome. .pg -TODO \fBAlex Kompel\fP maintained a port of NetHack 3.6.0 to Windows Phone. -.pg \fBThis version of the game is special in a particular way. Near the end of the development of 3.6, one of the significant inspirations for many of the humorous and fun features found in the game, author \fBTerry Pratchett\fP, diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index ae3cfa8a7..d31fa52aa 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -33,7 +33,7 @@ \begin{document} % % input file: guidebook.mn -% $Revision: 1.122 $ $Date: 2015/03/27 06:00:00 $ +% $Revision: 1.122 $ $Date: 2015/04/12 06:00:00 $ % %.ds h0 " %.ds h1 %.ds h2 \% @@ -46,7 +46,7 @@ %.au \author{Eric S. Raymond\\ (Edited and expanded for 3.6)} -\date{March 27, 2015} +\date{April 12, 2015} \maketitle @@ -3597,6 +3597,9 @@ A string explaining how to recover a game on this system (no default value). \item[\ib{SEDUCE}] 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source) for details on this function. +%.lp +\item[\ib{CHECK\_SAVE\_UID}] +0 or 1 to disable or enable, respectively, the UID checking for savefiles. \elist %.pg @@ -3952,6 +3955,18 @@ originally by Daniel Thaler and then by Alex Smith, and Dynahack by Tung Nguyen. Some of those variants continue to be developed, maintained, and enjoyed by the community to this day. +%.pg +\medskip +At the beginning of development for what would eventually get released +as 3.6.0, the development team consisted of {\it Warwick Allison}, +{\it Michael Allison}, {\it Ken Arromdee}, +{\it David Cohrs}, {\it Jessie Collet}, +{\it Ken Lorber}, {\it Dean Luick}, {\it Pat Rankin}, +{\it Mike Stephenson}, {\it Janet Walz}, and {\it Paul Winner}. +Leading up to the release of 3.6.0 in early 2015, new members +{\it Sean Hunt}, {\it Pasi Kallinen}, and {\it Derek S. Ray} +joined the NetHack development team. + %.pg \medskip In September 2014, an interim snapshot of the code under development was @@ -3964,47 +3979,31 @@ would never be a 3.4.4, 3.5, or 3.5.0 official release version. %.pg \medskip -In January 2015, preparation began for the release of NetHack 3.6 - -%.pg -\medskip -At the beginning of development for what would eventually get released -as 3.6.0, the development team consisted of {\it Warwick Allison}, -{\it Michael Allison}, {\it Ken Arromdee}, -{\it David Cohrs}, {\it Jessie Collet}, -{\it Ken Lorber}, {\it Dean Luick}, {\it Pat Rankin}, -{\it Mike Stephenson}, {\it Janet Walz}, and {\it Paul Winner}. -Leading up to the release of 3.6.0 in early 2015, new members -{\it Sean Hunt}, {\it Pasi Kallinen}, and {\it Derek S. Ray} -joined the NetHack development team, - -%.pg -\medskip -3.6.0 TODO insert apprpriate description of 3.6.0 here +In January 2015, preparation began for the release of NetHack 3.6. +The 3.6 version merges work done by the development team since the previous +release with some of the beloved community patches. Many bugs were fixed +and some code was restructured. %.pg \medskip The development team, as well as {\it Steve VanDevender} and {\it Kevin Smolkowski} ensured that NetHack 3.6.0 continued to operate on -various Unix flavors as well as maintaining the X11 interface. +various Unix flavors and maintained the X11 interface. +%.pg {\it Ken Lorber}, {\it Haoyang Wang}, {\it Pat Rankin}, and {\it Dean Luick} maintained the port of NetHack 3.6.0 for Mac. %.pg \medskip {\it Michael Allison}, {\it Derek S. Ray}, {\it Yitzhak Sapir}, -{\it Alex Kompel}, and {\it David Cohrs} maintained the port of +{\it Alex Kompel}, and {\it Dion Nicolaas} maintained the port of NetHack 3.6.0 for Microsoft Windows. %.pg \medskip {\it Jeff Bailey} created and maintained a port of NetHack 3.6.0 for Chrome. -%.pg -\medskip -{\it Alex Kompel} maintained a port of NetHack 3.6.0 to Windows Phone. ? - %.pg \medskip This version of the game is special in a particular way. Near the end of diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 0993ac707..5f5abf250 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -894,6 +894,9 @@ non-pet rust monsters would eat rust-proofed non-digestibles but ignore kicking a grave may topple the gravestone allow showing legal positions for stinking cloud, jumping and polearms when asked for a location +cloned creatures (of any type) don't deathdrop items +pudding corpses behave somewhat differently than before +mithril armor should have silver color Platform- and/or Interface-Specific Fixes @@ -1112,6 +1115,7 @@ show more explicit reason why player was helpless at death added new hallucinatory-only gods options to create the character blind or nudist moving clouds on the plane of air +disclose extinct species alongside genocided ones tribute to Terry Pratchett @@ -1153,7 +1157,7 @@ adopt/adapt/improve Dungeon Overview Aardvark Joe's Extended Logfile Michael Deutschmann's use_darkgray Clive Crous' dark_room -Jukka Lahtinen's sortloot +sortloot by Jeroen Demeyer and Jukka Lahtinen Code Cleanup and Reorganization diff --git a/include/config.h b/include/config.h index fbe4704ae..4cce7dba8 100644 --- a/include/config.h +++ b/include/config.h @@ -437,8 +437,12 @@ typedef unsigned char uchar; */ /* Menucolors */ +/* HACK: this is being added to fix the builds temporarily. + * Remove it whenever we finally get a real regex for Win32 */ +#ifdef UNIX # define MENU_COLOR_REGEX /* use GNU regex */ /*# define MENU_COLOR_REGEX_POSIX*/ /* use POSIX regex */ +#endif /* if neither is defined, uses pmatch() * pmatch() provides basic globbing: '*' and '?' wildcards. */ diff --git a/include/extern.h b/include/extern.h index 367963f15..199201925 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.5 extern.h $NHDT-Date: 1428196810 2015/04/05 01:20:10 $ $NHDT-Branch: nhmall-booktribute $:$NHDT-Revision: 1.451 $ */ +/* NetHack 3.5 extern.h $NHDT-Date: 1428806395 2015/04/12 02:39:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.455 $ */ /* NetHack 3.5 extern.h $Date: 2013/11/05 00:57:53 $ $Revision: 1.380 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -836,6 +836,8 @@ E int FDECL(isqrt, (int)); E int FDECL(distmin, (int,int,int,int)); E boolean FDECL(online2, (int,int,int,int)); E boolean FDECL(pmatch, (const char *,const char *)); +E boolean FDECL(pmatchi, (const char *,const char *)); +E boolean FDECL(pmatchz, (const char *,const char *)); #ifndef STRNCMPI E int FDECL(strncmpi, (const char *,const char *,int)); #endif @@ -1230,6 +1232,10 @@ E void FDECL(obj_ice_effects, (int, int, BOOLEAN_P)); E long FDECL(peek_at_iced_corpse_age, (struct obj *)); E int FDECL(hornoplenty, (struct obj *,BOOLEAN_P)); E void NDECL(obj_sanity_check); +E struct obj* FDECL(obj_nexto, (struct obj*)); +E struct obj* FDECL(obj_nexto_xy, (int, int, int, unsigned)); +E struct obj* FDECL(obj_absorb, (struct obj**, struct obj**)); +E struct obj* FDECL(obj_meld, (struct obj**, struct obj**)); /* ### mkroom.c ### */ @@ -2663,7 +2669,7 @@ E struct monst *FDECL(bhit, (int,int,int,int,int (*)(MONST_P,OBJ_P), int (*)(OBJ_P,OBJ_P),struct obj **)); E struct monst *FDECL(boomhit, (struct obj *,int,int)); E int FDECL(zhitm, (struct monst *,int,int,struct obj **)); -E int FDECL(burn_floor_paper, (int,int,BOOLEAN_P,BOOLEAN_P)); +E int FDECL(burn_floor_objects, (int,int,BOOLEAN_P,BOOLEAN_P)); E void FDECL(buzz, (int,int,XCHAR_P,XCHAR_P,int,int)); E void FDECL(melt_ice, (XCHAR_P,XCHAR_P,const char *)); E void FDECL(start_melt_ice_timeout, (XCHAR_P,XCHAR_P,long)); diff --git a/include/obj.h b/include/obj.h index 39f163632..0f4e6b306 100644 --- a/include/obj.h +++ b/include/obj.h @@ -94,7 +94,7 @@ struct obj { Bitfield(recharged,3); /* number of times it's been recharged */ #define on_ice recharged /* corpse on ice */ Bitfield(lamplit,1); /* a light-source -- can be lit */ - Bitfield(oreserved1,1); /* was the placeholder for invisible objects, free for use */ + Bitfield(globby,1); /* globby; will combine with like types on adjacent squares */ Bitfield(greased,1); /* covered with grease */ Bitfield(nomerge,1); /* set temporarily to prevent merging */ Bitfield(was_thrown,1); /* thrown by hero since last picked up */ @@ -233,6 +233,11 @@ struct obj { #define polyfodder(obj) (ofood(obj) && pm_to_cham((obj)->corpsenm) != NON_PM) #define mlevelgain(obj) (ofood(obj) && (obj)->corpsenm == PM_WRAITH) #define mhealup(obj) (ofood(obj) && (obj)->corpsenm == PM_NURSE) +#define Is_pudding(o) (o->otyp == GLOB_OF_GRAY_OOZE \ + || o->otyp == GLOB_OF_BROWN_PUDDING \ + || o->otyp == GLOB_OF_GREEN_SLIME \ + || o->otyp == GLOB_OF_BLACK_PUDDING) + /* Containers */ #define carried(o) ((o)->where == OBJ_INVENT) diff --git a/include/sys.h b/include/sys.h index 84d42b5b6..8b6c4b502 100644 --- a/include/sys.h +++ b/include/sys.h @@ -35,6 +35,7 @@ struct sysopt { # endif #endif int seduce; + int check_save_uid; /* restoring savefile checks UID? */ }; extern struct sysopt sysopt; diff --git a/src/cmd.c b/src/cmd.c index 3798a4fb0..24b1791c5 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1244,7 +1244,7 @@ char resultbuf[]; /* should be at least [7] to hold "18/100\0" */ void enlightenment(mode, final) int mode; /* BASICENLIGHTENMENT | MAGICENLIGHTENMENT (| both) */ -int final; /* ENL_GAMEINPROGRESS:0, ENL_GAVEOVERALIVE, ENL_GAMEOVERDEAD */ +int final; /* ENL_GAMEINPROGRESS:0, ENL_GAMEOVERALIVE, ENL_GAMEOVERDEAD */ { char buf[BUFSZ], tmpbuf[BUFSZ]; diff --git a/src/display.c b/src/display.c index 75af16442..1369fbfb3 100644 --- a/src/display.c +++ b/src/display.c @@ -160,7 +160,7 @@ magic_map_background(x, y, show) if (!cansee(x,y) && !lev->waslit) { /* Floor spaces are dark if unlit. Corridors are dark if unlit. */ if (lev->typ == ROOM && glyph == cmap_to_glyph(S_room)) - glyph = cmap_to_glyph(S_stone); + glyph = cmap_to_glyph((flags.dark_room && iflags.use_color) ? (DARKROOMSYM) : S_stone); else if (lev->typ == CORR && glyph == cmap_to_glyph(S_litcorr)) glyph = cmap_to_glyph(S_corr); } diff --git a/src/do.c b/src/do.c index 8ba500501..75b61159e 100644 --- a/src/do.c +++ b/src/do.c @@ -22,20 +22,20 @@ STATIC_DCL void NDECL(final_level); extern int n_dgns; /* number of dungeons, from dungeon.c */ static NEARDATA const char drop_types[] = - { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, 0 }; + { ALLOW_COUNT, COIN_CLASS, ALL_CLASSES, 0 }; /* 'd' command: drop one inventory item */ int dodrop() { - int result, i = (invent) ? 0 : (SIZE(drop_types) - 1); + int result, i = (invent) ? 0 : (SIZE(drop_types) - 1); - if (*u.ushops) sellobj_state(SELL_DELIBERATE); - result = drop(getobj(&drop_types[i], "drop")); - if (*u.ushops) sellobj_state(SELL_NORMAL); - reset_occupations(); + if (*u.ushops) sellobj_state(SELL_DELIBERATE); + result = drop(getobj(&drop_types[i], "drop")); + if (*u.ushops) sellobj_state(SELL_NORMAL); + reset_occupations(); - return result; + return result; } /* Called when a boulder is dropped, thrown, or pushed. If it ends up @@ -48,75 +48,75 @@ struct obj *otmp; register int rx, ry; boolean pushing; { - if (!otmp || otmp->otyp != BOULDER) - impossible("Not a boulder?"); - else if (!Is_waterlevel(&u.uz) && is_pool_or_lava(rx,ry)) { - boolean lava = is_lava(rx,ry), fills_up; - const char *what = waterbody_name(rx,ry); - schar ltyp = levl[rx][ry].typ; - int chance = rn2(10); /* water: 90%; lava: 10% */ - fills_up = lava ? chance == 0 : chance != 0; + if (!otmp || otmp->otyp != BOULDER) + impossible("Not a boulder?"); + else if (!Is_waterlevel(&u.uz) && is_pool_or_lava(rx,ry)) { + boolean lava = is_lava(rx,ry), fills_up; + const char *what = waterbody_name(rx,ry); + schar ltyp = levl[rx][ry].typ; + int chance = rn2(10); /* water: 90%; lava: 10% */ + fills_up = lava ? chance == 0 : chance != 0; - if (fills_up) { - struct trap *ttmp = t_at(rx, ry); + if (fills_up) { + struct trap *ttmp = t_at(rx, ry); - if (ltyp == DRAWBRIDGE_UP) { - levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */ - levl[rx][ry].drawbridgemask |= DB_FLOOR; - } else - levl[rx][ry].typ = ROOM; + if (ltyp == DRAWBRIDGE_UP) { + levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */ + levl[rx][ry].drawbridgemask |= DB_FLOOR; + } else + levl[rx][ry].typ = ROOM; - if (ttmp) (void) delfloortrap(ttmp); - bury_objs(rx, ry); - - newsym(rx,ry); - if (pushing) { - char whobuf[BUFSZ]; + if (ttmp) (void) delfloortrap(ttmp); + bury_objs(rx, ry); + + newsym(rx,ry); + if (pushing) { + char whobuf[BUFSZ]; - Strcpy(whobuf, "you"); - if (u.usteed) Strcpy(whobuf, y_monnam(u.usteed)); - pline("%s %s %s into the %s.", upstart(whobuf), - vtense(whobuf, "push"), the(xname(otmp)), what); - if (flags.verbose && !Blind) - pline("Now you can cross it!"); - /* no splashing in this case */ - } - } - if (!fills_up || !pushing) { /* splashing occurs */ - if (!u.uinwater) { - if (pushing ? !Blind : cansee(rx,ry)) { - There("is a large splash as %s %s the %s.", - the(xname(otmp)), fills_up? "fills":"falls into", - what); - } else if (!Deaf) - You_hear("a%s splash.", lava ? " sizzling" : ""); - wake_nearto(rx, ry, 40); - } + Strcpy(whobuf, "you"); + if (u.usteed) Strcpy(whobuf, y_monnam(u.usteed)); + pline("%s %s %s into the %s.", upstart(whobuf), + vtense(whobuf, "push"), the(xname(otmp)), what); + if (flags.verbose && !Blind) + pline("Now you can cross it!"); + /* no splashing in this case */ + } + } + if (!fills_up || !pushing) { /* splashing occurs */ + if (!u.uinwater) { + if (pushing ? !Blind : cansee(rx,ry)) { + There("is a large splash as %s %s the %s.", + the(xname(otmp)), fills_up? "fills":"falls into", + what); + } else if (!Deaf) + You_hear("a%s splash.", lava ? " sizzling" : ""); + wake_nearto(rx, ry, 40); + } - if (fills_up && u.uinwater && distu(rx,ry) == 0) { - u.uinwater = 0; - docrt(); - vision_full_recalc = 1; - You("find yourself on dry land again!"); - } else if (lava && distu(rx,ry) <= 2) { - int dmg; - You("are hit by molten lava%c", - Fire_resistance ? '.' : '!'); - burn_away_slime(); - dmg = d((Fire_resistance ? 1 : 3), 6); - losehp(Maybe_Half_Phys(dmg), /* lava damage */ - "molten lava", KILLED_BY); - } else if (!fills_up && flags.verbose && - (pushing ? !Blind : cansee(rx,ry))) - pline("It sinks without a trace!"); - } + if (fills_up && u.uinwater && distu(rx,ry) == 0) { + u.uinwater = 0; + docrt(); + vision_full_recalc = 1; + You("find yourself on dry land again!"); + } else if (lava && distu(rx,ry) <= 2) { + int dmg; + You("are hit by molten lava%c", + Fire_resistance ? '.' : '!'); + burn_away_slime(); + dmg = d((Fire_resistance ? 1 : 3), 6); + losehp(Maybe_Half_Phys(dmg), /* lava damage */ + "molten lava", KILLED_BY); + } else if (!fills_up && flags.verbose && + (pushing ? !Blind : cansee(rx,ry))) + pline("It sinks without a trace!"); + } - /* boulder is now gone */ - if (pushing) delobj(otmp); - else obfree(otmp, (struct obj *)0); - return TRUE; - } - return FALSE; + /* boulder is now gone */ + if (pushing) delobj(otmp); + else obfree(otmp, (struct obj *)0); + return TRUE; + } + return FALSE; } /* Used for objects which sometimes do special things when dropped; must be @@ -129,98 +129,106 @@ struct obj *obj; int x, y; const char *verb; { - struct trap *t; - struct monst *mtmp; + struct trap *t; + struct monst *mtmp; + struct obj* otmp; - if (obj->where != OBJ_FREE) - panic("flooreffects: obj not free"); + if (obj->where != OBJ_FREE) + panic("flooreffects: obj not free"); - /* make sure things like water_damage() have no pointers to follow */ - obj->nobj = obj->nexthere = (struct obj *)0; + /* make sure things like water_damage() have no pointers to follow */ + obj->nobj = obj->nexthere = (struct obj *)0; - if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) - return TRUE; - else if (obj->otyp == BOULDER && (t = t_at(x,y)) != 0 && - (t->ttyp==PIT || t->ttyp==SPIKED_PIT - || t->ttyp==TRAPDOOR || t->ttyp==HOLE)) { - if (((mtmp = m_at(x, y)) && mtmp->mtrapped) || - (u.utrap && u.ux == x && u.uy == y)) { - if (*verb) - pline_The("boulder %s into the pit%s.", - vtense((const char *)0, verb), - (mtmp) ? "" : " with you"); - if (mtmp) { - if (!passes_walls(mtmp->data) && - !throws_rocks(mtmp->data)) { - if (hmon(mtmp, obj, TRUE) && !is_whirly(mtmp->data)) - return FALSE; /* still alive */ - } - mtmp->mtrapped = 0; - } else { - if (!Passes_walls && !throws_rocks(youmonst.data)) { - losehp(Maybe_Half_Phys(rnd(15)), - "squished under a boulder", - NO_KILLER_PREFIX); - return FALSE; /* player remains trapped */ - } else u.utrap = 0; - } - } - if (*verb) { - if (Blind && (x == u.ux) && (y == u.uy)) { - You_hear("a CRASH! beneath you."); - } else if (!Blind && cansee(x, y)) { - pline_The("boulder %s%s.", - t->tseen ? "" : "triggers and ", - t->ttyp == TRAPDOOR ? "plugs a trap door" : - t->ttyp == HOLE ? "plugs a hole" : - "fills a pit"); - } else { - You_hear("a boulder %s.", verb); - } - } - deltrap(t); - useupf(obj, 1L); - bury_objs(x, y); - newsym(x,y); - return TRUE; - } else if (is_lava(x, y)) { - return fire_damage(obj, FALSE, x, y); - } else if (is_pool(x, y)) { - /* Reasonably bulky objects (arbitrary) splash when dropped. - * If you're floating above the water even small things make - * noise. Stuff dropped near fountains always misses */ - if ((Blind || (Levitation || Flying)) && !Deaf && - ((x == u.ux) && (y == u.uy))) { - if (!Underwater) { - if (weight(obj) > 9) { - pline("Splash!"); - } else if (Levitation || Flying) { - pline("Plop!"); - } - } - map_background(x, y, 0); - newsym(x, y); - } - return water_damage(obj, NULL, FALSE) == ER_DESTROYED; - } else if (u.ux == x && u.uy == y && - (t = t_at(x,y)) != 0 && uteetering_at_seen_pit(t)) { - if (Blind && !Deaf) - You_hear("%s tumble downwards.", - the(xname(obj))); - else - pline("%s %s into %s pit.", - The(xname(obj)), otense(obj, "tumble"), - the_your[t->madeby_u]); - } - return FALSE; + if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) + return TRUE; + else if (obj->otyp == BOULDER && (t = t_at(x,y)) != 0 && + (t->ttyp==PIT || t->ttyp==SPIKED_PIT + || t->ttyp==TRAPDOOR || t->ttyp==HOLE)) { + if (((mtmp = m_at(x, y)) && mtmp->mtrapped) || + (u.utrap && u.ux == x && u.uy == y)) { + if (*verb) + pline_The("boulder %s into the pit%s.", + vtense((const char *)0, verb), + (mtmp) ? "" : " with you"); + if (mtmp) { + if (!passes_walls(mtmp->data) && + !throws_rocks(mtmp->data)) { + if (hmon(mtmp, obj, TRUE) && !is_whirly(mtmp->data)) + return FALSE; /* still alive */ + } + mtmp->mtrapped = 0; + } else { + if (!Passes_walls && !throws_rocks(youmonst.data)) { + losehp(Maybe_Half_Phys(rnd(15)), + "squished under a boulder", + NO_KILLER_PREFIX); + return FALSE; /* player remains trapped */ + } else u.utrap = 0; + } + } + if (*verb) { + if (Blind && (x == u.ux) && (y == u.uy)) { + You_hear("a CRASH! beneath you."); + } else if (!Blind && cansee(x, y)) { + pline_The("boulder %s%s.", + t->tseen ? "" : "triggers and ", + t->ttyp == TRAPDOOR ? "plugs a trap door" : + t->ttyp == HOLE ? "plugs a hole" : + "fills a pit"); + } else { + You_hear("a boulder %s.", verb); + } + } + deltrap(t); + useupf(obj, 1L); + bury_objs(x, y); + newsym(x,y); + return TRUE; + } else if (is_lava(x, y)) { + return fire_damage(obj, FALSE, x, y); + } else if (is_pool(x, y)) { + /* Reasonably bulky objects (arbitrary) splash when dropped. + * If you're floating above the water even small things make + * noise. Stuff dropped near fountains always misses */ + if ((Blind || (Levitation || Flying)) && !Deaf && + ((x == u.ux) && (y == u.uy))) { + if (!Underwater) { + if (weight(obj) > 9) { + pline("Splash!"); + } else if (Levitation || Flying) { + pline("Plop!"); + } + } + map_background(x, y, 0); + newsym(x, y); + } + return water_damage(obj, NULL, FALSE) == ER_DESTROYED; + } else if (u.ux == x && u.uy == y && + (t = t_at(x,y)) != 0 && uteetering_at_seen_pit(t)) { + if (Blind && !Deaf) + You_hear("%s tumble downwards.", + the(xname(obj))); + else + pline("%s %s into %s pit.", + The(xname(obj)), otense(obj, "tumble"), + the_your[t->madeby_u]); + } else if (obj->globby) { + /* Globby things like puddings might stick together */ + while (obj && (otmp = obj_nexto_xy(obj->otyp, x, y, obj->o_id)) != (struct obj*)0) { + pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + obj_meld(&obj, &otmp); + } + return (obj == NULL); + } + return FALSE; } void doaltarobj(obj) /* obj is an object dropped on an altar */ - register struct obj *obj; + register struct obj *obj; { - if (Blind) - return; + if (Blind) + return; if (obj->oclass != COIN_CLASS) { /* KMH, conduct */ @@ -231,15 +239,15 @@ doaltarobj(obj) /* obj is an object dropped on an altar */ } if (obj->blessed || obj->cursed) { - There("is %s flash as %s %s the altar.", - an(hcolor(obj->blessed ? NH_AMBER : NH_BLACK)), - doname(obj), otense(obj, "hit")); - if (!Hallucination) obj->bknown = 1; - } else { - pline("%s %s on the altar.", Doname2(obj), - otense(obj, "land")); + There("is %s flash as %s %s the altar.", + an(hcolor(obj->blessed ? NH_AMBER : NH_BLACK)), + doname(obj), otense(obj, "hit")); + if (!Hallucination) obj->bknown = 1; + } else { + pline("%s %s on the altar.", Doname2(obj), + otense(obj, "land")); if (obj->oclass != COIN_CLASS) obj->bknown = 1; - } + } } STATIC_OVL @@ -247,9 +255,9 @@ void trycall(obj) register struct obj *obj; { - if(!objects[obj->otyp].oc_name_known && - !objects[obj->otyp].oc_uname) - docall(obj); + if(!objects[obj->otyp].oc_name_known && + !objects[obj->otyp].oc_uname) + docall(obj); } STATIC_OVL @@ -257,141 +265,141 @@ void dosinkring(obj) /* obj is a ring being dropped over a kitchen sink */ register struct obj *obj; { - register struct obj *otmp,*otmp2; - register boolean ideed = TRUE; + register struct obj *otmp,*otmp2; + register boolean ideed = TRUE; - You("drop %s down the drain.", doname(obj)); - obj->in_use = TRUE; /* block free identification via interrupt */ - switch(obj->otyp) { /* effects that can be noticed without eyes */ - case RIN_SEARCHING: - You("thought %s got lost in the sink, but there it is!", - yname(obj)); - goto giveback; - case RIN_SLOW_DIGESTION: - pline_The("ring is regurgitated!"); + You("drop %s down the drain.", doname(obj)); + obj->in_use = TRUE; /* block free identification via interrupt */ + switch(obj->otyp) { /* effects that can be noticed without eyes */ + case RIN_SEARCHING: + You("thought %s got lost in the sink, but there it is!", + yname(obj)); + goto giveback; + case RIN_SLOW_DIGESTION: + pline_The("ring is regurgitated!"); giveback: - obj->in_use = FALSE; - dropx(obj); - trycall(obj); - return; - case RIN_LEVITATION: - pline_The("sink quivers upward for a moment."); - break; - case RIN_POISON_RESISTANCE: - You("smell rotten %s.", makeplural(fruitname(FALSE))); - break; - case RIN_AGGRAVATE_MONSTER: - pline("Several flies buzz angrily around the sink."); - break; - case RIN_SHOCK_RESISTANCE: - pline("Static electricity surrounds the sink."); - break; - case RIN_CONFLICT: - You_hear("loud noises coming from the drain."); - break; - case RIN_SUSTAIN_ABILITY: /* KMH */ - pline_The("water flow seems fixed."); - break; - case RIN_GAIN_STRENGTH: - pline_The("water flow seems %ser now.", - (obj->spe<0) ? "weak" : "strong"); - break; - case RIN_GAIN_CONSTITUTION: - pline_The("water flow seems %ser now.", - (obj->spe<0) ? "less" : "great"); - break; - case RIN_INCREASE_ACCURACY: /* KMH */ - pline_The("water flow %s the drain.", - (obj->spe<0) ? "misses" : "hits"); - break; - case RIN_INCREASE_DAMAGE: - pline_The("water's force seems %ser now.", - (obj->spe<0) ? "small" : "great"); - break; - case RIN_HUNGER: - ideed = FALSE; - for(otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { - otmp2 = otmp->nexthere; - if (otmp != uball && otmp != uchain && - !obj_resists(otmp, 1, 99)) { - if (!Blind) { - pline("Suddenly, %s %s from the sink!", - doname(otmp), otense(otmp, "vanish")); - ideed = TRUE; - } - delobj(otmp); - } - } - break; - case MEAT_RING: - /* Not the same as aggravate monster; besides, it's obvious. */ - pline("Several flies buzz around the sink."); - break; - default: - ideed = FALSE; - break; - } - if(!Blind && !ideed && obj->otyp != RIN_HUNGER) { - ideed = TRUE; - switch(obj->otyp) { /* effects that need eyes */ - case RIN_ADORNMENT: - pline_The("faucets flash brightly for a moment."); - break; - case RIN_REGENERATION: - pline_The("sink looks as good as new."); - break; - case RIN_INVISIBILITY: - You("don't see anything happen to the sink."); - break; - case RIN_FREE_ACTION: - You_see("the ring slide right down the drain!"); - break; - case RIN_SEE_INVISIBLE: - You_see("some air in the sink."); - break; - case RIN_STEALTH: - pline_The("sink seems to blend into the floor for a moment."); - break; - case RIN_FIRE_RESISTANCE: - pline_The("hot water faucet flashes brightly for a moment."); - break; - case RIN_COLD_RESISTANCE: - pline_The("cold water faucet flashes brightly for a moment."); - break; - case RIN_PROTECTION_FROM_SHAPE_CHAN: - pline_The("sink looks nothing like a fountain."); - break; - case RIN_PROTECTION: - pline_The("sink glows %s for a moment.", - hcolor((obj->spe<0) ? NH_BLACK : NH_SILVER)); - break; - case RIN_WARNING: - pline_The("sink glows %s for a moment.", hcolor(NH_WHITE)); - break; - case RIN_TELEPORTATION: - pline_The("sink momentarily vanishes."); - break; - case RIN_TELEPORT_CONTROL: - pline_The("sink looks like it is being beamed aboard somewhere."); - break; - case RIN_POLYMORPH: - pline_The("sink momentarily looks like a fountain."); - break; - case RIN_POLYMORPH_CONTROL: - pline_The("sink momentarily looks like a regularly erupting geyser."); - break; - } - } - if(ideed) - trycall(obj); - else - You_hear("the ring bouncing down the drainpipe."); - if (!rn2(20)) { - pline_The("sink backs up, leaving %s.", doname(obj)); - obj->in_use = FALSE; - dropx(obj); - } else - useup(obj); + obj->in_use = FALSE; + dropx(obj); + trycall(obj); + return; + case RIN_LEVITATION: + pline_The("sink quivers upward for a moment."); + break; + case RIN_POISON_RESISTANCE: + You("smell rotten %s.", makeplural(fruitname(FALSE))); + break; + case RIN_AGGRAVATE_MONSTER: + pline("Several flies buzz angrily around the sink."); + break; + case RIN_SHOCK_RESISTANCE: + pline("Static electricity surrounds the sink."); + break; + case RIN_CONFLICT: + You_hear("loud noises coming from the drain."); + break; + case RIN_SUSTAIN_ABILITY: /* KMH */ + pline_The("water flow seems fixed."); + break; + case RIN_GAIN_STRENGTH: + pline_The("water flow seems %ser now.", + (obj->spe<0) ? "weak" : "strong"); + break; + case RIN_GAIN_CONSTITUTION: + pline_The("water flow seems %ser now.", + (obj->spe<0) ? "less" : "great"); + break; + case RIN_INCREASE_ACCURACY: /* KMH */ + pline_The("water flow %s the drain.", + (obj->spe<0) ? "misses" : "hits"); + break; + case RIN_INCREASE_DAMAGE: + pline_The("water's force seems %ser now.", + (obj->spe<0) ? "small" : "great"); + break; + case RIN_HUNGER: + ideed = FALSE; + for(otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) { + otmp2 = otmp->nexthere; + if (otmp != uball && otmp != uchain && + !obj_resists(otmp, 1, 99)) { + if (!Blind) { + pline("Suddenly, %s %s from the sink!", + doname(otmp), otense(otmp, "vanish")); + ideed = TRUE; + } + delobj(otmp); + } + } + break; + case MEAT_RING: + /* Not the same as aggravate monster; besides, it's obvious. */ + pline("Several flies buzz around the sink."); + break; + default: + ideed = FALSE; + break; + } + if(!Blind && !ideed && obj->otyp != RIN_HUNGER) { + ideed = TRUE; + switch(obj->otyp) { /* effects that need eyes */ + case RIN_ADORNMENT: + pline_The("faucets flash brightly for a moment."); + break; + case RIN_REGENERATION: + pline_The("sink looks as good as new."); + break; + case RIN_INVISIBILITY: + You("don't see anything happen to the sink."); + break; + case RIN_FREE_ACTION: + You_see("the ring slide right down the drain!"); + break; + case RIN_SEE_INVISIBLE: + You_see("some air in the sink."); + break; + case RIN_STEALTH: + pline_The("sink seems to blend into the floor for a moment."); + break; + case RIN_FIRE_RESISTANCE: + pline_The("hot water faucet flashes brightly for a moment."); + break; + case RIN_COLD_RESISTANCE: + pline_The("cold water faucet flashes brightly for a moment."); + break; + case RIN_PROTECTION_FROM_SHAPE_CHAN: + pline_The("sink looks nothing like a fountain."); + break; + case RIN_PROTECTION: + pline_The("sink glows %s for a moment.", + hcolor((obj->spe<0) ? NH_BLACK : NH_SILVER)); + break; + case RIN_WARNING: + pline_The("sink glows %s for a moment.", hcolor(NH_WHITE)); + break; + case RIN_TELEPORTATION: + pline_The("sink momentarily vanishes."); + break; + case RIN_TELEPORT_CONTROL: + pline_The("sink looks like it is being beamed aboard somewhere."); + break; + case RIN_POLYMORPH: + pline_The("sink momentarily looks like a fountain."); + break; + case RIN_POLYMORPH_CONTROL: + pline_The("sink momentarily looks like a regularly erupting geyser."); + break; + } + } + if(ideed) + trycall(obj); + else + You_hear("the ring bouncing down the drainpipe."); + if (!rn2(20)) { + pline_The("sink backs up, leaving %s.", doname(obj)); + obj->in_use = FALSE; + dropx(obj); + } else + useup(obj); } /* some common tests when trying to drop or throw items */ @@ -400,41 +408,41 @@ canletgo(obj,word) register struct obj *obj; register const char *word; { - if(obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)){ - if (*word) - Norep("You cannot %s %s you are wearing.",word, - something); - return(FALSE); - } - if (obj->otyp == LOADSTONE && obj->cursed) { - /* getobj() kludge sets corpsenm to user's specified count - when refusing to split a stack of cursed loadstones */ - if (*word) { - /* getobj() ignores a count for throwing since that is - implicitly forced to be 1; replicate its kludge... */ - if (!strcmp(word, "throw") && obj->quan > 1L) - obj->corpsenm = 1; - pline("For some reason, you cannot %s%s the stone%s!", - word, obj->corpsenm ? " any of" : "", - plur(obj->quan)); - } - obj->corpsenm = 0; /* reset */ - obj->bknown = 1; - return(FALSE); - } - if (obj->otyp == LEASH && obj->leashmon != 0) { - if (*word) - pline_The("leash is tied around your %s.", - body_part(HAND)); - return(FALSE); - } - if (obj->owornmask & W_SADDLE) { - if (*word) - You("cannot %s %s you are sitting on.", word, - something); - return (FALSE); - } - return(TRUE); + if(obj->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL)){ + if (*word) + Norep("You cannot %s %s you are wearing.",word, + something); + return(FALSE); + } + if (obj->otyp == LOADSTONE && obj->cursed) { + /* getobj() kludge sets corpsenm to user's specified count + when refusing to split a stack of cursed loadstones */ + if (*word) { + /* getobj() ignores a count for throwing since that is + implicitly forced to be 1; replicate its kludge... */ + if (!strcmp(word, "throw") && obj->quan > 1L) + obj->corpsenm = 1; + pline("For some reason, you cannot %s%s the stone%s!", + word, obj->corpsenm ? " any of" : "", + plur(obj->quan)); + } + obj->corpsenm = 0; /* reset */ + obj->bknown = 1; + return(FALSE); + } + if (obj->otyp == LEASH && obj->leashmon != 0) { + if (*word) + pline_The("leash is tied around your %s.", + body_part(HAND)); + return(FALSE); + } + if (obj->owornmask & W_SADDLE) { + if (*word) + You("cannot %s %s you are sitting on.", word, + something); + return (FALSE); + } + return(TRUE); } STATIC_PTR @@ -442,60 +450,60 @@ int drop(obj) register struct obj *obj; { - if(!obj) return(0); - if(!canletgo(obj,"drop")) - return(0); - if(obj == uwep) { - if(welded(uwep)) { - weldmsg(obj); - return(0); - } - setuwep((struct obj *)0); - } - if(obj == uquiver) { - setuqwep((struct obj *)0); - } - if (obj == uswapwep) { - setuswapwep((struct obj *)0); - } + if(!obj) return(0); + if(!canletgo(obj,"drop")) + return(0); + if(obj == uwep) { + if(welded(uwep)) { + weldmsg(obj); + return(0); + } + setuwep((struct obj *)0); + } + if(obj == uquiver) { + setuqwep((struct obj *)0); + } + if (obj == uswapwep) { + setuswapwep((struct obj *)0); + } - if (u.uswallow) { - /* barrier between you and the floor */ - if(flags.verbose) - { - char buf[BUFSZ]; + if (u.uswallow) { + /* barrier between you and the floor */ + if(flags.verbose) + { + char buf[BUFSZ]; - /* doname can call s_suffix, reusing its buffer */ - Strcpy(buf, s_suffix(mon_nam(u.ustuck))); - You("drop %s into %s %s.", doname(obj), buf, - mbodypart(u.ustuck, STOMACH)); - } - } else { - if((obj->oclass == RING_CLASS || obj->otyp == MEAT_RING) && - IS_SINK(levl[u.ux][u.uy].typ)) { - dosinkring(obj); - return(1); - } - if (!can_reach_floor(TRUE)) { - /* we might be levitating due to #invoke Heart of Ahriman; - if so, levitation would end during call to freeinv() - and we want hitfloor() to happen before float_down() */ - boolean levhack = finesse_ahriman(obj); + /* doname can call s_suffix, reusing its buffer */ + Strcpy(buf, s_suffix(mon_nam(u.ustuck))); + You("drop %s into %s %s.", doname(obj), buf, + mbodypart(u.ustuck, STOMACH)); + } + } else { + if((obj->oclass == RING_CLASS || obj->otyp == MEAT_RING) && + IS_SINK(levl[u.ux][u.uy].typ)) { + dosinkring(obj); + return(1); + } + if (!can_reach_floor(TRUE)) { + /* we might be levitating due to #invoke Heart of Ahriman; + if so, levitation would end during call to freeinv() + and we want hitfloor() to happen before float_down() */ + boolean levhack = finesse_ahriman(obj); - if (levhack) ELevitation = W_ART; /* other than W_ARTI */ - if(flags.verbose) You("drop %s.", doname(obj)); - /* Ensure update when we drop gold objects */ - if (obj->oclass == COIN_CLASS) context.botl = 1; - freeinv(obj); - hitfloor(obj); - if (levhack) float_down(I_SPECIAL|TIMEOUT, W_ARTI|W_ART); - return(1); - } - if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose) - You("drop %s.", doname(obj)); - } - dropx(obj); - return(1); + if (levhack) ELevitation = W_ART; /* other than W_ARTI */ + if(flags.verbose) You("drop %s.", doname(obj)); + /* Ensure update when we drop gold objects */ + if (obj->oclass == COIN_CLASS) context.botl = 1; + freeinv(obj); + hitfloor(obj); + if (levhack) float_down(I_SPECIAL|TIMEOUT, W_ARTI|W_ART); + return(1); + } + if (!IS_ALTAR(levl[u.ux][u.uy].typ) && flags.verbose) + You("drop %s.", doname(obj)); + } + dropx(obj); + return(1); } /* dropx - take dropped item out of inventory; @@ -508,12 +516,12 @@ register struct obj *obj; /* Ensure update when we drop gold objects */ if (obj->oclass == COIN_CLASS) context.botl = 1; freeinv(obj); - if (!u.uswallow) { - if (ship_object(obj, u.ux, u.uy, FALSE)) return; - if (IS_ALTAR(levl[u.ux][u.uy].typ)) - doaltarobj(obj); /* set bknown */ - } - dropy(obj); + if (!u.uswallow) { + if (ship_object(obj, u.ux, u.uy, FALSE)) return; + if (IS_ALTAR(levl[u.ux][u.uy].typ)) + doaltarobj(obj); /* set bknown */ + } + dropy(obj); } /* dropy - put dropped object at its destination; called from lots of places */ @@ -521,7 +529,7 @@ void dropy(obj) struct obj *obj; { - dropz(obj, FALSE); + dropz(obj, FALSE); } /* dropz - really put dropped object at its destination... */ @@ -530,61 +538,61 @@ dropz(obj, with_impact) struct obj *obj; boolean with_impact; { - if (obj == uwep) setuwep((struct obj *)0); - if (obj == uquiver) setuqwep((struct obj *)0); - if (obj == uswapwep) setuswapwep((struct obj *)0); + if (obj == uwep) setuwep((struct obj *)0); + if (obj == uquiver) setuqwep((struct obj *)0); + if (obj == uswapwep) setuswapwep((struct obj *)0); - if (!u.uswallow && flooreffects(obj,u.ux,u.uy,"drop")) return; - /* uswallow check done by GAN 01/29/87 */ - if(u.uswallow) { - boolean could_petrify = FALSE; - boolean could_poly = FALSE; - boolean could_slime = FALSE; - boolean could_grow = FALSE; - boolean could_heal = FALSE; + if (!u.uswallow && flooreffects(obj,u.ux,u.uy,"drop")) return; + /* uswallow check done by GAN 01/29/87 */ + if(u.uswallow) { + boolean could_petrify = FALSE; + boolean could_poly = FALSE; + boolean could_slime = FALSE; + boolean could_grow = FALSE; + boolean could_heal = FALSE; - if (obj != uball) { /* mon doesn't pick up ball */ - if (obj->otyp == CORPSE) { - could_petrify = touch_petrifies(&mons[obj->corpsenm]); - could_poly = polyfodder(obj); - could_slime = (obj->corpsenm == PM_GREEN_SLIME); - could_grow = (obj->corpsenm == PM_WRAITH); - could_heal = (obj->corpsenm == PM_NURSE); - } - (void) mpickobj(u.ustuck,obj); - if (is_animal(u.ustuck->data)) { - if (could_poly || could_slime) { - (void) newcham(u.ustuck, - could_poly ? (struct permonst *)0 : - &mons[PM_GREEN_SLIME], - FALSE, could_slime); - delobj(obj); /* corpse is digested */ - } else if (could_petrify) { - minstapetrify(u.ustuck, TRUE); - /* Don't leave a cockatrice corpse in a statue */ - if (!u.uswallow) delobj(obj); - } else if (could_grow) { - (void) grow_up(u.ustuck, (struct monst *)0); - delobj(obj); /* corpse is digested */ - } else if (could_heal) { - u.ustuck->mhp = u.ustuck->mhpmax; - delobj(obj); /* corpse is digested */ - } - } - } - } else { - place_object(obj, u.ux, u.uy); - if (with_impact) - container_impact_dmg(obj, u.ux, u.uy); - if (obj == uball) - drop_ball(u.ux,u.uy); - else if (level.flags.has_shop) - sellobj(obj, u.ux, u.uy); - stackobj(obj); - if(Blind && Levitation) - map_object(obj, 0); - newsym(u.ux,u.uy); /* remap location under self */ - } + if (obj != uball) { /* mon doesn't pick up ball */ + if (obj->otyp == CORPSE) { + could_petrify = touch_petrifies(&mons[obj->corpsenm]); + could_poly = polyfodder(obj); + could_slime = (obj->corpsenm == PM_GREEN_SLIME); + could_grow = (obj->corpsenm == PM_WRAITH); + could_heal = (obj->corpsenm == PM_NURSE); + } + (void) mpickobj(u.ustuck,obj); + if (is_animal(u.ustuck->data)) { + if (could_poly || could_slime) { + (void) newcham(u.ustuck, + could_poly ? (struct permonst *)0 : + &mons[PM_GREEN_SLIME], + FALSE, could_slime); + delobj(obj); /* corpse is digested */ + } else if (could_petrify) { + minstapetrify(u.ustuck, TRUE); + /* Don't leave a cockatrice corpse in a statue */ + if (!u.uswallow) delobj(obj); + } else if (could_grow) { + (void) grow_up(u.ustuck, (struct monst *)0); + delobj(obj); /* corpse is digested */ + } else if (could_heal) { + u.ustuck->mhp = u.ustuck->mhpmax; + delobj(obj); /* corpse is digested */ + } + } + } + } else { + place_object(obj, u.ux, u.uy); + if (with_impact) + container_impact_dmg(obj, u.ux, u.uy); + if (obj == uball) + drop_ball(u.ux,u.uy); + else if (level.flags.has_shop) + sellobj(obj, u.ux, u.uy); + stackobj(obj); + if(Blind && Levitation) + map_object(obj, 0); + newsym(u.ux,u.uy); /* remap location under self */ + } } /* things that must change when not held; recurse into containers. @@ -593,48 +601,48 @@ void obj_no_longer_held(obj) struct obj *obj; { - if (!obj) { - return; - } else if (Has_contents(obj)) { - struct obj *contents; + if (!obj) { + return; + } else if (Has_contents(obj)) { + struct obj *contents; - for (contents = obj->cobj; contents; contents = contents->nobj) - obj_no_longer_held(contents); - } - switch (obj->otyp) { - case CRYSKNIFE: - /* Normal crysknife reverts to worm tooth when not held by hero - * or monster; fixed crysknife has only 10% chance of reverting. - * When a stack of the latter is involved, it could be worthwhile - * to give each individual crysknife its own separate 10% chance, - * but we aren't in any position to handle stack splitting here. - */ - if (!obj->oerodeproof || !rn2(10)) { - /* if monsters aren't moving, assume player is responsible */ - if (!context.mon_moving && !program_state.gameover) - costly_alteration(obj, COST_DEGRD); - obj->otyp = WORM_TOOTH; - obj->oerodeproof = 0; - } - break; - } + for (contents = obj->cobj; contents; contents = contents->nobj) + obj_no_longer_held(contents); + } + switch (obj->otyp) { + case CRYSKNIFE: + /* Normal crysknife reverts to worm tooth when not held by hero + * or monster; fixed crysknife has only 10% chance of reverting. + * When a stack of the latter is involved, it could be worthwhile + * to give each individual crysknife its own separate 10% chance, + * but we aren't in any position to handle stack splitting here. + */ + if (!obj->oerodeproof || !rn2(10)) { + /* if monsters aren't moving, assume player is responsible */ + if (!context.mon_moving && !program_state.gameover) + costly_alteration(obj, COST_DEGRD); + obj->otyp = WORM_TOOTH; + obj->oerodeproof = 0; + } + break; + } } /* 'D' command: drop several things */ int doddrop() { - int result = 0; + int result = 0; - add_valid_menu_class(0); /* clear any classes already there */ - if (*u.ushops) sellobj_state(SELL_DELIBERATE); - if (flags.menu_style != MENU_TRADITIONAL || - (result = ggetobj("drop", drop, 0, FALSE, (unsigned *)0)) < -1) - result = menu_drop(result); - if (*u.ushops) sellobj_state(SELL_NORMAL); - reset_occupations(); + add_valid_menu_class(0); /* clear any classes already there */ + if (*u.ushops) sellobj_state(SELL_DELIBERATE); + if (flags.menu_style != MENU_TRADITIONAL || + (result = ggetobj("drop", drop, 0, FALSE, (unsigned *)0)) < -1) + result = menu_drop(result); + if (*u.ushops) sellobj_state(SELL_NORMAL); + reset_occupations(); - return result; + return result; } /* Drop things from the hero's inventory, using a menu. */ @@ -650,98 +658,98 @@ int retry; boolean drop_everything = FALSE; if (retry) { - all_categories = (retry == -2); + all_categories = (retry == -2); } else if (flags.menu_style == MENU_FULL) { - all_categories = FALSE; - n = query_category("Drop what type of items?", - invent, - UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL | - BUC_BLESSED | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN, - &pick_list, PICK_ANY); - if (!n) goto drop_done; - for (i = 0; i < n; i++) { - if (pick_list[i].item.a_int == ALL_TYPES_SELECTED) - all_categories = TRUE; - else if (pick_list[i].item.a_int == 'A') - drop_everything = TRUE; - else - add_valid_menu_class(pick_list[i].item.a_int); - } - free((genericptr_t) pick_list); + all_categories = FALSE; + n = query_category("Drop what type of items?", + invent, + UNPAID_TYPES | ALL_TYPES | CHOOSE_ALL | + BUC_BLESSED | BUC_CURSED | BUC_UNCURSED | BUC_UNKNOWN, + &pick_list, PICK_ANY); + if (!n) goto drop_done; + for (i = 0; i < n; i++) { + if (pick_list[i].item.a_int == ALL_TYPES_SELECTED) + all_categories = TRUE; + else if (pick_list[i].item.a_int == 'A') + drop_everything = TRUE; + else + add_valid_menu_class(pick_list[i].item.a_int); + } + free((genericptr_t) pick_list); } else if (flags.menu_style == MENU_COMBINATION) { - unsigned ggoresults = 0; - all_categories = FALSE; - /* Gather valid classes via traditional NetHack method */ - i = ggetobj("drop", drop, 0, TRUE, &ggoresults); - if (i == -2) all_categories = TRUE; - if (ggoresults & ALL_FINISHED) { - n_dropped = i; - goto drop_done; - } + unsigned ggoresults = 0; + all_categories = FALSE; + /* Gather valid classes via traditional NetHack method */ + i = ggetobj("drop", drop, 0, TRUE, &ggoresults); + if (i == -2) all_categories = TRUE; + if (ggoresults & ALL_FINISHED) { + n_dropped = i; + goto drop_done; + } } if (drop_everything) { - /* - * Dropping a burning potion of oil while levitating can cause - * an explosion which might destroy some of hero's inventory, - * so the old code - * for (otmp = invent; otmp; otmp = otmp2) { - * otmp2 = otmp->nobj; - * n_dropped += drop(otmp); - * } - * was unreliable and could lead to an "object lost" panic. - * - * Use the bypass bit to mark items already processed (hence - * not droppable) and rescan inventory until no unbypassed - * items remain. - */ - bypass_objlist(invent, FALSE); /* clear bypass bit for invent */ - while ((otmp = nxt_unbypassed_obj(invent)) != 0) - n_dropped += drop(otmp); - /* we might not have dropped everything (worn armor, welded weapon, - cursed loadstones), so reset any remaining inventory to normal */ - bypass_objlist(invent, FALSE); + /* + * Dropping a burning potion of oil while levitating can cause + * an explosion which might destroy some of hero's inventory, + * so the old code + * for (otmp = invent; otmp; otmp = otmp2) { + * otmp2 = otmp->nobj; + * n_dropped += drop(otmp); + * } + * was unreliable and could lead to an "object lost" panic. + * + * Use the bypass bit to mark items already processed (hence + * not droppable) and rescan inventory until no unbypassed + * items remain. + */ + bypass_objlist(invent, FALSE); /* clear bypass bit for invent */ + while ((otmp = nxt_unbypassed_obj(invent)) != 0) + n_dropped += drop(otmp); + /* we might not have dropped everything (worn armor, welded weapon, + cursed loadstones), so reset any remaining inventory to normal */ + bypass_objlist(invent, FALSE); } else { - /* should coordinate with perm invent, maybe not show worn items */ - n = query_objlist("What would you like to drop?", invent, - USE_INVLET|INVORDER_SORT, &pick_list, - PICK_ANY, all_categories ? allow_all : allow_category); - if (n > 0) { - /* - * picklist[] contains a set of pointers into inventory, but - * as soon as something gets dropped, they might become stale - * (see the drop_everything code above for an explanation). - * Just checking to see whether one is still in the invent - * chain is not sufficient validation since destroyed items - * will be freed and items we've split here might have already - * reused that memory and put the same pointer value back into - * invent. Ditto for using invlet to validate. So we start - * by setting bypass on all of invent, then check each pointer - * to verify that it is in invent and has that bit set. - */ - bypass_objlist(invent, TRUE); - for (i = 0; i < n; i++) { - otmp = pick_list[i].item.a_obj; - for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj) - if (otmp2 == otmp) break; - if (!otmp2 || !otmp2->bypass) continue; - /* found next selected invent item */ - cnt = pick_list[i].count; - if (cnt < otmp->quan) { - if (welded(otmp)) { - ; /* don't split */ - } else if (otmp->otyp == LOADSTONE && otmp->cursed) { - /* same kludge as getobj(), for canletgo()'s use */ - otmp->corpsenm = (int) cnt; /* don't split */ - } else { - otmp = splitobj(otmp, cnt); - } - } - n_dropped += drop(otmp); - } - bypass_objlist(invent, FALSE); /* reset invent to normal */ - free((genericptr_t) pick_list); - } + /* should coordinate with perm invent, maybe not show worn items */ + n = query_objlist("What would you like to drop?", invent, + USE_INVLET|INVORDER_SORT, &pick_list, + PICK_ANY, all_categories ? allow_all : allow_category); + if (n > 0) { + /* + * picklist[] contains a set of pointers into inventory, but + * as soon as something gets dropped, they might become stale + * (see the drop_everything code above for an explanation). + * Just checking to see whether one is still in the invent + * chain is not sufficient validation since destroyed items + * will be freed and items we've split here might have already + * reused that memory and put the same pointer value back into + * invent. Ditto for using invlet to validate. So we start + * by setting bypass on all of invent, then check each pointer + * to verify that it is in invent and has that bit set. + */ + bypass_objlist(invent, TRUE); + for (i = 0; i < n; i++) { + otmp = pick_list[i].item.a_obj; + for (otmp2 = invent; otmp2; otmp2 = otmp2->nobj) + if (otmp2 == otmp) break; + if (!otmp2 || !otmp2->bypass) continue; + /* found next selected invent item */ + cnt = pick_list[i].count; + if (cnt < otmp->quan) { + if (welded(otmp)) { + ; /* don't split */ + } else if (otmp->otyp == LOADSTONE && otmp->cursed) { + /* same kludge as getobj(), for canletgo()'s use */ + otmp->corpsenm = (int) cnt; /* don't split */ + } else { + otmp = splitobj(otmp, cnt); + } + } + n_dropped += drop(otmp); + } + bypass_objlist(invent, FALSE); /* reset invent to normal */ + free((genericptr_t) pick_list); + } } drop_done: @@ -754,167 +762,167 @@ static NEARDATA boolean at_ladder = FALSE; int dodown() { - struct trap *trap = 0; - boolean stairs_down = ((u.ux == xdnstair && u.uy == ydnstair) || - (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)), - ladder_down = (u.ux == xdnladder && u.uy == ydnladder); + struct trap *trap = 0; + boolean stairs_down = ((u.ux == xdnstair && u.uy == ydnstair) || + (u.ux == sstairs.sx && u.uy == sstairs.sy && !sstairs.up)), + ladder_down = (u.ux == xdnladder && u.uy == ydnladder); - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return 1; - } + if(!youmonst.data->mmove) { + You("are rooted %s.", + Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? + "in place" : "to the ground"); + nomul(0); + return 1; + } - if (stucksteed(TRUE)) { - return 0; - } - /* Levitation might be blocked, but player can still use '>' to - turn off controlled levitaiton */ - if (HLevitation || ELevitation) { - if ((HLevitation & I_SPECIAL) || (ELevitation & W_ARTI)) { - /* end controlled levitation */ - if (ELevitation & W_ARTI) { - struct obj *obj; + if (stucksteed(TRUE)) { + return 0; + } + /* Levitation might be blocked, but player can still use '>' to + turn off controlled levitaiton */ + if (HLevitation || ELevitation) { + if ((HLevitation & I_SPECIAL) || (ELevitation & W_ARTI)) { + /* end controlled levitation */ + if (ELevitation & W_ARTI) { + struct obj *obj; - for(obj = invent; obj; obj = obj->nobj) { - if (obj->oartifact && - artifact_has_invprop(obj, LEVITATION)) { - if (obj->age < monstermoves) - obj->age = monstermoves; - obj->age += rnz(100); - } - } - } - if (float_down(I_SPECIAL|TIMEOUT, W_ARTI)) { - return 1; /* came down, so moved */ - } else if (!HLevitation && !ELevitation) { - Your("latent levitation ceases."); - return 1; /* did something, effectively moved */ - } - } - if (BLevitation) { - ; /* weren't actually floating after all */ - } else if (Blind) { - /* Avoid alerting player to an unknown stair or ladder. - * Changes the message for a covered, known staircase - * too; staircase knowledge is not stored anywhere. - */ - if (stairs_down) - stairs_down = - (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnstair); - else if (ladder_down) - ladder_down = - (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnladder); - } - floating_above(stairs_down ? "stairs" : ladder_down ? - "ladder" : surface(u.ux, u.uy)); - return (0); /* didn't move */ - } - if (!stairs_down && !ladder_down) { - trap = t_at(u.ux,u.uy); - if (trap && uteetering_at_seen_pit(trap)) { - dotrap(trap, TOOKPLUNGE); - return(1); - } else if (!trap || - (trap->ttyp != TRAPDOOR && trap->ttyp != HOLE) || - !Can_fall_thru(&u.uz) || !trap->tseen) { - if (flags.autodig && !context.nopick && - uwep && is_pick(uwep)) { - return use_pick_axe2(uwep); - } else { - You_cant("go down here."); - return(0); - } - } - } - if(u.ustuck) { - You("are %s, and cannot go down.", - !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? - "swallowed" : "engulfed"); - return(1); - } - if (on_level(&valley_level, &u.uz) && !u.uevent.gehennom_entered) { - You("are standing at the gate to Gehennom."); - pline("Unspeakable cruelty and harm lurk down there."); - if (yn("Are you sure you want to enter?") != 'y') - return(0); - else pline("So be it."); - u.uevent.gehennom_entered = 1; /* don't ask again */ - } + for(obj = invent; obj; obj = obj->nobj) { + if (obj->oartifact && + artifact_has_invprop(obj, LEVITATION)) { + if (obj->age < monstermoves) + obj->age = monstermoves; + obj->age += rnz(100); + } + } + } + if (float_down(I_SPECIAL|TIMEOUT, W_ARTI)) { + return 1; /* came down, so moved */ + } else if (!HLevitation && !ELevitation) { + Your("latent levitation ceases."); + return 1; /* did something, effectively moved */ + } + } + if (BLevitation) { + ; /* weren't actually floating after all */ + } else if (Blind) { + /* Avoid alerting player to an unknown stair or ladder. + * Changes the message for a covered, known staircase + * too; staircase knowledge is not stored anywhere. + */ + if (stairs_down) + stairs_down = + (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnstair); + else if (ladder_down) + ladder_down = + (glyph_to_cmap(levl[u.ux][u.uy].glyph) == S_dnladder); + } + floating_above(stairs_down ? "stairs" : ladder_down ? + "ladder" : surface(u.ux, u.uy)); + return (0); /* didn't move */ + } + if (!stairs_down && !ladder_down) { + trap = t_at(u.ux,u.uy); + if (trap && uteetering_at_seen_pit(trap)) { + dotrap(trap, TOOKPLUNGE); + return(1); + } else if (!trap || + (trap->ttyp != TRAPDOOR && trap->ttyp != HOLE) || + !Can_fall_thru(&u.uz) || !trap->tseen) { + if (flags.autodig && !context.nopick && + uwep && is_pick(uwep)) { + return use_pick_axe2(uwep); + } else { + You_cant("go down here."); + return(0); + } + } + } + if(u.ustuck) { + You("are %s, and cannot go down.", + !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? + "swallowed" : "engulfed"); + return(1); + } + if (on_level(&valley_level, &u.uz) && !u.uevent.gehennom_entered) { + You("are standing at the gate to Gehennom."); + pline("Unspeakable cruelty and harm lurk down there."); + if (yn("Are you sure you want to enter?") != 'y') + return(0); + else pline("So be it."); + u.uevent.gehennom_entered = 1; /* don't ask again */ + } - if(!next_to_u()) { - You("are held back by your pet!"); - return(0); - } + if(!next_to_u()) { + You("are held back by your pet!"); + return(0); + } - if (trap) - You("%s %s.", Flying ? "fly" : locomotion(youmonst.data, "jump"), - trap->ttyp == HOLE ? "down the hole" : "through the trap door"); + if (trap) + You("%s %s.", Flying ? "fly" : locomotion(youmonst.data, "jump"), + trap->ttyp == HOLE ? "down the hole" : "through the trap door"); - if (trap && Is_stronghold(&u.uz)) { - goto_hell(FALSE, TRUE); - } else { - at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); - next_level(!trap); - at_ladder = FALSE; - } - return(1); + if (trap && Is_stronghold(&u.uz)) { + goto_hell(FALSE, TRUE); + } else { + at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); + next_level(!trap); + at_ladder = FALSE; + } + return(1); } int doup() { - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return 1; - } + if(!youmonst.data->mmove) { + You("are rooted %s.", + Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? + "in place" : "to the ground"); + nomul(0); + return 1; + } - /* "up" to get out of a pit... */ - if (u.utrap && u.utraptype == TT_PIT) { - climb_pit(); - return 1; - } + /* "up" to get out of a pit... */ + if (u.utrap && u.utraptype == TT_PIT) { + climb_pit(); + return 1; + } - if( (u.ux != xupstair || u.uy != yupstair) - && (!xupladder || u.ux != xupladder || u.uy != yupladder) - && (!sstairs.sx || u.ux != sstairs.sx || u.uy != sstairs.sy - || !sstairs.up) - ) { - You_cant("go up here."); - return(0); - } - if (stucksteed(TRUE)) { - return(0); - } - if(u.ustuck) { - You("are %s, and cannot go up.", - !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? - "swallowed" : "engulfed"); - return(1); - } - if(near_capacity() > SLT_ENCUMBER) { - /* No levitation check; inv_weight() already allows for it */ - Your("load is too heavy to climb the %s.", - levl[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder"); - return(1); - } - if(ledger_no(&u.uz) == 1) { - if (yn("Beware, there will be no return! Still climb?") != 'y') - return(0); - } - if(!next_to_u()) { - You("are held back by your pet!"); - return(0); - } - at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); - prev_level(TRUE); - at_ladder = FALSE; - return(1); + if( (u.ux != xupstair || u.uy != yupstair) + && (!xupladder || u.ux != xupladder || u.uy != yupladder) + && (!sstairs.sx || u.ux != sstairs.sx || u.uy != sstairs.sy + || !sstairs.up) + ) { + You_cant("go up here."); + return(0); + } + if (stucksteed(TRUE)) { + return(0); + } + if(u.ustuck) { + You("are %s, and cannot go up.", + !u.uswallow ? "being held" : is_animal(u.ustuck->data) ? + "swallowed" : "engulfed"); + return(1); + } + if(near_capacity() > SLT_ENCUMBER) { + /* No levitation check; inv_weight() already allows for it */ + Your("load is too heavy to climb the %s.", + levl[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder"); + return(1); + } + if(ledger_no(&u.uz) == 1) { + if (yn("Beware, there will be no return! Still climb?") != 'y') + return(0); + } + if(!next_to_u()) { + You("are held back by your pet!"); + return(0); + } + at_ladder = (boolean) (levl[u.ux][u.uy].typ == LADDER); + prev_level(TRUE); + at_ladder = FALSE; + return(1); } d_level save_dlevel = {0, 0}; @@ -923,55 +931,55 @@ d_level save_dlevel = {0, 0}; STATIC_OVL int currentlevel_rewrite() { - register int fd; - char whynot[BUFSZ]; + register int fd; + char whynot[BUFSZ]; - /* since level change might be a bit slow, flush any buffered screen - * output (like "you fall through a trap door") */ - mark_synch(); + /* since level change might be a bit slow, flush any buffered screen + * output (like "you fall through a trap door") */ + mark_synch(); - fd = create_levelfile(ledger_no(&u.uz), whynot); - if (fd < 0) { - /* - * This is not quite impossible: e.g., we may have - * exceeded our quota. If that is the case then we - * cannot leave this level, and cannot save either. - * Another possibility is that the directory was not - * writable. - */ - pline1(whynot); - return -1; - } + fd = create_levelfile(ledger_no(&u.uz), whynot); + if (fd < 0) { + /* + * This is not quite impossible: e.g., we may have + * exceeded our quota. If that is the case then we + * cannot leave this level, and cannot save either. + * Another possibility is that the directory was not + * writable. + */ + pline1(whynot); + return -1; + } #ifdef MFLOPPY - if (!savelev(fd, ledger_no(&u.uz), COUNT_SAVE)) { + if (!savelev(fd, ledger_no(&u.uz), COUNT_SAVE)) { (void) nhclose(fd); - delete_levelfile(ledger_no(&u.uz)); - pline("NetHack is out of disk space for making levels!"); - You("can save, quit, or continue playing."); - return -1; - } + delete_levelfile(ledger_no(&u.uz)); + pline("NetHack is out of disk space for making levels!"); + You("can save, quit, or continue playing."); + return -1; + } #endif - return fd; + return fd; } #ifdef INSURANCE void save_currentstate() { - int fd; + int fd; - if (flags.ins_chkpt) { - /* write out just-attained level, with pets and everything */ - fd = currentlevel_rewrite(); - if(fd < 0) return; - bufon(fd); - savelev(fd,ledger_no(&u.uz), WRITE_SAVE); - bclose(fd); - } + if (flags.ins_chkpt) { + /* write out just-attained level, with pets and everything */ + fd = currentlevel_rewrite(); + if(fd < 0) return; + bufon(fd); + savelev(fd,ledger_no(&u.uz), WRITE_SAVE); + bclose(fd); + } - /* write out non-level state */ - savestateinlock(); + /* write out non-level state */ + savestateinlock(); } #endif @@ -980,8 +988,8 @@ static boolean badspot(x, y) register xchar x, y; { - return((levl[x][y].typ != ROOM && levl[x][y].typ != AIR && - levl[x][y].typ != CORR) || MON_AT(x, y)); + return((levl[x][y].typ != ROOM && levl[x][y].typ != AIR && + levl[x][y].typ != CORR) || MON_AT(x, y)); } */ @@ -990,30 +998,30 @@ goto_level(newlevel, at_stairs, falling, portal) d_level *newlevel; boolean at_stairs, falling, portal; { - int fd, l_idx; - xchar new_ledger; - boolean cant_go_back, - up = (depth(newlevel) < depth(&u.uz)), - newdungeon = (u.uz.dnum != newlevel->dnum), - was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz), - familiar = FALSE; - boolean new = FALSE; /* made a new level? */ - struct monst *mtmp; - char whynot[BUFSZ]; + int fd, l_idx; + xchar new_ledger; + boolean cant_go_back, + up = (depth(newlevel) < depth(&u.uz)), + newdungeon = (u.uz.dnum != newlevel->dnum), + was_in_W_tower = In_W_tower(u.ux, u.uy, &u.uz), + familiar = FALSE; + boolean new = FALSE; /* made a new level? */ + struct monst *mtmp; + char whynot[BUFSZ]; - if (dunlev(newlevel) > dunlevs_in_dungeon(newlevel)) - newlevel->dlevel = dunlevs_in_dungeon(newlevel); - if (newdungeon && In_endgame(newlevel)) { /* 1st Endgame Level !!! */ - if (!u.uhave.amulet) return; /* must have the Amulet */ - if (!wizard) /* wizard ^V can bypass Earth level */ - assign_level(newlevel, &earth_level); /* (redundant) */ - } - new_ledger = ledger_no(newlevel); - if (new_ledger <= 0) - done(ESCAPED); /* in fact < 0 is impossible */ + if (dunlev(newlevel) > dunlevs_in_dungeon(newlevel)) + newlevel->dlevel = dunlevs_in_dungeon(newlevel); + if (newdungeon && In_endgame(newlevel)) { /* 1st Endgame Level !!! */ + if (!u.uhave.amulet) return; /* must have the Amulet */ + if (!wizard) /* wizard ^V can bypass Earth level */ + assign_level(newlevel, &earth_level); /* (redundant) */ + } + new_ledger = ledger_no(newlevel); + if (new_ledger <= 0) + done(ESCAPED); /* in fact < 0 is impossible */ - /* If you have the amulet and are trying to get out of Gehennom, going - * up a set of stairs sometimes does some very strange things! + /* If you have the amulet and are trying to get out of Gehennom, going + * up a set of stairs sometimes does some very strange things! * Biased against law and towards chaos. (The chance to be sent * down multiple levels when attempting to go up are significantly * less than the corresponding comment in older versions indicated @@ -1026,407 +1034,407 @@ boolean at_stairs, falling, portal; * -1 11.46 12.50 12.5 * -2 5.21 4.17 0.0 * -3 2.08 0.0 0.0 - */ - if (Inhell && up && u.uhave.amulet && !newdungeon && !portal && - (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)-3)) { - if (!rn2(4)) { - int odds = 3 + (int)u.ualign.type, /* 2..4 */ - diff = odds <= 1 ? 0 : rn2(odds); /* paranoia */ + */ + if (Inhell && up && u.uhave.amulet && !newdungeon && !portal && + (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)-3)) { + if (!rn2(4)) { + int odds = 3 + (int)u.ualign.type, /* 2..4 */ + diff = odds <= 1 ? 0 : rn2(odds); /* paranoia */ - if (diff != 0) { - assign_rnd_level(newlevel, &u.uz, diff); - /* if inside the tower, stay inside */ - if (was_in_W_tower && - !On_W_tower_level(newlevel)) diff = 0; - } - if (diff == 0) - assign_level(newlevel, &u.uz); + if (diff != 0) { + assign_rnd_level(newlevel, &u.uz, diff); + /* if inside the tower, stay inside */ + if (was_in_W_tower && + !On_W_tower_level(newlevel)) diff = 0; + } + if (diff == 0) + assign_level(newlevel, &u.uz); - new_ledger = ledger_no(newlevel); + new_ledger = ledger_no(newlevel); - pline("A mysterious force momentarily surrounds you..."); - if (on_level(newlevel, &u.uz)) { - (void) safe_teleds(FALSE); - (void) next_to_u(); - return; - } else - at_stairs = at_ladder = FALSE; - } - } + pline("A mysterious force momentarily surrounds you..."); + if (on_level(newlevel, &u.uz)) { + (void) safe_teleds(FALSE); + (void) next_to_u(); + return; + } else + at_stairs = at_ladder = FALSE; + } + } - /* Prevent the player from going past the first quest level unless - * (s)he has been given the go-ahead by the leader. - */ - if (on_level(&u.uz, &qstart_level) && !newdungeon && !ok_to_quest()) { - pline("A mysterious force prevents you from descending."); - return; - } + /* Prevent the player from going past the first quest level unless + * (s)he has been given the go-ahead by the leader. + */ + if (on_level(&u.uz, &qstart_level) && !newdungeon && !ok_to_quest()) { + pline("A mysterious force prevents you from descending."); + return; + } - if (on_level(newlevel, &u.uz)) return; /* this can happen */ + if (on_level(newlevel, &u.uz)) return; /* this can happen */ - /* tethered movement makes level change while trapped feasible */ - if (u.utrap && u.utraptype == TT_BURIEDBALL) - buried_ball_to_punishment(); /* (before we save/leave old level) */ + /* tethered movement makes level change while trapped feasible */ + if (u.utrap && u.utraptype == TT_BURIEDBALL) + buried_ball_to_punishment(); /* (before we save/leave old level) */ - fd = currentlevel_rewrite(); - if (fd < 0) return; + fd = currentlevel_rewrite(); + if (fd < 0) return; - if (falling) /* assuming this is only trap door or hole */ - impact_drop((struct obj *)0, u.ux, u.uy, newlevel->dlevel); + if (falling) /* assuming this is only trap door or hole */ + impact_drop((struct obj *)0, u.ux, u.uy, newlevel->dlevel); - check_special_room(TRUE); /* probably was a trap door */ - if (Punished) unplacebc(); - u.utrap = 0; /* needed in level_tele */ - fill_pit(u.ux, u.uy); - u.ustuck = 0; /* idem */ - u.uinwater = 0; - u.uundetected = 0; /* not hidden, even if means are available */ - keepdogs(FALSE); - if (u.uswallow) /* idem */ - u.uswldtim = u.uswallow = 0; - recalc_mapseen(); /* recalculate map overview before we leave the level */ - /* - * We no longer see anything on the level. Make sure that this - * follows u.uswallow set to null since uswallow overrides all - * normal vision. - */ - vision_recalc(2); + check_special_room(TRUE); /* probably was a trap door */ + if (Punished) unplacebc(); + u.utrap = 0; /* needed in level_tele */ + fill_pit(u.ux, u.uy); + u.ustuck = 0; /* idem */ + u.uinwater = 0; + u.uundetected = 0; /* not hidden, even if means are available */ + keepdogs(FALSE); + if (u.uswallow) /* idem */ + u.uswldtim = u.uswallow = 0; + recalc_mapseen(); /* recalculate map overview before we leave the level */ + /* + * We no longer see anything on the level. Make sure that this + * follows u.uswallow set to null since uswallow overrides all + * normal vision. + */ + vision_recalc(2); - /* - * Save the level we're leaving. If we're entering the endgame, - * we can get rid of all existing levels because they cannot be - * reached any more. We still need to use savelev()'s cleanup - * for the level being left, to recover dynamic memory in use and - * to avoid dangling timers and light sources. - */ - cant_go_back = (newdungeon && In_endgame(newlevel)); - if (!cant_go_back) { - update_mlstmv(); /* current monsters are becoming inactive */ - bufon(fd); /* use buffered output */ - } - savelev(fd, ledger_no(&u.uz), - cant_go_back ? FREE_SAVE : (WRITE_SAVE | FREE_SAVE)); - bclose(fd); - if (cant_go_back) { - /* discard unreachable levels; keep #0 */ - for (l_idx = maxledgerno(); l_idx > 0; --l_idx) - delete_levelfile(l_idx); - /* mark #overview data for all dungeon branches as uninteresting */ - for (l_idx = 0; l_idx < n_dgns; ++l_idx) - remdun_mapseen(l_idx); - } + /* + * Save the level we're leaving. If we're entering the endgame, + * we can get rid of all existing levels because they cannot be + * reached any more. We still need to use savelev()'s cleanup + * for the level being left, to recover dynamic memory in use and + * to avoid dangling timers and light sources. + */ + cant_go_back = (newdungeon && In_endgame(newlevel)); + if (!cant_go_back) { + update_mlstmv(); /* current monsters are becoming inactive */ + bufon(fd); /* use buffered output */ + } + savelev(fd, ledger_no(&u.uz), + cant_go_back ? FREE_SAVE : (WRITE_SAVE | FREE_SAVE)); + bclose(fd); + if (cant_go_back) { + /* discard unreachable levels; keep #0 */ + for (l_idx = maxledgerno(); l_idx > 0; --l_idx) + delete_levelfile(l_idx); + /* mark #overview data for all dungeon branches as uninteresting */ + for (l_idx = 0; l_idx < n_dgns; ++l_idx) + remdun_mapseen(l_idx); + } - if (Is_rogue_level(newlevel) || Is_rogue_level(&u.uz)) - assign_graphics(Is_rogue_level(newlevel) ? ROGUESET : PRIMARY); + if (Is_rogue_level(newlevel) || Is_rogue_level(&u.uz)) + assign_graphics(Is_rogue_level(newlevel) ? ROGUESET : PRIMARY); #ifdef USE_TILES - substitute_tiles(newlevel); + substitute_tiles(newlevel); #endif - /* record this level transition as a potential seen branch unless using - * some non-standard means of transportation (level teleport). - */ - if ((at_stairs || falling || portal) && (u.uz.dnum != newlevel->dnum)) - recbranch_mapseen(&u.uz, newlevel); - assign_level(&u.uz0, &u.uz); - assign_level(&u.uz, newlevel); - assign_level(&u.utolev, newlevel); - u.utotype = 0; - if (dunlev_reached(&u.uz) < dunlev(&u.uz)) - dunlev_reached(&u.uz) = dunlev(&u.uz); - reset_rndmonst(NON_PM); /* u.uz change affects monster generation */ + /* record this level transition as a potential seen branch unless using + * some non-standard means of transportation (level teleport). + */ + if ((at_stairs || falling || portal) && (u.uz.dnum != newlevel->dnum)) + recbranch_mapseen(&u.uz, newlevel); + assign_level(&u.uz0, &u.uz); + assign_level(&u.uz, newlevel); + assign_level(&u.utolev, newlevel); + u.utotype = 0; + if (dunlev_reached(&u.uz) < dunlev(&u.uz)) + dunlev_reached(&u.uz) = dunlev(&u.uz); + reset_rndmonst(NON_PM); /* u.uz change affects monster generation */ - /* set default level change destination areas */ - /* the special level code may override these */ - (void) memset((genericptr_t) &updest, 0, sizeof updest); - (void) memset((genericptr_t) &dndest, 0, sizeof dndest); + /* set default level change destination areas */ + /* the special level code may override these */ + (void) memset((genericptr_t) &updest, 0, sizeof updest); + (void) memset((genericptr_t) &dndest, 0, sizeof dndest); - if (!(level_info[new_ledger].flags & LFILE_EXISTS)) { - /* entering this level for first time; make it now */ - if (level_info[new_ledger].flags & (FORGOTTEN|VISITED)) { - impossible("goto_level: returning to discarded level?"); - level_info[new_ledger].flags &= ~(FORGOTTEN|VISITED); - } - mklev(); - new = TRUE; /* made the level */ - } else { - /* returning to previously visited level; reload it */ - fd = open_levelfile(new_ledger, whynot); - if (fd < 0) { - pline1(whynot); - pline("Probably someone removed it."); - Strcpy(killer.name, whynot); - done(TRICKED); - /* we'll reach here if running in wizard mode */ - error("Cannot continue this game."); - } - minit(); /* ZEROCOMP */ - getlev(fd, hackpid, new_ledger, FALSE); + if (!(level_info[new_ledger].flags & LFILE_EXISTS)) { + /* entering this level for first time; make it now */ + if (level_info[new_ledger].flags & (FORGOTTEN|VISITED)) { + impossible("goto_level: returning to discarded level?"); + level_info[new_ledger].flags &= ~(FORGOTTEN|VISITED); + } + mklev(); + new = TRUE; /* made the level */ + } else { + /* returning to previously visited level; reload it */ + fd = open_levelfile(new_ledger, whynot); + if (fd < 0) { + pline1(whynot); + pline("Probably someone removed it."); + Strcpy(killer.name, whynot); + done(TRICKED); + /* we'll reach here if running in wizard mode */ + error("Cannot continue this game."); + } + minit(); /* ZEROCOMP */ + getlev(fd, hackpid, new_ledger, FALSE); (void) nhclose(fd); - oinit(); /* reassign level dependent obj probabilities */ - } - /* do this prior to level-change pline messages */ - vision_reset(); /* clear old level's line-of-sight */ - vision_full_recalc = 0; /* don't let that reenable vision yet */ - flush_screen(-1); /* ensure all map flushes are postponed */ + oinit(); /* reassign level dependent obj probabilities */ + } + /* do this prior to level-change pline messages */ + vision_reset(); /* clear old level's line-of-sight */ + vision_full_recalc = 0; /* don't let that reenable vision yet */ + flush_screen(-1); /* ensure all map flushes are postponed */ - if (portal && !In_endgame(&u.uz)) { - /* find the portal on the new level */ - register struct trap *ttrap; + if (portal && !In_endgame(&u.uz)) { + /* find the portal on the new level */ + register struct trap *ttrap; - for (ttrap = ftrap; ttrap; ttrap = ttrap->ntrap) - if (ttrap->ttyp == MAGIC_PORTAL) break; + for (ttrap = ftrap; ttrap; ttrap = ttrap->ntrap) + if (ttrap->ttyp == MAGIC_PORTAL) break; - if (!ttrap) panic("goto_level: no corresponding portal!"); - seetrap(ttrap); - u_on_newpos(ttrap->tx, ttrap->ty); - } else if (at_stairs && !In_endgame(&u.uz)) { - if (up) { - if (at_ladder) - u_on_newpos(xdnladder, ydnladder); - else if (newdungeon) - u_on_sstairs(1); - else - u_on_dnstairs(); - /* you climb up the {stairs|ladder}; - fly up the stairs; fly up along the ladder */ - pline("%s %s up%s the %s.", - (Punished && !Levitation) ? "With great effort you" : - "You", - Flying ? "fly" : "climb", - (Flying && at_ladder) ? " along" : "", - at_ladder ? "ladder" : "stairs"); - } else { /* down */ - if (at_ladder) - u_on_newpos(xupladder, yupladder); - else if (newdungeon) - u_on_sstairs(0); - else - u_on_upstairs(); - if (!u.dz) { - ; /* stayed on same level? (no transit effects) */ - } else if (Flying) { - if (flags.verbose) - You("fly down %s.", - at_ladder ? "along the ladder" : "the stairs"); - } else if (near_capacity() > UNENCUMBERED || - Punished || Fumbling) { - You("fall down the %s.", at_ladder ? "ladder" : "stairs"); - if (Punished) { - drag_down(); - if (carried(uball)) { - if (uwep == uball) - setuwep((struct obj *)0); - if (uswapwep == uball) - setuswapwep((struct obj *)0); - if (uquiver == uball) - setuqwep((struct obj *)0); - freeinv(uball); - } - } - /* falling off steed has its own losehp() call */ - if (u.usteed) - dismount_steed(DISMOUNT_FELL); - else - losehp(Maybe_Half_Phys(rnd(3)), - at_ladder ? "falling off a ladder" : - "tumbling down a flight of stairs", - KILLED_BY); - selftouch("Falling, you"); - } else { /* ordinary descent */ - if (flags.verbose) - You("%s.", at_ladder ? "climb down the ladder" : - "descend the stairs"); - } - } - } else { /* trap door or level_tele or In_endgame */ - u_on_rndspot((up ? 1 : 0) | (was_in_W_tower ? 2 : 0)); - if (falling) { - if (Punished) ballfall(); - selftouch("Falling, you"); - } - } + if (!ttrap) panic("goto_level: no corresponding portal!"); + seetrap(ttrap); + u_on_newpos(ttrap->tx, ttrap->ty); + } else if (at_stairs && !In_endgame(&u.uz)) { + if (up) { + if (at_ladder) + u_on_newpos(xdnladder, ydnladder); + else if (newdungeon) + u_on_sstairs(1); + else + u_on_dnstairs(); + /* you climb up the {stairs|ladder}; + fly up the stairs; fly up along the ladder */ + pline("%s %s up%s the %s.", + (Punished && !Levitation) ? "With great effort you" : + "You", + Flying ? "fly" : "climb", + (Flying && at_ladder) ? " along" : "", + at_ladder ? "ladder" : "stairs"); + } else { /* down */ + if (at_ladder) + u_on_newpos(xupladder, yupladder); + else if (newdungeon) + u_on_sstairs(0); + else + u_on_upstairs(); + if (!u.dz) { + ; /* stayed on same level? (no transit effects) */ + } else if (Flying) { + if (flags.verbose) + You("fly down %s.", + at_ladder ? "along the ladder" : "the stairs"); + } else if (near_capacity() > UNENCUMBERED || + Punished || Fumbling) { + You("fall down the %s.", at_ladder ? "ladder" : "stairs"); + if (Punished) { + drag_down(); + if (carried(uball)) { + if (uwep == uball) + setuwep((struct obj *)0); + if (uswapwep == uball) + setuswapwep((struct obj *)0); + if (uquiver == uball) + setuqwep((struct obj *)0); + freeinv(uball); + } + } + /* falling off steed has its own losehp() call */ + if (u.usteed) + dismount_steed(DISMOUNT_FELL); + else + losehp(Maybe_Half_Phys(rnd(3)), + at_ladder ? "falling off a ladder" : + "tumbling down a flight of stairs", + KILLED_BY); + selftouch("Falling, you"); + } else { /* ordinary descent */ + if (flags.verbose) + You("%s.", at_ladder ? "climb down the ladder" : + "descend the stairs"); + } + } + } else { /* trap door or level_tele or In_endgame */ + u_on_rndspot((up ? 1 : 0) | (was_in_W_tower ? 2 : 0)); + if (falling) { + if (Punished) ballfall(); + selftouch("Falling, you"); + } + } - if (Punished) placebc(); - obj_delivery(FALSE); - losedogs(); - kill_genocided_monsters(); /* for those wiped out while in limbo */ - /* - * Expire all timers that have gone off while away. Must be - * after migrating monsters and objects are delivered - * (losedogs and obj_delivery). - */ - run_timers(); + if (Punished) placebc(); + obj_delivery(FALSE); + losedogs(); + kill_genocided_monsters(); /* for those wiped out while in limbo */ + /* + * Expire all timers that have gone off while away. Must be + * after migrating monsters and objects are delivered + * (losedogs and obj_delivery). + */ + run_timers(); - initrack(); + initrack(); - if ((mtmp = m_at(u.ux, u.uy)) != 0 && mtmp != u.usteed) { - /* There's a monster at your target destination; it might be one - which accompanied you--see mon_arrive(dogmove.c)--or perhaps - it was already here. Randomly move you to an adjacent spot - or else the monster to any nearby location. Prior to 3.3.0 - the latter was done unconditionally. */ - coord cc; + if ((mtmp = m_at(u.ux, u.uy)) != 0 && mtmp != u.usteed) { + /* There's a monster at your target destination; it might be one + which accompanied you--see mon_arrive(dogmove.c)--or perhaps + it was already here. Randomly move you to an adjacent spot + or else the monster to any nearby location. Prior to 3.3.0 + the latter was done unconditionally. */ + coord cc; - if (!rn2(2) && - enexto(&cc, u.ux, u.uy, youmonst.data) && - distu(cc.x, cc.y) <= 2) - u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/ - else - mnexto(mtmp); + if (!rn2(2) && + enexto(&cc, u.ux, u.uy, youmonst.data) && + distu(cc.x, cc.y) <= 2) + u_on_newpos(cc.x, cc.y); /*[maybe give message here?]*/ + else + mnexto(mtmp); - if ((mtmp = m_at(u.ux, u.uy)) != 0) { - /* there was an unconditional impossible("mnearto failed") - here, but it's not impossible and we're prepared to cope - with the situation, so only say something when debugging */ - if (wizard) pline("(monster in hero's way)"); - if (!rloc(mtmp, TRUE)) - /* no room to move it; send it away, to return later */ - migrate_to_level(mtmp, ledger_no(&u.uz), - MIGR_RANDOM, (coord *)0); - } - } + if ((mtmp = m_at(u.ux, u.uy)) != 0) { + /* there was an unconditional impossible("mnearto failed") + here, but it's not impossible and we're prepared to cope + with the situation, so only say something when debugging */ + if (wizard) pline("(monster in hero's way)"); + if (!rloc(mtmp, TRUE)) + /* no room to move it; send it away, to return later */ + migrate_to_level(mtmp, ledger_no(&u.uz), + MIGR_RANDOM, (coord *)0); + } + } - /* initial movement of bubbles just before vision_recalc */ + /* initial movement of bubbles just before vision_recalc */ if (Is_waterlevel(&u.uz) || Is_airlevel(&u.uz)) - movebubbles(); + movebubbles(); else if (Is_firelevel(&u.uz)) fumaroles(); - if (level_info[new_ledger].flags & FORGOTTEN) { - forget_map(ALL_MAP); /* forget the map */ - forget_traps(); /* forget all traps too */ - familiar = TRUE; - level_info[new_ledger].flags &= ~FORGOTTEN; - } + if (level_info[new_ledger].flags & FORGOTTEN) { + forget_map(ALL_MAP); /* forget the map */ + forget_traps(); /* forget all traps too */ + familiar = TRUE; + level_info[new_ledger].flags &= ~FORGOTTEN; + } - /* Reset the screen. */ - vision_reset(); /* reset the blockages */ - docrt(); /* does a full vision recalc */ - flush_screen(-1); + /* Reset the screen. */ + vision_reset(); /* reset the blockages */ + docrt(); /* does a full vision recalc */ + flush_screen(-1); - /* - * Move all plines beyond the screen reset. - */ + /* + * Move all plines beyond the screen reset. + */ - /* special levels can have a custom arrival message */ - deliver_splev_message(); + /* special levels can have a custom arrival message */ + deliver_splev_message(); - /* give room entrance message, if any */ - check_special_room(FALSE); + /* give room entrance message, if any */ + check_special_room(FALSE); - /* deliver objects traveling with player */ - obj_delivery(TRUE); + /* deliver objects traveling with player */ + obj_delivery(TRUE); - /* Check whether we just entered Gehennom. */ - if (!In_hell(&u.uz0) && Inhell) { - if (Is_valley(&u.uz)) { - You("arrive at the Valley of the Dead..."); - pline_The("odor of burnt flesh and decay pervades the air."); + /* Check whether we just entered Gehennom. */ + if (!In_hell(&u.uz0) && Inhell) { + if (Is_valley(&u.uz)) { + You("arrive at the Valley of the Dead..."); + pline_The("odor of burnt flesh and decay pervades the air."); #ifdef MICRO - display_nhwindow(WIN_MESSAGE, FALSE); + display_nhwindow(WIN_MESSAGE, FALSE); #endif - You_hear("groans and moans everywhere."); - } else pline("It is hot here. You smell smoke..."); + You_hear("groans and moans everywhere."); + } else pline("It is hot here. You smell smoke..."); u.uachieve.enter_gehennom = 1; - } - /* in case we've managed to bypass the Valley's stairway down */ - if (Inhell && !Is_valley(&u.uz)) u.uevent.gehennom_entered = 1; + } + /* in case we've managed to bypass the Valley's stairway down */ + if (Inhell && !Is_valley(&u.uz)) u.uevent.gehennom_entered = 1; - if (familiar) { - static const char * const fam_msgs[4] = { - "You have a sense of deja vu.", - "You feel like you've been here before.", - "This place %s familiar...", - 0 /* no message */ - }; - static const char * const halu_fam_msgs[4] = { - "Whoa! Everything %s different.", - "You are surrounded by twisty little passages, all alike.", - "Gee, this %s like uncle Conan's place...", - 0 /* no message */ - }; - const char *mesg; - char buf[BUFSZ]; - int which = rn2(4); + if (familiar) { + static const char * const fam_msgs[4] = { + "You have a sense of deja vu.", + "You feel like you've been here before.", + "This place %s familiar...", + 0 /* no message */ + }; + static const char * const halu_fam_msgs[4] = { + "Whoa! Everything %s different.", + "You are surrounded by twisty little passages, all alike.", + "Gee, this %s like uncle Conan's place...", + 0 /* no message */ + }; + const char *mesg; + char buf[BUFSZ]; + int which = rn2(4); - if (Hallucination) - mesg = halu_fam_msgs[which]; - else - mesg = fam_msgs[which]; - if (mesg && index(mesg, '%')) { - Sprintf(buf, mesg, !Blind ? "looks" : "seems"); - mesg = buf; - } - if (mesg) pline1(mesg); - } + if (Hallucination) + mesg = halu_fam_msgs[which]; + else + mesg = fam_msgs[which]; + if (mesg && index(mesg, '%')) { + Sprintf(buf, mesg, !Blind ? "looks" : "seems"); + mesg = buf; + } + if (mesg) pline1(mesg); + } - /* special location arrival messages/events */ - if (In_endgame(&u.uz)) { - if (new && on_level(&u.uz, &astral_level)) - final_level(); /* guardian angel,&c */ - else if (newdungeon && u.uhave.amulet) - resurrect(); /* force confrontation with Wizard */ - } else if (In_quest(&u.uz)) { - onquest(); /* might be reaching locate|goal level */ - } else if (In_V_tower(&u.uz)) { - if (newdungeon && In_hell(&u.uz0)) - pline_The("heat and smoke are gone."); - } else if (Is_knox(&u.uz)) { - /* alarm stops working once Croesus has died */ - if (new || !mvitals[PM_CROESUS].died) { - You("have penetrated a high security area!"); - pline("An alarm sounds!"); - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - mtmp->msleeping = 0; - } - } - } else { - if (new && Is_rogue_level(&u.uz)) - You("enter what seems to be an older, more primitive world."); - /* main dungeon message from your quest leader */ - if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest") && - !(u.uevent.qcompleted || u.uevent.qexpelled || - quest_status.leader_is_dead)) { - if (!u.uevent.qcalled) { - u.uevent.qcalled = 1; - com_pager(2); /* main "leader needs help" message */ - } else { /* reminder message */ - com_pager(Role_if(PM_ROGUE) ? 4 : 3); - } - } - } + /* special location arrival messages/events */ + if (In_endgame(&u.uz)) { + if (new && on_level(&u.uz, &astral_level)) + final_level(); /* guardian angel,&c */ + else if (newdungeon && u.uhave.amulet) + resurrect(); /* force confrontation with Wizard */ + } else if (In_quest(&u.uz)) { + onquest(); /* might be reaching locate|goal level */ + } else if (In_V_tower(&u.uz)) { + if (newdungeon && In_hell(&u.uz0)) + pline_The("heat and smoke are gone."); + } else if (Is_knox(&u.uz)) { + /* alarm stops working once Croesus has died */ + if (new || !mvitals[PM_CROESUS].died) { + You("have penetrated a high security area!"); + pline("An alarm sounds!"); + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + mtmp->msleeping = 0; + } + } + } else { + if (new && Is_rogue_level(&u.uz)) + You("enter what seems to be an older, more primitive world."); + /* main dungeon message from your quest leader */ + if (!In_quest(&u.uz0) && at_dgn_entrance("The Quest") && + !(u.uevent.qcompleted || u.uevent.qexpelled || + quest_status.leader_is_dead)) { + if (!u.uevent.qcalled) { + u.uevent.qcalled = 1; + com_pager(2); /* main "leader needs help" message */ + } else { /* reminder message */ + com_pager(Role_if(PM_ROGUE) ? 4 : 3); + } + } + } - assign_level(&u.uz0, &u.uz); /* reset u.uz0 */ + assign_level(&u.uz0, &u.uz); /* reset u.uz0 */ #ifdef INSURANCE - save_currentstate(); + save_currentstate(); #endif - /* assume this will always return TRUE when changing level */ - (void) in_out_region(u.ux, u.uy); - (void) pickup(1); + /* assume this will always return TRUE when changing level */ + (void) in_out_region(u.ux, u.uy); + (void) pickup(1); context.polearm.hitmon = NULL; } STATIC_OVL void final_level() { - struct monst *mtmp; + struct monst *mtmp; - /* reset monster hostility relative to player */ - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - reset_hostility(mtmp); - } + /* reset monster hostility relative to player */ + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + reset_hostility(mtmp); + } - /* create some player-monsters */ - create_mplayers(rn1(4, 3), TRUE); + /* create some player-monsters */ + create_mplayers(rn1(4, 3), TRUE); - /* create a guardian angel next to player, if worthy */ - gain_guardian_angel(); + /* create a guardian angel next to player, if worthy */ + gain_guardian_angel(); } static char *dfr_pre_msg = 0, /* pline() before level change */ - *dfr_post_msg = 0; /* pline() after level change */ + *dfr_post_msg = 0; /* pline() after level change */ /* change levels at the end of this turn, after monsters finish moving */ void @@ -1436,49 +1444,49 @@ boolean at_stairs, falling; int portal_flag; const char *pre_msg, *post_msg; { - int typmask = 0100; /* non-zero triggers `deferred_goto' */ + int typmask = 0100; /* non-zero triggers `deferred_goto' */ - /* destination flags (`goto_level' args) */ - if (at_stairs) typmask |= 1; - if (falling) typmask |= 2; - if (portal_flag) typmask |= 4; - if (portal_flag < 0) typmask |= 0200; /* flag for portal removal */ - u.utotype = typmask; - /* destination level */ - assign_level(&u.utolev, tolev); + /* destination flags (`goto_level' args) */ + if (at_stairs) typmask |= 1; + if (falling) typmask |= 2; + if (portal_flag) typmask |= 4; + if (portal_flag < 0) typmask |= 0200; /* flag for portal removal */ + u.utotype = typmask; + /* destination level */ + assign_level(&u.utolev, tolev); - if (pre_msg) - dfr_pre_msg = dupstr(pre_msg); - if (post_msg) - dfr_post_msg = dupstr(post_msg); + if (pre_msg) + dfr_pre_msg = dupstr(pre_msg); + if (post_msg) + dfr_post_msg = dupstr(post_msg); } /* handle something like portal ejection */ void deferred_goto() { - if (!on_level(&u.uz, &u.utolev)) { - d_level dest; - int typmask = u.utotype; /* save it; goto_level zeroes u.utotype */ + if (!on_level(&u.uz, &u.utolev)) { + d_level dest; + int typmask = u.utotype; /* save it; goto_level zeroes u.utotype */ - assign_level(&dest, &u.utolev); - if (dfr_pre_msg) pline1(dfr_pre_msg); - goto_level(&dest, !!(typmask&1), !!(typmask&2), !!(typmask&4)); - if (typmask & 0200) { /* remove portal */ - struct trap *t = t_at(u.ux, u.uy); + assign_level(&dest, &u.utolev); + if (dfr_pre_msg) pline1(dfr_pre_msg); + goto_level(&dest, !!(typmask&1), !!(typmask&2), !!(typmask&4)); + if (typmask & 0200) { /* remove portal */ + struct trap *t = t_at(u.ux, u.uy); - if (t) { - deltrap(t); - newsym(u.ux, u.uy); - } - } - if (dfr_post_msg) pline1(dfr_post_msg); - } - u.utotype = 0; /* our caller keys off of this */ - if (dfr_pre_msg) - free((genericptr_t)dfr_pre_msg), dfr_pre_msg = 0; - if (dfr_post_msg) - free((genericptr_t)dfr_post_msg), dfr_post_msg = 0; + if (t) { + deltrap(t); + newsym(u.ux, u.uy); + } + } + if (dfr_post_msg) pline1(dfr_post_msg); + } + u.utotype = 0; /* our caller keys off of this */ + if (dfr_pre_msg) + free((genericptr_t)dfr_pre_msg), dfr_pre_msg = 0; + if (dfr_post_msg) + free((genericptr_t)dfr_post_msg), dfr_post_msg = 0; } /* @@ -1500,73 +1508,73 @@ struct obj *corpse; is_uwep = (corpse == uwep); chewed = (corpse->oeaten != 0); Strcpy(cname, corpse_xname(corpse, - chewed ? "bite-covered" : (const char *)0, - CXN_SINGULAR)); + chewed ? "bite-covered" : (const char *)0, + CXN_SINGULAR)); mcarry = (where == OBJ_MINVENT) ? corpse->ocarry : 0; if (where == OBJ_CONTAINED) { - struct monst *mtmp2; + struct monst *mtmp2; - container = corpse->ocontainer; - mtmp2 = get_container_location(container, &container_where, (int *)0); - /* container_where is the outermost container's location even if nested */ - if (container_where == OBJ_MINVENT && mtmp2) mcarry = mtmp2; + container = corpse->ocontainer; + mtmp2 = get_container_location(container, &container_where, (int *)0); + /* container_where is the outermost container's location even if nested */ + if (container_where == OBJ_MINVENT && mtmp2) mcarry = mtmp2; } mtmp = revive(corpse, FALSE); /* corpse is gone if successful */ if (mtmp) { - switch (where) { - case OBJ_INVENT: - if (is_uwep) - pline_The("%s writhes out of your grasp!", cname); - else - You_feel("squirming in your backpack!"); - break; + switch (where) { + case OBJ_INVENT: + if (is_uwep) + pline_The("%s writhes out of your grasp!", cname); + else + You_feel("squirming in your backpack!"); + break; - case OBJ_FLOOR: - if (cansee(mtmp->mx, mtmp->my)) - pline("%s rises from the dead!", chewed ? - Adjmonnam(mtmp, "bite-covered") : Monnam(mtmp)); - break; + case OBJ_FLOOR: + if (cansee(mtmp->mx, mtmp->my)) + pline("%s rises from the dead!", chewed ? + Adjmonnam(mtmp, "bite-covered") : Monnam(mtmp)); + break; - case OBJ_MINVENT: /* probably a nymph's */ - if (cansee(mtmp->mx, mtmp->my)) { - if (canseemon(mcarry)) - pline("Startled, %s drops %s as it revives!", - mon_nam(mcarry), an(cname)); - else - pline("%s suddenly appears!", chewed ? - Adjmonnam(mtmp, "bite-covered") : Monnam(mtmp)); - } - break; - case OBJ_CONTAINED: - { - char sackname[BUFSZ]; + case OBJ_MINVENT: /* probably a nymph's */ + if (cansee(mtmp->mx, mtmp->my)) { + if (canseemon(mcarry)) + pline("Startled, %s drops %s as it revives!", + mon_nam(mcarry), an(cname)); + else + pline("%s suddenly appears!", chewed ? + Adjmonnam(mtmp, "bite-covered") : Monnam(mtmp)); + } + break; + case OBJ_CONTAINED: + { + char sackname[BUFSZ]; - if (container_where == OBJ_MINVENT && - cansee(mtmp->mx, mtmp->my) && - mcarry && canseemon(mcarry) && container) { - pline("%s writhes out of %s!", - Amonnam(mtmp), yname(container)); - } else if (container_where == OBJ_INVENT && container) { - Strcpy(sackname, an(xname(container))); - pline("%s %s out of %s in your pack!", - Blind ? Something : Amonnam(mtmp), - locomotion(mtmp->data,"writhes"), - sackname); - } else if (container_where == OBJ_FLOOR && container && - cansee(mtmp->mx, mtmp->my)) { - Strcpy(sackname, an(xname(container))); - pline("%s escapes from %s!", Amonnam(mtmp), sackname); - } - break; - } - default: - /* we should be able to handle the other cases... */ - impossible("revive_corpse: lost corpse @ %d", where); - break; - } - return TRUE; + if (container_where == OBJ_MINVENT && + cansee(mtmp->mx, mtmp->my) && + mcarry && canseemon(mcarry) && container) { + pline("%s writhes out of %s!", + Amonnam(mtmp), yname(container)); + } else if (container_where == OBJ_INVENT && container) { + Strcpy(sackname, an(xname(container))); + pline("%s %s out of %s in your pack!", + Blind ? Something : Amonnam(mtmp), + locomotion(mtmp->data,"writhes"), + sackname); + } else if (container_where == OBJ_FLOOR && container && + cansee(mtmp->mx, mtmp->my)) { + Strcpy(sackname, an(xname(container))); + pline("%s escapes from %s!", Amonnam(mtmp), sackname); + } + break; + } + default: + /* we should be able to handle the other cases... */ + impossible("revive_corpse: lost corpse @ %d", where); + break; + } + return TRUE; } return FALSE; } @@ -1586,82 +1594,82 @@ long timeout UNUSED; /* corpse will revive somewhere else if there is a monster in the way; Riders get a chance to try to bump the obstacle out of their way */ if ((mptr->mflags3 & M3_DISPLACES) != 0 && body->where == OBJ_FLOOR && - get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0) { - boolean notice_it = canseemon(mtmp); /* before rloc() */ - char *monname = Monnam(mtmp); + get_obj_location(body, &x, &y, 0) && (mtmp = m_at(x, y)) != 0) { + boolean notice_it = canseemon(mtmp); /* before rloc() */ + char *monname = Monnam(mtmp); - if (rloc(mtmp, TRUE)) { - if (notice_it && !canseemon(mtmp)) - pline("%s vanishes.", monname); - else if (!notice_it && canseemon(mtmp)) - pline("%s appears.", Monnam(mtmp)); /* not pre-rloc monname */ - else if (notice_it && dist2(mtmp->mx, mtmp->my, x, y) > 2) - pline("%s teleports.", monname); /* saw it and still see it */ - } + if (rloc(mtmp, TRUE)) { + if (notice_it && !canseemon(mtmp)) + pline("%s vanishes.", monname); + else if (!notice_it && canseemon(mtmp)) + pline("%s appears.", Monnam(mtmp)); /* not pre-rloc monname */ + else if (notice_it && dist2(mtmp->mx, mtmp->my, x, y) > 2) + pline("%s teleports.", monname); /* saw it and still see it */ + } } /* if we succeed, the corpse is gone */ if (!revive_corpse(body)) { - long when; - int action; + long when; + int action; - if (is_rider(mptr) && rn2(99)) { /* Rider usually tries again */ - action = REVIVE_MON; - for (when = 3L; when < 67L; when++) - if (!rn2(3)) break; - } else { /* rot this corpse away */ - You_feel("%sless hassled.", is_rider(mptr) ? "much " : ""); - action = ROT_CORPSE; - when = 250L - (monstermoves - body->age); - if (when < 1L) when = 1L; - } - (void) start_timer(when, TIMER_OBJECT, action, arg); + if (is_rider(mptr) && rn2(99)) { /* Rider usually tries again */ + action = REVIVE_MON; + for (when = 3L; when < 67L; when++) + if (!rn2(3)) break; + } else { /* rot this corpse away */ + You_feel("%sless hassled.", is_rider(mptr) ? "much " : ""); + action = ROT_CORPSE; + when = 250L - (monstermoves - body->age); + if (when < 1L) when = 1L; + } + (void) start_timer(when, TIMER_OBJECT, action, arg); } } int donull() { - return(1); /* Do nothing, but let other things happen */ + return(1); /* Do nothing, but let other things happen */ } STATIC_PTR int wipeoff(VOID_ARGS) { - if(u.ucreamed < 4) u.ucreamed = 0; - else u.ucreamed -= 4; - if (Blinded < 4) Blinded = 0; - else Blinded -= 4; - if (!Blinded) { - pline("You've got the glop off."); - u.ucreamed = 0; - if (!gulp_blnd_check()) { - Blinded = 1; - make_blinded(0L,TRUE); - } - return(0); - } else if (!u.ucreamed) { - Your("%s feels clean now.", body_part(FACE)); - return(0); - } - return(1); /* still busy */ + if(u.ucreamed < 4) u.ucreamed = 0; + else u.ucreamed -= 4; + if (Blinded < 4) Blinded = 0; + else Blinded -= 4; + if (!Blinded) { + pline("You've got the glop off."); + u.ucreamed = 0; + if (!gulp_blnd_check()) { + Blinded = 1; + make_blinded(0L,TRUE); + } + return(0); + } else if (!u.ucreamed) { + Your("%s feels clean now.", body_part(FACE)); + return(0); + } + return(1); /* still busy */ } int dowipe() { - if(u.ucreamed) { - static NEARDATA char buf[39]; + if(u.ucreamed) { + static NEARDATA char buf[39]; - Sprintf(buf, "wiping off your %s", body_part(FACE)); - set_occupation(wipeoff, buf, 0); - /* Not totally correct; what if they change back after now - * but before they're finished wiping? - */ - return(1); - } - Your("%s is already clean.", body_part(FACE)); - return(1); + Sprintf(buf, "wiping off your %s", body_part(FACE)); + set_occupation(wipeoff, buf, 0); + /* Not totally correct; what if they change back after now + * but before they're finished wiping? + */ + return(1); + } + Your("%s is already clean.", body_part(FACE)); + return(1); } void @@ -1669,57 +1677,57 @@ set_wounded_legs(side, timex) register long side; register int timex; { - /* KMH -- STEED - * If you are riding, your steed gets the wounded legs instead. - * You still call this function, but don't lose hp. - * Caller is also responsible for adjusting messages. - */ + /* KMH -- STEED + * If you are riding, your steed gets the wounded legs instead. + * You still call this function, but don't lose hp. + * Caller is also responsible for adjusting messages. + */ - if(!Wounded_legs) { - ATEMP(A_DEX)--; - context.botl = 1; - } + if(!Wounded_legs) { + ATEMP(A_DEX)--; + context.botl = 1; + } - if(!Wounded_legs || (HWounded_legs & TIMEOUT)) - HWounded_legs = timex; - EWounded_legs = side; - (void)encumber_msg(); + if(!Wounded_legs || (HWounded_legs & TIMEOUT)) + HWounded_legs = timex; + EWounded_legs = side; + (void)encumber_msg(); } void heal_legs() { - if (Wounded_legs) { - if (ATEMP(A_DEX) < 0) { - ATEMP(A_DEX)++; - context.botl = 1; - } + if (Wounded_legs) { + if (ATEMP(A_DEX) < 0) { + ATEMP(A_DEX)++; + context.botl = 1; + } - if (!u.usteed) - { - const char *legs = body_part(LEG); + if (!u.usteed) + { + const char *legs = body_part(LEG); - if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES) - legs = makeplural(legs); - /* this used to say "somewhat better" but that was - misleading since legs are being fully healed */ - Your("%s %s better.", legs, vtense(legs, "feel")); - } + if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES) + legs = makeplural(legs); + /* this used to say "somewhat better" but that was + misleading since legs are being fully healed */ + Your("%s %s better.", legs, vtense(legs, "feel")); + } - HWounded_legs = EWounded_legs = 0; + HWounded_legs = EWounded_legs = 0; - /* Wounded_legs reduces carrying capacity, so we want - an encumbrance check when they're healed. However, - while dismounting, first steed's legs get healed, - then hero is dropped to floor and a new encumbrance - check is made [in dismount_steed()]. So don't give - encumbrance feedback during the dismount stage - because it could seem to be shown out of order and - it might be immediately contradicted [able to carry - more when steed becomes healthy, then possible floor - feedback, then able to carry less when back on foot]. */ - if (!in_steed_dismounting) (void)encumber_msg(); - } + /* Wounded_legs reduces carrying capacity, so we want + an encumbrance check when they're healed. However, + while dismounting, first steed's legs get healed, + then hero is dropped to floor and a new encumbrance + check is made [in dismount_steed()]. So don't give + encumbrance feedback during the dismount stage + because it could seem to be shown out of order and + it might be immediately contradicted [able to carry + more when steed becomes healthy, then possible floor + feedback, then able to carry less when back on foot]. */ + if (!in_steed_dismounting) (void)encumber_msg(); + } } /*do.c*/ diff --git a/src/eat.c b/src/eat.c index cb92f16c1..ea3f77691 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1612,7 +1612,7 @@ start_eating(otmp) /* called as you start to eat */ context.victual.fullwarn = context.victual.doreset = FALSE; context.victual.eating = TRUE; - if (otmp->otyp == CORPSE) { + if (otmp->otyp == CORPSE || otmp->globby) { cprefx(context.victual.piece->corpsenm); if (!context.victual.piece || !context.victual.eating) { /* rider revived, or died and lifesaved */ @@ -2127,7 +2127,7 @@ struct obj *otmp; !Stone_resistance && !poly_when_stoned(youmonst.data)); - if (mnum == PM_GREEN_SLIME) + if (mnum == PM_GREEN_SLIME || otmp->otyp == GLOB_OF_GREEN_SLIME) stoneorslime = (!Unchanging && !slimeproof(youmonst.data)); if (cadaver && !nonrotting_corpse(mnum)) { @@ -2397,7 +2397,7 @@ doeat() /* generic "eat" command funtion (see cmd.c) */ * for normal vs. rotten food. The reqtime and nutrit values are * then adjusted in accordance with the amount of food left. */ - if(otmp->otyp == CORPSE) { + if(otmp->otyp == CORPSE || otmp->globby) { int tmp = eatcorpse(otmp); if (tmp == 2) { /* used up */ diff --git a/src/end.c b/src/end.c index 42acca2ba..9767e0481 100644 --- a/src/end.c +++ b/src/end.c @@ -1238,7 +1238,7 @@ boolean identified, all_containers, reportempty; { register struct obj *box, *obj; struct obj **oarray; - int i,j,n; + int i,n; char *invlet; char buf[BUFSZ]; boolean cat, deadcat; @@ -1437,43 +1437,72 @@ num_genocides() return n; } +int +num_extinct() +{ + int i, n = 0; + + for (i = LOW_PM; i < NUMMONS; ++i) + if (!(mvitals[i].mvflags & G_GENOD) && + (mvitals[i].mvflags & G_GONE) && + !(mons[i].geno & G_UNIQ)) ++n; + + return n; +} + + STATIC_OVL void list_genocided(defquery, ask) char defquery; boolean ask; { register int i; - int ngenocided; + int ngenocided, nextinct; char c; winid klwin; char buf[BUFSZ]; ngenocided = num_genocides(); + nextinct = num_extinct(); - /* genocided species list */ - if (ngenocided != 0) { - c = ask ? yn_function("Do you want a list of species genocided?", - ynqchars, defquery) : defquery; + /* genocided or extinct species list */ + if (ngenocided != 0 || nextinct != 0) { + Sprintf(buf, "Do you want a list of %sspecies%s%s?", + (nextinct && !ngenocided) ? "extinct " : "", + (ngenocided) ? " genocided" : "", + (nextinct && ngenocided) ? " and extinct" : ""); + c = ask ? yn_function(buf, ynqchars, defquery) : defquery; if (c == 'q') done_stopprint++; if (c == 'y') { klwin = create_nhwindow(NHW_MENU); - putstr(klwin, 0, "Genocided species:"); + Sprintf(buf, "%s%s species:", + (ngenocided) ? "Genocided" : "Extinct", + (nextinct && ngenocided) ? " or extinct" : ""); + putstr(klwin, 0, buf); putstr(klwin, 0, ""); for (i = LOW_PM; i < NUMMONS; i++) - if (mvitals[i].mvflags & G_GENOD) { + if (mvitals[i].mvflags & G_GONE && !(mons[i].geno & G_UNIQ)) { if ((mons[i].geno & G_UNIQ) && i != PM_HIGH_PRIEST) Sprintf(buf, "%s%s", !type_is_pname(&mons[i]) ? "" : "the ", mons[i].mname); else Strcpy(buf, makeplural(mons[i].mname)); + if (!(mvitals[i].mvflags & G_GENOD)) + Strcat(buf, " (extinct)"); putstr(klwin, 0, buf); } putstr(klwin, 0, ""); - Sprintf(buf, "%d species genocided.", ngenocided); - putstr(klwin, 0, buf); + if (ngenocided > 0) { + Sprintf(buf, "%d species genocided.", ngenocided); + putstr(klwin, 0, buf); + } + if (nextinct > 0) { + Sprintf(buf, "%d species extinct.", nextinct); + putstr(klwin, 0, buf); + } display_nhwindow(klwin, TRUE); destroy_nhwindow(klwin); diff --git a/src/files.c b/src/files.c index 326eb2e3c..cd6f735d5 100644 --- a/src/files.c +++ b/src/files.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 files.c $NHDT-Date: 1426969026 2015/03/21 20:17:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.137 $ */ +/* NetHack 3.5 files.c $NHDT-Date: 1427337311 2015/03/26 02:35:11 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.141 $ */ /* NetHack 3.5 files.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.124 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -190,7 +190,7 @@ STATIC_DCL char *FDECL(make_lockname, (const char *,char *)); #endif STATIC_DCL FILE *FDECL(fopen_config_file, (const char *, int)); STATIC_DCL int FDECL(get_uchars, - (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *)); + (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *)); int FDECL(parse_config_line, (FILE *,char *,int)); STATIC_DCL FILE *NDECL(fopen_sym_file); STATIC_DCL void FDECL(set_symhandling, (char *,int)); @@ -232,34 +232,34 @@ char quotechar; char *s, *callerbuf; int bufsz; { - char *sp, *op; - int cnt = 0; - static char hexdigits[] = "0123456789ABCDEF"; + char *sp, *op; + int cnt = 0; + static char hexdigits[] = "0123456789ABCDEF"; - sp = s; - op = callerbuf; - *op = '\0'; - - while (*sp) { - /* Do we have room for one more character or encoding? */ - if ((bufsz - cnt) <= 4) return callerbuf; + sp = s; + op = callerbuf; + *op = '\0'; + + while (*sp) { + /* Do we have room for one more character or encoding? */ + if ((bufsz - cnt) <= 4) return callerbuf; - if (*sp == quotechar) { - (void)sprintf(op, "%c%02X", quotechar, *sp); - op += 3; - cnt += 3; - } else if ((index(legal, *sp) != 0) || (index(hexdigits, *sp) != 0)) { - *op++ = *sp; - *op = '\0'; - cnt++; - } else { - (void)sprintf(op,"%c%02X", quotechar, *sp); - op += 3; - cnt += 3; - } - sp++; - } - return callerbuf; + if (*sp == quotechar) { + (void)sprintf(op, "%c%02X", quotechar, *sp); + op += 3; + cnt += 3; + } else if ((index(legal, *sp) != 0) || (index(hexdigits, *sp) != 0)) { + *op++ = *sp; + *op = '\0'; + cnt++; + } else { + (void)sprintf(op,"%c%02X", quotechar, *sp); + op += 3; + cnt += 3; + } + sp++; + } + return callerbuf; } /* @@ -277,37 +277,37 @@ char quotechar; char *s, *callerbuf; int bufsz; { - char *sp, *op; - int k,calc,cnt = 0; - static char hexdigits[] = "0123456789ABCDEF"; + char *sp, *op; + int k,calc,cnt = 0; + static char hexdigits[] = "0123456789ABCDEF"; - sp = s; - op = callerbuf; - *op = '\0'; - calc = 0; + sp = s; + op = callerbuf; + *op = '\0'; + calc = 0; - while (*sp) { - /* Do we have room for one more character? */ - if ((bufsz - cnt) <= 2) return callerbuf; - if (*sp == quotechar) { - sp++; - for (k=0; k < 16; ++k) if (*sp == hexdigits[k]) break; - if (k >= 16) return callerbuf; /* impossible, so bail */ - calc = k << 4; - sp++; - for (k=0; k < 16; ++k) if (*sp == hexdigits[k]) break; - if (k >= 16) return callerbuf; /* impossible, so bail */ - calc += k; - sp++; - *op++ = calc; - *op = '\0'; - } else { - *op++ = *sp++; - *op = '\0'; - } - cnt++; - } - return callerbuf; + while (*sp) { + /* Do we have room for one more character? */ + if ((bufsz - cnt) <= 2) return callerbuf; + if (*sp == quotechar) { + sp++; + for (k=0; k < 16; ++k) if (*sp == hexdigits[k]) break; + if (k >= 16) return callerbuf; /* impossible, so bail */ + calc = k << 4; + sp++; + for (k=0; k < 16; ++k) if (*sp == hexdigits[k]) break; + if (k >= 16) return callerbuf; /* impossible, so bail */ + calc += k; + sp++; + *op++ = calc; + *op = '\0'; + } else { + *op++ = *sp++; + *op = '\0'; + } + cnt++; + } + return callerbuf; } #ifdef PREFIXES_IN_USE @@ -324,25 +324,25 @@ int whichprefix UNUSED_if_not_PREFIXES_IN_USE; int buffnum UNUSED_if_not_PREFIXES_IN_USE; { #ifndef PREFIXES_IN_USE - return basenam; + return basenam; #else - if (!basenam || whichprefix < 0 || whichprefix >= PREFIX_COUNT) - return basenam; - if (!fqn_prefix[whichprefix]) - return basenam; - if (buffnum < 0 || buffnum >= FQN_NUMBUF) { - impossible("Invalid fqn_filename_buffer specified: %d", - buffnum); - buffnum = 0; - } - if (strlen(fqn_prefix[whichprefix]) + strlen(basenam) >= - FQN_MAX_FILENAME) { - impossible("fqname too long: %s + %s", fqn_prefix[whichprefix], - basenam); - return basenam; /* XXX */ - } - Strcpy(fqn_filename_buffer[buffnum], fqn_prefix[whichprefix]); - return strcat(fqn_filename_buffer[buffnum], basenam); + if (!basenam || whichprefix < 0 || whichprefix >= PREFIX_COUNT) + return basenam; + if (!fqn_prefix[whichprefix]) + return basenam; + if (buffnum < 0 || buffnum >= FQN_NUMBUF) { + impossible("Invalid fqn_filename_buffer specified: %d", + buffnum); + buffnum = 0; + } + if (strlen(fqn_prefix[whichprefix]) + strlen(basenam) >= + FQN_MAX_FILENAME) { + impossible("fqname too long: %s + %s", fqn_prefix[whichprefix], + basenam); + return basenam; /* XXX */ + } + Strcpy(fqn_filename_buffer[buffnum], fqn_prefix[whichprefix]); + return strcat(fqn_filename_buffer[buffnum], basenam); #endif } @@ -351,46 +351,46 @@ validate_prefix_locations(reasonbuf) char *reasonbuf; /* reasonbuf must be at least BUFSZ, supplied by caller */ { #if defined(NOCWD_ASSUMPTIONS) - FILE *fp; - const char *filename; - int prefcnt, failcount = 0; - char panicbuf1[BUFSZ], panicbuf2[BUFSZ]; - const char *details; + FILE *fp; + const char *filename; + int prefcnt, failcount = 0; + char panicbuf1[BUFSZ], panicbuf2[BUFSZ]; + const char *details; #endif - if (reasonbuf) reasonbuf[0] = '\0'; + if (reasonbuf) reasonbuf[0] = '\0'; #if defined(NOCWD_ASSUMPTIONS) - for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) { - /* don't test writing to configdir or datadir; they're readonly */ - if (prefcnt == SYSCONFPREFIX || - prefcnt == CONFIGPREFIX || - prefcnt == DATAPREFIX) continue; - filename = fqname("validate", prefcnt, 3); - if ((fp = fopen(filename, "w"))) { - fclose(fp); - (void) unlink(filename); - } else { - if (reasonbuf) { - if (failcount) Strcat(reasonbuf,", "); - Strcat(reasonbuf, fqn_prefix_names[prefcnt]); - } - /* the paniclog entry gets the value of errno as well */ - Sprintf(panicbuf1,"Invalid %s", fqn_prefix_names[prefcnt]); + for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) { + /* don't test writing to configdir or datadir; they're readonly */ + if (prefcnt == SYSCONFPREFIX || + prefcnt == CONFIGPREFIX || + prefcnt == DATAPREFIX) continue; + filename = fqname("validate", prefcnt, 3); + if ((fp = fopen(filename, "w"))) { + fclose(fp); + (void) unlink(filename); + } else { + if (reasonbuf) { + if (failcount) Strcat(reasonbuf,", "); + Strcat(reasonbuf, fqn_prefix_names[prefcnt]); + } + /* the paniclog entry gets the value of errno as well */ + Sprintf(panicbuf1,"Invalid %s", fqn_prefix_names[prefcnt]); #if defined (NHSTDC) && !defined(NOTSTDC) - if (!(details = strerror(errno))) + if (!(details = strerror(errno))) #endif - details = ""; - Sprintf(panicbuf2,"\"%s\", (%d) %s", - fqn_prefix[prefcnt], errno, details); - paniclog(panicbuf1, panicbuf2); - failcount++; - } - } - if (failcount) - return 0; - else + details = ""; + Sprintf(panicbuf2,"\"%s\", (%d) %s", + fqn_prefix[prefcnt], errno, details); + paniclog(panicbuf1, panicbuf2); + failcount++; + } + } + if (failcount) + return 0; + else #endif - return 1; + return 1; } /* fopen a file, with OS-dependent bells and whistles */ @@ -400,11 +400,11 @@ fopen_datafile(filename, mode, prefix) const char *filename, *mode; int prefix; { - FILE *fp; + FILE *fp; - filename = fqname(filename, prefix, prefix == TROUBLEPREFIX ? 3 : 0); - fp = fopen(filename, mode); - return fp; + filename = fqname(filename, prefix, prefix == TROUBLEPREFIX ? 3 : 0); + fp = fopen(filename, mode); + return fp; } /* ---------- BEGIN LEVEL FILE HANDLING ----------- */ @@ -414,22 +414,22 @@ int prefix; void set_lock_and_bones() { - if (!ramdisk) { - Strcpy(levels, permbones); - Strcpy(bones, permbones); - } - append_slash(permbones); - append_slash(levels); + if (!ramdisk) { + Strcpy(levels, permbones); + Strcpy(bones, permbones); + } + append_slash(permbones); + append_slash(levels); #ifdef AMIGA - strncat(levels, bbs_id, PATHLEN); + strncat(levels, bbs_id, PATHLEN); #endif - append_slash(bones); - Strcat(bones, "bonesnn.*"); - Strcpy(lock, levels); + append_slash(bones); + Strcat(bones, "bonesnn.*"); + Strcpy(lock, levels); #ifndef AMIGA - Strcat(lock, alllevels); + Strcat(lock, alllevels); #endif - return; + return; } #endif /* MFLOPPY */ @@ -445,15 +445,15 @@ set_levelfile_name(file, lev) char *file; int lev; { - char *tf; + char *tf; - tf = rindex(file, '.'); - if (!tf) tf = eos(file); - Sprintf(tf, ".%d", lev); + tf = rindex(file, '.'); + if (!tf) tf = eos(file); + Sprintf(tf, ".%d", lev); #ifdef VMS - Strcat(tf, ";1"); + Strcat(tf, ";1"); #endif - return; + return; } int @@ -461,40 +461,40 @@ create_levelfile(lev, errbuf) int lev; char errbuf[]; { - int fd; - const char *fq_lock; + int fd; + const char *fq_lock; - if (errbuf) *errbuf = '\0'; - set_levelfile_name(lock, lev); - fq_lock = fqname(lock, LEVELPREFIX, 0); + if (errbuf) *errbuf = '\0'; + set_levelfile_name(lock, lev); + fq_lock = fqname(lock, LEVELPREFIX, 0); #if defined(MICRO) || defined(WIN32) - /* Use O_TRUNC to force the file to be shortened if it already - * exists and is currently longer. - */ + /* Use O_TRUNC to force the file to be shortened if it already + * exists and is currently longer. + */ # ifdef HOLD_LOCKFILE_OPEN - if (lev == 0) - fd = open_levelfile_exclusively(fq_lock, lev, - O_WRONLY |O_CREAT | O_TRUNC | O_BINARY); - else + if (lev == 0) + fd = open_levelfile_exclusively(fq_lock, lev, + O_WRONLY |O_CREAT | O_TRUNC | O_BINARY); + else # endif - fd = open(fq_lock, O_WRONLY |O_CREAT | O_TRUNC | O_BINARY, FCMASK); + fd = open(fq_lock, O_WRONLY |O_CREAT | O_TRUNC | O_BINARY, FCMASK); #else # ifdef MAC - fd = maccreat(fq_lock, LEVL_TYPE); + fd = maccreat(fq_lock, LEVL_TYPE); # else - fd = creat(fq_lock, FCMASK); + fd = creat(fq_lock, FCMASK); # endif #endif /* MICRO || WIN32 */ - if (fd >= 0) - level_info[lev].flags |= LFILE_EXISTS; - else if (errbuf) /* failure explanation */ - Sprintf(errbuf, - "Cannot create file \"%s\" for level %d (errno %d).", - lock, lev, errno); + if (fd >= 0) + level_info[lev].flags |= LFILE_EXISTS; + else if (errbuf) /* failure explanation */ + Sprintf(errbuf, + "Cannot create file \"%s\" for level %d (errno %d).", + lock, lev, errno); - return fd; + return fd; } @@ -503,37 +503,37 @@ open_levelfile(lev, errbuf) int lev; char errbuf[]; { - int fd; - const char *fq_lock; + int fd; + const char *fq_lock; - if (errbuf) *errbuf = '\0'; - set_levelfile_name(lock, lev); - fq_lock = fqname(lock, LEVELPREFIX, 0); + if (errbuf) *errbuf = '\0'; + set_levelfile_name(lock, lev); + fq_lock = fqname(lock, LEVELPREFIX, 0); #ifdef MFLOPPY - /* If not currently accessible, swap it in. */ - if (level_info[lev].where != ACTIVE) - swapin_file(lev); + /* If not currently accessible, swap it in. */ + if (level_info[lev].where != ACTIVE) + swapin_file(lev); #endif #ifdef MAC - fd = macopen(fq_lock, O_RDONLY | O_BINARY, LEVL_TYPE); + fd = macopen(fq_lock, O_RDONLY | O_BINARY, LEVL_TYPE); #else # ifdef HOLD_LOCKFILE_OPEN - if (lev == 0) - fd = open_levelfile_exclusively(fq_lock, lev, O_RDONLY | O_BINARY ); - else + if (lev == 0) + fd = open_levelfile_exclusively(fq_lock, lev, O_RDONLY | O_BINARY ); + else # endif - fd = open(fq_lock, O_RDONLY | O_BINARY, 0); + fd = open(fq_lock, O_RDONLY | O_BINARY, 0); #endif - /* for failure, return an explanation that our caller can use; - settle for `lock' instead of `fq_lock' because the latter - might end up being too big for nethack's BUFSZ */ - if (fd < 0 && errbuf) - Sprintf(errbuf, - "Cannot open file \"%s\" for level %d (errno %d).", - lock, lev, errno); + /* for failure, return an explanation that our caller can use; + settle for `lock' instead of `fq_lock' because the latter + might end up being too big for nethack's BUFSZ */ + if (fd < 0 && errbuf) + Sprintf(errbuf, + "Cannot open file \"%s\" for level %d (errno %d).", + lock, lev, errno); - return fd; + return fd; } @@ -541,18 +541,18 @@ void delete_levelfile(lev) int lev; { - /* - * Level 0 might be created by port specific code that doesn't - * call create_levfile(), so always assume that it exists. - */ - if (lev == 0 || (level_info[lev].flags & LFILE_EXISTS)) { - set_levelfile_name(lock, lev); + /* + * Level 0 might be created by port specific code that doesn't + * call create_levfile(), so always assume that it exists. + */ + if (lev == 0 || (level_info[lev].flags & LFILE_EXISTS)) { + set_levelfile_name(lock, lev); #ifdef HOLD_LOCKFILE_OPEN - if (lev == 0) really_close(); + if (lev == 0) really_close(); #endif - (void) unlink(fqname(lock, LEVELPREFIX, 0)); - level_info[lev].flags &= ~LFILE_EXISTS; - } + (void) unlink(fqname(lock, LEVELPREFIX, 0)); + level_info[lev].flags &= ~LFILE_EXISTS; + } } @@ -560,25 +560,25 @@ void clearlocks() { #ifdef HANGUPHANDLING - if (program_state.preserve_locks) return; + if (program_state.preserve_locks) return; #endif #if !defined(PC_LOCKING) && defined(MFLOPPY) && !defined(AMIGA) - eraseall(levels, alllevels); - if (ramdisk) - eraseall(permbones, alllevels); + eraseall(levels, alllevels); + if (ramdisk) + eraseall(permbones, alllevels); #else { - register int x; + register int x; # ifndef NO_SIGNAL - (void) signal(SIGINT, SIG_IGN); + (void) signal(SIGINT, SIG_IGN); # endif # if defined(UNIX) || defined(VMS) - sethanguphandler((void FDECL((*),(int)))SIG_IGN); + sethanguphandler((void FDECL((*),(int)))SIG_IGN); # endif - /* can't access maxledgerno() before dungeons are created -dlc */ - for (x = (n_dgns ? maxledgerno() : 0); x >= 0; x--) - delete_levelfile(x); /* not all levels need be present */ + /* can't access maxledgerno() before dungeons are created -dlc */ + for (x = (n_dgns ? maxledgerno() : 0); x >= 0; x--) + delete_levelfile(x); /* not all levels need be present */ } #endif /* ?PC_LOCKING,&c */ } @@ -590,9 +590,9 @@ const void *p; const void *q; { #if defined(UNIX) && defined(QT_GRAPHICS) - return strncasecmp(*(char **) p, *(char **) q, 16); + return strncasecmp(*(char **) p, *(char **) q, 16); # else - return strncmpi(*(char **) p, *(char **) q, 16); + return strncmpi(*(char **) p, *(char **) q, 16); # endif } #endif @@ -603,58 +603,58 @@ open_levelfile_exclusively(name, lev, oflag) const char *name; int lev, oflag; { - int reslt, fd; - if (!lftrack.init) { - lftrack.init = 1; - lftrack.fd = -1; - } - if (lftrack.fd >= 0) { - /* check for compatible access */ - if (lftrack.oflag == oflag) { - fd = lftrack.fd; - reslt = lseek(fd, 0L, SEEK_SET); - if (reslt == -1L) - panic("open_levelfile_exclusively: lseek failed %d", errno); - lftrack.nethack_thinks_it_is_open = TRUE; - } else { - really_close(); - fd = sopen(name, oflag,SH_DENYRW, FCMASK); - lftrack.fd = fd; - lftrack.oflag = oflag; - lftrack.nethack_thinks_it_is_open = TRUE; - } - } else { - fd = sopen(name, oflag,SH_DENYRW, FCMASK); - lftrack.fd = fd; - lftrack.oflag = oflag; - if (fd >= 0) - lftrack.nethack_thinks_it_is_open = TRUE; - } - return fd; + int reslt, fd; + if (!lftrack.init) { + lftrack.init = 1; + lftrack.fd = -1; + } + if (lftrack.fd >= 0) { + /* check for compatible access */ + if (lftrack.oflag == oflag) { + fd = lftrack.fd; + reslt = lseek(fd, 0L, SEEK_SET); + if (reslt == -1L) + panic("open_levelfile_exclusively: lseek failed %d", errno); + lftrack.nethack_thinks_it_is_open = TRUE; + } else { + really_close(); + fd = sopen(name, oflag,SH_DENYRW, FCMASK); + lftrack.fd = fd; + lftrack.oflag = oflag; + lftrack.nethack_thinks_it_is_open = TRUE; + } + } else { + fd = sopen(name, oflag,SH_DENYRW, FCMASK); + lftrack.fd = fd; + lftrack.oflag = oflag; + if (fd >= 0) + lftrack.nethack_thinks_it_is_open = TRUE; + } + return fd; } void really_close() { - int fd = lftrack.fd; - lftrack.nethack_thinks_it_is_open = FALSE; - lftrack.fd = -1; - lftrack.oflag = 0; - if (fd != -1) + int fd = lftrack.fd; + lftrack.nethack_thinks_it_is_open = FALSE; + lftrack.fd = -1; + lftrack.oflag = 0; + if (fd != -1) (void)close(fd); - return; + return; } int nhclose(fd) int fd; { - if (lftrack.fd == fd) { - really_close(); /* close it, but reopen it to hold it */ - fd = open_levelfile(0, (char *)0); - lftrack.nethack_thinks_it_is_open = FALSE; - return 0; - } + if (lftrack.fd == fd) { + really_close(); /* close it, but reopen it to hold it */ + fd = open_levelfile(0, (char *)0); + lftrack.nethack_thinks_it_is_open = FALSE; + return 0; + } return close(fd); } #else @@ -679,20 +679,20 @@ set_bonesfile_name(file, lev) char *file; d_level *lev; { - s_level *sptr; - char *dptr; + s_level *sptr; + char *dptr; - Sprintf(file, "bon%c%s", dungeons[lev->dnum].boneid, - In_quest(lev) ? urole.filecode : "0"); - dptr = eos(file); - if ((sptr = Is_special(lev)) != 0) - Sprintf(dptr, ".%c", sptr->boneid); - else - Sprintf(dptr, ".%d", lev->dlevel); + Sprintf(file, "bon%c%s", dungeons[lev->dnum].boneid, + In_quest(lev) ? urole.filecode : "0"); + dptr = eos(file); + if ((sptr = Is_special(lev)) != 0) + Sprintf(dptr, ".%c", sptr->boneid); + else + Sprintf(dptr, ".%d", lev->dlevel); #ifdef VMS - Strcat(dptr, ";1"); + Strcat(dptr, ";1"); #endif - return(dptr-2); + return(dptr-2); } /* set up temporary file name for writing bones, to avoid another game's @@ -704,15 +704,15 @@ d_level *lev; STATIC_OVL char * set_bonestemp_name() { - char *tf; + char *tf; - tf = rindex(lock, '.'); - if (!tf) tf = eos(lock); - Sprintf(tf, ".bn"); + tf = rindex(lock, '.'); + if (!tf) tf = eos(lock); + Sprintf(tf, ".bn"); #ifdef VMS - Strcat(tf, ";1"); + Strcat(tf, ";1"); #endif - return lock; + return lock; } int @@ -721,44 +721,44 @@ d_level *lev; char **bonesid; char errbuf[]; { - const char *file; - int fd; + const char *file; + int fd; - if (errbuf) *errbuf = '\0'; - *bonesid = set_bonesfile_name(bones, lev); - file = set_bonestemp_name(); - file = fqname(file, BONESPREFIX, 0); + if (errbuf) *errbuf = '\0'; + *bonesid = set_bonesfile_name(bones, lev); + file = set_bonestemp_name(); + file = fqname(file, BONESPREFIX, 0); #if defined(MICRO) || defined(WIN32) - /* Use O_TRUNC to force the file to be shortened if it already - * exists and is currently longer. - */ - fd = open(file, O_WRONLY |O_CREAT | O_TRUNC | O_BINARY, FCMASK); + /* Use O_TRUNC to force the file to be shortened if it already + * exists and is currently longer. + */ + fd = open(file, O_WRONLY |O_CREAT | O_TRUNC | O_BINARY, FCMASK); #else # ifdef MAC - fd = maccreat(file, BONE_TYPE); + fd = maccreat(file, BONE_TYPE); # else - fd = creat(file, FCMASK); + fd = creat(file, FCMASK); # endif #endif - if (fd < 0 && errbuf) /* failure explanation */ - Sprintf(errbuf, - "Cannot create bones \"%s\", id %s (errno %d).", - lock, *bonesid, errno); + if (fd < 0 && errbuf) /* failure explanation */ + Sprintf(errbuf, + "Cannot create bones \"%s\", id %s (errno %d).", + lock, *bonesid, errno); # if defined(VMS) && !defined(SECURE) - /* - Re-protect bones file with world:read+write+execute+delete access. - umask() doesn't seem very reliable; also, vaxcrtl won't let us set - delete access without write access, which is what's really wanted. - Can't simply create it with the desired protection because creat - ANDs the mask with the user's default protection, which usually - denies some or all access to world. - */ - (void) chmod(file, FCMASK | 007); /* allow other users full access */ + /* + Re-protect bones file with world:read+write+execute+delete access. + umask() doesn't seem very reliable; also, vaxcrtl won't let us set + delete access without write access, which is what's really wanted. + Can't simply create it with the desired protection because creat + ANDs the mask with the user's default protection, which usually + denies some or all access to world. + */ + (void) chmod(file, FCMASK | 007); /* allow other users full access */ # endif /* VMS && !SECURE */ - return fd; + return fd; } #ifdef MFLOPPY @@ -766,11 +766,11 @@ char errbuf[]; void cancel_bonesfile() { - const char *tempname; + const char *tempname; - tempname = set_bonestemp_name(); - tempname = fqname(tempname, BONESPREFIX, 0); - (void) unlink(tempname); + tempname = set_bonestemp_name(); + tempname = fqname(tempname, BONESPREFIX, 0); + (void) unlink(tempname); } #endif /* MFLOPPY */ @@ -779,26 +779,26 @@ void commit_bonesfile(lev) d_level *lev; { - const char *fq_bones, *tempname; - int ret; + const char *fq_bones, *tempname; + int ret; - (void) set_bonesfile_name(bones, lev); - fq_bones = fqname(bones, BONESPREFIX, 0); - tempname = set_bonestemp_name(); - tempname = fqname(tempname, BONESPREFIX, 1); + (void) set_bonesfile_name(bones, lev); + fq_bones = fqname(bones, BONESPREFIX, 0); + tempname = set_bonestemp_name(); + tempname = fqname(tempname, BONESPREFIX, 1); #if (defined(SYSV) && !defined(SVR4)) || defined(GENIX) - /* old SYSVs don't have rename. Some SVR3's may, but since they - * also have link/unlink, it doesn't matter. :-) - */ - (void) unlink(fq_bones); - ret = link(tempname, fq_bones); - ret += unlink(tempname); + /* old SYSVs don't have rename. Some SVR3's may, but since they + * also have link/unlink, it doesn't matter. :-) + */ + (void) unlink(fq_bones); + ret = link(tempname, fq_bones); + ret += unlink(tempname); #else - ret = rename(tempname, fq_bones); + ret = rename(tempname, fq_bones); #endif - if (wizard && ret != 0) - pline("couldn't rename %s to %s.", tempname, fq_bones); + if (wizard && ret != 0) + pline("couldn't rename %s to %s.", tempname, fq_bones); } @@ -807,18 +807,18 @@ open_bonesfile(lev, bonesid) d_level *lev; char **bonesid; { - const char *fq_bones; - int fd; + const char *fq_bones; + int fd; - *bonesid = set_bonesfile_name(bones, lev); - fq_bones = fqname(bones, BONESPREFIX, 0); - nh_uncompress(fq_bones); /* no effect if nonexistent */ + *bonesid = set_bonesfile_name(bones, lev); + fq_bones = fqname(bones, BONESPREFIX, 0); + nh_uncompress(fq_bones); /* no effect if nonexistent */ #ifdef MAC - fd = macopen(fq_bones, O_RDONLY | O_BINARY, BONE_TYPE); + fd = macopen(fq_bones, O_RDONLY | O_BINARY, BONE_TYPE); #else - fd = open(fq_bones, O_RDONLY | O_BINARY, 0); + fd = open(fq_bones, O_RDONLY | O_BINARY, 0); #endif - return fd; + return fd; } @@ -826,8 +826,8 @@ int delete_bonesfile(lev) d_level *lev; { - (void) set_bonesfile_name(bones, lev); - return !(unlink(fqname(bones, BONESPREFIX, 0)) < 0); + (void) set_bonesfile_name(bones, lev); + return !(unlink(fqname(bones, BONESPREFIX, 0)) < 0); } @@ -836,7 +836,7 @@ d_level *lev; void compress_bonesfile() { - nh_compress(fqname(bones, BONESPREFIX, 0)); + nh_compress(fqname(bones, BONESPREFIX, 0)); } /* ---------- END BONES FILE HANDLING ----------- */ @@ -851,44 +851,44 @@ set_savefile_name(regularize_it) boolean regularize_it; { #ifdef VMS - Sprintf(SAVEF, "[.save]%d%s", getuid(), plname); - if (regularize_it) regularize(SAVEF+7); - Strcat(SAVEF, ";1"); + Sprintf(SAVEF, "[.save]%d%s", getuid(), plname); + if (regularize_it) regularize(SAVEF+7); + Strcat(SAVEF, ";1"); #else # if defined(MICRO) - Strcpy(SAVEF, SAVEP); + Strcpy(SAVEF, SAVEP); # ifdef AMIGA - strncat(SAVEF, bbs_id, PATHLEN); + strncat(SAVEF, bbs_id, PATHLEN); # endif - { - int i = strlen(SAVEP); + { + int i = strlen(SAVEP); # ifdef AMIGA - /* plname has to share space with SAVEP and ".sav" */ - (void)strncat(SAVEF, plname, FILENAME - i - 4); + /* plname has to share space with SAVEP and ".sav" */ + (void)strncat(SAVEF, plname, FILENAME - i - 4); # else - (void)strncat(SAVEF, plname, 8); + (void)strncat(SAVEF, plname, 8); # endif - if (regularize_it) regularize(SAVEF+i); - } - Strcat(SAVEF, SAVE_EXTENSION); + if (regularize_it) regularize(SAVEF+i); + } + Strcat(SAVEF, SAVE_EXTENSION); # else # if defined(WIN32) { - static const char okchars[] = - "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-."; - const char *legal = okchars; - char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ]; + static const char okchars[] = + "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-."; + const char *legal = okchars; + char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ]; - /* Obtain the name of the logged on user and incorporate - * it into the name. */ - Sprintf(fnamebuf, "%s-%s", get_username(0), plname); - if (regularize_it) ++legal; /* skip '*' wildcard character */ - (void)fname_encode(legal, '%', fnamebuf, encodedfnamebuf, BUFSZ); - Sprintf(SAVEF, "%s%s", encodedfnamebuf,SAVE_EXTENSION); + /* Obtain the name of the logged on user and incorporate + * it into the name. */ + Sprintf(fnamebuf, "%s-%s", get_username(0), plname); + if (regularize_it) ++legal; /* skip '*' wildcard character */ + (void)fname_encode(legal, '%', fnamebuf, encodedfnamebuf, BUFSZ); + Sprintf(SAVEF, "%s%s", encodedfnamebuf,SAVE_EXTENSION); } # else /* not VMS or MICRO or WIN32 */ - Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname); - if (regularize_it) regularize(SAVEF+5); /* avoid . or / in name */ + Sprintf(SAVEF, "save/%d%s", (int)getuid(), plname); + if (regularize_it) regularize(SAVEF+5); /* avoid . or / in name */ # endif /* WIN32 */ # endif /* MICRO */ #endif /* VMS */ @@ -899,7 +899,7 @@ void save_savefile_name(fd) int fd; { - (void) write(fd, (genericptr_t) SAVEF, sizeof(SAVEF)); + (void) write(fd, (genericptr_t) SAVEF, sizeof(SAVEF)); } #endif @@ -911,15 +911,15 @@ set_error_savefile() { # ifdef VMS { - char *semi_colon = rindex(SAVEF, ';'); - if (semi_colon) *semi_colon = '\0'; + char *semi_colon = rindex(SAVEF, ';'); + if (semi_colon) *semi_colon = '\0'; } - Strcat(SAVEF, ".e;1"); + Strcat(SAVEF, ".e;1"); # else # ifdef MAC - Strcat(SAVEF, "-e"); + Strcat(SAVEF, "-e"); # else - Strcat(SAVEF, ".e"); + Strcat(SAVEF, ".e"); # endif # endif } @@ -930,31 +930,31 @@ set_error_savefile() int create_savefile() { - const char *fq_save; - int fd; + const char *fq_save; + int fd; - fq_save = fqname(SAVEF, SAVEPREFIX, 0); + fq_save = fqname(SAVEF, SAVEPREFIX, 0); #if defined(MICRO) || defined(WIN32) - fd = open(fq_save, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK); + fd = open(fq_save, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK); #else # ifdef MAC - fd = maccreat(fq_save, SAVE_TYPE); + fd = maccreat(fq_save, SAVE_TYPE); # else - fd = creat(fq_save, FCMASK); + fd = creat(fq_save, FCMASK); # endif # if defined(VMS) && !defined(SECURE) - /* - Make sure the save file is owned by the current process. That's - the default for non-privileged users, but for priv'd users the - file will be owned by the directory's owner instead of the user. - */ + /* + Make sure the save file is owned by the current process. That's + the default for non-privileged users, but for priv'd users the + file will be owned by the directory's owner instead of the user. + */ # undef getuid - (void) chown(fq_save, getuid(), getgid()); + (void) chown(fq_save, getuid(), getgid()); # define getuid() vms_getuid() # endif /* VMS && !SECURE */ #endif /* MICRO */ - return fd; + return fd; } @@ -962,16 +962,16 @@ create_savefile() int open_savefile() { - const char *fq_save; - int fd; + const char *fq_save; + int fd; - fq_save = fqname(SAVEF, SAVEPREFIX, 0); + fq_save = fqname(SAVEF, SAVEPREFIX, 0); #ifdef MAC - fd = macopen(fq_save, O_RDONLY | O_BINARY, SAVE_TYPE); + fd = macopen(fq_save, O_RDONLY | O_BINARY, SAVE_TYPE); #else - fd = open(fq_save, O_RDONLY | O_BINARY, 0); + fd = open(fq_save, O_RDONLY | O_BINARY, 0); #endif - return fd; + return fd; } @@ -979,8 +979,8 @@ open_savefile() int delete_savefile() { - (void) unlink(fqname(SAVEF, SAVEPREFIX, 0)); - return 0; /* for restore_saved_game() (ex-xxxmain.c) test */ + (void) unlink(fqname(SAVEF, SAVEPREFIX, 0)); + return 0; /* for restore_saved_game() (ex-xxxmain.c) test */ } @@ -988,25 +988,25 @@ delete_savefile() int restore_saved_game() { - const char *fq_save; - int fd; + const char *fq_save; + int fd; - reset_restpref(); - set_savefile_name(TRUE); + reset_restpref(); + set_savefile_name(TRUE); #ifdef MFLOPPY - if (!saveDiskPrompt(1)) - return -1; + if (!saveDiskPrompt(1)) + return -1; #endif /* MFLOPPY */ - fq_save = fqname(SAVEF, SAVEPREFIX, 0); + fq_save = fqname(SAVEF, SAVEPREFIX, 0); - nh_uncompress(fq_save); - if ((fd = open_savefile()) < 0) return fd; + nh_uncompress(fq_save); + if ((fd = open_savefile()) < 0) return fd; - if (validate(fd, fq_save) != 0) { + if (validate(fd, fq_save) != 0) { (void) nhclose(fd), fd = -1; - (void) delete_savefile(); - } - return fd; + (void) delete_savefile(); + } + return fd; } #if defined(SELECTSAVED) @@ -1023,11 +1023,11 @@ const char* filename; # endif nh_uncompress(SAVEF); if ((fd = open_savefile()) >= 0) { - if (validate(fd, filename)==0) { - char tplname[PL_NSIZ]; - get_plname_from_file(fd, tplname); - result = dupstr(tplname); - } + if (validate(fd, filename)==0) { + char tplname[PL_NSIZ]; + get_plname_from_file(fd, tplname); + result = dupstr(tplname); + } (void) nhclose(fd); } nh_compress(SAVEF); @@ -1050,14 +1050,14 @@ const char* filename; if ( sscanf( filename, "%*[^/]/%d%63[^.]" EXTSTR, &uid, name ) == 2 ) { #undef EXTSTR /* "_" most likely means " ", which certainly looks nicer */ - for (k=0; name[k]; k++) - if ( name[k]=='_' ) - name[k]=' '; - return dupstr(name); + for (k=0; name[k]; k++) + if ( name[k]=='_' ) + name[k]=' '; + return dupstr(name); } else # endif /* UNIX && QT_GRAPHICS */ { - return 0; + return 0; } /* --------- end of obsolete code ----*/ # endif /* 0 - WAS STORE_PLNAME_IN_FILE*/ @@ -1072,73 +1072,73 @@ get_saved_games() char **result = 0; # ifdef WIN32CON { - char *foundfile; - const char *fq_save; + char *foundfile; + const char *fq_save; - Strcpy(plname, "*"); - set_savefile_name(FALSE); + Strcpy(plname, "*"); + set_savefile_name(FALSE); #if defined(ZLIB_COMP) - Strcat(SAVEF, COMPRESS_EXTENSION); + Strcat(SAVEF, COMPRESS_EXTENSION); #endif - fq_save = fqname(SAVEF, SAVEPREFIX, 0); + fq_save = fqname(SAVEF, SAVEPREFIX, 0); - n = 0; - foundfile = foundfile_buffer(); - if (findfirst((char *)fq_save)) { - do { - ++n; - } while (findnext()); - } - if (n > 0) { - result = (char**)alloc((n+1)*sizeof(char*)); /* at most */ - (void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*)); - if (findfirst((char *)fq_save)) { - j = n = 0; - do { - char *r; - r = plname_from_file(foundfile); - if (r) - result[j++] = r; - ++n; - } while (findnext()); - } - } + n = 0; + foundfile = foundfile_buffer(); + if (findfirst((char *)fq_save)) { + do { + ++n; + } while (findnext()); + } + if (n > 0) { + result = (char**)alloc((n+1)*sizeof(char*)); /* at most */ + (void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*)); + if (findfirst((char *)fq_save)) { + j = n = 0; + do { + char *r; + r = plname_from_file(foundfile); + if (r) + result[j++] = r; + ++n; + } while (findnext()); + } + } } # endif # if defined(UNIX) && defined(QT_GRAPHICS) - /* posixly correct version */ + /* posixly correct version */ int myuid=getuid(); DIR *dir; if((dir=opendir(fqname("save", SAVEPREFIX, 0)))) { - for(n=0; readdir(dir); n++) - ; - closedir(dir); - if(n>0) { - int i; - if(!(dir=opendir(fqname("save", SAVEPREFIX, 0)))) - return 0; - result = (char**)alloc((n+1)*sizeof(char*)); /* at most */ - (void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*)); - for (i=0, j=0; id_name, "%d%63s", &uid, name ) == 2 ) { - if ( uid == myuid ) { - char filename[BUFSZ]; - char* r; - Sprintf(filename,"save/%d%s",uid,name); - r = plname_from_file(filename); - if ( r ) - result[j++] = r; - } - } - } - closedir(dir); - } + for(n=0; readdir(dir); n++) + ; + closedir(dir); + if(n>0) { + int i; + if(!(dir=opendir(fqname("save", SAVEPREFIX, 0)))) + return 0; + result = (char**)alloc((n+1)*sizeof(char*)); /* at most */ + (void) memset((genericptr_t) result, 0, (n+1)*sizeof(char*)); + for (i=0, j=0; id_name, "%d%63s", &uid, name ) == 2 ) { + if ( uid == myuid ) { + char filename[BUFSZ]; + char* r; + Sprintf(filename,"save/%d%s",uid,name); + r = plname_from_file(filename); + if ( r ) + result[j++] = r; + } + } + } + closedir(dir); + } } # endif # ifdef VMS @@ -1148,11 +1148,11 @@ get_saved_games() # endif /* VMS */ if (j > 0) { - if (j > 1) qsort(result, j, sizeof (char *), strcmp_wrap); - result[j] = 0; - return result; + if (j > 1) qsort(result, j, sizeof (char *), strcmp_wrap); + result[j] = 0; + return result; } else if (result) { /* could happen if save files are obsolete */ - free_saved_games(result); + free_saved_games(result); } #endif /* SELECTSAVED */ return 0; @@ -1163,9 +1163,9 @@ free_saved_games(saved) char** saved; { if ( saved ) { - int i=0; - while (saved[i]) free((genericptr_t)saved[i++]); - free((genericptr_t)saved); + int i=0; + while (saved[i]) free((genericptr_t)saved[i++]); + free((genericptr_t)saved); } } @@ -1183,11 +1183,11 @@ const char *filename, *mode; FILE *stream; boolean uncomp; { - if (freopen(filename, mode, stream) == (FILE *)0) { - (void) fprintf(stderr, "freopen of %s for %scompress failed\n", - filename, uncomp ? "un" : ""); - terminate(EXIT_FAILURE); - } + if (freopen(filename, mode, stream) == (FILE *)0) { + (void) fprintf(stderr, "freopen of %s for %scompress failed\n", + filename, uncomp ? "un" : ""); + terminate(EXIT_FAILURE); + } } /* @@ -1202,148 +1202,148 @@ docompress_file(filename, uncomp) const char *filename; boolean uncomp; { - char cfn[80]; - FILE *cf; - const char *args[10]; + char cfn[80]; + FILE *cf; + const char *args[10]; # ifdef COMPRESS_OPTIONS - char opts[80]; + char opts[80]; # endif - int i = 0; - int f; + int i = 0; + int f; # ifdef TTY_GRAPHICS - boolean istty = !strncmpi(windowprocs.name, "tty", 3); + boolean istty = !strncmpi(windowprocs.name, "tty", 3); # endif - Strcpy(cfn, filename); + Strcpy(cfn, filename); # ifdef COMPRESS_EXTENSION - Strcat(cfn, COMPRESS_EXTENSION); + Strcat(cfn, COMPRESS_EXTENSION); # endif - /* when compressing, we know the file exists */ - if (uncomp) { - if ((cf = fopen(cfn, RDBMODE)) == (FILE *)0) - return; - (void) fclose(cf); - } + /* when compressing, we know the file exists */ + if (uncomp) { + if ((cf = fopen(cfn, RDBMODE)) == (FILE *)0) + return; + (void) fclose(cf); + } - args[0] = COMPRESS; - if (uncomp) args[++i] = "-d"; /* uncompress */ + args[0] = COMPRESS; + if (uncomp) args[++i] = "-d"; /* uncompress */ # ifdef COMPRESS_OPTIONS - { - /* we can't guarantee there's only one additional option, sigh */ - char *opt; - boolean inword = FALSE; + { + /* we can't guarantee there's only one additional option, sigh */ + char *opt; + boolean inword = FALSE; - Strcpy(opts, COMPRESS_OPTIONS); - opt = opts; - while (*opt) { - if ((*opt == ' ') || (*opt == '\t')) { - if (inword) { - *opt = '\0'; - inword = FALSE; - } - } else if (!inword) { - args[++i] = opt; - inword = TRUE; - } - opt++; - } - } + Strcpy(opts, COMPRESS_OPTIONS); + opt = opts; + while (*opt) { + if ((*opt == ' ') || (*opt == '\t')) { + if (inword) { + *opt = '\0'; + inword = FALSE; + } + } else if (!inword) { + args[++i] = opt; + inword = TRUE; + } + opt++; + } + } # endif - args[++i] = (char *)0; + args[++i] = (char *)0; # ifdef TTY_GRAPHICS - /* If we don't do this and we are right after a y/n question *and* - * there is an error message from the compression, the 'y' or 'n' can - * end up being displayed after the error message. - */ - if (istty) - mark_synch(); + /* If we don't do this and we are right after a y/n question *and* + * there is an error message from the compression, the 'y' or 'n' can + * end up being displayed after the error message. + */ + if (istty) + mark_synch(); # endif - f = fork(); - if (f == 0) { /* child */ + f = fork(); + if (f == 0) { /* child */ # ifdef TTY_GRAPHICS - /* any error messages from the compression must come out after - * the first line, because the more() to let the user read - * them will have to clear the first line. This should be - * invisible if there are no error messages. - */ - if (istty) - raw_print(""); + /* any error messages from the compression must come out after + * the first line, because the more() to let the user read + * them will have to clear the first line. This should be + * invisible if there are no error messages. + */ + if (istty) + raw_print(""); # endif - /* run compressor without privileges, in case other programs - * have surprises along the line of gzip once taking filenames - * in GZIP. - */ - /* assume all compressors will compress stdin to stdout - * without explicit filenames. this is true of at least - * compress and gzip, those mentioned in config.h. - */ - if (uncomp) { - redirect(cfn, RDBMODE, stdin, uncomp); - redirect(filename, WRBMODE, stdout, uncomp); - } else { - redirect(filename, RDBMODE, stdin, uncomp); - redirect(cfn, WRBMODE, stdout, uncomp); - } - (void) setgid(getgid()); - (void) setuid(getuid()); - (void) execv(args[0], (char *const *) args); - perror((char *)0); - (void) fprintf(stderr, "Exec to %scompress %s failed.\n", - uncomp ? "un" : "", filename); - terminate(EXIT_FAILURE); - } else if (f == -1) { - perror((char *)0); - pline("Fork to %scompress %s failed.", - uncomp ? "un" : "", filename); - return; - } + /* run compressor without privileges, in case other programs + * have surprises along the line of gzip once taking filenames + * in GZIP. + */ + /* assume all compressors will compress stdin to stdout + * without explicit filenames. this is true of at least + * compress and gzip, those mentioned in config.h. + */ + if (uncomp) { + redirect(cfn, RDBMODE, stdin, uncomp); + redirect(filename, WRBMODE, stdout, uncomp); + } else { + redirect(filename, RDBMODE, stdin, uncomp); + redirect(cfn, WRBMODE, stdout, uncomp); + } + (void) setgid(getgid()); + (void) setuid(getuid()); + (void) execv(args[0], (char *const *) args); + perror((char *)0); + (void) fprintf(stderr, "Exec to %scompress %s failed.\n", + uncomp ? "un" : "", filename); + terminate(EXIT_FAILURE); + } else if (f == -1) { + perror((char *)0); + pline("Fork to %scompress %s failed.", + uncomp ? "un" : "", filename); + return; + } # ifndef NO_SIGNAL - (void) signal(SIGINT, SIG_IGN); - (void) signal(SIGQUIT, SIG_IGN); - (void) wait((int *)&i); - (void) signal(SIGINT, (SIG_RET_TYPE) done1); - if (wizard) (void) signal(SIGQUIT, SIG_DFL); + (void) signal(SIGINT, SIG_IGN); + (void) signal(SIGQUIT, SIG_IGN); + (void) wait((int *)&i); + (void) signal(SIGINT, (SIG_RET_TYPE) done1); + if (wizard) (void) signal(SIGQUIT, SIG_DFL); #else - /* I don't think we can really cope with external compression - * without signals, so we'll declare that compress failed and - * go on. (We could do a better job by forcing off external - * compression if there are no signals, but we want this for - * testing with FailSafeC - */ - i = 1; + /* I don't think we can really cope with external compression + * without signals, so we'll declare that compress failed and + * go on. (We could do a better job by forcing off external + * compression if there are no signals, but we want this for + * testing with FailSafeC + */ + i = 1; #endif - if (i == 0) { - /* (un)compress succeeded: remove file left behind */ - if (uncomp) - (void) unlink(cfn); - else - (void) unlink(filename); - } else { - /* (un)compress failed; remove the new, bad file */ - if (uncomp) { - raw_printf("Unable to uncompress %s", filename); - (void) unlink(filename); - } else { - /* no message needed for compress case; life will go on */ - (void) unlink(cfn); - } + if (i == 0) { + /* (un)compress succeeded: remove file left behind */ + if (uncomp) + (void) unlink(cfn); + else + (void) unlink(filename); + } else { + /* (un)compress failed; remove the new, bad file */ + if (uncomp) { + raw_printf("Unable to uncompress %s", filename); + (void) unlink(filename); + } else { + /* no message needed for compress case; life will go on */ + (void) unlink(cfn); + } #ifdef TTY_GRAPHICS - /* Give them a chance to read any error messages from the - * compression--these would go to stdout or stderr and would get - * overwritten only in tty mode. It's still ugly, since the - * messages are being written on top of the screen, but at least - * the user can read them. - */ - if (istty) - { - clear_nhwindow(WIN_MESSAGE); - more(); - /* No way to know if this is feasible */ - /* doredraw(); */ - } + /* Give them a chance to read any error messages from the + * compression--these would go to stdout or stderr and would get + * overwritten only in tty mode. It's still ugly, since the + * messages are being written on top of the screen, but at least + * the user can read them. + */ + if (istty) + { + clear_nhwindow(WIN_MESSAGE); + more(); + /* No way to know if this is feasible */ + /* doredraw(); */ + } #endif - } + } } #endif /* COMPRESS */ @@ -1363,7 +1363,7 @@ const char *filename UNUSED_if_not_COMPRESS; # pragma unused(filename) # endif #else - docompress_file(filename, FALSE); + docompress_file(filename, FALSE); #endif } @@ -1378,7 +1378,7 @@ const char *filename UNUSED_if_not_COMPRESS; # pragma unused(filename) # endif #else - docompress_file(filename, TRUE); + docompress_file(filename, TRUE); #endif } @@ -1389,29 +1389,29 @@ const char *filename; char *cfn; { #ifndef SHORT_FILENAMES - /* Assume free-form filename with no 8.3 restrictions */ - strcpy(cfn, filename); - strcat(cfn, COMPRESS_EXTENSION); - return TRUE; + /* Assume free-form filename with no 8.3 restrictions */ + strcpy(cfn, filename); + strcat(cfn, COMPRESS_EXTENSION); + return TRUE; #else # ifdef SAVE_EXTENSION - char *bp = (char *)0; - strcpy(cfn, filename); - if ((bp = strstri(cfn, SAVE_EXTENSION))) { - strsubst(bp, SAVE_EXTENSION, ".saz"); - return TRUE; - } else { - /* find last occurrence of bon */ - bp = eos(cfn); - while (bp-- > cfn) { - if (strstri(bp,"bon")) { - strsubst(bp, "bon", "boz"); - return TRUE; - } - } - } + char *bp = (char *)0; + strcpy(cfn, filename); + if ((bp = strstri(cfn, SAVE_EXTENSION))) { + strsubst(bp, SAVE_EXTENSION, ".saz"); + return TRUE; + } else { + /* find last occurrence of bon */ + bp = eos(cfn); + while (bp-- > cfn) { + if (strstri(bp,"bon")) { + strsubst(bp, "bon", "boz"); + return TRUE; + } + } + } # endif /* SAVE_EXTENSION */ - return FALSE; + return FALSE; #endif /* SHORT_FILENAMES */ } @@ -1421,123 +1421,123 @@ const char *filename; boolean uncomp; { gzFile compressedfile; - FILE *uncompressedfile; - char cfn[256]; - char buf[1024]; - unsigned len, len2; + FILE *uncompressedfile; + char cfn[256]; + char buf[1024]; + unsigned len, len2; - if (!make_compressed_name(filename, cfn)) - return; + if (!make_compressed_name(filename, cfn)) + return; - if (!uncomp) { - /* Open the input and output files */ - /* Note that gzopen takes "wb" as its mode, even on systems where - fopen takes "r" and "w" */ + if (!uncomp) { + /* Open the input and output files */ + /* Note that gzopen takes "wb" as its mode, even on systems where + fopen takes "r" and "w" */ - uncompressedfile = fopen(filename, RDBMODE); - if (!uncompressedfile) { - pline("Error in zlib docompress_file %s", filename); - return; - } - compressedfile = gzopen(cfn, "wb"); - if (compressedfile == NULL) { - if (errno == 0) { - pline("zlib failed to allocate memory"); - } else { - panic("Error in docompress_file %d", - errno); - } - fclose(uncompressedfile); - return; - } + uncompressedfile = fopen(filename, RDBMODE); + if (!uncompressedfile) { + pline("Error in zlib docompress_file %s", filename); + return; + } + compressedfile = gzopen(cfn, "wb"); + if (compressedfile == NULL) { + if (errno == 0) { + pline("zlib failed to allocate memory"); + } else { + panic("Error in docompress_file %d", + errno); + } + fclose(uncompressedfile); + return; + } - /* Copy from the uncompressed to the compressed file */ + /* Copy from the uncompressed to the compressed file */ - while (1) { - len = fread(buf, 1, sizeof(buf), uncompressedfile); - if (ferror(uncompressedfile)) { - pline("Failure reading uncompressed file"); - pline("Can't compress %s.", filename); - fclose(uncompressedfile); - gzclose(compressedfile); - (void)unlink(cfn); - return; - } - if (len == 0) break; /* End of file */ + while (1) { + len = fread(buf, 1, sizeof(buf), uncompressedfile); + if (ferror(uncompressedfile)) { + pline("Failure reading uncompressed file"); + pline("Can't compress %s.", filename); + fclose(uncompressedfile); + gzclose(compressedfile); + (void)unlink(cfn); + return; + } + if (len == 0) break; /* End of file */ - len2 = gzwrite(compressedfile, buf, len); - if (len2 == 0) { - pline("Failure writing compressed file"); - pline("Can't compress %s.", filename); - fclose(uncompressedfile); - gzclose(compressedfile); - (void)unlink(cfn); - return; - } - } + len2 = gzwrite(compressedfile, buf, len); + if (len2 == 0) { + pline("Failure writing compressed file"); + pline("Can't compress %s.", filename); + fclose(uncompressedfile); + gzclose(compressedfile); + (void)unlink(cfn); + return; + } + } - fclose(uncompressedfile); - gzclose(compressedfile); + fclose(uncompressedfile); + gzclose(compressedfile); - /* Delete the file left behind */ + /* Delete the file left behind */ - (void)unlink(filename); + (void)unlink(filename); - } else { /* uncomp */ + } else { /* uncomp */ - /* Open the input and output files */ - /* Note that gzopen takes "rb" as its mode, even on systems where - fopen takes "r" and "w" */ + /* Open the input and output files */ + /* Note that gzopen takes "rb" as its mode, even on systems where + fopen takes "r" and "w" */ - compressedfile = gzopen(cfn, "rb"); - if (compressedfile == NULL) { - if (errno == 0) { - pline("zlib failed to allocate memory"); - } else if (errno != ENOENT) { - panic("Error in zlib docompress_file %s, %d", - filename, errno); - } - return; - } - uncompressedfile = fopen(filename, WRBMODE); - if (!uncompressedfile) { - pline("Error in zlib docompress file uncompress %s", - filename); - gzclose(compressedfile); - return; - } + compressedfile = gzopen(cfn, "rb"); + if (compressedfile == NULL) { + if (errno == 0) { + pline("zlib failed to allocate memory"); + } else if (errno != ENOENT) { + panic("Error in zlib docompress_file %s, %d", + filename, errno); + } + return; + } + uncompressedfile = fopen(filename, WRBMODE); + if (!uncompressedfile) { + pline("Error in zlib docompress file uncompress %s", + filename); + gzclose(compressedfile); + return; + } - /* Copy from the compressed to the uncompressed file */ + /* Copy from the compressed to the uncompressed file */ - while (1) { - len = gzread(compressedfile, buf, sizeof(buf)); - if (len == (unsigned)-1) { - pline("Failure reading compressed file"); - pline("Can't uncompress %s.", filename); - fclose(uncompressedfile); - gzclose(compressedfile); - (void)unlink(filename); - return; - } - if (len == 0) break; /* End of file */ + while (1) { + len = gzread(compressedfile, buf, sizeof(buf)); + if (len == (unsigned)-1) { + pline("Failure reading compressed file"); + pline("Can't uncompress %s.", filename); + fclose(uncompressedfile); + gzclose(compressedfile); + (void)unlink(filename); + return; + } + if (len == 0) break; /* End of file */ - fwrite(buf, 1, len, uncompressedfile); - if (ferror(uncompressedfile)) { - pline("Failure writing uncompressed file"); - pline("Can't uncompress %s.", filename); - fclose(uncompressedfile); - gzclose(compressedfile); - (void)unlink(filename); - return; - } - } + fwrite(buf, 1, len, uncompressedfile); + if (ferror(uncompressedfile)) { + pline("Failure writing uncompressed file"); + pline("Can't uncompress %s.", filename); + fclose(uncompressedfile); + gzclose(compressedfile); + (void)unlink(filename); + return; + } + } - fclose(uncompressedfile); - gzclose(compressedfile); + fclose(uncompressedfile); + gzclose(compressedfile); - /* Delete the file left behind */ - (void)unlink(cfn); - } + /* Delete the file left behind */ + (void)unlink(cfn); + } } #endif /* RLC 09 Mar 1999: End ZLIB patch */ @@ -1565,28 +1565,28 @@ char *lockname; { #if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(WIN32) || defined(MSDOS) # ifdef NO_FILE_LINKS - Strcpy(lockname, LOCKDIR); - Strcat(lockname, "/"); - Strcat(lockname, filename); + Strcpy(lockname, LOCKDIR); + Strcat(lockname, "/"); + Strcat(lockname, filename); # else - Strcpy(lockname, filename); + Strcpy(lockname, filename); # endif # ifdef VMS { - char *semi_colon = rindex(lockname, ';'); - if (semi_colon) *semi_colon = '\0'; + char *semi_colon = rindex(lockname, ';'); + if (semi_colon) *semi_colon = '\0'; } - Strcat(lockname, ".lock;1"); + Strcat(lockname, ".lock;1"); # else - Strcat(lockname, "_lock"); + Strcat(lockname, "_lock"); # endif - return lockname; + return lockname; #else /* !(UNIX || VMS || AMIGA || WIN32 || MSDOS) */ # ifdef PRAGMA_UNUSED # pragma unused(filename) # endif - lockname[0] = '\0'; - return (char*)0; + lockname[0] = '\0'; + return (char*)0; #endif } #endif /* !USE_FCNTL */ @@ -1602,117 +1602,117 @@ int retryct; # pragma unused(retryct) #endif #ifndef USE_FCNTL - char locknambuf[BUFSZ]; - const char *lockname; + char locknambuf[BUFSZ]; + const char *lockname; #endif - nesting++; - if (nesting > 1) { - impossible("TRIED TO NEST LOCKS"); - return TRUE; - } + nesting++; + if (nesting > 1) { + impossible("TRIED TO NEST LOCKS"); + return TRUE; + } #ifndef USE_FCNTL - lockname = make_lockname(filename, locknambuf); + lockname = make_lockname(filename, locknambuf); #ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */ - lockname = fqname(lockname, LOCKPREFIX, 2); + lockname = fqname(lockname, LOCKPREFIX, 2); #endif #endif - filename = fqname(filename, whichprefix, 0); + filename = fqname(filename, whichprefix, 0); #ifdef USE_FCNTL - lockfd = open(filename,O_RDWR); - if (lockfd == -1) { - HUP raw_printf("Cannot open file %s. This is a program bug.", - filename); - } - sflock.l_type = F_WRLCK; - sflock.l_whence = SEEK_SET; - sflock.l_start = 0; - sflock.l_len = 0; + lockfd = open(filename,O_RDWR); + if (lockfd == -1) { + HUP raw_printf("Cannot open file %s. This is a program bug.", + filename); + } + sflock.l_type = F_WRLCK; + sflock.l_whence = SEEK_SET; + sflock.l_start = 0; + sflock.l_len = 0; #endif #if defined(UNIX) || defined(VMS) # ifdef USE_FCNTL - while (fcntl(lockfd,F_SETLK,&sflock) == -1) { + while (fcntl(lockfd,F_SETLK,&sflock) == -1) { # else # ifdef NO_FILE_LINKS - while ((lockfd = open(lockname, O_RDWR|O_CREAT|O_EXCL, 0666)) == -1) { + while ((lockfd = open(lockname, O_RDWR|O_CREAT|O_EXCL, 0666)) == -1) { # else - while (link(filename, lockname) == -1) { + while (link(filename, lockname) == -1) { # endif # endif #ifdef USE_FCNTL - if (retryct--) { - HUP raw_printf( - "Waiting for release of fcntl lock on %s. (%d retries left).", - filename, retryct); - sleep(1); - } else { - HUP (void) raw_print("I give up. Sorry."); - HUP raw_printf("Some other process has an unnatural grip on %s.", - filename); - nesting--; - return FALSE; - } + if (retryct--) { + HUP raw_printf( + "Waiting for release of fcntl lock on %s. (%d retries left).", + filename, retryct); + sleep(1); + } else { + HUP (void) raw_print("I give up. Sorry."); + HUP raw_printf("Some other process has an unnatural grip on %s.", + filename); + nesting--; + return FALSE; + } #else - register int errnosv = errno; + register int errnosv = errno; - switch (errnosv) { /* George Barbanis */ - case EEXIST: - if (retryct--) { - HUP raw_printf( - "Waiting for access to %s. (%d retries left).", - filename, retryct); + switch (errnosv) { /* George Barbanis */ + case EEXIST: + if (retryct--) { + HUP raw_printf( + "Waiting for access to %s. (%d retries left).", + filename, retryct); # if defined(SYSV) || defined(ULTRIX) || defined(VMS) - (void) + (void) # endif - sleep(1); - } else { - HUP (void) raw_print("I give up. Sorry."); - HUP raw_printf("Perhaps there is an old %s around?", - lockname); - nesting--; - return FALSE; - } + sleep(1); + } else { + HUP (void) raw_print("I give up. Sorry."); + HUP raw_printf("Perhaps there is an old %s around?", + lockname); + nesting--; + return FALSE; + } - break; - case ENOENT: - HUP raw_printf("Can't find file %s to lock!", filename); - nesting--; - return FALSE; - case EACCES: - HUP raw_printf("No write permission to lock %s!", filename); - nesting--; - return FALSE; + break; + case ENOENT: + HUP raw_printf("Can't find file %s to lock!", filename); + nesting--; + return FALSE; + case EACCES: + HUP raw_printf("No write permission to lock %s!", filename); + nesting--; + return FALSE; # ifdef VMS /* c__translate(vmsfiles.c) */ - case EPERM: - /* could be misleading, but usually right */ - HUP raw_printf("Can't lock %s due to directory protection.", - filename); - nesting--; - return FALSE; + case EPERM: + /* could be misleading, but usually right */ + HUP raw_printf("Can't lock %s due to directory protection.", + filename); + nesting--; + return FALSE; # endif - case EROFS: - /* take a wild guess at the underlying cause */ - HUP perror(lockname); - HUP raw_printf("Cannot lock %s.", filename); - HUP raw_printf( + case EROFS: + /* take a wild guess at the underlying cause */ + HUP perror(lockname); + HUP raw_printf("Cannot lock %s.", filename); + HUP raw_printf( "(Perhaps you are running NetHack from inside the distribution package?)." - ); - nesting--; - return FALSE; - default: - HUP perror(lockname); - HUP raw_printf( - "Cannot lock %s for unknown reason (%d).", - filename, errnosv); - nesting--; - return FALSE; - } + ); + nesting--; + return FALSE; + default: + HUP perror(lockname); + HUP raw_printf( + "Cannot lock %s for unknown reason (%d).", + filename, errnosv); + nesting--; + return FALSE; + } #endif /* USE_FCNTL */ - } + } #endif /* UNIX || VMS */ #if (defined(AMIGA) || defined(WIN32) || defined(MSDOS)) && !defined(USE_FCNTL) @@ -1725,28 +1725,28 @@ int retryct; # endif while (--retryct && OPENFAILURE(lockptr)) { # if defined(WIN32) && !defined(WIN_CE) - lockptr = sopen(lockname, O_RDWR|O_CREAT, SH_DENYRW, S_IWRITE); + lockptr = sopen(lockname, O_RDWR|O_CREAT, SH_DENYRW, S_IWRITE); # else - (void)DeleteFile(lockname); /* in case dead process was here first */ + (void)DeleteFile(lockname); /* in case dead process was here first */ # ifdef AMIGA - lockptr = Open(lockname,MODE_NEWFILE); + lockptr = Open(lockname,MODE_NEWFILE); # else - lockptr = open(lockname, O_RDWR|O_CREAT|O_EXCL, S_IWRITE); + lockptr = open(lockname, O_RDWR|O_CREAT|O_EXCL, S_IWRITE); # endif # endif - if (OPENFAILURE(lockptr)) { - raw_printf("Waiting for access to %s. (%d retries left).", - filename, retryct); - Delay(50); - } + if (OPENFAILURE(lockptr)) { + raw_printf("Waiting for access to %s. (%d retries left).", + filename, retryct); + Delay(50); + } } if (!retryct) { - raw_printf("I give up. Sorry."); - nesting--; - return FALSE; + raw_printf("I give up. Sorry."); + nesting--; + return FALSE; } #endif /* AMIGA || WIN32 || MSDOS */ - return TRUE; + return TRUE; } @@ -1763,26 +1763,26 @@ unlock_file(filename) const char *filename; { #ifndef USE_FCNTL - char locknambuf[BUFSZ]; - const char *lockname; + char locknambuf[BUFSZ]; + const char *lockname; #endif - if (nesting == 1) { + if (nesting == 1) { #ifdef USE_FCNTL - sflock.l_type = F_UNLCK; - if (fcntl(lockfd,F_SETLK,&sflock) == -1) { - HUP raw_printf("Can't remove fcntl lock on %s.", filename); - (void) close(lockfd); - } + sflock.l_type = F_UNLCK; + if (fcntl(lockfd,F_SETLK,&sflock) == -1) { + HUP raw_printf("Can't remove fcntl lock on %s.", filename); + (void) close(lockfd); + } #else - lockname = make_lockname(filename, locknambuf); + lockname = make_lockname(filename, locknambuf); #ifndef NO_FILE_LINKS /* LOCKDIR should be subsumed by LOCKPREFIX */ - lockname = fqname(lockname, LOCKPREFIX, 2); + lockname = fqname(lockname, LOCKPREFIX, 2); #endif #if defined(UNIX) || defined(VMS) - if (unlink(lockname) < 0) - HUP raw_printf("Can't unlink %s.", lockname); + if (unlink(lockname) < 0) + HUP raw_printf("Can't unlink %s.", lockname); # ifdef NO_FILE_LINKS (void) nhclose(lockfd); # endif @@ -1790,14 +1790,14 @@ const char *filename; #endif /* UNIX || VMS */ #if defined(AMIGA) || defined(WIN32) || defined(MSDOS) - if (lockptr) Close(lockptr); - DeleteFile(lockname); - lockptr = 0; + if (lockptr) Close(lockptr); + DeleteFile(lockname); + lockptr = 0; #endif /* AMIGA || WIN32 || MSDOS */ #endif /* USE_FCNTL */ - } + } - nesting--; + nesting--; } /* ---------- END FILE LOCKING HANDLING ----------- */ @@ -1807,15 +1807,15 @@ const char *filename; const char *configfile = #ifdef UNIX - ".nethackrc"; + ".nethackrc"; #else # if defined(MAC) || defined(__BEOS__) - "NetHack Defaults"; + "NetHack Defaults"; # else # if defined(MSDOS) || defined(WIN32) - "defaults.nh"; + "defaults.nh"; # else - "NetHack.cnf"; + "NetHack.cnf"; # endif # endif #endif @@ -1843,137 +1843,136 @@ fopen_config_file(filename, src) const char *filename; int src; { - FILE *fp; + FILE *fp; #if defined(UNIX) || defined(VMS) - char tmp_config[BUFSZ]; - char *envp; + char tmp_config[BUFSZ]; + char *envp; #endif - /* If src != SET_IN_SYS, "filename" is an environment variable, so it - * should hang around. If set, it is expected to be a full path name - * (if relevant) */ - if (filename) { + /* If src != SET_IN_SYS, "filename" is an environment variable, so it + * should hang around. If set, it is expected to be a full path name + * (if relevant) */ + if (filename) { #ifdef UNIX - if ((src!=SET_IN_SYS) && access(filename, 4) == -1) { - /* 4 is R_OK on newer systems */ - /* nasty sneaky attempt to read file through - * NetHack's setuid permissions -- this is the only - * place a file name may be wholly under the player's - * control (but SYSCF_FILE is not under the player's - * control so it's OK). - */ - raw_printf("Access to %s denied (%d).", - filename, errno); - wait_synch(); - /* fall through to standard names */ - } else + if ((src!=SET_IN_SYS) && access(filename, 4) == -1) { + /* 4 is R_OK on newer systems */ + /* nasty sneaky attempt to read file through + * NetHack's setuid permissions -- this is the only + * place a file name may be wholly under the player's + * control (but SYSCF_FILE is not under the player's + * control so it's OK). + */ + raw_printf("Access to %s denied (%d).", + filename, errno); + wait_synch(); + /* fall through to standard names */ + } else #endif #ifdef PREFIXES_IN_USE - if (src == SET_IN_SYS) { - (void) strncpy(lastconfigfile, - fqname(filename, SYSCONFPREFIX, 0), BUFSZ-1); - } else + if (src == SET_IN_SYS) { + (void) strncpy(lastconfigfile, + fqname(filename, SYSCONFPREFIX, 0), BUFSZ-1); + } else #endif - (void) strncpy(lastconfigfile, filename, BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { - return(fp); + /* always honor sysconf first before anything else */ + (void) strncpy(lastconfigfile, filename, BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) + return(fp); + if ((fp = fopenp(filename, "r")) != (FILE *)0) { + return(fp); #if defined(UNIX) || defined(VMS) - } else { - /* access() above probably caught most problems for UNIX */ - raw_printf("Couldn't open requested config file %s (%d).", - filename, errno); - wait_synch(); - /* fall through to standard names */ + } else { + /* access() above probably caught most problems for UNIX */ + raw_printf("Couldn't open requested config file %s (%d).", + filename, errno); + wait_synch(); + /* fall through to standard names */ #endif - } - } + } + } #if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32) - (void) strncpy(lastconfigfile, - fqname(configfile, CONFIGPREFIX, 0), BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { - return(fp); - } + if ((fp = fopenp(fqname(configfile, CONFIGPREFIX, 0), "r")) != (FILE *)0) + return(fp); + if ((fp = fopenp(configfile, "r")) != (FILE *)0) + return(fp); # ifdef MSDOS - (void) strncpy(lastconfigfile, - fqname(backward_compat_configfile, CONFIGPREFIX, 0), - BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - else if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) - return(fp); + if ((fp = fopenp(fqname(backward_compat_configfile, CONFIGPREFIX, 0), "r")) != (FILE *)0) + return(fp); + if ((fp = fopenp(backward_compat_configfile, "r")) != (FILE *)0) + return(fp); # endif #else - /* constructed full path names don't need fqname() */ + /* constructed full path names don't need fqname() */ # ifdef VMS - (void) strncpy(lastconfigfile, fqname("nethackini", CONFIGPREFIX, 0), - BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { - return(fp); - } - (void) strncpy(lastconfigfile,"sys$login:nethack.ini", BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { - return(fp); - } + (void) strncpy(lastconfigfile, fqname("nethackini", CONFIGPREFIX, 0), + BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { + return(fp); + } + (void) strncpy(lastconfigfile,"sys$login:nethack.ini", BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) { + return(fp); + } - envp = nh_getenv("HOME"); - if (!envp) - Strcpy(tmp_config, "NetHack.cnf"); - else - Sprintf(tmp_config, "%s%s", envp, "NetHack.cnf"); + envp = nh_getenv("HOME"); + if (!envp) + Strcpy(tmp_config, "NetHack.cnf"); + else + Sprintf(tmp_config, "%s%s", envp, "NetHack.cnf"); - (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(tmp_config, "r")) != (FILE *)0) - return(fp); + (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(tmp_config, "r")) != (FILE *)0) + return(fp); # else /* should be only UNIX left */ - envp = nh_getenv("HOME"); - if (!envp) - Strcpy(tmp_config, ".nethackrc"); - else - Sprintf(tmp_config, "%s/%s", envp, ".nethackrc"); + envp = nh_getenv("HOME"); + if (!envp) + Strcpy(tmp_config, ".nethackrc"); + else + Sprintf(tmp_config, "%s/%s", envp, ".nethackrc"); - (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) - return(fp); + (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) + return(fp); # if defined(__APPLE__) - /* try an alternative */ - if (envp) { - Sprintf(tmp_config, "%s/%s", envp, - "Library/Preferences/NetHack Defaults"); - (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) - return(fp); - Sprintf(tmp_config, "%s/%s", envp, - "Library/Preferences/NetHack Defaults.txt"); - (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); - lastconfigfile[BUFSZ-1] = '\0'; - if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) - return(fp); - } + /* try an alternative */ + if (envp) { + Sprintf(tmp_config, "%s/%s", envp, + "Library/Preferences/NetHack Defaults"); + (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) + return(fp); + Sprintf(tmp_config, "%s/%s", envp, + "Library/Preferences/NetHack Defaults.txt"); + (void) strncpy(lastconfigfile, tmp_config, BUFSZ-1); + lastconfigfile[BUFSZ-1] = '\0'; + if ((fp = fopenp(lastconfigfile, "r")) != (FILE *)0) + return(fp); + } # endif - if (errno != ENOENT) { - const char *details; + if (errno != ENOENT) { + const char *details; - /* e.g., problems when setuid NetHack can't search home - * directory restricted to user */ + /* e.g., problems when setuid NetHack can't search home + * directory restricted to user */ # if defined (NHSTDC) && !defined(NOTSTDC) - if ((details = strerror(errno)) == 0) + if ((details = strerror(errno)) == 0) # endif - details = ""; - raw_printf("Couldn't open default config file %s %s(%d).", - lastconfigfile, details, errno); - wait_synch(); - } + details = ""; + raw_printf("Couldn't open default config file %s %s(%d).", + lastconfigfile, details, errno); + wait_synch(); + } # endif /* Unix */ #endif - return (FILE *)0; + return (FILE *)0; } @@ -1998,43 +1997,43 @@ get_uchars(fp, buf, bufp, list, modlist, size, name) boolean havenum = FALSE; while (1) { - switch(*bufp) { - case ' ': case '\0': - case '\t': case '\n': - if (havenum) { - /* if modifying in place, don't insert zeros */ - if (num || !modlist) list[count] = num; - count++; - num = 0; - havenum = FALSE; - } - if (count == size || !*bufp) return count; - bufp++; - break; + switch(*bufp) { + case ' ': case '\0': + case '\t': case '\n': + if (havenum) { + /* if modifying in place, don't insert zeros */ + if (num || !modlist) list[count] = num; + count++; + num = 0; + havenum = FALSE; + } + if (count == size || !*bufp) return count; + bufp++; + break; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - case '8': case '9': - havenum = TRUE; - num = num*10 + (*bufp-'0'); - bufp++; - break; + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': + havenum = TRUE; + num = num*10 + (*bufp-'0'); + bufp++; + break; - case '\\': - if (fp == (FILE *)0) - goto gi_error; - do { - if (!fgets(buf, BUFSZ, fp)) goto gi_error; - } while (buf[0] == '#'); - bufp = buf; - break; + case '\\': + if (fp == (FILE *)0) + goto gi_error; + do { + if (!fgets(buf, BUFSZ, fp)) goto gi_error; + } while (buf[0] == '#'); + bufp = buf; + break; - default: + default: gi_error: - raw_printf("Syntax error in %s", name); - wait_synch(); - return count; - } + raw_printf("Syntax error in %s", name); + wait_synch(); + return count; + } } /*NOTREACHED*/ } @@ -2045,16 +2044,16 @@ adjust_prefix(bufp, prefixid) char *bufp; int prefixid; { - char *ptr; + char *ptr; - if (!bufp) return; - /* Backward compatibility, ignore trailing ;n */ - if ((ptr = index(bufp, ';')) != 0) *ptr = '\0'; - if (strlen(bufp) > 0) { - fqn_prefix[prefixid] = (char *)alloc(strlen(bufp)+2); - Strcpy(fqn_prefix[prefixid], bufp); - append_slash(fqn_prefix[prefixid]); - } + if (!bufp) return; + /* Backward compatibility, ignore trailing ;n */ + if ((ptr = index(bufp, ';')) != 0) *ptr = '\0'; + if (strlen(bufp) > 0) { + fqn_prefix[prefixid] = (char *)alloc(strlen(bufp)+2); + Strcpy(fqn_prefix[prefixid], bufp); + append_slash(fqn_prefix[prefixid]); + } } #endif @@ -2067,415 +2066,418 @@ char *buf; int src; { #if defined(MICRO) && !defined(NOCWD_ASSUMPTIONS) - static boolean ramdisk_specified = FALSE; + static boolean ramdisk_specified = FALSE; #endif #ifdef SYSCF - int n; + int n; #endif - char *bufp, *altp; - uchar translate[MAXPCHARS]; - int len; - /* lines beginning with '#' are comments */ - if (*buf == '#') - return 1; + char *bufp, *altp; + uchar translate[MAXPCHARS]; + int len; + /* lines beginning with '#' are comments */ + if (*buf == '#') + return 1; - /* remove trailing whitespace */ - bufp = eos(buf); - while (--bufp > buf && isspace(*bufp)) - continue; + /* remove trailing whitespace */ + bufp = eos(buf); + while (--bufp > buf && isspace(*bufp)) + continue; - if (bufp <= buf) - return 1; /* skip all-blank lines */ - else - *(bufp + 1) = '\0'; /* terminate line */ + if (bufp <= buf) + return 1; /* skip all-blank lines */ + else + *(bufp + 1) = '\0'; /* terminate line */ - /* find the '=' or ':' */ - bufp = index(buf, '='); - altp = index(buf, ':'); - if (!bufp || (altp && altp < bufp)) bufp = altp; - if (!bufp) return 0; + /* find the '=' or ':' */ + bufp = index(buf, '='); + altp = index(buf, ':'); + if (!bufp || (altp && altp < bufp)) bufp = altp; + if (!bufp) return 0; - /* skip whitespace between '=' and value */ - do { ++bufp; } while (isspace(*bufp)); + /* skip whitespace between '=' and value */ + do { ++bufp; } while (isspace(*bufp)); - /* Go through possible variables */ - /* some of these (at least LEVELS and SAVE) should now set the - * appropriate fqn_prefix[] rather than specialized variables - */ - if (match_varname(buf, "OPTIONS", 4)) { - parseoptions(bufp, TRUE, TRUE); - if (plname[0]) /* If a name was given */ - plnamesuffix(); /* set the character class */ - } else if (match_varname(buf, "AUTOPICKUP_EXCEPTION", 5)) { - add_autopickup_exception(bufp); + /* Go through possible variables */ + /* some of these (at least LEVELS and SAVE) should now set the + * appropriate fqn_prefix[] rather than specialized variables + */ + if (match_varname(buf, "OPTIONS", 4)) { + parseoptions(bufp, TRUE, TRUE); + if (plname[0]) /* If a name was given */ + plnamesuffix(); /* set the character class */ + } else if (match_varname(buf, "AUTOPICKUP_EXCEPTION", 5)) { + add_autopickup_exception(bufp); #ifdef NOCWD_ASSUMPTIONS - } else if (match_varname(buf, "HACKDIR", 4)) { - adjust_prefix(bufp, HACKPREFIX); - } else if (match_varname(buf, "LEVELDIR", 4) || - match_varname(buf, "LEVELS", 4)) { - adjust_prefix(bufp, LEVELPREFIX); - } else if (match_varname(buf, "SAVEDIR", 4)) { - adjust_prefix(bufp, SAVEPREFIX); - } else if (match_varname(buf, "BONESDIR", 5)) { - adjust_prefix(bufp, BONESPREFIX); - } else if (match_varname(buf, "DATADIR", 4)) { - adjust_prefix(bufp, DATAPREFIX); - } else if (match_varname(buf, "SCOREDIR", 4)) { - adjust_prefix(bufp, SCOREPREFIX); - } else if (match_varname(buf, "LOCKDIR", 4)) { - adjust_prefix(bufp, LOCKPREFIX); - } else if (match_varname(buf, "CONFIGDIR", 4)) { - adjust_prefix(bufp, CONFIGPREFIX); - } else if (match_varname(buf, "TROUBLEDIR", 4)) { - adjust_prefix(bufp, TROUBLEPREFIX); + } else if (match_varname(buf, "HACKDIR", 4)) { + adjust_prefix(bufp, HACKPREFIX); + } else if (match_varname(buf, "LEVELDIR", 4) || + match_varname(buf, "LEVELS", 4)) { + adjust_prefix(bufp, LEVELPREFIX); + } else if (match_varname(buf, "SAVEDIR", 4)) { + adjust_prefix(bufp, SAVEPREFIX); + } else if (match_varname(buf, "BONESDIR", 5)) { + adjust_prefix(bufp, BONESPREFIX); + } else if (match_varname(buf, "DATADIR", 4)) { + adjust_prefix(bufp, DATAPREFIX); + } else if (match_varname(buf, "SCOREDIR", 4)) { + adjust_prefix(bufp, SCOREPREFIX); + } else if (match_varname(buf, "LOCKDIR", 4)) { + adjust_prefix(bufp, LOCKPREFIX); + } else if (match_varname(buf, "CONFIGDIR", 4)) { + adjust_prefix(bufp, CONFIGPREFIX); + } else if (match_varname(buf, "TROUBLEDIR", 4)) { + adjust_prefix(bufp, TROUBLEPREFIX); #else /*NOCWD_ASSUMPTIONS*/ # ifdef MICRO - } else if (match_varname(buf, "HACKDIR", 4)) { - (void) strncpy(hackdir, bufp, PATHLEN-1); + } else if (match_varname(buf, "HACKDIR", 4)) { + (void) strncpy(hackdir, bufp, PATHLEN-1); # ifdef MFLOPPY - } else if (match_varname(buf, "RAMDISK", 3)) { - /* The following ifdef is NOT in the wrong - * place. For now, we accept and silently - * ignore RAMDISK */ + } else if (match_varname(buf, "RAMDISK", 3)) { + /* The following ifdef is NOT in the wrong + * place. For now, we accept and silently + * ignore RAMDISK */ # ifndef AMIGA - if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0'; - Strcpy(levels, bufp); - ramdisk = (strcmp(permbones, levels) != 0); - ramdisk_specified = TRUE; + if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0'; + Strcpy(levels, bufp); + ramdisk = (strcmp(permbones, levels) != 0); + ramdisk_specified = TRUE; # endif # endif - } else if (match_varname(buf, "LEVELS", 4)) { - if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0'; - Strcpy(permbones, bufp); - if (!ramdisk_specified || !*levels) Strcpy(levels, bufp); - ramdisk = (strcmp(permbones, levels) != 0); - } else if (match_varname(buf, "SAVE", 4)) { + } else if (match_varname(buf, "LEVELS", 4)) { + if (strlen(bufp) >= PATHLEN) bufp[PATHLEN-1] = '\0'; + Strcpy(permbones, bufp); + if (!ramdisk_specified || !*levels) Strcpy(levels, bufp); + ramdisk = (strcmp(permbones, levels) != 0); + } else if (match_varname(buf, "SAVE", 4)) { # ifdef MFLOPPY - extern int saveprompt; + extern int saveprompt; # endif - char *ptr; + char *ptr; - if ((ptr = index(bufp, ';')) != 0) { - *ptr = '\0'; + if ((ptr = index(bufp, ';')) != 0) { + *ptr = '\0'; # ifdef MFLOPPY - if (*(ptr+1) == 'n' || *(ptr+1) == 'N') { - saveprompt = FALSE; - } + if (*(ptr+1) == 'n' || *(ptr+1) == 'N') { + saveprompt = FALSE; + } # endif - } + } # if defined(SYSFLAGS) && defined(MFLOPPY) - else - saveprompt = sysflags.asksavedisk; + else + saveprompt = sysflags.asksavedisk; # endif - (void) strncpy(SAVEP, bufp, SAVESIZE-1); - append_slash(SAVEP); + (void) strncpy(SAVEP, bufp, SAVESIZE-1); + append_slash(SAVEP); # endif /* MICRO */ #endif /*NOCWD_ASSUMPTIONS*/ - } else if (match_varname(buf, "NAME", 4)) { - (void) strncpy(plname, bufp, PL_NSIZ-1); - plnamesuffix(); - } else if (match_varname(buf, "ROLE", 4) || - match_varname(buf, "CHARACTER", 4)) { - if ((len = str2role(bufp)) >= 0) - flags.initrole = len; - } else if (match_varname(buf, "DOGNAME", 3)) { - (void) strncpy(dogname, bufp, PL_PSIZ-1); - } else if (match_varname(buf, "CATNAME", 3)) { - (void) strncpy(catname, bufp, PL_PSIZ-1); + } else if (match_varname(buf, "NAME", 4)) { + (void) strncpy(plname, bufp, PL_NSIZ-1); + plnamesuffix(); + } else if (match_varname(buf, "ROLE", 4) || + match_varname(buf, "CHARACTER", 4)) { + if ((len = str2role(bufp)) >= 0) + flags.initrole = len; + } else if (match_varname(buf, "DOGNAME", 3)) { + (void) strncpy(dogname, bufp, PL_PSIZ-1); + } else if (match_varname(buf, "CATNAME", 3)) { + (void) strncpy(catname, bufp, PL_PSIZ-1); #ifdef SYSCF - } else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) { - if (sysopt.wizards) free(sysopt.wizards); - sysopt.wizards = dupstr(bufp); - } else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) { - if (sysopt.shellers) free(sysopt.shellers); - sysopt.shellers = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "WIZARDS", 7)) { + if (sysopt.wizards) free(sysopt.wizards); + sysopt.wizards = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) { + if (sysopt.shellers) free(sysopt.shellers); + sysopt.shellers = dupstr(bufp); } else if (src == SET_IN_SYS && match_varname(buf, "EXPLORERS", 7)) { if (sysopt.explorers) free(sysopt.explorers); sysopt.explorers = dupstr(bufp); - } else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) { - if (sysopt.debugfiles) free(sysopt.debugfiles); - /* if showdebug() has already been called (perhaps we've added - some debugpline() calls to option processing) and has found - a value for getenv("DEBUGFILES"), don't override that */ - if (sysopt.env_dbgfl == 0) - sysopt.debugfiles = dupstr(bufp); - } else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) { - if (sysopt.support) free(sysopt.support); - sysopt.support = dupstr(bufp); - } else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) { - if (sysopt.recover) free(sysopt.recover); - sysopt.recover = dupstr(bufp); - } else if (match_varname(buf, "SEDUCE", 6)) { - n = !!atoi(bufp); /* XXX this could be tighter */ - /* allow anyone to turn it off, but only sysconf to turn it on*/ - if (src != SET_IN_SYS && n != 0) { - raw_printf("Illegal value in SEDUCE"); - return 0; - } - sysopt.seduce = n; - sysopt_seduce_set(sysopt.seduce); - } else if (src == SET_IN_SYS && match_varname(buf, "MAXPLAYERS", 10)) { - n = atoi(bufp); - /* XXX to get more than 25, need to rewrite all lock code */ - if (n < 1 || n > 25) { - raw_printf("Illegal value in MAXPLAYERS (maximum is 25)."); - return 0; - } - sysopt.maxplayers = n; - } else if (src == SET_IN_SYS && match_varname(buf, "PERSMAX", 7)) { - n = atoi(bufp); - if (n < 1) { - raw_printf("Illegal value in PERSMAX (minimum is 1)."); - return 0; - } - sysopt.persmax = n; - } else if (src == SET_IN_SYS && match_varname(buf, "PERS_IS_UID", 11)) { - n = atoi(bufp); - if (n != 0 && n != 1) { - raw_printf("Illegal value in PERS_IS_UID (must be 0 or 1)."); - return 0; - } - sysopt.pers_is_uid = n; - } else if (src == SET_IN_SYS && match_varname(buf, "ENTRYMAX", 8)) { - n = atoi(bufp); - if (n < 10) { - raw_printf("Illegal value in ENTRYMAX (minimum is 10)."); - return 0; - } - sysopt.entrymax = n; - } else if ( (src==SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) { - n = atoi(bufp); - if (n < 1) { - raw_printf("Illegal value in POINTSMIN (minimum is 1)."); - return 0; - } - sysopt.pointsmin = n; - } else if (src == SET_IN_SYS && match_varname(buf, "MAX_STATUENAME_RANK", 10)) { - n = atoi(bufp); - if (n < 1) { - raw_printf("Illegal value in MAX_STATUENAME_RANK (minimum is 1)."); - return 0; - } - sysopt.tt_oname_maxrank = n; + } else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) { + if (sysopt.debugfiles) free(sysopt.debugfiles); + /* if showdebug() has already been called (perhaps we've added + some debugpline() calls to option processing) and has found + a value for getenv("DEBUGFILES"), don't override that */ + if (sysopt.env_dbgfl == 0) + sysopt.debugfiles = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) { + if (sysopt.support) free(sysopt.support); + sysopt.support = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) { + if (sysopt.recover) free(sysopt.recover); + sysopt.recover = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "CHECK_SAVE_UID", 14)) { + n = atoi(bufp); + sysopt.check_save_uid = n; + } else if (match_varname(buf, "SEDUCE", 6)) { + n = !!atoi(bufp); /* XXX this could be tighter */ + /* allow anyone to turn it off, but only sysconf to turn it on*/ + if (src != SET_IN_SYS && n != 0) { + raw_printf("Illegal value in SEDUCE"); + return 0; + } + sysopt.seduce = n; + sysopt_seduce_set(sysopt.seduce); + } else if (src == SET_IN_SYS && match_varname(buf, "MAXPLAYERS", 10)) { + n = atoi(bufp); + /* XXX to get more than 25, need to rewrite all lock code */ + if (n < 1 || n > 25) { + raw_printf("Illegal value in MAXPLAYERS (maximum is 25)."); + return 0; + } + sysopt.maxplayers = n; + } else if (src == SET_IN_SYS && match_varname(buf, "PERSMAX", 7)) { + n = atoi(bufp); + if (n < 1) { + raw_printf("Illegal value in PERSMAX (minimum is 1)."); + return 0; + } + sysopt.persmax = n; + } else if (src == SET_IN_SYS && match_varname(buf, "PERS_IS_UID", 11)) { + n = atoi(bufp); + if (n != 0 && n != 1) { + raw_printf("Illegal value in PERS_IS_UID (must be 0 or 1)."); + return 0; + } + sysopt.pers_is_uid = n; + } else if (src == SET_IN_SYS && match_varname(buf, "ENTRYMAX", 8)) { + n = atoi(bufp); + if (n < 10) { + raw_printf("Illegal value in ENTRYMAX (minimum is 10)."); + return 0; + } + sysopt.entrymax = n; + } else if ( (src==SET_IN_SYS) && match_varname(buf, "POINTSMIN", 9)) { + n = atoi(bufp); + if (n < 1) { + raw_printf("Illegal value in POINTSMIN (minimum is 1)."); + return 0; + } + sysopt.pointsmin = n; + } else if (src == SET_IN_SYS && match_varname(buf, "MAX_STATUENAME_RANK", 10)) { + n = atoi(bufp); + if (n < 1) { + raw_printf("Illegal value in MAX_STATUENAME_RANK (minimum is 1)."); + return 0; + } + sysopt.tt_oname_maxrank = n; # ifdef PANICTRACE - } else if (src == SET_IN_SYS && - match_varname(buf, "PANICTRACE_LIBC", 15)) { + } else if (src == SET_IN_SYS && + match_varname(buf, "PANICTRACE_LIBC", 15)) { # ifdef PANICTRACE_LIBC - n = atoi(bufp); - if (n < 0 || n > 2) { - raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2)."); - return 0; - } - sysopt.panictrace_libc = n; + n = atoi(bufp); + if (n < 0 || n > 2) { + raw_printf("Illegal value in PANICTRACE_LIBC (not 0,1,2)."); + return 0; + } + sysopt.panictrace_libc = n; # endif /* PANICTRACE_LIBC */ - } else if (src == SET_IN_SYS && - match_varname(buf, "PANICTRACE_GDB", 14)) { - n = atoi(bufp); - if (n < 0 || n > 2) { - raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2)."); - return 0; - } - sysopt.panictrace_gdb = n; - } else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) { - if (!file_exists(bufp)) { - raw_printf("File specified in GDBPATH does not exist."); - return 0; - } - if (sysopt.gdbpath) free(sysopt.gdbpath); - sysopt.gdbpath = dupstr(bufp); - } else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) { - if (!file_exists(bufp)) { - raw_printf("File specified in GREPPATH does not exist."); - return 0; - } - if (sysopt.greppath) free(sysopt.greppath); - sysopt.greppath = dupstr(bufp); + } else if (src == SET_IN_SYS && + match_varname(buf, "PANICTRACE_GDB", 14)) { + n = atoi(bufp); + if (n < 0 || n > 2) { + raw_printf("Illegal value in PANICTRACE_GDB (not 0,1,2)."); + return 0; + } + sysopt.panictrace_gdb = n; + } else if (src == SET_IN_SYS && match_varname(buf, "GDBPATH", 7)) { + if (!file_exists(bufp)) { + raw_printf("File specified in GDBPATH does not exist."); + return 0; + } + if (sysopt.gdbpath) free(sysopt.gdbpath); + sysopt.gdbpath = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "GREPPATH", 7)) { + if (!file_exists(bufp)) { + raw_printf("File specified in GREPPATH does not exist."); + return 0; + } + if (sysopt.greppath) free(sysopt.greppath); + sysopt.greppath = dupstr(bufp); # endif /* PANICTRACE */ #endif /* SYSCF */ - } else if (match_varname(buf, "BOULDER", 3)) { - (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE, - 1, "BOULDER"); + } else if (match_varname(buf, "BOULDER", 3)) { + (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE, + 1, "BOULDER"); } else if (match_varname(buf, "MENUCOLOR", 9)) { (void) add_menu_coloring(bufp); - } else if (match_varname(buf, "WARNINGS", 5)) { - (void) get_uchars(fp, buf, bufp, translate, FALSE, - WARNCOUNT, "WARNINGS"); - assign_warnings(translate); - } else if (match_varname(buf, "SYMBOLS", 4)) { - char *op, symbuf[BUFSZ]; - boolean morelines; - do { - morelines = FALSE; + } else if (match_varname(buf, "WARNINGS", 5)) { + (void) get_uchars(fp, buf, bufp, translate, FALSE, + WARNCOUNT, "WARNINGS"); + assign_warnings(translate); + } else if (match_varname(buf, "SYMBOLS", 4)) { + char *op, symbuf[BUFSZ]; + boolean morelines; + do { + morelines = FALSE; - /* strip leading and trailing white space */ - while (isspace(*bufp)) bufp++; - op = eos(bufp); - while (--op >= bufp && isspace(*op)) *op = '\0'; + /* strip leading and trailing white space */ + while (isspace(*bufp)) bufp++; + op = eos(bufp); + while (--op >= bufp && isspace(*op)) *op = '\0'; - /* check for line continuation (trailing '\') */ - op = eos(bufp); - if (--op >= bufp && *op == '\\') { - *op = '\0'; - morelines = TRUE; - /* strip trailing space now that '\' is gone */ - while (--op >= bufp && isspace(*op)) *op = '\0'; - } - /* parse here */ - parsesymbols(bufp); - if (morelines) - do { - *symbuf = '\0'; - if (!fgets(symbuf, BUFSZ, fp)) { - morelines = FALSE; - break; - } - bufp = symbuf; - } while (*bufp == '#'); - } while (morelines); - switch_symbols(TRUE); - } else if (match_varname(buf, "WIZKIT", 6)) { - (void) strncpy(wizkit, bufp, WIZKIT_MAX-1); + /* check for line continuation (trailing '\') */ + op = eos(bufp); + if (--op >= bufp && *op == '\\') { + *op = '\0'; + morelines = TRUE; + /* strip trailing space now that '\' is gone */ + while (--op >= bufp && isspace(*op)) *op = '\0'; + } + /* parse here */ + parsesymbols(bufp); + if (morelines) + do { + *symbuf = '\0'; + if (!fgets(symbuf, BUFSZ, fp)) { + morelines = FALSE; + break; + } + bufp = symbuf; + } while (*bufp == '#'); + } while (morelines); + switch_symbols(TRUE); + } else if (match_varname(buf, "WIZKIT", 6)) { + (void) strncpy(wizkit, bufp, WIZKIT_MAX-1); #ifdef AMIGA - } else if (match_varname(buf, "FONT", 4)) { - char *t; + } else if (match_varname(buf, "FONT", 4)) { + char *t; - if( t = strchr( buf+5, ':' ) ) - { - *t = 0; - amii_set_text_font( buf+5, atoi( t + 1 ) ); - *t = ':'; - } - } else if (match_varname(buf, "PATH", 4)) { - (void) strncpy(PATH, bufp, PATHLEN-1); - } else if (match_varname(buf, "DEPTH", 5)) { - extern int amii_numcolors; - int val = atoi( bufp ); - amii_numcolors = 1L << min( DEPTH, val ); + if( t = strchr( buf+5, ':' ) ) + { + *t = 0; + amii_set_text_font( buf+5, atoi( t + 1 ) ); + *t = ':'; + } + } else if (match_varname(buf, "PATH", 4)) { + (void) strncpy(PATH, bufp, PATHLEN-1); + } else if (match_varname(buf, "DEPTH", 5)) { + extern int amii_numcolors; + int val = atoi( bufp ); + amii_numcolors = 1L << min( DEPTH, val ); #if defined(SYSFLAGS) - } else if (match_varname(buf, "DRIPENS", 7)) { - int i, val; - char *t; - for (i = 0, t = strtok(bufp, ",/"); t != (char *)0; - i < 20 && (t = strtok((char*)0, ",/")), ++i) { - sscanf(t, "%d", &val ); - sysflags.amii_dripens[i] = val; - } + } else if (match_varname(buf, "DRIPENS", 7)) { + int i, val; + char *t; + for (i = 0, t = strtok(bufp, ",/"); t != (char *)0; + i < 20 && (t = strtok((char*)0, ",/")), ++i) { + sscanf(t, "%d", &val ); + sysflags.amii_dripens[i] = val; + } #endif - } else if (match_varname(buf, "SCREENMODE", 10 )) { - extern long amii_scrnmode; - if (!stricmp(bufp,"req")) - amii_scrnmode = 0xffffffff; /* Requester */ - else if( sscanf(bufp, "%x", &amii_scrnmode) != 1 ) - amii_scrnmode = 0; - } else if (match_varname(buf, "MSGPENS", 7)) { - extern int amii_msgAPen, amii_msgBPen; - char *t = strtok(bufp, ",/"); - if( t ) - { - sscanf(t, "%d", &amii_msgAPen); - if( t = strtok((char*)0, ",/") ) - sscanf(t, "%d", &amii_msgBPen); - } - } else if (match_varname(buf, "TEXTPENS", 8)) { - extern int amii_textAPen, amii_textBPen; - char *t = strtok(bufp, ",/"); - if( t ) - { - sscanf(t, "%d", &amii_textAPen); - if( t = strtok((char*)0, ",/") ) - sscanf(t, "%d", &amii_textBPen); - } - } else if (match_varname(buf, "MENUPENS", 8)) { - extern int amii_menuAPen, amii_menuBPen; - char *t = strtok(bufp, ",/"); - if( t ) - { - sscanf(t, "%d", &amii_menuAPen); - if( t = strtok((char*)0, ",/") ) - sscanf(t, "%d", &amii_menuBPen); - } - } else if (match_varname(buf, "STATUSPENS", 10)) { - extern int amii_statAPen, amii_statBPen; - char *t = strtok(bufp, ",/"); - if( t ) - { - sscanf(t, "%d", &amii_statAPen); - if( t = strtok((char*)0, ",/") ) - sscanf(t, "%d", &amii_statBPen); - } - } else if (match_varname(buf, "OTHERPENS", 9)) { - extern int amii_otherAPen, amii_otherBPen; - char *t = strtok(bufp, ",/"); - if( t ) - { - sscanf(t, "%d", &amii_otherAPen); - if( t = strtok((char*)0, ",/") ) - sscanf(t, "%d", &amii_otherBPen); - } - } else if (match_varname(buf, "PENS", 4)) { - extern unsigned short amii_init_map[ AMII_MAXCOLORS ]; - int i; - char *t; + } else if (match_varname(buf, "SCREENMODE", 10 )) { + extern long amii_scrnmode; + if (!stricmp(bufp,"req")) + amii_scrnmode = 0xffffffff; /* Requester */ + else if( sscanf(bufp, "%x", &amii_scrnmode) != 1 ) + amii_scrnmode = 0; + } else if (match_varname(buf, "MSGPENS", 7)) { + extern int amii_msgAPen, amii_msgBPen; + char *t = strtok(bufp, ",/"); + if( t ) + { + sscanf(t, "%d", &amii_msgAPen); + if( t = strtok((char*)0, ",/") ) + sscanf(t, "%d", &amii_msgBPen); + } + } else if (match_varname(buf, "TEXTPENS", 8)) { + extern int amii_textAPen, amii_textBPen; + char *t = strtok(bufp, ",/"); + if( t ) + { + sscanf(t, "%d", &amii_textAPen); + if( t = strtok((char*)0, ",/") ) + sscanf(t, "%d", &amii_textBPen); + } + } else if (match_varname(buf, "MENUPENS", 8)) { + extern int amii_menuAPen, amii_menuBPen; + char *t = strtok(bufp, ",/"); + if( t ) + { + sscanf(t, "%d", &amii_menuAPen); + if( t = strtok((char*)0, ",/") ) + sscanf(t, "%d", &amii_menuBPen); + } + } else if (match_varname(buf, "STATUSPENS", 10)) { + extern int amii_statAPen, amii_statBPen; + char *t = strtok(bufp, ",/"); + if( t ) + { + sscanf(t, "%d", &amii_statAPen); + if( t = strtok((char*)0, ",/") ) + sscanf(t, "%d", &amii_statBPen); + } + } else if (match_varname(buf, "OTHERPENS", 9)) { + extern int amii_otherAPen, amii_otherBPen; + char *t = strtok(bufp, ",/"); + if( t ) + { + sscanf(t, "%d", &amii_otherAPen); + if( t = strtok((char*)0, ",/") ) + sscanf(t, "%d", &amii_otherBPen); + } + } else if (match_varname(buf, "PENS", 4)) { + extern unsigned short amii_init_map[ AMII_MAXCOLORS ]; + int i; + char *t; - for (i = 0, t = strtok(bufp, ",/"); - i < AMII_MAXCOLORS && t != (char *)0; - t = strtok((char *)0, ",/"), ++i) - { - sscanf(t, "%hx", &amii_init_map[i]); - } - amii_setpens( amii_numcolors = i ); - } else if (match_varname(buf, "FGPENS", 6)) { - extern int foreg[ AMII_MAXCOLORS ]; - int i; - char *t; + for (i = 0, t = strtok(bufp, ",/"); + i < AMII_MAXCOLORS && t != (char *)0; + t = strtok((char *)0, ",/"), ++i) + { + sscanf(t, "%hx", &amii_init_map[i]); + } + amii_setpens( amii_numcolors = i ); + } else if (match_varname(buf, "FGPENS", 6)) { + extern int foreg[ AMII_MAXCOLORS ]; + int i; + char *t; - for (i = 0, t = strtok(bufp, ",/"); - i < AMII_MAXCOLORS && t != (char *)0; - t = strtok((char *)0, ",/"), ++i) - { - sscanf(t, "%d", &foreg[i]); - } - } else if (match_varname(buf, "BGPENS", 6)) { - extern int backg[ AMII_MAXCOLORS ]; - int i; - char *t; + for (i = 0, t = strtok(bufp, ",/"); + i < AMII_MAXCOLORS && t != (char *)0; + t = strtok((char *)0, ",/"), ++i) + { + sscanf(t, "%d", &foreg[i]); + } + } else if (match_varname(buf, "BGPENS", 6)) { + extern int backg[ AMII_MAXCOLORS ]; + int i; + char *t; - for (i = 0, t = strtok(bufp, ",/"); - i < AMII_MAXCOLORS && t != (char *)0; - t = strtok((char *)0, ",/"), ++i) - { - sscanf(t, "%d", &backg[i]); - } + for (i = 0, t = strtok(bufp, ",/"); + i < AMII_MAXCOLORS && t != (char *)0; + t = strtok((char *)0, ",/"), ++i) + { + sscanf(t, "%d", &backg[i]); + } #endif #ifdef USER_SOUNDS - } else if (match_varname(buf, "SOUNDDIR", 8)) { - sounddir = dupstr(bufp); - } else if (match_varname(buf, "SOUND", 5)) { - add_sound_mapping(bufp); + } else if (match_varname(buf, "SOUNDDIR", 8)) { + sounddir = dupstr(bufp); + } else if (match_varname(buf, "SOUND", 5)) { + add_sound_mapping(bufp); #endif #ifdef QT_GRAPHICS - /* These should move to wc_ options */ - } else if (match_varname(buf, "QT_TILEWIDTH", 12)) { - extern char *qt_tilewidth; - if (qt_tilewidth == NULL) - qt_tilewidth = dupstr(bufp); - } else if (match_varname(buf, "QT_TILEHEIGHT", 13)) { - extern char *qt_tileheight; - if (qt_tileheight == NULL) - qt_tileheight = dupstr(bufp); - } else if (match_varname(buf, "QT_FONTSIZE", 11)) { - extern char *qt_fontsize; - if (qt_fontsize == NULL) - qt_fontsize = dupstr(bufp); - } else if (match_varname(buf, "QT_COMPACT", 10)) { - extern int qt_compact_mode; - qt_compact_mode = atoi(bufp); + /* These should move to wc_ options */ + } else if (match_varname(buf, "QT_TILEWIDTH", 12)) { + extern char *qt_tilewidth; + if (qt_tilewidth == NULL) + qt_tilewidth = dupstr(bufp); + } else if (match_varname(buf, "QT_TILEHEIGHT", 13)) { + extern char *qt_tileheight; + if (qt_tileheight == NULL) + qt_tileheight = dupstr(bufp); + } else if (match_varname(buf, "QT_FONTSIZE", 11)) { + extern char *qt_fontsize; + if (qt_fontsize == NULL) + qt_fontsize = dupstr(bufp); + } else if (match_varname(buf, "QT_COMPACT", 10)) { + extern int qt_compact_mode; + qt_compact_mode = atoi(bufp); #endif - } else - return 0; - return 1; + } else + return 0; + return 1; } #ifdef USER_SOUNDS @@ -2483,7 +2485,7 @@ boolean can_read_file(filename) const char *filename; { - return (access(filename, 4) == 0); + return (access(filename, 4) == 0); } #endif /* USER_SOUNDS */ @@ -2492,16 +2494,16 @@ read_config_file(filename, src) const char *filename; int src; { - char buf[4*BUFSZ]; - FILE *fp; - boolean rv = TRUE; /* assume successful parse */ + char buf[4*BUFSZ]; + FILE *fp; + boolean rv = TRUE; /* assume successful parse */ - if (!(fp = fopen_config_file(filename, src))) return FALSE; + if (!(fp = fopen_config_file(filename, src))) return FALSE; - /* begin detection of duplicate configfile options */ - set_duplicate_opt_detection(1); + /* begin detection of duplicate configfile options */ + set_duplicate_opt_detection(1); - while (fgets(buf, sizeof buf, fp)) { + while (fgets(buf, sizeof buf, fp)) { #ifdef notyet /* XXX Don't call read() in parse_config_line, read as callback or reassemble line @@ -2509,87 +2511,87 @@ at this level. OR: Forbid multiline stuff for alternate config sources. */ #endif - if (!parse_config_line(fp, buf, src)) { - raw_printf("Bad option line: \"%.50s\"", buf); - wait_synch(); - rv = FALSE; - } - } - (void) fclose(fp); - - /* turn off detection of duplicate configfile options */ - set_duplicate_opt_detection(0); - return rv; + if (!parse_config_line(fp, buf, src)) { + raw_printf("Bad option line: \"%.50s\"", buf); + wait_synch(); + rv = FALSE; + } + } + (void) fclose(fp); + + /* turn off detection of duplicate configfile options */ + set_duplicate_opt_detection(0); + return rv; } STATIC_OVL FILE * fopen_wizkit_file() { - FILE *fp; + FILE *fp; #if defined(VMS) || defined(UNIX) - char tmp_wizkit[BUFSZ]; + char tmp_wizkit[BUFSZ]; #endif - char *envp; + char *envp; - envp = nh_getenv("WIZKIT"); - if (envp && *envp) (void) strncpy(wizkit, envp, WIZKIT_MAX - 1); - if (!wizkit[0]) return (FILE *)0; + envp = nh_getenv("WIZKIT"); + if (envp && *envp) (void) strncpy(wizkit, envp, WIZKIT_MAX - 1); + if (!wizkit[0]) return (FILE *)0; #ifdef UNIX - if (access(wizkit, 4) == -1) { - /* 4 is R_OK on newer systems */ - /* nasty sneaky attempt to read file through - * NetHack's setuid permissions -- this is a - * place a file name may be wholly under the player's - * control - */ - raw_printf("Access to %s denied (%d).", - wizkit, errno); - wait_synch(); - /* fall through to standard names */ - } else + if (access(wizkit, 4) == -1) { + /* 4 is R_OK on newer systems */ + /* nasty sneaky attempt to read file through + * NetHack's setuid permissions -- this is a + * place a file name may be wholly under the player's + * control + */ + raw_printf("Access to %s denied (%d).", + wizkit, errno); + wait_synch(); + /* fall through to standard names */ + } else #endif - if ((fp = fopenp(wizkit, "r")) != (FILE *)0) { - return(fp); + if ((fp = fopenp(wizkit, "r")) != (FILE *)0) { + return(fp); #if defined(UNIX) || defined(VMS) - } else { - /* access() above probably caught most problems for UNIX */ - raw_printf("Couldn't open requested config file %s (%d).", - wizkit, errno); - wait_synch(); + } else { + /* access() above probably caught most problems for UNIX */ + raw_printf("Couldn't open requested config file %s (%d).", + wizkit, errno); + wait_synch(); #endif - } + } #if defined(MICRO) || defined(MAC) || defined(__BEOS__) || defined(WIN32) - if ((fp = fopenp(fqname(wizkit, CONFIGPREFIX, 0), "r")) - != (FILE *)0) - return(fp); + if ((fp = fopenp(fqname(wizkit, CONFIGPREFIX, 0), "r")) + != (FILE *)0) + return(fp); #else # ifdef VMS - envp = nh_getenv("HOME"); - if (envp) - Sprintf(tmp_wizkit, "%s%s", envp, wizkit); - else - Sprintf(tmp_wizkit, "%s%s", "sys$login:", wizkit); - if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *)0) - return(fp); + envp = nh_getenv("HOME"); + if (envp) + Sprintf(tmp_wizkit, "%s%s", envp, wizkit); + else + Sprintf(tmp_wizkit, "%s%s", "sys$login:", wizkit); + if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *)0) + return(fp); # else /* should be only UNIX left */ - envp = nh_getenv("HOME"); - if (envp) - Sprintf(tmp_wizkit, "%s/%s", envp, wizkit); - else Strcpy(tmp_wizkit, wizkit); - if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *)0) - return(fp); - else if (errno != ENOENT) { - /* e.g., problems when setuid NetHack can't search home - * directory restricted to user */ - raw_printf("Couldn't open default wizkit file %s (%d).", - tmp_wizkit, errno); - wait_synch(); - } + envp = nh_getenv("HOME"); + if (envp) + Sprintf(tmp_wizkit, "%s/%s", envp, wizkit); + else Strcpy(tmp_wizkit, wizkit); + if ((fp = fopenp(tmp_wizkit, "r")) != (FILE *)0) + return(fp); + else if (errno != ENOENT) { + /* e.g., problems when setuid NetHack can't search home + * directory restricted to user */ + raw_printf("Couldn't open default wizkit file %s (%d).", + tmp_wizkit, errno); + wait_synch(); + } # endif #endif - return (FILE *)0; + return (FILE *)0; } /* add to hero's inventory if there's room, otherwise put item on floor */ @@ -2604,55 +2606,55 @@ struct obj *obj; if (Role_if(PM_PRIEST)) obj->bknown = 1; /* same criteria as lift_object()'s check for available inventory slot */ if (obj->oclass != COIN_CLASS && - inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) { - /* inventory overflow; can't just place & stack object since - hero isn't in position yet, so schedule for arrival later */ - add_to_migration(obj); - obj->ox = 0; /* index of main dungeon */ - obj->oy = 1; /* starting level number */ - obj->owornmask = (long)(MIGR_WITH_HERO | MIGR_NOBREAK|MIGR_NOSCATTER); + inv_cnt(FALSE) >= 52 && !merge_choice(invent, obj)) { + /* inventory overflow; can't just place & stack object since + hero isn't in position yet, so schedule for arrival later */ + add_to_migration(obj); + obj->ox = 0; /* index of main dungeon */ + obj->oy = 1; /* starting level number */ + obj->owornmask = (long)(MIGR_WITH_HERO | MIGR_NOBREAK|MIGR_NOSCATTER); } else { - (void)addinv(obj); + (void)addinv(obj); } } void read_wizkit() { - FILE *fp; - char *ep, buf[BUFSZ]; - struct obj *otmp; - boolean bad_items = FALSE, skip = FALSE; + FILE *fp; + char *ep, buf[BUFSZ]; + struct obj *otmp; + boolean bad_items = FALSE, skip = FALSE; - if (!wizard || !(fp = fopen_wizkit_file())) return; + if (!wizard || !(fp = fopen_wizkit_file())) return; - program_state.wizkit_wishing = 1; - while (fgets(buf, (int)(sizeof buf), fp)) { - ep = index(buf, '\n'); - if (skip) { /* in case previous line was too long */ - if (ep) skip = FALSE; /* found newline; next line is normal */ - } else { - if (!ep) skip = TRUE; /* newline missing; discard next fgets */ - else *ep = '\0'; /* remove newline */ + program_state.wizkit_wishing = 1; + while (fgets(buf, (int)(sizeof buf), fp)) { + ep = index(buf, '\n'); + if (skip) { /* in case previous line was too long */ + if (ep) skip = FALSE; /* found newline; next line is normal */ + } else { + if (!ep) skip = TRUE; /* newline missing; discard next fgets */ + else *ep = '\0'; /* remove newline */ - if (buf[0]) { - otmp = readobjnam(buf, (struct obj *)0); - if (otmp) { - if (otmp != &zeroobj) - wizkit_addinv(otmp); - } else { - /* .60 limits output line width to 79 chars */ - raw_printf("Bad wizkit item: \"%.60s\"", buf); - bad_items = TRUE; - } - } - } - } - program_state.wizkit_wishing = 0; - if (bad_items) - wait_synch(); - (void) fclose(fp); - return; + if (buf[0]) { + otmp = readobjnam(buf, (struct obj *)0); + if (otmp) { + if (otmp != &zeroobj) + wizkit_addinv(otmp); + } else { + /* .60 limits output line width to 79 chars */ + raw_printf("Bad wizkit item: \"%.60s\"", buf); + bad_items = TRUE; + } + } + } + } + program_state.wizkit_wishing = 0; + if (bad_items) + wait_synch(); + (void) fclose(fp); + return; } extern struct symsetentry *symset_list; /* options.c */ @@ -2666,10 +2668,10 @@ STATIC_OVL FILE * fopen_sym_file() { - FILE *fp; + FILE *fp; - fp = fopen_datafile(SYMBOLS, "r", HACKPREFIX); - return fp; + fp = fopen_datafile(SYMBOLS, "r", HACKPREFIX); + return fp; } /* @@ -2680,29 +2682,29 @@ int read_sym_file(which_set) int which_set; { - char buf[4*BUFSZ]; - FILE *fp; + char buf[4*BUFSZ]; + FILE *fp; - if (!(fp = fopen_sym_file())) return 0; + if (!(fp = fopen_sym_file())) return 0; - symset_count = 0; - chosen_symset_start = chosen_symset_end = FALSE; - while (fgets(buf, 4*BUFSZ, fp)) { - if (!parse_sym_line(buf, which_set)) { - raw_printf("Bad symbol line: \"%.50s\"", buf); - wait_synch(); - } - } - (void) fclose(fp); - if (!chosen_symset_end && !chosen_symset_start) - return (symset[which_set].name == 0) ? 1 : 0; - if (!chosen_symset_end) { - raw_printf("Missing finish for symset \"%s\"", - symset[which_set].name ? - symset[which_set].name : "unknown"); - wait_synch(); - } - return 1; + symset_count = 0; + chosen_symset_start = chosen_symset_end = FALSE; + while (fgets(buf, 4*BUFSZ, fp)) { + if (!parse_sym_line(buf, which_set)) { + raw_printf("Bad symbol line: \"%.50s\"", buf); + wait_synch(); + } + } + (void) fclose(fp); + if (!chosen_symset_end && !chosen_symset_start) + return (symset[which_set].name == 0) ? 1 : 0; + if (!chosen_symset_end) { + raw_printf("Missing finish for symset \"%s\"", + symset[which_set].name ? + symset[which_set].name : "unknown"); + wait_synch(); + } + return 1; } /* returns 0 on error */ @@ -2711,185 +2713,185 @@ parse_sym_line(buf, which_set) char *buf; int which_set; { - int val, i; - struct symparse *symp = (struct symparse *)0; - char *bufp, *commentp, *altp; + int val, i; + struct symparse *symp = (struct symparse *)0; + char *bufp, *commentp, *altp; - if (*buf == '#') - return 1; + if (*buf == '#') + return 1; - /* remove trailing comment(s) */ - commentp = eos(buf); - while (--commentp > buf) { - if (*commentp != '#') continue; - *commentp = '\0'; - } + /* remove trailing comment(s) */ + commentp = eos(buf); + while (--commentp > buf) { + if (*commentp != '#') continue; + *commentp = '\0'; + } - /* remove trailing whitespace */ - bufp = eos(buf); - while (--bufp > buf && isspace(*bufp)) - continue; + /* remove trailing whitespace */ + bufp = eos(buf); + while (--bufp > buf && isspace(*bufp)) + continue; - if (bufp <= buf) - return 1; /* skip all-blank lines */ - else - *(bufp + 1) = '\0'; /* terminate line */ + if (bufp <= buf) + return 1; /* skip all-blank lines */ + else + *(bufp + 1) = '\0'; /* terminate line */ - /* skip leading whitespace on option name */ - while (isspace(*buf)) ++buf; - - /* find the '=' or ':' */ - bufp = index(buf, '='); - altp = index(buf, ':'); - if (!bufp || (altp && altp < bufp)) bufp = altp; - if (!bufp) { - if (strncmpi(buf, "finish", 6) == 0) { - /* end current graphics set */ - if (chosen_symset_start) - chosen_symset_end = TRUE; - chosen_symset_start = FALSE; - return 1; - } - return 0; - } + /* skip leading whitespace on option name */ + while (isspace(*buf)) ++buf; + + /* find the '=' or ':' */ + bufp = index(buf, '='); + altp = index(buf, ':'); + if (!bufp || (altp && altp < bufp)) bufp = altp; + if (!bufp) { + if (strncmpi(buf, "finish", 6) == 0) { + /* end current graphics set */ + if (chosen_symset_start) + chosen_symset_end = TRUE; + chosen_symset_start = FALSE; + return 1; + } + return 0; + } - /* skip whitespace between '=' and value */ - do { ++bufp; } while (isspace(*bufp)); + /* skip whitespace between '=' and value */ + do { ++bufp; } while (isspace(*bufp)); - symp = match_sym(buf); - if (!symp) - return 0; + symp = match_sym(buf); + if (!symp) + return 0; - if (!symset[which_set].name) { - /* A null symset name indicates that we're just - building a pick-list of possible symset - values from the file, so only do that */ - if (symp->range == SYM_CONTROL) { - struct symsetentry *tmpsp; + if (!symset[which_set].name) { + /* A null symset name indicates that we're just + building a pick-list of possible symset + values from the file, so only do that */ + if (symp->range == SYM_CONTROL) { + struct symsetentry *tmpsp; switch (symp->idx) { case 0: - tmpsp = (struct symsetentry *)alloc(sizeof(struct symsetentry)); - tmpsp->next = (struct symsetentry *)0; - if (!symset_list) { - symset_list = tmpsp; - symset_count = 0; - } else { - symset_count++; - tmpsp->next = symset_list; - symset_list = tmpsp; - } - tmpsp->idx = symset_count; - tmpsp->name = dupstr(bufp); - tmpsp->desc = (char *)0; - tmpsp->nocolor = 0; - /* initialize restriction bits */ - tmpsp->primary = 0; - tmpsp->rogue = 0; - break; - case 2: - /* handler type identified */ - tmpsp = symset_list; /* most recent symset */ - tmpsp->handling = H_UNK; - i = 0; - while (known_handling[i]) { - if (!strcmpi(known_handling[i], bufp)) { - tmpsp->handling = i; - break; /* while loop */ - } - i++; - } - break; - case 3: /* description:something */ - tmpsp = symset_list; /* most recent symset */ - if (tmpsp && !tmpsp->desc) - tmpsp->desc = dupstr(bufp); - break; - case 5: - /* restrictions: xxxx*/ - tmpsp = symset_list; /* most recent symset */ + tmpsp = (struct symsetentry *)alloc(sizeof(struct symsetentry)); + tmpsp->next = (struct symsetentry *)0; + if (!symset_list) { + symset_list = tmpsp; + symset_count = 0; + } else { + symset_count++; + tmpsp->next = symset_list; + symset_list = tmpsp; + } + tmpsp->idx = symset_count; + tmpsp->name = dupstr(bufp); + tmpsp->desc = (char *)0; + tmpsp->nocolor = 0; + /* initialize restriction bits */ + tmpsp->primary = 0; + tmpsp->rogue = 0; + break; + case 2: + /* handler type identified */ + tmpsp = symset_list; /* most recent symset */ + tmpsp->handling = H_UNK; + i = 0; + while (known_handling[i]) { + if (!strcmpi(known_handling[i], bufp)) { + tmpsp->handling = i; + break; /* while loop */ + } + i++; + } + break; + case 3: /* description:something */ + tmpsp = symset_list; /* most recent symset */ + if (tmpsp && !tmpsp->desc) + tmpsp->desc = dupstr(bufp); + break; + case 5: + /* restrictions: xxxx*/ + tmpsp = symset_list; /* most recent symset */ for (i = 0; known_restrictions[i]; ++i) { - if (!strcmpi(known_restrictions[i], bufp)) { - switch(i) { - case 0: tmpsp->primary = 1; break; - case 1: tmpsp->rogue = 1; break; - } - break; /* while loop */ - } - } - break; - } - } - return 1; - } - if (symp->range) { - if (symp->range == SYM_CONTROL) { - switch(symp->idx) { - case 0: - /* start of symset */ - if (!strcmpi(bufp, symset[which_set].name)) { - /* matches desired one */ - chosen_symset_start = TRUE; - /* these init_*() functions clear symset fields too */ - if (which_set == ROGUESET) init_r_symbols(); + if (!strcmpi(known_restrictions[i], bufp)) { + switch(i) { + case 0: tmpsp->primary = 1; break; + case 1: tmpsp->rogue = 1; break; + } + break; /* while loop */ + } + } + break; + } + } + return 1; + } + if (symp->range) { + if (symp->range == SYM_CONTROL) { + switch(symp->idx) { + case 0: + /* start of symset */ + if (!strcmpi(bufp, symset[which_set].name)) { + /* matches desired one */ + chosen_symset_start = TRUE; + /* these init_*() functions clear symset fields too */ + if (which_set == ROGUESET) init_r_symbols(); else if (which_set == PRIMARY) init_l_symbols(); - } - break; - case 1: - /* finish symset */ - if (chosen_symset_start) - chosen_symset_end = TRUE; - chosen_symset_start = FALSE; - break; - case 2: - /* handler type identified */ - if (chosen_symset_start) - set_symhandling(bufp, which_set); - break; - /* case 3: (description) is ignored here */ - case 4: /* color:off */ - if (chosen_symset_start) { - if (bufp) { - if (!strcmpi(bufp, "true") || - !strcmpi(bufp, "yes") || - !strcmpi(bufp, "on")) - symset[which_set].nocolor = 0; - else if (!strcmpi(bufp, "false") || - !strcmpi(bufp, "no") || - !strcmpi(bufp, "off")) - symset[which_set].nocolor = 1; - } - } - break; - case 5: /* restrictions: xxxx*/ - if (chosen_symset_start) { - int n = 0; - while (known_restrictions[n]) { - if (!strcmpi(known_restrictions[n], bufp)) { - switch(n) { - case 0: symset[which_set].primary = 1; - break; - case 1: symset[which_set].rogue = 1; - break; - } - break; /* while loop */ - } - n++; - } - } - break; - } - } else { /* !SYM_CONTROL */ - val = sym_val(bufp); - if (chosen_symset_start) { - if (which_set == PRIMARY) { - update_l_symset(symp, val); - } else if (which_set == ROGUESET) { - update_r_symset(symp, val); - } - } - } - } - return 1; + } + break; + case 1: + /* finish symset */ + if (chosen_symset_start) + chosen_symset_end = TRUE; + chosen_symset_start = FALSE; + break; + case 2: + /* handler type identified */ + if (chosen_symset_start) + set_symhandling(bufp, which_set); + break; + /* case 3: (description) is ignored here */ + case 4: /* color:off */ + if (chosen_symset_start) { + if (bufp) { + if (!strcmpi(bufp, "true") || + !strcmpi(bufp, "yes") || + !strcmpi(bufp, "on")) + symset[which_set].nocolor = 0; + else if (!strcmpi(bufp, "false") || + !strcmpi(bufp, "no") || + !strcmpi(bufp, "off")) + symset[which_set].nocolor = 1; + } + } + break; + case 5: /* restrictions: xxxx*/ + if (chosen_symset_start) { + int n = 0; + while (known_restrictions[n]) { + if (!strcmpi(known_restrictions[n], bufp)) { + switch(n) { + case 0: symset[which_set].primary = 1; + break; + case 1: symset[which_set].rogue = 1; + break; + } + break; /* while loop */ + } + n++; + } + } + break; + } + } else { /* !SYM_CONTROL */ + val = sym_val(bufp); + if (chosen_symset_start) { + if (which_set == PRIMARY) { + update_l_symset(symp, val); + } else if (which_set == ROGUESET) { + update_r_symset(symp, val); + } + } + } + } + return 1; } STATIC_OVL void @@ -2897,16 +2899,16 @@ set_symhandling(handling, which_set) char *handling; int which_set; { - int i = 0; + int i = 0; - symset[which_set].handling = H_UNK; - while (known_handling[i]) { - if (!strcmpi(known_handling[i], handling)) { - symset[which_set].handling = i; - return; - } - i++; - } + symset[which_set].handling = H_UNK; + while (known_handling[i]) { + if (!strcmpi(known_handling[i], handling)) { + symset[which_set].handling = i; + return; + } + i++; + } } /* ---------- END CONFIG FILE HANDLING ----------- */ @@ -2928,73 +2930,73 @@ const char *dir UNUSED_if_not_OS2_CODEVIEW; #if defined(PRAGMA_UNUSED) && !defined(OS2_CODEVIEW) # pragma unused(dir) #endif - const char *fq_record; - int fd; + const char *fq_record; + int fd; #if defined(UNIX) || defined(VMS) - fq_record = fqname(RECORD, SCOREPREFIX, 0); - fd = open(fq_record, O_RDWR, 0); - if (fd >= 0) { + fq_record = fqname(RECORD, SCOREPREFIX, 0); + fd = open(fq_record, O_RDWR, 0); + if (fd >= 0) { # ifdef VMS /* must be stream-lf to use UPDATE_RECORD_IN_PLACE */ - if (!file_is_stmlf(fd)) { - raw_printf( - "Warning: scoreboard file %s is not in stream_lf format", - fq_record); - wait_synch(); - } + if (!file_is_stmlf(fd)) { + raw_printf( + "Warning: scoreboard file %s is not in stream_lf format", + fq_record); + wait_synch(); + } # endif (void) nhclose(fd); /* RECORD is accessible */ - } else if ((fd = open(fq_record, O_CREAT|O_RDWR, FCMASK)) >= 0) { + } else if ((fd = open(fq_record, O_CREAT|O_RDWR, FCMASK)) >= 0) { (void) nhclose(fd); /* RECORD newly created */ # if defined(VMS) && !defined(SECURE) - /* Re-protect RECORD with world:read+write+execute+delete access. */ - (void) chmod(fq_record, FCMASK | 007); + /* Re-protect RECORD with world:read+write+execute+delete access. */ + (void) chmod(fq_record, FCMASK | 007); # endif /* VMS && !SECURE */ - } else { - raw_printf("Warning: cannot write scoreboard file %s", fq_record); - wait_synch(); - } + } else { + raw_printf("Warning: cannot write scoreboard file %s", fq_record); + wait_synch(); + } #endif /* !UNIX && !VMS */ #if defined(MICRO) || defined(WIN32) - char tmp[PATHLEN]; + char tmp[PATHLEN]; # ifdef OS2_CODEVIEW /* explicit path on opening for OS/2 */ - /* how does this work when there isn't an explicit path or fopenp - * for later access to the file via fopen_datafile? ? */ - (void) strncpy(tmp, dir, PATHLEN - 1); - tmp[PATHLEN-1] = '\0'; - if ((strlen(tmp) + 1 + strlen(RECORD)) < (PATHLEN - 1)) { - append_slash(tmp); - Strcat(tmp, RECORD); - } - fq_record = tmp; + /* how does this work when there isn't an explicit path or fopenp + * for later access to the file via fopen_datafile? ? */ + (void) strncpy(tmp, dir, PATHLEN - 1); + tmp[PATHLEN-1] = '\0'; + if ((strlen(tmp) + 1 + strlen(RECORD)) < (PATHLEN - 1)) { + append_slash(tmp); + Strcat(tmp, RECORD); + } + fq_record = tmp; # else - Strcpy(tmp, RECORD); - fq_record = fqname(RECORD, SCOREPREFIX, 0); + Strcpy(tmp, RECORD); + fq_record = fqname(RECORD, SCOREPREFIX, 0); # endif - if ((fd = open(fq_record, O_RDWR)) < 0) { - /* try to create empty record */ + if ((fd = open(fq_record, O_RDWR)) < 0) { + /* try to create empty record */ # if defined(AZTEC_C) || defined(_DCC) || (defined(__GNUC__) && defined(__AMIGA__)) - /* Aztec doesn't use the third argument */ - /* DICE doesn't like it */ - if ((fd = open(fq_record, O_CREAT|O_RDWR)) < 0) { + /* Aztec doesn't use the third argument */ + /* DICE doesn't like it */ + if ((fd = open(fq_record, O_CREAT|O_RDWR)) < 0) { # else - if ((fd = open(fq_record, O_CREAT|O_RDWR, S_IREAD|S_IWRITE)) < 0) { + if ((fd = open(fq_record, O_CREAT|O_RDWR, S_IREAD|S_IWRITE)) < 0) { # endif - raw_printf("Warning: cannot write record %s", tmp); - wait_synch(); - } else + raw_printf("Warning: cannot write record %s", tmp); + wait_synch(); + } else (void) nhclose(fd); - } else /* open succeeded */ + } else /* open succeeded */ (void) nhclose(fd); #else /* MICRO || WIN32*/ # ifdef MAC - /* Create the "record" file, if necessary */ - fq_record = fqname(RECORD, SCOREPREFIX, 0); - fd = macopen (fq_record, O_RDWR | O_CREAT, TEXT_TYPE); - if (fd != -1) macclose (fd); + /* Create the "record" file, if necessary */ + fq_record = fqname(RECORD, SCOREPREFIX, 0); + fd = macopen (fq_record, O_RDWR | O_CREAT, TEXT_TYPE); + if (fd != -1) macclose (fd); # endif /* MAC */ #endif /* MICRO || WIN32*/ @@ -3011,28 +3013,28 @@ const char *type; /* panic, impossible, trickery */ const char *reason; /* explanation */ { #ifdef PANICLOG - FILE *lfile; - char buf[BUFSZ]; + FILE *lfile; + char buf[BUFSZ]; - if (!program_state.in_paniclog) { - program_state.in_paniclog = 1; - lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX); - if (lfile) { - time_t now = getnow(); - int uid = getuid(); - char playmode = wizard ? 'D' : discover ? 'X' : '-'; + if (!program_state.in_paniclog) { + program_state.in_paniclog = 1; + lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX); + if (lfile) { + time_t now = getnow(); + int uid = getuid(); + char playmode = wizard ? 'D' : discover ? 'X' : '-'; - (void) fprintf(lfile, "%s %08ld %06ld %d %c: %s %s\n", - version_string(buf), - yyyymmdd(now), hhmmss(now), - uid, playmode, - type, reason); - (void) fclose(lfile); - } - program_state.in_paniclog = 0; - } + (void) fprintf(lfile, "%s %08ld %06ld %d %c: %s %s\n", + version_string(buf), + yyyymmdd(now), hhmmss(now), + uid, playmode, + type, reason); + (void) fclose(lfile); + } + program_state.in_paniclog = 0; + } #endif /* PANICLOG */ - return; + return; } /* ---------- END PANIC/IMPOSSIBLE LOG ----------- */ @@ -3043,198 +3045,198 @@ const char *reason; /* explanation */ boolean recover_savefile() { - int gfd, lfd, sfd; - int lev, savelev, hpid, pltmpsiz; - xchar levc; - struct version_info version_data; - int processed[256]; - char savename[SAVESIZE], errbuf[BUFSZ]; - struct savefile_info sfi; - char tmpplbuf[PL_NSIZ]; + int gfd, lfd, sfd; + int lev, savelev, hpid, pltmpsiz; + xchar levc; + struct version_info version_data; + int processed[256]; + char savename[SAVESIZE], errbuf[BUFSZ]; + struct savefile_info sfi; + char tmpplbuf[PL_NSIZ]; - for (lev = 0; lev < 256; lev++) - processed[lev] = 0; + for (lev = 0; lev < 256; lev++) + processed[lev] = 0; - /* level 0 file contains: - * pid of creating process (ignored here) - * level number for current level of save file - * name of save file nethack would have created - * savefile info - * player name - * and game state - */ - gfd = open_levelfile(0, errbuf); - if (gfd < 0) { - raw_printf("%s\n", errbuf); - return FALSE; - } - if (read(gfd, (genericptr_t) &hpid, sizeof hpid) != sizeof hpid) { - raw_printf( + /* level 0 file contains: + * pid of creating process (ignored here) + * level number for current level of save file + * name of save file nethack would have created + * savefile info + * player name + * and game state + */ + gfd = open_levelfile(0, errbuf); + if (gfd < 0) { + raw_printf("%s\n", errbuf); + return FALSE; + } + if (read(gfd, (genericptr_t) &hpid, sizeof hpid) != sizeof hpid) { + raw_printf( "\nCheckpoint data incompletely written or subsequently clobbered. Recovery impossible."); (void)nhclose(gfd); - return FALSE; - } - if (read(gfd, (genericptr_t) &savelev, sizeof(savelev)) - != sizeof(savelev)) { - raw_printf("\nCheckpointing was not in effect for %s -- recovery impossible.\n", - lock); + return FALSE; + } + if (read(gfd, (genericptr_t) &savelev, sizeof(savelev)) + != sizeof(savelev)) { + raw_printf("\nCheckpointing was not in effect for %s -- recovery impossible.\n", + lock); (void)nhclose(gfd); - return FALSE; - } - if ((read(gfd, (genericptr_t) savename, sizeof savename) - != sizeof savename) || - (read(gfd, (genericptr_t) &version_data, sizeof version_data) - != sizeof version_data) || - (read(gfd, (genericptr_t) &sfi, sizeof sfi) - != sizeof sfi) || - (read(gfd, (genericptr_t) &pltmpsiz, sizeof pltmpsiz) - != sizeof pltmpsiz) || (pltmpsiz > PL_NSIZ) || - (read(gfd, (genericptr_t) &tmpplbuf, pltmpsiz) - != pltmpsiz)) { - raw_printf("\nError reading %s -- can't recover.\n", lock); + return FALSE; + } + if ((read(gfd, (genericptr_t) savename, sizeof savename) + != sizeof savename) || + (read(gfd, (genericptr_t) &version_data, sizeof version_data) + != sizeof version_data) || + (read(gfd, (genericptr_t) &sfi, sizeof sfi) + != sizeof sfi) || + (read(gfd, (genericptr_t) &pltmpsiz, sizeof pltmpsiz) + != sizeof pltmpsiz) || (pltmpsiz > PL_NSIZ) || + (read(gfd, (genericptr_t) &tmpplbuf, pltmpsiz) + != pltmpsiz)) { + raw_printf("\nError reading %s -- can't recover.\n", lock); (void)nhclose(gfd); - return FALSE; - } + return FALSE; + } - /* save file should contain: - * version info - * savefile info - * player name - * current level (including pets) - * (non-level-based) game state - * other levels - */ - set_savefile_name(TRUE); - sfd = create_savefile(); - if (sfd < 0) { - raw_printf("\nCannot recover savefile %s.\n", SAVEF); + /* save file should contain: + * version info + * savefile info + * player name + * current level (including pets) + * (non-level-based) game state + * other levels + */ + set_savefile_name(TRUE); + sfd = create_savefile(); + if (sfd < 0) { + raw_printf("\nCannot recover savefile %s.\n", SAVEF); (void)nhclose(gfd); - return FALSE; - } + return FALSE; + } - lfd = open_levelfile(savelev, errbuf); - if (lfd < 0) { - raw_printf("\n%s\n", errbuf); + lfd = open_levelfile(savelev, errbuf); + if (lfd < 0) { + raw_printf("\n%s\n", errbuf); (void)nhclose(gfd); (void)nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } - if (write(sfd, (genericptr_t) &version_data, sizeof version_data) - != sizeof version_data) { - raw_printf("\nError writing %s; recovery failed.", SAVEF); + if (write(sfd, (genericptr_t) &version_data, sizeof version_data) + != sizeof version_data) { + raw_printf("\nError writing %s; recovery failed.", SAVEF); (void)nhclose(gfd); (void)nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } - if (write(sfd, (genericptr_t) &sfi, sizeof sfi) - != sizeof sfi) { - raw_printf( - "\nError writing %s; recovery failed (savefile_info).\n", - SAVEF); + if (write(sfd, (genericptr_t) &sfi, sizeof sfi) + != sizeof sfi) { + raw_printf( + "\nError writing %s; recovery failed (savefile_info).\n", + SAVEF); (void)nhclose(gfd); (void)nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } - if (write(sfd, (genericptr_t) &pltmpsiz, sizeof pltmpsiz) - != sizeof pltmpsiz) { - raw_printf( - "Error writing %s; recovery failed (player name size).\n", - SAVEF); + if (write(sfd, (genericptr_t) &pltmpsiz, sizeof pltmpsiz) + != sizeof pltmpsiz) { + raw_printf( + "Error writing %s; recovery failed (player name size).\n", + SAVEF); (void)nhclose(gfd); (void)nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } - if (write(sfd, (genericptr_t) &tmpplbuf, pltmpsiz) - != pltmpsiz) { - raw_printf( - "Error writing %s; recovery failed (player name).\n", - SAVEF); + if (write(sfd, (genericptr_t) &tmpplbuf, pltmpsiz) + != pltmpsiz) { + raw_printf( + "Error writing %s; recovery failed (player name).\n", + SAVEF); (void)nhclose(gfd); (void)nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } - if (!copy_bytes(lfd, sfd)) { + if (!copy_bytes(lfd, sfd)) { (void) nhclose(lfd); (void) nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } (void)nhclose(lfd); - processed[savelev] = 1; + processed[savelev] = 1; - if (!copy_bytes(gfd, sfd)) { + if (!copy_bytes(gfd, sfd)) { (void) nhclose(lfd); (void) nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } (void)nhclose(gfd); - processed[0] = 1; + processed[0] = 1; - for (lev = 1; lev < 256; lev++) { - /* level numbers are kept in xchars in save.c, so the - * maximum level number (for the endlevel) must be < 256 - */ - if (lev != savelev) { - lfd = open_levelfile(lev, (char *)0); - if (lfd >= 0) { - /* any or all of these may not exist */ - levc = (xchar) lev; - write(sfd, (genericptr_t) &levc, sizeof(levc)); - if (!copy_bytes(lfd, sfd)) { + for (lev = 1; lev < 256; lev++) { + /* level numbers are kept in xchars in save.c, so the + * maximum level number (for the endlevel) must be < 256 + */ + if (lev != savelev) { + lfd = open_levelfile(lev, (char *)0); + if (lfd >= 0) { + /* any or all of these may not exist */ + levc = (xchar) lev; + write(sfd, (genericptr_t) &levc, sizeof(levc)); + if (!copy_bytes(lfd, sfd)) { (void) nhclose(lfd); (void) nhclose(sfd); - delete_savefile(); - return FALSE; - } + delete_savefile(); + return FALSE; + } (void)nhclose(lfd); - processed[lev] = 1; - } - } - } + processed[lev] = 1; + } + } + } (void)nhclose(sfd); #ifdef HOLD_LOCKFILE_OPEN - really_close(); + really_close(); #endif - /* - * We have a successful savefile! - * Only now do we erase the level files. - */ - for (lev = 0; lev < 256; lev++) { - if (processed[lev]) { - const char *fq_lock; - set_levelfile_name(lock, lev); - fq_lock = fqname(lock, LEVELPREFIX, 3); - (void) unlink(fq_lock); - } - } - return TRUE; + /* + * We have a successful savefile! + * Only now do we erase the level files. + */ + for (lev = 0; lev < 256; lev++) { + if (processed[lev]) { + const char *fq_lock; + set_levelfile_name(lock, lev); + fq_lock = fqname(lock, LEVELPREFIX, 3); + (void) unlink(fq_lock); + } + } + return TRUE; } boolean copy_bytes(ifd, ofd) int ifd, ofd; { - char buf[BUFSIZ]; - int nfrom, nto; + char buf[BUFSIZ]; + int nfrom, nto; - do { - nfrom = read(ifd, buf, BUFSIZ); - nto = write(ofd, buf, nfrom); - if (nto != nfrom) return FALSE; - } while (nfrom == BUFSIZ); - return TRUE; + do { + nfrom = read(ifd, buf, BUFSIZ); + nto = write(ofd, buf, nfrom); + if (nto != nfrom) return FALSE; + } while (nfrom == BUFSIZ); + return TRUE; } /* ---------- END INTERNAL RECOVER ----------- */ @@ -3246,17 +3248,17 @@ int ifd, ofd; # ifdef SYSCF_FILE void assure_syscf_file() { - /* All we really care about is the end result - can we read the file? - * So just check that directly. */ - int fd; - fd = open(SYSCF_FILE, O_RDONLY); - if(fd >= 0){ - /* readable */ - close(fd); - return; - } - raw_printf("Unable to open SYSCF_FILE.\n"); - exit(EXIT_FAILURE); + /* All we really care about is the end result - can we read the file? + * So just check that directly. */ + int fd; + fd = open(SYSCF_FILE, O_RDONLY); + if(fd >= 0){ + /* readable */ + close(fd); + return; + } + raw_printf("Unable to open SYSCF_FILE.\n"); + exit(EXIT_FAILURE); } # endif /* SYSCF_FILE */ @@ -3276,16 +3278,16 @@ const char *filename; if (!filename || !*filename) return FALSE; /* sanity precaution */ if (sysopt.env_dbgfl == 0) { - /* check once for DEBUGFILES in the environment; - if found, it supersedes the sysconf value - [note: getenv() rather than nh_getenv() since a long value - is valid and doesn't pose any sort of overflow risk here] */ - if ((p = getenv("DEBUGFILES")) != 0) { - if (sysopt.debugfiles) free(sysopt.debugfiles); - sysopt.debugfiles = dupstr(p); - sysopt.env_dbgfl = 1; - } else - sysopt.env_dbgfl = -1; + /* check once for DEBUGFILES in the environment; + if found, it supersedes the sysconf value + [note: getenv() rather than nh_getenv() since a long value + is valid and doesn't pose any sort of overflow risk here] */ + if ((p = getenv("DEBUGFILES")) != 0) { + if (sysopt.debugfiles) free(sysopt.debugfiles); + sysopt.debugfiles = dupstr(p); + sysopt.env_dbgfl = 1; + } else + sysopt.env_dbgfl = -1; } debugfiles = sysopt.debugfiles; @@ -3313,15 +3315,15 @@ const char *filename; * overkill for the intended usage.] */ if (pmatch(debugfiles, filename)) - return TRUE; + return TRUE; /* check whether filename is an element of the list */ if ((p = strstr(debugfiles, filename)) != 0) { - int l = (int)strlen(filename); + int l = (int)strlen(filename); - if ((p == debugfiles || p[-1] == ' ' || p[-1] == '/') - && (p[l] == ' ' || p[l] == '\0')) - return TRUE; + if ((p == debugfiles || p[-1] == ' ' || p[-1] == '/') + && (p[l] == ' ' || p[l] == '\0')) + return TRUE; } return FALSE; } diff --git a/src/hack.c b/src/hack.c index 5e14a3fab..ebf1ce891 100644 --- a/src/hack.c +++ b/src/hack.c @@ -69,26 +69,26 @@ const char *msg; boolean revived = FALSE; for(otmp = level.objects[x][y]; otmp; otmp = otmp2) { - otmp2 = otmp->nexthere; - if (otmp->otyp == CORPSE && - (is_rider(&mons[otmp->corpsenm]) || - otmp->corpsenm == PM_WIZARD_OF_YENDOR)) { - /* move any living monster already at that location */ - if((mtmp = m_at(x,y)) && enexto(&cc, x, y, mtmp->data)) - rloc_to(mtmp, cc.x, cc.y); - if(msg) Norep("%s", msg); - revived = revive_corpse(otmp); - } + otmp2 = otmp->nexthere; + if (otmp->otyp == CORPSE && + (is_rider(&mons[otmp->corpsenm]) || + otmp->corpsenm == PM_WIZARD_OF_YENDOR)) { + /* move any living monster already at that location */ + if((mtmp = m_at(x,y)) && enexto(&cc, x, y, mtmp->data)) + rloc_to(mtmp, cc.x, cc.y); + if(msg) Norep("%s", msg); + revived = revive_corpse(otmp); + } } /* this location might not be safe, if not, move revived monster */ if (revived) { - mtmp = m_at(x,y); - if (mtmp && !goodpos(x, y, mtmp, 0) && - enexto(&cc, x, y, mtmp->data)) { - rloc_to(mtmp, cc.x, cc.y); - } - /* else impossible? */ + mtmp = m_at(x,y); + if (mtmp && !goodpos(x, y, mtmp, 0) && + enexto(&cc, x, y, mtmp->data)) { + rloc_to(mtmp, cc.x, cc.y); + } + /* else impossible? */ } return (revived); @@ -104,226 +104,226 @@ moverock() sx = u.ux + u.dx, sy = u.uy + u.dy; /* boulder starting position */ while ((otmp = sobj_at(BOULDER, sx, sy)) != 0) { - /* make sure that this boulder is visible as the top object */ - if (otmp != level.objects[sx][sy]) movobj(otmp, sx, sy); + /* make sure that this boulder is visible as the top object */ + if (otmp != level.objects[sx][sy]) movobj(otmp, sx, sy); - rx = u.ux + 2 * u.dx; /* boulder destination position */ - ry = u.uy + 2 * u.dy; - nomul(0); - if (Levitation || Is_airlevel(&u.uz)) { - if (Blind) feel_location(sx, sy); - You("don't have enough leverage to push %s.", the(xname(otmp))); - /* Give them a chance to climb over it? */ - return -1; - } - if (verysmall(youmonst.data) && !u.usteed) { - if (Blind) feel_location(sx, sy); - pline("You're too small to push that %s.", xname(otmp)); - goto cannot_push; - } - if (isok(rx,ry) && !IS_ROCK(levl[rx][ry].typ) && - levl[rx][ry].typ != IRONBARS && - (!IS_DOOR(levl[rx][ry].typ) || !(u.dx && u.dy) || - doorless_door(rx, ry)) && - !sobj_at(BOULDER, rx, ry)) { - ttmp = t_at(rx, ry); - mtmp = m_at(rx, ry); + rx = u.ux + 2 * u.dx; /* boulder destination position */ + ry = u.uy + 2 * u.dy; + nomul(0); + if (Levitation || Is_airlevel(&u.uz)) { + if (Blind) feel_location(sx, sy); + You("don't have enough leverage to push %s.", the(xname(otmp))); + /* Give them a chance to climb over it? */ + return -1; + } + if (verysmall(youmonst.data) && !u.usteed) { + if (Blind) feel_location(sx, sy); + pline("You're too small to push that %s.", xname(otmp)); + goto cannot_push; + } + if (isok(rx,ry) && !IS_ROCK(levl[rx][ry].typ) && + levl[rx][ry].typ != IRONBARS && + (!IS_DOOR(levl[rx][ry].typ) || !(u.dx && u.dy) || + doorless_door(rx, ry)) && + !sobj_at(BOULDER, rx, ry)) { + ttmp = t_at(rx, ry); + mtmp = m_at(rx, ry); - /* KMH -- Sokoban doesn't let you push boulders diagonally */ - if (Sokoban && u.dx && u.dy) { - if (Blind) feel_location(sx,sy); - pline("%s won't roll diagonally on this %s.", - The(xname(otmp)), surface(sx, sy)); - goto cannot_push; - } + /* KMH -- Sokoban doesn't let you push boulders diagonally */ + if (Sokoban && u.dx && u.dy) { + if (Blind) feel_location(sx,sy); + pline("%s won't roll diagonally on this %s.", + The(xname(otmp)), surface(sx, sy)); + goto cannot_push; + } - if (revive_nasty(rx, ry, "You sense movement on the other side.")) - return (-1); + if (revive_nasty(rx, ry, "You sense movement on the other side.")) + return (-1); - if (mtmp && !noncorporeal(mtmp->data) && - (!mtmp->mtrapped || - !(ttmp && ((ttmp->ttyp == PIT) || - (ttmp->ttyp == SPIKED_PIT))))) { - if (Blind) feel_location(sx, sy); - if (canspotmon(mtmp)) - pline("There's %s on the other side.", a_monnam(mtmp)); - else { - You_hear("a monster behind %s.", the(xname(otmp))); - map_invisible(rx, ry); - } - if (flags.verbose) - pline("Perhaps that's why %s cannot move it.", - u.usteed ? y_monnam(u.usteed) : "you"); - goto cannot_push; - } + if (mtmp && !noncorporeal(mtmp->data) && + (!mtmp->mtrapped || + !(ttmp && ((ttmp->ttyp == PIT) || + (ttmp->ttyp == SPIKED_PIT))))) { + if (Blind) feel_location(sx, sy); + if (canspotmon(mtmp)) + pline("There's %s on the other side.", a_monnam(mtmp)); + else { + You_hear("a monster behind %s.", the(xname(otmp))); + map_invisible(rx, ry); + } + if (flags.verbose) + pline("Perhaps that's why %s cannot move it.", + u.usteed ? y_monnam(u.usteed) : "you"); + goto cannot_push; + } - if (ttmp) { - /* if a trap operates on the boulder, don't attempt - to move any others at this location; return -1 - if another boulder is in hero's way, or 0 if he - should advance to the vacated boulder position */ - switch(ttmp->ttyp) { - case LANDMINE: - if (rn2(10)) { - obj_extract_self(otmp); - place_object(otmp, rx, ry); - newsym(sx, sy); - pline("KAABLAMM!!! %s %s land mine.", - Tobjnam(otmp, "trigger"), - ttmp->madeby_u ? "your" : "a"); - blow_up_landmine(ttmp); - /* if the boulder remains, it should fill the pit */ - fill_pit(u.ux, u.uy); - if (cansee(rx,ry)) newsym(rx,ry); - return sobj_at(BOULDER, sx, sy) ? -1 : 0; - } - break; - case SPIKED_PIT: - case PIT: - obj_extract_self(otmp); - /* vision kludge to get messages right; - the pit will temporarily be seen even - if this is one among multiple boulders */ - if (!Blind) viz_array[ry][rx] |= IN_SIGHT; - if (!flooreffects(otmp, rx, ry, "fall")) { - place_object(otmp, rx, ry); - } - if (mtmp && !Blind) newsym(rx, ry); - return sobj_at(BOULDER, sx, sy) ? -1 : 0; - case HOLE: - case TRAPDOOR: - if (Blind) - pline("Kerplunk! You no longer feel %s.", - the(xname(otmp))); - else - pline("%s%s and %s a %s in the %s!", - Tobjnam(otmp, - (ttmp->ttyp == TRAPDOOR) ? "trigger" : "fall"), - (ttmp->ttyp == TRAPDOOR) ? "" : " into", - otense(otmp, "plug"), - (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole", - surface(rx, ry)); - deltrap(ttmp); - delobj(otmp); - bury_objs(rx, ry); - levl[rx][ry].wall_info &= ~W_NONDIGGABLE; - levl[rx][ry].candig = 1; - if (cansee(rx,ry)) newsym(rx,ry); - return sobj_at(BOULDER, sx, sy) ? -1 : 0; - case LEVEL_TELEP: - case TELEP_TRAP: - { - int newlev = 0; /* lint suppression */ - d_level dest; + if (ttmp) { + /* if a trap operates on the boulder, don't attempt + to move any others at this location; return -1 + if another boulder is in hero's way, or 0 if he + should advance to the vacated boulder position */ + switch(ttmp->ttyp) { + case LANDMINE: + if (rn2(10)) { + obj_extract_self(otmp); + place_object(otmp, rx, ry); + newsym(sx, sy); + pline("KAABLAMM!!! %s %s land mine.", + Tobjnam(otmp, "trigger"), + ttmp->madeby_u ? "your" : "a"); + blow_up_landmine(ttmp); + /* if the boulder remains, it should fill the pit */ + fill_pit(u.ux, u.uy); + if (cansee(rx,ry)) newsym(rx,ry); + return sobj_at(BOULDER, sx, sy) ? -1 : 0; + } + break; + case SPIKED_PIT: + case PIT: + obj_extract_self(otmp); + /* vision kludge to get messages right; + the pit will temporarily be seen even + if this is one among multiple boulders */ + if (!Blind) viz_array[ry][rx] |= IN_SIGHT; + if (!flooreffects(otmp, rx, ry, "fall")) { + place_object(otmp, rx, ry); + } + if (mtmp && !Blind) newsym(rx, ry); + return sobj_at(BOULDER, sx, sy) ? -1 : 0; + case HOLE: + case TRAPDOOR: + if (Blind) + pline("Kerplunk! You no longer feel %s.", + the(xname(otmp))); + else + pline("%s%s and %s a %s in the %s!", + Tobjnam(otmp, + (ttmp->ttyp == TRAPDOOR) ? "trigger" : "fall"), + (ttmp->ttyp == TRAPDOOR) ? "" : " into", + otense(otmp, "plug"), + (ttmp->ttyp == TRAPDOOR) ? "trap door" : "hole", + surface(rx, ry)); + deltrap(ttmp); + delobj(otmp); + bury_objs(rx, ry); + levl[rx][ry].wall_info &= ~W_NONDIGGABLE; + levl[rx][ry].candig = 1; + if (cansee(rx,ry)) newsym(rx,ry); + return sobj_at(BOULDER, sx, sy) ? -1 : 0; + case LEVEL_TELEP: + case TELEP_TRAP: + { + int newlev = 0; /* lint suppression */ + d_level dest; - if (ttmp->ttyp == LEVEL_TELEP) { - newlev = random_teleport_level(); - if (newlev == depth(&u.uz) || In_endgame(&u.uz)) - /* trap didn't work; skip "disappears" message */ - goto dopush; - } - if (u.usteed) + if (ttmp->ttyp == LEVEL_TELEP) { + newlev = random_teleport_level(); + if (newlev == depth(&u.uz) || In_endgame(&u.uz)) + /* trap didn't work; skip "disappears" message */ + goto dopush; + } + if (u.usteed) pline("%s pushes %s and suddenly it disappears!", - upstart(y_monnam(u.usteed)), the(xname(otmp))); - else + upstart(y_monnam(u.usteed)), the(xname(otmp))); + else You("push %s and suddenly it disappears!", - the(xname(otmp))); - if (ttmp->ttyp == TELEP_TRAP) { - (void)rloco(otmp); - } else { - obj_extract_self(otmp); - add_to_migration(otmp); - get_level(&dest, newlev); - otmp->ox = dest.dnum; - otmp->oy = dest.dlevel; - otmp->owornmask = (long)MIGR_RANDOM; - } - seetrap(ttmp); - return sobj_at(BOULDER, sx, sy) ? -1 : 0; - } - default: - break; /* boulder not affected by this trap */ - } - } + the(xname(otmp))); + if (ttmp->ttyp == TELEP_TRAP) { + (void)rloco(otmp); + } else { + obj_extract_self(otmp); + add_to_migration(otmp); + get_level(&dest, newlev); + otmp->ox = dest.dnum; + otmp->oy = dest.dlevel; + otmp->owornmask = (long)MIGR_RANDOM; + } + seetrap(ttmp); + return sobj_at(BOULDER, sx, sy) ? -1 : 0; + } + default: + break; /* boulder not affected by this trap */ + } + } - if (closed_door(rx, ry)) - goto nopushmsg; - if (boulder_hits_pool(otmp, rx, ry, TRUE)) - continue; - /* - * Re-link at top of fobj chain so that pile order is preserved - * when level is restored. - */ - if (otmp != fobj) { - remove_object(otmp); - place_object(otmp, otmp->ox, otmp->oy); - } + if (closed_door(rx, ry)) + goto nopushmsg; + if (boulder_hits_pool(otmp, rx, ry, TRUE)) + continue; + /* + * Re-link at top of fobj chain so that pile order is preserved + * when level is restored. + */ + if (otmp != fobj) { + remove_object(otmp); + place_object(otmp, otmp->ox, otmp->oy); + } - { + { #ifdef LINT /* static long lastmovetime; */ - long lastmovetime; - lastmovetime = 0; + long lastmovetime; + lastmovetime = 0; #else - /* note: reset to zero after save/restore cycle */ - static NEARDATA long lastmovetime; + /* note: reset to zero after save/restore cycle */ + static NEARDATA long lastmovetime; #endif dopush: - if (!u.usteed) { - if (moves > lastmovetime+2 || moves < lastmovetime) - pline("With %s effort you move %s.", - throws_rocks(youmonst.data) ? "little" : "great", - the(xname(otmp))); - exercise(A_STR, TRUE); - } else - pline("%s moves %s.", - upstart(y_monnam(u.usteed)), the(xname(otmp))); - lastmovetime = moves; - } + if (!u.usteed) { + if (moves > lastmovetime+2 || moves < lastmovetime) + pline("With %s effort you move %s.", + throws_rocks(youmonst.data) ? "little" : "great", + the(xname(otmp))); + exercise(A_STR, TRUE); + } else + pline("%s moves %s.", + upstart(y_monnam(u.usteed)), the(xname(otmp))); + lastmovetime = moves; + } - /* Move the boulder *after* the message. */ - if (glyph_is_invisible(levl[rx][ry].glyph)) - unmap_object(rx, ry); - movobj(otmp, rx, ry); /* does newsym(rx,ry) */ - if (Blind) { - feel_location(rx,ry); - feel_location(sx, sy); - } else { - newsym(sx, sy); - } - } else { + /* Move the boulder *after* the message. */ + if (glyph_is_invisible(levl[rx][ry].glyph)) + unmap_object(rx, ry); + movobj(otmp, rx, ry); /* does newsym(rx,ry) */ + if (Blind) { + feel_location(rx,ry); + feel_location(sx, sy); + } else { + newsym(sx, sy); + } + } else { nopushmsg: - if (u.usteed) - pline("%s tries to move %s, but cannot.", - upstart(y_monnam(u.usteed)), the(xname(otmp))); - else - You("try to move %s, but in vain.", the(xname(otmp))); - if (Blind) feel_location(sx, sy); + if (u.usteed) + pline("%s tries to move %s, but cannot.", + upstart(y_monnam(u.usteed)), the(xname(otmp))); + else + You("try to move %s, but in vain.", the(xname(otmp))); + if (Blind) feel_location(sx, sy); cannot_push: - if (throws_rocks(youmonst.data)) { - if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) { - You("aren't skilled enough to %s %s from %s.", - (flags.pickup && !Sokoban) ? "pick up" : "push aside", - the(xname(otmp)), y_monnam(u.usteed)); - } else { - pline("However, you can easily %s.", - (flags.pickup && !Sokoban) ? - "pick it up" : "push it aside"); - sokoban_guilt(); - break; - } - break; - } + if (throws_rocks(youmonst.data)) { + if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) { + You("aren't skilled enough to %s %s from %s.", + (flags.pickup && !Sokoban) ? "pick up" : "push aside", + the(xname(otmp)), y_monnam(u.usteed)); + } else { + pline("However, you can easily %s.", + (flags.pickup && !Sokoban) ? + "pick it up" : "push it aside"); + sokoban_guilt(); + break; + } + break; + } - if (!u.usteed && (((!invent || inv_weight() <= -850) && - (!u.dx || !u.dy || (IS_ROCK(levl[u.ux][sy].typ) - && IS_ROCK(levl[sx][u.uy].typ)))) - || verysmall(youmonst.data))) { - pline("However, you can squeeze yourself into a small opening."); - sokoban_guilt(); - break; - } else - return (-1); - } + if (!u.usteed && (((!invent || inv_weight() <= -850) && + (!u.dx || !u.dy || (IS_ROCK(levl[u.ux][sy].typ) + && IS_ROCK(levl[sx][u.uy].typ)))) + || verysmall(youmonst.data))) { + pline("However, you can squeeze yourself into a small opening."); + sokoban_guilt(); + break; + } else + return (-1); + } } return (0); } @@ -343,40 +343,40 @@ still_chewing(x,y) const char *digtxt = (char *)0, *dmgtxt = (char *)0; if (context.digging.down) /* not continuing previous dig (w/ pick-axe) */ - (void) memset((genericptr_t)&context.digging, 0, sizeof(struct dig_info)); + (void) memset((genericptr_t)&context.digging, 0, sizeof(struct dig_info)); if (!boulder && IS_ROCK(lev->typ) && !may_dig(x,y)) { - You("hurt your teeth on the %s.", - IS_TREE(lev->typ) ? "tree" : "hard stone"); - nomul(0); - return 1; + You("hurt your teeth on the %s.", + IS_TREE(lev->typ) ? "tree" : "hard stone"); + nomul(0); + return 1; } else if (context.digging.pos.x != x || context.digging.pos.y != y || - !on_level(&context.digging.level, &u.uz)) { - context.digging.down = FALSE; - context.digging.chew = TRUE; - context.digging.warned = FALSE; - context.digging.pos.x = x; - context.digging.pos.y = y; - assign_level(&context.digging.level, &u.uz); - /* solid rock takes more work & time to dig through */ - context.digging.effort = - (IS_ROCK(lev->typ) && !IS_TREE(lev->typ) ? 30 : 60) + u.udaminc; - You("start chewing %s %s.", - (boulder || IS_TREE(lev->typ)) ? "on a" : "a hole in the", - boulder ? "boulder" : - IS_TREE(lev->typ) ? "tree" : IS_ROCK(lev->typ) ? "rock" : "door"); - watch_dig((struct monst *)0, x, y, FALSE); - return 1; + !on_level(&context.digging.level, &u.uz)) { + context.digging.down = FALSE; + context.digging.chew = TRUE; + context.digging.warned = FALSE; + context.digging.pos.x = x; + context.digging.pos.y = y; + assign_level(&context.digging.level, &u.uz); + /* solid rock takes more work & time to dig through */ + context.digging.effort = + (IS_ROCK(lev->typ) && !IS_TREE(lev->typ) ? 30 : 60) + u.udaminc; + You("start chewing %s %s.", + (boulder || IS_TREE(lev->typ)) ? "on a" : "a hole in the", + boulder ? "boulder" : + IS_TREE(lev->typ) ? "tree" : IS_ROCK(lev->typ) ? "rock" : "door"); + watch_dig((struct monst *)0, x, y, FALSE); + return 1; } else if ((context.digging.effort += (30 + u.udaminc)) <= 100) { - if (flags.verbose) - You("%s chewing on the %s.", - context.digging.chew ? "continue" : "begin", - boulder ? "boulder" : - IS_TREE(lev->typ) ? "tree" : - IS_ROCK(lev->typ) ? "rock" : "door"); - context.digging.chew = TRUE; - watch_dig((struct monst *)0, x, y, FALSE); - return 1; + if (flags.verbose) + You("%s chewing on the %s.", + context.digging.chew ? "continue" : "begin", + boulder ? "boulder" : + IS_TREE(lev->typ) ? "tree" : + IS_ROCK(lev->typ) ? "rock" : "door"); + context.digging.chew = TRUE; + watch_dig((struct monst *)0, x, y, FALSE); + return 1; } /* Okay, you've chewed through something */ @@ -384,66 +384,66 @@ still_chewing(x,y) u.uhunger += rnd(20); if (boulder) { - delobj(boulder); /* boulder goes bye-bye */ - You("eat the boulder."); /* yum */ + delobj(boulder); /* boulder goes bye-bye */ + You("eat the boulder."); /* yum */ - /* - * The location could still block because of - * 1. More than one boulder - * 2. Boulder stuck in a wall/stone/door. - * - * [perhaps use does_block() below (from vision.c)] - */ - if (IS_ROCK(lev->typ) || closed_door(x,y) || sobj_at(BOULDER,x,y)) { - block_point(x,y); /* delobj will unblock the point */ - /* reset dig state */ - (void) memset((genericptr_t)&context.digging, 0, sizeof(struct dig_info)); - return 1; - } + /* + * The location could still block because of + * 1. More than one boulder + * 2. Boulder stuck in a wall/stone/door. + * + * [perhaps use does_block() below (from vision.c)] + */ + if (IS_ROCK(lev->typ) || closed_door(x,y) || sobj_at(BOULDER,x,y)) { + block_point(x,y); /* delobj will unblock the point */ + /* reset dig state */ + (void) memset((genericptr_t)&context.digging, 0, sizeof(struct dig_info)); + return 1; + } } else if (IS_WALL(lev->typ)) { - if (*in_rooms(x, y, SHOPBASE)) { - add_damage(x, y, 10L * ACURRSTR); - dmgtxt = "damage"; - } - digtxt = "chew a hole in the wall."; - if (level.flags.is_maze_lev) { - lev->typ = ROOM; - } else if (level.flags.is_cavernous_lev && !in_town(x, y)) { - lev->typ = CORR; - } else { - lev->typ = DOOR; - lev->doormask = D_NODOOR; - } + if (*in_rooms(x, y, SHOPBASE)) { + add_damage(x, y, 10L * ACURRSTR); + dmgtxt = "damage"; + } + digtxt = "chew a hole in the wall."; + if (level.flags.is_maze_lev) { + lev->typ = ROOM; + } else if (level.flags.is_cavernous_lev && !in_town(x, y)) { + lev->typ = CORR; + } else { + lev->typ = DOOR; + lev->doormask = D_NODOOR; + } } else if (IS_TREE(lev->typ)) { - digtxt = "chew through the tree."; - lev->typ = ROOM; + digtxt = "chew through the tree."; + lev->typ = ROOM; } else if (lev->typ == SDOOR) { - if (lev->doormask & D_TRAPPED) { - lev->doormask = D_NODOOR; - b_trapped("secret door", 0); - } else { - digtxt = "chew through the secret door."; - lev->doormask = D_BROKEN; - } - lev->typ = DOOR; + if (lev->doormask & D_TRAPPED) { + lev->doormask = D_NODOOR; + b_trapped("secret door", 0); + } else { + digtxt = "chew through the secret door."; + lev->doormask = D_BROKEN; + } + lev->typ = DOOR; } else if (IS_DOOR(lev->typ)) { - if (*in_rooms(x, y, SHOPBASE)) { - add_damage(x, y, 400L); - dmgtxt = "break"; - } - if (lev->doormask & D_TRAPPED) { - lev->doormask = D_NODOOR; - b_trapped("door", 0); - } else { - digtxt = "chew through the door."; - lev->doormask = D_BROKEN; - } + if (*in_rooms(x, y, SHOPBASE)) { + add_damage(x, y, 400L); + dmgtxt = "break"; + } + if (lev->doormask & D_TRAPPED) { + lev->doormask = D_NODOOR; + b_trapped("door", 0); + } else { + digtxt = "chew through the door."; + lev->doormask = D_BROKEN; + } } else { /* STONE or SCORR */ - digtxt = "chew a passage through the rock."; - lev->typ = CORR; + digtxt = "chew a passage through the rock."; + lev->typ = CORR; } unblock_point(x, y); /* vision */ @@ -459,11 +459,11 @@ movobj(obj, ox, oy) register struct obj *obj; register xchar ox, oy; { - /* optimize by leaving on the fobj chain? */ - remove_object(obj); - newsym(obj->ox, obj->oy); - place_object(obj, ox, oy); - newsym(ox, oy); + /* optimize by leaving on the fobj chain? */ + remove_object(obj); + newsym(obj->ox, obj->oy); + place_object(obj, ox, oy); + newsym(ox, oy); } static NEARDATA const char fell_on_sink[] = "fell onto a sink"; @@ -471,80 +471,80 @@ static NEARDATA const char fell_on_sink[] = "fell onto a sink"; STATIC_OVL void dosinkfall() { - register struct obj *obj; - int dmg; - boolean lev_boots = (uarmf && uarmf->otyp == LEVITATION_BOOTS), - innate_lev = ((HLevitation & (FROMOUTSIDE|FROMFORM)) != 0L), - ufall = (!innate_lev && !(HFlying || EFlying)); /* BFlying */ + register struct obj *obj; + int dmg; + boolean lev_boots = (uarmf && uarmf->otyp == LEVITATION_BOOTS), + innate_lev = ((HLevitation & (FROMOUTSIDE|FROMFORM)) != 0L), + ufall = (!innate_lev && !(HFlying || EFlying)); /* BFlying */ - if (!ufall) { - You(innate_lev ? "wobble unsteadily for a moment." : - "gain control of your flight."); - } else { - long save_ELev = ELevitation, save_HLev = HLevitation; + if (!ufall) { + You(innate_lev ? "wobble unsteadily for a moment." : + "gain control of your flight."); + } else { + long save_ELev = ELevitation, save_HLev = HLevitation; - /* fake removal of levitation in advance so that final - disclosure will be right in case this turns out to - be fatal; fortunately the fact that rings and boots - are really still worn has no effect on bones data */ - ELevitation = HLevitation = 0L; - You("crash to the floor!"); - dmg = rn1(8, 25 - (int)ACURR(A_CON)); - losehp(Maybe_Half_Phys(dmg), - fell_on_sink, NO_KILLER_PREFIX); - exercise(A_DEX, FALSE); - selftouch("Falling, you"); - for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) - if (obj->oclass == WEAPON_CLASS || is_weptool(obj)) { - You("fell on %s.", doname(obj)); - losehp(Maybe_Half_Phys(rnd(3)), fell_on_sink, NO_KILLER_PREFIX); - exercise(A_CON, FALSE); - } - ELevitation = save_ELev; - HLevitation = save_HLev; - } + /* fake removal of levitation in advance so that final + disclosure will be right in case this turns out to + be fatal; fortunately the fact that rings and boots + are really still worn has no effect on bones data */ + ELevitation = HLevitation = 0L; + You("crash to the floor!"); + dmg = rn1(8, 25 - (int)ACURR(A_CON)); + losehp(Maybe_Half_Phys(dmg), + fell_on_sink, NO_KILLER_PREFIX); + exercise(A_DEX, FALSE); + selftouch("Falling, you"); + for (obj = level.objects[u.ux][u.uy]; obj; obj = obj->nexthere) + if (obj->oclass == WEAPON_CLASS || is_weptool(obj)) { + You("fell on %s.", doname(obj)); + losehp(Maybe_Half_Phys(rnd(3)), fell_on_sink, NO_KILLER_PREFIX); + exercise(A_CON, FALSE); + } + ELevitation = save_ELev; + HLevitation = save_HLev; + } - /* - * Interrupt multi-turn putting on/taking off of armor (in which - * case we reached the sink due to being teleported while busy; - * in 3.4.3, Boots_on()/Boots_off() [called via (*aftermv)() when - * 'multi' reaches 0] triggered a crash if we were donning/doffing - * levitation boots [because the Boots_off() below causes 'uarmf' - * to be null by the time 'aftermv' gets called]). - * - * Interrupt donning/doffing if we fall onto the sink, or if the - * code below is going to remove levitation boots even when we - * haven't fallen (innate floating or flying becoming unblocked). - */ - if (ufall || lev_boots) { - (void) stop_donning(lev_boots ? uarmf : (struct obj *)0); - /* recalculate in case uarmf just got set to null */ - lev_boots = (uarmf && uarmf->otyp == LEVITATION_BOOTS); - } + /* + * Interrupt multi-turn putting on/taking off of armor (in which + * case we reached the sink due to being teleported while busy; + * in 3.4.3, Boots_on()/Boots_off() [called via (*aftermv)() when + * 'multi' reaches 0] triggered a crash if we were donning/doffing + * levitation boots [because the Boots_off() below causes 'uarmf' + * to be null by the time 'aftermv' gets called]). + * + * Interrupt donning/doffing if we fall onto the sink, or if the + * code below is going to remove levitation boots even when we + * haven't fallen (innate floating or flying becoming unblocked). + */ + if (ufall || lev_boots) { + (void) stop_donning(lev_boots ? uarmf : (struct obj *)0); + /* recalculate in case uarmf just got set to null */ + lev_boots = (uarmf && uarmf->otyp == LEVITATION_BOOTS); + } - /* remove worn levitation items */ - ELevitation &= ~W_ARTI; - HLevitation &= ~(I_SPECIAL|TIMEOUT); - HLevitation++; - if(uleft && uleft->otyp == RIN_LEVITATION) { - obj = uleft; - Ring_off(obj); - off_msg(obj); - } - if(uright && uright->otyp == RIN_LEVITATION) { - obj = uright; - Ring_off(obj); - off_msg(obj); - } - if (lev_boots) { - obj = uarmf; - (void)Boots_off(); - off_msg(obj); - } - HLevitation--; - /* probably moot; we're either still levitating or went - through float_down(), but make sure BFlying is up to date */ - float_vs_flight(); + /* remove worn levitation items */ + ELevitation &= ~W_ARTI; + HLevitation &= ~(I_SPECIAL|TIMEOUT); + HLevitation++; + if(uleft && uleft->otyp == RIN_LEVITATION) { + obj = uleft; + Ring_off(obj); + off_msg(obj); + } + if(uright && uright->otyp == RIN_LEVITATION) { + obj = uright; + Ring_off(obj); + off_msg(obj); + } + if (lev_boots) { + obj = uarmf; + (void)Boots_off(); + off_msg(obj); + } + HLevitation--; + /* probably moot; we're either still levitating or went + through float_down(), but make sure BFlying is up to date */ + float_vs_flight(); } boolean @@ -553,7 +553,7 @@ register xchar x,y; /* intended to be called only on ROCKs */ { return (boolean)(!(IS_STWALL(levl[x][y].typ) && - (levl[x][y].wall_info & W_NONDIGGABLE))); + (levl[x][y].wall_info & W_NONDIGGABLE))); } boolean @@ -561,7 +561,7 @@ may_passwall(x,y) register xchar x,y; { return (boolean)(!(IS_STWALL(levl[x][y].typ) && - (levl[x][y].wall_info & W_NONPASSWALL))); + (levl[x][y].wall_info & W_NONPASSWALL))); } boolean @@ -569,10 +569,10 @@ bad_rock(mdat,x,y) struct permonst *mdat; register xchar x,y; { - return((boolean) ((Sokoban && sobj_at(BOULDER,x,y)) || - (IS_ROCK(levl[x][y].typ) - && (!tunnels(mdat) || needspick(mdat) || !may_dig(x,y)) - && !(passes_walls(mdat) && may_passwall(x,y))))); + return((boolean) ((Sokoban && sobj_at(BOULDER,x,y)) || + (IS_ROCK(levl[x][y].typ) + && (!tunnels(mdat) || needspick(mdat) || !may_dig(x,y)) + && !(passes_walls(mdat) && may_passwall(x,y))))); } /* caller has already decided that it's a tight diagonal; check whether a @@ -587,12 +587,12 @@ struct monst *mon; /* too big? */ if (bigmonst(ptr) && - !(amorphous(ptr) || is_whirly(ptr) || - noncorporeal(ptr) || slithy(ptr) || can_fog(mon))) return 1; + !(amorphous(ptr) || is_whirly(ptr) || + noncorporeal(ptr) || slithy(ptr) || can_fog(mon))) return 1; /* lugging too much junk? */ amt = (mon == &youmonst) ? inv_weight() + weight_cap() : - curr_mon_load(mon); + curr_mon_load(mon); if (amt > 600) return 2; /* Sokoban restriction applies to hero only */ @@ -606,7 +606,7 @@ boolean invocation_pos(x, y) xchar x, y; { - return((boolean)(Invocation_lev(&u.uz) && x == inv_pos.x && y == inv_pos.y)); + return((boolean)(Invocation_lev(&u.uz) && x == inv_pos.x && y == inv_pos.y)); } /* return TRUE if (dx,dy) is an OK place to move @@ -626,142 +626,142 @@ int mode; * Check for physical obstacles. First, the place we are going. */ if (IS_ROCK(tmpr->typ) || tmpr->typ == IRONBARS) { - if (Blind && mode == DO_MOVE) feel_location(x,y); - if (Passes_walls && may_passwall(x,y)) { - ; /* do nothing */ - } else if (tmpr->typ == IRONBARS) { + if (Blind && mode == DO_MOVE) feel_location(x,y); + if (Passes_walls && may_passwall(x,y)) { + ; /* do nothing */ + } else if (tmpr->typ == IRONBARS) { if (!(Passes_walls || passes_bars(youmonst.data))) { if (iflags.mention_walls) You("cannot pass through the bars."); - return FALSE; + return FALSE; } - } else if (tunnels(youmonst.data) && !needspick(youmonst.data)) { - /* Eat the rock. */ - if (mode == DO_MOVE && still_chewing(x,y)) return FALSE; - } else if (flags.autodig && !context.run && !context.nopick && - uwep && is_pick(uwep)) { - /* MRKR: Automatic digging when wielding the appropriate tool */ - if (mode == DO_MOVE) - (void) use_pick_axe2(uwep); - return FALSE; - } else { - if (mode == DO_MOVE) { - if (Is_stronghold(&u.uz) && is_db_wall(x,y)) - pline_The("drawbridge is up!"); - /* sokoban restriction stays even after puzzle is solved */ + } else if (tunnels(youmonst.data) && !needspick(youmonst.data)) { + /* Eat the rock. */ + if (mode == DO_MOVE && still_chewing(x,y)) return FALSE; + } else if (flags.autodig && !context.run && !context.nopick && + uwep && is_pick(uwep)) { + /* MRKR: Automatic digging when wielding the appropriate tool */ + if (mode == DO_MOVE) + (void) use_pick_axe2(uwep); + return FALSE; + } else { + if (mode == DO_MOVE) { + if (Is_stronghold(&u.uz) && is_db_wall(x,y)) + pline_The("drawbridge is up!"); + /* sokoban restriction stays even after puzzle is solved */ else if (Passes_walls && !may_passwall(x,y) && In_sokoban(&u.uz)) - pline_The("Sokoban walls resist your ability."); + pline_The("Sokoban walls resist your ability."); else if (iflags.mention_walls) pline("It's a wall."); - } - return FALSE; - } + } + return FALSE; + } } else if (IS_DOOR(tmpr->typ)) { - if (closed_door(x,y)) { - if (Blind && mode == DO_MOVE) feel_location(x,y); - if (Passes_walls) - ; /* do nothing */ - else if (can_ooze(&youmonst)) { - if (mode == DO_MOVE) You("ooze under the door."); - } else if (tunnels(youmonst.data) && !needspick(youmonst.data)) { - /* Eat the door. */ - if (mode == DO_MOVE && still_chewing(x,y)) return FALSE; - } else { - if (mode == DO_MOVE) { - if (amorphous(youmonst.data)) - You("try to ooze under the door, but can't squeeze your possessions through."); - else if (x == ux || y == uy) { - if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) { - if (u.usteed) { - You_cant("lead %s through that closed door.", - y_monnam(u.usteed)); - } else { - pline("Ouch! You bump into a door."); - exercise(A_DEX, FALSE); - } - } else pline("That door is closed."); - } - } else if (mode == TEST_TRAV) goto testdiag; - return FALSE; - } - } else { - testdiag: - if (dx && dy && !Passes_walls - && (!doorless_door(x, y) || block_door(x, y))) { - /* Diagonal moves into a door are not allowed. */ - if (Blind && mode == DO_MOVE) - feel_location(x,y); - return FALSE; - } - } + if (closed_door(x,y)) { + if (Blind && mode == DO_MOVE) feel_location(x,y); + if (Passes_walls) + ; /* do nothing */ + else if (can_ooze(&youmonst)) { + if (mode == DO_MOVE) You("ooze under the door."); + } else if (tunnels(youmonst.data) && !needspick(youmonst.data)) { + /* Eat the door. */ + if (mode == DO_MOVE && still_chewing(x,y)) return FALSE; + } else { + if (mode == DO_MOVE) { + if (amorphous(youmonst.data)) + You("try to ooze under the door, but can't squeeze your possessions through."); + else if (x == ux || y == uy) { + if (Blind || Stunned || ACURR(A_DEX) < 10 || Fumbling) { + if (u.usteed) { + You_cant("lead %s through that closed door.", + y_monnam(u.usteed)); + } else { + pline("Ouch! You bump into a door."); + exercise(A_DEX, FALSE); + } + } else pline("That door is closed."); + } + } else if (mode == TEST_TRAV) goto testdiag; + return FALSE; + } + } else { + testdiag: + if (dx && dy && !Passes_walls + && (!doorless_door(x, y) || block_door(x, y))) { + /* Diagonal moves into a door are not allowed. */ + if (Blind && mode == DO_MOVE) + feel_location(x,y); + return FALSE; + } + } } if (dx && dy - && bad_rock(youmonst.data,ux,y) && bad_rock(youmonst.data,x,uy)) { - /* Move at a diagonal. */ - switch (cant_squeeze_thru(&youmonst)) { - case 3: - if (mode == DO_MOVE) You("cannot pass that way."); - return FALSE; - case 2: - if (mode == DO_MOVE) You("are carrying too much to get through."); - return FALSE; - case 1: - if (mode == DO_MOVE) Your("body is too large to fit through."); - return FALSE; - default: - break; /* can squeeze through */ - } + && bad_rock(youmonst.data,ux,y) && bad_rock(youmonst.data,x,uy)) { + /* Move at a diagonal. */ + switch (cant_squeeze_thru(&youmonst)) { + case 3: + if (mode == DO_MOVE) You("cannot pass that way."); + return FALSE; + case 2: + if (mode == DO_MOVE) You("are carrying too much to get through."); + return FALSE; + case 1: + if (mode == DO_MOVE) Your("body is too large to fit through."); + return FALSE; + default: + break; /* can squeeze through */ + } } else if (dx && dy && worm_cross(ux, uy, x, y)) { - /* consecutive long worm segments are at and */ - if (mode == DO_MOVE) pline("%s is in your way.", Monnam(m_at(ux, y))); - return FALSE; + /* consecutive long worm segments are at and */ + if (mode == DO_MOVE) pline("%s is in your way.", Monnam(m_at(ux, y))); + return FALSE; } /* Pick travel path that does not require crossing a trap. * Avoid water and lava using the usual running rules. * (but not u.ux/u.uy because findtravelpath walks toward u.ux/u.uy) */ if (context.run == 8 && mode != DO_MOVE && (x != u.ux || y != u.uy)) { - struct trap* t = t_at(x, y); + struct trap* t = t_at(x, y); - if ((t && t->tseen) || - (!Levitation && !Flying && - !is_clinger(youmonst.data) && - is_pool_or_lava(x, y) && levl[x][y].seenv)) - return FALSE; + if ((t && t->tseen) || + (!Levitation && !Flying && + !is_clinger(youmonst.data) && + is_pool_or_lava(x, y) && levl[x][y].seenv)) + return FALSE; } ust = &levl[ux][uy]; /* Now see if other things block our way . . */ if (dx && dy && !Passes_walls && IS_DOOR(ust->typ) && - (!doorless_door(ux, uy) || block_entry(x, y))) { - /* Can't move at a diagonal out of a doorway with door. */ - return FALSE; + (!doorless_door(ux, uy) || block_entry(x, y))) { + /* Can't move at a diagonal out of a doorway with door. */ + return FALSE; } if (sobj_at(BOULDER,x,y) && (Sokoban || !Passes_walls)) { - if (!(Blind || Hallucination) && (context.run >= 2) && mode != TEST_TRAV) - return FALSE; - if (mode == DO_MOVE) { - /* tunneling monsters will chew before pushing */ - if (tunnels(youmonst.data) && !needspick(youmonst.data) && - !Sokoban) { - if (still_chewing(x,y)) return FALSE; - } else - if (moverock() < 0) return FALSE; - } else if (mode == TEST_TRAV) { - struct obj* obj; + if (!(Blind || Hallucination) && (context.run >= 2) && mode != TEST_TRAV) + return FALSE; + if (mode == DO_MOVE) { + /* tunneling monsters will chew before pushing */ + if (tunnels(youmonst.data) && !needspick(youmonst.data) && + !Sokoban) { + if (still_chewing(x,y)) return FALSE; + } else + if (moverock() < 0) return FALSE; + } else if (mode == TEST_TRAV) { + struct obj* obj; - /* don't pick two boulders in a row, unless there's a way thru */ - if (sobj_at(BOULDER,ux,uy) && !Sokoban) { - if (!Passes_walls && - !(tunnels(youmonst.data) && !needspick(youmonst.data)) && - !carrying(PICK_AXE) && !carrying(DWARVISH_MATTOCK) && - !((obj = carrying(WAN_DIGGING)) && - !objects[obj->otyp].oc_name_known)) - return FALSE; - } - } - /* assume you'll be able to push it when you get there... */ + /* don't pick two boulders in a row, unless there's a way thru */ + if (sobj_at(BOULDER,ux,uy) && !Sokoban) { + if (!Passes_walls && + !(tunnels(youmonst.data) && !needspick(youmonst.data)) && + !carrying(PICK_AXE) && !carrying(DWARVISH_MATTOCK) && + !((obj = carrying(WAN_DIGGING)) && + !objects[obj->otyp].oc_name_known)) + return FALSE; + } + } + /* assume you'll be able to push it when you get there... */ } /* OK, it is a legal place to move. */ @@ -774,8 +774,8 @@ static boolean trav_debug = FALSE; int wiz_debug_cmd_traveldisplay() /* in this case, toggle display of travel debug info */ { - trav_debug = !trav_debug; - return 0; + trav_debug = !trav_debug; + return 0; } #endif /* DEBUG */ @@ -791,173 +791,173 @@ boolean guess; { /* if travel to adjacent, reachable location, use normal movement rules */ if (!guess && context.travel1 && distmin(u.ux, u.uy, u.tx, u.ty) == 1 && - !(u.ux != u.tx && u.uy != u.ty && NODIAG(u.umonnum))) { - context.run = 0; - if (test_move(u.ux, u.uy, u.tx-u.ux, u.ty-u.uy, TEST_MOVE)) { - u.dx = u.tx-u.ux; - u.dy = u.ty-u.uy; - nomul(0); - iflags.travelcc.x = iflags.travelcc.y = -1; - return TRUE; - } - context.run = 8; + !(u.ux != u.tx && u.uy != u.ty && NODIAG(u.umonnum))) { + context.run = 0; + if (test_move(u.ux, u.uy, u.tx-u.ux, u.ty-u.uy, TEST_MOVE)) { + u.dx = u.tx-u.ux; + u.dy = u.ty-u.uy; + nomul(0); + iflags.travelcc.x = iflags.travelcc.y = -1; + return TRUE; + } + context.run = 8; } if (u.tx != u.ux || u.ty != u.uy) { - xchar travel[COLNO][ROWNO]; - xchar travelstepx[2][COLNO*ROWNO]; - xchar travelstepy[2][COLNO*ROWNO]; - xchar tx, ty, ux, uy; - int n = 1; /* max offset in travelsteps */ - int set = 0; /* two sets current and previous */ - int radius = 1; /* search radius */ - int i; + xchar travel[COLNO][ROWNO]; + xchar travelstepx[2][COLNO*ROWNO]; + xchar travelstepy[2][COLNO*ROWNO]; + xchar tx, ty, ux, uy; + int n = 1; /* max offset in travelsteps */ + int set = 0; /* two sets current and previous */ + int radius = 1; /* search radius */ + int i; - /* If guessing, first find an "obvious" goal location. The obvious - * goal is the position the player knows of, or might figure out - * (couldsee) that is closest to the target on a straight path. - */ - if (guess) { - tx = u.ux; ty = u.uy; ux = u.tx; uy = u.ty; - } else { - tx = u.tx; ty = u.ty; ux = u.ux; uy = u.uy; - } + /* If guessing, first find an "obvious" goal location. The obvious + * goal is the position the player knows of, or might figure out + * (couldsee) that is closest to the target on a straight path. + */ + if (guess) { + tx = u.ux; ty = u.uy; ux = u.tx; uy = u.ty; + } else { + tx = u.tx; ty = u.ty; ux = u.ux; uy = u.uy; + } noguess: - (void) memset((genericptr_t)travel, 0, sizeof(travel)); - travelstepx[0][0] = tx; - travelstepy[0][0] = ty; + (void) memset((genericptr_t)travel, 0, sizeof(travel)); + travelstepx[0][0] = tx; + travelstepy[0][0] = ty; - while (n != 0) { - int nn = 0; + while (n != 0) { + int nn = 0; - for (i = 0; i < n; i++) { - int dir; - int x = travelstepx[set][i]; - int y = travelstepy[set][i]; - static int ordered[] = { 0, 2, 4, 6, 1, 3, 5, 7 }; - /* no diagonal movement for grid bugs */ - int dirmax = NODIAG(u.umonnum) ? 4 : 8; + for (i = 0; i < n; i++) { + int dir; + int x = travelstepx[set][i]; + int y = travelstepy[set][i]; + static int ordered[] = { 0, 2, 4, 6, 1, 3, 5, 7 }; + /* no diagonal movement for grid bugs */ + int dirmax = NODIAG(u.umonnum) ? 4 : 8; - for (dir = 0; dir < dirmax; ++dir) { - int nx = x+xdir[ordered[dir]]; - int ny = y+ydir[ordered[dir]]; + for (dir = 0; dir < dirmax; ++dir) { + int nx = x+xdir[ordered[dir]]; + int ny = y+ydir[ordered[dir]]; - if (!isok(nx, ny)) continue; - if ((!Passes_walls && !can_ooze(&youmonst) && - closed_door(x, y)) || sobj_at(BOULDER, x, y)) { - /* closed doors and boulders usually - * cause a delay, so prefer another path */ - if (travel[x][y] > radius-3) { - travelstepx[1-set][nn] = x; - travelstepy[1-set][nn] = y; - /* don't change travel matrix! */ - nn++; - continue; - } - } - if (test_move(x, y, nx-x, ny-y, TEST_TRAV) && - (levl[nx][ny].seenv || (!Blind && couldsee(nx, ny)))) { - if (nx == ux && ny == uy) { - if (!guess) { - u.dx = x-ux; - u.dy = y-uy; - if (x == u.tx && y == u.ty) { - nomul(0); - /* reset run so domove run checks work */ - context.run = 8; - iflags.travelcc.x = iflags.travelcc.y = -1; - } - return TRUE; - } - } else if (!travel[nx][ny]) { - travelstepx[1-set][nn] = nx; - travelstepy[1-set][nn] = ny; - travel[nx][ny] = radius; - nn++; - } - } - } - } + if (!isok(nx, ny)) continue; + if ((!Passes_walls && !can_ooze(&youmonst) && + closed_door(x, y)) || sobj_at(BOULDER, x, y)) { + /* closed doors and boulders usually + * cause a delay, so prefer another path */ + if (travel[x][y] > radius-3) { + travelstepx[1-set][nn] = x; + travelstepy[1-set][nn] = y; + /* don't change travel matrix! */ + nn++; + continue; + } + } + if (test_move(x, y, nx-x, ny-y, TEST_TRAV) && + (levl[nx][ny].seenv || (!Blind && couldsee(nx, ny)))) { + if (nx == ux && ny == uy) { + if (!guess) { + u.dx = x-ux; + u.dy = y-uy; + if (x == u.tx && y == u.ty) { + nomul(0); + /* reset run so domove run checks work */ + context.run = 8; + iflags.travelcc.x = iflags.travelcc.y = -1; + } + return TRUE; + } + } else if (!travel[nx][ny]) { + travelstepx[1-set][nn] = nx; + travelstepy[1-set][nn] = ny; + travel[nx][ny] = radius; + nn++; + } + } + } + } #ifdef DEBUG - if (trav_debug) { - /* Use of warning glyph is arbitrary. It stands out. */ - tmp_at(DISP_ALL, warning_to_glyph(1)); - for (i = 0; i < nn; ++i) { - tmp_at(travelstepx[1-set][i], travelstepy[1-set][i]); - } - delay_output(); - if (flags.runmode == RUN_CRAWL) { - delay_output(); - delay_output(); - } - tmp_at(DISP_END,0); - } + if (trav_debug) { + /* Use of warning glyph is arbitrary. It stands out. */ + tmp_at(DISP_ALL, warning_to_glyph(1)); + for (i = 0; i < nn; ++i) { + tmp_at(travelstepx[1-set][i], travelstepy[1-set][i]); + } + delay_output(); + if (flags.runmode == RUN_CRAWL) { + delay_output(); + delay_output(); + } + tmp_at(DISP_END,0); + } #endif /* DEBUG */ - n = nn; - set = 1-set; - radius++; - } + n = nn; + set = 1-set; + radius++; + } - /* if guessing, find best location in travel matrix and go there */ - if (guess) { - int px = tx, py = ty; /* pick location */ - int dist, nxtdist, d2, nd2; + /* if guessing, find best location in travel matrix and go there */ + if (guess) { + int px = tx, py = ty; /* pick location */ + int dist, nxtdist, d2, nd2; - dist = distmin(ux, uy, tx, ty); - d2 = dist2(ux, uy, tx, ty); - for (tx = 1; tx < COLNO; ++tx) - for (ty = 0; ty < ROWNO; ++ty) - if (travel[tx][ty]) { - nxtdist = distmin(ux, uy, tx, ty); - if (nxtdist == dist && couldsee(tx, ty)) { - nd2 = dist2(ux, uy, tx, ty); - if (nd2 < d2) { - /* prefer non-zigzag path */ - px = tx; py = ty; - d2 = nd2; - } - } else if (nxtdist < dist && couldsee(tx, ty)) { - px = tx; py = ty; - dist = nxtdist; - d2 = dist2(ux, uy, tx, ty); - } - } + dist = distmin(ux, uy, tx, ty); + d2 = dist2(ux, uy, tx, ty); + for (tx = 1; tx < COLNO; ++tx) + for (ty = 0; ty < ROWNO; ++ty) + if (travel[tx][ty]) { + nxtdist = distmin(ux, uy, tx, ty); + if (nxtdist == dist && couldsee(tx, ty)) { + nd2 = dist2(ux, uy, tx, ty); + if (nd2 < d2) { + /* prefer non-zigzag path */ + px = tx; py = ty; + d2 = nd2; + } + } else if (nxtdist < dist && couldsee(tx, ty)) { + px = tx; py = ty; + dist = nxtdist; + d2 = dist2(ux, uy, tx, ty); + } + } - if (px == u.ux && py == u.uy) { - /* no guesses, just go in the general direction */ - u.dx = sgn(u.tx - u.ux); - u.dy = sgn(u.ty - u.uy); - if (test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE)) - return TRUE; - goto found; - } + if (px == u.ux && py == u.uy) { + /* no guesses, just go in the general direction */ + u.dx = sgn(u.tx - u.ux); + u.dy = sgn(u.ty - u.uy); + if (test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE)) + return TRUE; + goto found; + } #ifdef DEBUG - if (trav_debug) { - /* Use of warning glyph is arbitrary. It stands out. */ - tmp_at(DISP_ALL, warning_to_glyph(2)); - tmp_at(px, py); - delay_output(); - if (flags.runmode == RUN_CRAWL) { - delay_output(); - delay_output(); - delay_output(); - delay_output(); - } - tmp_at(DISP_END,0); - } + if (trav_debug) { + /* Use of warning glyph is arbitrary. It stands out. */ + tmp_at(DISP_ALL, warning_to_glyph(2)); + tmp_at(px, py); + delay_output(); + if (flags.runmode == RUN_CRAWL) { + delay_output(); + delay_output(); + delay_output(); + delay_output(); + } + tmp_at(DISP_END,0); + } #endif /* DEBUG */ - tx = px; - ty = py; - ux = u.ux; - uy = u.uy; - set = 0; - n = radius = 1; - guess = FALSE; - goto noguess; - } - return FALSE; + tx = px; + ty = py; + ux = u.ux; + uy = u.uy; + set = 0; + n = radius = 1; + guess = FALSE; + goto noguess; + } + return FALSE; } found: @@ -983,117 +983,117 @@ struct trap *desttrap; /* nonnull if another trap at */ switch (u.utraptype) { case TT_BEARTRAP: - if (flags.verbose) { - predicament = "caught in a bear trap"; - if (u.usteed) - Norep("%s is %s.", upstart(steedname), predicament); - else - Norep("You are %s.", predicament); - } - /* [why does diagonal movement give quickest escape?] */ - if ((u.dx && u.dy) || !rn2(5)) u.utrap--; - break; + if (flags.verbose) { + predicament = "caught in a bear trap"; + if (u.usteed) + Norep("%s is %s.", upstart(steedname), predicament); + else + Norep("You are %s.", predicament); + } + /* [why does diagonal movement give quickest escape?] */ + if ((u.dx && u.dy) || !rn2(5)) u.utrap--; + break; case TT_PIT: - if (desttrap && desttrap->tseen && - (desttrap->ttyp == PIT || desttrap->ttyp == SPIKED_PIT)) - return TRUE; /* move into adjacent pit */ - /* try to escape; position stays same regardless of success */ - climb_pit(); - break; + if (desttrap && desttrap->tseen && + (desttrap->ttyp == PIT || desttrap->ttyp == SPIKED_PIT)) + return TRUE; /* move into adjacent pit */ + /* try to escape; position stays same regardless of success */ + climb_pit(); + break; case TT_WEB: - if (uwep && uwep->oartifact == ART_STING) { - u.utrap = 0; - pline("Sting cuts through the web!"); - break; /* escape trap but don't move */ - } - if (--u.utrap) { - if (flags.verbose) { - predicament = "stuck to the web"; - if (u.usteed) - Norep("%s is %s.", upstart(steedname), predicament); - else - Norep("You are %s.", predicament); - } - } else { - if (u.usteed) - pline("%s breaks out of the web.", upstart(steedname)); - else - You("disentangle yourself."); - } - break; + if (uwep && uwep->oartifact == ART_STING) { + u.utrap = 0; + pline("Sting cuts through the web!"); + break; /* escape trap but don't move */ + } + if (--u.utrap) { + if (flags.verbose) { + predicament = "stuck to the web"; + if (u.usteed) + Norep("%s is %s.", upstart(steedname), predicament); + else + Norep("You are %s.", predicament); + } + } else { + if (u.usteed) + pline("%s breaks out of the web.", upstart(steedname)); + else + You("disentangle yourself."); + } + break; case TT_LAVA: - if (flags.verbose) { - predicament = "stuck in the lava"; - if (u.usteed) - Norep("%s is %s.", upstart(steedname), predicament); - else - Norep("You are %s.", predicament); - } - if (!is_lava(x, y)) { - u.utrap--; - if ((u.utrap & 0xff) == 0) { - u.utrap = 0; - if (u.usteed) - You("lead %s to the edge of the lava.", steedname); - else - You("pull yourself to the edge of the lava."); - } - } - u.umoved = TRUE; - break; + if (flags.verbose) { + predicament = "stuck in the lava"; + if (u.usteed) + Norep("%s is %s.", upstart(steedname), predicament); + else + Norep("You are %s.", predicament); + } + if (!is_lava(x, y)) { + u.utrap--; + if ((u.utrap & 0xff) == 0) { + u.utrap = 0; + if (u.usteed) + You("lead %s to the edge of the lava.", steedname); + else + You("pull yourself to the edge of the lava."); + } + } + u.umoved = TRUE; + break; case TT_INFLOOR: case TT_BURIEDBALL: - anchored = (u.utraptype == TT_BURIEDBALL); - if (anchored) { - coord cc; + anchored = (u.utraptype == TT_BURIEDBALL); + if (anchored) { + coord cc; - cc.x = u.ux, cc.y = u.uy; - /* can move normally within radius 1 of buried ball */ - if (buried_ball(&cc) && dist2(x, y, cc.x, cc.y) <= 2) { - /* ugly hack: we need to issue some message here - in case "you are chained to the buried ball" - was the most recent message given, otherwise - our next attempt to move out of tether range - after this successful move would have its - can't-do-that message suppressed by Norep */ - if (flags.verbose) - Norep("You move within the chain's reach."); - return TRUE; - } - } - if (--u.utrap) { - if (flags.verbose) { - if (anchored) { - predicament = "chained to the"; - culprit = "buried ball"; - } else { - predicament = "stuck in the"; - culprit = surface(u.ux, u.uy); - } - if (u.usteed) { - if (anchored) - Norep("You and %s are %s %s.", steedname, - predicament, culprit); - else - Norep("%s is %s %s.", upstart(steedname), - predicament, culprit); - } else - Norep("You are %s %s.", predicament, culprit); - } - } else { - if (u.usteed) - pline("%s finally %s free.", upstart(steedname), - !anchored ? "lurches" : "wrenches the ball"); - else - You("finally %s free.", - !anchored ? "wriggle" : "wrench the ball"); - if (anchored) - buried_ball_to_punishment(); - } - break; + cc.x = u.ux, cc.y = u.uy; + /* can move normally within radius 1 of buried ball */ + if (buried_ball(&cc) && dist2(x, y, cc.x, cc.y) <= 2) { + /* ugly hack: we need to issue some message here + in case "you are chained to the buried ball" + was the most recent message given, otherwise + our next attempt to move out of tether range + after this successful move would have its + can't-do-that message suppressed by Norep */ + if (flags.verbose) + Norep("You move within the chain's reach."); + return TRUE; + } + } + if (--u.utrap) { + if (flags.verbose) { + if (anchored) { + predicament = "chained to the"; + culprit = "buried ball"; + } else { + predicament = "stuck in the"; + culprit = surface(u.ux, u.uy); + } + if (u.usteed) { + if (anchored) + Norep("You and %s are %s %s.", steedname, + predicament, culprit); + else + Norep("%s is %s %s.", upstart(steedname), + predicament, culprit); + } else + Norep("You are %s %s.", predicament, culprit); + } + } else { + if (u.usteed) + pline("%s finally %s free.", upstart(steedname), + !anchored ? "lurches" : "wrenches the ball"); + else + You("finally %s free.", + !anchored ? "wriggle" : "wrench the ball"); + if (anchored) + buried_ball_to_punishment(); + } + break; default: - impossible("trapmove: stuck in unknown trap? (%d)", (int)u.utraptype); - break; + impossible("trapmove: stuck in unknown trap? (%d)", (int)u.utraptype); + break; } return FALSE; } @@ -1101,491 +1101,491 @@ struct trap *desttrap; /* nonnull if another trap at */ void domove() { - register struct monst *mtmp; - register struct rm *tmpr; - register xchar x,y; + register struct monst *mtmp; + register struct rm *tmpr; + register xchar x,y; struct trap *trap = (struct trap *)0; - int wtcap; - boolean on_ice; - xchar chainx, chainy, ballx, bally; /* ball&chain new positions */ - int bc_control; /* control for ball&chain */ - boolean cause_delay = FALSE; /* dragging ball will skip a move */ + int wtcap; + boolean on_ice; + xchar chainx, chainy, ballx, bally; /* ball&chain new positions */ + int bc_control; /* control for ball&chain */ + boolean cause_delay = FALSE; /* dragging ball will skip a move */ - u_wipe_engr(rnd(5)); + u_wipe_engr(rnd(5)); - if (context.travel) { - if (!findtravelpath(FALSE)) - (void) findtravelpath(TRUE); - context.travel1 = 0; - } + if (context.travel) { + if (!findtravelpath(FALSE)) + (void) findtravelpath(TRUE); + context.travel1 = 0; + } - if(((wtcap = near_capacity()) >= OVERLOADED - || (wtcap > SLT_ENCUMBER && - (Upolyd ? (u.mh < 5 && u.mh != u.mhmax) - : (u.uhp < 10 && u.uhp != u.uhpmax)))) - && !Is_airlevel(&u.uz)) { - if(wtcap < OVERLOADED) { - You("don't have enough stamina to move."); - exercise(A_CON, FALSE); - } else - You("collapse under your load."); - nomul(0); - return; - } - if(u.uswallow) { - u.dx = u.dy = 0; - u.ux = x = u.ustuck->mx; - u.uy = y = u.ustuck->my; - mtmp = u.ustuck; - } else { - if (Is_airlevel(&u.uz) && rn2(4) && - !Levitation && !Flying) { - switch(rn2(3)) { - case 0: - You("tumble in place."); - exercise(A_DEX, FALSE); - break; - case 1: - You_cant("control your movements very well."); break; - case 2: - pline("It's hard to walk in thin air."); - exercise(A_DEX, TRUE); - break; - } - return; - } + if(((wtcap = near_capacity()) >= OVERLOADED + || (wtcap > SLT_ENCUMBER && + (Upolyd ? (u.mh < 5 && u.mh != u.mhmax) + : (u.uhp < 10 && u.uhp != u.uhpmax)))) + && !Is_airlevel(&u.uz)) { + if(wtcap < OVERLOADED) { + You("don't have enough stamina to move."); + exercise(A_CON, FALSE); + } else + You("collapse under your load."); + nomul(0); + return; + } + if(u.uswallow) { + u.dx = u.dy = 0; + u.ux = x = u.ustuck->mx; + u.uy = y = u.ustuck->my; + mtmp = u.ustuck; + } else { + if (Is_airlevel(&u.uz) && rn2(4) && + !Levitation && !Flying) { + switch(rn2(3)) { + case 0: + You("tumble in place."); + exercise(A_DEX, FALSE); + break; + case 1: + You_cant("control your movements very well."); break; + case 2: + pline("It's hard to walk in thin air."); + exercise(A_DEX, TRUE); + break; + } + return; + } - /* check slippery ice */ - on_ice = !Levitation && is_ice(u.ux, u.uy); - if (on_ice) { - static int skates = 0; - if (!skates) skates = find_skates(); - if ((uarmf && uarmf->otyp == skates) - || resists_cold(&youmonst) || Flying - || is_floater(youmonst.data) || is_clinger(youmonst.data) - || is_whirly(youmonst.data)) - on_ice = FALSE; - else if (!rn2(Cold_resistance ? 3 : 2)) { - HFumbling |= FROMOUTSIDE; - HFumbling &= ~TIMEOUT; - HFumbling += 1; /* slip on next move */ - } - } - if (!on_ice && (HFumbling & FROMOUTSIDE)) - HFumbling &= ~FROMOUTSIDE; + /* check slippery ice */ + on_ice = !Levitation && is_ice(u.ux, u.uy); + if (on_ice) { + static int skates = 0; + if (!skates) skates = find_skates(); + if ((uarmf && uarmf->otyp == skates) + || resists_cold(&youmonst) || Flying + || is_floater(youmonst.data) || is_clinger(youmonst.data) + || is_whirly(youmonst.data)) + on_ice = FALSE; + else if (!rn2(Cold_resistance ? 3 : 2)) { + HFumbling |= FROMOUTSIDE; + HFumbling &= ~TIMEOUT; + HFumbling += 1; /* slip on next move */ + } + } + if (!on_ice && (HFumbling & FROMOUTSIDE)) + HFumbling &= ~FROMOUTSIDE; - x = u.ux + u.dx; - y = u.uy + u.dy; - if(Stunned || (Confusion && !rn2(5))) { - register int tries = 0; + x = u.ux + u.dx; + y = u.uy + u.dy; + if(Stunned || (Confusion && !rn2(5))) { + register int tries = 0; - do { - if(tries++ > 50) { - nomul(0); - return; - } - confdir(); - x = u.ux + u.dx; - y = u.uy + u.dy; - } while(!isok(x, y) || bad_rock(youmonst.data, x, y)); - } - /* turbulence might alter your actual destination */ - if (u.uinwater) { - water_friction(); - if (!u.dx && !u.dy) { - nomul(0); - return; - } - x = u.ux + u.dx; - y = u.uy + u.dy; - } - if(!isok(x, y)) { - nomul(0); - return; - } - if (((trap = t_at(x, y)) && trap->tseen) || - (Blind && !Levitation && !Flying && - !is_clinger(youmonst.data) && - is_pool_or_lava(x, y) && levl[x][y].seenv)) { - if(context.run >= 2) { - nomul(0); - context.move = 0; - return; - } else - nomul(0); - } + do { + if(tries++ > 50) { + nomul(0); + return; + } + confdir(); + x = u.ux + u.dx; + y = u.uy + u.dy; + } while(!isok(x, y) || bad_rock(youmonst.data, x, y)); + } + /* turbulence might alter your actual destination */ + if (u.uinwater) { + water_friction(); + if (!u.dx && !u.dy) { + nomul(0); + return; + } + x = u.ux + u.dx; + y = u.uy + u.dy; + } + if(!isok(x, y)) { + nomul(0); + return; + } + if (((trap = t_at(x, y)) && trap->tseen) || + (Blind && !Levitation && !Flying && + !is_clinger(youmonst.data) && + is_pool_or_lava(x, y) && levl[x][y].seenv)) { + if(context.run >= 2) { + nomul(0); + context.move = 0; + return; + } else + nomul(0); + } - if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) { - if (distu(u.ustuck->mx, u.ustuck->my) > 2) { - /* perhaps it fled (or was teleported or ... ) */ - u.ustuck = 0; - } else if (sticks(youmonst.data)) { - /* When polymorphed into a sticking monster, - * u.ustuck means it's stuck to you, not you to it. - */ - You("release %s.", mon_nam(u.ustuck)); - u.ustuck = 0; - } else { - /* If holder is asleep or paralyzed: - * 37.5% chance of getting away, - * 12.5% chance of waking/releasing it; - * otherwise: - * 7.5% chance of getting away. - * [strength ought to be a factor] - * If holder is tame and there is no conflict, - * guaranteed escape. - */ - switch (rn2(!u.ustuck->mcanmove ? 8 : 40)) { - case 0: case 1: case 2: - pull_free: - You("pull free from %s.", mon_nam(u.ustuck)); - u.ustuck = 0; - break; - case 3: - if (!u.ustuck->mcanmove) { - /* it's free to move on next turn */ - u.ustuck->mfrozen = 1; - u.ustuck->msleeping = 0; - } - /*FALLTHRU*/ - default: - if (u.ustuck->mtame && - !Conflict && !u.ustuck->mconf) - goto pull_free; - You("cannot escape from %s!", mon_nam(u.ustuck)); - nomul(0); - return; - } - } - } + if (u.ustuck && (x != u.ustuck->mx || y != u.ustuck->my)) { + if (distu(u.ustuck->mx, u.ustuck->my) > 2) { + /* perhaps it fled (or was teleported or ... ) */ + u.ustuck = 0; + } else if (sticks(youmonst.data)) { + /* When polymorphed into a sticking monster, + * u.ustuck means it's stuck to you, not you to it. + */ + You("release %s.", mon_nam(u.ustuck)); + u.ustuck = 0; + } else { + /* If holder is asleep or paralyzed: + * 37.5% chance of getting away, + * 12.5% chance of waking/releasing it; + * otherwise: + * 7.5% chance of getting away. + * [strength ought to be a factor] + * If holder is tame and there is no conflict, + * guaranteed escape. + */ + switch (rn2(!u.ustuck->mcanmove ? 8 : 40)) { + case 0: case 1: case 2: + pull_free: + You("pull free from %s.", mon_nam(u.ustuck)); + u.ustuck = 0; + break; + case 3: + if (!u.ustuck->mcanmove) { + /* it's free to move on next turn */ + u.ustuck->mfrozen = 1; + u.ustuck->msleeping = 0; + } + /*FALLTHRU*/ + default: + if (u.ustuck->mtame && + !Conflict && !u.ustuck->mconf) + goto pull_free; + You("cannot escape from %s!", mon_nam(u.ustuck)); + nomul(0); + return; + } + } + } - mtmp = m_at(x,y); - if (mtmp) { - /* Don't attack if you're running, and can see it */ - /* We should never get here if forcefight */ - if (context.run && - ((!Blind && mon_visible(mtmp) && - ((mtmp->m_ap_type != M_AP_FURNITURE && - mtmp->m_ap_type != M_AP_OBJECT) || - Protection_from_shape_changers)) || - sensemon(mtmp))) { - nomul(0); - context.move = 0; - return; - } - } - } + mtmp = m_at(x,y); + if (mtmp) { + /* Don't attack if you're running, and can see it */ + /* We should never get here if forcefight */ + if (context.run && + ((!Blind && mon_visible(mtmp) && + ((mtmp->m_ap_type != M_AP_FURNITURE && + mtmp->m_ap_type != M_AP_OBJECT) || + Protection_from_shape_changers)) || + sensemon(mtmp))) { + nomul(0); + context.move = 0; + return; + } + } + } - u.ux0 = u.ux; - u.uy0 = u.uy; - bhitpos.x = x; - bhitpos.y = y; - tmpr = &levl[x][y]; + u.ux0 = u.ux; + u.uy0 = u.uy; + bhitpos.x = x; + bhitpos.y = y; + tmpr = &levl[x][y]; - /* attack monster */ - if(mtmp) { - nomul(0); - /* only attack if we know it's there */ - /* or if we used the 'F' command to fight blindly */ - /* or if it hides_under, in which case we call attack() to print - * the Wait! message. - * This is different from ceiling hiders, who aren't handled in - * attack(). - */ + /* attack monster */ + if(mtmp) { + nomul(0); + /* only attack if we know it's there */ + /* or if we used the 'F' command to fight blindly */ + /* or if it hides_under, in which case we call attack() to print + * the Wait! message. + * This is different from ceiling hiders, who aren't handled in + * attack(). + */ - /* If they used a 'm' command, trying to move onto a monster - * prints the below message and wastes a turn. The exception is - * if the monster is unseen and the player doesn't remember an - * invisible monster--then, we fall through to attack() and - * attack_check(), which still wastes a turn, but prints a - * different message and makes the player remember the monster. */ - if(context.nopick && - (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))){ - if(mtmp->m_ap_type && !Protection_from_shape_changers - && !sensemon(mtmp)) - stumble_onto_mimic(mtmp); - else if (mtmp->mpeaceful && !Hallucination) - pline("Pardon me, %s.", m_monnam(mtmp)); - else - You("move right into %s.", mon_nam(mtmp)); - return; - } - if(context.forcefight || !mtmp->mundetected || sensemon(mtmp) || - ((hides_under(mtmp->data) || mtmp->data->mlet == S_EEL) && - !is_safepet(mtmp))){ - /* try to attack; note that it might evade */ - /* also, we don't attack tame when _safepet_ */ - if(attack(mtmp)) return; - } - } + /* If they used a 'm' command, trying to move onto a monster + * prints the below message and wastes a turn. The exception is + * if the monster is unseen and the player doesn't remember an + * invisible monster--then, we fall through to attack() and + * attack_check(), which still wastes a turn, but prints a + * different message and makes the player remember the monster. */ + if(context.nopick && + (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))){ + if(mtmp->m_ap_type && !Protection_from_shape_changers + && !sensemon(mtmp)) + stumble_onto_mimic(mtmp); + else if (mtmp->mpeaceful && !Hallucination) + pline("Pardon me, %s.", m_monnam(mtmp)); + else + You("move right into %s.", mon_nam(mtmp)); + return; + } + if(context.forcefight || !mtmp->mundetected || sensemon(mtmp) || + ((hides_under(mtmp->data) || mtmp->data->mlet == S_EEL) && + !is_safepet(mtmp))){ + /* try to attack; note that it might evade */ + /* also, we don't attack tame when _safepet_ */ + if(attack(mtmp)) return; + } + } - /* specifying 'F' with no monster wastes a turn */ - if (context.forcefight || - /* remembered an 'I' && didn't use a move command */ - (glyph_is_invisible(levl[x][y].glyph) && !context.nopick)) { - struct obj *boulder = sobj_at(BOULDER, x, y); - boolean explo = (Upolyd && attacktype(youmonst.data, AT_EXPL)), - solid = !accessible(x, y); - int glyph = glyph_at(x, y); /* might be monster */ - char buf[BUFSZ]; + /* specifying 'F' with no monster wastes a turn */ + if (context.forcefight || + /* remembered an 'I' && didn't use a move command */ + (glyph_is_invisible(levl[x][y].glyph) && !context.nopick)) { + struct obj *boulder = sobj_at(BOULDER, x, y); + boolean explo = (Upolyd && attacktype(youmonst.data, AT_EXPL)), + solid = !accessible(x, y); + int glyph = glyph_at(x, y); /* might be monster */ + char buf[BUFSZ]; - /* if a statue is displayed at the target location, - player is attempting to attack it [and boulder - handlng below is suitable for handling that] */ - if (glyph_is_statue(glyph) || - (Hallucination && glyph_is_monster(glyph))) - boulder = sobj_at(STATUE, x, y); + /* if a statue is displayed at the target location, + player is attempting to attack it [and boulder + handlng below is suitable for handling that] */ + if (glyph_is_statue(glyph) || + (Hallucination && glyph_is_monster(glyph))) + boulder = sobj_at(STATUE, x, y); - /* force fight at boulder/statue or wall/door while wielding - pick: start digging to break the boulder or wall */ - if (context.forcefight && - /* can we dig? */ - uwep && dig_typ(uwep, x, y) && - /* should we dig? */ - !glyph_is_invisible(glyph) && - !glyph_is_monster(glyph)) { - (void)use_pick_axe2(uwep); - return; - } + /* force fight at boulder/statue or wall/door while wielding + pick: start digging to break the boulder or wall */ + if (context.forcefight && + /* can we dig? */ + uwep && dig_typ(uwep, x, y) && + /* should we dig? */ + !glyph_is_invisible(glyph) && + !glyph_is_monster(glyph)) { + (void)use_pick_axe2(uwep); + return; + } - if (boulder) - Strcpy(buf, ansimpleoname(boulder)); - else if (solid) - Strcpy(buf, the(defsyms[glyph_to_cmap(glyph)].explanation)); - else if (!Underwater) - Strcpy(buf, "thin air"); - else if (is_pool(x, y)) - Strcpy(buf, "empty water"); - else /* Underwater, targetting non-water */ - Sprintf(buf, "a vacant spot on the %s", surface(x,y)); - You("%s%s %s.", - !(boulder || solid) ? "" : - !explo ? "harmlessly " : "futilely ", - explo ? "explode at" : "attack", - buf); - unmap_object(x, y); /* known empty -- remove 'I' if present */ - if (boulder) map_object(boulder, TRUE); - newsym(x, y); - nomul(0); - if (explo) { - wake_nearby(); - u.mh = -1; /* dead in the current form */ - rehumanize(); - } - return; - } - if (glyph_is_invisible(levl[x][y].glyph)) { - unmap_object(x, y); - newsym(x, y); - } - /* not attacking an animal, so we try to move */ - if ((u.dx || u.dy) && u.usteed && stucksteed(FALSE)) { - nomul(0); - return; - } - if(!youmonst.data->mmove) { - You("are rooted %s.", - Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? - "in place" : "to the ground"); - nomul(0); - return; - } - if(u.utrap) { - if (!trapmove(x, y, trap)) return; - } + if (boulder) + Strcpy(buf, ansimpleoname(boulder)); + else if (solid) + Strcpy(buf, the(defsyms[glyph_to_cmap(glyph)].explanation)); + else if (!Underwater) + Strcpy(buf, "thin air"); + else if (is_pool(x, y)) + Strcpy(buf, "empty water"); + else /* Underwater, targetting non-water */ + Sprintf(buf, "a vacant spot on the %s", surface(x,y)); + You("%s%s %s.", + !(boulder || solid) ? "" : + !explo ? "harmlessly " : "futilely ", + explo ? "explode at" : "attack", + buf); + unmap_object(x, y); /* known empty -- remove 'I' if present */ + if (boulder) map_object(boulder, TRUE); + newsym(x, y); + nomul(0); + if (explo) { + wake_nearby(); + u.mh = -1; /* dead in the current form */ + rehumanize(); + } + return; + } + if (glyph_is_invisible(levl[x][y].glyph)) { + unmap_object(x, y); + newsym(x, y); + } + /* not attacking an animal, so we try to move */ + if ((u.dx || u.dy) && u.usteed && stucksteed(FALSE)) { + nomul(0); + return; + } + if(!youmonst.data->mmove) { + You("are rooted %s.", + Levitation || Is_airlevel(&u.uz) || Is_waterlevel(&u.uz) ? + "in place" : "to the ground"); + nomul(0); + return; + } + if(u.utrap) { + if (!trapmove(x, y, trap)) return; + } - if (!test_move(u.ux, u.uy, x-u.ux, y-u.uy, DO_MOVE)) { - context.move = 0; - nomul(0); - return; - } + if (!test_move(u.ux, u.uy, x-u.ux, y-u.uy, DO_MOVE)) { + context.move = 0; + nomul(0); + return; + } - /* Move ball and chain. */ - if (Punished) - if (!drag_ball(x,y, &bc_control, &ballx, &bally, &chainx, &chainy, - &cause_delay, TRUE)) - return; + /* Move ball and chain. */ + if (Punished) + if (!drag_ball(x,y, &bc_control, &ballx, &bally, &chainx, &chainy, + &cause_delay, TRUE)) + return; - /* Check regions entering/leaving */ - if (!in_out_region(x,y)) - return; + /* Check regions entering/leaving */ + if (!in_out_region(x,y)) + return; - /* now move the hero */ - mtmp = m_at(x, y); - u.ux += u.dx; - u.uy += u.dy; - /* Move your steed, too */ - if (u.usteed) { - u.usteed->mx = u.ux; - u.usteed->my = u.uy; - exercise_steed(); - } + /* now move the hero */ + mtmp = m_at(x, y); + u.ux += u.dx; + u.uy += u.dy; + /* Move your steed, too */ + if (u.usteed) { + u.usteed->mx = u.ux; + u.usteed->my = u.uy; + exercise_steed(); + } - /* - * If safepet at destination then move the pet to the hero's - * previous location using the same conditions as in attack(). - * there are special extenuating circumstances: - * (1) if the pet dies then your god angers, - * (2) if the pet gets trapped then your god may disapprove, - * (3) if the pet was already trapped and you attempt to free it - * not only do you encounter the trap but you may frighten your - * pet causing it to go wild! moral: don't abuse this privilege. - * - * Ceiling-hiding pets are skipped by this section of code, to - * be caught by the normal falling-monster code. - */ - if (is_safepet(mtmp) && !(is_hider(mtmp->data) && mtmp->mundetected)) { - /* if trapped, there's a chance the pet goes wild */ - if (mtmp->mtrapped) { - if (!rn2(mtmp->mtame)) { - mtmp->mtame = mtmp->mpeaceful = mtmp->msleeping = 0; - if (mtmp->mleashed) m_unleash(mtmp, TRUE); - growl(mtmp); - } else { - yelp(mtmp); - } - } - mtmp->mundetected = 0; - if (mtmp->m_ap_type) seemimic(mtmp); - else if (!mtmp->mtame) newsym(mtmp->mx, mtmp->my); + /* + * If safepet at destination then move the pet to the hero's + * previous location using the same conditions as in attack(). + * there are special extenuating circumstances: + * (1) if the pet dies then your god angers, + * (2) if the pet gets trapped then your god may disapprove, + * (3) if the pet was already trapped and you attempt to free it + * not only do you encounter the trap but you may frighten your + * pet causing it to go wild! moral: don't abuse this privilege. + * + * Ceiling-hiding pets are skipped by this section of code, to + * be caught by the normal falling-monster code. + */ + if (is_safepet(mtmp) && !(is_hider(mtmp->data) && mtmp->mundetected)) { + /* if trapped, there's a chance the pet goes wild */ + if (mtmp->mtrapped) { + if (!rn2(mtmp->mtame)) { + mtmp->mtame = mtmp->mpeaceful = mtmp->msleeping = 0; + if (mtmp->mleashed) m_unleash(mtmp, TRUE); + growl(mtmp); + } else { + yelp(mtmp); + } + } + mtmp->mundetected = 0; + if (mtmp->m_ap_type) seemimic(mtmp); + else if (!mtmp->mtame) newsym(mtmp->mx, mtmp->my); - if (mtmp->mtrapped && - (trap = t_at(mtmp->mx, mtmp->my)) != 0 && - (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT) && - sobj_at(BOULDER, trap->tx, trap->ty)) { - /* can't swap places with pet pinned in a pit by a boulder */ - u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */ - } else if (u.ux0 != x && u.uy0 != y && NODIAG(mtmp->data - mons)) { - /* can't swap places when pet can't move to your spot */ - u.ux = u.ux0, u.uy = u.uy0; - You("stop. %s can't move diagonally.", - upstart(y_monnam(mtmp))); - } else if (u.ux0 != x && u.uy0 != y && - bad_rock(mtmp->data, x, u.uy0) && - bad_rock(mtmp->data, u.ux0, y) && - (bigmonst(mtmp->data) || (curr_mon_load(mtmp) > 600))) { - /* can't swap places when pet won't fit thru the opening */ - u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */ - You("stop. %s won't fit through.", upstart(y_monnam(mtmp))); - } else { - char pnambuf[BUFSZ]; + if (mtmp->mtrapped && + (trap = t_at(mtmp->mx, mtmp->my)) != 0 && + (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT) && + sobj_at(BOULDER, trap->tx, trap->ty)) { + /* can't swap places with pet pinned in a pit by a boulder */ + u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */ + } else if (u.ux0 != x && u.uy0 != y && NODIAG(mtmp->data - mons)) { + /* can't swap places when pet can't move to your spot */ + u.ux = u.ux0, u.uy = u.uy0; + You("stop. %s can't move diagonally.", + upstart(y_monnam(mtmp))); + } else if (u.ux0 != x && u.uy0 != y && + bad_rock(mtmp->data, x, u.uy0) && + bad_rock(mtmp->data, u.ux0, y) && + (bigmonst(mtmp->data) || (curr_mon_load(mtmp) > 600))) { + /* can't swap places when pet won't fit thru the opening */ + u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */ + You("stop. %s won't fit through.", upstart(y_monnam(mtmp))); + } else { + char pnambuf[BUFSZ]; - /* save its current description in case of polymorph */ - Strcpy(pnambuf, y_monnam(mtmp)); - mtmp->mtrapped = 0; - remove_monster(x, y); - place_monster(mtmp, u.ux0, u.uy0); - newsym(x, y); - newsym(u.ux0, u.uy0); + /* save its current description in case of polymorph */ + Strcpy(pnambuf, y_monnam(mtmp)); + mtmp->mtrapped = 0; + remove_monster(x, y); + place_monster(mtmp, u.ux0, u.uy0); + newsym(x, y); + newsym(u.ux0, u.uy0); - You("%s %s.", mtmp->mtame ? "swap places with" : "frighten", - pnambuf); + You("%s %s.", mtmp->mtame ? "swap places with" : "frighten", + pnambuf); - /* check for displacing it into pools and traps */ - switch (minliquid(mtmp) ? 2 : mintrap(mtmp)) { - case 0: - break; - case 1: /* trapped */ - case 3: /* changed levels */ - /* there's already been a trap message, reinforce it */ - abuse_dog(mtmp); - adjalign(-3); - break; - case 2: - /* drowned or died... - * you killed your pet by direct action, so get experience - * and possibly penalties; - * we want the level gain message, if it happens, to occur - * before the guilt message below - */ - { - /* minliquid() and mintrap() call mondead() rather than - killed() so we duplicate some of the latter here */ - int tmp, mndx; + /* check for displacing it into pools and traps */ + switch (minliquid(mtmp) ? 2 : mintrap(mtmp)) { + case 0: + break; + case 1: /* trapped */ + case 3: /* changed levels */ + /* there's already been a trap message, reinforce it */ + abuse_dog(mtmp); + adjalign(-3); + break; + case 2: + /* drowned or died... + * you killed your pet by direct action, so get experience + * and possibly penalties; + * we want the level gain message, if it happens, to occur + * before the guilt message below + */ + { + /* minliquid() and mintrap() call mondead() rather than + killed() so we duplicate some of the latter here */ + int tmp, mndx; - u.uconduct.killer++; - mndx = monsndx(mtmp->data); - tmp = experience(mtmp, (int)mvitals[mndx].died); - more_experienced(tmp, 0); - newexplevel(); /* will decide if you go up */ - } - /* That's no way to treat a pet! Your god gets angry. - * - * [This has always been pretty iffy. Why does your - * patron deity care at all, let alone enough to get mad?] - */ - if (rn2(4)) { - You_feel("guilty about losing your pet like this."); - u.ugangr++; - adjalign(-15); - } - break; - default: - pline("that's strange, unknown mintrap result!"); - break; - } - } - } + u.uconduct.killer++; + mndx = monsndx(mtmp->data); + tmp = experience(mtmp, (int)mvitals[mndx].died); + more_experienced(tmp, 0); + newexplevel(); /* will decide if you go up */ + } + /* That's no way to treat a pet! Your god gets angry. + * + * [This has always been pretty iffy. Why does your + * patron deity care at all, let alone enough to get mad?] + */ + if (rn2(4)) { + You_feel("guilty about losing your pet like this."); + u.ugangr++; + adjalign(-15); + } + break; + default: + pline("that's strange, unknown mintrap result!"); + break; + } + } + } - reset_occupations(); - if (context.run) { - if ( context.run < 8 ) - if (IS_DOOR(tmpr->typ) || IS_ROCK(tmpr->typ) || - IS_FURNITURE(tmpr->typ)) - nomul(0); - } + reset_occupations(); + if (context.run) { + if ( context.run < 8 ) + if (IS_DOOR(tmpr->typ) || IS_ROCK(tmpr->typ) || + IS_FURNITURE(tmpr->typ)) + nomul(0); + } - if (hides_under(youmonst.data) || (youmonst.data->mlet == S_EEL) || - u.dx || u.dy) - (void) hideunder(&youmonst); + if (hides_under(youmonst.data) || (youmonst.data->mlet == S_EEL) || + u.dx || u.dy) + (void) hideunder(&youmonst); - /* - * Mimics (or whatever) become noticeable if they move and are - * imitating something that doesn't move. We could extend this - * to non-moving monsters... - */ - if ((u.dx || u.dy) && (youmonst.m_ap_type == M_AP_OBJECT - || youmonst.m_ap_type == M_AP_FURNITURE)) - youmonst.m_ap_type = M_AP_NOTHING; + /* + * Mimics (or whatever) become noticeable if they move and are + * imitating something that doesn't move. We could extend this + * to non-moving monsters... + */ + if ((u.dx || u.dy) && (youmonst.m_ap_type == M_AP_OBJECT + || youmonst.m_ap_type == M_AP_FURNITURE)) + youmonst.m_ap_type = M_AP_NOTHING; - check_leash(u.ux0,u.uy0); + check_leash(u.ux0,u.uy0); - if(u.ux0 != u.ux || u.uy0 != u.uy) { - u.umoved = TRUE; - /* Clean old position -- vision_recalc() will print our new one. */ - newsym(u.ux0,u.uy0); - /* Since the hero has moved, adjust what can be seen/unseen. */ - vision_recalc(1); /* Do the work now in the recover time. */ - invocation_message(); - } + if(u.ux0 != u.ux || u.uy0 != u.uy) { + u.umoved = TRUE; + /* Clean old position -- vision_recalc() will print our new one. */ + newsym(u.ux0,u.uy0); + /* Since the hero has moved, adjust what can be seen/unseen. */ + vision_recalc(1); /* Do the work now in the recover time. */ + invocation_message(); + } - if (Punished) /* put back ball and chain */ - move_bc(0,bc_control,ballx,bally,chainx,chainy); + if (Punished) /* put back ball and chain */ + move_bc(0,bc_control,ballx,bally,chainx,chainy); - spoteffects(TRUE); + spoteffects(TRUE); - /* delay next move because of ball dragging */ - /* must come after we finished picking up, in spoteffects() */ - if (cause_delay) { - nomul(-2); + /* delay next move because of ball dragging */ + /* must come after we finished picking up, in spoteffects() */ + if (cause_delay) { + nomul(-2); multi_reason = "dragging an iron ball"; - nomovemsg = ""; - } + nomovemsg = ""; + } - if (context.run && flags.runmode != RUN_TPORT) { - /* display every step or every 7th step depending upon mode */ - if (flags.runmode != RUN_LEAP || !(moves % 7L)) { - if (flags.time) context.botl = 1; - curs_on_u(); - delay_output(); - if (flags.runmode == RUN_CRAWL) { - delay_output(); - delay_output(); - delay_output(); - delay_output(); - } - } - } + if (context.run && flags.runmode != RUN_TPORT) { + /* display every step or every 7th step depending upon mode */ + if (flags.runmode != RUN_LEAP || !(moves % 7L)) { + if (flags.time) context.botl = 1; + curs_on_u(); + delay_output(); + if (flags.runmode == RUN_CRAWL) { + delay_output(); + delay_output(); + delay_output(); + delay_output(); + } + } + } } /* combat increases metabolism */ @@ -1597,15 +1597,15 @@ overexertion() execute if you decline to attack a peaceful monster */ gethungry(); if ((moves % 3L) != 0L && near_capacity() >= HVY_ENCUMBER) { - int *hp = (!Upolyd ? &u.uhp : &u.mh); + int *hp = (!Upolyd ? &u.uhp : &u.mh); - if (*hp > 1) { - *hp -= 1; - } else { - You("pass out from exertion!"); - exercise(A_CON, FALSE); - fall_asleep(-10, FALSE); - } + if (*hp > 1) { + *hp -= 1; + } else { + You("pass out from exertion!"); + exercise(A_CON, FALSE); + fall_asleep(-10, FALSE); + } } return (multi < 0); /* might have fainted (actually gone to sleep) */ } @@ -1613,22 +1613,22 @@ overexertion() void invocation_message() { - /* a special clue-msg when on the Invocation position */ - if(invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)) { - char buf[BUFSZ]; - struct obj *otmp = carrying(CANDELABRUM_OF_INVOCATION); + /* a special clue-msg when on the Invocation position */ + if(invocation_pos(u.ux, u.uy) && !On_stairs(u.ux, u.uy)) { + char buf[BUFSZ]; + struct obj *otmp = carrying(CANDELABRUM_OF_INVOCATION); - nomul(0); /* stop running or travelling */ - if (u.usteed) Sprintf(buf, "beneath %s", y_monnam(u.usteed)); - else if (Levitation || Flying) Strcpy(buf, "beneath you"); - else Sprintf(buf, "under your %s", makeplural(body_part(FOOT))); + nomul(0); /* stop running or travelling */ + if (u.usteed) Sprintf(buf, "beneath %s", y_monnam(u.usteed)); + else if (Levitation || Flying) Strcpy(buf, "beneath you"); + else Sprintf(buf, "under your %s", makeplural(body_part(FOOT))); - You_feel("a strange vibration %s.", buf); - u.uevent.uvibrated = 1; - if (otmp && otmp->spe == 7 && otmp->lamplit) - pline("%s %s!", The(xname(otmp)), - Blind ? "throbs palpably" : "glows with a strange light"); - } + You_feel("a strange vibration %s.", buf); + u.uevent.uvibrated = 1; + if (otmp && otmp->spe == 7 && otmp->lamplit) + pline("%s %s!", The(xname(otmp)), + Blind ? "throbs palpably" : "glows with a strange light"); + } } /* moving onto different terrain; @@ -1639,27 +1639,27 @@ switch_terrain() { struct rm *lev = &levl[u.ux][u.uy]; boolean blocklev = (IS_ROCK(lev->typ) || closed_door(u.ux, u.uy) || - (Is_waterlevel(&u.uz) && lev->typ == WATER)); + (Is_waterlevel(&u.uz) && lev->typ == WATER)); if (blocklev) { - /* called from spoteffects(), skip float_down() */ - if (Levitation) You_cant("levitate in here."); - BLevitation |= FROMOUTSIDE; + /* called from spoteffects(), skip float_down() */ + if (Levitation) You_cant("levitate in here."); + BLevitation |= FROMOUTSIDE; } else if (BLevitation) { - BLevitation &= ~FROMOUTSIDE; - if (Levitation) float_up(); + BLevitation &= ~FROMOUTSIDE; + if (Levitation) float_up(); } /* the same terrain that blocks levitation also blocks flight */ if (blocklev) { - if (Flying) You_cant("fly in here."); - BFlying |= FROMOUTSIDE; + if (Flying) You_cant("fly in here."); + BFlying |= FROMOUTSIDE; } else if (BFlying) { - BFlying &= ~FROMOUTSIDE; - float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ - /* [minor bug: we don't know whether this is beginning flight or - resuming it; that could be tracked so that this message could - be adjusted to "resume flying", but isn't worth the effort...] */ - if (Flying) You("start flying."); + BFlying &= ~FROMOUTSIDE; + float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ + /* [minor bug: we don't know whether this is beginning flight or + resuming it; that could be tracked so that this message could + be adjusted to "resume flying", but isn't worth the effort...] */ + if (Flying) You("start flying."); } } @@ -1671,67 +1671,67 @@ boolean newspot; /* true if called by spoteffects */ { /* check for leaving water */ if (u.uinwater) { - boolean still_inwater = FALSE; /* assume we're getting out */ + boolean still_inwater = FALSE; /* assume we're getting out */ - if (!is_pool(u.ux,u.uy)) { - if (Is_waterlevel(&u.uz)) - You("pop into an air bubble."); - else if (is_lava(u.ux, u.uy)) - You("leave the water..."); /* oops! */ - else - You("are on solid %s again.", - is_ice(u.ux, u.uy) ? "ice" : "land"); - } else if (Is_waterlevel(&u.uz)) { - still_inwater = TRUE; - } else if (Levitation) { - You("pop out of the water like a cork!"); - } else if (Flying) { - You("fly out of the water."); - } else if (Wwalking) { - You("slowly rise above the surface."); - } else { - still_inwater = TRUE; - } - if (!still_inwater) { - boolean was_underwater = (Underwater && !Is_waterlevel(&u.uz)); + if (!is_pool(u.ux,u.uy)) { + if (Is_waterlevel(&u.uz)) + You("pop into an air bubble."); + else if (is_lava(u.ux, u.uy)) + You("leave the water..."); /* oops! */ + else + You("are on solid %s again.", + is_ice(u.ux, u.uy) ? "ice" : "land"); + } else if (Is_waterlevel(&u.uz)) { + still_inwater = TRUE; + } else if (Levitation) { + You("pop out of the water like a cork!"); + } else if (Flying) { + You("fly out of the water."); + } else if (Wwalking) { + You("slowly rise above the surface."); + } else { + still_inwater = TRUE; + } + if (!still_inwater) { + boolean was_underwater = (Underwater && !Is_waterlevel(&u.uz)); - u.uinwater = 0; /* leave the water */ - if (was_underwater) { /* restore vision */ - docrt(); - vision_full_recalc = 1; - } - } + u.uinwater = 0; /* leave the water */ + if (was_underwater) { /* restore vision */ + docrt(); + vision_full_recalc = 1; + } + } } /* check for entering water or lava */ if (!u.ustuck && !Levitation && !Flying && - is_pool_or_lava(u.ux, u.uy)) { - if (u.usteed && (is_flyer(u.usteed->data) || - is_floater(u.usteed->data) || is_clinger(u.usteed->data))) { - /* floating or clinging steed keeps hero safe (is_flyer() test - is redundant; it can't be true since Flying yielded false) */ - return FALSE; - } else if (u.usteed) { - /* steed enters pool */ - dismount_steed(Underwater ? DISMOUNT_FELL : DISMOUNT_GENERIC); - /* dismount_steed() -> float_down() -> pickup() - (float_down doesn't do autopickup on Air or Water) */ - if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) return FALSE; - /* even if we actually end up at same location, float_down() - has already done spoteffect()'s trap and pickup actions */ - if (newspot) check_special_room(FALSE); /* spoteffects */ - return TRUE; - } - /* not mounted */ + is_pool_or_lava(u.ux, u.uy)) { + if (u.usteed && (is_flyer(u.usteed->data) || + is_floater(u.usteed->data) || is_clinger(u.usteed->data))) { + /* floating or clinging steed keeps hero safe (is_flyer() test + is redundant; it can't be true since Flying yielded false) */ + return FALSE; + } else if (u.usteed) { + /* steed enters pool */ + dismount_steed(Underwater ? DISMOUNT_FELL : DISMOUNT_GENERIC); + /* dismount_steed() -> float_down() -> pickup() + (float_down doesn't do autopickup on Air or Water) */ + if (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)) return FALSE; + /* even if we actually end up at same location, float_down() + has already done spoteffect()'s trap and pickup actions */ + if (newspot) check_special_room(FALSE); /* spoteffects */ + return TRUE; + } + /* not mounted */ - /* drown(),lava_effects() return true if hero changes - location while surviving the problem */ - if (is_lava(u.ux, u.uy)) { - if (lava_effects()) return TRUE; - } else if (!Wwalking && - (newspot || !u.uinwater || !(Swimming || Amphibious))) { - if (drown()) return TRUE; - } + /* drown(),lava_effects() return true if hero changes + location while surviving the problem */ + if (is_lava(u.ux, u.uy)) { + if (lava_effects()) return TRUE; + } else if (!Wwalking && + (newspot || !u.uinwater || !(Swimming || Amphibious))) { + if (drown()) return TRUE; + } } return FALSE; } @@ -1740,142 +1740,142 @@ void spoteffects(pick) boolean pick; { - static int inspoteffects = 0; - static coord spotloc; - static int spotterrain; - static struct trap *spottrap = (struct trap *)0; - static unsigned spottraptyp = NO_TRAP; - struct trap *trap = t_at(u.ux, u.uy); - register struct monst *mtmp; + static int inspoteffects = 0; + static coord spotloc; + static int spotterrain; + static struct trap *spottrap = (struct trap *)0; + static unsigned spottraptyp = NO_TRAP; + struct trap *trap = t_at(u.ux, u.uy); + register struct monst *mtmp; - /* prevent recursion from affecting the hero all over again - [hero poly'd to iron golem enters water here, drown() inflicts - damage that triggers rehumanize() which calls spoteffects()...] */ - if (inspoteffects && u.ux == spotloc.x && u.uy == spotloc.y && - /* except when reason is transformed terrain (ice -> water) */ - spotterrain == levl[u.ux][u.uy].typ && - /* or transformed trap (land mine -> pit) */ - (!spottrap || !trap || trap->ttyp == spottraptyp)) - return; + /* prevent recursion from affecting the hero all over again + [hero poly'd to iron golem enters water here, drown() inflicts + damage that triggers rehumanize() which calls spoteffects()...] */ + if (inspoteffects && u.ux == spotloc.x && u.uy == spotloc.y && + /* except when reason is transformed terrain (ice -> water) */ + spotterrain == levl[u.ux][u.uy].typ && + /* or transformed trap (land mine -> pit) */ + (!spottrap || !trap || trap->ttyp == spottraptyp)) + return; - ++inspoteffects; - spotterrain = levl[u.ux][u.uy].typ; - spotloc.x = u.ux, spotloc.y = u.uy; + ++inspoteffects; + spotterrain = levl[u.ux][u.uy].typ; + spotloc.x = u.ux, spotloc.y = u.uy; - /* moving onto different terrain might cause Levitation to toggle */ - if (spotterrain != levl[u.ux0][u.uy0].typ || !on_level(&u.uz, &u.uz0)) - switch_terrain(); + /* moving onto different terrain might cause Levitation to toggle */ + if (spotterrain != levl[u.ux0][u.uy0].typ || !on_level(&u.uz, &u.uz0)) + switch_terrain(); - if (pooleffects(TRUE)) goto spotdone; + if (pooleffects(TRUE)) goto spotdone; - check_special_room(FALSE); - if(IS_SINK(levl[u.ux][u.uy].typ) && Levitation) - dosinkfall(); - if (!in_steed_dismounting) { /* if dismounting, we'll check again later */ - boolean pit; + check_special_room(FALSE); + if(IS_SINK(levl[u.ux][u.uy].typ) && Levitation) + dosinkfall(); + if (!in_steed_dismounting) { /* if dismounting, we'll check again later */ + boolean pit; - /* if levitation is due to time out at the end of this - turn, allowing it to do so could give the perception - that a trap here is being triggered twice, so adjust - the timeout to prevent that */ - if (trap && (HLevitation & TIMEOUT) == 1L && - !ELevitation && !(HLevitation & ~TIMEOUT)) { - if (rn2(2)) { /* defer timeout */ - incr_itimeout(&HLevitation, 1L); - } else { /* timeout early */ - if (float_down(I_SPECIAL|TIMEOUT, 0L)) { - /* levitation has ended; we've already triggered - any trap and [usually] performed autopickup */ - trap = 0; - pick = FALSE; - } - } - } - /* - * If not a pit, pickup before triggering trap. - * If pit, trigger trap before pickup. - */ - pit = (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)); - if (pick && !pit) (void) pickup(1); + /* if levitation is due to time out at the end of this + turn, allowing it to do so could give the perception + that a trap here is being triggered twice, so adjust + the timeout to prevent that */ + if (trap && (HLevitation & TIMEOUT) == 1L && + !ELevitation && !(HLevitation & ~TIMEOUT)) { + if (rn2(2)) { /* defer timeout */ + incr_itimeout(&HLevitation, 1L); + } else { /* timeout early */ + if (float_down(I_SPECIAL|TIMEOUT, 0L)) { + /* levitation has ended; we've already triggered + any trap and [usually] performed autopickup */ + trap = 0; + pick = FALSE; + } + } + } + /* + * If not a pit, pickup before triggering trap. + * If pit, trigger trap before pickup. + */ + pit = (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)); + if (pick && !pit) (void) pickup(1); - if (trap) { + if (trap) { - /* - * dotrap on a fire trap calls melt_ice() which triggers - * spoteffects() (again) which can trigger the same fire - * trap (again). Use static spottrap to prevent that. - * We track spottraptyp because some traps morph - * (landmine to pit) and any new trap type - * should get triggered. - */ - if (!spottrap || spottraptyp != trap->ttyp) { - spottrap = trap; - spottraptyp = trap->ttyp; - dotrap(trap, 0); /* fall into arrow trap, etc. */ - spottrap = (struct trap *)0; - spottraptyp = NO_TRAP; - } - } - if (pick && pit) (void) pickup(1); - } - /* Warning alerts you to ice danger */ - if (Warning && is_ice(u.ux,u.uy)) { - static const char * const icewarnings[] = { - "The ice seems very soft and slushy.", - "You feel the ice shift beneath you!", - "The ice, is gonna BREAK!", /* The Dead Zone */ - }; - long time_left = spot_time_left(u.ux, u.uy, MELT_ICE_AWAY); - if (time_left && time_left < 15L) - pline1( - (time_left < 5L) ? icewarnings[2] : - (time_left < 10L) ? icewarnings[1] : icewarnings[0]); - } - if((mtmp = m_at(u.ux, u.uy)) && !u.uswallow) { - mtmp->mundetected = mtmp->msleeping = 0; - switch(mtmp->data->mlet) { - case S_PIERCER: - pline("%s suddenly drops from the %s!", - Amonnam(mtmp), ceiling(u.ux,u.uy)); - if(mtmp->mtame) /* jumps to greet you, not attack */ - ; - else if(uarmh && is_metallic(uarmh)) - pline("Its blow glances off your %s.", - helm_simple_name(uarmh)); - else if (u.uac + 3 <= rnd(20)) - You("are almost hit by %s!", - x_monnam(mtmp, ARTICLE_A, "falling", 0, TRUE)); - else { - int dmg; - You("are hit by %s!", - x_monnam(mtmp, ARTICLE_A, "falling", 0, TRUE)); - dmg = d(4,6); - if(Half_physical_damage) dmg = (dmg+1) / 2; - mdamageu(mtmp, dmg); - } - break; - default: /* monster surprises you. */ - if(mtmp->mtame) - pline("%s jumps near you from the %s.", - Amonnam(mtmp), ceiling(u.ux,u.uy)); - else if(mtmp->mpeaceful) { - You("surprise %s!", - Blind && !sensemon(mtmp) ? - something : a_monnam(mtmp)); - mtmp->mpeaceful = 0; - } else - pline("%s attacks you by surprise!", - Amonnam(mtmp)); - break; - } - mnexto(mtmp); /* have to move the monster */ - } + /* + * dotrap on a fire trap calls melt_ice() which triggers + * spoteffects() (again) which can trigger the same fire + * trap (again). Use static spottrap to prevent that. + * We track spottraptyp because some traps morph + * (landmine to pit) and any new trap type + * should get triggered. + */ + if (!spottrap || spottraptyp != trap->ttyp) { + spottrap = trap; + spottraptyp = trap->ttyp; + dotrap(trap, 0); /* fall into arrow trap, etc. */ + spottrap = (struct trap *)0; + spottraptyp = NO_TRAP; + } + } + if (pick && pit) (void) pickup(1); + } + /* Warning alerts you to ice danger */ + if (Warning && is_ice(u.ux,u.uy)) { + static const char * const icewarnings[] = { + "The ice seems very soft and slushy.", + "You feel the ice shift beneath you!", + "The ice, is gonna BREAK!", /* The Dead Zone */ + }; + long time_left = spot_time_left(u.ux, u.uy, MELT_ICE_AWAY); + if (time_left && time_left < 15L) + pline1( + (time_left < 5L) ? icewarnings[2] : + (time_left < 10L) ? icewarnings[1] : icewarnings[0]); + } + if((mtmp = m_at(u.ux, u.uy)) && !u.uswallow) { + mtmp->mundetected = mtmp->msleeping = 0; + switch(mtmp->data->mlet) { + case S_PIERCER: + pline("%s suddenly drops from the %s!", + Amonnam(mtmp), ceiling(u.ux,u.uy)); + if(mtmp->mtame) /* jumps to greet you, not attack */ + ; + else if(uarmh && is_metallic(uarmh)) + pline("Its blow glances off your %s.", + helm_simple_name(uarmh)); + else if (u.uac + 3 <= rnd(20)) + You("are almost hit by %s!", + x_monnam(mtmp, ARTICLE_A, "falling", 0, TRUE)); + else { + int dmg; + You("are hit by %s!", + x_monnam(mtmp, ARTICLE_A, "falling", 0, TRUE)); + dmg = d(4,6); + if(Half_physical_damage) dmg = (dmg+1) / 2; + mdamageu(mtmp, dmg); + } + break; + default: /* monster surprises you. */ + if(mtmp->mtame) + pline("%s jumps near you from the %s.", + Amonnam(mtmp), ceiling(u.ux,u.uy)); + else if(mtmp->mpeaceful) { + You("surprise %s!", + Blind && !sensemon(mtmp) ? + something : a_monnam(mtmp)); + mtmp->mpeaceful = 0; + } else + pline("%s attacks you by surprise!", + Amonnam(mtmp)); + break; + } + mnexto(mtmp); /* have to move the monster */ + } spotdone: - if (!--inspoteffects) { - spotterrain = STONE; /* 0 */ - spotloc.x = spotloc.y = 0; - } - return; + if (!--inspoteffects) { + spotterrain = STONE; /* 0 */ + spotloc.x = spotloc.y = 0; + } + return; } /* returns first matching monster */ @@ -1884,15 +1884,15 @@ monstinroom(mdat,roomno) struct permonst *mdat; int roomno; { - register struct monst *mtmp; + register struct monst *mtmp; - for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if (mtmp->data == mdat && - index(in_rooms(mtmp->mx, mtmp->my, 0), roomno + ROOMOFFSET)) - return mtmp; - } - return (struct monst *)0; + for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if (mtmp->data == mdat && + index(in_rooms(mtmp->mx, mtmp->my, 0), roomno + ROOMOFFSET)) + return mtmp; + } + return (struct monst *)0; } char * @@ -1900,67 +1900,67 @@ in_rooms(x, y, typewanted) register xchar x, y; register int typewanted; { - static char buf[5]; - char rno, *ptr = &buf[4]; - int typefound, min_x, min_y, max_x, max_y_offset, step; - register struct rm *lev; + static char buf[5]; + char rno, *ptr = &buf[4]; + int typefound, min_x, min_y, max_x, max_y_offset, step; + register struct rm *lev; #define goodtype(rno) (!typewanted || \ - ((typefound = rooms[rno - ROOMOFFSET].rtype) == typewanted) || \ - ((typewanted == SHOPBASE) && (typefound > SHOPBASE))) \ + ((typefound = rooms[rno - ROOMOFFSET].rtype) == typewanted) || \ + ((typewanted == SHOPBASE) && (typefound > SHOPBASE))) \ - switch (rno = levl[x][y].roomno) { - case NO_ROOM: - return(ptr); - case SHARED: - step = 2; - break; - case SHARED_PLUS: - step = 1; - break; - default: /* i.e. a regular room # */ - if (goodtype(rno)) - *(--ptr) = rno; - return(ptr); - } + switch (rno = levl[x][y].roomno) { + case NO_ROOM: + return(ptr); + case SHARED: + step = 2; + break; + case SHARED_PLUS: + step = 1; + break; + default: /* i.e. a regular room # */ + if (goodtype(rno)) + *(--ptr) = rno; + return(ptr); + } - min_x = x - 1; - max_x = x + 1; - if (x < 1) - min_x += step; - else - if (x >= COLNO) - max_x -= step; + min_x = x - 1; + max_x = x + 1; + if (x < 1) + min_x += step; + else + if (x >= COLNO) + max_x -= step; - min_y = y - 1; - max_y_offset = 2; - if (min_y < 0) { - min_y += step; - max_y_offset -= step; - } else - if ((min_y + max_y_offset) >= ROWNO) - max_y_offset -= step; + min_y = y - 1; + max_y_offset = 2; + if (min_y < 0) { + min_y += step; + max_y_offset -= step; + } else + if ((min_y + max_y_offset) >= ROWNO) + max_y_offset -= step; - for (x = min_x; x <= max_x; x += step) { - lev = &levl[x][min_y]; - y = 0; - if (((rno = lev[y].roomno) >= ROOMOFFSET) && - !index(ptr, rno) && goodtype(rno)) - *(--ptr) = rno; - y += step; - if (y > max_y_offset) - continue; - if (((rno = lev[y].roomno) >= ROOMOFFSET) && - !index(ptr, rno) && goodtype(rno)) - *(--ptr) = rno; - y += step; - if (y > max_y_offset) - continue; - if (((rno = lev[y].roomno) >= ROOMOFFSET) && - !index(ptr, rno) && goodtype(rno)) - *(--ptr) = rno; - } - return(ptr); + for (x = min_x; x <= max_x; x += step) { + lev = &levl[x][min_y]; + y = 0; + if (((rno = lev[y].roomno) >= ROOMOFFSET) && + !index(ptr, rno) && goodtype(rno)) + *(--ptr) = rno; + y += step; + if (y > max_y_offset) + continue; + if (((rno = lev[y].roomno) >= ROOMOFFSET) && + !index(ptr, rno) && goodtype(rno)) + *(--ptr) = rno; + y += step; + if (y > max_y_offset) + continue; + if (((rno = lev[y].roomno) >= ROOMOFFSET) && + !index(ptr, rno) && goodtype(rno)) + *(--ptr) = rno; + } + return(ptr); } /* is (x,y) in a town? */ @@ -1968,246 +1968,246 @@ boolean in_town(x, y) register int x, y; { - s_level *slev = Is_special(&u.uz); - register struct mkroom *sroom; - boolean has_subrooms = FALSE; + s_level *slev = Is_special(&u.uz); + register struct mkroom *sroom; + boolean has_subrooms = FALSE; - if (!slev || !slev->flags.town) return 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; - } - } + /* + * 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; + return !has_subrooms; } STATIC_OVL void move_update(newlev) register boolean newlev; { - char *ptr1, *ptr2, *ptr3, *ptr4; + char *ptr1, *ptr2, *ptr3, *ptr4; - Strcpy(u.urooms0, u.urooms); - Strcpy(u.ushops0, u.ushops); - if (newlev) { - u.urooms[0] = '\0'; - u.uentered[0] = '\0'; - u.ushops[0] = '\0'; - u.ushops_entered[0] = '\0'; - Strcpy(u.ushops_left, u.ushops0); - return; - } - Strcpy(u.urooms, in_rooms(u.ux, u.uy, 0)); + Strcpy(u.urooms0, u.urooms); + Strcpy(u.ushops0, u.ushops); + if (newlev) { + u.urooms[0] = '\0'; + u.uentered[0] = '\0'; + u.ushops[0] = '\0'; + u.ushops_entered[0] = '\0'; + Strcpy(u.ushops_left, u.ushops0); + return; + } + Strcpy(u.urooms, in_rooms(u.ux, u.uy, 0)); - for (ptr1 = &u.urooms[0], - ptr2 = &u.uentered[0], - ptr3 = &u.ushops[0], - ptr4 = &u.ushops_entered[0]; - *ptr1; ptr1++) { - if (!index(u.urooms0, *ptr1)) - *(ptr2++) = *ptr1; - if (IS_SHOP(*ptr1 - ROOMOFFSET)) { - *(ptr3++) = *ptr1; - if (!index(u.ushops0, *ptr1)) - *(ptr4++) = *ptr1; - } - } - *ptr2 = '\0'; - *ptr3 = '\0'; - *ptr4 = '\0'; + for (ptr1 = &u.urooms[0], + ptr2 = &u.uentered[0], + ptr3 = &u.ushops[0], + ptr4 = &u.ushops_entered[0]; + *ptr1; ptr1++) { + if (!index(u.urooms0, *ptr1)) + *(ptr2++) = *ptr1; + if (IS_SHOP(*ptr1 - ROOMOFFSET)) { + *(ptr3++) = *ptr1; + if (!index(u.ushops0, *ptr1)) + *(ptr4++) = *ptr1; + } + } + *ptr2 = '\0'; + *ptr3 = '\0'; + *ptr4 = '\0'; - /* filter u.ushops0 -> u.ushops_left */ - for (ptr1 = &u.ushops0[0], ptr2 = &u.ushops_left[0]; *ptr1; ptr1++) - if (!index(u.ushops, *ptr1)) - *(ptr2++) = *ptr1; - *ptr2 = '\0'; + /* filter u.ushops0 -> u.ushops_left */ + for (ptr1 = &u.ushops0[0], ptr2 = &u.ushops_left[0]; *ptr1; ptr1++) + if (!index(u.ushops, *ptr1)) + *(ptr2++) = *ptr1; + *ptr2 = '\0'; } void check_special_room(newlev) register boolean newlev; { - register struct monst *mtmp; - char *ptr; + register struct monst *mtmp; + char *ptr; - move_update(newlev); + move_update(newlev); - if (*u.ushops0) - u_left_shop(u.ushops_left, newlev); + if (*u.ushops0) + u_left_shop(u.ushops_left, newlev); - if (!*u.uentered && !*u.ushops_entered) /* implied by newlev */ - return; /* no entrance messages necessary */ + if (!*u.uentered && !*u.ushops_entered) /* implied by newlev */ + return; /* no entrance messages necessary */ - /* Did we just enter a shop? */ - if (*u.ushops_entered) - u_entered_shop(u.ushops_entered); + /* Did we just enter a shop? */ + if (*u.ushops_entered) + u_entered_shop(u.ushops_entered); - for (ptr = &u.uentered[0]; *ptr; ptr++) { - int roomno = *ptr - ROOMOFFSET, - rt = rooms[roomno].rtype; - boolean msg_given = TRUE; + for (ptr = &u.uentered[0]; *ptr; ptr++) { + int roomno = *ptr - ROOMOFFSET, + rt = rooms[roomno].rtype; + boolean msg_given = TRUE; - /* Did we just enter some other special room? */ - /* vault.c insists that a vault remain a VAULT, - * and temples should remain TEMPLEs, - * but everything else gives a message only the first time */ - switch (rt) { - case ZOO: - pline("Welcome to David's treasure zoo!"); - break; - case SWAMP: - pline("It %s rather %s down here.", - Blind ? "feels" : "looks", - Blind ? "humid" : "muddy"); - break; - case COURT: - You("enter an opulent throne room!"); - break; - case LEPREHALL: - You("enter a leprechaun hall!"); - break; - case MORGUE: - if(midnight()) { - const char *run = locomotion(youmonst.data, "Run"); - pline("%s away! %s away!", run, run); - } else - You("have an uncanny feeling..."); - break; - case BEEHIVE: - You("enter a giant beehive!"); - break; - case COCKNEST: - You("enter a disgusting nest!"); - break; - case ANTHOLE: - You("enter an anthole!"); - break; - case BARRACKS: - if(monstinroom(&mons[PM_SOLDIER], roomno) || - monstinroom(&mons[PM_SERGEANT], roomno) || - monstinroom(&mons[PM_LIEUTENANT], roomno) || - monstinroom(&mons[PM_CAPTAIN], roomno)) - You("enter a military barracks!"); - else - You("enter an abandoned barracks."); - break; - case DELPHI: - { - struct monst *oracle = monstinroom(&mons[PM_ORACLE], - roomno); - if (oracle) { - if (!oracle->mpeaceful) - verbalize("You're in Delphi, %s.", - plname); - else - verbalize("%s, %s, welcome to Delphi!", - Hello((struct monst *) 0), plname); - } else - msg_given = FALSE; - break; - } - case TEMPLE: - intemple(roomno + ROOMOFFSET); - /*FALLTHRU*/ - default: - msg_given = (rt == TEMPLE); - rt = 0; - break; - } - if (msg_given) room_discovered(roomno); + /* Did we just enter some other special room? */ + /* vault.c insists that a vault remain a VAULT, + * and temples should remain TEMPLEs, + * but everything else gives a message only the first time */ + switch (rt) { + case ZOO: + pline("Welcome to David's treasure zoo!"); + break; + case SWAMP: + pline("It %s rather %s down here.", + Blind ? "feels" : "looks", + Blind ? "humid" : "muddy"); + break; + case COURT: + You("enter an opulent throne room!"); + break; + case LEPREHALL: + You("enter a leprechaun hall!"); + break; + case MORGUE: + if(midnight()) { + const char *run = locomotion(youmonst.data, "Run"); + pline("%s away! %s away!", run, run); + } else + You("have an uncanny feeling..."); + break; + case BEEHIVE: + You("enter a giant beehive!"); + break; + case COCKNEST: + You("enter a disgusting nest!"); + break; + case ANTHOLE: + You("enter an anthole!"); + break; + case BARRACKS: + if(monstinroom(&mons[PM_SOLDIER], roomno) || + monstinroom(&mons[PM_SERGEANT], roomno) || + monstinroom(&mons[PM_LIEUTENANT], roomno) || + monstinroom(&mons[PM_CAPTAIN], roomno)) + You("enter a military barracks!"); + else + You("enter an abandoned barracks."); + break; + case DELPHI: + { + struct monst *oracle = monstinroom(&mons[PM_ORACLE], + roomno); + if (oracle) { + if (!oracle->mpeaceful) + verbalize("You're in Delphi, %s.", + plname); + else + verbalize("%s, %s, welcome to Delphi!", + Hello((struct monst *) 0), plname); + } else + msg_given = FALSE; + break; + } + case TEMPLE: + intemple(roomno + ROOMOFFSET); + /*FALLTHRU*/ + default: + msg_given = (rt == TEMPLE); + rt = 0; + break; + } + if (msg_given) room_discovered(roomno); - if (rt != 0) { - rooms[roomno].rtype = OROOM; - if (!search_special(rt)) { - /* No more room of that type */ - switch(rt) { - case COURT: - level.flags.has_court = 0; - break; - case SWAMP: - level.flags.has_swamp = 0; - break; - case MORGUE: - level.flags.has_morgue = 0; - break; - case ZOO: - level.flags.has_zoo = 0; - break; - case BARRACKS: - level.flags.has_barracks = 0; - break; - case TEMPLE: - level.flags.has_temple = 0; - break; - case BEEHIVE: - level.flags.has_beehive = 0; - break; - } - } - if (rt == COURT || rt == SWAMP || rt == MORGUE || rt == ZOO) - for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if (!Stealth && !rn2(3)) - mtmp->msleeping = 0; - } - } - } + if (rt != 0) { + rooms[roomno].rtype = OROOM; + if (!search_special(rt)) { + /* No more room of that type */ + switch(rt) { + case COURT: + level.flags.has_court = 0; + break; + case SWAMP: + level.flags.has_swamp = 0; + break; + case MORGUE: + level.flags.has_morgue = 0; + break; + case ZOO: + level.flags.has_zoo = 0; + break; + case BARRACKS: + level.flags.has_barracks = 0; + break; + case TEMPLE: + level.flags.has_temple = 0; + break; + case BEEHIVE: + level.flags.has_beehive = 0; + break; + } + } + if (rt == COURT || rt == SWAMP || rt == MORGUE || rt == ZOO) + for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if (!Stealth && !rn2(3)) + mtmp->msleeping = 0; + } + } + } - return; + return; } int dopickup() { - int count; - struct trap *traphere = t_at(u.ux, u.uy); - /* awful kludge to work around parse()'s pre-decrement */ - count = (multi || (save_cm && *save_cm == ',')) ? multi + 1 : 0; - multi = 0; /* always reset */ - /* uswallow case added by GAN 01/29/87 */ - if(u.uswallow) { - if (!u.ustuck->minvent) { - if (is_animal(u.ustuck->data)) { - You("pick up %s tongue.", s_suffix(mon_nam(u.ustuck))); - pline("But it's kind of slimy, so you drop it."); - } else - You("don't %s anything in here to pick up.", - Blind ? "feel" : "see"); - return(1); - } else { - int tmpcount = -count; - return loot_mon(u.ustuck, &tmpcount, (boolean *)0); - } - } - if(is_pool(u.ux, u.uy)) { - if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data) - || (Flying && !Breathless)) { - You("cannot dive into the water to pick things up."); - return(0); - } else if (!Underwater) { - You_cant("even see the bottom, let alone pick up %s.", - something); - return(0); - } - } - if (is_lava(u.ux, u.uy)) { - if (Wwalking || is_floater(youmonst.data) || - is_clinger(youmonst.data) || (Flying && !Breathless)) { - You_cant("reach the bottom to pick things up."); - return(0); - } else if (!likes_lava(youmonst.data)) { - You("would burn to a crisp trying to pick things up."); - return(0); - } - } - if (!OBJ_AT(u.ux, u.uy)) { + int count; + struct trap *traphere = t_at(u.ux, u.uy); + /* awful kludge to work around parse()'s pre-decrement */ + count = (multi || (save_cm && *save_cm == ',')) ? multi + 1 : 0; + multi = 0; /* always reset */ + /* uswallow case added by GAN 01/29/87 */ + if(u.uswallow) { + if (!u.ustuck->minvent) { + if (is_animal(u.ustuck->data)) { + You("pick up %s tongue.", s_suffix(mon_nam(u.ustuck))); + pline("But it's kind of slimy, so you drop it."); + } else + You("don't %s anything in here to pick up.", + Blind ? "feel" : "see"); + return(1); + } else { + int tmpcount = -count; + return loot_mon(u.ustuck, &tmpcount, (boolean *)0); + } + } + if(is_pool(u.ux, u.uy)) { + if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data) + || (Flying && !Breathless)) { + You("cannot dive into the water to pick things up."); + return(0); + } else if (!Underwater) { + You_cant("even see the bottom, let alone pick up %s.", + something); + return(0); + } + } + if (is_lava(u.ux, u.uy)) { + if (Wwalking || is_floater(youmonst.data) || + is_clinger(youmonst.data) || (Flying && !Breathless)) { + You_cant("reach the bottom to pick things up."); + return(0); + } else if (!likes_lava(youmonst.data)) { + You("would burn to a crisp trying to pick things up."); + return(0); + } + } + if (!OBJ_AT(u.ux, u.uy)) { register struct rm *lev = &levl[u.ux][u.uy]; if (IS_THRONE(lev->typ)) pline("It must weigh%s a ton!", @@ -2221,21 +2221,21 @@ dopickup() else if (IS_DOOR(lev->typ) && (lev->doormask & D_ISOPEN)) pline("It won't come off the hinges."); else There("is nothing here to pick up."); - return 0; - } - if (!can_reach_floor(TRUE)) { - if (traphere && uteetering_at_seen_pit(traphere)) - You("cannot reach the bottom of the pit."); - else if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) - rider_cant_reach(); - else if (Blind && !can_reach_floor(TRUE)) - You("cannot reach anything here."); - else - You("cannot reach the %s.", surface(u.ux,u.uy)); - return 0; - } + return 0; + } + if (!can_reach_floor(TRUE)) { + if (traphere && uteetering_at_seen_pit(traphere)) + You("cannot reach the bottom of the pit."); + else if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) + rider_cant_reach(); + else if (Blind && !can_reach_floor(TRUE)) + You("cannot reach anything here."); + else + You("cannot reach the %s.", surface(u.ux,u.uy)); + return 0; + } - return (pickup(-count)); + return (pickup(-count)); } /* stop running if we see something interesting */ @@ -2252,115 +2252,115 @@ lookaround() /* Grid bugs stop if trying to move diagonal, even if blind. Maybe */ /* they polymorphed while in the middle of a long move. */ if (u.umonnum == PM_GRID_BUG && u.dx && u.dy) { - nomul(0); - return; + nomul(0); + return; } if(Blind || context.run == 0) return; for(x = u.ux-1; x <= u.ux+1; x++) for(y = u.uy-1; y <= u.uy+1; y++) { - if(!isok(x,y)) continue; + if(!isok(x,y)) continue; - if(u.umonnum == PM_GRID_BUG && x != u.ux && y != u.uy) continue; + if(u.umonnum == PM_GRID_BUG && x != u.ux && y != u.uy) continue; - if(x == u.ux && y == u.uy) continue; + if(x == u.ux && y == u.uy) continue; - if((mtmp = m_at(x,y)) && - mtmp->m_ap_type != M_AP_FURNITURE && - mtmp->m_ap_type != M_AP_OBJECT && - (!mtmp->minvis || See_invisible) && !mtmp->mundetected) { - if((context.run != 1 && !mtmp->mtame) - || (x == u.ux+u.dx && y == u.uy+u.dy)) - goto stop; - } + if((mtmp = m_at(x,y)) && + mtmp->m_ap_type != M_AP_FURNITURE && + mtmp->m_ap_type != M_AP_OBJECT && + (!mtmp->minvis || See_invisible) && !mtmp->mundetected) { + if((context.run != 1 && !mtmp->mtame) + || (x == u.ux+u.dx && y == u.uy+u.dy)) + goto stop; + } - if (levl[x][y].typ == STONE) continue; - if (x == u.ux-u.dx && y == u.uy-u.dy) continue; + if (levl[x][y].typ == STONE) continue; + if (x == u.ux-u.dx && y == u.uy-u.dy) continue; - if (IS_ROCK(levl[x][y].typ) || (levl[x][y].typ == ROOM) || - IS_AIR(levl[x][y].typ)) - continue; - else if (closed_door(x,y) || - (mtmp && mtmp->m_ap_type == M_AP_FURNITURE && - (mtmp->mappearance == S_hcdoor || - mtmp->mappearance == S_vcdoor))) { - if(x != u.ux && y != u.uy) continue; - if(context.run != 1) goto stop; - goto bcorr; - } else if (levl[x][y].typ == CORR) { + if (IS_ROCK(levl[x][y].typ) || (levl[x][y].typ == ROOM) || + IS_AIR(levl[x][y].typ)) + continue; + else if (closed_door(x,y) || + (mtmp && mtmp->m_ap_type == M_AP_FURNITURE && + (mtmp->mappearance == S_hcdoor || + mtmp->mappearance == S_vcdoor))) { + if(x != u.ux && y != u.uy) continue; + if(context.run != 1) goto stop; + goto bcorr; + } else if (levl[x][y].typ == CORR) { bcorr: - if(levl[u.ux][u.uy].typ != ROOM) { - if(context.run == 1 || context.run == 3 || context.run == 8) { - i = dist2(x,y,u.ux+u.dx,u.uy+u.dy); - if(i > 2) continue; - if(corrct == 1 && dist2(x,y,x0,y0) != 1) - noturn = 1; - if(i < i0) { - i0 = i; - x0 = x; - y0 = y; - m0 = mtmp ? 1 : 0; - } - } - corrct++; - } - continue; - } else if ((trap = t_at(x,y)) && trap->tseen) { - if(context.run == 1) goto bcorr; /* if you must */ - if(x == u.ux+u.dx && y == u.uy+u.dy) goto stop; - continue; - } else if (is_pool_or_lava(x,y)) { - /* water and lava only stop you if directly in front, and stop - * you even if you are running - */ - if(!Levitation && !Flying && !is_clinger(youmonst.data) && - x == u.ux+u.dx && y == u.uy+u.dy) - /* No Wwalking check; otherwise they'd be able - * to test boots by trying to SHIFT-direction - * into a pool and seeing if the game allowed it - */ - goto stop; - continue; - } else { /* e.g. objects or trap or stairs */ - if(context.run == 1) goto bcorr; - if(context.run == 8) continue; - if(mtmp) continue; /* d */ - if(((x == u.ux - u.dx) && (y != u.uy + u.dy)) || - ((y == u.uy - u.dy) && (x != u.ux + u.dx))) - continue; - } + if(levl[u.ux][u.uy].typ != ROOM) { + if(context.run == 1 || context.run == 3 || context.run == 8) { + i = dist2(x,y,u.ux+u.dx,u.uy+u.dy); + if(i > 2) continue; + if(corrct == 1 && dist2(x,y,x0,y0) != 1) + noturn = 1; + if(i < i0) { + i0 = i; + x0 = x; + y0 = y; + m0 = mtmp ? 1 : 0; + } + } + corrct++; + } + continue; + } else if ((trap = t_at(x,y)) && trap->tseen) { + if(context.run == 1) goto bcorr; /* if you must */ + if(x == u.ux+u.dx && y == u.uy+u.dy) goto stop; + continue; + } else if (is_pool_or_lava(x,y)) { + /* water and lava only stop you if directly in front, and stop + * you even if you are running + */ + if(!Levitation && !Flying && !is_clinger(youmonst.data) && + x == u.ux+u.dx && y == u.uy+u.dy) + /* No Wwalking check; otherwise they'd be able + * to test boots by trying to SHIFT-direction + * into a pool and seeing if the game allowed it + */ + goto stop; + continue; + } else { /* e.g. objects or trap or stairs */ + if(context.run == 1) goto bcorr; + if(context.run == 8) continue; + if(mtmp) continue; /* d */ + if(((x == u.ux - u.dx) && (y != u.uy + u.dy)) || + ((y == u.uy - u.dy) && (x != u.ux + u.dx))) + continue; + } stop: - nomul(0); - return; + nomul(0); + return; } /* end for loops */ if(corrct > 1 && context.run == 2) goto stop; if((context.run == 1 || context.run == 3 || context.run == 8) && - !noturn && !m0 && i0 && (corrct == 1 || (corrct == 2 && i0 == 1))) + !noturn && !m0 && i0 && (corrct == 1 || (corrct == 2 && i0 == 1))) { - /* make sure that we do not turn too far */ - if(i0 == 2) { - if(u.dx == y0-u.uy && u.dy == u.ux-x0) - i = 2; /* straight turn right */ - else - i = -2; /* straight turn left */ - } else if(u.dx && u.dy) { - if((u.dx == u.dy && y0 == u.uy) || (u.dx != u.dy && y0 != u.uy)) - i = -1; /* half turn left */ - else - i = 1; /* half turn right */ - } else { - if((x0-u.ux == y0-u.uy && !u.dy) || (x0-u.ux != y0-u.uy && u.dy)) - i = 1; /* half turn right */ - else - i = -1; /* half turn left */ - } + /* make sure that we do not turn too far */ + if(i0 == 2) { + if(u.dx == y0-u.uy && u.dy == u.ux-x0) + i = 2; /* straight turn right */ + else + i = -2; /* straight turn left */ + } else if(u.dx && u.dy) { + if((u.dx == u.dy && y0 == u.uy) || (u.dx != u.dy && y0 != u.uy)) + i = -1; /* half turn left */ + else + i = 1; /* half turn right */ + } else { + if((x0-u.ux == y0-u.uy && !u.dy) || (x0-u.ux != y0-u.uy && u.dy)) + i = 1; /* half turn right */ + else + i = -1; /* half turn left */ + } - i += u.last_str_turn; - if(i <= 2 && i >= -2) { - u.last_str_turn = i; - u.dx = x0-u.ux; - u.dy = y0-u.uy; - } + i += u.last_str_turn; + if(i <= 2 && i >= -2) { + u.last_str_turn = i; + u.dx = x0-u.ux; + u.dy = y0-u.uy; + } } } @@ -2394,10 +2394,10 @@ int x, y; if (Passes_walls) return TRUE; /* or a xorn... */ /* pool could be next to a door, conceivably even inside a shop */ if (IS_DOOR(levl[x][y].typ) && (!doorless_door(x, y) || block_door(x, y))) - return FALSE; + return FALSE; /* finally, are we trying to squeeze through a too-narrow gap? */ return !(bad_rock(youmonst.data, u.ux, y) && - bad_rock(youmonst.data, x, u.uy)); + bad_rock(youmonst.data, x, u.uy)); } /* something like lookaround, but we are not running */ @@ -2405,38 +2405,38 @@ int x, y; int monster_nearby() { - register int x,y; - register struct monst *mtmp; + register int x,y; + register struct monst *mtmp; - /* Also see the similar check in dochugw() in monmove.c */ - for(x = u.ux-1; x <= u.ux+1; x++) - for(y = u.uy-1; y <= u.uy+1; y++) { - if(!isok(x,y)) continue; - if(x == u.ux && y == u.uy) continue; - if((mtmp = m_at(x,y)) && - mtmp->m_ap_type != M_AP_FURNITURE && - mtmp->m_ap_type != M_AP_OBJECT && - (!mtmp->mpeaceful || Hallucination) && - (!is_hider(mtmp->data) || !mtmp->mundetected) && - !noattacks(mtmp->data) && - mtmp->mcanmove && !mtmp->msleeping && /* aplvax!jcn */ - !onscary(u.ux, u.uy, mtmp) && - canspotmon(mtmp)) - return(1); - } - return(0); + /* Also see the similar check in dochugw() in monmove.c */ + for(x = u.ux-1; x <= u.ux+1; x++) + for(y = u.uy-1; y <= u.uy+1; y++) { + if(!isok(x,y)) continue; + if(x == u.ux && y == u.uy) continue; + if((mtmp = m_at(x,y)) && + mtmp->m_ap_type != M_AP_FURNITURE && + mtmp->m_ap_type != M_AP_OBJECT && + (!mtmp->mpeaceful || Hallucination) && + (!is_hider(mtmp->data) || !mtmp->mundetected) && + !noattacks(mtmp->data) && + mtmp->mcanmove && !mtmp->msleeping && /* aplvax!jcn */ + !onscary(u.ux, u.uy, mtmp) && + canspotmon(mtmp)) + return(1); + } + return(0); } void nomul(nval) - register int nval; + register int nval; { - if(multi < nval) return; /* This is a bug fix by ab@unido */ - u.uinvulnerable = FALSE; /* Kludge to avoid ctrl-C bug -dlc */ - u.usleep = 0; - multi = nval; + if(multi < nval) return; /* This is a bug fix by ab@unido */ + u.uinvulnerable = FALSE; /* Kludge to avoid ctrl-C bug -dlc */ + u.usleep = 0; + multi = nval; if (nval == 0) multi_reason = NULL; - context.travel = context.travel1 = context.mv = context.run = 0; + context.travel = context.travel1 = context.mv = context.run = 0; } /* called when a non-movement, multi-turn action has completed */ @@ -2444,45 +2444,45 @@ void unmul(msg_override) const char *msg_override; { - multi = 0; /* caller will usually have done this already */ - if (msg_override) nomovemsg = msg_override; - else if (!nomovemsg) nomovemsg = You_can_move_again; - if (*nomovemsg) pline1(nomovemsg); - nomovemsg = 0; - u.usleep = 0; + multi = 0; /* caller will usually have done this already */ + if (msg_override) nomovemsg = msg_override; + else if (!nomovemsg) nomovemsg = You_can_move_again; + if (*nomovemsg) pline1(nomovemsg); + nomovemsg = 0; + u.usleep = 0; multi_reason = NULL; - if (afternmv) (*afternmv)(); - afternmv = 0; + if (afternmv) (*afternmv)(); + afternmv = 0; } STATIC_OVL void maybe_wail() { static short powers[] = { TELEPORT, SEE_INVIS, POISON_RES, COLD_RES, - SHOCK_RES, FIRE_RES, SLEEP_RES, DISINT_RES, - TELEPORT_CONTROL, STEALTH, FAST, INVIS }; + SHOCK_RES, FIRE_RES, SLEEP_RES, DISINT_RES, + TELEPORT_CONTROL, STEALTH, FAST, INVIS }; if (moves <= wailmsg + 50) return; wailmsg = moves; if (Role_if(PM_WIZARD) || Race_if(PM_ELF) || Role_if(PM_VALKYRIE)) { - const char *who; - int i, powercnt; + const char *who; + int i, powercnt; - who = (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ? - urole.name.m : "Elf"; - if (u.uhp == 1) { - pline("%s is about to die.", who); - } else { - for (i = 0, powercnt = 0; i < SIZE(powers); ++i) - if (u.uprops[powers[i]].intrinsic & INTRINSIC) ++powercnt; - - pline(powercnt >= 4 ? "%s, all your powers will be lost..." - : "%s, your life force is running out.", who); - } + who = (Role_if(PM_WIZARD) || Role_if(PM_VALKYRIE)) ? + urole.name.m : "Elf"; + if (u.uhp == 1) { + pline("%s is about to die.", who); } else { - You_hear(u.uhp == 1 ? "the wailing of the Banshee..." - : "the howling of the CwnAnnwn..."); + for (i = 0, powercnt = 0; i < SIZE(powers); ++i) + if (u.uprops[powers[i]].intrinsic & INTRINSIC) ++powercnt; + + pline(powercnt >= 4 ? "%s, all your powers will be lost..." + : "%s, your life force is running out.", who); + } + } else { + You_hear(u.uhp == 1 ? "the wailing of the Banshee..." + : "the howling of the CwnAnnwn..."); } } @@ -2492,62 +2492,62 @@ register int n; register const char *knam; boolean k_format; { - if (Upolyd) { - u.mh -= n; - if (u.mhmax < u.mh) u.mhmax = u.mh; - context.botl = 1; - if (u.mh < 1) - rehumanize(); - else if (n > 0 && u.mh*10 < u.mhmax && Unchanging) - maybe_wail(); - return; - } + if (Upolyd) { + u.mh -= n; + if (u.mhmax < u.mh) u.mhmax = u.mh; + context.botl = 1; + if (u.mh < 1) + rehumanize(); + else if (n > 0 && u.mh*10 < u.mhmax && Unchanging) + maybe_wail(); + return; + } - u.uhp -= n; - if(u.uhp > u.uhpmax) - u.uhpmax = u.uhp; /* perhaps n was negative */ - context.botl = 1; - if(u.uhp < 1) { - killer.format = k_format; - if (killer.name != knam) /* the thing that killed you */ - Strcpy(killer.name, knam ? knam : ""); - You("die..."); - done(DIED); - } else if (n > 0 && u.uhp*10 < u.uhpmax) { - maybe_wail(); - } + u.uhp -= n; + if(u.uhp > u.uhpmax) + u.uhpmax = u.uhp; /* perhaps n was negative */ + context.botl = 1; + if(u.uhp < 1) { + killer.format = k_format; + if (killer.name != knam) /* the thing that killed you */ + Strcpy(killer.name, knam ? knam : ""); + You("die..."); + done(DIED); + } else if (n > 0 && u.uhp*10 < u.uhpmax) { + maybe_wail(); + } } int weight_cap() { - register long carrcap; + register long carrcap; - carrcap = 25*(ACURRSTR + ACURR(A_CON)) + 50; - if (Upolyd) { - /* consistent with can_carry() in mon.c */ - if (youmonst.data->mlet == S_NYMPH) - carrcap = MAX_CARR_CAP; - else if (!youmonst.data->cwt) - carrcap = (carrcap * (long)youmonst.data->msize) / MZ_HUMAN; - else if (!strongmonst(youmonst.data) - || (strongmonst(youmonst.data) && (youmonst.data->cwt > WT_HUMAN))) - carrcap = (carrcap * (long)youmonst.data->cwt / WT_HUMAN); - } + carrcap = 25*(ACURRSTR + ACURR(A_CON)) + 50; + if (Upolyd) { + /* consistent with can_carry() in mon.c */ + if (youmonst.data->mlet == S_NYMPH) + carrcap = MAX_CARR_CAP; + else if (!youmonst.data->cwt) + carrcap = (carrcap * (long)youmonst.data->msize) / MZ_HUMAN; + else if (!strongmonst(youmonst.data) + || (strongmonst(youmonst.data) && (youmonst.data->cwt > WT_HUMAN))) + carrcap = (carrcap * (long)youmonst.data->cwt / WT_HUMAN); + } - if (Levitation || Is_airlevel(&u.uz) /* pugh@cornell */ - || (u.usteed && strongmonst(u.usteed->data)) - ) - carrcap = MAX_CARR_CAP; - else { - if(carrcap > MAX_CARR_CAP) carrcap = MAX_CARR_CAP; - if (!Flying) { - if(EWounded_legs & LEFT_SIDE) carrcap -= 100; - if(EWounded_legs & RIGHT_SIDE) carrcap -= 100; - } - if (carrcap < 0) carrcap = 0; - } - return((int) carrcap); + if (Levitation || Is_airlevel(&u.uz) /* pugh@cornell */ + || (u.usteed && strongmonst(u.usteed->data)) + ) + carrcap = MAX_CARR_CAP; + else { + if(carrcap > MAX_CARR_CAP) carrcap = MAX_CARR_CAP; + if (!Flying) { + if(EWounded_legs & LEFT_SIDE) carrcap -= 100; + if(EWounded_legs & RIGHT_SIDE) carrcap -= 100; + } + if (carrcap < 0) carrcap = 0; + } + return((int) carrcap); } static int wc; /* current weight_cap(); valid after call to inv_weight() */ @@ -2557,18 +2557,18 @@ static int wc; /* current weight_cap(); valid after call to inv_weight() */ int inv_weight() { - register struct obj *otmp = invent; - register int wt = 0; + register struct obj *otmp = invent; + register int wt = 0; - while (otmp) { - if (otmp->oclass == COIN_CLASS) - wt += (int)(((long)otmp->quan + 50L) / 100L); - else if (otmp->otyp != BOULDER || !throws_rocks(youmonst.data)) - wt += otmp->owt; - otmp = otmp->nobj; - } - wc = weight_cap(); - return (wt - wc); + while (otmp) { + if (otmp->oclass == COIN_CLASS) + wt += (int)(((long)otmp->quan + 50L) / 100L); + else if (otmp->otyp != BOULDER || !throws_rocks(youmonst.data)) + wt += otmp->owt; + otmp = otmp->nobj; + } + wc = weight_cap(); + return (wt - wc); } /* @@ -2606,11 +2606,11 @@ check_capacity(str) const char *str; { if(near_capacity() >= EXT_ENCUMBER) { - if(str) - pline1(str); - else - You_cant("do that while carrying so much stuff."); - return 1; + if(str) + pline1(str); + else + You_cant("do that while carrying so much stuff."); + return 1; } return 0; } @@ -2619,14 +2619,14 @@ int inv_cnt(incl_gold) boolean incl_gold; { - register struct obj *otmp = invent; - register int ct = 0; + register struct obj *otmp = invent; + register int ct = 0; - while(otmp){ - if (incl_gold || otmp->invlet != GOLD_SYM) ct++; - otmp = otmp->nobj; - } - return(ct); + while(otmp){ + if (incl_gold || otmp->invlet != GOLD_SYM) ct++; + otmp = otmp->nobj; + } + return(ct); } /* Counts the money in an object chain. */ @@ -2638,9 +2638,9 @@ money_cnt(otmp) struct obj *otmp; { while (otmp) { - /* Must change when silver & copper is implemented: */ - if (otmp->oclass == COIN_CLASS) return otmp->quan; - otmp = otmp->nobj; + /* Must change when silver & copper is implemented: */ + if (otmp->oclass == COIN_CLASS) return otmp->quan; + otmp = otmp->nobj; } return 0L; } diff --git a/src/hacklib.c b/src/hacklib.c index 1ad5028a9..e0806027f 100644 --- a/src/hacklib.c +++ b/src/hacklib.c @@ -1,15 +1,15 @@ -/* NetHack 3.5 hacklib.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 hacklib.c $NHDT-Date: 1428806394 2015/04/12 02:39:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */ /* NetHack 3.5 hacklib.c $Date: 2009/05/06 10:46:32 $ $Revision: 1.23 $ */ /* SCCS Id: @(#)hacklib.c 3.5 2007/04/30 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Robert Patrick Rankin, 1991 */ /* NetHack may be freely redistributed. See license for details. */ -/* We could include only config.h, except for the overlay definitions... */ -#include "hack.h" +#include "hack.h" /* for config.h+extern.h */ /*= Assorted 'small' utility routines. They're virtually independent of -NetHack, except that rounddiv may call panic(). +NetHack, except that rounddiv may call panic(). setrandom calls one of +srandom(), srand48(), or srand() depending upon configuration. return type routine name argument type(s) boolean digit (char) @@ -40,9 +40,12 @@ NetHack, except that rounddiv may call panic(). int dist2 (int, int, int, int) boolean online2 (int, int) boolean pmatch (const char *, const char *) + boolean pmatchi (const char *, const char *) + boolean pmatchz (const char *, const char *) int strncmpi (const char *, const char *, int) char * strstri (const char *, const char *) - boolean fuzzymatch (const char *,const char *,const char *,boolean) + boolean fuzzymatch (const char *,const char *, + const char *,boolean) void setrandom (void) time_t getnow (void) int getyear (void) @@ -62,6 +65,9 @@ NetHack, except that rounddiv may call panic(). # define Static static #endif +static boolean FDECL(pmatch_internal, (const char *,const char *, + BOOLEAN_P,const char *)); + boolean digit(c) /* is 'c' a digit? */ char c; @@ -465,9 +471,12 @@ online2(x0, y0, x1, y1) /* are two points lined up (on a straight line)? */ return((boolean)(!dy || !dx || (dy == dx) || (dy + dx == 0))); /* (dy == -dx) */ } -boolean -pmatch(patrn, strng) /* match a string against a pattern */ +/* guts of pmatch(), pmatchi(), and pmatchz() */ +static boolean +pmatch_internal(patrn, strng, ci, sk) /* match a string against a pattern */ const char *patrn, *strng; + boolean ci; /* True => case-insensitive, False => case-sensitive */ + const char *sk; /* set of characters to skip */ { char s, p; /* @@ -475,18 +484,53 @@ pmatch(patrn, strng) /* match a string against a pattern */ : any single character. Returns TRUE if 'strng' matches 'patrn'. */ pmatch_top: - s = *strng++; p = *patrn++; /* get next chars and pre-advance */ + if (!sk) { + s = *strng++; p = *patrn++; /* get next chars and pre-advance */ + } else { + /* fuzzy match variant of pmatch; particular characters are ignored */ + do { s = *strng++; } while (index(sk, s)); + do { p = *patrn++; } while (index(sk, p)); + } if (!p) /* end of pattern */ - return((boolean)(s == '\0')); /* matches iff end of string too */ + return (boolean)(s == '\0'); /* matches iff end of string too */ else if (p == '*') /* wildcard reached */ - return((boolean)((!*patrn || pmatch(patrn, strng-1)) ? TRUE : - s ? pmatch(patrn-1, strng) : FALSE)); - else if (p != s && (p != '?' || !s)) /* check single character */ + return (boolean) + ((!*patrn || pmatch_internal(patrn, strng-1, ci, sk)) ? TRUE : + s ? pmatch_internal(patrn-1, strng, ci, sk) : FALSE); + else if ((ci ? lowc(p) != lowc(s) : p != s) /* check single character */ + && (p != '?' || !s)) /* & single-char wildcard */ return FALSE; /* doesn't match */ - else /* return pmatch(patrn, strng); */ + else /* return pmatch_internal(patrn, strng, ci, sk); */ goto pmatch_top; /* optimize tail recursion */ } +/* case-sensitive wildcard match */ +boolean +pmatch(patrn, strng) + const char *patrn, *strng; +{ + return pmatch_internal(patrn, strng, FALSE, (const char *)0); +} + +/* case-insensitive wildcard match */ +boolean +pmatchi(patrn, strng) + const char *patrn, *strng; +{ + return pmatch_internal(patrn, strng, TRUE, (const char *)0); +} + +/* case-insensitive wildcard fuzzymatch */ +boolean +pmatchz(patrn, strng) + const char *patrn, *strng; +{ + /* ignore spaces, tabs (just in case), dashes, and underscores */ + static const char fuzzychars[] = " \t-_"; + + return pmatch_internal(patrn, strng, TRUE, fuzzychars); +} + #ifndef STRNCMPI int strncmpi(s1, s2, n) /* case insensitive counted string comparison */ @@ -603,7 +647,7 @@ STATIC_DCL struct tm *NDECL(getlt); void setrandom() { - unsigned long seed = getnow(); /* time((TIME_type) 0) */ + unsigned long seed = (unsigned long)getnow(); /* time((TIME_type) 0) */ #ifdef UNIX /* Quick dirty band-aid to prevent PRNG prediction */ seed *= getpid(); diff --git a/src/invent.c b/src/invent.c index 8f4515551..9e4041603 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,3 @@ -/* NetHack 3.5 invent.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ /* NetHack 3.5 invent.c $Date: 2013/11/05 00:57:55 $ $Revision: 1.125 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -129,33 +128,33 @@ void assigninvlet(otmp) register struct obj *otmp; { - boolean inuse[52]; - register int i; - register struct obj *obj; + boolean inuse[52]; + register int i; + register struct obj *obj; - /* there should be at most one of these in inventory... */ - if (otmp->oclass == COIN_CLASS) { - otmp->invlet = GOLD_SYM; - return; - } + /* there should be at most one of these in inventory... */ + if (otmp->oclass == COIN_CLASS) { + otmp->invlet = GOLD_SYM; + return; + } - for(i = 0; i < 52; i++) inuse[i] = FALSE; - for(obj = invent; obj; obj = obj->nobj) if(obj != otmp) { - i = obj->invlet; - if('a' <= i && i <= 'z') inuse[i - 'a'] = TRUE; else - if('A' <= i && i <= 'Z') inuse[i - 'A' + 26] = TRUE; - if(i == otmp->invlet) otmp->invlet = 0; - } - if((i = otmp->invlet) && - (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) - return; - for(i = lastinvnr+1; i != lastinvnr; i++) { - if(i == 52) { i = -1; continue; } - if(!inuse[i]) break; - } - otmp->invlet = (inuse[i] ? NOINVSYM : - (i < 26) ? ('a'+i) : ('A'+i-26)); - lastinvnr = i; + for(i = 0; i < 52; i++) inuse[i] = FALSE; + for(obj = invent; obj; obj = obj->nobj) if(obj != otmp) { + i = obj->invlet; + if('a' <= i && i <= 'z') inuse[i - 'a'] = TRUE; else + if('A' <= i && i <= 'Z') inuse[i - 'A' + 26] = TRUE; + if(i == otmp->invlet) otmp->invlet = 0; + } + if((i = otmp->invlet) && + (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z'))) + return; + for(i = lastinvnr+1; i != lastinvnr; i++) { + if(i == 52) { i = -1; continue; } + if(!inuse[i]) break; + } + otmp->invlet = (inuse[i] ? NOINVSYM : + (i < 26) ? ('a'+i) : ('A'+i-26)); + lastinvnr = i; } /* note: assumes ASCII; toggling a bit puts lowercase in front of uppercase */ @@ -165,30 +164,30 @@ register struct obj *otmp; STATIC_OVL void reorder_invent() { - struct obj *otmp, *prev, *next; - boolean need_more_sorting; + struct obj *otmp, *prev, *next; + boolean need_more_sorting; - do { - /* - * We expect at most one item to be out of order, so this - * isn't nearly as inefficient as it may first appear. - */ - need_more_sorting = FALSE; - for (otmp = invent, prev = 0; otmp; ) { - next = otmp->nobj; - if (next && inv_rank(next) < inv_rank(otmp)) { - need_more_sorting = TRUE; - if (prev) prev->nobj = next; - else invent = next; - otmp->nobj = next->nobj; - next->nobj = otmp; - prev = next; - } else { - prev = otmp; - otmp = next; - } - } - } while (need_more_sorting); + do { + /* + * We expect at most one item to be out of order, so this + * isn't nearly as inefficient as it may first appear. + */ + need_more_sorting = FALSE; + for (otmp = invent, prev = 0; otmp; ) { + next = otmp->nobj; + if (next && inv_rank(next) < inv_rank(otmp)) { + need_more_sorting = TRUE; + if (prev) prev->nobj = next; + else invent = next; + otmp->nobj = next->nobj; + next->nobj = otmp; + prev = next; + } else { + prev = otmp; + otmp = next; + } + } + } while (need_more_sorting); } #undef inv_rank @@ -200,33 +199,33 @@ struct obj * merge_choice(objlist, obj) struct obj *objlist, *obj; { - struct monst *shkp; - int save_nocharge; + struct monst *shkp; + int save_nocharge; - if (obj->otyp == SCR_SCARE_MONSTER) /* punt on these */ - return (struct obj *)0; - /* if this is an item on the shop floor, the attributes it will - have when carried are different from what they are now; prevent - that from eliciting an incorrect result from mergable() */ - save_nocharge = obj->no_charge; - if (objlist == invent && obj->where == OBJ_FLOOR && - (shkp = shop_keeper(inside_shop(obj->ox, obj->oy))) != 0) { - if (obj->no_charge) obj->no_charge = 0; - /* A billable object won't have its `unpaid' bit set, so would - erroneously seem to be a candidate to merge with a similar - ordinary object. That's no good, because once it's really - picked up, it won't merge after all. It might merge with - another unpaid object, but we can't check that here (depends - too much upon shk's bill) and if it doesn't merge it would - end up in the '#' overflow inventory slot, so reject it now. */ - else if (inhishop(shkp)) return (struct obj *)0; - } - while (objlist) { - if (mergable(objlist, obj)) break; - objlist = objlist->nobj; - } - obj->no_charge = save_nocharge; - return objlist; + if (obj->otyp == SCR_SCARE_MONSTER) /* punt on these */ + return (struct obj *)0; + /* if this is an item on the shop floor, the attributes it will + have when carried are different from what they are now; prevent + that from eliciting an incorrect result from mergable() */ + save_nocharge = obj->no_charge; + if (objlist == invent && obj->where == OBJ_FLOOR && + (shkp = shop_keeper(inside_shop(obj->ox, obj->oy))) != 0) { + if (obj->no_charge) obj->no_charge = 0; + /* A billable object won't have its `unpaid' bit set, so would + erroneously seem to be a candidate to merge with a similar + ordinary object. That's no good, because once it's really + picked up, it won't merge after all. It might merge with + another unpaid object, but we can't check that here (depends + too much upon shk's bill) and if it doesn't merge it would + end up in the '#' overflow inventory slot, so reject it now. */ + else if (inhishop(shkp)) return (struct obj *)0; + } + while (objlist) { + if (mergable(objlist, obj)) break; + objlist = objlist->nobj; + } + obj->no_charge = save_nocharge; + return objlist; } /* merge obj with otmp and delete obj if types agree */ @@ -234,73 +233,83 @@ int merged(potmp, pobj) struct obj **potmp, **pobj; { - register struct obj *otmp = *potmp, *obj = *pobj; + register struct obj *otmp = *potmp, *obj = *pobj; - if(mergable(otmp, obj)) { - /* Approximate age: we do it this way because if we were to - * do it "accurately" (merge only when ages are identical) - * we'd wind up never merging any corpses. - * otmp->age = otmp->age*(1-proportion) + obj->age*proportion; - * - * Don't do the age manipulation if lit. We would need - * to stop the burn on both items, then merge the age, - * then restart the burn. - */ - if (!obj->lamplit) - otmp->age = ((otmp->age*otmp->quan) + (obj->age*obj->quan)) - / (otmp->quan + obj->quan); + if(mergable(otmp, obj)) { + /* Approximate age: we do it this way because if we were to + * do it "accurately" (merge only when ages are identical) + * we'd wind up never merging any corpses. + * otmp->age = otmp->age*(1-proportion) + obj->age*proportion; + * + * Don't do the age manipulation if lit. We would need + * to stop the burn on both items, then merge the age, + * then restart the burn. + */ + if (!obj->lamplit) + otmp->age = ((otmp->age*otmp->quan) + (obj->age*obj->quan)) + / (otmp->quan + obj->quan); - otmp->quan += obj->quan; - /* temporary special case for gold objects!!!! */ - if (otmp->oclass == COIN_CLASS) otmp->owt = weight(otmp); - else otmp->owt += obj->owt; - if(!has_oname(otmp) && has_oname(obj)) - otmp = *potmp = oname(otmp, ONAME(obj)); - obj_extract_self(obj); + otmp->quan += obj->quan; + /* temporary special case for gold objects!!!! */ + if (otmp->oclass == COIN_CLASS) otmp->owt = weight(otmp); + /* and puddings!!!1!!one! */ + else if (!Is_pudding(otmp)) otmp->owt += obj->owt; + if(!has_oname(otmp) && has_oname(obj)) + otmp = *potmp = oname(otmp, ONAME(obj)); + obj_extract_self(obj); - /* really should merge the timeouts */ - if (obj->lamplit) obj_merge_light_sources(obj, otmp); - if (obj->timed) obj_stop_timers(obj); /* follows lights */ + /* really should merge the timeouts */ + if (obj->lamplit) obj_merge_light_sources(obj, otmp); + if (obj->timed) obj_stop_timers(obj); /* follows lights */ - /* fixup for `#adjust' merging wielded darts, daggers, &c */ - if (obj->owornmask && carried(otmp)) { - long wmask = otmp->owornmask | obj->owornmask; + /* fixup for `#adjust' merging wielded darts, daggers, &c */ + if (obj->owornmask && carried(otmp)) { + long wmask = otmp->owornmask | obj->owornmask; - /* Both the items might be worn in competing slots; - merger preference (regardless of which is which): - primary weapon + alternate weapon -> primary weapon; - primary weapon + quiver -> primary weapon; - alternate weapon + quiver -> alternate weapon. - (Prior to 3.3.0, it was not possible for the two - stacks to be worn in different slots and `obj' - didn't need to be unworn when merging.) */ - if (wmask & W_WEP) wmask = W_WEP; - else if (wmask & W_SWAPWEP) wmask = W_SWAPWEP; - else if (wmask & W_QUIVER) wmask = W_QUIVER; - else { - impossible("merging strangely worn items (%lx)", wmask); - wmask = otmp->owornmask; - } - if ((otmp->owornmask & ~wmask) != 0L) setnotworn(otmp); - setworn(otmp, wmask); - setnotworn(obj); - } + /* Both the items might be worn in competing slots; + merger preference (regardless of which is which): + primary weapon + alternate weapon -> primary weapon; + primary weapon + quiver -> primary weapon; + alternate weapon + quiver -> alternate weapon. + (Prior to 3.3.0, it was not possible for the two + stacks to be worn in different slots and `obj' + didn't need to be unworn when merging.) */ + if (wmask & W_WEP) wmask = W_WEP; + else if (wmask & W_SWAPWEP) wmask = W_SWAPWEP; + else if (wmask & W_QUIVER) wmask = W_QUIVER; + else { + impossible("merging strangely worn items (%lx)", wmask); + wmask = otmp->owornmask; + } + if ((otmp->owornmask & ~wmask) != 0L) setnotworn(otmp); + setworn(otmp, wmask); + setnotworn(obj); + } #if 0 - /* (this should not be necessary, since items - already in a monster's inventory don't ever get - merged into other objects [only vice versa]) */ - else if (obj->owornmask && mcarried(otmp)) { - if (obj == MON_WEP(otmp->ocarry)) { - MON_WEP(otmp->ocarry) = otmp; - otmp->owornmask = W_WEP; - } - } + /* (this should not be necessary, since items + already in a monster's inventory don't ever get + merged into other objects [only vice versa]) */ + else if (obj->owornmask && mcarried(otmp)) { + if (obj == MON_WEP(otmp->ocarry)) { + MON_WEP(otmp->ocarry) = otmp; + otmp->owornmask = W_WEP; + } + } #endif /*0*/ - obfree(obj,otmp); /* free(obj), bill->otmp */ - return(1); - } - return 0; + /* handle puddings a bit differently; absorption will + * free the other object automatically so we can just + * return out from here. */ + if (Is_pudding(obj)) { + pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + obj_absorb(potmp, pobj); + return(1); + } + + obfree(obj,otmp); /* free(obj), bill->otmp */ + return(1); + } + return 0; } /* @@ -318,33 +327,33 @@ void addinv_core1(obj) struct obj *obj; { - if (obj->oclass == COIN_CLASS) { - context.botl = 1; - } else if (obj->otyp == AMULET_OF_YENDOR) { - if (u.uhave.amulet) impossible("already have amulet?"); - u.uhave.amulet = 1; + if (obj->oclass == COIN_CLASS) { + context.botl = 1; + } else if (obj->otyp == AMULET_OF_YENDOR) { + if (u.uhave.amulet) impossible("already have amulet?"); + u.uhave.amulet = 1; u.uachieve.amulet = 1; - } else if (obj->otyp == CANDELABRUM_OF_INVOCATION) { - if (u.uhave.menorah) impossible("already have candelabrum?"); - u.uhave.menorah = 1; + } else if (obj->otyp == CANDELABRUM_OF_INVOCATION) { + if (u.uhave.menorah) impossible("already have candelabrum?"); + u.uhave.menorah = 1; u.uachieve.menorah = 1; - } else if (obj->otyp == BELL_OF_OPENING) { - if (u.uhave.bell) impossible("already have silver bell?"); - u.uhave.bell = 1; + } else if (obj->otyp == BELL_OF_OPENING) { + if (u.uhave.bell) impossible("already have silver bell?"); + u.uhave.bell = 1; u.uachieve.bell = 1; - } else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { - if (u.uhave.book) impossible("already have the book?"); - u.uhave.book = 1; + } else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { + if (u.uhave.book) impossible("already have the book?"); + u.uhave.book = 1; u.uachieve.book = 1; - } else if (obj->oartifact) { - if (is_quest_artifact(obj)) { - if (u.uhave.questart) - impossible("already have quest artifact?"); - u.uhave.questart = 1; - artitouch(obj); - } - set_artifact_intrinsic(obj, 1, W_ART); - } + } else if (obj->oartifact) { + if (is_quest_artifact(obj)) { + if (u.uhave.questart) + impossible("already have quest artifact?"); + u.uhave.questart = 1; + artitouch(obj); + } + set_artifact_intrinsic(obj, 1, W_ART); + } if(obj->otyp == LUCKSTONE && obj->record_achieve_special) { u.uachieve.mines_luckstone = 1; obj->record_achieve_special = 0; @@ -369,11 +378,11 @@ void addinv_core2(obj) struct obj *obj; { - if (confers_luck(obj)) { - /* new luckstone must be in inventory by this point - * for correct calculation */ - set_moreluck(); - } + if (confers_luck(obj)) { + /* new luckstone must be in inventory by this point + * for correct calculation */ + set_moreluck(); + } } /* @@ -384,48 +393,48 @@ struct obj * addinv(obj) struct obj *obj; { - struct obj *otmp, *prev; + struct obj *otmp, *prev; - if (obj->where != OBJ_FREE) - panic("addinv: obj not free"); - /* normally addtobill() clears no_charge when items in a shop are - picked up, but won't do so if the shop has become untended */ - obj->no_charge = 0; /* should not be set in hero's invent */ - if (Has_contents(obj)) picked_container(obj); /* clear no_charge */ - obj->was_thrown = 0; /* not meaningful for invent */ + if (obj->where != OBJ_FREE) + panic("addinv: obj not free"); + /* normally addtobill() clears no_charge when items in a shop are + picked up, but won't do so if the shop has become untended */ + obj->no_charge = 0; /* should not be set in hero's invent */ + if (Has_contents(obj)) picked_container(obj); /* clear no_charge */ + obj->was_thrown = 0; /* not meaningful for invent */ - addinv_core1(obj); + addinv_core1(obj); - /* merge with quiver in preference to any other inventory slot - in case quiver and wielded weapon are both eligible; adding - extra to quivered stack is more useful than to wielded one */ - if (uquiver && merged(&uquiver, &obj)) { - obj = uquiver; - goto added; - } - /* merge if possible; find end of chain in the process */ - for (prev = 0, otmp = invent; otmp; prev = otmp, otmp = otmp->nobj) - if (merged(&otmp, &obj)) { - obj = otmp; - goto added; - } - /* didn't merge, so insert into chain */ - if (flags.invlet_constant || !prev) { - if (flags.invlet_constant) assigninvlet(obj); - obj->nobj = invent; /* insert at beginning */ - invent = obj; - if (flags.invlet_constant) reorder_invent(); - } else { - prev->nobj = obj; /* insert at end */ - obj->nobj = 0; - } - obj->where = OBJ_INVENT; + /* merge with quiver in preference to any other inventory slot + in case quiver and wielded weapon are both eligible; adding + extra to quivered stack is more useful than to wielded one */ + if (uquiver && merged(&uquiver, &obj)) { + obj = uquiver; + goto added; + } + /* merge if possible; find end of chain in the process */ + for (prev = 0, otmp = invent; otmp; prev = otmp, otmp = otmp->nobj) + if (merged(&otmp, &obj)) { + obj = otmp; + goto added; + } + /* didn't merge, so insert into chain */ + if (flags.invlet_constant || !prev) { + if (flags.invlet_constant) assigninvlet(obj); + obj->nobj = invent; /* insert at beginning */ + invent = obj; + if (flags.invlet_constant) reorder_invent(); + } else { + prev->nobj = obj; /* insert at end */ + obj->nobj = 0; + } + obj->where = OBJ_INVENT; added: - addinv_core2(obj); - carry_obj_effects(obj); /* carrying affects the obj */ - update_inventory(); - return(obj); + addinv_core2(obj); + carry_obj_effects(obj); /* carrying affects the obj */ + update_inventory(); + return(obj); } /* @@ -438,15 +447,15 @@ void carry_obj_effects(obj) struct obj *obj; { - /* Cursed figurines can spontaneously transform - when carried. */ - if (obj->otyp == FIGURINE) { - if (obj->cursed - && obj->corpsenm != NON_PM - && !dead_species(obj->corpsenm,TRUE)) { - attach_fig_transform_timeout(obj); - } - } + /* Cursed figurines can spontaneously transform + when carried. */ + if (obj->otyp == FIGURINE) { + if (obj->cursed + && obj->corpsenm != NON_PM + && !dead_species(obj->corpsenm,TRUE)) { + attach_fig_transform_timeout(obj); + } + } } /* Add an item to the inventory unless we're fumbling or it refuses to be @@ -461,67 +470,67 @@ hold_another_object(obj, drop_fmt, drop_arg, hold_msg) struct obj *obj; const char *drop_fmt, *drop_arg, *hold_msg; { - char buf[BUFSZ]; + char buf[BUFSZ]; - if (!Blind) obj->dknown = 1; /* maximize mergibility */ - if (obj->oartifact) { - /* place_object may change these */ - boolean crysknife = (obj->otyp == CRYSKNIFE); - int oerode = obj->oerodeproof; - boolean wasUpolyd = Upolyd; + if (!Blind) obj->dknown = 1; /* maximize mergibility */ + if (obj->oartifact) { + /* place_object may change these */ + boolean crysknife = (obj->otyp == CRYSKNIFE); + int oerode = obj->oerodeproof; + boolean wasUpolyd = Upolyd; - /* in case touching this object turns out to be fatal */ - place_object(obj, u.ux, u.uy); + /* in case touching this object turns out to be fatal */ + place_object(obj, u.ux, u.uy); - if (!touch_artifact(obj, &youmonst)) { - obj_extract_self(obj); /* remove it from the floor */ - dropy(obj); /* now put it back again :-) */ - return obj; - } else if (wasUpolyd && !Upolyd) { - /* loose your grip if you revert your form */ - if (drop_fmt) pline(drop_fmt, drop_arg); - obj_extract_self(obj); - dropy(obj); - return obj; - } - obj_extract_self(obj); - if (crysknife) { - obj->otyp = CRYSKNIFE; - obj->oerodeproof = oerode; - } - } - if (Fumbling) { - if (drop_fmt) pline(drop_fmt, drop_arg); - dropy(obj); - } else { - long oquan = obj->quan; - int prev_encumbr = near_capacity(); /* before addinv() */ + if (!touch_artifact(obj, &youmonst)) { + obj_extract_self(obj); /* remove it from the floor */ + dropy(obj); /* now put it back again :-) */ + return obj; + } else if (wasUpolyd && !Upolyd) { + /* loose your grip if you revert your form */ + if (drop_fmt) pline(drop_fmt, drop_arg); + obj_extract_self(obj); + dropy(obj); + return obj; + } + obj_extract_self(obj); + if (crysknife) { + obj->otyp = CRYSKNIFE; + obj->oerodeproof = oerode; + } + } + if (Fumbling) { + if (drop_fmt) pline(drop_fmt, drop_arg); + dropy(obj); + } else { + long oquan = obj->quan; + int prev_encumbr = near_capacity(); /* before addinv() */ - /* encumbrance only matters if it would now become worse - than max( current_value, stressed ) */ - if (prev_encumbr < MOD_ENCUMBER) prev_encumbr = MOD_ENCUMBER; - /* addinv() may redraw the entire inventory, overwriting - drop_arg when it comes from something like doname() */ - if (drop_arg) drop_arg = strcpy(buf, drop_arg); + /* encumbrance only matters if it would now become worse + than max( current_value, stressed ) */ + if (prev_encumbr < MOD_ENCUMBER) prev_encumbr = MOD_ENCUMBER; + /* addinv() may redraw the entire inventory, overwriting + drop_arg when it comes from something like doname() */ + if (drop_arg) drop_arg = strcpy(buf, drop_arg); - obj = addinv(obj); - if (inv_cnt(FALSE) > 52 - || ((obj->otyp != LOADSTONE || !obj->cursed) - && near_capacity() > prev_encumbr)) { - if (drop_fmt) pline(drop_fmt, drop_arg); - /* undo any merge which took place */ - if (obj->quan > oquan) obj = splitobj(obj, oquan); - dropx(obj); - } else { - if (flags.autoquiver && !uquiver && !obj->owornmask && - (is_missile(obj) || - ammo_and_launcher(obj, uwep) || - ammo_and_launcher(obj, uswapwep))) - setuqwep(obj); - if (hold_msg || drop_fmt) prinv(hold_msg, obj, oquan); - } - } - return obj; + obj = addinv(obj); + if (inv_cnt(FALSE) > 52 + || ((obj->otyp != LOADSTONE || !obj->cursed) + && near_capacity() > prev_encumbr)) { + if (drop_fmt) pline(drop_fmt, drop_arg); + /* undo any merge which took place */ + if (obj->quan > oquan) obj = splitobj(obj, oquan); + dropx(obj); + } else { + if (flags.autoquiver && !uquiver && !obj->owornmask && + (is_missile(obj) || + ammo_and_launcher(obj, uwep) || + ammo_and_launcher(obj, uswapwep))) + setuqwep(obj); + if (hold_msg || drop_fmt) prinv(hold_msg, obj, oquan); + } + } + return obj; } /* useup() all of an item regardless of its quantity */ @@ -529,25 +538,25 @@ void useupall(obj) struct obj *obj; { - setnotworn(obj); - freeinv(obj); - obfree(obj, (struct obj *)0); /* deletes contents also */ + setnotworn(obj); + freeinv(obj); + obfree(obj, (struct obj *)0); /* deletes contents also */ } void useup(obj) register struct obj *obj; { - /* Note: This works correctly for containers because they */ - /* (containers) don't merge. */ - if (obj->quan > 1L) { - obj->in_use = FALSE; /* no longer in use */ - obj->quan--; - obj->owt = weight(obj); - update_inventory(); - } else { - useupall(obj); - } + /* Note: This works correctly for containers because they */ + /* (containers) don't merge. */ + if (obj->quan > 1L) { + obj->in_use = FALSE; /* no longer in use */ + obj->quan--; + obj->owt = weight(obj); + update_inventory(); + } else { + useupall(obj); + } } /* use one charge from an item and possibly incur shop debt for it */ @@ -556,9 +565,9 @@ consume_obj_charge(obj, maybe_unpaid) struct obj *obj; boolean maybe_unpaid; /* false if caller handles shop billing */ { - if (maybe_unpaid) check_unpaid(obj); - obj->spe -= 1; - if (obj->known) update_inventory(); + if (maybe_unpaid) check_unpaid(obj); + obj->spe -= 1; + if (obj->known) update_inventory(); } /* @@ -572,38 +581,38 @@ void freeinv_core(obj) struct obj *obj; { - if (obj->oclass == COIN_CLASS) { - context.botl = 1; - return; - } else if (obj->otyp == AMULET_OF_YENDOR) { - if (!u.uhave.amulet) impossible("don't have amulet?"); - u.uhave.amulet = 0; - } else if (obj->otyp == CANDELABRUM_OF_INVOCATION) { - if (!u.uhave.menorah) impossible("don't have candelabrum?"); - u.uhave.menorah = 0; - } else if (obj->otyp == BELL_OF_OPENING) { - if (!u.uhave.bell) impossible("don't have silver bell?"); - u.uhave.bell = 0; - } else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { - if (!u.uhave.book) impossible("don't have the book?"); - u.uhave.book = 0; - } else if (obj->oartifact) { - if (is_quest_artifact(obj)) { - if (!u.uhave.questart) - impossible("don't have quest artifact?"); - u.uhave.questart = 0; - } - set_artifact_intrinsic(obj, 0, W_ART); - } + if (obj->oclass == COIN_CLASS) { + context.botl = 1; + return; + } else if (obj->otyp == AMULET_OF_YENDOR) { + if (!u.uhave.amulet) impossible("don't have amulet?"); + u.uhave.amulet = 0; + } else if (obj->otyp == CANDELABRUM_OF_INVOCATION) { + if (!u.uhave.menorah) impossible("don't have candelabrum?"); + u.uhave.menorah = 0; + } else if (obj->otyp == BELL_OF_OPENING) { + if (!u.uhave.bell) impossible("don't have silver bell?"); + u.uhave.bell = 0; + } else if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { + if (!u.uhave.book) impossible("don't have the book?"); + u.uhave.book = 0; + } else if (obj->oartifact) { + if (is_quest_artifact(obj)) { + if (!u.uhave.questart) + impossible("don't have quest artifact?"); + u.uhave.questart = 0; + } + set_artifact_intrinsic(obj, 0, W_ART); + } - if (obj->otyp == LOADSTONE) { - curse(obj); - } else if (confers_luck(obj)) { - set_moreluck(); - context.botl = 1; - } else if (obj->otyp == FIGURINE && obj->timed) { - (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj)); - } + if (obj->otyp == LOADSTONE) { + curse(obj); + } else if (confers_luck(obj)) { + set_moreluck(); + context.botl = 1; + } else if (obj->otyp == FIGURINE && obj->timed) { + (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj)); + } } /* remove an object from the hero's inventory */ @@ -611,26 +620,26 @@ void freeinv(obj) register struct obj *obj; { - extract_nobj(obj, &invent); - freeinv_core(obj); - update_inventory(); + extract_nobj(obj, &invent); + freeinv_core(obj); + update_inventory(); } void delallobj(x, y) int x, y; { - struct obj *otmp, *otmp2; + struct obj *otmp, *otmp2; - for (otmp = level.objects[x][y]; otmp; otmp = otmp2) { - if (otmp == uball) - unpunish(); - /* after unpunish(), or might get deallocated chain */ - otmp2 = otmp->nexthere; - if (otmp == uchain) - continue; - delobj(otmp); - } + for (otmp = level.objects[x][y]; otmp; otmp = otmp2) { + if (otmp == uball) + unpunish(); + /* after unpunish(), or might get deallocated chain */ + otmp2 = otmp->nexthere; + if (otmp == uchain) + continue; + delobj(otmp); + } } /* destroy object in fobj chain (if unpaid, it remains on the bill) */ @@ -638,23 +647,23 @@ void delobj(obj) register struct obj *obj; { - boolean update_map; + boolean update_map; - if (obj->otyp == AMULET_OF_YENDOR || - obj->otyp == CANDELABRUM_OF_INVOCATION || - obj->otyp == BELL_OF_OPENING || - obj->otyp == SPE_BOOK_OF_THE_DEAD) { - /* player might be doing something stupid, but we - * can't guarantee that. assume special artifacts - * are indestructible via drawbridges, and exploding - * chests, and golem creation, and ... - */ - return; - } - update_map = (obj->where == OBJ_FLOOR); - obj_extract_self(obj); - if (update_map) newsym(obj->ox, obj->oy); - obfree(obj, (struct obj *) 0); /* frees contents also */ + if (obj->otyp == AMULET_OF_YENDOR || + obj->otyp == CANDELABRUM_OF_INVOCATION || + obj->otyp == BELL_OF_OPENING || + obj->otyp == SPE_BOOK_OF_THE_DEAD) { + /* player might be doing something stupid, but we + * can't guarantee that. assume special artifacts + * are indestructible via drawbridges, and exploding + * chests, and golem creation, and ... + */ + return; + } + update_map = (obj->where == OBJ_FLOOR); + obj_extract_self(obj); + if (update_map) newsym(obj->ox, obj->oy); + obfree(obj, (struct obj *) 0); /* frees contents also */ } /* try to find a particular type of object at designated map location */ @@ -663,12 +672,12 @@ sobj_at(otyp, x, y) int otyp; int x, y; { - register struct obj *otmp; + register struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) - if (otmp->otyp == otyp) break; + for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + if (otmp->otyp == otyp) break; - return otmp; + return otmp; } /* sobj_at(&c) traversal -- find next object of specified type */ @@ -678,46 +687,46 @@ struct obj *obj; int type; boolean by_nexthere; { - register struct obj *otmp; + register struct obj *otmp; - otmp = obj; /* start with the object after this one */ - do { - otmp = !by_nexthere ? otmp->nobj : otmp->nexthere; - if (!otmp) break; - } while (otmp->otyp != type); + otmp = obj; /* start with the object after this one */ + do { + otmp = !by_nexthere ? otmp->nobj : otmp->nexthere; + if (!otmp) break; + } while (otmp->otyp != type); - return otmp; + return otmp; } struct obj * carrying(type) register int type; { - register struct obj *otmp; + register struct obj *otmp; - for(otmp = invent; otmp; otmp = otmp->nobj) - if(otmp->otyp == type) - return(otmp); - return((struct obj *) 0); + for(otmp = invent; otmp; otmp = otmp->nobj) + if(otmp->otyp == type) + return(otmp); + return((struct obj *) 0); } const char * currency(amount) long amount; { - if (amount == 1L) return "zorkmid"; - else return "zorkmids"; + if (amount == 1L) return "zorkmid"; + else return "zorkmids"; } boolean have_lizard() { - register struct obj *otmp; + register struct obj *otmp; - for(otmp = invent; otmp; otmp = otmp->nobj) - if(otmp->otyp == CORPSE && otmp->corpsenm == PM_LIZARD) - return(TRUE); - return(FALSE); + for(otmp = invent; otmp; otmp = otmp->nobj) + if(otmp->otyp == CORPSE && otmp->corpsenm == PM_LIZARD) + return(TRUE); + return(FALSE); } struct obj * @@ -725,15 +734,15 @@ o_on(id, objchn) unsigned int id; register struct obj *objchn; { - struct obj *temp; + struct obj *temp; - while(objchn) { - if(objchn->o_id == id) return(objchn); - if (Has_contents(objchn) && (temp = o_on(id,objchn->cobj))) - return temp; - objchn = objchn->nobj; - } - return((struct obj *) 0); + while(objchn) { + if(objchn->o_id == id) return(objchn); + if (Has_contents(objchn) && (temp = o_on(id,objchn->cobj))) + return temp; + objchn = objchn->nobj; + } + return((struct obj *) 0); } boolean @@ -741,23 +750,23 @@ obj_here(obj, x, y) register struct obj *obj; int x, y; { - register struct obj *otmp; + register struct obj *otmp; - for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) - if(obj == otmp) return(TRUE); - return(FALSE); + for(otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) + if(obj == otmp) return(TRUE); + return(FALSE); } struct obj * g_at(x,y) register int x, y; { - register struct obj *obj = level.objects[x][y]; - while(obj) { - if (obj->oclass == COIN_CLASS) return obj; - obj = obj->nexthere; - } - return((struct obj *)0); + register struct obj *obj = level.objects[x][y]; + while(obj) { + if (obj->oclass == COIN_CLASS) return obj; + obj = obj->nexthere; + } + return((struct obj *)0); } STATIC_OVL void @@ -765,38 +774,38 @@ compactify(buf) register char *buf; /* compact a string of inventory letters by dashing runs of letters */ { - register int i1 = 1, i2 = 1; - register char ilet, ilet1, ilet2; + register int i1 = 1, i2 = 1; + register char ilet, ilet1, ilet2; - ilet2 = buf[0]; - ilet1 = buf[1]; - buf[++i2] = buf[++i1]; - ilet = buf[i1]; - while(ilet) { - if(ilet == ilet1+1) { - if(ilet1 == ilet2+1) - buf[i2 - 1] = ilet1 = '-'; - else if(ilet2 == '-') { - buf[i2 - 1] = ++ilet1; - buf[i2] = buf[++i1]; - ilet = buf[i1]; - continue; - } - } else if (ilet == NOINVSYM) { - /* compact three or more consecutive '#' - characters into "#-#" */ - if (i2 >= 2 && buf[i2 - 2] == NOINVSYM && - buf[i2 - 1] == NOINVSYM) - buf[i2 - 1] = '-'; - else if (i2 >= 3 && buf[i2 - 3] == NOINVSYM && - buf[i2 - 2] == '-' && buf[i2 - 1] == NOINVSYM) - --i2; - } - ilet2 = ilet1; - ilet1 = ilet; - buf[++i2] = buf[++i1]; - ilet = buf[i1]; - } + ilet2 = buf[0]; + ilet1 = buf[1]; + buf[++i2] = buf[++i1]; + ilet = buf[i1]; + while(ilet) { + if(ilet == ilet1+1) { + if(ilet1 == ilet2+1) + buf[i2 - 1] = ilet1 = '-'; + else if(ilet2 == '-') { + buf[i2 - 1] = ++ilet1; + buf[i2] = buf[++i1]; + ilet = buf[i1]; + continue; + } + } else if (ilet == NOINVSYM) { + /* compact three or more consecutive '#' + characters into "#-#" */ + if (i2 >= 2 && buf[i2 - 2] == NOINVSYM && + buf[i2 - 1] == NOINVSYM) + buf[i2 - 1] = '-'; + else if (i2 >= 3 && buf[i2 - 3] == NOINVSYM && + buf[i2 - 2] == '-' && buf[i2 - 1] == NOINVSYM) + --i2; + } + ilet2 = ilet1; + ilet1 = ilet; + buf[++i2] = buf[++i1]; + ilet = buf[i1]; + } } /* some objects shouldn't be split when count given to getobj or askchain */ @@ -805,7 +814,7 @@ splittable(obj) struct obj *obj; { return !((obj->otyp == LOADSTONE && obj->cursed) || - (obj == uwep && welded(uwep))); + (obj == uwep && welded(uwep))); } /* match the prompt for either 'T' or 'R' command */ @@ -836,225 +845,225 @@ struct obj * getobj(let,word) register const char *let,*word; { - register struct obj *otmp; - register char ilet; - char buf[BUFSZ], qbuf[QBUFSZ]; - char lets[BUFSZ], altlets[BUFSZ], *ap; - register int foo = 0; - register char *bp = buf; - xchar allowcnt = 0; /* 0, 1 or 2 */ - struct obj *firstobj = invent; - boolean usegold = FALSE; /* can't use gold because its illegal */ - boolean allowall = FALSE; - boolean allownone = FALSE; - boolean useboulder = FALSE; - xchar foox = 0; - long cnt, prevcnt; - boolean prezero; - long dummymask; + register struct obj *otmp; + register char ilet; + char buf[BUFSZ], qbuf[QBUFSZ]; + char lets[BUFSZ], altlets[BUFSZ], *ap; + register int foo = 0; + register char *bp = buf; + xchar allowcnt = 0; /* 0, 1 or 2 */ + struct obj *firstobj = invent; + boolean usegold = FALSE; /* can't use gold because its illegal */ + boolean allowall = FALSE; + boolean allownone = FALSE; + boolean useboulder = FALSE; + xchar foox = 0; + long cnt, prevcnt; + boolean prezero; + long dummymask; - if(*let == ALLOW_COUNT) let++, allowcnt = 1; - if(*let == COIN_CLASS) let++, usegold = TRUE; + if(*let == ALLOW_COUNT) let++, allowcnt = 1; + if(*let == COIN_CLASS) let++, usegold = TRUE; - /* Equivalent of an "ugly check" for gold */ - if (usegold && !strcmp(word, "eat") && - (!metallivorous(youmonst.data) - || youmonst.data == &mons[PM_RUST_MONSTER])) - usegold = FALSE; + /* Equivalent of an "ugly check" for gold */ + if (usegold && !strcmp(word, "eat") && + (!metallivorous(youmonst.data) + || youmonst.data == &mons[PM_RUST_MONSTER])) + usegold = FALSE; - if(*let == ALL_CLASSES) let++, allowall = TRUE; - if(*let == ALLOW_NONE) let++, allownone = TRUE; - /* "ugly check" for reading fortune cookies, part 1 */ - /* The normal 'ugly check' keeps the object on the inventory list. - * We don't want to do that for shirts/cookies, so the check for - * them is handled a bit differently (and also requires that we set - * allowall in the caller) - */ - if(allowall && !strcmp(word, "read")) allowall = FALSE; + if(*let == ALL_CLASSES) let++, allowall = TRUE; + if(*let == ALLOW_NONE) let++, allownone = TRUE; + /* "ugly check" for reading fortune cookies, part 1 */ + /* The normal 'ugly check' keeps the object on the inventory list. + * We don't want to do that for shirts/cookies, so the check for + * them is handled a bit differently (and also requires that we set + * allowall in the caller) + */ + if(allowall && !strcmp(word, "read")) allowall = FALSE; - /* another ugly check: show boulders (not statues) */ - if(*let == WEAPON_CLASS && - !strcmp(word, "throw") && throws_rocks(youmonst.data)) - useboulder = TRUE; + /* another ugly check: show boulders (not statues) */ + if(*let == WEAPON_CLASS && + !strcmp(word, "throw") && throws_rocks(youmonst.data)) + useboulder = TRUE; - if(allownone) *bp++ = '-'; - if(bp > buf && bp[-1] == '-') *bp++ = ' '; - ap = altlets; + if(allownone) *bp++ = '-'; + if(bp > buf && bp[-1] == '-') *bp++ = ' '; + ap = altlets; - if (!flags.invlet_constant) reassign(); + if (!flags.invlet_constant) reassign(); - for (otmp = firstobj; otmp; otmp = otmp->nobj) { - if (&bp[foo] == &buf[sizeof buf - 1] || - ap == &altlets[sizeof altlets - 1]) { - /* we must have a huge number of NOINVSYM items somehow */ - impossible("getobj: inventory overflow"); - break; - } + for (otmp = firstobj; otmp; otmp = otmp->nobj) { + if (&bp[foo] == &buf[sizeof buf - 1] || + ap == &altlets[sizeof altlets - 1]) { + /* we must have a huge number of NOINVSYM items somehow */ + impossible("getobj: inventory overflow"); + break; + } - if (!*let || index(let, otmp->oclass) - || (usegold && otmp->invlet == GOLD_SYM) - || (useboulder && otmp->otyp == BOULDER) - ) { - register int otyp = otmp->otyp; - bp[foo++] = otmp->invlet; + if (!*let || index(let, otmp->oclass) + || (usegold && otmp->invlet == GOLD_SYM) + || (useboulder && otmp->otyp == BOULDER) + ) { + register int otyp = otmp->otyp; + bp[foo++] = otmp->invlet; - /* ugly check: remove inappropriate things */ - if ((taking_off(word) && - !(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) - || (putting_on(word) && - (otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) - /* already worn */ + /* ugly check: remove inappropriate things */ + if ((taking_off(word) && + !(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) + || (putting_on(word) && + (otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL))) + /* already worn */ #if 0 /* 3.4.1 -- include currently wielded weapon among the choices */ - || (!strcmp(word, "wield") && - (otmp->owornmask & W_WEP)) + || (!strcmp(word, "wield") && + (otmp->owornmask & W_WEP)) #endif - || (!strcmp(word, "ready") && - (otmp == uwep || (otmp == uswapwep && u.twoweap))) - || ((!strcmp(word, "dip") || !strcmp(word, "grease")) && - inaccessible_equipment(otmp, (const char *)0 , FALSE)) - ) { - foo--; - foox++; - } + || (!strcmp(word, "ready") && + (otmp == uwep || (otmp == uswapwep && u.twoweap))) + || ((!strcmp(word, "dip") || !strcmp(word, "grease")) && + inaccessible_equipment(otmp, (const char *)0 , FALSE)) + ) { + foo--; + foox++; + } - /* Second ugly check; unlike the first it won't trigger an - * "else" in "you don't have anything else to ___". - */ - else if ((putting_on(word) && - ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING) || - (otmp->oclass == TOOL_CLASS && - otyp != BLINDFOLD && otyp != TOWEL && otyp != LENSES))) - || (!strcmp(word, "wield") && - (otmp->oclass == TOOL_CLASS && !is_weptool(otmp))) - || (!strcmp(word, "eat") && !is_edible(otmp)) - || (!strcmp(word, "sacrifice") && - (otyp != CORPSE && - otyp != AMULET_OF_YENDOR && otyp != FAKE_AMULET_OF_YENDOR)) - || (!strcmp(word, "write with") && - (otmp->oclass == TOOL_CLASS && - otyp != MAGIC_MARKER && otyp != TOWEL)) - || (!strcmp(word, "tin") && - (otyp != CORPSE || !tinnable(otmp))) - || (!strcmp(word, "rub") && - ((otmp->oclass == TOOL_CLASS && - otyp != OIL_LAMP && otyp != MAGIC_LAMP && - otyp != BRASS_LANTERN) || - (otmp->oclass == GEM_CLASS && !is_graystone(otmp)))) - || ((!strcmp(word, "use or apply") || - !strcmp(word, "untrap with")) && - /* Picks, axes, pole-weapons, bullwhips */ - ((otmp->oclass == WEAPON_CLASS && !is_pick(otmp) && - !is_axe(otmp) && !is_pole(otmp) && otyp != BULLWHIP) || - (otmp->oclass == POTION_CLASS && - /* only applicable potion is oil, and it will only - be offered as a choice when already discovered */ - (otyp != POT_OIL || !otmp->dknown || - !objects[POT_OIL].oc_name_known)) || - (otmp->oclass == FOOD_CLASS && - otyp != CREAM_PIE && otyp != EUCALYPTUS_LEAF) || - (otmp->oclass == GEM_CLASS && !is_graystone(otmp)))) - || (!strcmp(word, "invoke") && - (!otmp->oartifact && !objects[otyp].oc_unique && - (otyp != FAKE_AMULET_OF_YENDOR || otmp->known) && - otyp != CRYSTAL_BALL && /* #invoke synonym for apply */ - /* note: presenting the possibility of invoking non-artifact - mirrors and/or lamps is a simply a cruel deception... */ - otyp != MIRROR && otyp != MAGIC_LAMP && - (otyp != OIL_LAMP || /* don't list known oil lamp */ - (otmp->dknown && objects[OIL_LAMP].oc_name_known)))) - || (!strcmp(word, "untrap with") && - (otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE)) - || (!strcmp(word, "tip") && !Is_container(otmp) && - /* include horn of plenty if sufficiently discovered */ - (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown || - !objects[HORN_OF_PLENTY].oc_name_known)) - || (!strcmp(word, "charge") && !is_chargeable(otmp)) - || (!strcmp(word, "call") && !objtyp_is_callable(otyp)) - ) - foo--; - /* ugly check for unworn armor that can't be worn */ - else if ((putting_on(word) && *let == ARMOR_CLASS && - !canwearobj(otmp, &dummymask, FALSE)) - /* or unsuitable items rubbed on known touchstone */ - || (!strncmp(word, "rub on the stone", 16) && - *let == GEM_CLASS && - otmp->dknown && objects[otyp].oc_name_known) - /* suppress corpses on astral, amulets elsewhere */ - || (!strcmp(word, "sacrifice") && - /* (!astral && amulet) || (astral && !amulet) */ - (!Is_astralevel(&u.uz) ^ (otmp->oclass != AMULET_CLASS))) - /* suppress container being stashed into */ - || (!strcmp(word, "stash") && !ck_bag(otmp)) - /* worn armor or accessory covered by cursed worn armor */ - || (taking_off(word) && - inaccessible_equipment(otmp, (const char *)0, TRUE)) - ) { - /* acceptable but not listed as likely candidate */ - foo--; - allowall = TRUE; - *ap++ = otmp->invlet; - } - } else { + /* Second ugly check; unlike the first it won't trigger an + * "else" in "you don't have anything else to ___". + */ + else if ((putting_on(word) && + ((otmp->oclass == FOOD_CLASS && otmp->otyp != MEAT_RING) || + (otmp->oclass == TOOL_CLASS && + otyp != BLINDFOLD && otyp != TOWEL && otyp != LENSES))) + || (!strcmp(word, "wield") && + (otmp->oclass == TOOL_CLASS && !is_weptool(otmp))) + || (!strcmp(word, "eat") && !is_edible(otmp)) + || (!strcmp(word, "sacrifice") && + (otyp != CORPSE && + otyp != AMULET_OF_YENDOR && otyp != FAKE_AMULET_OF_YENDOR)) + || (!strcmp(word, "write with") && + (otmp->oclass == TOOL_CLASS && + otyp != MAGIC_MARKER && otyp != TOWEL)) + || (!strcmp(word, "tin") && + (otyp != CORPSE || !tinnable(otmp))) + || (!strcmp(word, "rub") && + ((otmp->oclass == TOOL_CLASS && + otyp != OIL_LAMP && otyp != MAGIC_LAMP && + otyp != BRASS_LANTERN) || + (otmp->oclass == GEM_CLASS && !is_graystone(otmp)))) + || ((!strcmp(word, "use or apply") || + !strcmp(word, "untrap with")) && + /* Picks, axes, pole-weapons, bullwhips */ + ((otmp->oclass == WEAPON_CLASS && !is_pick(otmp) && + !is_axe(otmp) && !is_pole(otmp) && otyp != BULLWHIP) || + (otmp->oclass == POTION_CLASS && + /* only applicable potion is oil, and it will only + be offered as a choice when already discovered */ + (otyp != POT_OIL || !otmp->dknown || + !objects[POT_OIL].oc_name_known)) || + (otmp->oclass == FOOD_CLASS && + otyp != CREAM_PIE && otyp != EUCALYPTUS_LEAF) || + (otmp->oclass == GEM_CLASS && !is_graystone(otmp)))) + || (!strcmp(word, "invoke") && + (!otmp->oartifact && !objects[otyp].oc_unique && + (otyp != FAKE_AMULET_OF_YENDOR || otmp->known) && + otyp != CRYSTAL_BALL && /* #invoke synonym for apply */ + /* note: presenting the possibility of invoking non-artifact + mirrors and/or lamps is a simply a cruel deception... */ + otyp != MIRROR && otyp != MAGIC_LAMP && + (otyp != OIL_LAMP || /* don't list known oil lamp */ + (otmp->dknown && objects[OIL_LAMP].oc_name_known)))) + || (!strcmp(word, "untrap with") && + (otmp->oclass == TOOL_CLASS && otyp != CAN_OF_GREASE)) + || (!strcmp(word, "tip") && !Is_container(otmp) && + /* include horn of plenty if sufficiently discovered */ + (otmp->otyp != HORN_OF_PLENTY || !otmp->dknown || + !objects[HORN_OF_PLENTY].oc_name_known)) + || (!strcmp(word, "charge") && !is_chargeable(otmp)) + || (!strcmp(word, "call") && !objtyp_is_callable(otyp)) + ) + foo--; + /* ugly check for unworn armor that can't be worn */ + else if ((putting_on(word) && *let == ARMOR_CLASS && + !canwearobj(otmp, &dummymask, FALSE)) + /* or unsuitable items rubbed on known touchstone */ + || (!strncmp(word, "rub on the stone", 16) && + *let == GEM_CLASS && + otmp->dknown && objects[otyp].oc_name_known) + /* suppress corpses on astral, amulets elsewhere */ + || (!strcmp(word, "sacrifice") && + /* (!astral && amulet) || (astral && !amulet) */ + (!Is_astralevel(&u.uz) ^ (otmp->oclass != AMULET_CLASS))) + /* suppress container being stashed into */ + || (!strcmp(word, "stash") && !ck_bag(otmp)) + /* worn armor or accessory covered by cursed worn armor */ + || (taking_off(word) && + inaccessible_equipment(otmp, (const char *)0, TRUE)) + ) { + /* acceptable but not listed as likely candidate */ + foo--; + allowall = TRUE; + *ap++ = otmp->invlet; + } + } else { - /* "ugly check" for reading fortune cookies, part 2 */ - if ((!strcmp(word, "read") + /* "ugly check" for reading fortune cookies, part 2 */ + if ((!strcmp(word, "read") && is_readable(otmp))) allowall = usegold = TRUE; - } - } - bp[foo] = 0; - if(foo == 0 && bp > buf && bp[-1] == ' ') *--bp = 0; - Strcpy(lets, bp); /* necessary since we destroy buf */ - if(foo > 5) /* compactify string */ - compactify(bp); - *ap = '\0'; + } + } + bp[foo] = 0; + if(foo == 0 && bp > buf && bp[-1] == ' ') *--bp = 0; + Strcpy(lets, bp); /* necessary since we destroy buf */ + if(foo > 5) /* compactify string */ + compactify(bp); + *ap = '\0'; - if(!foo && !allowall && !allownone) { - You("don't have anything %sto %s.", - foox ? "else " : "", word); - return((struct obj *)0); - } - for(;;) { - cnt = 0; - if (allowcnt == 2) allowcnt = 1; /* abort previous count */ - prezero = FALSE; - if(!buf[0]) { - Sprintf(qbuf, "What do you want to %s? [*]", word); - } else { - Sprintf(qbuf, "What do you want to %s? [%s or ?*]", - word, buf); - } - if (in_doagain) - ilet = readchar(); - else - ilet = yn_function(qbuf, (char *)0, '\0'); - if (digit(ilet) && !allowcnt) { - pline("No count allowed with this command."); - continue; - } - if (ilet == '0') prezero = TRUE; - while (digit(ilet)) { - if (ilet != '?' && ilet != '*') savech(ilet); - /* accumulate unless cnt has overflowed */ - if (allowcnt < 3) { - prevcnt = cnt; - cnt = 10L * cnt + (long)(ilet - '0'); - /* signal presence of cnt */ - allowcnt = (cnt >= prevcnt) ? 2 : 3; - } - ilet = readchar(); - } - if (allowcnt == 3) { - /* overflow detected; force cnt to be invalid */ - cnt = -1L; - allowcnt = 2; - } - if(index(quitchars,ilet)) { - if(flags.verbose) - pline1(Never_mind); - return((struct obj *)0); - } - if(ilet == '-') { + if(!foo && !allowall && !allownone) { + You("don't have anything %sto %s.", + foox ? "else " : "", word); + return((struct obj *)0); + } + for(;;) { + cnt = 0; + if (allowcnt == 2) allowcnt = 1; /* abort previous count */ + prezero = FALSE; + if(!buf[0]) { + Sprintf(qbuf, "What do you want to %s? [*]", word); + } else { + Sprintf(qbuf, "What do you want to %s? [%s or ?*]", + word, buf); + } + if (in_doagain) + ilet = readchar(); + else + ilet = yn_function(qbuf, (char *)0, '\0'); + if (digit(ilet) && !allowcnt) { + pline("No count allowed with this command."); + continue; + } + if (ilet == '0') prezero = TRUE; + while (digit(ilet)) { + if (ilet != '?' && ilet != '*') savech(ilet); + /* accumulate unless cnt has overflowed */ + if (allowcnt < 3) { + prevcnt = cnt; + cnt = 10L * cnt + (long)(ilet - '0'); + /* signal presence of cnt */ + allowcnt = (cnt >= prevcnt) ? 2 : 3; + } + ilet = readchar(); + } + if (allowcnt == 3) { + /* overflow detected; force cnt to be invalid */ + cnt = -1L; + allowcnt = 2; + } + if(index(quitchars,ilet)) { + if(flags.verbose) + pline1(Never_mind); + return((struct obj *)0); + } + if(ilet == '-') { if (!allownone) { char *suf = NULL; strcpy(buf, word); @@ -1070,93 +1079,93 @@ register const char *let,*word; suf ? " " : "", suf ? suf : ""); } return(allownone ? &zeroobj : (struct obj *) 0); - } - if(ilet == def_oc_syms[COIN_CLASS].sym) { - if (!usegold) { - You("cannot %s gold.", word); - return(struct obj *)0; - } - /* Historic note: early Nethack had a bug which was - * first reported for Larn, where trying to drop 2^32-n - * gold pieces was allowed, and did interesting things - * to your money supply. The LRS is the tax bureau - * from Larn. - */ - if (allowcnt == 2 && cnt <= 0) { - if (cnt < 0 || !prezero) - pline_The( - "LRS would be very interested to know you have that much."); - return (struct obj *)0; - } + } + if(ilet == def_oc_syms[COIN_CLASS].sym) { + if (!usegold) { + You("cannot %s gold.", word); + return(struct obj *)0; + } + /* Historic note: early Nethack had a bug which was + * first reported for Larn, where trying to drop 2^32-n + * gold pieces was allowed, and did interesting things + * to your money supply. The LRS is the tax bureau + * from Larn. + */ + if (allowcnt == 2 && cnt <= 0) { + if (cnt < 0 || !prezero) + pline_The( + "LRS would be very interested to know you have that much."); + return (struct obj *)0; + } - } - if(ilet == '?' || ilet == '*') { - char *allowed_choices = (ilet == '?') ? lets : (char *)0; - long ctmp = 0; + } + if(ilet == '?' || ilet == '*') { + char *allowed_choices = (ilet == '?') ? lets : (char *)0; + long ctmp = 0; - if (ilet == '?' && !*lets && *altlets) - allowed_choices = altlets; - ilet = display_pickinv(allowed_choices, TRUE, - allowcnt ? &ctmp : (long *)0); - if(!ilet) continue; - if (allowcnt && ctmp >= 0) { - cnt = ctmp; - if (!cnt) prezero = TRUE; - allowcnt = 2; - } - if(ilet == '\033') { - if(flags.verbose) - pline1(Never_mind); - return((struct obj *)0); - } - /* they typed a letter (not a space) at the prompt */ - } - if(allowcnt == 2 && !strcmp(word,"throw")) { - /* permit counts for throwing gold, but don't accept - * counts for other things since the throw code will - * split off a single item anyway */ - if (ilet != def_oc_syms[COIN_CLASS].sym) - allowcnt = 1; - if(cnt == 0 && prezero) return((struct obj *)0); - if(cnt > 1) { - You("can only throw one item at a time."); - continue; - } - } - context.botl = 1; /* May have changed the amount of money */ - savech(ilet); - for (otmp = invent; otmp; otmp = otmp->nobj) - if (otmp->invlet == ilet) break; - if(!otmp) { - You("don't have that object."); - if (in_doagain) return((struct obj *) 0); - continue; - } else if (cnt < 0 || otmp->quan < cnt) { - You("don't have that many! You have only %ld.", - otmp->quan); - if (in_doagain) return((struct obj *) 0); - continue; - } - break; - } - if(!allowall && let && !index(let,otmp->oclass) - && !(usegold && otmp->oclass == COIN_CLASS) - ) { - silly_thing(word, otmp); - return((struct obj *)0); - } - if(allowcnt == 2) { /* cnt given */ - if(cnt == 0) return (struct obj *)0; - if(cnt != otmp->quan) { - /* don't split a stack of cursed loadstones */ - if (splittable(otmp)) - otmp = splitobj(otmp, cnt); - else if (otmp->otyp == LOADSTONE && otmp->cursed) - /* kludge for canletgo()'s can't-drop-this message */ - otmp->corpsenm = (int) cnt; - } - } - return(otmp); + if (ilet == '?' && !*lets && *altlets) + allowed_choices = altlets; + ilet = display_pickinv(allowed_choices, TRUE, + allowcnt ? &ctmp : (long *)0); + if(!ilet) continue; + if (allowcnt && ctmp >= 0) { + cnt = ctmp; + if (!cnt) prezero = TRUE; + allowcnt = 2; + } + if(ilet == '\033') { + if(flags.verbose) + pline1(Never_mind); + return((struct obj *)0); + } + /* they typed a letter (not a space) at the prompt */ + } + if(allowcnt == 2 && !strcmp(word,"throw")) { + /* permit counts for throwing gold, but don't accept + * counts for other things since the throw code will + * split off a single item anyway */ + if (ilet != def_oc_syms[COIN_CLASS].sym) + allowcnt = 1; + if(cnt == 0 && prezero) return((struct obj *)0); + if(cnt > 1) { + You("can only throw one item at a time."); + continue; + } + } + context.botl = 1; /* May have changed the amount of money */ + savech(ilet); + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->invlet == ilet) break; + if(!otmp) { + You("don't have that object."); + if (in_doagain) return((struct obj *) 0); + continue; + } else if (cnt < 0 || otmp->quan < cnt) { + You("don't have that many! You have only %ld.", + otmp->quan); + if (in_doagain) return((struct obj *) 0); + continue; + } + break; + } + if(!allowall && let && !index(let,otmp->oclass) + && !(usegold && otmp->oclass == COIN_CLASS) + ) { + silly_thing(word, otmp); + return((struct obj *)0); + } + if(allowcnt == 2) { /* cnt given */ + if(cnt == 0) return (struct obj *)0; + if(cnt != otmp->quan) { + /* don't split a stack of cursed loadstones */ + if (splittable(otmp)) + otmp = splitobj(otmp, cnt); + else if (otmp->otyp == LOADSTONE && otmp->cursed) + /* kludge for canletgo()'s can't-drop-this message */ + otmp->corpsenm = (int) cnt; + } + } + return(otmp); } void @@ -1164,57 +1173,57 @@ silly_thing(word, otmp) const char *word; struct obj *otmp; { - const char *s1, *s2, *s3, *what; - int ocls = otmp->oclass, otyp = otmp->otyp; + const char *s1, *s2, *s3, *what; + int ocls = otmp->oclass, otyp = otmp->otyp; - s1 = s2 = s3 = 0; - /* check for attempted use of accessory commands ('P','R') on armor - and for corresponding armor commands ('W','T') on accessories */ - if (ocls == ARMOR_CLASS) { - if (!strcmp(word, "put on")) - s1 = "W", s2 = "wear", s3 = ""; - else if (!strcmp(word, "remove")) - s1 = "T", s2 = "take", s3 = " off"; - } else if ((ocls == RING_CLASS || otyp == MEAT_RING) || - ocls == AMULET_CLASS || - (otyp == BLINDFOLD || otyp == TOWEL || otyp == LENSES)) { - if (!strcmp(word, "wear")) - s1 = "P", s2 = "put", s3 = " on"; - else if (!strcmp(word, "take off")) - s1 = "R", s2 = "remove", s3 = ""; - } - if (s1) { - what = "that"; - /* quantity for armor and accessory objects is always 1, - but some things should be referred to as plural */ - if (otyp == LENSES || is_gloves(otmp) || is_boots(otmp)) - what = "those"; - pline("Use the '%s' command to %s %s%s.", s1, s2, what, s3); - } else { - pline(silly_thing_to, word); - } + s1 = s2 = s3 = 0; + /* check for attempted use of accessory commands ('P','R') on armor + and for corresponding armor commands ('W','T') on accessories */ + if (ocls == ARMOR_CLASS) { + if (!strcmp(word, "put on")) + s1 = "W", s2 = "wear", s3 = ""; + else if (!strcmp(word, "remove")) + s1 = "T", s2 = "take", s3 = " off"; + } else if ((ocls == RING_CLASS || otyp == MEAT_RING) || + ocls == AMULET_CLASS || + (otyp == BLINDFOLD || otyp == TOWEL || otyp == LENSES)) { + if (!strcmp(word, "wear")) + s1 = "P", s2 = "put", s3 = " on"; + else if (!strcmp(word, "take off")) + s1 = "R", s2 = "remove", s3 = ""; + } + if (s1) { + what = "that"; + /* quantity for armor and accessory objects is always 1, + but some things should be referred to as plural */ + if (otyp == LENSES || is_gloves(otmp) || is_boots(otmp)) + what = "those"; + pline("Use the '%s' command to %s %s%s.", s1, s2, what, s3); + } else { + pline(silly_thing_to, word); + } } STATIC_PTR int ckvalidcat(otmp) register struct obj *otmp; { - /* use allow_category() from pickup.c */ - return((int)allow_category(otmp)); + /* use allow_category() from pickup.c */ + return((int)allow_category(otmp)); } STATIC_PTR int ckunpaid(otmp) register struct obj *otmp; { - return (otmp->unpaid || (Has_contents(otmp) && count_unpaid(otmp))); + return (otmp->unpaid || (Has_contents(otmp) && count_unpaid(otmp))); } boolean wearing_armor() { - return((boolean)(uarm || uarmc || uarmf || uarmg || uarmh || uarms - || uarmu)); + return((boolean)(uarm || uarmc || uarmf || uarmg || uarmh || uarms + || uarmu)); } boolean @@ -1222,7 +1231,7 @@ is_worn(otmp) register struct obj *otmp; { return((boolean)(!!(otmp->owornmask & (W_ARMOR | W_RING | W_AMUL | W_TOOL | - W_SADDLE | W_WEP | W_SWAPWEP | W_QUIVER)))); + W_SADDLE | W_WEP | W_SWAPWEP | W_QUIVER)))); } /* extra xprname() input that askchain() can't pass through safe_qbuf() */ @@ -1237,8 +1246,8 @@ safeq_xprname(obj) struct obj *obj; { return xprname(obj, (char *)0, - safeq_xprn_ctx.let, safeq_xprn_ctx.dot, - 0L, 0L); + safeq_xprn_ctx.let, safeq_xprn_ctx.dot, + 0L, 0L); } /* alternate safe_qbuf() -> short_oname() callback */ @@ -1247,12 +1256,12 @@ safeq_shortxprname(obj) struct obj *obj; { return xprname(obj, ansimpleoname(obj), - safeq_xprn_ctx.let, safeq_xprn_ctx.dot, - 0L, 0L); + safeq_xprn_ctx.let, safeq_xprn_ctx.dot, + 0L, 0L); } static NEARDATA const char removeables[] = - { ARMOR_CLASS, WEAPON_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, 0 }; + { ARMOR_CLASS, WEAPON_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, 0 }; /* interactive version of getobj - used for Drop, Identify and */ /* Takeoff (A). Return the number of times fn was called successfully */ @@ -1264,156 +1273,156 @@ int FDECL((*fn),(OBJ_P)), mx; boolean combo; /* combination menu flag */ unsigned *resultflags; { - int FDECL((*ckfn),(OBJ_P)) = (int FDECL((*),(OBJ_P))) 0; - boolean FDECL((*filter),(OBJ_P)) = (boolean FDECL((*),(OBJ_P))) 0; - boolean takeoff, ident, allflag, m_seen; - int itemcount; - int oletct, iletct, unpaid, oc_of_sym; - char sym, *ip, olets[MAXOCLASSES+5], ilets[MAXOCLASSES+5]; - char extra_removeables[3+1]; /* uwep,uswapwep,uquiver */ - char buf[BUFSZ], qbuf[QBUFSZ]; + int FDECL((*ckfn),(OBJ_P)) = (int FDECL((*),(OBJ_P))) 0; + boolean FDECL((*filter),(OBJ_P)) = (boolean FDECL((*),(OBJ_P))) 0; + boolean takeoff, ident, allflag, m_seen; + int itemcount; + int oletct, iletct, unpaid, oc_of_sym; + char sym, *ip, olets[MAXOCLASSES+5], ilets[MAXOCLASSES+5]; + char extra_removeables[3+1]; /* uwep,uswapwep,uquiver */ + char buf[BUFSZ], qbuf[QBUFSZ]; - if (resultflags) *resultflags = 0; - takeoff = ident = allflag = m_seen = FALSE; - if(!invent){ - You("have nothing to %s.", word); - return(0); - } - add_valid_menu_class(0); /* reset */ - if (taking_off(word)) { - takeoff = TRUE; - filter = is_worn; - } else if (!strcmp(word, "identify")) { - ident = TRUE; - filter = not_fully_identified; - } + if (resultflags) *resultflags = 0; + takeoff = ident = allflag = m_seen = FALSE; + if(!invent){ + You("have nothing to %s.", word); + return(0); + } + add_valid_menu_class(0); /* reset */ + if (taking_off(word)) { + takeoff = TRUE; + filter = is_worn; + } else if (!strcmp(word, "identify")) { + ident = TRUE; + filter = not_fully_identified; + } - iletct = collect_obj_classes(ilets, invent, - FALSE, - filter, &itemcount); - unpaid = count_unpaid(invent); + iletct = collect_obj_classes(ilets, invent, + FALSE, + filter, &itemcount); + unpaid = count_unpaid(invent); - if (ident && !iletct) { - return -1; /* no further identifications */ - } else if (!takeoff && (unpaid || invent)) { - ilets[iletct++] = ' '; - if (unpaid) ilets[iletct++] = 'u'; - if (count_buc(invent, BUC_BLESSED)) ilets[iletct++] = 'B'; - if (count_buc(invent, BUC_UNCURSED)) ilets[iletct++] = 'U'; - if (count_buc(invent, BUC_CURSED)) ilets[iletct++] = 'C'; - if (count_buc(invent, BUC_UNKNOWN)) ilets[iletct++] = 'X'; - if (invent) ilets[iletct++] = 'a'; - } else if (takeoff && invent) { - ilets[iletct++] = ' '; - } - ilets[iletct++] = 'i'; - if (!combo) - ilets[iletct++] = 'm'; /* allow menu presentation on request */ - ilets[iletct] = '\0'; + if (ident && !iletct) { + return -1; /* no further identifications */ + } else if (!takeoff && (unpaid || invent)) { + ilets[iletct++] = ' '; + if (unpaid) ilets[iletct++] = 'u'; + if (count_buc(invent, BUC_BLESSED)) ilets[iletct++] = 'B'; + if (count_buc(invent, BUC_UNCURSED)) ilets[iletct++] = 'U'; + if (count_buc(invent, BUC_CURSED)) ilets[iletct++] = 'C'; + if (count_buc(invent, BUC_UNKNOWN)) ilets[iletct++] = 'X'; + if (invent) ilets[iletct++] = 'a'; + } else if (takeoff && invent) { + ilets[iletct++] = ' '; + } + ilets[iletct++] = 'i'; + if (!combo) + ilets[iletct++] = 'm'; /* allow menu presentation on request */ + ilets[iletct] = '\0'; - for (;;) { - Sprintf(qbuf,"What kinds of thing do you want to %s? [%s]", - word, ilets); - getlin(qbuf, buf); - if (buf[0] == '\033') return(0); - if (index(buf, 'i')) { - if (display_inventory((char *)0, TRUE) == '\033') return 0; - } else - break; - } + for (;;) { + Sprintf(qbuf,"What kinds of thing do you want to %s? [%s]", + word, ilets); + getlin(qbuf, buf); + if (buf[0] == '\033') return(0); + if (index(buf, 'i')) { + if (display_inventory((char *)0, TRUE) == '\033') return 0; + } else + break; + } - extra_removeables[0] = '\0'; - if (takeoff) { - /* arbitrary types of items can be placed in the weapon slots - [any duplicate entries in extra_removeables[] won't matter] */ - if (uwep) (void)strkitten(extra_removeables, uwep->oclass); - if (uswapwep) (void)strkitten(extra_removeables, uswapwep->oclass); - if (uquiver) (void)strkitten(extra_removeables, uquiver->oclass); - } + extra_removeables[0] = '\0'; + if (takeoff) { + /* arbitrary types of items can be placed in the weapon slots + [any duplicate entries in extra_removeables[] won't matter] */ + if (uwep) (void)strkitten(extra_removeables, uwep->oclass); + if (uswapwep) (void)strkitten(extra_removeables, uswapwep->oclass); + if (uquiver) (void)strkitten(extra_removeables, uquiver->oclass); + } - ip = buf; - olets[oletct = 0] = '\0'; - while ((sym = *ip++) != '\0') { - if (sym == ' ') continue; - oc_of_sym = def_char_to_objclass(sym); - if (takeoff && oc_of_sym != MAXOCLASSES) { - if (index(extra_removeables, oc_of_sym)) { - ; /* skip rest of takeoff checks */ - } else if (!index(removeables, oc_of_sym)) { - pline("Not applicable."); - return 0; - } else if (oc_of_sym == ARMOR_CLASS && !wearing_armor()) { - noarmor(FALSE); - return 0; - } else if (oc_of_sym == WEAPON_CLASS && - !uwep && !uswapwep && !uquiver) { - You("are not wielding anything."); - return 0; - } else if (oc_of_sym == RING_CLASS && !uright && !uleft) { - You("are not wearing rings."); - return 0; - } else if (oc_of_sym == AMULET_CLASS && !uamul) { - You("are not wearing an amulet."); - return 0; - } else if (oc_of_sym == TOOL_CLASS && !ublindf) { - You("are not wearing a blindfold."); - return 0; - } - } + ip = buf; + olets[oletct = 0] = '\0'; + while ((sym = *ip++) != '\0') { + if (sym == ' ') continue; + oc_of_sym = def_char_to_objclass(sym); + if (takeoff && oc_of_sym != MAXOCLASSES) { + if (index(extra_removeables, oc_of_sym)) { + ; /* skip rest of takeoff checks */ + } else if (!index(removeables, oc_of_sym)) { + pline("Not applicable."); + return 0; + } else if (oc_of_sym == ARMOR_CLASS && !wearing_armor()) { + noarmor(FALSE); + return 0; + } else if (oc_of_sym == WEAPON_CLASS && + !uwep && !uswapwep && !uquiver) { + You("are not wielding anything."); + return 0; + } else if (oc_of_sym == RING_CLASS && !uright && !uleft) { + You("are not wearing rings."); + return 0; + } else if (oc_of_sym == AMULET_CLASS && !uamul) { + You("are not wearing an amulet."); + return 0; + } else if (oc_of_sym == TOOL_CLASS && !ublindf) { + You("are not wearing a blindfold."); + return 0; + } + } - if (oc_of_sym == COIN_CLASS && !combo) { - context.botl = 1; - } else if (sym == 'a') { - allflag = TRUE; - } else if (sym == 'A') { - /* same as the default */ ; - } else if (sym == 'u') { - add_valid_menu_class('u'); - ckfn = ckunpaid; - } else if (sym == 'B') { - add_valid_menu_class('B'); - ckfn = ckvalidcat; - } else if (sym == 'U') { - add_valid_menu_class('U'); - ckfn = ckvalidcat; - } else if (sym == 'C') { - add_valid_menu_class('C'); - ckfn = ckvalidcat; - } else if (sym == 'X') { - add_valid_menu_class('X'); - ckfn = ckvalidcat; - } else if (sym == 'm') { - m_seen = TRUE; - } else if (oc_of_sym == MAXOCLASSES) { - You("don't have any %c's.", sym); - } else if (oc_of_sym != VENOM_CLASS) { /* suppress venom */ - if (!index(olets, oc_of_sym)) { - add_valid_menu_class(oc_of_sym); - olets[oletct++] = oc_of_sym; - olets[oletct] = 0; - } - } - } + if (oc_of_sym == COIN_CLASS && !combo) { + context.botl = 1; + } else if (sym == 'a') { + allflag = TRUE; + } else if (sym == 'A') { + /* same as the default */ ; + } else if (sym == 'u') { + add_valid_menu_class('u'); + ckfn = ckunpaid; + } else if (sym == 'B') { + add_valid_menu_class('B'); + ckfn = ckvalidcat; + } else if (sym == 'U') { + add_valid_menu_class('U'); + ckfn = ckvalidcat; + } else if (sym == 'C') { + add_valid_menu_class('C'); + ckfn = ckvalidcat; + } else if (sym == 'X') { + add_valid_menu_class('X'); + ckfn = ckvalidcat; + } else if (sym == 'm') { + m_seen = TRUE; + } else if (oc_of_sym == MAXOCLASSES) { + You("don't have any %c's.", sym); + } else if (oc_of_sym != VENOM_CLASS) { /* suppress venom */ + if (!index(olets, oc_of_sym)) { + add_valid_menu_class(oc_of_sym); + olets[oletct++] = oc_of_sym; + olets[oletct] = 0; + } + } + } - if (m_seen) - return (allflag || (!oletct && ckfn != ckunpaid)) ? -2 : -3; - else if (flags.menu_style != MENU_TRADITIONAL && combo && !allflag) - return 0; - else /*!!!! if (allowgold == 2 && !oletct) - !!!! return 1; you dropped gold (or at least tried to) + if (m_seen) + return (allflag || (!oletct && ckfn != ckunpaid)) ? -2 : -3; + else if (flags.menu_style != MENU_TRADITIONAL && combo && !allflag) + return 0; + else /*!!!! if (allowgold == 2 && !oletct) + !!!! return 1; you dropped gold (or at least tried to) !!!! test gold dropping - else*/ { - int cnt = askchain(&invent, olets, allflag, fn, ckfn, mx, word); - /* - * askchain() has already finished the job in this case - * so set a special flag to convey that back to the caller - * so that it won't continue processing. - * Fix for bug C331-1 reported by Irina Rempt-Drijfhout. - */ - if (combo && allflag && resultflags) - *resultflags |= ALL_FINISHED; - return cnt; - } + else*/ { + int cnt = askchain(&invent, olets, allflag, fn, ckfn, mx, word); + /* + * askchain() has already finished the job in this case + * so set a special flag to convey that back to the caller + * so that it won't continue processing. + * Fix for bug C331-1 reported by Irina Rempt-Drijfhout. + */ + if (combo && allflag && resultflags) + *resultflags |= ALL_FINISHED; + return cnt; + } } /* @@ -1430,119 +1439,119 @@ register int allflag, mx; register const char *olets, *word; /* olets is an Obj Class char array */ register int FDECL((*fn),(OBJ_P)), FDECL((*ckfn),(OBJ_P)); { - struct obj *otmp, *otmpo; - register char sym, ilet; - register int cnt = 0, dud = 0, tmp; - boolean takeoff, nodot, ident, take_out, put_in, first, ininv; - char qbuf[QBUFSZ], qpfx[QBUFSZ]; + struct obj *otmp, *otmpo; + register char sym, ilet; + register int cnt = 0, dud = 0, tmp; + boolean takeoff, nodot, ident, take_out, put_in, first, ininv; + char qbuf[QBUFSZ], qpfx[QBUFSZ]; - takeoff = taking_off(word); - ident = !strcmp(word, "identify"); - take_out = !strcmp(word, "take out"); - put_in = !strcmp(word, "put in"); - nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") || - ident || takeoff || take_out || put_in); - ininv = (*objchn == invent); - first = TRUE; - /* Changed so the askchain is interrogated in the order specified. - * For example, if a person specifies =/ then first all rings will be - * asked about followed by all wands -dgk - */ + takeoff = taking_off(word); + ident = !strcmp(word, "identify"); + take_out = !strcmp(word, "take out"); + put_in = !strcmp(word, "put in"); + nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") || + ident || takeoff || take_out || put_in); + ininv = (*objchn == invent); + first = TRUE; + /* Changed so the askchain is interrogated in the order specified. + * For example, if a person specifies =/ then first all rings will be + * asked about followed by all wands -dgk + */ nextclass: - ilet = 'a'-1; - if (*objchn && (*objchn)->oclass == COIN_CLASS) - ilet--; /* extra iteration */ - /* - * Multiple Drop can change the invent chain while it operates - * (dropping a burning potion of oil while levitating creates - * an explosion which can destroy inventory items), so simple - * list traversal - * for (otmp = *objchn; otmp; otmp = otmp2) { - * otmp2 = otmp->nobj; - * ... - * } - * is inadeqate here. Use each object's bypass bit to keep - * track of which list elements have already been processed. - */ - bypass_objlist(*objchn, FALSE); /* clear chain's bypass bits */ - while ((otmp = nxt_unbypassed_obj(*objchn)) != 0) { - if (ilet == 'z') ilet = 'A'; else ilet++; - if (olets && *olets && otmp->oclass != *olets) continue; - if (takeoff && !is_worn(otmp)) continue; - if (ident && !not_fully_identified(otmp)) continue; - if (ckfn && !(*ckfn)(otmp)) continue; - if (!allflag) { - safeq_xprn_ctx.let = ilet; - safeq_xprn_ctx.dot = !nodot; - *qpfx = '\0'; - if (first) { - /* traditional_loot() skips prompting when only one - class of objects is involved, so prefix the first - object being queried here with an explanation why */ - if (take_out || put_in) - Sprintf(qpfx, "%s: ", word), *qpfx = highc(*qpfx); - first = FALSE; - } - (void)safe_qbuf(qbuf, qpfx, "?", - otmp, ininv ? safeq_xprname : doname, - ininv ? safeq_shortxprname : ansimpleoname, - "item"); - sym = (takeoff || ident || otmp->quan < 2L) ? - nyaq(qbuf) : nyNaq(qbuf); - } else - sym = 'y'; + ilet = 'a'-1; + if (*objchn && (*objchn)->oclass == COIN_CLASS) + ilet--; /* extra iteration */ + /* + * Multiple Drop can change the invent chain while it operates + * (dropping a burning potion of oil while levitating creates + * an explosion which can destroy inventory items), so simple + * list traversal + * for (otmp = *objchn; otmp; otmp = otmp2) { + * otmp2 = otmp->nobj; + * ... + * } + * is inadeqate here. Use each object's bypass bit to keep + * track of which list elements have already been processed. + */ + bypass_objlist(*objchn, FALSE); /* clear chain's bypass bits */ + while ((otmp = nxt_unbypassed_obj(*objchn)) != 0) { + if (ilet == 'z') ilet = 'A'; else ilet++; + if (olets && *olets && otmp->oclass != *olets) continue; + if (takeoff && !is_worn(otmp)) continue; + if (ident && !not_fully_identified(otmp)) continue; + if (ckfn && !(*ckfn)(otmp)) continue; + if (!allflag) { + safeq_xprn_ctx.let = ilet; + safeq_xprn_ctx.dot = !nodot; + *qpfx = '\0'; + if (first) { + /* traditional_loot() skips prompting when only one + class of objects is involved, so prefix the first + object being queried here with an explanation why */ + if (take_out || put_in) + Sprintf(qpfx, "%s: ", word), *qpfx = highc(*qpfx); + first = FALSE; + } + (void)safe_qbuf(qbuf, qpfx, "?", + otmp, ininv ? safeq_xprname : doname, + ininv ? safeq_shortxprname : ansimpleoname, + "item"); + sym = (takeoff || ident || otmp->quan < 2L) ? + nyaq(qbuf) : nyNaq(qbuf); + } else + sym = 'y'; - otmpo = otmp; - if (sym == '#') { - /* Number was entered; split the object unless it corresponds - to 'none' or 'all'. 2 special cases: cursed loadstones and - welded weapons (eg, multiple daggers) will remain as merged - unit; done to avoid splitting an object that won't be - droppable (even if we're picking up rather than dropping). - */ - if (!yn_number) - sym = 'n'; - else { - sym = 'y'; - if (yn_number < otmp->quan && splittable(otmp)) - otmp = splitobj(otmp, yn_number); - } - } - switch(sym){ - case 'a': - allflag = 1; - case 'y': - tmp = (*fn)(otmp); - if(tmp < 0) { - if (container_gone(fn)) { - /* otmp caused magic bag to explode; - both are now gone */ - otmp = 0; /* and return */ - } else if (otmp && otmp != otmpo) { - /* split occurred, merge again */ - (void) merged(&otmpo, &otmp); - } - goto ret; - } - cnt += tmp; - if(--mx == 0) goto ret; - case 'n': - if(nodot) dud++; - default: - break; - case 'q': - /* special case for seffects() */ - if (ident) cnt = -1; - goto ret; - } - } - if (olets && *olets && *++olets) - goto nextclass; - if(!takeoff && (dud || cnt)) pline("That was all."); - else if(!dud && !cnt) pline("No applicable objects."); + otmpo = otmp; + if (sym == '#') { + /* Number was entered; split the object unless it corresponds + to 'none' or 'all'. 2 special cases: cursed loadstones and + welded weapons (eg, multiple daggers) will remain as merged + unit; done to avoid splitting an object that won't be + droppable (even if we're picking up rather than dropping). + */ + if (!yn_number) + sym = 'n'; + else { + sym = 'y'; + if (yn_number < otmp->quan && splittable(otmp)) + otmp = splitobj(otmp, yn_number); + } + } + switch(sym){ + case 'a': + allflag = 1; + case 'y': + tmp = (*fn)(otmp); + if(tmp < 0) { + if (container_gone(fn)) { + /* otmp caused magic bag to explode; + both are now gone */ + otmp = 0; /* and return */ + } else if (otmp && otmp != otmpo) { + /* split occurred, merge again */ + (void) merged(&otmpo, &otmp); + } + goto ret; + } + cnt += tmp; + if(--mx == 0) goto ret; + case 'n': + if(nodot) dud++; + default: + break; + case 'q': + /* special case for seffects() */ + if (ident) cnt = -1; + goto ret; + } + } + if (olets && *olets && *++olets) + goto nextclass; + if(!takeoff && (dud || cnt)) pline("That was all."); + else if(!dud && !cnt) pline("No applicable objects."); ret: - bypass_objlist(*objchn, FALSE); - return(cnt); + bypass_objlist(*objchn, FALSE); + return(cnt); } @@ -1559,9 +1568,9 @@ struct obj *otmp; if (otmp->oartifact) discover_artifact((xchar)otmp->oartifact); otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1; if (Is_container(otmp) || otmp->otyp == STATUE) - otmp->cknown = otmp->lknown = 1; + otmp->cknown = otmp->lknown = 1; if (otmp->otyp == EGG && otmp->corpsenm != NON_PM) - learn_egg_type(otmp->corpsenm); + learn_egg_type(otmp->corpsenm); } /* ggetobj callback routine; identify an object and give immediate feedback */ @@ -1585,30 +1594,30 @@ int id_limit; /* assumptions: id_limit > 0 and at least one unID'd item is present */ while (id_limit) { - Sprintf(buf, "What would you like to identify %s?", - first ? "first" : "next"); - n = query_objlist(buf, invent, - SIGNAL_NOMENU|SIGNAL_ESCAPE|USE_INVLET|INVORDER_SORT, - &pick_list, PICK_ANY, not_fully_identified); + Sprintf(buf, "What would you like to identify %s?", + first ? "first" : "next"); + n = query_objlist(buf, invent, + SIGNAL_NOMENU|SIGNAL_ESCAPE|USE_INVLET|INVORDER_SORT, + &pick_list, PICK_ANY, not_fully_identified); - if (n > 0) { - if (n > id_limit) n = id_limit; - for (i = 0; i < n; i++, id_limit--) - (void) identify(pick_list[i].item.a_obj); - free((genericptr_t) pick_list); - mark_synch(); /* Before we loop to pop open another menu */ - first = 0; - } else if (n == -2) { /* player used ESC to quit menu */ - break; - } else if (n == -1) { /* no eligible items found */ - pline("That was all."); - break; - } else if (!--tryct) { /* stop re-prompting */ - pline1(thats_enough_tries); - break; - } else { /* try again */ - pline("Choose an item; use ESC to decline."); - } + if (n > 0) { + if (n > id_limit) n = id_limit; + for (i = 0; i < n; i++, id_limit--) + (void) identify(pick_list[i].item.a_obj); + free((genericptr_t) pick_list); + mark_synch(); /* Before we loop to pop open another menu */ + first = 0; + } else if (n == -2) { /* player used ESC to quit menu */ + break; + } else if (n == -1) { /* no eligible items found */ + pline("That was all."); + break; + } else if (!--tryct) { /* stop re-prompting */ + pline1(thats_enough_tries); + break; + } else { /* try again */ + pline("Choose an item; use ESC to decline."); + } } } @@ -1624,32 +1633,32 @@ boolean learning_id; /* true if we just read unknown identify scroll */ unid_cnt = 0; the_obj = 0; /* if unid_cnt ends up 1, this will be it */ for (obj = invent; obj; obj = obj->nobj) - if (not_fully_identified(obj)) ++unid_cnt, the_obj = obj; + if (not_fully_identified(obj)) ++unid_cnt, the_obj = obj; if (!unid_cnt) { - You("have already identified all %sof your possessions.", - learning_id ? "the rest " : ""); + You("have already identified all %sof your possessions.", + learning_id ? "the rest " : ""); } else if (!id_limit || id_limit >= unid_cnt) { - /* identify everything */ - if (unid_cnt == 1) { - (void) identify(the_obj); - } else { - - /* TODO: use fully_identify_obj and cornline/menu/whatever here */ - for (obj = invent; obj; obj = obj->nobj) - if (not_fully_identified(obj)) (void) identify(obj); - - } + /* identify everything */ + if (unid_cnt == 1) { + (void) identify(the_obj); } else { - /* identify up to `id_limit' items */ - n = 0; - if (flags.menu_style == MENU_TRADITIONAL) - do { - n = ggetobj("identify", identify, id_limit, FALSE, (unsigned *)0); - if (n < 0) break; /* quit or no eligible items */ - } while ((id_limit -= n) > 0); - if (n == 0 || n < -1) - menu_identify(id_limit); + + /* TODO: use fully_identify_obj and cornline/menu/whatever here */ + for (obj = invent; obj; obj = obj->nobj) + if (not_fully_identified(obj)) (void) identify(obj); + + } + } else { + /* identify up to `id_limit' items */ + n = 0; + if (flags.menu_style == MENU_TRADITIONAL) + do { + n = ggetobj("identify", identify, id_limit, FALSE, (unsigned *)0); + if (n < 0) break; /* quit or no eligible items */ + } while ((id_limit -= n) > 0); + if (n == 0 || n < -1) + menu_identify(id_limit); } update_inventory(); } @@ -1664,13 +1673,13 @@ learn_unseen_invent() if (Blind) return; /* sanity check */ for (otmp = invent; otmp; otmp = otmp->nobj) { - if (otmp->dknown) continue; /* already seen */ - /* set dknown, perhaps bknown (for priest[ess]) */ - (void) xname(otmp); - /* - * If object->eknown gets implemented (see learnwand(zap.c)), - * handle deferred discovery here. - */ + if (otmp->dknown) continue; /* already seen */ + /* set dknown, perhaps bknown (for priest[ess]) */ + (void) xname(otmp); + /* + * If object->eknown gets implemented (see learnwand(zap.c)), + * handle deferred discovery here. + */ } update_inventory(); } @@ -1679,11 +1688,11 @@ STATIC_OVL char obj_to_let(obj) /* should of course only be called for things in invent */ register struct obj *obj; { - if (!flags.invlet_constant) { - obj->invlet = NOINVSYM; - reassign(); - } - return obj->invlet; + if (!flags.invlet_constant) { + obj->invlet = NOINVSYM; + reassign(); + } + return obj->invlet; } /* @@ -1696,10 +1705,10 @@ const char *prefix; register struct obj *obj; long quan; { - if (!prefix) prefix = ""; - pline("%s%s%s", - prefix, *prefix ? " " : "", - xprname(obj, (char *)0, obj_to_let(obj), TRUE, 0L, quan)); + if (!prefix) prefix = ""; + pline("%s%s%s", + prefix, *prefix ? " " : "", + xprname(obj, (char *)0, obj_to_let(obj), TRUE, 0L, quan)); } char * @@ -1720,8 +1729,8 @@ long quan; /* if non-0, print this quantity, not obj->quan */ long savequan = 0; if (quan && obj) { - savequan = obj->quan; - obj->quan = quan; + savequan = obj->quan; + obj->quan = quan; } /* @@ -1730,15 +1739,15 @@ long quan; /* if non-0, print this quantity, not obj->quan */ * > Then the object is contained and doesn't have an inventory letter. */ if (cost != 0 || let == '*') { - /* if dot is true, we're doing Iu, otherwise Ix */ - Sprintf(li, "%c - %-45s %6ld %s", - (dot && use_invlet ? obj->invlet : let), - (txt ? txt : doname(obj)), cost, currency(cost)); + /* if dot is true, we're doing Iu, otherwise Ix */ + Sprintf(li, "%c - %-45s %6ld %s", + (dot && use_invlet ? obj->invlet : let), + (txt ? txt : doname(obj)), cost, currency(cost)); } else { - /* ordinary inventory display or pickup message */ - Sprintf(li, "%c - %s%s", - (use_invlet ? obj->invlet : let), - (txt ? txt : doname(obj)), (dot ? "." : "")); + /* ordinary inventory display or pickup message */ + Sprintf(li, "%c - %s%s", + (use_invlet ? obj->invlet : let), + (txt ? txt : doname(obj)), (dot ? "." : "")); } if (savequan) obj->quan = savequan; @@ -1749,8 +1758,8 @@ long quan; /* if non-0, print this quantity, not obj->quan */ int ddoinv() { - (void) display_inventory((char *)0, FALSE); - return 0; + (void) display_inventory((char *)0, FALSE); + return 0; } /* @@ -1769,19 +1778,19 @@ find_unpaid(list, last_found) struct obj *obj; while (list) { - if (list->unpaid) { - if (*last_found) { - /* still looking for previous unpaid object */ - if (list == *last_found) - *last_found = (struct obj *) 0; - } else - return (*last_found = list); - } - if (Has_contents(list)) { - if ((obj = find_unpaid(list->cobj, last_found)) != 0) - return obj; - } - list = list->nobj; + if (list->unpaid) { + if (*last_found) { + /* still looking for previous unpaid object */ + if (list == *last_found) + *last_found = (struct obj *) 0; + } else + return (*last_found = list); + } + if (Has_contents(list)) { + if ((obj = find_unpaid(list->cobj, last_found)) != 0) + return obj; + } + list = list->nobj; } return (struct obj *) 0; } @@ -1797,61 +1806,60 @@ register const char *lets; boolean want_reply; long* out_cnt; { - struct obj *otmp; - char ilet, ret; - char *invlet = flags.inv_order; - int n, classcount; - winid win; /* windows being used */ - static winid local_win = WIN_ERR; /* window for partial menus */ - anything any; - menu_item *selected; + struct obj *otmp; + char ilet, ret; + char *invlet = flags.inv_order; + int i, n, classcount; + winid win; /* windows being used */ + static winid local_win = WIN_ERR; /* window for partial menus */ + anything any; + menu_item *selected; struct obj **oarray; - int i, j; - /* overriden by global flag */ - if (flags.perm_invent) { - win = (lets && *lets) ? local_win : WIN_INVEN; - /* create the first time used */ - if (win == WIN_ERR) - win = local_win = create_nhwindow(NHW_MENU); - } else - win = WIN_INVEN; + /* overriden by global flag */ + if (flags.perm_invent) { + win = (lets && *lets) ? local_win : WIN_INVEN; + /* create the first time used */ + if (win == WIN_ERR) + win = local_win = create_nhwindow(NHW_MENU); + } else + win = WIN_INVEN; - /* - Exit early if no inventory -- but keep going if we are doing - a permanent inventory update. We need to keep going so the - permanent inventory window updates itself to remove the last - item(s) dropped. One down side: the addition of the exception - for permanent inventory window updates _can_ pop the window - up when it's not displayed -- even if it's empty -- because we - don't know at this level if its up or not. This may not be - an issue if empty checks are done before hand and the call - to here is short circuited away. - */ - if (!invent && !(flags.perm_invent && !lets && !want_reply)) { - pline("Not carrying anything."); - return 0; - } + /* + Exit early if no inventory -- but keep going if we are doing + a permanent inventory update. We need to keep going so the + permanent inventory window updates itself to remove the last + item(s) dropped. One down side: the addition of the exception + for permanent inventory window updates _can_ pop the window + up when it's not displayed -- even if it's empty -- because we + don't know at this level if its up or not. This may not be + an issue if empty checks are done before hand and the call + to here is short circuited away. + */ + if (!invent && !(flags.perm_invent && !lets && !want_reply)) { + pline("Not carrying anything."); + return 0; + } - /* oxymoron? temporarily assign permanent inventory letters */ - if (!flags.invlet_constant) reassign(); + /* oxymoron? temporarily assign permanent inventory letters */ + if (!flags.invlet_constant) reassign(); - if (lets && strlen(lets) == 1 && !iflags.override_ID) { - /* when only one item of interest, use pline instead of menus; - we actually use a fake message-line menu in order to allow - the user to perform selection at the --More-- prompt for tty */ - ret = '\0'; - for (otmp = invent; otmp; otmp = otmp->nobj) { - if (otmp->invlet == lets[0]) { - ret = message_menu(lets[0], - want_reply ? PICK_ONE : PICK_NONE, - xprname(otmp, (char *)0, lets[0], TRUE, 0L, 0L)); - if (out_cnt) *out_cnt = -1L; /* select all */ - break; - } - } - return ret; - } + if (lets && strlen(lets) == 1 && !iflags.override_ID) { + /* when only one item of interest, use pline instead of menus; + we actually use a fake message-line menu in order to allow + the user to perform selection at the --More-- prompt for tty */ + ret = '\0'; + for (otmp = invent; otmp; otmp = otmp->nobj) { + if (otmp->invlet == lets[0]) { + ret = message_menu(lets[0], + want_reply ? PICK_ONE : PICK_NONE, + xprname(otmp, (char *)0, lets[0], TRUE, 0L, 0L)); + if (out_cnt) *out_cnt = -1L; /* select all */ + break; + } + } + return ret; + } /* count the number of items */ for (n = 0, otmp = invent; otmp; otmp = otmp->nobj) @@ -1866,20 +1874,20 @@ long* out_cnt; objarr_set(otmp, i++, oarray, (flags.sortloot == 'f')); } - start_menu(win); - if (wizard && iflags.override_ID) { - char prompt[BUFSZ]; - any.a_char = -1; - /* wiz_identify stuffed the wiz_identify cmd character - into iflags.override_ID */ - Sprintf(prompt, "Debug Identify (%s to permanently identify)", - visctrl(iflags.override_ID)); - add_menu(win, NO_GLYPH, &any,' ', iflags.override_ID, ATR_NONE, - prompt, MENU_UNSELECTED); - } + start_menu(win); + if (wizard && iflags.override_ID) { + char prompt[BUFSZ]; + any.a_char = -1; + /* wiz_identify stuffed the wiz_identify cmd character + into iflags.override_ID */ + Sprintf(prompt, "Debug Identify (%s to permanently identify)", + visctrl(iflags.override_ID)); + add_menu(win, NO_GLYPH, &any,' ', iflags.override_ID, ATR_NONE, + prompt, MENU_UNSELECTED); + } nextclass: - classcount = 0; - any = zeroany; /* set all bits to zero */ + classcount = 0; + any = zeroany; /* set all bits to zero */ for(i = 0; i < n; i++) { otmp = oarray[i]; ilet = otmp->invlet; @@ -1896,25 +1904,25 @@ nextclass: MENU_UNSELECTED); } } - if (flags.sortpack) { - if (*++invlet) goto nextclass; - if (--invlet != venom_inv) { - invlet = venom_inv; - goto nextclass; - } - } + if (flags.sortpack) { + if (*++invlet) goto nextclass; + if (--invlet != venom_inv) { + invlet = venom_inv; + goto nextclass; + } + } free(oarray); - end_menu(win, (char *) 0); + end_menu(win, (char *) 0); - n = select_menu(win, want_reply ? PICK_ONE : PICK_NONE, &selected); - if (n > 0) { - ret = selected[0].item.a_char; - if (out_cnt) *out_cnt = selected[0].count; - free((genericptr_t)selected); - } else - ret = !n ? '\0' : '\033'; /* cancelled */ + n = select_menu(win, want_reply ? PICK_ONE : PICK_NONE, &selected); + if (n > 0) { + ret = selected[0].item.a_char; + if (out_cnt) *out_cnt = selected[0].count; + free((genericptr_t)selected); + } else + ret = !n ? '\0' : '\033'; /* cancelled */ - return ret; + return ret; } /* @@ -1929,7 +1937,7 @@ display_inventory(lets, want_reply) register const char *lets; boolean want_reply; { - return display_pickinv(lets, want_reply, (long *)0); + return display_pickinv(lets, want_reply, (long *)0); } /* @@ -1940,49 +1948,49 @@ STATIC_OVL char display_used_invlets(avoidlet) char avoidlet; { - struct obj *otmp; - char ilet, ret = 0; - char *invlet = flags.inv_order; - int n, classcount, invdone = 0; - winid win; - anything any; - menu_item *selected; + struct obj *otmp; + char ilet, ret = 0; + char *invlet = flags.inv_order; + int n, classcount, invdone = 0; + winid win; + anything any; + menu_item *selected; - if (invent) { - win = create_nhwindow(NHW_MENU); - start_menu(win); - while (!invdone) { - any = zeroany; /* set all bits to zero */ - classcount = 0; - for(otmp = invent; otmp; otmp = otmp->nobj) { - ilet = otmp->invlet; - if (ilet == avoidlet) continue; - if (!flags.sortpack || otmp->oclass == *invlet) { - if (flags.sortpack && !classcount) { - any = zeroany; /* zero */ - add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, + if (invent) { + win = create_nhwindow(NHW_MENU); + start_menu(win); + while (!invdone) { + any = zeroany; /* set all bits to zero */ + classcount = 0; + for(otmp = invent; otmp; otmp = otmp->nobj) { + ilet = otmp->invlet; + if (ilet == avoidlet) continue; + if (!flags.sortpack || otmp->oclass == *invlet) { + if (flags.sortpack && !classcount) { + any = zeroany; /* zero */ + add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, let_to_name(*invlet, FALSE, FALSE), MENU_UNSELECTED); - classcount++; - } - any.a_char = ilet; - add_menu(win, obj_to_glyph(otmp), - &any, ilet, 0, ATR_NONE, doname(otmp), - MENU_UNSELECTED); - } - } - if (flags.sortpack && *++invlet) continue; - invdone = 1; - } - end_menu(win, "Inventory letters used:"); + classcount++; + } + any.a_char = ilet; + add_menu(win, obj_to_glyph(otmp), + &any, ilet, 0, ATR_NONE, doname(otmp), + MENU_UNSELECTED); + } + } + if (flags.sortpack && *++invlet) continue; + invdone = 1; + } + end_menu(win, "Inventory letters used:"); - n = select_menu(win, PICK_NONE, &selected); - if (n > 0) { - ret = selected[0].item.a_char; - free((genericptr_t)selected); - } else - ret = !n ? '\0' : '\033'; /* cancelled */ - } - return ret; + n = select_menu(win, PICK_NONE, &selected); + if (n > 0) { + ret = selected[0].item.a_char; + free((genericptr_t)selected); + } else + ret = !n ? '\0' : '\033'; /* cancelled */ + } + return ret; } /* @@ -1996,10 +2004,10 @@ count_unpaid(list) int count = 0; while (list) { - if (list->unpaid) count++; - if (Has_contents(list)) - count += count_unpaid(list->cobj); - list = list->nobj; + if (list->unpaid) count++; + if (Has_contents(list)) + count += count_unpaid(list->cobj); + list = list->nobj; } return count; } @@ -2019,17 +2027,17 @@ count_buc(list, type) int count = 0; for ( ; list; list = list->nobj) { - /* coins are "none of the above" as far as BUCX filtering goes */ - if (list->oclass == COIN_CLASS) continue; - /* priests always know bless/curse state */ - if (Role_if(PM_PRIEST)) list->bknown = 1; + /* coins are "none of the above" as far as BUCX filtering goes */ + if (list->oclass == COIN_CLASS) continue; + /* priests always know bless/curse state */ + if (Role_if(PM_PRIEST)) list->bknown = 1; - /* check whether this object matches the requested type */ - if (!list->bknown ? (type == BUC_UNKNOWN) : - list->blessed ? (type == BUC_BLESSED) : - list->cursed ? (type == BUC_CURSED) : - (type == BUC_UNCURSED)) - ++count; + /* check whether this object matches the requested type */ + if (!list->bknown ? (type == BUC_UNKNOWN) : + list->blessed ? (type == BUC_BLESSED) : + list->cursed ? (type == BUC_CURSED) : + (type == BUC_UNCURSED)) + ++count; } return count; } @@ -2038,17 +2046,17 @@ long count_contents(container, nested, quantity, everything) struct obj *container; boolean nested, /* include contents of any nested containers */ - quantity, /* count all vs count separate stacks */ - everything; /* all objects vs only unpaid objects */ + quantity, /* count all vs count separate stacks */ + everything; /* all objects vs only unpaid objects */ { struct obj *otmp; long count = 0L; for (otmp = container->cobj; otmp; otmp = otmp->nobj) { - if (nested && Has_contents(otmp)) - count += count_contents(otmp, nested, quantity, everything); - if (everything || otmp->unpaid) - count += quantity ? otmp->quan : 1L; + if (nested && Has_contents(otmp)) + count += count_contents(otmp, nested, quantity, everything); + if (everything || otmp->unpaid) + count += quantity ? otmp->quan : 1L; } return count; } @@ -2066,15 +2074,15 @@ dounpaid() count = count_unpaid(invent); if (count == 1) { - marker = (struct obj *) 0; - otmp = find_unpaid(invent, &marker); - cost = unpaid_cost(otmp, FALSE); - iflags.suppress_price++; /* suppress "(unpaid)" suffix */ - pline1(xprname(otmp, distant_name(otmp, doname), - carried(otmp) ? otmp->invlet : CONTAINED_SYM, - TRUE, cost, 0L)); - iflags.suppress_price--; - return; + marker = (struct obj *) 0; + otmp = find_unpaid(invent, &marker); + cost = unpaid_cost(otmp, FALSE); + iflags.suppress_price++; /* suppress "(unpaid)" suffix */ + pline1(xprname(otmp, distant_name(otmp, doname), + carried(otmp) ? otmp->invlet : CONTAINED_SYM, + TRUE, cost, 0L)); + iflags.suppress_price--; + return; } win = create_nhwindow(NHW_MENU); @@ -2083,63 +2091,63 @@ dounpaid() if (!flags.invlet_constant) reassign(); do { - classcount = 0; - for (otmp = invent; otmp; otmp = otmp->nobj) { - ilet = otmp->invlet; - if (otmp->unpaid) { - if (!flags.sortpack || otmp->oclass == *invlet) { - if (flags.sortpack && !classcount) { + classcount = 0; + for (otmp = invent; otmp; otmp = otmp->nobj) { + ilet = otmp->invlet; + if (otmp->unpaid) { + if (!flags.sortpack || otmp->oclass == *invlet) { + if (flags.sortpack && !classcount) { putstr(win, 0, let_to_name(*invlet, TRUE, FALSE)); - classcount++; - } + classcount++; + } - totcost += cost = unpaid_cost(otmp, FALSE); - iflags.suppress_price++; /* suppress "(unpaid)" suffix */ - putstr(win, 0, xprname(otmp, distant_name(otmp, doname), - ilet, TRUE, cost, 0L)); - iflags.suppress_price--; - num_so_far++; - } - } - } + totcost += cost = unpaid_cost(otmp, FALSE); + iflags.suppress_price++; /* suppress "(unpaid)" suffix */ + putstr(win, 0, xprname(otmp, distant_name(otmp, doname), + ilet, TRUE, cost, 0L)); + iflags.suppress_price--; + num_so_far++; + } + } + } } while (flags.sortpack && (*++invlet)); if (count > num_so_far) { - /* something unpaid is contained */ - if (flags.sortpack) + /* something unpaid is contained */ + if (flags.sortpack) putstr(win, 0, let_to_name(CONTAINED_SYM, TRUE, FALSE)); - /* - * Search through the container objects in the inventory for - * unpaid items. The top level inventory items have already - * been listed. - */ - for (otmp = invent; otmp; otmp = otmp->nobj) { - if (Has_contents(otmp)) { - long contcost = 0L; + /* + * Search through the container objects in the inventory for + * unpaid items. The top level inventory items have already + * been listed. + */ + for (otmp = invent; otmp; otmp = otmp->nobj) { + if (Has_contents(otmp)) { + long contcost = 0L; - marker = (struct obj *) 0; /* haven't found any */ - while (find_unpaid(otmp->cobj, &marker)) { - totcost += cost = unpaid_cost(marker, FALSE); - contcost += cost; - if (otmp->cknown) { - iflags.suppress_price++; /* suppress "(unpaid)" sfx */ - putstr(win, 0, - xprname(marker, distant_name(marker, doname), - CONTAINED_SYM, TRUE, cost, 0L)); - iflags.suppress_price--; - } - } - if (!otmp->cknown) { - char contbuf[BUFSZ]; + marker = (struct obj *) 0; /* haven't found any */ + while (find_unpaid(otmp->cobj, &marker)) { + totcost += cost = unpaid_cost(marker, FALSE); + contcost += cost; + if (otmp->cknown) { + iflags.suppress_price++; /* suppress "(unpaid)" sfx */ + putstr(win, 0, + xprname(marker, distant_name(marker, doname), + CONTAINED_SYM, TRUE, cost, 0L)); + iflags.suppress_price--; + } + } + if (!otmp->cknown) { + char contbuf[BUFSZ]; - /* Shopkeeper knows what to charge for contents */ - Sprintf(contbuf, "%s contents", s_suffix(xname(otmp))); - putstr(win, 0, - xprname((struct obj *)0, contbuf, - CONTAINED_SYM, TRUE, contcost, 0L)); - } - } - } + /* Shopkeeper knows what to charge for contents */ + Sprintf(contbuf, "%s contents", s_suffix(xname(otmp))); + putstr(win, 0, + xprname((struct obj *)0, contbuf, + CONTAINED_SYM, TRUE, contcost, 0L)); + } + } + } } putstr(win, 0, ""); @@ -2163,104 +2171,104 @@ this_type_only(obj) int dotypeinv() { - char c = '\0'; - int n, i = 0; - char *extra_types, types[BUFSZ]; - int class_count, oclass, unpaid_count, itemcount; - boolean billx = *u.ushops && doinvbill(0); - menu_item *pick_list; - boolean traditional = TRUE; - const char *prompt = "What type of object do you want an inventory of?"; + char c = '\0'; + int n, i = 0; + char *extra_types, types[BUFSZ]; + int class_count, oclass, unpaid_count, itemcount; + boolean billx = *u.ushops && doinvbill(0); + menu_item *pick_list; + boolean traditional = TRUE; + const char *prompt = "What type of object do you want an inventory of?"; - if (!invent && !billx) { - You("aren't carrying anything."); - return 0; - } - unpaid_count = count_unpaid(invent); - if (flags.menu_style != MENU_TRADITIONAL) { - if (flags.menu_style == MENU_FULL || - flags.menu_style == MENU_PARTIAL) { - traditional = FALSE; - i = UNPAID_TYPES; - if (billx) i |= BILLED_TYPES; - n = query_category(prompt, invent, i, &pick_list, PICK_ONE); - if (!n) return 0; - this_type = c = pick_list[0].item.a_int; - free((genericptr_t) pick_list); - } - } - if (traditional) { - /* collect a list of classes of objects carried, for use as a prompt */ - types[0] = 0; - class_count = collect_obj_classes(types, invent, - FALSE, - (boolean FDECL((*),(OBJ_P))) 0, &itemcount); - if (unpaid_count) { - Strcat(types, "u"); - class_count++; - } - if (billx) { - Strcat(types, "x"); - class_count++; - } - /* add everything not already included; user won't see these */ - extra_types = eos(types); - *extra_types++ = '\033'; - if (!unpaid_count) *extra_types++ = 'u'; - if (!billx) *extra_types++ = 'x'; - *extra_types = '\0'; /* for index() */ - for (i = 0; i < MAXOCLASSES; i++) - if (!index(types, def_oc_syms[i].sym)) { - *extra_types++ = def_oc_syms[i].sym; - *extra_types = '\0'; - } + if (!invent && !billx) { + You("aren't carrying anything."); + return 0; + } + unpaid_count = count_unpaid(invent); + if (flags.menu_style != MENU_TRADITIONAL) { + if (flags.menu_style == MENU_FULL || + flags.menu_style == MENU_PARTIAL) { + traditional = FALSE; + i = UNPAID_TYPES; + if (billx) i |= BILLED_TYPES; + n = query_category(prompt, invent, i, &pick_list, PICK_ONE); + if (!n) return 0; + this_type = c = pick_list[0].item.a_int; + free((genericptr_t) pick_list); + } + } + if (traditional) { + /* collect a list of classes of objects carried, for use as a prompt */ + types[0] = 0; + class_count = collect_obj_classes(types, invent, + FALSE, + (boolean FDECL((*),(OBJ_P))) 0, &itemcount); + if (unpaid_count) { + Strcat(types, "u"); + class_count++; + } + if (billx) { + Strcat(types, "x"); + class_count++; + } + /* add everything not already included; user won't see these */ + extra_types = eos(types); + *extra_types++ = '\033'; + if (!unpaid_count) *extra_types++ = 'u'; + if (!billx) *extra_types++ = 'x'; + *extra_types = '\0'; /* for index() */ + for (i = 0; i < MAXOCLASSES; i++) + if (!index(types, def_oc_syms[i].sym)) { + *extra_types++ = def_oc_syms[i].sym; + *extra_types = '\0'; + } - if(class_count > 1) { - c = yn_function(prompt, types, '\0'); - savech(c); - if(c == '\0') { - clear_nhwindow(WIN_MESSAGE); - return 0; - } - } else { - /* only one thing to itemize */ - if (unpaid_count) - c = 'u'; - else if (billx) - c = 'x'; - else - c = types[0]; - } - } - if (c == 'x') { - if (billx) - (void) doinvbill(1); - else - pline("No used-up objects on your shopping bill."); - return 0; - } - if (c == 'u') { - if (unpaid_count) - dounpaid(); - else - You("are not carrying any unpaid objects."); - return 0; - } - if (traditional) { - oclass = def_char_to_objclass(c); /* change to object class */ - if (oclass == COIN_CLASS) { - return doprgold(); - } else if (index(types, c) > index(types, '\033')) { - You("have no such objects."); - return 0; - } - this_type = oclass; - } - if (query_objlist((char *) 0, invent, - (flags.invlet_constant ? USE_INVLET : 0)|INVORDER_SORT, - &pick_list, PICK_NONE, this_type_only) > 0) - free((genericptr_t)pick_list); - return 0; + if(class_count > 1) { + c = yn_function(prompt, types, '\0'); + savech(c); + if(c == '\0') { + clear_nhwindow(WIN_MESSAGE); + return 0; + } + } else { + /* only one thing to itemize */ + if (unpaid_count) + c = 'u'; + else if (billx) + c = 'x'; + else + c = types[0]; + } + } + if (c == 'x') { + if (billx) + (void) doinvbill(1); + else + pline("No used-up objects on your shopping bill."); + return 0; + } + if (c == 'u') { + if (unpaid_count) + dounpaid(); + else + You("are not carrying any unpaid objects."); + return 0; + } + if (traditional) { + oclass = def_char_to_objclass(c); /* change to object class */ + if (oclass == COIN_CLASS) { + return doprgold(); + } else if (index(types, c) > index(types, '\033')) { + You("have no such objects."); + return 0; + } + this_type = oclass; + } + if (query_objlist((char *) 0, invent, + (flags.invlet_constant ? USE_INVLET : 0)|INVORDER_SORT, + &pick_list, PICK_NONE, this_type_only) > 0) + free((genericptr_t)pick_list); + return 0; } /* return a string describing the dungeon feature at if there @@ -2270,65 +2278,65 @@ dfeature_at(x, y, buf) int x, y; char *buf; { - struct rm *lev = &levl[x][y]; - int ltyp = lev->typ, cmap = -1; - const char *dfeature = 0; - static char altbuf[BUFSZ]; + struct rm *lev = &levl[x][y]; + int ltyp = lev->typ, cmap = -1; + const char *dfeature = 0; + static char altbuf[BUFSZ]; - if (IS_DOOR(ltyp)) { - switch (lev->doormask) { - case D_NODOOR: cmap = S_ndoor; break; /* "doorway" */ - case D_ISOPEN: cmap = S_vodoor; break; /* "open door" */ - case D_BROKEN: dfeature = "broken door"; break; - default: cmap = S_vcdoor; break; /* "closed door" */ - } - /* override door description for open drawbridge */ - if (is_drawbridge_wall(x, y) >= 0) - dfeature = "open drawbridge portcullis", cmap = -1; - } else if (IS_FOUNTAIN(ltyp)) - cmap = S_fountain; /* "fountain" */ - else if (IS_THRONE(ltyp)) - cmap = S_throne; /* "opulent throne" */ - else if (is_lava(x,y)) - cmap = S_lava; /* "molten lava" */ - else if (is_ice(x,y)) - cmap = S_ice; /* "ice" */ - else if (is_pool(x,y)) - dfeature = "pool of water"; - else if (IS_SINK(ltyp)) - cmap = S_sink; /* "sink" */ - else if (IS_ALTAR(ltyp)) { - Sprintf(altbuf, "%saltar to %s (%s)", - ((lev->altarmask & AM_SHRINE) && - (Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) ? - "high " : "", - a_gname(), - align_str(Amask2align(lev->altarmask & ~AM_SHRINE))); - dfeature = altbuf; - } else if ((x == xupstair && y == yupstair) || - (x == sstairs.sx && y == sstairs.sy && sstairs.up)) - cmap = S_upstair; /* "staircase up" */ - else if ((x == xdnstair && y == ydnstair) || - (x == sstairs.sx && y == sstairs.sy && !sstairs.up)) - cmap = S_dnstair; /* "staircase down" */ - else if (x == xupladder && y == yupladder) - cmap = S_upladder; /* "ladder up" */ - else if (x == xdnladder && y == ydnladder) - cmap = S_dnladder; /* "ladder down" */ - else if (ltyp == DRAWBRIDGE_DOWN) - cmap = S_vodbridge; /* "lowered drawbridge" */ - else if (ltyp == DBWALL) - cmap = S_vcdbridge; /* "raised drawbridge" */ - else if (IS_GRAVE(ltyp)) - cmap = S_grave; /* "grave" */ - else if (ltyp == TREE) - cmap = S_tree; /* "tree" */ - else if (ltyp == IRONBARS) - dfeature = "set of iron bars"; + if (IS_DOOR(ltyp)) { + switch (lev->doormask) { + case D_NODOOR: cmap = S_ndoor; break; /* "doorway" */ + case D_ISOPEN: cmap = S_vodoor; break; /* "open door" */ + case D_BROKEN: dfeature = "broken door"; break; + default: cmap = S_vcdoor; break; /* "closed door" */ + } + /* override door description for open drawbridge */ + if (is_drawbridge_wall(x, y) >= 0) + dfeature = "open drawbridge portcullis", cmap = -1; + } else if (IS_FOUNTAIN(ltyp)) + cmap = S_fountain; /* "fountain" */ + else if (IS_THRONE(ltyp)) + cmap = S_throne; /* "opulent throne" */ + else if (is_lava(x,y)) + cmap = S_lava; /* "molten lava" */ + else if (is_ice(x,y)) + cmap = S_ice; /* "ice" */ + else if (is_pool(x,y)) + dfeature = "pool of water"; + else if (IS_SINK(ltyp)) + cmap = S_sink; /* "sink" */ + else if (IS_ALTAR(ltyp)) { + Sprintf(altbuf, "%saltar to %s (%s)", + ((lev->altarmask & AM_SHRINE) && + (Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) ? + "high " : "", + a_gname(), + align_str(Amask2align(lev->altarmask & ~AM_SHRINE))); + dfeature = altbuf; + } else if ((x == xupstair && y == yupstair) || + (x == sstairs.sx && y == sstairs.sy && sstairs.up)) + cmap = S_upstair; /* "staircase up" */ + else if ((x == xdnstair && y == ydnstair) || + (x == sstairs.sx && y == sstairs.sy && !sstairs.up)) + cmap = S_dnstair; /* "staircase down" */ + else if (x == xupladder && y == yupladder) + cmap = S_upladder; /* "ladder up" */ + else if (x == xdnladder && y == ydnladder) + cmap = S_dnladder; /* "ladder down" */ + else if (ltyp == DRAWBRIDGE_DOWN) + cmap = S_vodbridge; /* "lowered drawbridge" */ + else if (ltyp == DBWALL) + cmap = S_vcdbridge; /* "raised drawbridge" */ + else if (IS_GRAVE(ltyp)) + cmap = S_grave; /* "grave" */ + else if (ltyp == TREE) + cmap = S_tree; /* "tree" */ + else if (ltyp == IRONBARS) + dfeature = "set of iron bars"; - if (cmap >= 0) dfeature = defsyms[cmap].explanation; - if (dfeature) Strcpy(buf, dfeature); - return dfeature; + if (cmap >= 0) dfeature = defsyms[cmap].explanation; + if (dfeature) Strcpy(buf, dfeature); + return dfeature; } /* look at what is here; if there are many objects (pile_limit or more), @@ -2338,146 +2346,146 @@ look_here(obj_cnt, picked_some) int obj_cnt; /* obj_cnt > 0 implies that autopickup is in progess */ boolean picked_some; { - struct obj *otmp; - struct trap *trap; - const char *verb = Blind ? "feel" : "see"; - const char *dfeature = (char *)0; - char fbuf[BUFSZ], fbuf2[BUFSZ]; - winid tmpwin; - boolean skip_objects, felt_cockatrice = FALSE; + struct obj *otmp; + struct trap *trap; + const char *verb = Blind ? "feel" : "see"; + const char *dfeature = (char *)0; + char fbuf[BUFSZ], fbuf2[BUFSZ]; + winid tmpwin; + boolean skip_objects, felt_cockatrice = FALSE; - /* default pile_limit is 5; a value of 0 means "never skip" - (and 1 effectively forces "always skip") */ - skip_objects = (flags.pile_limit > 0 && obj_cnt >= flags.pile_limit); - if (u.uswallow && u.ustuck) { - struct monst *mtmp = u.ustuck; - Sprintf(fbuf, "Contents of %s %s", - s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH)); - /* Skip "Contents of " by using fbuf index 12 */ - You("%s to %s what is lying in %s.", - Blind ? "try" : "look around", verb, &fbuf[12]); - otmp = mtmp->minvent; - if (otmp) { - for ( ; otmp; otmp = otmp->nobj) { - /* If swallower is an animal, it should have become stone but... */ - if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE); - } - if (Blind) Strcpy(fbuf, "You feel"); - Strcat(fbuf,":"); - (void) display_minventory(mtmp, MINV_ALL, fbuf); - } else { - You("%s no objects here.", verb); - } - return(!!Blind); - } - if (!skip_objects && (trap = t_at(u.ux,u.uy)) && trap->tseen) - There("is %s here.", - an(defsyms[trap_to_defsym(trap->ttyp)].explanation)); + /* default pile_limit is 5; a value of 0 means "never skip" + (and 1 effectively forces "always skip") */ + skip_objects = (flags.pile_limit > 0 && obj_cnt >= flags.pile_limit); + if (u.uswallow && u.ustuck) { + struct monst *mtmp = u.ustuck; + Sprintf(fbuf, "Contents of %s %s", + s_suffix(mon_nam(mtmp)), mbodypart(mtmp, STOMACH)); + /* Skip "Contents of " by using fbuf index 12 */ + You("%s to %s what is lying in %s.", + Blind ? "try" : "look around", verb, &fbuf[12]); + otmp = mtmp->minvent; + if (otmp) { + for ( ; otmp; otmp = otmp->nobj) { + /* If swallower is an animal, it should have become stone but... */ + if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE); + } + if (Blind) Strcpy(fbuf, "You feel"); + Strcat(fbuf,":"); + (void) display_minventory(mtmp, MINV_ALL, fbuf); + } else { + You("%s no objects here.", verb); + } + return(!!Blind); + } + if (!skip_objects && (trap = t_at(u.ux,u.uy)) && trap->tseen) + There("is %s here.", + an(defsyms[trap_to_defsym(trap->ttyp)].explanation)); - otmp = level.objects[u.ux][u.uy]; - dfeature = dfeature_at(u.ux, u.uy, fbuf2); - if (dfeature && !strcmp(dfeature, "pool of water") && Underwater) - dfeature = 0; + otmp = level.objects[u.ux][u.uy]; + dfeature = dfeature_at(u.ux, u.uy, fbuf2); + if (dfeature && !strcmp(dfeature, "pool of water") && Underwater) + dfeature = 0; - if (Blind) { - boolean drift = Is_airlevel(&u.uz) || Is_waterlevel(&u.uz); + if (Blind) { + boolean drift = Is_airlevel(&u.uz) || Is_waterlevel(&u.uz); - if (dfeature && !strncmp(dfeature, "altar ", 6)) { - /* don't say "altar" twice, dfeature has more info */ - You("try to feel what is here."); - } else { - const char *where = (Blind && !can_reach_floor(TRUE)) ? - "lying beneath you" : "lying here on the ", - *onwhat = (Blind && !can_reach_floor(TRUE)) ? - "" : surface(u.ux,u.uy); + if (dfeature && !strncmp(dfeature, "altar ", 6)) { + /* don't say "altar" twice, dfeature has more info */ + You("try to feel what is here."); + } else { + const char *where = (Blind && !can_reach_floor(TRUE)) ? + "lying beneath you" : "lying here on the ", + *onwhat = (Blind && !can_reach_floor(TRUE)) ? + "" : surface(u.ux,u.uy); - You("try to feel what is %s%s.", - drift ? "floating here" : where, - drift ? "" : onwhat); - } - if (dfeature && !drift && !strcmp(dfeature, surface(u.ux,u.uy))) - dfeature = 0; /* ice already identifed */ - if (!can_reach_floor(TRUE)) { - pline("But you can't reach it!"); - return(0); - } - } + You("try to feel what is %s%s.", + drift ? "floating here" : where, + drift ? "" : onwhat); + } + if (dfeature && !drift && !strcmp(dfeature, surface(u.ux,u.uy))) + dfeature = 0; /* ice already identifed */ + if (!can_reach_floor(TRUE)) { + pline("But you can't reach it!"); + return(0); + } + } - if (dfeature) - Sprintf(fbuf, "There is %s here.", an(dfeature)); + if (dfeature) + Sprintf(fbuf, "There is %s here.", an(dfeature)); - if (!otmp || is_lava(u.ux,u.uy) || (is_pool(u.ux,u.uy) && !Underwater)) { - if (dfeature) pline1(fbuf); - read_engr_at(u.ux, u.uy); /* Eric Backus */ - if (!skip_objects && (Blind || !dfeature)) - You("%s no objects here.", verb); - return(!!Blind); - } - /* we know there is something here */ + if (!otmp || is_lava(u.ux,u.uy) || (is_pool(u.ux,u.uy) && !Underwater)) { + if (dfeature) pline1(fbuf); + read_engr_at(u.ux, u.uy); /* Eric Backus */ + if (!skip_objects && (Blind || !dfeature)) + You("%s no objects here.", verb); + return(!!Blind); + } + /* we know there is something here */ - if (skip_objects) { - if (dfeature) pline1(fbuf); - read_engr_at(u.ux, u.uy); /* Eric Backus */ - if (obj_cnt == 1 && otmp->quan == 1L) - There("is %s object here.", picked_some ? "another" : "an"); - else - There("are %s%s objects here.", - (obj_cnt < 5) ? "a few" : - (obj_cnt < 10) ? "several" : "many", - picked_some ? " more" : ""); - for ( ; otmp; otmp = otmp->nexthere) - if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) { - pline("%s %s%s.", - (obj_cnt > 1) ? "Including" : - (otmp->quan > 1L) ? "They're" : "It's", - corpse_xname(otmp, (const char *)0, CXN_ARTICLE), - poly_when_stoned(youmonst.data) ? "" : - ", unfortunately"); - feel_cockatrice(otmp, FALSE); - break; - } - } else if (!otmp->nexthere) { - /* only one object */ - if (dfeature) pline1(fbuf); - read_engr_at(u.ux, u.uy); /* Eric Backus */ - You("%s here %s.", verb, doname(otmp)); - iflags.last_msg = PLNMSG_ONE_ITEM_HERE; - if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE); - } else { - char buf[BUFSZ]; + if (skip_objects) { + if (dfeature) pline1(fbuf); + read_engr_at(u.ux, u.uy); /* Eric Backus */ + if (obj_cnt == 1 && otmp->quan == 1L) + There("is %s object here.", picked_some ? "another" : "an"); + else + There("are %s%s objects here.", + (obj_cnt < 5) ? "a few" : + (obj_cnt < 10) ? "several" : "many", + picked_some ? " more" : ""); + for ( ; otmp; otmp = otmp->nexthere) + if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) { + pline("%s %s%s.", + (obj_cnt > 1) ? "Including" : + (otmp->quan > 1L) ? "They're" : "It's", + corpse_xname(otmp, (const char *)0, CXN_ARTICLE), + poly_when_stoned(youmonst.data) ? "" : + ", unfortunately"); + feel_cockatrice(otmp, FALSE); + break; + } + } else if (!otmp->nexthere) { + /* only one object */ + if (dfeature) pline1(fbuf); + read_engr_at(u.ux, u.uy); /* Eric Backus */ + You("%s here %s.", verb, doname(otmp)); + iflags.last_msg = PLNMSG_ONE_ITEM_HERE; + if (otmp->otyp == CORPSE) feel_cockatrice(otmp, FALSE); + } else { + char buf[BUFSZ]; - display_nhwindow(WIN_MESSAGE, FALSE); - tmpwin = create_nhwindow(NHW_MENU); - if(dfeature) { - putstr(tmpwin, 0, fbuf); - putstr(tmpwin, 0, ""); - } - Sprintf(buf, "%s that %s here:", - picked_some ? "Other things" : "Things", - Blind ? "you feel" : "are"); - putstr(tmpwin, 0, buf); - for ( ; otmp; otmp = otmp->nexthere) { - if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) { - felt_cockatrice = TRUE; - Sprintf(buf, "%s...", doname(otmp)); - putstr(tmpwin, 0, buf); - break; - } - putstr(tmpwin, 0, doname(otmp)); - } - display_nhwindow(tmpwin, TRUE); - destroy_nhwindow(tmpwin); - if (felt_cockatrice) feel_cockatrice(otmp, FALSE); - read_engr_at(u.ux, u.uy); /* Eric Backus */ - } - return(!!Blind); + display_nhwindow(WIN_MESSAGE, FALSE); + tmpwin = create_nhwindow(NHW_MENU); + if(dfeature) { + putstr(tmpwin, 0, fbuf); + putstr(tmpwin, 0, ""); + } + Sprintf(buf, "%s that %s here:", + picked_some ? "Other things" : "Things", + Blind ? "you feel" : "are"); + putstr(tmpwin, 0, buf); + for ( ; otmp; otmp = otmp->nexthere) { + if (otmp->otyp == CORPSE && will_feel_cockatrice(otmp, FALSE)) { + felt_cockatrice = TRUE; + Sprintf(buf, "%s...", doname(otmp)); + putstr(tmpwin, 0, buf); + break; + } + putstr(tmpwin, 0, doname(otmp)); + } + display_nhwindow(tmpwin, TRUE); + destroy_nhwindow(tmpwin); + if (felt_cockatrice) feel_cockatrice(otmp, FALSE); + read_engr_at(u.ux, u.uy); /* Eric Backus */ + } + return(!!Blind); } /* explicilty look at what is here, including all objects */ int dolook() { - return look_here(0, FALSE); + return look_here(0, FALSE); } boolean @@ -2485,11 +2493,11 @@ will_feel_cockatrice(otmp, force_touch) struct obj *otmp; boolean force_touch; { - if ((Blind || force_touch) && !uarmg && !Stone_resistance && - (otmp->otyp == CORPSE && - touch_petrifies(&mons[otmp->corpsenm]))) - return TRUE; - return FALSE; + if ((Blind || force_touch) && !uarmg && !Stone_resistance && + (otmp->otyp == CORPSE && + touch_petrifies(&mons[otmp->corpsenm]))) + return TRUE; + return FALSE; } void @@ -2497,138 +2505,138 @@ feel_cockatrice(otmp, force_touch) struct obj *otmp; boolean force_touch; { - char kbuf[BUFSZ]; + char kbuf[BUFSZ]; - if (will_feel_cockatrice(otmp, force_touch)) { - /* "the corpse" */ - Strcpy(kbuf, corpse_xname(otmp, (const char *)0, CXN_PFX_THE)); + if (will_feel_cockatrice(otmp, force_touch)) { + /* "the corpse" */ + Strcpy(kbuf, corpse_xname(otmp, (const char *)0, CXN_PFX_THE)); - if (poly_when_stoned(youmonst.data)) - You("touched %s with your bare %s.", - kbuf, makeplural(body_part(HAND))); - else - pline("Touching %s is a fatal mistake...", kbuf); - /* normalize body shape here; hand, not body_part(HAND) */ - Sprintf(kbuf, "touching %s bare-handed", killer_xname(otmp)); - /* will call polymon() for the poly_when_stoned() case */ - instapetrify(kbuf); - } + if (poly_when_stoned(youmonst.data)) + You("touched %s with your bare %s.", + kbuf, makeplural(body_part(HAND))); + else + pline("Touching %s is a fatal mistake...", kbuf); + /* normalize body shape here; hand, not body_part(HAND) */ + Sprintf(kbuf, "touching %s bare-handed", killer_xname(otmp)); + /* will call polymon() for the poly_when_stoned() case */ + instapetrify(kbuf); + } } void stackobj(obj) struct obj *obj; { - struct obj *otmp; + struct obj *otmp; - for(otmp = level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) - if(otmp != obj && merged(&obj,&otmp)) - break; - return; + for(otmp = level.objects[obj->ox][obj->oy]; otmp; otmp = otmp->nexthere) + if(otmp != obj && merged(&obj,&otmp)) + break; + return; } STATIC_OVL boolean mergable(otmp, obj) /* returns TRUE if obj & otmp can be merged */ - register struct obj *otmp, *obj; + register struct obj *otmp, *obj; { - int objnamelth = 0, otmpnamelth = 0; - if (obj->otyp != otmp->otyp) return FALSE; - /* coins of the same kind will always merge */ - if (obj->oclass == COIN_CLASS) return TRUE; - if (obj->unpaid != otmp->unpaid || - obj->spe != otmp->spe || obj->dknown != otmp->dknown || - (obj->bknown != otmp->bknown && !Role_if(PM_PRIEST)) || - obj->cursed != otmp->cursed || obj->blessed != otmp->blessed || - obj->no_charge != otmp->no_charge || - obj->obroken != otmp->obroken || - obj->otrapped != otmp->otrapped || - obj->lamplit != otmp->lamplit || - obj->greased != otmp->greased || - obj->oeroded != otmp->oeroded || - obj->oeroded2 != otmp->oeroded2 || - obj->bypass != otmp->bypass) - return(FALSE); + int objnamelth = 0, otmpnamelth = 0; + if (obj->otyp != otmp->otyp) return FALSE; + /* coins of the same kind will always merge */ + if (obj->oclass == COIN_CLASS) return TRUE; + if (obj->unpaid != otmp->unpaid || + obj->spe != otmp->spe || obj->dknown != otmp->dknown || + (obj->bknown != otmp->bknown && !Role_if(PM_PRIEST)) || + obj->cursed != otmp->cursed || obj->blessed != otmp->blessed || + obj->no_charge != otmp->no_charge || + obj->obroken != otmp->obroken || + obj->otrapped != otmp->otrapped || + obj->lamplit != otmp->lamplit || + obj->greased != otmp->greased || + obj->oeroded != otmp->oeroded || + obj->oeroded2 != otmp->oeroded2 || + obj->bypass != otmp->bypass) + return(FALSE); - if (obj->nomerge) /* explicitly marked to prevent merge */ - return FALSE; + if (obj->nomerge) /* explicitly marked to prevent merge */ + return FALSE; - if ((obj->oclass==WEAPON_CLASS || obj->oclass==ARMOR_CLASS) && - (obj->oerodeproof!=otmp->oerodeproof || obj->rknown!=otmp->rknown)) - return FALSE; + if ((obj->oclass==WEAPON_CLASS || obj->oclass==ARMOR_CLASS) && + (obj->oerodeproof!=otmp->oerodeproof || obj->rknown!=otmp->rknown)) + return FALSE; - if (obj->oclass == FOOD_CLASS && (obj->oeaten != otmp->oeaten || - obj->orotten != otmp->orotten)) - return(FALSE); + if (obj->oclass == FOOD_CLASS && (obj->oeaten != otmp->oeaten || + obj->orotten != otmp->orotten)) + return(FALSE); - if (obj->otyp == CORPSE || obj->otyp == EGG || obj->otyp == TIN) { - if (obj->corpsenm != otmp->corpsenm) - return FALSE; - } + if (obj->otyp == CORPSE || obj->otyp == EGG || obj->otyp == TIN) { + if (obj->corpsenm != otmp->corpsenm) + return FALSE; + } - /* hatching eggs don't merge; ditto for revivable corpses */ - if ((obj->otyp == EGG && (obj->timed || otmp->timed)) || - (obj->otyp == CORPSE && otmp->corpsenm >= LOW_PM && - is_reviver(&mons[otmp->corpsenm]))) - return FALSE; + /* hatching eggs don't merge; ditto for revivable corpses */ + if ((obj->otyp == EGG && (obj->timed || otmp->timed)) || + (obj->otyp == CORPSE && otmp->corpsenm >= LOW_PM && + is_reviver(&mons[otmp->corpsenm]))) + return FALSE; - /* allow candle merging only if their ages are close */ - /* see begin_burn() for a reference for the magic "25" */ - if (Is_candle(obj) && obj->age/25 != otmp->age/25) - return(FALSE); + /* allow candle merging only if their ages are close */ + /* see begin_burn() for a reference for the magic "25" */ + if (Is_candle(obj) && obj->age/25 != otmp->age/25) + return(FALSE); - /* burning potions of oil never merge */ - if (obj->otyp == POT_OIL && obj->lamplit) - return FALSE; + /* burning potions of oil never merge */ + if (obj->otyp == POT_OIL && obj->lamplit) + return FALSE; - /* don't merge surcharged item with base-cost item */ - if (obj->unpaid && !same_price(obj, otmp)) - return FALSE; + /* don't merge surcharged item with base-cost item */ + if (obj->unpaid && !same_price(obj, otmp)) + return FALSE; - /* if they have names, make sure they're the same */ - objnamelth = strlen(safe_oname(obj)); - otmpnamelth = strlen(safe_oname(otmp)); - if ( (objnamelth != otmpnamelth && - ((objnamelth && otmpnamelth) || obj->otyp == CORPSE) - ) || - (objnamelth && otmpnamelth && - strncmp(ONAME(obj), ONAME(otmp), objnamelth))) - return FALSE; + /* if they have names, make sure they're the same */ + objnamelth = strlen(safe_oname(obj)); + otmpnamelth = strlen(safe_oname(otmp)); + if ( (objnamelth != otmpnamelth && + ((objnamelth && otmpnamelth) || obj->otyp == CORPSE) + ) || + (objnamelth && otmpnamelth && + strncmp(ONAME(obj), ONAME(otmp), objnamelth))) + return FALSE; - /* for the moment, any additional information is incompatible */ - if (has_omonst(obj) || has_omid(obj) || has_olong(obj) || - has_omonst(otmp) || has_omid(otmp) || has_olong(otmp)) - return FALSE; + /* for the moment, any additional information is incompatible */ + if (has_omonst(obj) || has_omid(obj) || has_olong(obj) || + has_omonst(otmp) || has_omid(otmp) || has_olong(otmp)) + return FALSE; - if(obj->oartifact != otmp->oartifact) return FALSE; + if(obj->oartifact != otmp->oartifact) return FALSE; - if(obj->known == otmp->known || - !objects[otmp->otyp].oc_uses_known) { - return((boolean)(objects[obj->otyp].oc_merge)); - } else return(FALSE); + if(obj->known == otmp->known || + !objects[otmp->otyp].oc_uses_known) { + return((boolean)(objects[obj->otyp].oc_merge)); + } else return(FALSE); } int doprgold() { - /* the messages used to refer to "carrying gold", but that didn't - take containers into account */ + /* the messages used to refer to "carrying gold", but that didn't + take containers into account */ long umoney = money_cnt(invent); - if(!umoney) - Your("wallet is empty."); - else - Your("wallet contains %ld %s.", umoney, currency(umoney)); - shopper_financial_report(); - return 0; + if(!umoney) + Your("wallet is empty."); + else + Your("wallet contains %ld %s.", umoney, currency(umoney)); + shopper_financial_report(); + return 0; } int doprwep() { if (!uwep) { - You("are empty %s.", body_part(HANDED)); + You("are empty %s.", body_part(HANDED)); } else { - prinv((char *)0, uwep, 0L); - if (u.twoweap) prinv((char *)0, uswapwep, 0L); + prinv((char *)0, uwep, 0L); + if (u.twoweap) prinv((char *)0, uswapwep, 0L); } return 0; } @@ -2639,95 +2647,95 @@ noarmor(report_uskin) boolean report_uskin; { if (!uskin || !report_uskin) { - You("are not wearing any armor."); + You("are not wearing any armor."); } else { - char *p, *uskinname, buf[BUFSZ]; + char *p, *uskinname, buf[BUFSZ]; - uskinname = strcpy(buf, simpleonames(uskin)); - /* shorten "set of dragon scales" to " scales" - and " dragon scale mail" to " scale mail" */ - if (!strncmpi(uskinname, "set of ", 7)) uskinname += 7; - if ((p = strstri(uskinname, " dragon ")) != 0) - while ((p[1] = p[8]) != '\0') ++p; + uskinname = strcpy(buf, simpleonames(uskin)); + /* shorten "set of dragon scales" to " scales" + and " dragon scale mail" to " scale mail" */ + if (!strncmpi(uskinname, "set of ", 7)) uskinname += 7; + if ((p = strstri(uskinname, " dragon ")) != 0) + while ((p[1] = p[8]) != '\0') ++p; - You("are not wearing armor but have %s embedded in your skin.", - uskinname); + You("are not wearing armor but have %s embedded in your skin.", + uskinname); } } int doprarm() { - if (!wearing_armor()) { - noarmor(TRUE); - } else { - char lets[8]; - register int ct = 0; + if (!wearing_armor()) { + noarmor(TRUE); + } else { + char lets[8]; + register int ct = 0; - if(uarmu) lets[ct++] = obj_to_let(uarmu); - if(uarm) lets[ct++] = obj_to_let(uarm); - if(uarmc) lets[ct++] = obj_to_let(uarmc); - if(uarmh) lets[ct++] = obj_to_let(uarmh); - if(uarms) lets[ct++] = obj_to_let(uarms); - if(uarmg) lets[ct++] = obj_to_let(uarmg); - if(uarmf) lets[ct++] = obj_to_let(uarmf); - lets[ct] = 0; - (void) display_inventory(lets, FALSE); - } - return 0; + if(uarmu) lets[ct++] = obj_to_let(uarmu); + if(uarm) lets[ct++] = obj_to_let(uarm); + if(uarmc) lets[ct++] = obj_to_let(uarmc); + if(uarmh) lets[ct++] = obj_to_let(uarmh); + if(uarms) lets[ct++] = obj_to_let(uarms); + if(uarmg) lets[ct++] = obj_to_let(uarmg); + if(uarmf) lets[ct++] = obj_to_let(uarmf); + lets[ct] = 0; + (void) display_inventory(lets, FALSE); + } + return 0; } int doprring() { - if(!uleft && !uright) - You("are not wearing any rings."); - else { - char lets[3]; - register int ct = 0; + if(!uleft && !uright) + You("are not wearing any rings."); + else { + char lets[3]; + register int ct = 0; - if(uleft) lets[ct++] = obj_to_let(uleft); - if(uright) lets[ct++] = obj_to_let(uright); - lets[ct] = 0; - (void) display_inventory(lets, FALSE); - } - return 0; + if(uleft) lets[ct++] = obj_to_let(uleft); + if(uright) lets[ct++] = obj_to_let(uright); + lets[ct] = 0; + (void) display_inventory(lets, FALSE); + } + return 0; } int dopramulet() { - if (!uamul) - You("are not wearing an amulet."); - else - prinv((char *)0, uamul, 0L); - return 0; + if (!uamul) + You("are not wearing an amulet."); + else + prinv((char *)0, uamul, 0L); + return 0; } STATIC_OVL boolean tool_in_use(obj) struct obj *obj; { - if ((obj->owornmask & (W_TOOL | W_SADDLE)) != 0L) return TRUE; - if (obj->oclass != TOOL_CLASS) return FALSE; - return (boolean)(obj == uwep || obj->lamplit || - (obj->otyp == LEASH && obj->leashmon)); + if ((obj->owornmask & (W_TOOL | W_SADDLE)) != 0L) return TRUE; + if (obj->oclass != TOOL_CLASS) return FALSE; + return (boolean)(obj == uwep || obj->lamplit || + (obj->otyp == LEASH && obj->leashmon)); } int doprtool() { - struct obj *otmp; - int ct = 0; - char lets[52+1]; + struct obj *otmp; + int ct = 0; + char lets[52+1]; - for (otmp = invent; otmp; otmp = otmp->nobj) - if (tool_in_use(otmp)) - lets[ct++] = obj_to_let(otmp); - lets[ct] = '\0'; - if (!ct) You("are not using any tools."); - else (void) display_inventory(lets, FALSE); - return 0; + for (otmp = invent; otmp; otmp = otmp->nobj) + if (tool_in_use(otmp)) + lets[ct++] = obj_to_let(otmp); + lets[ct] = '\0'; + if (!ct) You("are not using any tools."); + else (void) display_inventory(lets, FALSE); + return 0; } /* '*' command; combines the ')' + '[' + '=' + '"' + '(' commands; @@ -2735,17 +2743,17 @@ doprtool() int doprinuse() { - struct obj *otmp; - int ct = 0; - char lets[52+1]; + struct obj *otmp; + int ct = 0; + char lets[52+1]; - for (otmp = invent; otmp; otmp = otmp->nobj) - if (is_worn(otmp) || tool_in_use(otmp)) - lets[ct++] = obj_to_let(otmp); - lets[ct] = '\0'; - if (!ct) You("are not wearing or wielding anything."); - else (void) display_inventory(lets, FALSE); - return 0; + for (otmp = invent; otmp; otmp = otmp->nobj) + if (is_worn(otmp) || tool_in_use(otmp)) + lets[ct++] = obj_to_let(otmp); + lets[ct] = '\0'; + if (!ct) You("are not wearing or wielding anything."); + else (void) display_inventory(lets, FALSE); + return 0; } /* @@ -2756,23 +2764,23 @@ useupf(obj, numused) register struct obj *obj; long numused; { - register struct obj *otmp; - boolean at_u = (obj->ox == u.ux && obj->oy == u.uy); + register struct obj *otmp; + boolean at_u = (obj->ox == u.ux && obj->oy == u.uy); - /* burn_floor_paper() keeps an object pointer that it tries to - * useupf() multiple times, so obj must survive if plural */ - if (obj->quan > numused) - otmp = splitobj(obj, numused); - else - otmp = obj; - if(costly_spot(otmp->ox, otmp->oy)) { - if(index(u.urooms, *in_rooms(otmp->ox, otmp->oy, 0))) - addtobill(otmp, FALSE, FALSE, FALSE); - else (void)stolen_value(otmp, otmp->ox, otmp->oy, FALSE, FALSE); - } - delobj(otmp); - if (at_u && u.uundetected && hides_under(youmonst.data)) - (void) hideunder(&youmonst); + /* burn_floor_objects() keeps an object pointer that it tries to + * useupf() multiple times, so obj must survive if plural */ + if (obj->quan > numused) + otmp = splitobj(obj, numused); + else + otmp = obj; + if(costly_spot(otmp->ox, otmp->oy)) { + if(index(u.urooms, *in_rooms(otmp->ox, otmp->oy, 0))) + addtobill(otmp, FALSE, FALSE, FALSE); + else (void)stolen_value(otmp, otmp->ox, otmp->oy, FALSE, FALSE); + } + delobj(otmp); + if (at_u && u.uundetected && hides_under(youmonst.data)) + (void) hideunder(&youmonst); } /* @@ -2780,19 +2788,19 @@ long numused; * This must match the object class order. */ STATIC_VAR NEARDATA const char *names[] = { 0, - "Illegal objects", "Weapons", "Armor", "Rings", "Amulets", - "Tools", "Comestibles", "Potions", "Scrolls", "Spellbooks", - "Wands", "Coins", "Gems/Stones", "Boulders/Statues", "Iron balls", - "Chains", "Venoms" + "Illegal objects", "Weapons", "Armor", "Rings", "Amulets", + "Tools", "Comestibles", "Potions", "Scrolls", "Spellbooks", + "Wands", "Coins", "Gems/Stones", "Boulders/Statues", "Iron balls", + "Chains", "Venoms" }; static NEARDATA const char oth_symbols[] = { - CONTAINED_SYM, - '\0' + CONTAINED_SYM, + '\0' }; static NEARDATA const char *oth_names[] = { - "Bagged/Boxed items" + "Bagged/Boxed items" }; static NEARDATA char *invbuf = (char *)0; @@ -2805,29 +2813,29 @@ boolean unpaid,showsym; { const char *ocsymfmt = " ('%c')"; const int invbuf_sympadding = 8; /* arbitrary */ - const char *class_name; - const char *pos; - int oclass = (let >= 1 && let < MAXOCLASSES) ? let : 0; - unsigned len; + const char *class_name; + const char *pos; + int oclass = (let >= 1 && let < MAXOCLASSES) ? let : 0; + unsigned len; - if (oclass) - class_name = names[oclass]; - else if ((pos = index(oth_symbols, let)) != 0) - class_name = oth_names[pos - oth_symbols]; - else - class_name = names[0]; + if (oclass) + class_name = names[oclass]; + else if ((pos = index(oth_symbols, let)) != 0) + class_name = oth_names[pos - oth_symbols]; + else + class_name = names[0]; len = strlen(class_name) + (unpaid ? sizeof "unpaid_" : sizeof "") + (oclass ? (strlen(ocsymfmt)+invbuf_sympadding) : 0); - if (len > invbufsiz) { - if (invbuf) free((genericptr_t)invbuf); - invbufsiz = len + 10; /* add slop to reduce incremental realloc */ - invbuf = (char *) alloc(invbufsiz); - } - if (unpaid) - Strcat(strcpy(invbuf, "Unpaid "), class_name); - else - Strcpy(invbuf, class_name); + if (len > invbufsiz) { + if (invbuf) free((genericptr_t)invbuf); + invbufsiz = len + 10; /* add slop to reduce incremental realloc */ + invbuf = (char *) alloc(invbufsiz); + } + if (unpaid) + Strcat(strcpy(invbuf, "Unpaid "), class_name); + else + Strcpy(invbuf, class_name); if ((oclass != 0) && showsym) { char *bp = eos(invbuf); int mlen = invbuf_sympadding - strlen(class_name); @@ -2837,37 +2845,37 @@ boolean unpaid,showsym; *bp = '\0'; Sprintf(eos(invbuf), ocsymfmt, def_oc_syms[oclass].sym); } - return invbuf; + return invbuf; } /* release the static buffer used by let_to_name() */ void free_invbuf() { - if (invbuf) free((genericptr_t)invbuf), invbuf = (char *)0; - invbufsiz = 0; + if (invbuf) free((genericptr_t)invbuf), invbuf = (char *)0; + invbufsiz = 0; } /* give consecutive letters to every item in inventory (for !fixinv mode) */ void reassign() { - register int i; - register struct obj *obj; + register int i; + register struct obj *obj; - for(obj = invent, i = 0; obj; obj = obj->nobj, i++) { - if (obj->oclass == COIN_CLASS && obj->invlet == GOLD_SYM) - --i; /* keep $ instead of using up i'th letter */ - else - if (i < 52) - obj->invlet = (i < 26) ? ('a'+i) : ('A'+i-26); - else if (obj->oclass == COIN_CLASS) - obj->invlet = GOLD_SYM; - else - obj->invlet = NOINVSYM; - } - if (i >= 52) i = 52 - 1; - lastinvnr = i; + for(obj = invent, i = 0; obj; obj = obj->nobj, i++) { + if (obj->oclass == COIN_CLASS && obj->invlet == GOLD_SYM) + --i; /* keep $ instead of using up i'th letter */ + else + if (i < 52) + obj->invlet = (i < 26) ? ('a'+i) : ('A'+i-26); + else if (obj->oclass == COIN_CLASS) + obj->invlet = GOLD_SYM; + else + obj->invlet = NOINVSYM; + } + if (i >= 52) i = 52 - 1; + lastinvnr = i; } /* #adjust command @@ -2897,169 +2905,169 @@ reassign() int doorganize() /* inventory organizer by Del Lamb */ { - struct obj *obj, *otmp, *splitting, *bumped; - int ix, cur, trycnt; - char let; - char alphabet[52+1], buf[52+1]; - char qbuf[QBUFSZ]; - char allowall[3]; /* { ALLOW_COUNT, ALL_CLASSES, 0 } */ - const char *adj_type; + struct obj *obj, *otmp, *splitting, *bumped; + int ix, cur, trycnt; + char let; + char alphabet[52+1], buf[52+1]; + char qbuf[QBUFSZ]; + char allowall[3]; /* { ALLOW_COUNT, ALL_CLASSES, 0 } */ + const char *adj_type; - if (!invent) { - You("aren't carrying anything to adjust."); - return 0; - } + if (!invent) { + You("aren't carrying anything to adjust."); + return 0; + } - if (!flags.invlet_constant) reassign(); - /* get object the user wants to organize (the 'from' slot) */ - allowall[0] = ALLOW_COUNT; - allowall[1] = ALL_CLASSES; - allowall[2] = '\0'; - if (!(obj = getobj(allowall,"adjust"))) return(0); + if (!flags.invlet_constant) reassign(); + /* get object the user wants to organize (the 'from' slot) */ + allowall[0] = ALLOW_COUNT; + allowall[1] = ALL_CLASSES; + allowall[2] = '\0'; + if (!(obj = getobj(allowall,"adjust"))) return(0); - /* figure out whether user gave a split count to getobj() */ - splitting = bumped = 0; - for (otmp = invent; otmp; otmp = otmp->nobj) - if (otmp->nobj == obj) { /* knowledge of splitobj() operation */ - if (otmp->invlet == obj->invlet) splitting = otmp; - break; - } + /* figure out whether user gave a split count to getobj() */ + splitting = bumped = 0; + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp->nobj == obj) { /* knowledge of splitobj() operation */ + if (otmp->invlet == obj->invlet) splitting = otmp; + break; + } - /* initialize the list with all lower and upper case letters */ - for (ix = 0, let = 'a'; let <= 'z'; ) alphabet[ix++] = let++; - for (let = 'A'; let <= 'Z'; ) alphabet[ix++] = let++; - alphabet[ix] = '\0'; - /* for floating inv letters, truncate list after the first open slot */ - if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < 52) - alphabet[ix + (splitting ? 0 : 1)] = '\0'; + /* initialize the list with all lower and upper case letters */ + for (ix = 0, let = 'a'; let <= 'z'; ) alphabet[ix++] = let++; + for (let = 'A'; let <= 'Z'; ) alphabet[ix++] = let++; + alphabet[ix] = '\0'; + /* for floating inv letters, truncate list after the first open slot */ + if (!flags.invlet_constant && (ix = inv_cnt(FALSE)) < 52) + alphabet[ix + (splitting ? 0 : 1)] = '\0'; - /* blank out all the letters currently in use in the inventory */ - /* except those that will be merged with the selected object */ - for (otmp = invent; otmp; otmp = otmp->nobj) - if (otmp != obj && !mergable(otmp, obj)) { - let = otmp->invlet; - if (let >= 'a' && let <= 'z') - alphabet[let - 'a'] = ' '; - else if (let >= 'A' && let <= 'Z') - alphabet[let - 'A' + 26] = ' '; - } + /* blank out all the letters currently in use in the inventory */ + /* except those that will be merged with the selected object */ + for (otmp = invent; otmp; otmp = otmp->nobj) + if (otmp != obj && !mergable(otmp, obj)) { + let = otmp->invlet; + if (let >= 'a' && let <= 'z') + alphabet[let - 'a'] = ' '; + else if (let >= 'A' && let <= 'Z') + alphabet[let - 'A' + 26] = ' '; + } - /* compact the list by removing all the blanks */ - for (ix = cur = 0; alphabet[ix]; ix++) - if (alphabet[ix] != ' ') buf[cur++] = alphabet[ix]; - if (!cur && obj->invlet == NOINVSYM) buf[cur++] = NOINVSYM; - buf[cur] = '\0'; - /* and by dashing runs of letters */ - if(cur > 5) compactify(buf); + /* compact the list by removing all the blanks */ + for (ix = cur = 0; alphabet[ix]; ix++) + if (alphabet[ix] != ' ') buf[cur++] = alphabet[ix]; + if (!cur && obj->invlet == NOINVSYM) buf[cur++] = NOINVSYM; + buf[cur] = '\0'; + /* and by dashing runs of letters */ + if(cur > 5) compactify(buf); - /* get 'to' slot to use as destination */ - Sprintf(qbuf, "Adjust letter to what [%s]%s?", buf, - invent ? " (? see used letters)" : ""); - for (trycnt = 1; ; ++trycnt) { - let = yn_function(qbuf, (char *)0, '\0'); - if(let == '?' || let == '*') { - let = display_used_invlets(splitting ? obj->invlet : 0); - if (!let) continue; - if (let == '\033') goto noadjust; - } - if (index(quitchars, let) || - /* adjusting to same slot is meaningful since all - compatible stacks get collected along the way, - but splitting to same slot is not */ - (splitting && let == obj->invlet)) { + /* get 'to' slot to use as destination */ + Sprintf(qbuf, "Adjust letter to what [%s]%s?", buf, + invent ? " (? see used letters)" : ""); + for (trycnt = 1; ; ++trycnt) { + let = yn_function(qbuf, (char *)0, '\0'); + if(let == '?' || let == '*') { + let = display_used_invlets(splitting ? obj->invlet : 0); + if (!let) continue; + if (let == '\033') goto noadjust; + } + if (index(quitchars, let) || + /* adjusting to same slot is meaningful since all + compatible stacks get collected along the way, + but splitting to same slot is not */ + (splitting && let == obj->invlet)) { noadjust: - if (splitting) (void) merged(&splitting, &obj); - pline1(Never_mind); - return 0; - } - if ((letter(let) && let != '@') || index(buf, let)) - break; /* got one */ - if (trycnt == 5) goto noadjust; - pline("Select an inventory slot letter."); /* else try again */ - } + if (splitting) (void) merged(&splitting, &obj); + pline1(Never_mind); + return 0; + } + if ((letter(let) && let != '@') || index(buf, let)) + break; /* got one */ + if (trycnt == 5) goto noadjust; + pline("Select an inventory slot letter."); /* else try again */ + } - /* change the inventory and print the resulting item */ - adj_type = !splitting ? "Moving:" : "Splitting:"; + /* change the inventory and print the resulting item */ + adj_type = !splitting ? "Moving:" : "Splitting:"; - /* - * don't use freeinv/addinv to avoid double-touching artifacts, - * dousing lamps, losing luck, cursing loadstone, etc. - */ - extract_nobj(obj, &invent); + /* + * don't use freeinv/addinv to avoid double-touching artifacts, + * dousing lamps, losing luck, cursing loadstone, etc. + */ + extract_nobj(obj, &invent); - for (otmp = invent; otmp; ) { - if (!splitting) { - if (merged(&otmp, &obj)) { - adj_type = "Merging:"; - obj = otmp; - otmp = otmp->nobj; - extract_nobj(obj, &invent); - continue; /* otmp has already been updated */ - } else if (otmp->invlet == let) { - adj_type = "Swapping:"; - otmp->invlet = obj->invlet; - } - } else { - /* splitting: don't merge extra compatible stacks; - if destination is compatible, do merge with it, - otherwise bump whatever is there to an open slot */ - if (otmp->invlet == let) { - int olth = 0; + for (otmp = invent; otmp; ) { + if (!splitting) { + if (merged(&otmp, &obj)) { + adj_type = "Merging:"; + obj = otmp; + otmp = otmp->nobj; + extract_nobj(obj, &invent); + continue; /* otmp has already been updated */ + } else if (otmp->invlet == let) { + adj_type = "Swapping:"; + otmp->invlet = obj->invlet; + } + } else { + /* splitting: don't merge extra compatible stacks; + if destination is compatible, do merge with it, + otherwise bump whatever is there to an open slot */ + if (otmp->invlet == let) { + int olth = 0; - if (has_oname(obj)) olth = strlen(ONAME(obj)); - /* ugly hack: if these objects aren't going to merge - solely because they have conflicting user-assigned - names, strip off the name of the one being moved */ - if (olth && !obj->oartifact && !mergable(otmp, obj)) { - char *holdname = ONAME(obj); - ONAME(obj) = (char *)0; - /* restore name iff merging is still not possible */ - if (!mergable(otmp, obj)) { - ONAME(obj) = holdname; - holdname = (char *)0; - } else free((genericptr_t)holdname); - } + if (has_oname(obj)) olth = strlen(ONAME(obj)); + /* ugly hack: if these objects aren't going to merge + solely because they have conflicting user-assigned + names, strip off the name of the one being moved */ + if (olth && !obj->oartifact && !mergable(otmp, obj)) { + char *holdname = ONAME(obj); + ONAME(obj) = (char *)0; + /* restore name iff merging is still not possible */ + if (!mergable(otmp, obj)) { + ONAME(obj) = holdname; + holdname = (char *)0; + } else free((genericptr_t)holdname); + } - if (merged(&otmp, &obj)) { - obj = otmp; - extract_nobj(obj, &invent); - } else if (inv_cnt(FALSE) >= 52) { - (void) merged(&splitting, &obj); /* undo split */ - /* "knapsack cannot accommodate any more items" */ - Your("pack is too full."); - return 0; - } else { - bumped = otmp; - extract_nobj(bumped, &invent); - } - break; - } /* found 'to' slot */ - } /* splitting */ - otmp = otmp->nobj; - } + if (merged(&otmp, &obj)) { + obj = otmp; + extract_nobj(obj, &invent); + } else if (inv_cnt(FALSE) >= 52) { + (void) merged(&splitting, &obj); /* undo split */ + /* "knapsack cannot accommodate any more items" */ + Your("pack is too full."); + return 0; + } else { + bumped = otmp; + extract_nobj(bumped, &invent); + } + break; + } /* found 'to' slot */ + } /* splitting */ + otmp = otmp->nobj; + } - /* inline addinv; insert loose object at beginning of inventory */ - obj->invlet = let; - obj->nobj = invent; - obj->where = OBJ_INVENT; - invent = obj; - reorder_invent(); - if (bumped) { - /* splitting the 'from' stack is causing an incompatible - stack in the 'to' slot to be moved into an open one; - we need to do another inline insertion to inventory */ - assigninvlet(bumped); - bumped->nobj = invent; - bumped->where = OBJ_INVENT; - invent = bumped; - reorder_invent(); - } + /* inline addinv; insert loose object at beginning of inventory */ + obj->invlet = let; + obj->nobj = invent; + obj->where = OBJ_INVENT; + invent = obj; + reorder_invent(); + if (bumped) { + /* splitting the 'from' stack is causing an incompatible + stack in the 'to' slot to be moved into an open one; + we need to do another inline insertion to inventory */ + assigninvlet(bumped); + bumped->nobj = invent; + bumped->where = OBJ_INVENT; + invent = bumped; + reorder_invent(); + } - /* messages deferred until inventory has been fully reestablished */ - prinv(adj_type, obj, 0L); - if (bumped) prinv("Moving:", bumped, 0L); - update_inventory(); - return(0); + /* messages deferred until inventory has been fully reestablished */ + prinv(adj_type, obj, 0L); + if (bumped) prinv("Moving:", bumped, 0L); + update_inventory(); + return(0); } /* common to display_minventory and display_cinventory */ @@ -3067,21 +3075,21 @@ STATIC_OVL void invdisp_nothing(hdr, txt) const char *hdr, *txt; { - winid win; - anything any; - menu_item *selected; + winid win; + anything any; + menu_item *selected; - any = zeroany; - win = create_nhwindow(NHW_MENU); - start_menu(win); - add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, hdr, MENU_UNSELECTED); - add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); - add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, txt, MENU_UNSELECTED); - end_menu(win, (char *)0); - if (select_menu(win, PICK_NONE, &selected) > 0) - free((genericptr_t)selected); - destroy_nhwindow(win); - return; + any = zeroany; + win = create_nhwindow(NHW_MENU); + start_menu(win); + add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, hdr, MENU_UNSELECTED); + add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); + add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, txt, MENU_UNSELECTED); + end_menu(win, (char *)0); + if (select_menu(win, PICK_NONE, &selected) > 0) + free((genericptr_t)selected); + destroy_nhwindow(win); + return; } /* query_objlist callback: return things that could possibly be worn/wielded */ @@ -3090,10 +3098,10 @@ worn_wield_only(obj) struct obj *obj; { return (obj->oclass == WEAPON_CLASS - || obj->oclass == ARMOR_CLASS - || obj->oclass == AMULET_CLASS - || obj->oclass == RING_CLASS - || obj->oclass == TOOL_CLASS); + || obj->oclass == ARMOR_CLASS + || obj->oclass == AMULET_CLASS + || obj->oclass == RING_CLASS + || obj->oclass == TOOL_CLASS); } /* @@ -3113,42 +3121,42 @@ register struct monst *mon; int dflags; char *title; { - struct obj *ret; - char tmp[QBUFSZ]; - int n; - menu_item *selected = 0; - int do_all = (dflags & MINV_ALL) != 0, - incl_hero = (do_all && u.uswallow && mon == u.ustuck), - have_inv = (mon->minvent != 0), - have_any = (have_inv || incl_hero); + struct obj *ret; + char tmp[QBUFSZ]; + int n; + menu_item *selected = 0; + int do_all = (dflags & MINV_ALL) != 0, + incl_hero = (do_all && u.uswallow && mon == u.ustuck), + have_inv = (mon->minvent != 0), + have_any = (have_inv || incl_hero); - Sprintf(tmp,"%s %s:", s_suffix(noit_Monnam(mon)), - do_all ? "possessions" : "armament"); + Sprintf(tmp,"%s %s:", s_suffix(noit_Monnam(mon)), + do_all ? "possessions" : "armament"); - if (do_all ? have_any : (mon->misc_worn_check || MON_WEP(mon))) { - /* Fool the 'weapon in hand' routine into - * displaying 'weapon in claw', etc. properly. - */ - youmonst.data = mon->data; + if (do_all ? have_any : (mon->misc_worn_check || MON_WEP(mon))) { + /* Fool the 'weapon in hand' routine into + * displaying 'weapon in claw', etc. properly. + */ + youmonst.data = mon->data; - n = query_objlist(title ? title : tmp, mon->minvent, - INVORDER_SORT | (incl_hero ? INCLUDE_HERO : 0), - &selected, - (dflags & MINV_NOLET) ? PICK_NONE : PICK_ONE, - do_all ? allow_all : worn_wield_only); + n = query_objlist(title ? title : tmp, mon->minvent, + INVORDER_SORT | (incl_hero ? INCLUDE_HERO : 0), + &selected, + (dflags & MINV_NOLET) ? PICK_NONE : PICK_ONE, + do_all ? allow_all : worn_wield_only); - set_uasmon(); - } else { - invdisp_nothing(title ? title : tmp, "(none)"); - n = 0; - } + set_uasmon(); + } else { + invdisp_nothing(title ? title : tmp, "(none)"); + n = 0; + } - if (n > 0) { - ret = selected[0].item.a_obj; - free((genericptr_t)selected); - } else - ret = (struct obj *) 0; - return ret; + if (n > 0) { + ret = selected[0].item.a_obj; + free((genericptr_t)selected); + } else + ret = (struct obj *) 0; + return ret; } /* @@ -3159,28 +3167,28 @@ struct obj * display_cinventory(obj) register struct obj *obj; { - struct obj *ret; - char qbuf[QBUFSZ]; - int n; - menu_item *selected = 0; + struct obj *ret; + char qbuf[QBUFSZ]; + int n; + menu_item *selected = 0; - (void)safe_qbuf(qbuf, "Contents of ", ":", - obj, doname, ansimpleoname, "that"); + (void)safe_qbuf(qbuf, "Contents of ", ":", + obj, doname, ansimpleoname, "that"); - if (obj->cobj) { - n = query_objlist(qbuf, obj->cobj, INVORDER_SORT, &selected, - PICK_NONE, allow_all); - } else { - invdisp_nothing(qbuf, "(empty)"); - n = 0; - } - if (n > 0) { - ret = selected[0].item.a_obj; - free((genericptr_t)selected); - } else - ret = (struct obj *) 0; - obj->cknown = 1; - return ret; + if (obj->cobj) { + n = query_objlist(qbuf, obj->cobj, INVORDER_SORT, &selected, + PICK_NONE, allow_all); + } else { + invdisp_nothing(qbuf, "(empty)"); + n = 0; + } + if (n > 0) { + ret = selected[0].item.a_obj; + free((genericptr_t)selected); + } else + ret = (struct obj *) 0; + obj->cknown = 1; + return ret; } /* query objlist callback: return TRUE if obj is at given location */ @@ -3204,27 +3212,27 @@ display_binventory(x, y, as_if_seen) int x, y; boolean as_if_seen; { - struct obj *obj; - menu_item *selected = 0; - int n; + struct obj *obj; + menu_item *selected = 0; + int n; - /* count # of objects here */ - for (n = 0, obj = level.buriedobjlist; obj; obj = obj->nobj) - if (obj->ox == x && obj->oy == y) { - if (as_if_seen) obj->dknown = 1; - n++; - } + /* count # of objects here */ + for (n = 0, obj = level.buriedobjlist; obj; obj = obj->nobj) + if (obj->ox == x && obj->oy == y) { + if (as_if_seen) obj->dknown = 1; + n++; + } - if (n) { - only.x = x; - only.y = y; - if (query_objlist("Things that are buried here:", - level.buriedobjlist, INVORDER_SORT, - &selected, PICK_NONE, only_here) > 0) - free((genericptr_t)selected); - only.x = only.y = 0; - } - return n; + if (n) { + only.x = x; + only.y = y; + if (query_objlist("Things that are buried here:", + level.buriedobjlist, INVORDER_SORT, + &selected, PICK_NONE, only_here) > 0) + free((genericptr_t)selected); + only.x = only.y = 0; + } + return n; } /*invent.c*/ diff --git a/src/mcastu.c b/src/mcastu.c index 03c06f2ed..f3179f16d 100644 --- a/src/mcastu.c +++ b/src/mcastu.c @@ -519,7 +519,7 @@ int spellnum; destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); - (void) burn_floor_paper(u.ux, u.uy, TRUE, FALSE); + (void) burn_floor_objects(u.ux, u.uy, TRUE, FALSE); break; case CLC_LIGHTNING: { diff --git a/src/mkmaze.c b/src/mkmaze.c index 3d2cc9933..42851c0df 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -879,7 +879,6 @@ fumaroles() for (n = rn2(3)+2; n; n--) { xchar x = rn1(COLNO-4,3); xchar y = rn1(ROWNO-4,3); - struct trap *ttmp = t_at(x,y); if (levl[x][y].typ == LAVAPOOL) { NhRegion *r = create_gas_cloud(x,y, 4+rn2(5), rn1(10,5)); clear_heros_fault(r); diff --git a/src/mkobj.c b/src/mkobj.c index 0f67aed13..a9d0ebfe8 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 mkobj.c $NHDT-Date: 1426465437 2015/03/16 00:23:57 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.77 $ */ +/* NetHack 3.5 mkobj.c $NHDT-Date: 1428715841 2015/04/11 01:30:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.91 $ */ /* NetHack 3.5 mkobj.c $Date: 2012/03/10 02:49:08 $ $Revision: 1.70 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -14,7 +14,7 @@ STATIC_DCL void FDECL(objlist_sanity, (struct obj *,int,const char *)); STATIC_DCL void FDECL(mon_obj_sanity, (struct monst *,const char *)); STATIC_DCL const char *FDECL(where_name, (struct obj *)); STATIC_DCL void FDECL(insane_object, - (struct obj *,const char *,const char *,struct monst *)); + (struct obj *,const char *,const char *,struct monst *)); STATIC_DCL void FDECL(check_contained, (struct obj *,const char *)); struct icp { @@ -74,92 +74,92 @@ const struct icp hellprobs[] = { struct oextra * newoextra() { - struct oextra *oextra; + struct oextra *oextra; - oextra = (struct oextra *)alloc(sizeof(struct oextra)); - oextra->oname = 0; - oextra->omonst = 0; - oextra->omid = 0; - oextra->olong = 0; - oextra->omailcmd = 0; - return oextra; + oextra = (struct oextra *)alloc(sizeof(struct oextra)); + oextra->oname = 0; + oextra->omonst = 0; + oextra->omid = 0; + oextra->olong = 0; + oextra->omailcmd = 0; + return oextra; } void dealloc_oextra(x) struct oextra *x; { - if (x) { - if (x->oname) free((genericptr_t)x->oname); - if (x->omonst) free((genericptr_t)x->omonst); - if (x->omid) free((genericptr_t)x->omid); - if (x->olong) free((genericptr_t)x->olong); - if (x->omailcmd) free((genericptr_t)x->omailcmd); - free((genericptr_t)x); - } + if (x) { + if (x->oname) free((genericptr_t)x->oname); + if (x->omonst) free((genericptr_t)x->omonst); + if (x->omid) free((genericptr_t)x->omid); + if (x->olong) free((genericptr_t)x->olong); + if (x->omailcmd) free((genericptr_t)x->omailcmd); + free((genericptr_t)x); + } } void newomonst(otmp) struct obj *otmp; { - if (!otmp->oextra) otmp->oextra = newoextra(); - if (!OMONST(otmp)) { - OMONST(otmp) = (struct monst *)alloc(sizeof(struct monst)); - (void) memset((genericptr_t) OMONST(otmp), 0, sizeof(struct monst)); - } + if (!otmp->oextra) otmp->oextra = newoextra(); + if (!OMONST(otmp)) { + OMONST(otmp) = (struct monst *)alloc(sizeof(struct monst)); + (void) memset((genericptr_t) OMONST(otmp), 0, sizeof(struct monst)); + } } void free_omonst(otmp) struct obj *otmp; { - if (otmp->oextra && OMONST(otmp)) { - free((genericptr_t) OMONST(otmp)); - OMONST(otmp) = (struct monst *)0; - } + if (otmp->oextra && OMONST(otmp)) { + free((genericptr_t) OMONST(otmp)); + OMONST(otmp) = (struct monst *)0; + } } void newomid(otmp) struct obj *otmp; { - if (!otmp->oextra) otmp->oextra = newoextra(); - if (!OMID(otmp)) { - OMID(otmp) = (unsigned *)alloc(sizeof(unsigned)); - (void) memset((genericptr_t) OMID(otmp), 0, sizeof(unsigned)); - } + if (!otmp->oextra) otmp->oextra = newoextra(); + if (!OMID(otmp)) { + OMID(otmp) = (unsigned *)alloc(sizeof(unsigned)); + (void) memset((genericptr_t) OMID(otmp), 0, sizeof(unsigned)); + } } void free_omid(otmp) struct obj *otmp; { - if (otmp->oextra && OMID(otmp)) { - free((genericptr_t) OMID(otmp)); - OMID(otmp) = (unsigned *)0; - } + if (otmp->oextra && OMID(otmp)) { + free((genericptr_t) OMID(otmp)); + OMID(otmp) = (unsigned *)0; + } } void newolong(otmp) struct obj *otmp; { - if (!otmp->oextra) otmp->oextra = newoextra(); - if (!OLONG(otmp)) { - OLONG(otmp) = (long *)alloc(sizeof(long)); - (void) memset((genericptr_t) OLONG(otmp), 0, sizeof(long)); - } + if (!otmp->oextra) otmp->oextra = newoextra(); + if (!OLONG(otmp)) { + OLONG(otmp) = (long *)alloc(sizeof(long)); + (void) memset((genericptr_t) OLONG(otmp), 0, sizeof(long)); + } } void free_olong(otmp) struct obj *otmp; { - if (otmp->oextra && OLONG(otmp)) { - free((genericptr_t) OLONG(otmp)); - OLONG(otmp) = (long *)0; - } + if (otmp->oextra && OLONG(otmp)) { + free((genericptr_t) OLONG(otmp)); + OLONG(otmp) = (long *)0; + } } void @@ -167,19 +167,19 @@ new_omailcmd(otmp, response_cmd) struct obj *otmp; const char *response_cmd; { - if (!otmp->oextra) otmp->oextra = newoextra(); - if (OMAILCMD(otmp)) free_omailcmd(otmp); - OMAILCMD(otmp) = dupstr(response_cmd); + if (!otmp->oextra) otmp->oextra = newoextra(); + if (OMAILCMD(otmp)) free_omailcmd(otmp); + OMAILCMD(otmp) = dupstr(response_cmd); } void free_omailcmd(otmp) struct obj *otmp; { - if (otmp->oextra && OMAILCMD(otmp)) { - free((genericptr_t) OMAILCMD(otmp)); - OMAILCMD(otmp) = (char *)0; - } + if (otmp->oextra && OMAILCMD(otmp)) { + free((genericptr_t) OMAILCMD(otmp)); + OMAILCMD(otmp) = (char *)0; + } } struct obj * @@ -188,11 +188,11 @@ char let; int x, y; boolean artif; { - struct obj *otmp; + struct obj *otmp; - otmp = mkobj(let, artif); - place_object(otmp, x, y); - return(otmp); + otmp = mkobj(let, artif); + place_object(otmp, x, y); + return(otmp); } struct obj * @@ -200,11 +200,11 @@ mksobj_at(otyp, x, y, init, artif) int otyp, x, y; boolean init, artif; { - struct obj *otmp; + struct obj *otmp; - otmp = mksobj(otyp, init, artif); - place_object(otmp, x, y); - return(otmp); + otmp = mksobj(otyp, init, artif); + place_object(otmp, x, y); + return(otmp); } struct obj * @@ -212,153 +212,153 @@ mkobj(oclass, artif) char oclass; boolean artif; { - int tprob, i, prob = rnd(1000); + int tprob, i, prob = rnd(1000); - if(oclass == RANDOM_CLASS) { - const struct icp *iprobs = - (Is_rogue_level(&u.uz)) ? - (const struct icp *)rogueprobs : - Inhell ? (const struct icp *)hellprobs : - (const struct icp *)mkobjprobs; + if(oclass == RANDOM_CLASS) { + const struct icp *iprobs = + (Is_rogue_level(&u.uz)) ? + (const struct icp *)rogueprobs : + Inhell ? (const struct icp *)hellprobs : + (const struct icp *)mkobjprobs; - for(tprob = rnd(100); - (tprob -= iprobs->iprob) > 0; - iprobs++); - oclass = iprobs->iclass; - } + for(tprob = rnd(100); + (tprob -= iprobs->iprob) > 0; + iprobs++); + oclass = iprobs->iclass; + } - i = bases[(int)oclass]; - while((prob -= objects[i].oc_prob) > 0) i++; + i = bases[(int)oclass]; + while((prob -= objects[i].oc_prob) > 0) i++; - if(objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) - panic("probtype error, oclass=%d i=%d", (int) oclass, i); + if(objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) + panic("probtype error, oclass=%d i=%d", (int) oclass, i); - return(mksobj(i, TRUE, artif)); + return(mksobj(i, TRUE, artif)); } STATIC_OVL void mkbox_cnts(box) struct obj *box; { - register int n; - register struct obj *otmp; + register int n; + register struct obj *otmp; - box->cobj = (struct obj *) 0; + box->cobj = (struct obj *) 0; - switch (box->otyp) { - case ICE_BOX: n = 20; break; - case CHEST: n = 5; break; - case LARGE_BOX: n = 3; break; - case SACK: - case OILSKIN_SACK: - /* initial inventory: sack starts out empty */ - if (moves <= 1 && !in_mklev) { n = 0; break; } - /*else FALLTHRU*/ - case BAG_OF_HOLDING: n = 1; break; - default: n = 0; break; - } + switch (box->otyp) { + case ICE_BOX: n = 20; break; + case CHEST: n = 5; break; + case LARGE_BOX: n = 3; break; + case SACK: + case OILSKIN_SACK: + /* initial inventory: sack starts out empty */ + if (moves <= 1 && !in_mklev) { n = 0; break; } + /*else FALLTHRU*/ + case BAG_OF_HOLDING: n = 1; break; + default: n = 0; break; + } - for (n = rn2(n+1); n > 0; n--) { - if (box->otyp == ICE_BOX) { - if (!(otmp = mksobj(CORPSE, TRUE, TRUE))) continue; - /* Note: setting age to 0 is correct. Age has a different - * from usual meaning for objects stored in ice boxes. -KAA - */ - otmp->age = 0L; - if (otmp->timed) { - (void) stop_timer(ROT_CORPSE, obj_to_any(otmp)); - (void) stop_timer(REVIVE_MON, obj_to_any(otmp)); - } - } else { - register int tprob; - const struct icp *iprobs = boxiprobs; + for (n = rn2(n+1); n > 0; n--) { + if (box->otyp == ICE_BOX) { + if (!(otmp = mksobj(CORPSE, TRUE, TRUE))) continue; + /* Note: setting age to 0 is correct. Age has a different + * from usual meaning for objects stored in ice boxes. -KAA + */ + otmp->age = 0L; + if (otmp->timed) { + (void) stop_timer(ROT_CORPSE, obj_to_any(otmp)); + (void) stop_timer(REVIVE_MON, obj_to_any(otmp)); + } + } else { + register int tprob; + const struct icp *iprobs = boxiprobs; - for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++) - ; - if (!(otmp = mkobj(iprobs->iclass, TRUE))) continue; + for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++) + ; + if (!(otmp = mkobj(iprobs->iclass, TRUE))) continue; - /* handle a couple of special cases */ - if (otmp->oclass == COIN_CLASS) { - /* 2.5 x level's usual amount; weight adjusted below */ - otmp->quan = (long)(rnd(level_difficulty()+2) * rnd(75)); - otmp->owt = weight(otmp); - } else while (otmp->otyp == ROCK) { - otmp->otyp = rnd_class(DILITHIUM_CRYSTAL, LOADSTONE); - if (otmp->quan > 2L) otmp->quan = 1L; - otmp->owt = weight(otmp); - } - if (box->otyp == BAG_OF_HOLDING) { - if (Is_mbag(otmp)) { - otmp->otyp = SACK; - otmp->spe = 0; - otmp->owt = weight(otmp); - } else while (otmp->otyp == WAN_CANCELLATION) - otmp->otyp = rnd_class(WAN_LIGHT, WAN_LIGHTNING); - } - } - (void) add_to_container(box, otmp); - } + /* handle a couple of special cases */ + if (otmp->oclass == COIN_CLASS) { + /* 2.5 x level's usual amount; weight adjusted below */ + otmp->quan = (long)(rnd(level_difficulty()+2) * rnd(75)); + otmp->owt = weight(otmp); + } else while (otmp->otyp == ROCK) { + otmp->otyp = rnd_class(DILITHIUM_CRYSTAL, LOADSTONE); + if (otmp->quan > 2L) otmp->quan = 1L; + otmp->owt = weight(otmp); + } + if (box->otyp == BAG_OF_HOLDING) { + if (Is_mbag(otmp)) { + otmp->otyp = SACK; + otmp->spe = 0; + otmp->owt = weight(otmp); + } else while (otmp->otyp == WAN_CANCELLATION) + otmp->otyp = rnd_class(WAN_LIGHT, WAN_LIGHTNING); + } + } + (void) add_to_container(box, otmp); + } } int rndmonnum() /* select a random, common monster type */ { - register struct permonst *ptr; - register int i; - unsigned short excludeflags; + register struct permonst *ptr; + register int i; + unsigned short excludeflags; - /* Plan A: get a level-appropriate common monster */ - ptr = rndmonst(); - if (ptr) return(monsndx(ptr)); + /* Plan A: get a level-appropriate common monster */ + ptr = rndmonst(); + if (ptr) return(monsndx(ptr)); - /* Plan B: get any common monster */ - excludeflags = G_UNIQ | G_NOGEN | (Inhell ? G_NOHELL : G_HELL); - do { - i = rn1(SPECIAL_PM - LOW_PM, LOW_PM); - ptr = &mons[i]; - } while ((ptr->geno & excludeflags) != 0); + /* Plan B: get any common monster */ + excludeflags = G_UNIQ | G_NOGEN | (Inhell ? G_NOHELL : G_HELL); + do { + i = rn1(SPECIAL_PM - LOW_PM, LOW_PM); + ptr = &mons[i]; + } while ((ptr->geno & excludeflags) != 0); - return(i); + return(i); } void copy_oextra(obj2, obj1) struct obj *obj2, *obj1; { - if(!obj2 || !obj1 || !obj1->oextra) return; + if(!obj2 || !obj1 || !obj1->oextra) return; - if (!obj2->oextra) obj2->oextra = newoextra(); - if (has_oname(obj1)) oname(obj2, ONAME(obj1)); - if (has_omonst(obj1)) { - if (!OMONST(obj2)) newomonst(obj2); - (void)memcpy((genericptr_t)OMONST(obj2), - (genericptr_t)OMONST(obj1), - sizeof(struct monst)); - OMONST(obj2)->mextra = (struct mextra *)0; - OMONST(obj2)->nmon = (struct monst *)0; + if (!obj2->oextra) obj2->oextra = newoextra(); + if (has_oname(obj1)) oname(obj2, ONAME(obj1)); + if (has_omonst(obj1)) { + if (!OMONST(obj2)) newomonst(obj2); + (void)memcpy((genericptr_t)OMONST(obj2), + (genericptr_t)OMONST(obj1), + sizeof(struct monst)); + OMONST(obj2)->mextra = (struct mextra *)0; + OMONST(obj2)->nmon = (struct monst *)0; #if 0 - OMONST(obj2)->m_id = context.ident++; - if (OMONST(obj2)->m_id) /* ident overflowed */ - OMONST(obj2)->m_id = context.ident++; + OMONST(obj2)->m_id = context.ident++; + if (OMONST(obj2)->m_id) /* ident overflowed */ + OMONST(obj2)->m_id = context.ident++; #endif - if (OMONST(obj1)->mextra) - copy_mextra(OMONST(obj2),OMONST(obj1)); - } - if (has_omid(obj1)) { - if (!OMID(obj2)) newomid(obj2); - (void)memcpy((genericptr_t)OMID(obj2), - (genericptr_t)OMID(obj1), - sizeof(unsigned)); - } - if (has_olong(obj1)) { - if (!OLONG(obj2)) newolong(obj2); - (void)memcpy((genericptr_t)OLONG(obj2), - (genericptr_t)OLONG(obj1), - sizeof(long)); - } - if (has_omailcmd(obj1)) { - new_omailcmd(obj2, OMAILCMD(obj1)); - } + if (OMONST(obj1)->mextra) + copy_mextra(OMONST(obj2),OMONST(obj1)); + } + if (has_omid(obj1)) { + if (!OMID(obj2)) newomid(obj2); + (void)memcpy((genericptr_t)OMID(obj2), + (genericptr_t)OMID(obj1), + sizeof(unsigned)); + } + if (has_olong(obj1)) { + if (!OLONG(obj2)) newolong(obj2); + (void)memcpy((genericptr_t)OLONG(obj2), + (genericptr_t)OLONG(obj1), + sizeof(long)); + } + if (has_omailcmd(obj1)) { + new_omailcmd(obj2, OMAILCMD(obj1)); + } } /* @@ -372,33 +372,33 @@ splitobj(obj, num) struct obj *obj; long num; { - struct obj *otmp; + struct obj *otmp; - if (obj->cobj || num <= 0L || obj->quan <= num) - panic("splitobj"); /* can't split containers */ - otmp = newobj(); - *otmp = *obj; /* copies whole structure */ - otmp->oextra = (struct oextra *)0; - otmp->o_id = context.ident++; - if (!otmp->o_id) otmp->o_id = context.ident++; /* ident overflowed */ - otmp->timed = 0; /* not timed, yet */ - otmp->lamplit = 0; /* ditto */ - otmp->owornmask = 0L; /* new object isn't worn */ - obj->quan -= num; - obj->owt = weight(obj); - otmp->quan = num; - otmp->owt = weight(otmp); /* -= obj->owt ? */ - obj->nobj = otmp; - /* Only set nexthere when on the floor, nexthere is also used */ - /* as a back pointer to the container object when contained. */ - if (obj->where == OBJ_FLOOR) - obj->nexthere = otmp; - copy_oextra(otmp, obj); - if (has_omid(otmp)) free_omid(otmp); /* only one association with m_id*/ - if (obj->unpaid) splitbill(obj,otmp); - if (obj->timed) obj_split_timers(obj, otmp); - if (obj_sheds_light(obj)) obj_split_light_source(obj, otmp); - return otmp; + if (obj->cobj || num <= 0L || obj->quan <= num) + panic("splitobj"); /* can't split containers */ + otmp = newobj(); + *otmp = *obj; /* copies whole structure */ + otmp->oextra = (struct oextra *)0; + otmp->o_id = context.ident++; + if (!otmp->o_id) otmp->o_id = context.ident++; /* ident overflowed */ + otmp->timed = 0; /* not timed, yet */ + otmp->lamplit = 0; /* ditto */ + otmp->owornmask = 0L; /* new object isn't worn */ + obj->quan -= num; + obj->owt = weight(obj); + otmp->quan = num; + otmp->owt = weight(otmp); /* -= obj->owt ? */ + obj->nobj = otmp; + /* Only set nexthere when on the floor, nexthere is also used */ + /* as a back pointer to the container object when contained. */ + if (obj->where == OBJ_FLOOR) + obj->nexthere = otmp; + copy_oextra(otmp, obj); + if (has_omid(otmp)) free_omid(otmp); /* only one association with m_id*/ + if (obj->unpaid) splitbill(obj,otmp); + if (obj->timed) obj_split_timers(obj, otmp); + if (obj_sheds_light(obj)) obj_split_light_source(obj, otmp); + return otmp; } /* @@ -418,38 +418,38 @@ struct obj *otmp; otmp->where = obj->where; switch (obj->where) { case OBJ_FREE: - /* do nothing */ - break; + /* do nothing */ + break; case OBJ_INVENT: - otmp->nobj = obj->nobj; - obj->nobj = otmp; - extract_nobj(obj, &invent); - break; + otmp->nobj = obj->nobj; + obj->nobj = otmp; + extract_nobj(obj, &invent); + break; case OBJ_CONTAINED: - otmp->nobj = obj->nobj; - otmp->ocontainer = obj->ocontainer; - obj->nobj = otmp; - extract_nobj(obj, &obj->ocontainer->cobj); - break; + otmp->nobj = obj->nobj; + otmp->ocontainer = obj->ocontainer; + obj->nobj = otmp; + extract_nobj(obj, &obj->ocontainer->cobj); + break; case OBJ_MINVENT: - otmp->nobj = obj->nobj; - otmp->ocarry = obj->ocarry; - obj->nobj = otmp; - extract_nobj(obj, &obj->ocarry->minvent); - break; + otmp->nobj = obj->nobj; + otmp->ocarry = obj->ocarry; + obj->nobj = otmp; + extract_nobj(obj, &obj->ocarry->minvent); + break; case OBJ_FLOOR: - otmp->nobj = obj->nobj; - otmp->nexthere = obj->nexthere; - otmp->ox = obj->ox; - otmp->oy = obj->oy; - obj->nobj = otmp; - obj->nexthere = otmp; - extract_nobj(obj, &fobj); - extract_nexthere(obj, &level.objects[obj->ox][obj->oy]); - break; + otmp->nobj = obj->nobj; + otmp->nexthere = obj->nexthere; + otmp->ox = obj->ox; + otmp->oy = obj->oy; + obj->nobj = otmp; + obj->nexthere = otmp; + extract_nobj(obj, &fobj); + extract_nexthere(obj, &level.objects[obj->ox][obj->oy]); + break; default: - panic("replace_object: obj position"); - break; + panic("replace_object: obj position"); + break; } } @@ -471,38 +471,38 @@ void bill_dummy_object(otmp) register struct obj *otmp; { - register struct obj *dummy; - long cost = 0L; + register struct obj *dummy; + long cost = 0L; - if (otmp->unpaid) { - cost = unpaid_cost(otmp, FALSE); - subfrombill(otmp, shop_keeper(*u.ushops)); - } - dummy = newobj(); - *dummy = *otmp; - dummy->oextra = (struct oextra *)0; - dummy->where = OBJ_FREE; - dummy->o_id = context.ident++; - if (!dummy->o_id) dummy->o_id = context.ident++; /* ident overflowed */ - dummy->timed = 0; - copy_oextra(dummy, otmp); - if (has_omid(dummy)) free_omid(dummy); /* only one association with m_id*/ - if (Is_candle(dummy)) dummy->lamplit = 0; - addtobill(dummy, FALSE, TRUE, TRUE); - if (cost) alter_cost(dummy, -cost); - /* no_charge is only valid for some locations */ - otmp->no_charge = (otmp->where == OBJ_FLOOR || - otmp->where == OBJ_CONTAINED) ? 1 : 0; - otmp->unpaid = 0; - return; + if (otmp->unpaid) { + cost = unpaid_cost(otmp, FALSE); + subfrombill(otmp, shop_keeper(*u.ushops)); + } + dummy = newobj(); + *dummy = *otmp; + dummy->oextra = (struct oextra *)0; + dummy->where = OBJ_FREE; + dummy->o_id = context.ident++; + if (!dummy->o_id) dummy->o_id = context.ident++; /* ident overflowed */ + dummy->timed = 0; + copy_oextra(dummy, otmp); + if (has_omid(dummy)) free_omid(dummy); /* only one association with m_id*/ + if (Is_candle(dummy)) dummy->lamplit = 0; + addtobill(dummy, FALSE, TRUE, TRUE); + if (cost) alter_cost(dummy, -cost); + /* no_charge is only valid for some locations */ + otmp->no_charge = (otmp->where == OBJ_FLOOR || + otmp->where == OBJ_CONTAINED) ? 1 : 0; + otmp->unpaid = 0; + return; } /* alteration types; must match COST_xxx macros in hack.h */ static const char * const alteration_verbs[] = { - "cancel", "drain", "uncharge", "unbless", "uncurse", - "disenchant", "degrade", "dilute", "erase", "burn", - "neutralize", "destroy", "splatter", "bite", "open", - "break the lock on", "rust", "rot", "tarnish" + "cancel", "drain", "uncharge", "unbless", "uncurse", + "disenchant", "degrade", "dilute", "erase", "burn", + "neutralize", "destroy", "splatter", "bite", "open", + "break the lock on", "rust", "rot", "tarnish" }; /* possibly bill for an object which the player has just modified */ @@ -518,34 +518,34 @@ int alter_type; struct monst *shkp = 0; if (alter_type < 0 || alter_type >= SIZE(alteration_verbs)) { - impossible("invalid alteration type (%d)", alter_type); - alter_type = 0; + impossible("invalid alteration type (%d)", alter_type); + alter_type = 0; } ox = oy = 0; /* lint suppression */ objroom = '\0'; /* ditto */ if (carried(obj) || obj->where == OBJ_FREE) { - /* OBJ_FREE catches obj_no_longer_held()'s transformation - of crysknife back into worm tooth; the object has been - removed from inventory but not necessarily placed at - its new location yet--the unpaid flag will still be set - if this item is owned by a shop */ - if (!obj->unpaid) return; + /* OBJ_FREE catches obj_no_longer_held()'s transformation + of crysknife back into worm tooth; the object has been + removed from inventory but not necessarily placed at + its new location yet--the unpaid flag will still be set + if this item is owned by a shop */ + if (!obj->unpaid) return; } else { - /* this get_obj_location shouldn't fail, but if it does, - use hero's location */ - if (!get_obj_location(obj, &ox, &oy, CONTAINED_TOO)) - ox = u.ux, oy = u.uy; - if (!costly_spot(ox, oy)) return; - objroom = *in_rooms(ox, oy, SHOPBASE); - /* if no shop cares about it, we're done */ - if (!billable(&shkp, obj, objroom, FALSE)) return; + /* this get_obj_location shouldn't fail, but if it does, + use hero's location */ + if (!get_obj_location(obj, &ox, &oy, CONTAINED_TOO)) + ox = u.ux, oy = u.uy; + if (!costly_spot(ox, oy)) return; + objroom = *in_rooms(ox, oy, SHOPBASE); + /* if no shop cares about it, we're done */ + if (!billable(&shkp, obj, objroom, FALSE)) return; } if (obj->quan == 1L) - those = "that", them = "it"; + those = "that", them = "it"; else - those = "those", them = "them"; + those = "those", them = "them"; /* when shopkeeper describes the object as being uncursed or unblessed hero will know that it is now uncursed; will also make the feedback @@ -555,28 +555,28 @@ int alter_type; switch (obj->where) { case OBJ_FREE: /* obj_no_longer_held() */ case OBJ_INVENT: - if (set_bknown) obj->bknown = 1; - verbalize("You %s %s %s, you pay for %s!", - alteration_verbs[alter_type], those, - simpleonames(obj), them); - bill_dummy_object(obj); - break; + if (set_bknown) obj->bknown = 1; + verbalize("You %s %s %s, you pay for %s!", + alteration_verbs[alter_type], those, + simpleonames(obj), them); + bill_dummy_object(obj); + break; case OBJ_FLOOR: - if (set_bknown) obj->bknown = 1; - if (costly_spot(u.ux, u.uy) && objroom == *u.ushops) { - verbalize("You %s %s, you pay for %s!", - alteration_verbs[alter_type], those, them); - bill_dummy_object(obj); - } else { - (void) stolen_value(obj, ox, oy, FALSE, FALSE); - } - break; + if (set_bknown) obj->bknown = 1; + if (costly_spot(u.ux, u.uy) && objroom == *u.ushops) { + verbalize("You %s %s, you pay for %s!", + alteration_verbs[alter_type], those, them); + bill_dummy_object(obj); + } else { + (void) stolen_value(obj, ox, oy, FALSE, FALSE); + } + break; } } static const char dknowns[] = { - WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, - GEM_CLASS, SPBOOK_CLASS, WEAPON_CLASS, TOOL_CLASS, 0 + WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, + GEM_CLASS, SPBOOK_CLASS, WEAPON_CLASS, TOOL_CLASS, 0 }; struct obj * @@ -585,282 +585,291 @@ int otyp; boolean init; boolean artif; { - int mndx, tryct; - struct obj *otmp; - char let = objects[otyp].oc_class; + int mndx, tryct; + struct obj *otmp; + char let = objects[otyp].oc_class; - otmp = newobj(); - *otmp = zeroobj; - otmp->age = monstermoves; - otmp->o_id = context.ident++; - if (!otmp->o_id) otmp->o_id = context.ident++; /* ident overflowed */ - otmp->quan = 1L; - otmp->oclass = let; - otmp->otyp = otyp; - otmp->where = OBJ_FREE; - otmp->dknown = index(dknowns, let) ? 0 : 1; - if ((otmp->otyp >= ELVEN_SHIELD && otmp->otyp <= ORCISH_SHIELD) || - otmp->otyp == SHIELD_OF_REFLECTION) - otmp->dknown = 0; - if (!objects[otmp->otyp].oc_uses_known) - otmp->known = 1; - otmp->lknown = 0; - otmp->cknown = 0; - otmp->corpsenm = NON_PM; + otmp = newobj(); + *otmp = zeroobj; + otmp->age = monstermoves; + otmp->o_id = context.ident++; + if (!otmp->o_id) otmp->o_id = context.ident++; /* ident overflowed */ + otmp->quan = 1L; + otmp->oclass = let; + otmp->otyp = otyp; + otmp->where = OBJ_FREE; + otmp->dknown = index(dknowns, let) ? 0 : 1; + if ((otmp->otyp >= ELVEN_SHIELD && otmp->otyp <= ORCISH_SHIELD) || + otmp->otyp == SHIELD_OF_REFLECTION) + otmp->dknown = 0; + if (!objects[otmp->otyp].oc_uses_known) + otmp->known = 1; + otmp->lknown = 0; + otmp->cknown = 0; + otmp->corpsenm = NON_PM; - if (init) switch (let) { - case WEAPON_CLASS: - otmp->quan = is_multigen(otmp) ? (long) rn1(6,6) : 1L; - if(!rn2(11)) { - otmp->spe = rne(3); - otmp->blessed = rn2(2); - } else if(!rn2(10)) { - curse(otmp); - otmp->spe = -rne(3); - } else blessorcurse(otmp, 10); - if (is_poisonable(otmp) && !rn2(100)) - otmp->opoisoned = 1; + if (init) switch (let) { + case WEAPON_CLASS: + otmp->quan = is_multigen(otmp) ? (long) rn1(6,6) : 1L; + if(!rn2(11)) { + otmp->spe = rne(3); + otmp->blessed = rn2(2); + } else if(!rn2(10)) { + curse(otmp); + otmp->spe = -rne(3); + } else blessorcurse(otmp, 10); + if (is_poisonable(otmp) && !rn2(100)) + otmp->opoisoned = 1; - if (artif && !rn2(20)) - otmp = mk_artifact(otmp, (aligntyp)A_NONE); - break; - case FOOD_CLASS: - otmp->oeaten = 0; - switch(otmp->otyp) { - case CORPSE: - /* possibly overridden by mkcorpstat() */ - tryct = 50; - do otmp->corpsenm = undead_to_corpse(rndmonnum()); - while ((mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) && (--tryct > 0)); - if (tryct == 0) { - /* perhaps rndmonnum() only wants to make G_NOCORPSE monsters on - this level; let's create an adventurer's corpse instead, then */ - otmp->corpsenm = PM_HUMAN; - } - /* timer set below */ - break; - case EGG: - otmp->corpsenm = NON_PM; /* generic egg */ - if (!rn2(3)) for (tryct = 200; tryct > 0; --tryct) { - mndx = can_be_hatched(rndmonnum()); - if (mndx != NON_PM && !dead_species(mndx, TRUE)) { - otmp->corpsenm = mndx; /* typed egg */ - break; - } - } - /* timer set below */ - break; - case TIN: - otmp->corpsenm = NON_PM; /* empty (so far) */ - if (!rn2(6)) - set_tin_variety(otmp, SPINACH_TIN); - else for (tryct = 200; tryct > 0; --tryct) { - mndx = undead_to_corpse(rndmonnum()); - if (mons[mndx].cnutrit && - !(mvitals[mndx].mvflags & G_NOCORPSE)) { - otmp->corpsenm = mndx; - set_tin_variety(otmp, RANDOM_TIN); - break; - } - } - blessorcurse(otmp, 10); - break; - case SLIME_MOLD: - otmp->spe = context.current_fruit; - flags.made_fruit = TRUE; - break; - case KELP_FROND: - otmp->quan = (long) rnd(2); - break; - } - if (otmp->otyp != CORPSE && otmp->otyp != MEAT_RING && - otmp->otyp != KELP_FROND && !rn2(6)) - otmp->quan = 2L; - break; - case GEM_CLASS: - otmp->corpsenm = 0; /* LOADSTONE hack */ - if (otmp->otyp == LOADSTONE) curse(otmp); - else if (otmp->otyp == ROCK) otmp->quan = (long) rn1(6,6); - else if (otmp->otyp != LUCKSTONE && !rn2(6)) otmp->quan = 2L; - else otmp->quan = 1L; - break; - case TOOL_CLASS: - switch(otmp->otyp) { - case TALLOW_CANDLE: - case WAX_CANDLE: otmp->spe = 1; - otmp->age = 20L * /* 400 or 200 */ - (long)objects[otmp->otyp].oc_cost; - otmp->lamplit = 0; - otmp->quan = 1L + - (long)(rn2(2) ? rn2(7) : 0); - blessorcurse(otmp, 5); - break; - case BRASS_LANTERN: - case OIL_LAMP: otmp->spe = 1; - otmp->age = (long) rn1(500,1000); - otmp->lamplit = 0; - blessorcurse(otmp, 5); - break; - case MAGIC_LAMP: otmp->spe = 1; - otmp->lamplit = 0; - blessorcurse(otmp, 2); - break; - case CHEST: - case LARGE_BOX: otmp->olocked = !!(rn2(5)); - otmp->otrapped = !(rn2(10)); - case ICE_BOX: - case SACK: - case OILSKIN_SACK: - case BAG_OF_HOLDING: mkbox_cnts(otmp); - break; - case LEASH: otmp->leashmon = 0; - break; - case EXPENSIVE_CAMERA: - case TINNING_KIT: - case MAGIC_MARKER: otmp->spe = rn1(70,30); - break; - case CAN_OF_GREASE: otmp->spe = rnd(25); - blessorcurse(otmp, 10); - break; - case CRYSTAL_BALL: otmp->spe = rnd(5); - blessorcurse(otmp, 2); - break; - case HORN_OF_PLENTY: - case BAG_OF_TRICKS: otmp->spe = rnd(20); - break; - case FIGURINE: { int tryct2 = 0; - do - otmp->corpsenm = rndmonnum(); - while(is_human(&mons[otmp->corpsenm]) - && tryct2++ < 30); - blessorcurse(otmp, 4); - break; - } - case BELL_OF_OPENING: otmp->spe = 3; - break; - case MAGIC_FLUTE: - case MAGIC_HARP: - case FROST_HORN: - case FIRE_HORN: - case DRUM_OF_EARTHQUAKE: - otmp->spe = rn1(5,4); - break; - } - break; - case AMULET_CLASS: - if (otmp->otyp == AMULET_OF_YENDOR) context.made_amulet = TRUE; - if(rn2(10) && (otmp->otyp == AMULET_OF_STRANGULATION || - otmp->otyp == AMULET_OF_CHANGE || - otmp->otyp == AMULET_OF_RESTFUL_SLEEP)) { - curse(otmp); - } else blessorcurse(otmp, 10); - case VENOM_CLASS: - case CHAIN_CLASS: - case BALL_CLASS: - break; - case POTION_CLASS: - otmp->fromsink = 0; - if (otmp->otyp == POT_OIL) - otmp->age = MAX_OIL_IN_FLASK; /* amount of oil */ - /* fall through */ - case SCROLL_CLASS: + if (artif && !rn2(20)) + otmp = mk_artifact(otmp, (aligntyp)A_NONE); + break; + case FOOD_CLASS: + otmp->oeaten = 0; + switch(otmp->otyp) { + case CORPSE: + /* possibly overridden by mkcorpstat() */ + tryct = 50; + do otmp->corpsenm = undead_to_corpse(rndmonnum()); + while ((mvitals[otmp->corpsenm].mvflags & G_NOCORPSE) && (--tryct > 0)); + if (tryct == 0) { + /* perhaps rndmonnum() only wants to make G_NOCORPSE monsters on + this level; let's create an adventurer's corpse instead, then */ + otmp->corpsenm = PM_HUMAN; + } + /* timer set below */ + break; + case EGG: + otmp->corpsenm = NON_PM; /* generic egg */ + if (!rn2(3)) for (tryct = 200; tryct > 0; --tryct) { + mndx = can_be_hatched(rndmonnum()); + if (mndx != NON_PM && !dead_species(mndx, TRUE)) { + otmp->corpsenm = mndx; /* typed egg */ + break; + } + } + /* timer set below */ + break; + case TIN: + otmp->corpsenm = NON_PM; /* empty (so far) */ + if (!rn2(6)) + set_tin_variety(otmp, SPINACH_TIN); + else for (tryct = 200; tryct > 0; --tryct) { + mndx = undead_to_corpse(rndmonnum()); + if (mons[mndx].cnutrit && + !(mvitals[mndx].mvflags & G_NOCORPSE)) { + otmp->corpsenm = mndx; + set_tin_variety(otmp, RANDOM_TIN); + break; + } + } + blessorcurse(otmp, 10); + break; + case SLIME_MOLD: + otmp->spe = context.current_fruit; + flags.made_fruit = TRUE; + break; + case KELP_FROND: + otmp->quan = (long) rnd(2); + break; + } + if (Is_pudding(otmp)) { + otmp->globby = 1; + otmp->known = otmp->bknown = otmp->rknown = otmp->dknown = 1; + otmp->corpsenm = PM_GRAY_OOZE + (otmp->otyp - GLOB_OF_GRAY_OOZE); + /* this ensures that they don't fail merging because of + * BUC status or other irrelevancies */ + } else { + if (otmp->otyp != CORPSE && otmp->otyp != MEAT_RING + && otmp->otyp != KELP_FROND && !rn2(6)) { + otmp->quan = 2L; + } + } + break; + case GEM_CLASS: + otmp->corpsenm = 0; /* LOADSTONE hack */ + if (otmp->otyp == LOADSTONE) curse(otmp); + else if (otmp->otyp == ROCK) otmp->quan = (long) rn1(6,6); + else if (otmp->otyp != LUCKSTONE && !rn2(6)) otmp->quan = 2L; + else otmp->quan = 1L; + break; + case TOOL_CLASS: + switch(otmp->otyp) { + case TALLOW_CANDLE: + case WAX_CANDLE: otmp->spe = 1; + otmp->age = 20L * /* 400 or 200 */ + (long)objects[otmp->otyp].oc_cost; + otmp->lamplit = 0; + otmp->quan = 1L + + (long)(rn2(2) ? rn2(7) : 0); + blessorcurse(otmp, 5); + break; + case BRASS_LANTERN: + case OIL_LAMP: otmp->spe = 1; + otmp->age = (long) rn1(500,1000); + otmp->lamplit = 0; + blessorcurse(otmp, 5); + break; + case MAGIC_LAMP: otmp->spe = 1; + otmp->lamplit = 0; + blessorcurse(otmp, 2); + break; + case CHEST: + case LARGE_BOX: otmp->olocked = !!(rn2(5)); + otmp->otrapped = !(rn2(10)); + case ICE_BOX: + case SACK: + case OILSKIN_SACK: + case BAG_OF_HOLDING: mkbox_cnts(otmp); + break; + case LEASH: otmp->leashmon = 0; + break; + case EXPENSIVE_CAMERA: + case TINNING_KIT: + case MAGIC_MARKER: otmp->spe = rn1(70,30); + break; + case CAN_OF_GREASE: otmp->spe = rnd(25); + blessorcurse(otmp, 10); + break; + case CRYSTAL_BALL: otmp->spe = rnd(5); + blessorcurse(otmp, 2); + break; + case HORN_OF_PLENTY: + case BAG_OF_TRICKS: otmp->spe = rnd(20); + break; + case FIGURINE: { int tryct2 = 0; + do + otmp->corpsenm = rndmonnum(); + while(is_human(&mons[otmp->corpsenm]) + && tryct2++ < 30); + blessorcurse(otmp, 4); + break; + } + case BELL_OF_OPENING: otmp->spe = 3; + break; + case MAGIC_FLUTE: + case MAGIC_HARP: + case FROST_HORN: + case FIRE_HORN: + case DRUM_OF_EARTHQUAKE: + otmp->spe = rn1(5,4); + break; + } + break; + case AMULET_CLASS: + if (otmp->otyp == AMULET_OF_YENDOR) context.made_amulet = TRUE; + if(rn2(10) && (otmp->otyp == AMULET_OF_STRANGULATION || + otmp->otyp == AMULET_OF_CHANGE || + otmp->otyp == AMULET_OF_RESTFUL_SLEEP)) { + curse(otmp); + } else blessorcurse(otmp, 10); + case VENOM_CLASS: + case CHAIN_CLASS: + case BALL_CLASS: + break; + case POTION_CLASS: + otmp->fromsink = 0; + if (otmp->otyp == POT_OIL) + otmp->age = MAX_OIL_IN_FLASK; /* amount of oil */ + /* fall through */ + case SCROLL_CLASS: #ifdef MAIL - if (otmp->otyp != SCR_MAIL) + if (otmp->otyp != SCR_MAIL) #endif - blessorcurse(otmp, 4); - break; - case SPBOOK_CLASS: - otmp->spestudied = 0; - blessorcurse(otmp, 17); - break; - case ARMOR_CLASS: - if(rn2(10) && (otmp->otyp == FUMBLE_BOOTS || - otmp->otyp == LEVITATION_BOOTS || - otmp->otyp == HELM_OF_OPPOSITE_ALIGNMENT || - otmp->otyp == GAUNTLETS_OF_FUMBLING || - !rn2(11))) { - curse(otmp); - otmp->spe = -rne(3); - } else if(!rn2(10)) { - otmp->blessed = rn2(2); - otmp->spe = rne(3); - } else blessorcurse(otmp, 10); - if (artif && !rn2(40)) - otmp = mk_artifact(otmp, (aligntyp)A_NONE); - /* simulate lacquered armor for samurai */ - if (Role_if(PM_SAMURAI) && otmp->otyp == SPLINT_MAIL && - (moves <= 1 || In_quest(&u.uz))) { + blessorcurse(otmp, 4); + break; + case SPBOOK_CLASS: + otmp->spestudied = 0; + blessorcurse(otmp, 17); + break; + case ARMOR_CLASS: + if(rn2(10) && (otmp->otyp == FUMBLE_BOOTS || + otmp->otyp == LEVITATION_BOOTS || + otmp->otyp == HELM_OF_OPPOSITE_ALIGNMENT || + otmp->otyp == GAUNTLETS_OF_FUMBLING || + !rn2(11))) { + curse(otmp); + otmp->spe = -rne(3); + } else if(!rn2(10)) { + otmp->blessed = rn2(2); + otmp->spe = rne(3); + } else blessorcurse(otmp, 10); + if (artif && !rn2(40)) + otmp = mk_artifact(otmp, (aligntyp)A_NONE); + /* simulate lacquered armor for samurai */ + if (Role_if(PM_SAMURAI) && otmp->otyp == SPLINT_MAIL && + (moves <= 1 || In_quest(&u.uz))) { #ifdef UNIXPC - /* optimizer bitfield bug */ - otmp->oerodeproof = 1; - otmp->rknown = 1; + /* optimizer bitfield bug */ + otmp->oerodeproof = 1; + otmp->rknown = 1; #else - otmp->oerodeproof = otmp->rknown = 1; + otmp->oerodeproof = otmp->rknown = 1; #endif - } - break; - case WAND_CLASS: - if(otmp->otyp == WAN_WISHING) otmp->spe = rnd(3); else - otmp->spe = rn1(5, - (objects[otmp->otyp].oc_dir == NODIR) ? 11 : 4); - blessorcurse(otmp, 17); - otmp->recharged = 0; /* used to control recharging */ - break; - case RING_CLASS: - if(objects[otmp->otyp].oc_charged) { - blessorcurse(otmp, 3); - if(rn2(10)) { - if(rn2(10) && bcsign(otmp)) - otmp->spe = bcsign(otmp) * rne(3); - else otmp->spe = rn2(2) ? rne(3) : -rne(3); - } - /* make useless +0 rings much less common */ - if (otmp->spe == 0) otmp->spe = rn2(4) - rn2(3); - /* negative rings are usually cursed */ - if (otmp->spe < 0 && rn2(5)) curse(otmp); - } else if(rn2(10) && (otmp->otyp == RIN_TELEPORTATION || - otmp->otyp == RIN_POLYMORPH || - otmp->otyp == RIN_AGGRAVATE_MONSTER || - otmp->otyp == RIN_HUNGER || !rn2(9))) { - curse(otmp); - } - break; - case ROCK_CLASS: - switch (otmp->otyp) { - case STATUE: - /* possibly overridden by mkcorpstat() */ - otmp->corpsenm = rndmonnum(); - if (!verysmall(&mons[otmp->corpsenm]) && - rn2(level_difficulty()/2 + 10) > 10) - (void) add_to_container(otmp, - mkobj(SPBOOK_CLASS,FALSE)); - } - break; - case COIN_CLASS: - break; /* do nothing */ - default: - impossible("impossible mkobj %d, sym '%c'.", otmp->otyp, - objects[otmp->otyp].oc_class); - return (struct obj *)0; - } + } + break; + case WAND_CLASS: + if(otmp->otyp == WAN_WISHING) otmp->spe = rnd(3); else + otmp->spe = rn1(5, + (objects[otmp->otyp].oc_dir == NODIR) ? 11 : 4); + blessorcurse(otmp, 17); + otmp->recharged = 0; /* used to control recharging */ + break; + case RING_CLASS: + if(objects[otmp->otyp].oc_charged) { + blessorcurse(otmp, 3); + if(rn2(10)) { + if(rn2(10) && bcsign(otmp)) + otmp->spe = bcsign(otmp) * rne(3); + else otmp->spe = rn2(2) ? rne(3) : -rne(3); + } + /* make useless +0 rings much less common */ + if (otmp->spe == 0) otmp->spe = rn2(4) - rn2(3); + /* negative rings are usually cursed */ + if (otmp->spe < 0 && rn2(5)) curse(otmp); + } else if(rn2(10) && (otmp->otyp == RIN_TELEPORTATION || + otmp->otyp == RIN_POLYMORPH || + otmp->otyp == RIN_AGGRAVATE_MONSTER || + otmp->otyp == RIN_HUNGER || !rn2(9))) { + curse(otmp); + } + break; + case ROCK_CLASS: + switch (otmp->otyp) { + case STATUE: + /* possibly overridden by mkcorpstat() */ + otmp->corpsenm = rndmonnum(); + if (!verysmall(&mons[otmp->corpsenm]) && + rn2(level_difficulty()/2 + 10) > 10) + (void) add_to_container(otmp, + mkobj(SPBOOK_CLASS,FALSE)); + } + break; + case COIN_CLASS: + break; /* do nothing */ + default: + impossible("impossible mkobj %d, sym '%c'.", otmp->otyp, + objects[otmp->otyp].oc_class); + return (struct obj *)0; + } - /* some things must get done (corpsenm, timers) even if init = 0 */ - switch (otmp->otyp) { - case CORPSE: - if (otmp->corpsenm == NON_PM) { - otmp->corpsenm = undead_to_corpse(rndmonnum()); - if (mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE|G_GONE)) - otmp->corpsenm = urole.malenum; - } - /*FALLTHRU*/ - case STATUE: - case FIGURINE: - if (otmp->corpsenm == NON_PM) otmp->corpsenm = rndmonnum(); - /*FALLTHRU*/ - case EGG: - /* case TIN: */ - set_corpsenm(otmp, otmp->corpsenm); - break; + /* some things must get done (corpsenm, timers) even if init = 0 */ + switch (otmp->otyp) { + case CORPSE: + if (otmp->corpsenm == NON_PM) { + otmp->corpsenm = undead_to_corpse(rndmonnum()); + if (mvitals[otmp->corpsenm].mvflags & (G_NOCORPSE|G_GONE)) + otmp->corpsenm = urole.malenum; + } + /*FALLTHRU*/ + case STATUE: + case FIGURINE: + if (otmp->corpsenm == NON_PM) otmp->corpsenm = rndmonnum(); + /*FALLTHRU*/ + case EGG: + /* case TIN: */ + set_corpsenm(otmp, otmp->corpsenm); + break; case SPE_NOVEL: { int novidx = -1; @@ -868,13 +877,13 @@ boolean artif; otmp->novelidx = novidx; } break; - } + } - /* unique objects may have an associated artifact entry */ - if (objects[otyp].oc_unique && !otmp->oartifact) - otmp = mk_artifact(otmp, (aligntyp)A_NONE); - otmp->owt = weight(otmp); - return(otmp); + /* unique objects may have an associated artifact entry */ + if (objects[otyp].oc_unique && !otmp->oartifact) + otmp = mk_artifact(otmp, (aligntyp)A_NONE); + otmp->owt = weight(otmp); + return(otmp); } /* @@ -902,38 +911,38 @@ set_corpsenm(obj, id) struct obj *obj; int id; { - long when = 0L; + long when = 0L; - if (obj->timed) { - if (obj->otyp == EGG) - when = stop_timer(HATCH_EGG, obj_to_any(obj)); - else { - when = 0L; - obj_stop_timers(obj); /* corpse or figurine */ - } - } - obj->corpsenm = id; - switch(obj->otyp) { - case CORPSE: - start_corpse_timeout(obj); - obj->owt = weight(obj); - break; - case FIGURINE: - if (obj->corpsenm != NON_PM - && !dead_species(obj->corpsenm,TRUE) - && (carried(obj) || mcarried(obj))) - attach_fig_transform_timeout(obj); - obj->owt = weight(obj); - break; - case EGG: - if (obj->corpsenm != NON_PM - && !dead_species(obj->corpsenm,TRUE)) - attach_egg_hatch_timeout(obj, when); - break; - default: /* tin, etc. */ - obj->owt = weight(obj); - break; - } + if (obj->timed) { + if (obj->otyp == EGG) + when = stop_timer(HATCH_EGG, obj_to_any(obj)); + else { + when = 0L; + obj_stop_timers(obj); /* corpse or figurine */ + } + } + obj->corpsenm = id; + switch(obj->otyp) { + case CORPSE: + start_corpse_timeout(obj); + obj->owt = weight(obj); + break; + case FIGURINE: + if (obj->corpsenm != NON_PM + && !dead_species(obj->corpsenm,TRUE) + && (carried(obj) || mcarried(obj))) + attach_fig_transform_timeout(obj); + obj->owt = weight(obj); + break; + case EGG: + if (obj->corpsenm != NON_PM + && !dead_species(obj->corpsenm,TRUE)) + attach_egg_hatch_timeout(obj, when); + break; + default: /* tin, etc. */ + obj->owt = weight(obj); + break; + } } /* @@ -942,50 +951,50 @@ int id; */ void start_corpse_timeout(body) - struct obj *body; + struct obj *body; { - long when; /* rot away when this old */ - long corpse_age; /* age of corpse */ - int rot_adjust; - short action; + long when; /* rot away when this old */ + long corpse_age; /* age of corpse */ + int rot_adjust; + short action; #define TAINT_AGE (50L) /* age when corpses go bad */ #define TROLL_REVIVE_CHANCE 37 /* 1/37 chance for 50 turns ~ 75% chance */ #define ROT_AGE (250L) /* age when corpses rot away */ - /* lizards and lichen don't rot or revive */ - if (body->corpsenm == PM_LIZARD || body->corpsenm == PM_LICHEN) return; + /* lizards and lichen don't rot or revive */ + if (body->corpsenm == PM_LIZARD || body->corpsenm == PM_LICHEN) return; - action = ROT_CORPSE; /* default action: rot away */ - rot_adjust = in_mklev ? 25 : 10; /* give some variation */ - corpse_age = monstermoves - body->age; - if (corpse_age > ROT_AGE) - when = rot_adjust; - else - when = ROT_AGE - corpse_age; - when += (long)(rnz(rot_adjust) - rot_adjust); + action = ROT_CORPSE; /* default action: rot away */ + rot_adjust = in_mklev ? 25 : 10; /* give some variation */ + corpse_age = monstermoves - body->age; + if (corpse_age > ROT_AGE) + when = rot_adjust; + else + when = ROT_AGE - corpse_age; + when += (long)(rnz(rot_adjust) - rot_adjust); - if (is_rider(&mons[body->corpsenm])) { - /* - * Riders always revive. They have a 1/3 chance per turn - * of reviving after 12 turns. Always revive by 500. - */ - action = REVIVE_MON; - for (when = 12L; when < 500L; when++) - if (!rn2(3)) break; + if (is_rider(&mons[body->corpsenm])) { + /* + * Riders always revive. They have a 1/3 chance per turn + * of reviving after 12 turns. Always revive by 500. + */ + action = REVIVE_MON; + for (when = 12L; when < 500L; when++) + if (!rn2(3)) break; - } else if (mons[body->corpsenm].mlet == S_TROLL && !body->norevive) { - long age; - for (age = 2; age <= TAINT_AGE; age++) - if (!rn2(TROLL_REVIVE_CHANCE)) { /* troll revives */ - action = REVIVE_MON; - when = age; - break; - } - } - - if (body->norevive) body->norevive = 0; - (void) start_timer(when, TIMER_OBJECT, action, obj_to_any(body)); + } else if (mons[body->corpsenm].mlet == S_TROLL && !body->norevive) { + long age; + for (age = 2; age <= TAINT_AGE; age++) + if (!rn2(TROLL_REVIVE_CHANCE)) { /* troll revives */ + action = REVIVE_MON; + when = age; + break; + } + } + + if (body->norevive) body->norevive = 0; + (void) start_timer(when, TIMER_OBJECT, action, obj_to_any(body)); } STATIC_OVL void @@ -993,38 +1002,38 @@ maybe_adjust_light(obj, old_range) struct obj *obj; int old_range; { - char buf[BUFSZ]; - xchar ox, oy; - int new_range = arti_light_radius(obj), - delta = new_range - old_range; + char buf[BUFSZ]; + xchar ox, oy; + int new_range = arti_light_radius(obj), + delta = new_range - old_range; - /* radius of light emitting artifact varies by curse/bless state - so will change after blessing or cursing */ - if (delta) { - obj_adjust_light_radius(obj, new_range); - /* simplifying assumptions: hero is wielding this object; - artifacts have to be in use to emit light and monsters' - gear won't change bless or curse state */ - if (!Blind && get_obj_location(obj, &ox, &oy, 0)) { - *buf = '\0'; - if (iflags.last_msg == PLNMSG_OBJ_GLOWS) - /* we just saw "The glows ." from dipping */ - Strcpy(buf, (obj->quan == 1L) ? "It" : "They"); - else if (carried(obj) || cansee(ox, oy)) - Strcpy(buf, Yname2(obj)); - if (*buf) { - /* initial activation says "dimly" if cursed, - "brightly" if uncursed, and "brilliantly" if blessed; - when changing intensity, using "less brightly" is - straightforward for dimming, but we need "brighter" - rather than "more brightly" for brightening; ugh */ - pline("%s %s %s%s.", - buf, otense(obj, "shine"), - (abs(delta) > 1) ? "much " : "", - (delta > 0) ? "brighter" : "less brightly"); - } - } - } + /* radius of light emitting artifact varies by curse/bless state + so will change after blessing or cursing */ + if (delta) { + obj_adjust_light_radius(obj, new_range); + /* simplifying assumptions: hero is wielding this object; + artifacts have to be in use to emit light and monsters' + gear won't change bless or curse state */ + if (!Blind && get_obj_location(obj, &ox, &oy, 0)) { + *buf = '\0'; + if (iflags.last_msg == PLNMSG_OBJ_GLOWS) + /* we just saw "The glows ." from dipping */ + Strcpy(buf, (obj->quan == 1L) ? "It" : "They"); + else if (carried(obj) || cansee(ox, oy)) + Strcpy(buf, Yname2(obj)); + if (*buf) { + /* initial activation says "dimly" if cursed, + "brightly" if uncursed, and "brilliantly" if blessed; + when changing intensity, using "less brightly" is + straightforward for dimming, but we need "brighter" + rather than "more brightly" for brightening; ugh */ + pline("%s %s %s%s.", + buf, otense(obj, "shine"), + (abs(delta) > 1) ? "much " : "", + (delta > 0) ? "brighter" : "less brightly"); + } + } + } } /* @@ -1037,84 +1046,84 @@ void bless(otmp) register struct obj *otmp; { - int old_light = 0; + int old_light = 0; - if (otmp->oclass == COIN_CLASS) return; - if (otmp->lamplit) old_light = arti_light_radius(otmp); - otmp->cursed = 0; - otmp->blessed = 1; - if (carried(otmp) && confers_luck(otmp)) - set_moreluck(); - else if (otmp->otyp == BAG_OF_HOLDING) - otmp->owt = weight(otmp); - else if (otmp->otyp == FIGURINE && otmp->timed) - (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp)); - if (otmp->lamplit) maybe_adjust_light(otmp, old_light); - return; + if (otmp->oclass == COIN_CLASS) return; + if (otmp->lamplit) old_light = arti_light_radius(otmp); + otmp->cursed = 0; + otmp->blessed = 1; + if (carried(otmp) && confers_luck(otmp)) + set_moreluck(); + else if (otmp->otyp == BAG_OF_HOLDING) + otmp->owt = weight(otmp); + else if (otmp->otyp == FIGURINE && otmp->timed) + (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp)); + if (otmp->lamplit) maybe_adjust_light(otmp, old_light); + return; } void unbless(otmp) register struct obj *otmp; { - int old_light = 0; + int old_light = 0; - if (otmp->lamplit) old_light = arti_light_radius(otmp); - otmp->blessed = 0; - if (carried(otmp) && confers_luck(otmp)) - set_moreluck(); - else if (otmp->otyp == BAG_OF_HOLDING) - otmp->owt = weight(otmp); - if (otmp->lamplit) maybe_adjust_light(otmp, old_light); + if (otmp->lamplit) old_light = arti_light_radius(otmp); + otmp->blessed = 0; + if (carried(otmp) && confers_luck(otmp)) + set_moreluck(); + else if (otmp->otyp == BAG_OF_HOLDING) + otmp->owt = weight(otmp); + if (otmp->lamplit) maybe_adjust_light(otmp, old_light); } void curse(otmp) register struct obj *otmp; { - int old_light = 0; + int old_light = 0; - if (otmp->oclass == COIN_CLASS) return; - if (otmp->lamplit) old_light = arti_light_radius(otmp); - otmp->blessed = 0; - otmp->cursed = 1; - /* welded two-handed weapon interferes with some armor removal */ - if (otmp == uwep && bimanual(uwep)) reset_remarm(); - /* rules at top of wield.c state that twoweapon cannot be done - with cursed alternate weapon */ - if (otmp == uswapwep && u.twoweap) - drop_uswapwep(); - /* some cursed items need immediate updating */ - if (carried(otmp) && confers_luck(otmp)) - set_moreluck(); - else if (otmp->otyp == BAG_OF_HOLDING) - otmp->owt = weight(otmp); - else if (otmp->otyp == FIGURINE) { - if (otmp->corpsenm != NON_PM - && !dead_species(otmp->corpsenm,TRUE) - && (carried(otmp) || mcarried(otmp))) - attach_fig_transform_timeout(otmp); - } - if (otmp->lamplit) maybe_adjust_light(otmp, old_light); - return; + if (otmp->oclass == COIN_CLASS) return; + if (otmp->lamplit) old_light = arti_light_radius(otmp); + otmp->blessed = 0; + otmp->cursed = 1; + /* welded two-handed weapon interferes with some armor removal */ + if (otmp == uwep && bimanual(uwep)) reset_remarm(); + /* rules at top of wield.c state that twoweapon cannot be done + with cursed alternate weapon */ + if (otmp == uswapwep && u.twoweap) + drop_uswapwep(); + /* some cursed items need immediate updating */ + if (carried(otmp) && confers_luck(otmp)) + set_moreluck(); + else if (otmp->otyp == BAG_OF_HOLDING) + otmp->owt = weight(otmp); + else if (otmp->otyp == FIGURINE) { + if (otmp->corpsenm != NON_PM + && !dead_species(otmp->corpsenm,TRUE) + && (carried(otmp) || mcarried(otmp))) + attach_fig_transform_timeout(otmp); + } + if (otmp->lamplit) maybe_adjust_light(otmp, old_light); + return; } void uncurse(otmp) register struct obj *otmp; { - int old_light = 0; + int old_light = 0; - if (otmp->lamplit) old_light = arti_light_radius(otmp); - otmp->cursed = 0; - if (carried(otmp) && confers_luck(otmp)) - set_moreluck(); - else if (otmp->otyp == BAG_OF_HOLDING) - otmp->owt = weight(otmp); - else if (otmp->otyp == FIGURINE && otmp->timed) - (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp)); - if (otmp->lamplit) maybe_adjust_light(otmp, old_light); - return; + if (otmp->lamplit) old_light = arti_light_radius(otmp); + otmp->cursed = 0; + if (carried(otmp) && confers_luck(otmp)) + set_moreluck(); + else if (otmp->otyp == BAG_OF_HOLDING) + otmp->owt = weight(otmp); + else if (otmp->otyp == FIGURINE && otmp->timed) + (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp)); + if (otmp->lamplit) maybe_adjust_light(otmp, old_light); + return; } void @@ -1122,23 +1131,23 @@ blessorcurse(otmp, chance) register struct obj *otmp; register int chance; { - if(otmp->blessed || otmp->cursed) return; + if(otmp->blessed || otmp->cursed) return; - if(!rn2(chance)) { - if(!rn2(2)) { - curse(otmp); - } else { - bless(otmp); - } - } - return; + if(!rn2(chance)) { + if(!rn2(2)) { + curse(otmp); + } else { + bless(otmp); + } + } + return; } int bcsign(otmp) register struct obj *otmp; { - return(!!otmp->blessed - !!otmp->cursed); + return(!!otmp->blessed - !!otmp->cursed); } /* @@ -1153,54 +1162,54 @@ int weight(obj) register struct obj *obj; { - int wt = objects[obj->otyp].oc_weight; + int wt = objects[obj->otyp].oc_weight; - if (SchroedingersBox(obj)) - wt += mons[PM_HOUSECAT].cwt; - if (Is_container(obj) || obj->otyp == STATUE) { - struct obj *contents; - register int cwt = 0; + if (SchroedingersBox(obj)) + wt += mons[PM_HOUSECAT].cwt; + if (Is_container(obj) || obj->otyp == STATUE) { + struct obj *contents; + register int cwt = 0; - if (obj->otyp == STATUE && obj->corpsenm >= LOW_PM) - wt = (int)obj->quan * - ((int)mons[obj->corpsenm].cwt * 3 / 2); + if (obj->otyp == STATUE && obj->corpsenm >= LOW_PM) + wt = (int)obj->quan * + ((int)mons[obj->corpsenm].cwt * 3 / 2); - for(contents=obj->cobj; contents; contents=contents->nobj) - cwt += weight(contents); - /* - * The weight of bags of holding is calculated as the weight - * of the bag plus the weight of the bag's contents modified - * as follows: - * - * Bag status Weight of contents - * ---------- ------------------ - * cursed 2x - * blessed x/4 [rounded up: (x+3)/4] - * otherwise x/2 [rounded up: (x+1)/2] - * - * The macro DELTA_CWT in pickup.c also implements these - * weight equations. - */ - if (obj->otyp == BAG_OF_HOLDING) - cwt = obj->cursed ? (cwt * 2) : - obj->blessed ? ((cwt + 3) / 4) : - ((cwt + 1) / 2); + for(contents=obj->cobj; contents; contents=contents->nobj) + cwt += weight(contents); + /* + * The weight of bags of holding is calculated as the weight + * of the bag plus the weight of the bag's contents modified + * as follows: + * + * Bag status Weight of contents + * ---------- ------------------ + * cursed 2x + * blessed x/4 [rounded up: (x+3)/4] + * otherwise x/2 [rounded up: (x+1)/2] + * + * The macro DELTA_CWT in pickup.c also implements these + * weight equations. + */ + if (obj->otyp == BAG_OF_HOLDING) + cwt = obj->cursed ? (cwt * 2) : + obj->blessed ? ((cwt + 3) / 4) : + ((cwt + 1) / 2); - return wt + cwt; - } - if (obj->otyp == CORPSE && obj->corpsenm >= LOW_PM) { - long long_wt = obj->quan * (long) mons[obj->corpsenm].cwt; + return wt + cwt; + } + if (obj->otyp == CORPSE && obj->corpsenm >= LOW_PM) { + long long_wt = obj->quan * (long) mons[obj->corpsenm].cwt; - wt = (long_wt > LARGEST_INT) ? LARGEST_INT : (int)long_wt; - if (obj->oeaten) wt = eaten_stat(wt, obj); - return wt; - } else if (obj->oclass == FOOD_CLASS && obj->oeaten) { - return eaten_stat((int)obj->quan * wt, obj); - } else if (obj->oclass == COIN_CLASS) - return (int)((obj->quan + 50L) / 100L); - else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0) - return((int)(obj->owt)); /* kludge for "very" heavy iron ball */ - return(wt ? wt*(int)obj->quan : ((int)obj->quan + 1)>>1); + wt = (long_wt > LARGEST_INT) ? LARGEST_INT : (int)long_wt; + if (obj->oeaten) wt = eaten_stat(wt, obj); + return wt; + } else if (obj->oclass == FOOD_CLASS && obj->oeaten) { + return eaten_stat((int)obj->quan * wt, obj); + } else if (obj->oclass == COIN_CLASS) + return (int)((obj->quan + 50L) / 100L); + else if (obj->otyp == HEAVY_IRON_BALL && obj->owt != 0) + return((int)(obj->owt)); /* kludge for "very" heavy iron ball */ + return(wt ? wt*(int)obj->quan : ((int)obj->quan + 1)>>1); } static int treefruits[] = {APPLE,ORANGE,PEAR,BANANA,EUCALYPTUS_LEAF}; @@ -1209,7 +1218,7 @@ struct obj * rnd_treefruit_at(x,y) int x, y; { - return mksobj_at(treefruits[rn2(SIZE(treefruits))], x, y, TRUE, FALSE); + return mksobj_at(treefruits[rn2(SIZE(treefruits))], x, y, TRUE, FALSE); } struct obj * @@ -1220,12 +1229,12 @@ int x, y; register struct obj *gold = g_at(x,y); if (amount <= 0L) - amount = (long)(1 + rnd(level_difficulty()+2) * rnd(30)); + amount = (long)(1 + rnd(level_difficulty()+2) * rnd(30)); if (gold) { - gold->quan += amount; + gold->quan += amount; } else { - gold = mksobj_at(GOLD_PIECE, x, y, TRUE, FALSE); - gold->quan = amount; + gold = mksobj_at(GOLD_PIECE, x, y, TRUE, FALSE); + gold->quan = amount; } gold->owt = weight(gold); return (gold); @@ -1233,9 +1242,9 @@ int x, y; /* return TRUE if the corpse has special timing */ #define special_corpse(num) (((num) == PM_LIZARD) \ - || ((num) == PM_LICHEN) \ - || (is_rider(&mons[num])) \ - || (mons[num].mlet == S_TROLL)) + || ((num) == PM_LICHEN) \ + || (is_rider(&mons[num])) \ + || (mons[num].mlet == S_TROLL)) /* * OEXTRA note: Passing mtmp causes mtraits to be saved @@ -1254,41 +1263,41 @@ struct permonst *ptr; int x, y; unsigned corpstatflags; { - register struct obj *otmp; - boolean init = ((corpstatflags & CORPSTAT_INIT) != 0); + register struct obj *otmp; + boolean init = ((corpstatflags & CORPSTAT_INIT) != 0); - if (objtype != CORPSE && objtype != STATUE) - impossible("making corpstat type %d", objtype); - if (x == 0 && y == 0) { /* special case - random placement */ - otmp = mksobj(objtype, init, FALSE); - if (otmp) (void)rloco(otmp); - } else - otmp = mksobj_at(objtype, x, y, init, FALSE); - if (otmp) { - if (mtmp) { - struct obj *otmp2; + if (objtype != CORPSE && objtype != STATUE) + impossible("making corpstat type %d", objtype); + if (x == 0 && y == 0) { /* special case - random placement */ + otmp = mksobj(objtype, init, FALSE); + if (otmp) (void)rloco(otmp); + } else + otmp = mksobj_at(objtype, x, y, init, FALSE); + if (otmp) { + if (mtmp) { + struct obj *otmp2; - if (!ptr) ptr = mtmp->data; - /* save_mtraits frees original data pointed to by otmp */ - otmp2 = save_mtraits(otmp, mtmp); - if (otmp2) otmp = otmp2; - } - /* use the corpse or statue produced by mksobj() as-is - unless `ptr' is non-null */ - if (ptr) { - int old_corpsenm = otmp->corpsenm; + if (!ptr) ptr = mtmp->data; + /* save_mtraits frees original data pointed to by otmp */ + otmp2 = save_mtraits(otmp, mtmp); + if (otmp2) otmp = otmp2; + } + /* use the corpse or statue produced by mksobj() as-is + unless `ptr' is non-null */ + if (ptr) { + int old_corpsenm = otmp->corpsenm; - otmp->corpsenm = monsndx(ptr); - otmp->owt = weight(otmp); - if (otmp->otyp == CORPSE && - (special_corpse(old_corpsenm) || - special_corpse(otmp->corpsenm))) { - obj_stop_timers(otmp); - start_corpse_timeout(otmp); - } - } - } - return(otmp); + otmp->corpsenm = monsndx(ptr); + otmp->owt = weight(otmp); + if (otmp->otyp == CORPSE && + (special_corpse(old_corpsenm) || + special_corpse(otmp->corpsenm))) { + obj_stop_timers(otmp); + start_corpse_timeout(otmp); + } + } + } + return(otmp); } /* @@ -1303,16 +1312,16 @@ int corpse_revive_type(obj) struct obj *obj; { - int revivetype; - struct monst *mtmp; - if (has_omonst(obj) && - ((mtmp = get_mtraits(obj, FALSE)) != (struct monst *)0)) { - /* mtmp is a temporary pointer to a monster's stored - attributes, not a real monster */ - revivetype = mtmp->mnum; - } else - revivetype = obj->corpsenm; - return revivetype; + int revivetype; + struct monst *mtmp; + if (has_omonst(obj) && + ((mtmp = get_mtraits(obj, FALSE)) != (struct monst *)0)) { + /* mtmp is a temporary pointer to a monster's stored + attributes, not a real monster */ + revivetype = mtmp->mnum; + } else + revivetype = obj->corpsenm; + return revivetype; } /* @@ -1335,22 +1344,22 @@ save_mtraits(obj, mtmp) struct obj *obj; struct monst *mtmp; { - if (mtmp->ispriest) forget_temple_entry(mtmp); /* EPRI() */ - if (!has_omonst(obj)) newomonst(obj); - if (has_omonst(obj)) { - struct monst *mtmp2 = OMONST(obj); - *mtmp2 = *mtmp; - mtmp2->mextra = (struct mextra *)0; - if (mtmp->data) mtmp2->mnum = monsndx(mtmp->data); - /* invalidate pointers */ - /* m_id is needed to know if this is a revived quest leader */ - /* but m_id must be cleared when loading bones */ - mtmp2->nmon = (struct monst *)0; - mtmp2->data = (struct permonst *)0; - mtmp2->minvent = (struct obj *)0; - if (mtmp->mextra) copy_mextra(mtmp2, mtmp); - } - return obj; + if (mtmp->ispriest) forget_temple_entry(mtmp); /* EPRI() */ + if (!has_omonst(obj)) newomonst(obj); + if (has_omonst(obj)) { + struct monst *mtmp2 = OMONST(obj); + *mtmp2 = *mtmp; + mtmp2->mextra = (struct mextra *)0; + if (mtmp->data) mtmp2->mnum = monsndx(mtmp->data); + /* invalidate pointers */ + /* m_id is needed to know if this is a revived quest leader */ + /* but m_id must be cleared when loading bones */ + mtmp2->nmon = (struct monst *)0; + mtmp2->data = (struct permonst *)0; + mtmp2->minvent = (struct obj *)0; + if (mtmp->mextra) copy_mextra(mtmp2, mtmp); + } + return obj; } /* returns a pointer to a new monst structure based on @@ -1361,22 +1370,22 @@ get_mtraits(obj, copyof) struct obj *obj; boolean copyof; { - struct monst *mtmp = (struct monst *)0; - struct monst *mnew = (struct monst *)0; + struct monst *mtmp = (struct monst *)0; + struct monst *mnew = (struct monst *)0; - if (has_omonst(obj)) mtmp = OMONST(obj); - if (mtmp) { - if (copyof) { - mnew = newmonst(); - *mnew = *mtmp; - mnew->mextra = (struct mextra *)0; - if (mtmp->mextra) copy_mextra(mnew, mtmp); - } else { - /* Never insert this returned pointer into mon chains! */ - mnew = mtmp; - } - } - return mnew; + if (has_omonst(obj)) mtmp = OMONST(obj); + if (mtmp) { + if (copyof) { + mnew = newmonst(); + *mnew = *mtmp; + mnew->mextra = (struct mextra *)0; + if (mtmp->mextra) copy_mextra(mnew, mtmp); + } else { + /* Never insert this returned pointer into mon chains! */ + mnew = mtmp; + } + } + return mnew; } /* make an object named after someone listed in the scoreboard file */ @@ -1385,16 +1394,16 @@ mk_tt_object(objtype, x, y) int objtype; /* CORPSE or STATUE */ register int x, y; { - register struct obj *otmp, *otmp2; - boolean initialize_it; + register struct obj *otmp, *otmp2; + boolean initialize_it; - /* player statues never contain books */ - initialize_it = (objtype != STATUE); - if ((otmp = mksobj_at(objtype, x, y, initialize_it, FALSE)) != 0) { - /* tt_oname will return null if the scoreboard is empty */ - if ((otmp2 = tt_oname(otmp)) != 0) otmp = otmp2; - } - return(otmp); + /* player statues never contain books */ + initialize_it = (objtype != STATUE); + if ((otmp = mksobj_at(objtype, x, y, initialize_it, FALSE)) != 0) { + /* tt_oname will return null if the scoreboard is empty */ + if ((otmp2 = tt_oname(otmp)) != 0) otmp = otmp2; + } + return(otmp); } /* make a new corpse or statue, uninitialized if a statue (i.e. no books) */ @@ -1405,45 +1414,45 @@ struct permonst *ptr; int x, y; const char *nm; { - struct obj *otmp; - unsigned corpstatflags = (objtype != STATUE) ? - CORPSTAT_INIT : CORPSTAT_NONE; + struct obj *otmp; + unsigned corpstatflags = (objtype != STATUE) ? + CORPSTAT_INIT : CORPSTAT_NONE; - otmp = mkcorpstat(objtype, (struct monst *)0, ptr, - x, y, corpstatflags); - if (nm) - otmp = oname(otmp, nm); - return(otmp); + otmp = mkcorpstat(objtype, (struct monst *)0, ptr, + x, y, corpstatflags); + if (nm) + otmp = oname(otmp, nm); + return(otmp); } boolean is_flammable(otmp) register struct obj *otmp; { - int otyp = otmp->otyp; - int omat = objects[otyp].oc_material; + int otyp = otmp->otyp; + int omat = objects[otyp].oc_material; - /* Candles can be burned, but they're not flammable in the sense that - * they can't get fire damage and it makes no sense for them to be - * fireproofed. - */ - if (Is_candle(otmp)) - return FALSE; + /* Candles can be burned, but they're not flammable in the sense that + * they can't get fire damage and it makes no sense for them to be + * fireproofed. + */ + if (Is_candle(otmp)) + return FALSE; - if (objects[otyp].oc_oprop == FIRE_RES || otyp == WAN_FIRE) - return FALSE; + if (objects[otyp].oc_oprop == FIRE_RES || otyp == WAN_FIRE) + return FALSE; - return((boolean)((omat <= WOOD && omat != LIQUID) || omat == PLASTIC)); + return((boolean)((omat <= WOOD && omat != LIQUID) || omat == PLASTIC)); } boolean is_rottable(otmp) register struct obj *otmp; { - int otyp = otmp->otyp; + int otyp = otmp->otyp; - return((boolean)(objects[otyp].oc_material <= WOOD && - objects[otyp].oc_material != LIQUID)); + return((boolean)(objects[otyp].oc_material <= WOOD && + objects[otyp].oc_material != LIQUID)); } /* @@ -1460,7 +1469,7 @@ int x, y; register struct obj *otmp2 = level.objects[x][y]; if (otmp->where != OBJ_FREE) - panic("place_object: obj not free"); + panic("place_object: obj not free"); obj_no_longer_held(otmp); /* (could bypass this vision update if there is already a boulder here) */ @@ -1468,11 +1477,11 @@ int x, y; /* obj goes under boulders */ if (otmp2 && (otmp2->otyp == BOULDER)) { - otmp->nexthere = otmp2->nexthere; - otmp2->nexthere = otmp; + otmp->nexthere = otmp2->nexthere; + otmp2->nexthere = otmp; } else { - otmp->nexthere = otmp2; - level.objects[x][y] = otmp; + otmp->nexthere = otmp2; + level.objects[x][y] = otmp; } /* set the new object's location */ @@ -1497,18 +1506,18 @@ obj_ice_effects(x, y, do_buried) int x, y; boolean do_buried; { - struct obj *otmp; + struct obj *otmp; - for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) { - if (otmp->timed) obj_timer_checks(otmp, x, y, 0); - } - if (do_buried) { - for (otmp = level.buriedobjlist; otmp; otmp = otmp->nobj) { - if (otmp->ox == x && otmp->oy == y) { - if (otmp->timed) obj_timer_checks(otmp, x, y, 0); - } - } - } + for (otmp = level.objects[x][y]; otmp; otmp = otmp->nexthere) { + if (otmp->timed) obj_timer_checks(otmp, x, y, 0); + } + if (do_buried) { + for (otmp = level.buriedobjlist; otmp; otmp = otmp->nobj) { + if (otmp->ox == x && otmp->oy == y) { + if (otmp->timed) obj_timer_checks(otmp, x, y, 0); + } + } + } } /* @@ -1525,9 +1534,9 @@ struct obj *otmp; long age, retval = otmp->age; if (otmp->otyp == CORPSE && otmp->on_ice) { - /* Adjust the age; must be same as obj_timer_checks() for off ice*/ - age = monstermoves - otmp->age; - retval += age * (ROT_ICE_ADJUSTMENT-1) / ROT_ICE_ADJUSTMENT; + /* Adjust the age; must be same as obj_timer_checks() for off ice*/ + age = monstermoves - otmp->age; + retval += age * (ROT_ICE_ADJUSTMENT-1) / ROT_ICE_ADJUSTMENT; debugpline3("The %s age has ice modifications: otmp->age = %ld, returning %ld.", s_suffix(doname(otmp)), otmp->age, retval); debugpline1("Effective age of corpse: %ld.", monstermoves - retval); @@ -1549,56 +1558,56 @@ int force; /* 0 = no force so do checks, <0 = force off, >0 force on */ /* Check for corpses just placed on or in ice */ if (otmp->otyp == CORPSE && (on_floor || buried) && is_ice(x,y)) { - tleft = stop_timer(action, obj_to_any(otmp)); - if (tleft == 0L) { - action = REVIVE_MON; - tleft = stop_timer(action, obj_to_any(otmp)); - } - if (tleft != 0L) { - long age; - - /* mark the corpse as being on ice */ - otmp->on_ice = 1; + tleft = stop_timer(action, obj_to_any(otmp)); + if (tleft == 0L) { + action = REVIVE_MON; + tleft = stop_timer(action, obj_to_any(otmp)); + } + if (tleft != 0L) { + long age; + + /* mark the corpse as being on ice */ + otmp->on_ice = 1; debugpline3("%s is now on ice at <%d,%d>.", The(xname(otmp)), x, y); - /* Adjust the time remaining */ - tleft *= ROT_ICE_ADJUSTMENT; - restart_timer = TRUE; - /* Adjust the age; time spent off ice needs to be multiplied - by the ice adjustment and subtracted from the age so that - later calculations behave as if it had been on ice during - that time (longwinded way of saying this is the inverse - of removing it from the ice and of peeking at its age). */ - age = monstermoves - otmp->age; - otmp->age = monstermoves - (age * ROT_ICE_ADJUSTMENT); - } + /* Adjust the time remaining */ + tleft *= ROT_ICE_ADJUSTMENT; + restart_timer = TRUE; + /* Adjust the age; time spent off ice needs to be multiplied + by the ice adjustment and subtracted from the age so that + later calculations behave as if it had been on ice during + that time (longwinded way of saying this is the inverse + of removing it from the ice and of peeking at its age). */ + age = monstermoves - otmp->age; + otmp->age = monstermoves - (age * ROT_ICE_ADJUSTMENT); + } } /* Check for corpses coming off ice */ else if ((force < 0) || - (otmp->otyp == CORPSE && otmp->on_ice && - !((on_floor || buried) && is_ice(x,y)))) { - tleft = stop_timer(action, obj_to_any(otmp)); - if (tleft == 0L) { - action = REVIVE_MON; - tleft = stop_timer(action, obj_to_any(otmp)); - } - if (tleft != 0L) { - long age; + (otmp->otyp == CORPSE && otmp->on_ice && + !((on_floor || buried) && is_ice(x,y)))) { + tleft = stop_timer(action, obj_to_any(otmp)); + if (tleft == 0L) { + action = REVIVE_MON; + tleft = stop_timer(action, obj_to_any(otmp)); + } + if (tleft != 0L) { + long age; - otmp->on_ice = 0; + otmp->on_ice = 0; debugpline3("%s is no longer on ice at <%d,%d>.", The(xname(otmp)), x, y); - /* Adjust the remaining time */ - tleft /= ROT_ICE_ADJUSTMENT; - restart_timer = TRUE; - /* Adjust the age */ - age = monstermoves - otmp->age; - otmp->age += age * (ROT_ICE_ADJUSTMENT-1) / ROT_ICE_ADJUSTMENT; - } + /* Adjust the remaining time */ + tleft /= ROT_ICE_ADJUSTMENT; + restart_timer = TRUE; + /* Adjust the age */ + age = monstermoves - otmp->age; + otmp->age += age * (ROT_ICE_ADJUSTMENT-1) / ROT_ICE_ADJUSTMENT; + } } /* now re-start the timer with the appropriate modifications */ if (restart_timer) - (void) start_timer(tleft, TIMER_OBJECT, action, obj_to_any(otmp)); + (void) start_timer(tleft, TIMER_OBJECT, action, obj_to_any(otmp)); } #undef ROT_ICE_ADJUSTMENT @@ -1611,12 +1620,12 @@ register struct obj *otmp; xchar y = otmp->oy; if (otmp->where != OBJ_FLOOR) - panic("remove_object: obj not on floor"); + panic("remove_object: obj not on floor"); extract_nexthere(otmp, &level.objects[x][y]); extract_nobj(otmp, &fobj); /* update vision iff this was the only boulder at its spot */ if (otmp->otyp == BOULDER && !sobj_at(BOULDER, x, y)) - unblock_point(x,y); /* vision */ + unblock_point(x,y); /* vision */ if (otmp->timed) obj_timer_checks(otmp,x,y,0); } @@ -1629,17 +1638,17 @@ struct monst *mtmp; boolean keeping_mon = (mtmp->mhp > 0); while ((otmp = mtmp->minvent) != 0) { - /* this has now become very similar to m_useupall()... */ - obj_extract_self(otmp); - if (otmp->owornmask) { - if (keeping_mon) { - if (otmp == mwep) mwepgone(mtmp), mwep = 0; - mtmp->misc_worn_check &= ~otmp->owornmask; - update_mon_intrinsics(mtmp, otmp, FALSE, TRUE); - } - otmp->owornmask = 0L; /* obfree() expects this */ - } - obfree(otmp, (struct obj *)0); /* dealloc_obj() isn't sufficient */ + /* this has now become very similar to m_useupall()... */ + obj_extract_self(otmp); + if (otmp->owornmask) { + if (keeping_mon) { + if (otmp == mwep) mwepgone(mtmp), mwep = 0; + mtmp->misc_worn_check &= ~otmp->owornmask; + update_mon_intrinsics(mtmp, otmp, FALSE, TRUE); + } + otmp->owornmask = 0L; /* obfree() expects this */ + } + obfree(otmp, (struct obj *)0); /* dealloc_obj() isn't sufficient */ } } @@ -1663,33 +1672,33 @@ obj_extract_self(obj) struct obj *obj; { switch (obj->where) { - case OBJ_FREE: - break; - case OBJ_FLOOR: - remove_object(obj); - break; - case OBJ_CONTAINED: - extract_nobj(obj, &obj->ocontainer->cobj); - container_weight(obj->ocontainer); - break; - case OBJ_INVENT: - freeinv(obj); - break; - case OBJ_MINVENT: - extract_nobj(obj, &obj->ocarry->minvent); - break; - case OBJ_MIGRATING: - extract_nobj(obj, &migrating_objs); - break; - case OBJ_BURIED: - extract_nobj(obj, &level.buriedobjlist); - break; - case OBJ_ONBILL: - extract_nobj(obj, &billobjs); - break; - default: - panic("obj_extract_self"); - break; + case OBJ_FREE: + break; + case OBJ_FLOOR: + remove_object(obj); + break; + case OBJ_CONTAINED: + extract_nobj(obj, &obj->ocontainer->cobj); + container_weight(obj->ocontainer); + break; + case OBJ_INVENT: + freeinv(obj); + break; + case OBJ_MINVENT: + extract_nobj(obj, &obj->ocarry->minvent); + break; + case OBJ_MIGRATING: + extract_nobj(obj, &migrating_objs); + break; + case OBJ_BURIED: + extract_nobj(obj, &level.buriedobjlist); + break; + case OBJ_ONBILL: + extract_nobj(obj, &billobjs); + break; + default: + panic("obj_extract_self"); + break; } } @@ -1703,13 +1712,13 @@ extract_nobj(obj, head_ptr) curr = *head_ptr; for (prev = (struct obj *) 0; curr; prev = curr, curr = curr->nobj) { - if (curr == obj) { - if (prev) - prev->nobj = curr->nobj; - else - *head_ptr = curr->nobj; - break; - } + if (curr == obj) { + if (prev) + prev->nobj = curr->nobj; + else + *head_ptr = curr->nobj; + break; + } } if (!curr) panic("extract_nobj: object lost"); obj->where = OBJ_FREE; @@ -1730,13 +1739,13 @@ extract_nexthere(obj, head_ptr) curr = *head_ptr; for (prev = (struct obj *) 0; curr; prev = curr, curr = curr->nexthere) { - if (curr == obj) { - if (prev) - prev->nexthere = curr->nexthere; - else - *head_ptr = curr->nexthere; - break; - } + if (curr == obj) { + if (prev) + prev->nexthere = curr->nexthere; + else + *head_ptr = curr->nexthere; + break; + } } if (!curr) panic("extract_nexthere: object lost"); } @@ -1755,12 +1764,12 @@ add_to_minv(mon, obj) struct obj *otmp; if (obj->where != OBJ_FREE) - panic("add_to_minv: obj not free"); + panic("add_to_minv: obj not free"); /* merge if possible */ for (otmp = mon->minvent; otmp; otmp = otmp->nobj) - if (merged(&otmp, &obj)) - return 1; /* obj merged and then free'd */ + if (merged(&otmp, &obj)) + return 1; /* obj merged and then free'd */ /* else insert; don't bother forcing it to end of chain */ obj->where = OBJ_MINVENT; obj->ocarry = mon; @@ -1780,13 +1789,13 @@ add_to_container(container, obj) struct obj *otmp; if (obj->where != OBJ_FREE) - panic("add_to_container: obj not free"); + panic("add_to_container: obj not free"); if (container->where != OBJ_INVENT && container->where != OBJ_MINVENT) - obj_no_longer_held(obj); + obj_no_longer_held(obj); /* merge if possible */ for (otmp = container->cobj; otmp; otmp = otmp->nobj) - if (merged(&otmp, &obj)) return (otmp); + if (merged(&otmp, &obj)) return (otmp); obj->where = OBJ_CONTAINED; obj->ocontainer = container; @@ -1800,7 +1809,7 @@ add_to_migration(obj) struct obj *obj; { if (obj->where != OBJ_FREE) - panic("add_to_migration: obj not free"); + panic("add_to_migration: obj not free"); obj->where = OBJ_MIGRATING; obj->nobj = migrating_objs; @@ -1812,7 +1821,7 @@ add_to_buried(obj) struct obj *obj; { if (obj->where != OBJ_FREE) - panic("add_to_buried: obj not free"); + panic("add_to_buried: obj not free"); obj->where = OBJ_BURIED; obj->nobj = level.buriedobjlist; @@ -1826,10 +1835,10 @@ container_weight(container) { container->owt = weight(container); if (container->where == OBJ_CONTAINED) - container_weight(container->ocontainer); + container_weight(container->ocontainer); /* else if (container->where == OBJ_INVENT) - recalculate load delay here ??? + recalculate load delay here ??? */ } @@ -1842,11 +1851,11 @@ dealloc_obj(obj) struct obj *obj; { if (obj->where != OBJ_FREE) - panic("dealloc_obj: obj not free"); + panic("dealloc_obj: obj not free"); /* free up any timers attached to the object */ if (obj->timed) - obj_stop_timers(obj); + obj_stop_timers(obj); /* * Free up any light sources attached to the object. @@ -1857,7 +1866,7 @@ dealloc_obj(obj) * attached to it (and also requires lamplit to be set). */ if (obj_sheds_light(obj)) - del_light_source(LS_OBJECT, obj_to_any(obj)); + del_light_source(LS_OBJECT, obj_to_any(obj)); if (obj == thrownobj) thrownobj = 0; if (obj == kickedobj) kickedobj = 0; @@ -1875,64 +1884,64 @@ boolean tipping; /* caller emptying entire contents; affects shop handling */ int objcount = 0; if (!horn || horn->otyp != HORN_OF_PLENTY) { - impossible("bad horn o' plenty"); + impossible("bad horn o' plenty"); } else if (horn->spe < 1) { - pline1(nothing_happens); + pline1(nothing_happens); } else { - struct obj *obj; - const char *what; + struct obj *obj; + const char *what; - consume_obj_charge(horn, !tipping); - if (!rn2(13)) { - obj = mkobj(POTION_CLASS, FALSE); - if (objects[obj->otyp].oc_magic) do { - obj->otyp = rnd_class(POT_BOOZE, POT_WATER); - } while (obj->otyp == POT_SICKNESS); - what = (obj->quan > 1L) ? "Some potions" : "A potion"; - } else { - obj = mkobj(FOOD_CLASS, FALSE); - if (obj->otyp == FOOD_RATION && !rn2(7)) - obj->otyp = LUMP_OF_ROYAL_JELLY; - what = "Some food"; - } - ++objcount; - pline("%s %s out.", what, vtense(what, "spill")); - obj->blessed = horn->blessed; - obj->cursed = horn->cursed; - obj->owt = weight(obj); - /* using a shop's horn of plenty entails a usage fee and also - confers ownership of the created item to the shopkeeper */ - if (horn->unpaid) - addtobill(obj, FALSE, FALSE, tipping); - /* if it ended up on bill, we don't want "(unpaid, N zorkids)" - being included in its formatted name during next message */ - iflags.suppress_price++; - if (!tipping) { - obj = hold_another_object(obj, u.uswallow ? - "Oops! %s out of your reach!" : - (Is_airlevel(&u.uz) || - Is_waterlevel(&u.uz) || - levl[u.ux][u.uy].typ < IRONBARS || - levl[u.ux][u.uy].typ >= ICE) ? - "Oops! %s away from you!" : - "Oops! %s to the floor!", - The(aobjnam(obj, "slip")), - (const char *)0); - } else { - /* assumes this is taking place at hero's location */ - if (!can_reach_floor(TRUE)) { - hitfloor(obj); /* does altar check, message, drop */ - } else { - if (IS_ALTAR(levl[u.ux][u.uy].typ)) - doaltarobj(obj); /* does its own drop message */ - else - pline("%s %s to the %s.", Doname2(obj), - otense(obj, "drop"), surface(u.ux, u.uy)); - dropy(obj); - } - } - iflags.suppress_price--; - if (horn->dknown) makeknown(HORN_OF_PLENTY); + consume_obj_charge(horn, !tipping); + if (!rn2(13)) { + obj = mkobj(POTION_CLASS, FALSE); + if (objects[obj->otyp].oc_magic) do { + obj->otyp = rnd_class(POT_BOOZE, POT_WATER); + } while (obj->otyp == POT_SICKNESS); + what = (obj->quan > 1L) ? "Some potions" : "A potion"; + } else { + obj = mkobj(FOOD_CLASS, FALSE); + if (obj->otyp == FOOD_RATION && !rn2(7)) + obj->otyp = LUMP_OF_ROYAL_JELLY; + what = "Some food"; + } + ++objcount; + pline("%s %s out.", what, vtense(what, "spill")); + obj->blessed = horn->blessed; + obj->cursed = horn->cursed; + obj->owt = weight(obj); + /* using a shop's horn of plenty entails a usage fee and also + confers ownership of the created item to the shopkeeper */ + if (horn->unpaid) + addtobill(obj, FALSE, FALSE, tipping); + /* if it ended up on bill, we don't want "(unpaid, N zorkids)" + being included in its formatted name during next message */ + iflags.suppress_price++; + if (!tipping) { + obj = hold_another_object(obj, u.uswallow ? + "Oops! %s out of your reach!" : + (Is_airlevel(&u.uz) || + Is_waterlevel(&u.uz) || + levl[u.ux][u.uy].typ < IRONBARS || + levl[u.ux][u.uy].typ >= ICE) ? + "Oops! %s away from you!" : + "Oops! %s to the floor!", + The(aobjnam(obj, "slip")), + (const char *)0); + } else { + /* assumes this is taking place at hero's location */ + if (!can_reach_floor(TRUE)) { + hitfloor(obj); /* does altar check, message, drop */ + } else { + if (IS_ALTAR(levl[u.ux][u.uy].typ)) + doaltarobj(obj); /* does its own drop message */ + else + pline("%s %s to the %s.", Doname2(obj), + otense(obj, "drop"), surface(u.ux, u.uy)); + dropy(obj); + } + } + iflags.suppress_price--; + if (horn->dknown) makeknown(HORN_OF_PLENTY); } return objcount; } @@ -1940,11 +1949,11 @@ boolean tipping; /* caller emptying entire contents; affects shop handling */ /* support for wizard-mode's `sanity_check' option */ static const char NEARDATA /* pline formats for insane_object() */ - ofmt0[] = "%s obj %s %s: %s", - ofmt3[] = "%s [not null] %s %s: %s", - /* " held by mon %p (%s)" will be appended, filled by M,mon_nam(M) */ - mfmt1[] = "%s obj %s %s (%s)", - mfmt2[] = "%s obj %s %s (%s) *not*"; + ofmt0[] = "%s obj %s %s: %s", + ofmt3[] = "%s [not null] %s %s: %s", + /* " held by mon %p (%s)" will be appended, filled by M,mon_nam(M) */ + mfmt1[] = "%s obj %s %s (%s)", + mfmt2[] = "%s obj %s %s (%s) *not*"; /* Check all object lists for consistency. */ void @@ -1959,19 +1968,19 @@ obj_sanity_check() those objects should have already been sanity checked via the floor list so container contents are skipped here */ for (x = 0; x < COLNO; x++) - for (y = 0; y < ROWNO; y++) - for (obj = level.objects[x][y]; obj; obj = obj->nexthere) { - /* should match ; <0,*> should always be empty */ - if (obj->where != OBJ_FLOOR || x == 0 || - obj->ox != x || obj->oy != y) { - char at_fmt[BUFSZ]; + for (y = 0; y < ROWNO; y++) + for (obj = level.objects[x][y]; obj; obj = obj->nexthere) { + /* should match ; <0,*> should always be empty */ + if (obj->where != OBJ_FLOOR || x == 0 || + obj->ox != x || obj->oy != y) { + char at_fmt[BUFSZ]; - Sprintf(at_fmt, "%%s obj@<%d,%d> %%s %%s: %%s@<%d,%d>", - x, y, obj->ox, obj->oy); - insane_object(obj, at_fmt, "location sanity", - (struct monst *)0); - } - } + Sprintf(at_fmt, "%%s obj@<%d,%d> %%s %%s: %%s@<%d,%d>", + x, y, obj->ox, obj->oy); + insane_object(obj, at_fmt, "location sanity", + (struct monst *)0); + } + } objlist_sanity(invent, OBJ_INVENT, "invent sanity"); objlist_sanity(migrating_objs, OBJ_MIGRATING, "migrating sanity"); @@ -1983,16 +1992,16 @@ obj_sanity_check() /* monsters temporarily in transit; they should have arrived with hero by the time we get called */ if (mydogs) { - pline("mydogs sanity [not empty]"); - mon_obj_sanity(mydogs, "mydogs minvent sanity"); + pline("mydogs sanity [not empty]"); + mon_obj_sanity(mydogs, "mydogs minvent sanity"); } /* objects temporarily freed from invent/floor lists; they should have arrived somewhere by the time we get called */ if (thrownobj) - insane_object(thrownobj, ofmt3, "thrownobj sanity", (struct monst *)0); + insane_object(thrownobj, ofmt3, "thrownobj sanity", (struct monst *)0); if (kickedobj) - insane_object(kickedobj, ofmt3, "kickedobj sanity", (struct monst *)0); + insane_object(kickedobj, ofmt3, "kickedobj sanity", (struct monst *)0); /* [how about current_wand too?] */ } @@ -2006,15 +2015,15 @@ const char *mesg; struct obj *obj; for (obj = objlist; obj; obj = obj->nobj) { - if (obj->where != wheretype) - insane_object(obj, ofmt0, mesg, (struct monst *)0); - if (Has_contents(obj)) { - if (wheretype == OBJ_ONBILL) - /* containers on shop bill should always be empty */ - insane_object(obj, "%s obj contains something! %s %s: %s", - mesg, (struct monst *)0); - check_contained(obj, mesg); - } + if (obj->where != wheretype) + insane_object(obj, ofmt0, mesg, (struct monst *)0); + if (Has_contents(obj)) { + if (wheretype == OBJ_ONBILL) + /* containers on shop bill should always be empty */ + insane_object(obj, "%s obj contains something! %s %s: %s", + mesg, (struct monst *)0); + check_contained(obj, mesg); + } } } @@ -2028,19 +2037,19 @@ const char *mesg; struct obj *obj; for (mon = monlist; mon; mon = mon->nmon) - for (obj = mon->minvent; obj; obj = obj->nobj) { - if (obj->where != OBJ_MINVENT) - insane_object(obj, mfmt1, mesg, mon); - if (obj->ocarry != mon) - insane_object(obj, mfmt2, mesg, mon); - check_contained(obj, mesg); - } + for (obj = mon->minvent; obj; obj = obj->nobj) { + if (obj->where != OBJ_MINVENT) + insane_object(obj, mfmt1, mesg, mon); + if (obj->ocarry != mon) + insane_object(obj, mfmt2, mesg, mon); + check_contained(obj, mesg); + } } /* This must stay consistent with the defines in obj.h. */ static const char *obj_state_names[NOBJ_STATES] = { - "free", "floor", "contained", "invent", - "minvent", "migrating", "buried", "onbill" + "free", "floor", "contained", "invent", + "minvent", "migrating", "buried", "onbill" }; STATIC_OVL const char * @@ -2053,8 +2062,8 @@ struct obj *obj; if (!obj) return "nowhere"; where = obj->where; if (where < 0 || where >= NOBJ_STATES || !obj_state_names[where]) { - Sprintf(unknown, "unknown[%d]", where); - return unknown; + Sprintf(unknown, "unknown[%d]", where); + return unknown; } return obj_state_names[where]; } @@ -2070,19 +2079,19 @@ struct monst *mon; objnm = monnm = "null!"; if (obj) { - iflags.override_ID++; - objnm = doname(obj); - iflags.override_ID--; + iflags.override_ID++; + objnm = doname(obj); + iflags.override_ID--; } if (mon || (strstri(mesg, "minvent") && !strstri(mesg, "contained"))) { - Strcat(strcpy(altfmt, fmt), " held by mon %s (%s)"); - if (mon) - monnm = x_monnam(mon, ARTICLE_A, (char *)0, EXACT_NAME, TRUE); - pline(altfmt, mesg, - fmt_ptr((genericptr_t)obj), where_name(obj), objnm, - fmt_ptr((genericptr_t)mon), monnm); + Strcat(strcpy(altfmt, fmt), " held by mon %s (%s)"); + if (mon) + monnm = x_monnam(mon, ARTICLE_A, (char *)0, EXACT_NAME, TRUE); + pline(altfmt, mesg, + fmt_ptr((genericptr_t)obj), where_name(obj), objnm, + fmt_ptr((genericptr_t)mon), monnm); } else { - pline(fmt, mesg, fmt_ptr((genericptr_t)obj), where_name(obj), objnm); + pline(fmt, mesg, fmt_ptr((genericptr_t)obj), where_name(obj), objnm); } } @@ -2100,35 +2109,160 @@ check_contained(container, mesg) /* change "invent sanity" to "contained invent sanity" but leave "nested contained invent sanity" as is */ if (!strstri(mesg, "contained")) - mesg = strcat(strcpy(mesgbuf, "contained "), mesg); + mesg = strcat(strcpy(mesgbuf, "contained "), mesg); for (obj = container->cobj; obj; obj = obj->nobj) { - /* catch direct cycle to avoid unbounded recursion */ - if (obj == container) - panic("failed sanity check: container holds itself"); - if (obj->where != OBJ_CONTAINED) - insane_object(obj, "%s obj %s %s: %s", mesg, (struct monst *)0); - else if (obj->ocontainer != container) - pline("%s obj %s in container %s, not %s", mesg, - fmt_ptr((genericptr_t)obj), - fmt_ptr((genericptr_t)obj->ocontainer), - fmt_ptr((genericptr_t)container)); + /* catch direct cycle to avoid unbounded recursion */ + if (obj == container) + panic("failed sanity check: container holds itself"); + if (obj->where != OBJ_CONTAINED) + insane_object(obj, "%s obj %s %s: %s", mesg, (struct monst *)0); + else if (obj->ocontainer != container) + pline("%s obj %s in container %s, not %s", mesg, + fmt_ptr((genericptr_t)obj), + fmt_ptr((genericptr_t)obj->ocontainer), + fmt_ptr((genericptr_t)container)); - if (Has_contents(obj)) { - /* catch most likely indirect cycle; we won't notice if - parent is present when something comes before it, or - notice more deeply embedded cycles (grandparent, &c) */ - if (obj->cobj == container) - panic("failed sanity check: container holds its parent"); - /* change "contained... sanity" to "nested contained... sanity" - and "nested contained..." to "nested nested contained..." */ - Strcpy(nestedmesg, "nested "); - copynchars(eos(nestedmesg), mesg, - (int)sizeof nestedmesg - (int)strlen(nestedmesg) - 1); - /* recursively check contents */ - check_contained(obj, nestedmesg); - } + if (Has_contents(obj)) { + /* catch most likely indirect cycle; we won't notice if + parent is present when something comes before it, or + notice more deeply embedded cycles (grandparent, &c) */ + if (obj->cobj == container) + panic("failed sanity check: container holds its parent"); + /* change "contained... sanity" to "nested contained... sanity" + and "nested contained..." to "nested nested contained..." */ + Strcpy(nestedmesg, "nested "); + copynchars(eos(nestedmesg), mesg, + (int)sizeof nestedmesg - (int)strlen(nestedmesg) - 1); + /* recursively check contents */ + check_contained(obj, nestedmesg); + } } } + +/* + * wrapper to make "near this object" convenient + */ +struct obj* +obj_nexto(otmp) + struct obj* otmp; +{ + struct obj* otmp2 = NULL; + + if (otmp) { + otmp2 = obj_nexto_xy(otmp->otyp, otmp->ox, otmp->oy, otmp->o_id); + } else { + impossible("obj_nexto: wasn't given an object to check"); + } + + return otmp2; +} + + +/* + * looks for objects of a particular type next to x, y + * skips over oid if found (lets us avoid ourselves if + * we're looking for a second type of an existing object) + * + * TODO: return a list of all objects near us so we can more + * reliably predict which one we want to 'find' first + */ +struct obj* +obj_nexto_xy(otyp, x, y, oid) +int otyp, x, y; +unsigned oid; +{ + struct obj* otmp; + int fx, fy, ex, ey; + short dx, dy; + + /* check under our "feet" first */ + otmp = sobj_at(otyp, x, y); + while (otmp) { + /* don't be clever and find ourselves */ + if (otmp->o_id != oid) { return otmp; } + otmp = nxtobj(otmp, otyp, TRUE); + } + + /* search in a random order */ + dx = (rn2(2) ? -1 : 1); + dy = (rn2(2) ? -1 : 1); + ex = x - dx; + ey = y - dy; + + for (fx = ex; abs(fx - ex) < 3; fx += dx) { + for (fy = ey; abs(fy - ey) < 3; fy += dy) { + /* 0, 0 was checked above */ + if (fx != x || fy != y) { + if ((otmp = sobj_at(otyp, fx, fy)) != 0) { + return otmp; + } + } + } + } + return NULL; +} + + +/* + * Causes one object to absorb another, increasing + * weight accordingly. Frees obj2; obj1 remains and + * is returned. + */ +struct obj* +obj_absorb(obj1, obj2) + struct obj **obj1, **obj2; +{ + struct obj *otmp1 = NULL, *otmp2 = NULL; + int extrawt = 0; + + /* don't let people dumb it up */ + if (obj1 && obj2) { + otmp1 = *obj1; + otmp2 = *obj2; + if (otmp1 && otmp2) { + extrawt = otmp2->oeaten ? otmp2->oeaten : otmp2->owt; + otmp1->owt += extrawt; + otmp1->oeaten += otmp1->oeaten ? extrawt : 0; + otmp1->quan = 1; + obj_extract_self(otmp2); + newsym(otmp2->ox, otmp2->oy); /* in case of floor */ + dealloc_obj(otmp2); + *obj2 = NULL; + return otmp1; + } + } + + impossible("obj_absorb: not called with two actual objects"); + return NULL; +} + + +/* + * Causes the heavier object to absorb the lighter object; + * wrapper for obj_absorb so that floor_effects works more + * cleanly (since we don't know which we want to stay around) + */ +struct obj* +obj_meld(obj1, obj2) + struct obj **obj1, **obj2; +{ + struct obj *otmp1 = NULL, *otmp2 = NULL; + + if (obj1 && obj2) { + otmp1 = *obj1; + otmp2 = *obj2; + if (otmp1 && otmp2) { + if (otmp1->owt > otmp2->owt || rn2(2)) { + return obj_absorb(obj1, obj2); + } + return obj_absorb(obj2, obj1); + } + } + + impossible("obj_meld: not called with two actual objects"); + return NULL; +} + /*mkobj.c*/ diff --git a/src/mon.c b/src/mon.c index 5427f8da4..856b97b99 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 mon.c $NHDT-Date: 1427580482 2015/03/28 22:08:02 $ $NHDT-Branch: master $:$NHDT-Revision: 1.142 $ */ +/* NetHack 3.5 mon.c $NHDT-Date: 1426470347 2015/03/16 01:45:47 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.140 $ */ /* NetHack 3.5 mon.c $Date: 2012/05/16 02:15:10 $ $Revision: 1.126 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -25,13 +25,13 @@ STATIC_DCL boolean FDECL(validvamp, (struct monst *,int *,int)); STATIC_DCL struct permonst *FDECL(accept_newcham_form, (int)); #define LEVEL_SPECIFIC_NOCORPSE(mdat) \ - (Is_rogue_level(&u.uz) || \ - (level.flags.graveyard && is_undead(mdat) && rn2(3))) + (Is_rogue_level(&u.uz) || \ + (level.flags.graveyard && is_undead(mdat) && rn2(3))) #if 0 /* part of the original warning code which was replaced in 3.3.1 */ const char *warnings[] = { - "white", "pink", "red", "ruby", "purple", "black" + "white", "pink", "red", "ruby", "purple", "black" }; #endif /* 0 */ @@ -44,31 +44,31 @@ int undead_to_corpse(mndx) int mndx; { - switch (mndx) { - case PM_KOBOLD_ZOMBIE: - case PM_KOBOLD_MUMMY: mndx = PM_KOBOLD; break; - case PM_DWARF_ZOMBIE: - case PM_DWARF_MUMMY: mndx = PM_DWARF; break; - case PM_GNOME_ZOMBIE: - case PM_GNOME_MUMMY: mndx = PM_GNOME; break; - case PM_ORC_ZOMBIE: - case PM_ORC_MUMMY: mndx = PM_ORC; break; - case PM_ELF_ZOMBIE: - case PM_ELF_MUMMY: mndx = PM_ELF; break; - case PM_VAMPIRE: - case PM_VAMPIRE_LORD: + switch (mndx) { + case PM_KOBOLD_ZOMBIE: + case PM_KOBOLD_MUMMY: mndx = PM_KOBOLD; break; + case PM_DWARF_ZOMBIE: + case PM_DWARF_MUMMY: mndx = PM_DWARF; break; + case PM_GNOME_ZOMBIE: + case PM_GNOME_MUMMY: mndx = PM_GNOME; break; + case PM_ORC_ZOMBIE: + case PM_ORC_MUMMY: mndx = PM_ORC; break; + case PM_ELF_ZOMBIE: + case PM_ELF_MUMMY: mndx = PM_ELF; break; + case PM_VAMPIRE: + case PM_VAMPIRE_LORD: #if 0 /* DEFERRED */ - case PM_VAMPIRE_MAGE: + case PM_VAMPIRE_MAGE: #endif - case PM_HUMAN_ZOMBIE: - case PM_HUMAN_MUMMY: mndx = PM_HUMAN; break; - case PM_GIANT_ZOMBIE: - case PM_GIANT_MUMMY: mndx = PM_GIANT; break; - case PM_ETTIN_ZOMBIE: - case PM_ETTIN_MUMMY: mndx = PM_ETTIN; break; - default: break; - } - return mndx; + case PM_HUMAN_ZOMBIE: + case PM_HUMAN_MUMMY: mndx = PM_HUMAN; break; + case PM_GIANT_ZOMBIE: + case PM_GIANT_MUMMY: mndx = PM_GIANT; break; + case PM_ETTIN_ZOMBIE: + case PM_ETTIN_MUMMY: mndx = PM_ETTIN; break; + default: break; + } + return mndx; } /* Convert the monster index of some monsters (such as quest guardians) @@ -81,33 +81,33 @@ int genus(mndx, mode) int mndx, mode; { - switch (mndx) { + switch (mndx) { /* Quest guardians */ - case PM_STUDENT: mndx = mode ? PM_ARCHEOLOGIST : PM_HUMAN; break; - case PM_CHIEFTAIN: mndx = mode ? PM_BARBARIAN : PM_HUMAN; break; - case PM_NEANDERTHAL: mndx = mode ? PM_CAVEMAN : PM_HUMAN; break; - case PM_ATTENDANT: mndx = mode ? PM_HEALER : PM_HUMAN; break; - case PM_PAGE: mndx = mode ? PM_KNIGHT : PM_HUMAN; break; - case PM_ABBOT: mndx = mode ? PM_MONK : PM_HUMAN; break; - case PM_ACOLYTE: mndx = mode ? PM_PRIEST : PM_HUMAN; break; - case PM_HUNTER: mndx = mode ? PM_RANGER : PM_HUMAN; break; - case PM_THUG: mndx = mode ? PM_ROGUE : PM_HUMAN; break; - case PM_ROSHI: mndx = mode ? PM_SAMURAI : PM_HUMAN; break; - case PM_GUIDE: mndx = mode ? PM_TOURIST : PM_HUMAN; break; - case PM_APPRENTICE: mndx = mode ? PM_WIZARD : PM_HUMAN; break; - case PM_WARRIOR: mndx = mode ? PM_VALKYRIE : PM_HUMAN; break; - default: - if (mndx >= LOW_PM && mndx < NUMMONS) { - struct permonst *ptr = &mons[mndx]; - if (is_human(ptr)) mndx = PM_HUMAN; - else if (is_elf(ptr)) mndx = PM_ELF; - else if (is_dwarf(ptr)) mndx = PM_DWARF; - else if (is_gnome(ptr)) mndx = PM_GNOME; - else if (is_orc(ptr)) mndx = PM_ORC; - } - break; - } - return mndx; + case PM_STUDENT: mndx = mode ? PM_ARCHEOLOGIST : PM_HUMAN; break; + case PM_CHIEFTAIN: mndx = mode ? PM_BARBARIAN : PM_HUMAN; break; + case PM_NEANDERTHAL: mndx = mode ? PM_CAVEMAN : PM_HUMAN; break; + case PM_ATTENDANT: mndx = mode ? PM_HEALER : PM_HUMAN; break; + case PM_PAGE: mndx = mode ? PM_KNIGHT : PM_HUMAN; break; + case PM_ABBOT: mndx = mode ? PM_MONK : PM_HUMAN; break; + case PM_ACOLYTE: mndx = mode ? PM_PRIEST : PM_HUMAN; break; + case PM_HUNTER: mndx = mode ? PM_RANGER : PM_HUMAN; break; + case PM_THUG: mndx = mode ? PM_ROGUE : PM_HUMAN; break; + case PM_ROSHI: mndx = mode ? PM_SAMURAI : PM_HUMAN; break; + case PM_GUIDE: mndx = mode ? PM_TOURIST : PM_HUMAN; break; + case PM_APPRENTICE: mndx = mode ? PM_WIZARD : PM_HUMAN; break; + case PM_WARRIOR: mndx = mode ? PM_VALKYRIE : PM_HUMAN; break; + default: + if (mndx >= LOW_PM && mndx < NUMMONS) { + struct permonst *ptr = &mons[mndx]; + if (is_human(ptr)) mndx = PM_HUMAN; + else if (is_elf(ptr)) mndx = PM_ELF; + else if (is_dwarf(ptr)) mndx = PM_DWARF; + else if (is_gnome(ptr)) mndx = PM_GNOME; + else if (is_orc(ptr)) mndx = PM_ORC; + } + break; + } + return mndx; } /* return monster index if chameleon, or NON_PM if not */ @@ -115,26 +115,26 @@ int pm_to_cham(mndx) int mndx; { - int mcham = NON_PM; + int mcham = NON_PM; - /* - * As of 3.5.0 we just check M2_SHAPESHIFTER instead of having a - * big switch statement with hardcoded shapeshifter types here. - */ - if (mndx >= LOW_PM && is_shapeshifter(&mons[mndx])) mcham = mndx; - return mcham; + /* + * As of 3.5.0 we just check M2_SHAPESHIFTER instead of having a + * big switch statement with hardcoded shapeshifter types here. + */ + if (mndx >= LOW_PM && is_shapeshifter(&mons[mndx])) mcham = mndx; + return mcham; } /* for deciding whether corpse will carry along full monster data */ #define KEEPTRAITS(mon) ((mon)->isshk || (mon)->mtame || \ - unique_corpstat(mon->data) || \ - is_reviver((mon)->data) || \ - /* normally leader the will be unique, */ \ - /* but he might have been polymorphed */ \ - (mon)->m_id == quest_status.leader_m_id || \ - /* special cancellation handling for these */ \ - (dmgtype((mon)->data, AD_SEDU) || \ - dmgtype((mon)->data, AD_SSEX))) + unique_corpstat(mon->data) || \ + is_reviver((mon)->data) || \ + /* normally leader the will be unique, */ \ + /* but he might have been polymorphed */ \ + (mon)->m_id == quest_status.leader_m_id || \ + /* special cancellation handling for these */ \ + (dmgtype((mon)->data, AD_SEDU) || \ + dmgtype((mon)->data, AD_SSEX))) /* Creates a monster corpse, a "special" corpse, or nothing if it doesn't * leave corpses. Monsters which leave "special" corpses should have @@ -146,168 +146,187 @@ make_corpse(mtmp,corpseflags) register struct monst *mtmp; unsigned corpseflags; { - register struct permonst *mdat = mtmp->data; - int num; - struct obj *obj = (struct obj *)0; - int x = mtmp->mx, y = mtmp->my; - int mndx = monsndx(mdat); - unsigned corpstatflags = corpseflags; - boolean burythem = ((corpstatflags & CORPSTAT_BURIED) != 0); + register struct permonst *mdat = mtmp->data; + int num; + struct obj *obj = (struct obj *)0; + struct obj* otmp = (struct obj*)0; + int x = mtmp->mx, y = mtmp->my; + int mndx = monsndx(mdat); + unsigned corpstatflags = corpseflags; + boolean burythem = ((corpstatflags & CORPSTAT_BURIED) != 0); - switch(mndx) { - case PM_GRAY_DRAGON: - case PM_SILVER_DRAGON: + switch(mndx) { + case PM_GRAY_DRAGON: + case PM_SILVER_DRAGON: #if 0 /* DEFERRED */ - case PM_SHIMMERING_DRAGON: + case PM_SHIMMERING_DRAGON: #endif - case PM_RED_DRAGON: - case PM_ORANGE_DRAGON: - case PM_WHITE_DRAGON: - case PM_BLACK_DRAGON: - case PM_BLUE_DRAGON: - case PM_GREEN_DRAGON: - case PM_YELLOW_DRAGON: - /* Make dragon scales. This assumes that the order of the */ - /* dragons is the same as the order of the scales. */ - if (!rn2(mtmp->mrevived ? 20 : 3)) { - num = GRAY_DRAGON_SCALES + monsndx(mdat) - PM_GRAY_DRAGON; - obj = mksobj_at(num, x, y, FALSE, FALSE); - obj->spe = 0; - obj->cursed = obj->blessed = FALSE; - } - goto default_1; + case PM_RED_DRAGON: + case PM_ORANGE_DRAGON: + case PM_WHITE_DRAGON: + case PM_BLACK_DRAGON: + case PM_BLUE_DRAGON: + case PM_GREEN_DRAGON: + case PM_YELLOW_DRAGON: + /* Make dragon scales. This assumes that the order of the */ + /* dragons is the same as the order of the scales. */ + if (!rn2(mtmp->mrevived ? 20 : 3)) { + num = GRAY_DRAGON_SCALES + monsndx(mdat) - PM_GRAY_DRAGON; + obj = mksobj_at(num, x, y, FALSE, FALSE); + obj->spe = 0; + obj->cursed = obj->blessed = FALSE; + } + goto default_1; - case PM_WHITE_UNICORN: - case PM_GRAY_UNICORN: - case PM_BLACK_UNICORN: - if (mtmp->mrevived && rn2(2)) { - if (canseemon(mtmp)) - pline("%s recently regrown horn crumbles to dust.", - s_suffix(Monnam(mtmp))); - } else { - obj = mksobj_at(UNICORN_HORN, x, y, TRUE, FALSE); - if (obj && mtmp->mrevived) obj->degraded_horn = 1; - } - goto default_1; - case PM_LONG_WORM: - (void) mksobj_at(WORM_TOOTH, x, y, TRUE, FALSE); - goto default_1; - case PM_VAMPIRE: - case PM_VAMPIRE_LORD: - /* include mtmp in the mkcorpstat() call */ - num = undead_to_corpse(mndx); - corpstatflags |= CORPSTAT_INIT; - obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags); - obj->age -= 100; /* this is an *OLD* corpse */ - break; - case PM_KOBOLD_MUMMY: - case PM_DWARF_MUMMY: - case PM_GNOME_MUMMY: - case PM_ORC_MUMMY: - case PM_ELF_MUMMY: - case PM_HUMAN_MUMMY: - case PM_GIANT_MUMMY: - case PM_ETTIN_MUMMY: - case PM_KOBOLD_ZOMBIE: - case PM_DWARF_ZOMBIE: - case PM_GNOME_ZOMBIE: - case PM_ORC_ZOMBIE: - case PM_ELF_ZOMBIE: - case PM_HUMAN_ZOMBIE: - case PM_GIANT_ZOMBIE: - case PM_ETTIN_ZOMBIE: - num = undead_to_corpse(mndx); - corpstatflags |= CORPSTAT_INIT; - obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags); - obj->age -= 100; /* this is an *OLD* corpse */ - break; - case PM_IRON_GOLEM: - num = d(2,6); - while (num--) - obj = mksobj_at(IRON_CHAIN, x, y, TRUE, FALSE); - free_mname(mtmp); /* don't christen obj */ - break; - case PM_GLASS_GOLEM: - num = d(2,4); /* very low chance of creating all glass gems */ - while (num--) - obj = mksobj_at((LAST_GEM + rnd(9)), x, y, TRUE, FALSE); - free_mname(mtmp); - break; - case PM_CLAY_GOLEM: - obj = mksobj_at(ROCK, x, y, FALSE, FALSE); - obj->quan = (long)(rn2(20) + 50); - obj->owt = weight(obj); - free_mname(mtmp); - break; - case PM_STONE_GOLEM: - corpstatflags &= ~CORPSTAT_INIT; - obj = mkcorpstat(STATUE, (struct monst *)0, - mdat, x, y, corpstatflags); - break; - case PM_WOOD_GOLEM: - num = d(2,4); - while(num--) { - obj = mksobj_at(QUARTERSTAFF, x, y, TRUE, FALSE); - } - free_mname(mtmp); - break; - case PM_LEATHER_GOLEM: - num = d(2,4); - while(num--) - obj = mksobj_at(LEATHER_ARMOR, x, y, TRUE, FALSE); - free_mname(mtmp); - break; - case PM_GOLD_GOLEM: - /* Good luck gives more coins */ - obj = mkgold((long)(200 - rnl(101)), x, y); - free_mname(mtmp); - break; - case PM_PAPER_GOLEM: - num = rnd(4); - while (num--) - obj = mksobj_at(SCR_BLANK_PAPER, x, y, TRUE, FALSE); - free_mname(mtmp); - break; - default_1: - default: - if (mvitals[mndx].mvflags & G_NOCORPSE) - return (struct obj *)0; - else { - corpstatflags |= CORPSTAT_INIT; - /* preserve the unique traits of some creatures */ - obj = mkcorpstat(CORPSE, KEEPTRAITS(mtmp) ? mtmp : 0, - mdat, x, y, corpstatflags); - if (burythem) { + case PM_WHITE_UNICORN: + case PM_GRAY_UNICORN: + case PM_BLACK_UNICORN: + if (mtmp->mrevived && rn2(2)) { + if (canseemon(mtmp)) + pline("%s recently regrown horn crumbles to dust.", + s_suffix(Monnam(mtmp))); + } else { + obj = mksobj_at(UNICORN_HORN, x, y, TRUE, FALSE); + if (obj && mtmp->mrevived) obj->degraded_horn = 1; + } + goto default_1; + case PM_LONG_WORM: + (void) mksobj_at(WORM_TOOTH, x, y, TRUE, FALSE); + goto default_1; + case PM_VAMPIRE: + case PM_VAMPIRE_LORD: + /* include mtmp in the mkcorpstat() call */ + num = undead_to_corpse(mndx); + corpstatflags |= CORPSTAT_INIT; + obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags); + obj->age -= 100; /* this is an *OLD* corpse */ + break; + case PM_KOBOLD_MUMMY: + case PM_DWARF_MUMMY: + case PM_GNOME_MUMMY: + case PM_ORC_MUMMY: + case PM_ELF_MUMMY: + case PM_HUMAN_MUMMY: + case PM_GIANT_MUMMY: + case PM_ETTIN_MUMMY: + case PM_KOBOLD_ZOMBIE: + case PM_DWARF_ZOMBIE: + case PM_GNOME_ZOMBIE: + case PM_ORC_ZOMBIE: + case PM_ELF_ZOMBIE: + case PM_HUMAN_ZOMBIE: + case PM_GIANT_ZOMBIE: + case PM_ETTIN_ZOMBIE: + num = undead_to_corpse(mndx); + corpstatflags |= CORPSTAT_INIT; + obj = mkcorpstat(CORPSE, mtmp, &mons[num], x, y, corpstatflags); + obj->age -= 100; /* this is an *OLD* corpse */ + break; + case PM_IRON_GOLEM: + num = d(2,6); + while (num--) + obj = mksobj_at(IRON_CHAIN, x, y, TRUE, FALSE); + free_mname(mtmp); /* don't christen obj */ + break; + case PM_GLASS_GOLEM: + num = d(2,4); /* very low chance of creating all glass gems */ + while (num--) + obj = mksobj_at((LAST_GEM + rnd(9)), x, y, TRUE, FALSE); + free_mname(mtmp); + break; + case PM_CLAY_GOLEM: + obj = mksobj_at(ROCK, x, y, FALSE, FALSE); + obj->quan = (long)(rn2(20) + 50); + obj->owt = weight(obj); + free_mname(mtmp); + break; + case PM_STONE_GOLEM: + corpstatflags &= ~CORPSTAT_INIT; + obj = mkcorpstat(STATUE, (struct monst *)0, + mdat, x, y, corpstatflags); + break; + case PM_WOOD_GOLEM: + num = d(2,4); + while(num--) { + obj = mksobj_at(QUARTERSTAFF, x, y, TRUE, FALSE); + } + free_mname(mtmp); + break; + case PM_LEATHER_GOLEM: + num = d(2,4); + while(num--) + obj = mksobj_at(LEATHER_ARMOR, x, y, TRUE, FALSE); + free_mname(mtmp); + break; + case PM_GOLD_GOLEM: + /* Good luck gives more coins */ + obj = mkgold((long)(200 - rnl(101)), x, y); + free_mname(mtmp); + break; + case PM_PAPER_GOLEM: + num = rnd(4); + while (num--) + obj = mksobj_at(SCR_BLANK_PAPER, x, y, TRUE, FALSE); + free_mname(mtmp); + break; + /* expired puddings will congeal into a large blob + like dragons, relies on the order remaining consistent */ + case PM_GRAY_OOZE: + case PM_BROWN_PUDDING: + case PM_GREEN_SLIME: + case PM_BLACK_PUDDING: + /* we have to do this here because most other places + * expect there to be an object coming back; not this one */ + obj = mksobj_at(GLOB_OF_BLACK_PUDDING - (PM_BLACK_PUDDING - mndx), + x, y, TRUE, FALSE); + + while ((obj && (otmp = obj_nexto(obj)) != (struct obj*)0)) { + pline("The %s coalesce.", makeplural(obj_typename(obj->otyp))); + obj = obj_meld(&obj, &otmp); + } + free_mname(mtmp); + return obj; + break; + default_1: + default: + if (mvitals[mndx].mvflags & G_NOCORPSE) + return (struct obj *)0; + else { + corpstatflags |= CORPSTAT_INIT; + /* preserve the unique traits of some creatures */ + obj = mkcorpstat(CORPSE, KEEPTRAITS(mtmp) ? mtmp : 0, + mdat, x, y, corpstatflags); + if (burythem) { boolean dealloc; (void) bury_an_obj(obj, &dealloc); - newsym(x, y); + newsym(x, y); return (dealloc ? NULL : obj); - } - } - break; - } - /* All special cases should precede the G_NOCORPSE check */ + } + } + break; + } + /* All special cases should precede the G_NOCORPSE check */ - /* if polymorph or undead turning has killed this monster, - prevent the same attack beam from hitting its corpse */ - if (context.bypasses) bypass_obj(obj); + /* if polymorph or undead turning has killed this monster, + prevent the same attack beam from hitting its corpse */ + if (context.bypasses) bypass_obj(obj); - if (has_mname(mtmp)) - obj = oname(obj, MNAME(mtmp)); + if (has_mname(mtmp)) + obj = oname(obj, MNAME(mtmp)); - /* Avoid "It was hidden under a green mold corpse!" - * during Blind combat. An unseen monster referred to as "it" - * could be killed and leave a corpse. If a hider then hid - * underneath it, you could be told the corpse type of a - * monster that you never knew was there without this. - * The code in hitmu() substitutes the word "something" - * if the corpses obj->dknown is 0. - */ - if (Blind && !sensemon(mtmp)) obj->dknown = 0; + /* Avoid "It was hidden under a green mold corpse!" + * during Blind combat. An unseen monster referred to as "it" + * could be killed and leave a corpse. If a hider then hid + * underneath it, you could be told the corpse type of a + * monster that you never knew was there without this. + * The code in hitmu() substitutes the word "something" + * if the corpses obj->dknown is 0. + */ + if (Blind && !sensemon(mtmp)) obj->dknown = 0; - stackobj(obj); - newsym(x, y); - return obj; + stackobj(obj); + newsym(x, y); + return obj; } /* check mtmp and water/lava for compatibility, 0 (survived), 1 (died) */ @@ -318,101 +337,101 @@ register struct monst *mtmp; boolean inpool, inlava, infountain; inpool = is_pool(mtmp->mx,mtmp->my) && - !is_flyer(mtmp->data) && !is_floater(mtmp->data); + !is_flyer(mtmp->data) && !is_floater(mtmp->data); inlava = is_lava(mtmp->mx,mtmp->my) && - !is_flyer(mtmp->data) && !is_floater(mtmp->data); + !is_flyer(mtmp->data) && !is_floater(mtmp->data); infountain = IS_FOUNTAIN(levl[mtmp->mx][mtmp->my].typ); - /* Flying and levitation keeps our steed out of the liquid */ - /* (but not water-walking or swimming) */ - if (mtmp == u.usteed && (Flying || Levitation)) - return (0); + /* Flying and levitation keeps our steed out of the liquid */ + /* (but not water-walking or swimming) */ + if (mtmp == u.usteed && (Flying || Levitation)) + return (0); /* Gremlin multiplying won't go on forever since the hit points * keep going down, and when it gets to 1 hit point the clone * function will fail. */ if (mtmp->data == &mons[PM_GREMLIN] && (inpool || infountain) && rn2(3)) { - if (split_mon(mtmp, (struct monst *)0)) - dryup(mtmp->mx, mtmp->my, FALSE); - if (inpool) water_damage_chain(mtmp->minvent, FALSE); - return (0); + if (split_mon(mtmp, (struct monst *)0)) + dryup(mtmp->mx, mtmp->my, FALSE); + if (inpool) water_damage_chain(mtmp->minvent, FALSE); + return (0); } else if (mtmp->data == &mons[PM_IRON_GOLEM] && inpool && !rn2(5)) { - int dam = d(2,6); - if (cansee(mtmp->mx,mtmp->my)) - pline("%s rusts.", Monnam(mtmp)); - mtmp->mhp -= dam; - if (mtmp->mhpmax > dam) mtmp->mhpmax -= dam; - if (mtmp->mhp < 1) { - mondead(mtmp); - if (mtmp->mhp < 1) return (1); - } - water_damage_chain(mtmp->minvent, FALSE); - return (0); + int dam = d(2,6); + if (cansee(mtmp->mx,mtmp->my)) + pline("%s rusts.", Monnam(mtmp)); + mtmp->mhp -= dam; + if (mtmp->mhpmax > dam) mtmp->mhpmax -= dam; + if (mtmp->mhp < 1) { + mondead(mtmp); + if (mtmp->mhp < 1) return (1); + } + water_damage_chain(mtmp->minvent, FALSE); + return (0); } if (inlava) { - /* - * Lava effects much as water effects. Lava likers are able to - * protect their stuff. Fire resistant monsters can only protect - * themselves --ALI - */ - if (!is_clinger(mtmp->data) && !likes_lava(mtmp->data)) { - if (!resists_fire(mtmp)) { - if (cansee(mtmp->mx,mtmp->my)) - pline("%s %s.", Monnam(mtmp), - mtmp->data == &mons[PM_WATER_ELEMENTAL] ? - "boils away" : "burns to a crisp"); - mondead(mtmp); - } - else { - if (--mtmp->mhp < 1) { - if (cansee(mtmp->mx,mtmp->my)) - pline("%s surrenders to the fire.", Monnam(mtmp)); - mondead(mtmp); - } - else if (cansee(mtmp->mx,mtmp->my)) - pline("%s burns slightly.", Monnam(mtmp)); - } - if (mtmp->mhp > 0) { + /* + * Lava effects much as water effects. Lava likers are able to + * protect their stuff. Fire resistant monsters can only protect + * themselves --ALI + */ + if (!is_clinger(mtmp->data) && !likes_lava(mtmp->data)) { + if (!resists_fire(mtmp)) { + if (cansee(mtmp->mx,mtmp->my)) + pline("%s %s.", Monnam(mtmp), + mtmp->data == &mons[PM_WATER_ELEMENTAL] ? + "boils away" : "burns to a crisp"); + mondead(mtmp); + } + else { + if (--mtmp->mhp < 1) { + if (cansee(mtmp->mx,mtmp->my)) + pline("%s surrenders to the fire.", Monnam(mtmp)); + mondead(mtmp); + } + else if (cansee(mtmp->mx,mtmp->my)) + pline("%s burns slightly.", Monnam(mtmp)); + } + if (mtmp->mhp > 0) { (void) fire_damage_chain(mtmp->minvent, FALSE, FALSE, mtmp->mx, mtmp->my); - (void) rloc(mtmp, FALSE); - return 0; - } - return (1); - } + (void) rloc(mtmp, FALSE); + return 0; + } + return (1); + } } else if (inpool) { - /* Most monsters drown in pools. flooreffects() will take care of - * water damage to dead monsters' inventory, but survivors need to - * be handled here. Swimmers are able to protect their stuff... - */ - if (!is_clinger(mtmp->data) - && !is_swimmer(mtmp->data) && !amphibious(mtmp->data)) { - if (cansee(mtmp->mx,mtmp->my)) { - pline("%s drowns.", Monnam(mtmp)); - } - if (u.ustuck && u.uswallow && u.ustuck == mtmp) { - /* This can happen after a purple worm plucks you off a - flying steed while you are over water. */ - pline("%s sinks as water rushes in and flushes you out.", - Monnam(mtmp)); - } - mondead(mtmp); - if (mtmp->mhp > 0) { - water_damage_chain(mtmp->minvent, FALSE); - (void) rloc(mtmp, FALSE); - return 0; - } - return (1); - } + /* Most monsters drown in pools. flooreffects() will take care of + * water damage to dead monsters' inventory, but survivors need to + * be handled here. Swimmers are able to protect their stuff... + */ + if (!is_clinger(mtmp->data) + && !is_swimmer(mtmp->data) && !amphibious(mtmp->data)) { + if (cansee(mtmp->mx,mtmp->my)) { + pline("%s drowns.", Monnam(mtmp)); + } + if (u.ustuck && u.uswallow && u.ustuck == mtmp) { + /* This can happen after a purple worm plucks you off a + flying steed while you are over water. */ + pline("%s sinks as water rushes in and flushes you out.", + Monnam(mtmp)); + } + mondead(mtmp); + if (mtmp->mhp > 0) { + water_damage_chain(mtmp->minvent, FALSE); + (void) rloc(mtmp, FALSE); + return 0; + } + return (1); + } } else { - /* but eels have a difficult time outside */ - if (mtmp->data->mlet == S_EEL && !Is_waterlevel(&u.uz)) { - /* as mhp gets lower, the rate of further loss slows down */ - if (mtmp->mhp > 1 && rn2(mtmp->mhp) > rn2(8)) mtmp->mhp--; - monflee(mtmp, 2, FALSE, FALSE); - } + /* but eels have a difficult time outside */ + if (mtmp->data->mlet == S_EEL && !Is_waterlevel(&u.uz)) { + /* as mhp gets lower, the rate of further loss slows down */ + if (mtmp->mhp > 1 && rn2(mtmp->mhp) > rn2(8)) mtmp->mhp--; + monflee(mtmp, 2, FALSE, FALSE); + } } return (0); } @@ -429,22 +448,22 @@ struct monst *mon; * both adjustments have negligible effect on higher speeds. */ if (mon->mspeed == MSLOW) - mmove = (2 * mmove + 1) / 3; + mmove = (2 * mmove + 1) / 3; else if (mon->mspeed == MFAST) - mmove = (4 * mmove + 2) / 3; + mmove = (4 * mmove + 2) / 3; if (mon == u.usteed) { - if (u.ugallop && context.mv) { - /* average movement is 1.50 times normal */ - mmove = ((rn2(2) ? 4 : 5) * mmove) / 3; - } + if (u.ugallop && context.mv) { + /* average movement is 1.50 times normal */ + mmove = ((rn2(2) ? 4 : 5) * mmove) / 3; + } } else if (mmove) { - /* vary movement points allocated to slightly reduce predictability; - random increment (avg +2) exceeds random decrement (avg +1) by - a small amount; normal speed monsters will occasionally get an - extra move and slow ones won't be quite as slow */ - mmove += rn2(5) - rn2(3); /* + 0..4 - 0..2, average net +1 */ - if (mmove < 1) mmove = 1; + /* vary movement points allocated to slightly reduce predictability; + random increment (avg +2) exceeds random decrement (avg +1) by + a small amount; normal speed monsters will occasionally get an + extra move and slow ones won't be quite as slow */ + mmove += rn2(5) - rn2(3); /* + 0..4 - 0..2, average net +1 */ + if (mmove < 1) mmove = 1; } return mmove; @@ -459,36 +478,36 @@ mcalcdistress() struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; + if (DEADMONSTER(mtmp)) continue; - /* must check non-moving monsters once/turn in case - * they managed to end up in liquid */ - if (mtmp->data->mmove == 0) { - if (vision_full_recalc) vision_recalc(0); - if (minliquid(mtmp)) continue; - } + /* must check non-moving monsters once/turn in case + * they managed to end up in liquid */ + if (mtmp->data->mmove == 0) { + if (vision_full_recalc) vision_recalc(0); + if (minliquid(mtmp)) continue; + } - /* regenerate hit points */ - mon_regen(mtmp, FALSE); + /* regenerate hit points */ + mon_regen(mtmp, FALSE); - /* possibly polymorph shapechangers and lycanthropes */ - if (mtmp->cham >= LOW_PM) { - if (is_vampshifter(mtmp) || mtmp->data->mlet == S_VAMPIRE) - decide_to_shapeshift(mtmp,0); - else if (!rn2(6)) - (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE); - } - were_change(mtmp); + /* possibly polymorph shapechangers and lycanthropes */ + if (mtmp->cham >= LOW_PM) { + if (is_vampshifter(mtmp) || mtmp->data->mlet == S_VAMPIRE) + decide_to_shapeshift(mtmp,0); + else if (!rn2(6)) + (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE); + } + were_change(mtmp); - /* gradually time out temporary problems */ - if (mtmp->mblinded && !--mtmp->mblinded) - mtmp->mcansee = 1; - if (mtmp->mfrozen && !--mtmp->mfrozen) - mtmp->mcanmove = 1; - if (mtmp->mfleetim && !--mtmp->mfleetim) - mtmp->mflee = 0; + /* gradually time out temporary problems */ + if (mtmp->mblinded && !--mtmp->mblinded) + mtmp->mcansee = 1; + if (mtmp->mfrozen && !--mtmp->mfrozen) + mtmp->mcanmove = 1; + if (mtmp->mfleetim && !--mtmp->mfleetim) + mtmp->mflee = 0; - /* FIXME: mtmp->mlstmv ought to be updated here */ + /* FIXME: mtmp->mlstmv ought to be updated here */ } } @@ -519,81 +538,81 @@ movemon() for(mtmp = fmon; mtmp; mtmp = nmtmp) { #ifdef SAFERHANGUP - if (program_state.done_hup) { - somebody_can_move = FALSE; - break; - } + if (program_state.done_hup) { + somebody_can_move = FALSE; + break; + } #endif - nmtmp = mtmp->nmon; - /* one dead monster needs to perform a move after death: - vault guard whose temporary corridor is still on the map */ - if (mtmp->isgd && !mtmp->mx && mtmp->mhp <= 0) (void)gd_move(mtmp); - if (DEADMONSTER(mtmp)) continue; + nmtmp = mtmp->nmon; + /* one dead monster needs to perform a move after death: + vault guard whose temporary corridor is still on the map */ + if (mtmp->isgd && !mtmp->mx && mtmp->mhp <= 0) (void)gd_move(mtmp); + if (DEADMONSTER(mtmp)) continue; - /* Find a monster that we have not treated yet. */ - if(mtmp->movement < NORMAL_SPEED) - continue; + /* Find a monster that we have not treated yet. */ + if(mtmp->movement < NORMAL_SPEED) + continue; - mtmp->movement -= NORMAL_SPEED; - if (mtmp->movement >= NORMAL_SPEED) - somebody_can_move = TRUE; + mtmp->movement -= NORMAL_SPEED; + if (mtmp->movement >= NORMAL_SPEED) + somebody_can_move = TRUE; - if (vision_full_recalc) vision_recalc(0); /* vision! */ + if (vision_full_recalc) vision_recalc(0); /* vision! */ - if (minliquid(mtmp)) continue; + if (minliquid(mtmp)) continue; - if (is_hider(mtmp->data)) { - /* unwatched mimics and piercers may hide again [MRS] */ - if(restrap(mtmp)) continue; - if(mtmp->m_ap_type == M_AP_FURNITURE || - mtmp->m_ap_type == M_AP_OBJECT) - continue; - if(mtmp->mundetected) continue; - } else if (mtmp->data->mlet == S_EEL && !mtmp->mundetected && - (mtmp->mflee || distu(mtmp->mx, mtmp->my) > 2) && - !canseemon(mtmp) && !rn2(4)) { - /* some eels end up stuck in isolated pools, where they - can't--or at least won't--move, so they never reach - their post-move chance to re-hide */ - if (hideunder(mtmp)) continue; - } + if (is_hider(mtmp->data)) { + /* unwatched mimics and piercers may hide again [MRS] */ + if(restrap(mtmp)) continue; + if(mtmp->m_ap_type == M_AP_FURNITURE || + mtmp->m_ap_type == M_AP_OBJECT) + continue; + if(mtmp->mundetected) continue; + } else if (mtmp->data->mlet == S_EEL && !mtmp->mundetected && + (mtmp->mflee || distu(mtmp->mx, mtmp->my) > 2) && + !canseemon(mtmp) && !rn2(4)) { + /* some eels end up stuck in isolated pools, where they + can't--or at least won't--move, so they never reach + their post-move chance to re-hide */ + if (hideunder(mtmp)) continue; + } - /* continue if the monster died fighting */ - if (Conflict && !mtmp->iswiz && mtmp->mcansee) { - /* Note: - * Conflict does not take effect in the first round. - * Therefore, A monster when stepping into the area will - * get to swing at you. - * - * The call to fightm() must be _last_. The monster might - * have died if it returns 1. - */ - if (couldsee(mtmp->mx,mtmp->my) && - (distu(mtmp->mx,mtmp->my) <= BOLT_LIM*BOLT_LIM) && - fightm(mtmp)) - continue; /* mon might have died */ - } - if(dochugw(mtmp)) /* otherwise just move the monster */ - continue; + /* continue if the monster died fighting */ + if (Conflict && !mtmp->iswiz && mtmp->mcansee) { + /* Note: + * Conflict does not take effect in the first round. + * Therefore, A monster when stepping into the area will + * get to swing at you. + * + * The call to fightm() must be _last_. The monster might + * have died if it returns 1. + */ + if (couldsee(mtmp->mx,mtmp->my) && + (distu(mtmp->mx,mtmp->my) <= BOLT_LIM*BOLT_LIM) && + fightm(mtmp)) + continue; /* mon might have died */ + } + if(dochugw(mtmp)) /* otherwise just move the monster */ + continue; } if (any_light_source()) - vision_full_recalc = 1; /* in case a mon moved with a light source */ + vision_full_recalc = 1; /* in case a mon moved with a light source */ dmonsfree(); /* remove all dead monsters */ /* a monster may have levteleported player -dlc */ if (u.utotype) { - deferred_goto(); - /* changed levels, so these monsters are dormant */ - somebody_can_move = FALSE; + deferred_goto(); + /* changed levels, so these monsters are dormant */ + somebody_can_move = FALSE; } return somebody_can_move; } #define mstoning(obj) (ofood(obj) && \ - (touch_petrifies(&mons[(obj)->corpsenm]) || \ - (obj)->corpsenm == PM_MEDUSA)) + (touch_petrifies(&mons[(obj)->corpsenm]) || \ + (obj)->corpsenm == PM_MEDUSA)) /* * Maybe eat a metallic object (not just gold). @@ -604,312 +623,312 @@ movemon() */ int meatmetal(mtmp) - register struct monst *mtmp; + register struct monst *mtmp; { - register struct obj *otmp; - struct permonst *ptr; - int poly, grow, heal, mstone; + register struct obj *otmp; + struct permonst *ptr; + int poly, grow, heal, mstone; - /* If a pet, eating is handled separately, in dog.c */ - if (mtmp->mtame) return 0; + /* If a pet, eating is handled separately, in dog.c */ + if (mtmp->mtame) return 0; - /* Eats topmost metal object if it is there */ - for (otmp = level.objects[mtmp->mx][mtmp->my]; - otmp; otmp = otmp->nexthere) { + /* Eats topmost metal object if it is there */ + for (otmp = level.objects[mtmp->mx][mtmp->my]; + otmp; otmp = otmp->nexthere) { /* Don't eat indigestible/choking/inappropriate objects */ if ((mtmp->data == &mons[PM_RUST_MONSTER] && !is_rustprone(otmp)) || (otmp->otyp == AMULET_OF_STRANGULATION) || (otmp->otyp == RIN_SLOW_DIGESTION)) - continue; - if (is_metallic(otmp) && !obj_resists(otmp, 5, 95) && - touch_artifact(otmp,mtmp)) { - if (mtmp->data == &mons[PM_RUST_MONSTER] && otmp->oerodeproof) { - if (canseemon(mtmp) && flags.verbose) { - pline("%s eats %s!", - Monnam(mtmp), - distant_name(otmp,doname)); - } - /* The object's rustproofing is gone now */ - otmp->oerodeproof = 0; - mtmp->mstun = 1; - if (canseemon(mtmp) && flags.verbose) { - pline("%s spits %s out in disgust!", - Monnam(mtmp), distant_name(otmp,doname)); - } + continue; + if (is_metallic(otmp) && !obj_resists(otmp, 5, 95) && + touch_artifact(otmp,mtmp)) { + if (mtmp->data == &mons[PM_RUST_MONSTER] && otmp->oerodeproof) { + if (canseemon(mtmp) && flags.verbose) { + pline("%s eats %s!", + Monnam(mtmp), + distant_name(otmp,doname)); + } + /* The object's rustproofing is gone now */ + otmp->oerodeproof = 0; + mtmp->mstun = 1; + if (canseemon(mtmp) && flags.verbose) { + pline("%s spits %s out in disgust!", + Monnam(mtmp), distant_name(otmp,doname)); + } } else { - if (cansee(mtmp->mx,mtmp->my) && flags.verbose) - pline("%s eats %s!", Monnam(mtmp), - distant_name(otmp,doname)); - else if (flags.verbose) - You_hear("a crunching sound."); - mtmp->meating = otmp->owt/2 + 1; - /* Heal up to the object's weight in hp */ - if (mtmp->mhp < mtmp->mhpmax) { - mtmp->mhp += objects[otmp->otyp].oc_weight; - if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; - } - if(otmp == uball) { - unpunish(); - delobj(otmp); - } else if (otmp == uchain) { - unpunish(); /* frees uchain */ - } else { - poly = polyfodder(otmp); - grow = mlevelgain(otmp); - heal = mhealup(otmp); - mstone = mstoning(otmp); - delobj(otmp); - ptr = mtmp->data; - if (poly) { - if (newcham(mtmp, (struct permonst *)0, - FALSE, FALSE)) - ptr = mtmp->data; - } else if (grow) { - ptr = grow_up(mtmp, (struct monst *)0); - } else if (mstone) { - if (poly_when_stoned(ptr)) { - mon_to_stone(mtmp); - ptr = mtmp->data; - } else if (!resists_ston(mtmp)) { - if (canseemon(mtmp)) - pline("%s turns to stone!", Monnam(mtmp)); - monstone(mtmp); - ptr = (struct permonst *)0; - } - } else if (heal) { - mtmp->mhp = mtmp->mhpmax; - } - if (!ptr) return 2; /* it died */ - } - /* Left behind a pile? */ - if (rnd(25) < 3) - (void)mksobj_at(ROCK, mtmp->mx, mtmp->my, TRUE, FALSE); - newsym(mtmp->mx, mtmp->my); - return 1; - } - } - } - return 0; + if (cansee(mtmp->mx,mtmp->my) && flags.verbose) + pline("%s eats %s!", Monnam(mtmp), + distant_name(otmp,doname)); + else if (flags.verbose) + You_hear("a crunching sound."); + mtmp->meating = otmp->owt/2 + 1; + /* Heal up to the object's weight in hp */ + if (mtmp->mhp < mtmp->mhpmax) { + mtmp->mhp += objects[otmp->otyp].oc_weight; + if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; + } + if(otmp == uball) { + unpunish(); + delobj(otmp); + } else if (otmp == uchain) { + unpunish(); /* frees uchain */ + } else { + poly = polyfodder(otmp); + grow = mlevelgain(otmp); + heal = mhealup(otmp); + mstone = mstoning(otmp); + delobj(otmp); + ptr = mtmp->data; + if (poly) { + if (newcham(mtmp, (struct permonst *)0, + FALSE, FALSE)) + ptr = mtmp->data; + } else if (grow) { + ptr = grow_up(mtmp, (struct monst *)0); + } else if (mstone) { + if (poly_when_stoned(ptr)) { + mon_to_stone(mtmp); + ptr = mtmp->data; + } else if (!resists_ston(mtmp)) { + if (canseemon(mtmp)) + pline("%s turns to stone!", Monnam(mtmp)); + monstone(mtmp); + ptr = (struct permonst *)0; + } + } else if (heal) { + mtmp->mhp = mtmp->mhpmax; + } + if (!ptr) return 2; /* it died */ + } + /* Left behind a pile? */ + if (rnd(25) < 3) + (void)mksobj_at(ROCK, mtmp->mx, mtmp->my, TRUE, FALSE); + newsym(mtmp->mx, mtmp->my); + return 1; + } + } + } + return 0; } /* monster eats a pile of objects */ int meatobj(mtmp) /* for gelatinous cubes */ - register struct monst *mtmp; + register struct monst *mtmp; { - register struct obj *otmp, *otmp2; - struct permonst *ptr, *original_ptr = mtmp->data; - int poly, grow, heal, count = 0, ecount = 0; - char buf[BUFSZ]; + register struct obj *otmp, *otmp2; + struct permonst *ptr, *original_ptr = mtmp->data; + int poly, grow, heal, count = 0, ecount = 0; + char buf[BUFSZ]; - buf[0] = '\0'; - /* If a pet, eating is handled separately, in dog.c */ - if (mtmp->mtame) return 0; + buf[0] = '\0'; + /* If a pet, eating is handled separately, in dog.c */ + if (mtmp->mtame) return 0; - /* eat organic objects, including cloth and wood, if present; - engulf others, except huge rocks and metal attached to player - [despite comment at top, doesn't assume that eater is a g.cube] */ - for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { - otmp2 = otmp->nexthere; + /* eat organic objects, including cloth and wood, if present; + engulf others, except huge rocks and metal attached to player + [despite comment at top, doesn't assume that eater is a g.cube] */ + for (otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + otmp2 = otmp->nexthere; - /* touch senstive items */ - if (otmp->otyp == CORPSE && - is_rider(&mons[otmp->corpsenm])) { - /* Rider corpse isn't just inedible; can't engulf it either */ - (void)revive_corpse(otmp); + /* touch senstive items */ + if (otmp->otyp == CORPSE && + is_rider(&mons[otmp->corpsenm])) { + /* Rider corpse isn't just inedible; can't engulf it either */ + (void)revive_corpse(otmp); - /* untouchable (or inaccessible) items */ - } else if ((otmp->otyp == CORPSE && - touch_petrifies(&mons[otmp->corpsenm]) && - !resists_ston(mtmp)) || - /* don't engulf boulders and statues or ball&chain */ - otmp->oclass == ROCK_CLASS || - otmp == uball || otmp == uchain) { - /* do nothing--neither eaten nor engulfed */ - continue; + /* untouchable (or inaccessible) items */ + } else if ((otmp->otyp == CORPSE && + touch_petrifies(&mons[otmp->corpsenm]) && + !resists_ston(mtmp)) || + /* don't engulf boulders and statues or ball&chain */ + otmp->oclass == ROCK_CLASS || + otmp == uball || otmp == uchain) { + /* do nothing--neither eaten nor engulfed */ + continue; - /* inedible items -- engulf these */ - } else if (!is_organic(otmp) || - obj_resists(otmp, 5, 95) || - !touch_artifact(otmp, mtmp) || - /* redundant due to non-organic composition but - included for emphasis */ - (otmp->otyp == AMULET_OF_STRANGULATION || - otmp->otyp == RIN_SLOW_DIGESTION) || - /* cockatrice corpses handled above; this - touch_petrifies() check catches eggs */ - ((otmp->otyp == CORPSE || otmp->otyp == EGG) && - ((touch_petrifies(&mons[otmp->corpsenm]) && - !resists_ston(mtmp)) || - (otmp->corpsenm == PM_GREEN_SLIME && - !slimeproof(mtmp->data))))) { - /* engulf */ - ++ecount; - if (ecount == 1) - Sprintf(buf, "%s engulfs %s.", Monnam(mtmp), - distant_name(otmp,doname)); - else if (ecount == 2) - Sprintf(buf, "%s engulfs several objects.", Monnam(mtmp)); - obj_extract_self(otmp); - (void) mpickobj(mtmp, otmp); /* slurp */ + /* inedible items -- engulf these */ + } else if (!is_organic(otmp) || + obj_resists(otmp, 5, 95) || + !touch_artifact(otmp, mtmp) || + /* redundant due to non-organic composition but + included for emphasis */ + (otmp->otyp == AMULET_OF_STRANGULATION || + otmp->otyp == RIN_SLOW_DIGESTION) || + /* cockatrice corpses handled above; this + touch_petrifies() check catches eggs */ + ((otmp->otyp == CORPSE || otmp->otyp == EGG) && + ((touch_petrifies(&mons[otmp->corpsenm]) && + !resists_ston(mtmp)) || + (otmp->corpsenm == PM_GREEN_SLIME && + !slimeproof(mtmp->data))))) { + /* engulf */ + ++ecount; + if (ecount == 1) + Sprintf(buf, "%s engulfs %s.", Monnam(mtmp), + distant_name(otmp,doname)); + else if (ecount == 2) + Sprintf(buf, "%s engulfs several objects.", Monnam(mtmp)); + obj_extract_self(otmp); + (void) mpickobj(mtmp, otmp); /* slurp */ - /* lastly, edible items; yum! */ - } else { - /* devour */ - ++count; - if (cansee(mtmp->mx,mtmp->my) && flags.verbose) - pline("%s eats %s!", Monnam(mtmp), - distant_name(otmp, doname)); - else if (flags.verbose) - You_hear("a slurping sound."); - /* Heal up to the object's weight in hp */ - if (mtmp->mhp < mtmp->mhpmax) { - mtmp->mhp += objects[otmp->otyp].oc_weight; - if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; - } - if (Has_contents(otmp)) { - register struct obj *otmp3; - /* contents of eaten containers become engulfed; this - is arbitrary, but otherwise g.cubes are too powerful */ - while ((otmp3 = otmp->cobj) != 0) { - obj_extract_self(otmp3); - if (otmp->otyp == ICE_BOX && otmp3->otyp == CORPSE) { - otmp3->age = monstermoves - otmp3->age; - start_corpse_timeout(otmp3); - } - (void) mpickobj(mtmp, otmp3); - } - } - poly = polyfodder(otmp); - grow = mlevelgain(otmp); - heal = mhealup(otmp); - delobj(otmp); /* munch */ - ptr = mtmp->data; - if (poly) { - if (newcham(mtmp, (struct permonst *)0, FALSE, FALSE)) - ptr = mtmp->data; - } else if (grow) { - ptr = grow_up(mtmp, (struct monst *)0); - } else if (heal) { - mtmp->mhp = mtmp->mhpmax; - } - /* in case it polymorphed or died */ - if (ptr != original_ptr) - return !ptr ? 2 : 1; - } + /* lastly, edible items; yum! */ + } else { + /* devour */ + ++count; + if (cansee(mtmp->mx,mtmp->my) && flags.verbose) + pline("%s eats %s!", Monnam(mtmp), + distant_name(otmp, doname)); + else if (flags.verbose) + You_hear("a slurping sound."); + /* Heal up to the object's weight in hp */ + if (mtmp->mhp < mtmp->mhpmax) { + mtmp->mhp += objects[otmp->otyp].oc_weight; + if (mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; + } + if (Has_contents(otmp)) { + register struct obj *otmp3; + /* contents of eaten containers become engulfed; this + is arbitrary, but otherwise g.cubes are too powerful */ + while ((otmp3 = otmp->cobj) != 0) { + obj_extract_self(otmp3); + if (otmp->otyp == ICE_BOX && otmp3->otyp == CORPSE) { + otmp3->age = monstermoves - otmp3->age; + start_corpse_timeout(otmp3); + } + (void) mpickobj(mtmp, otmp3); + } + } + poly = polyfodder(otmp); + grow = mlevelgain(otmp); + heal = mhealup(otmp); + delobj(otmp); /* munch */ + ptr = mtmp->data; + if (poly) { + if (newcham(mtmp, (struct permonst *)0, FALSE, FALSE)) + ptr = mtmp->data; + } else if (grow) { + ptr = grow_up(mtmp, (struct monst *)0); + } else if (heal) { + mtmp->mhp = mtmp->mhpmax; + } + /* in case it polymorphed or died */ + if (ptr != original_ptr) + return !ptr ? 2 : 1; + } - /* Engulf & devour is instant, so don't set meating */ - if (mtmp->minvis) newsym(mtmp->mx, mtmp->my); - } + /* Engulf & devour is instant, so don't set meating */ + if (mtmp->minvis) newsym(mtmp->mx, mtmp->my); + } - if (ecount > 0) { - if (cansee(mtmp->mx, mtmp->my) && flags.verbose && buf[0]) - pline1(buf); - else if (flags.verbose) - You_hear("%s slurping sound%s.", - ecount == 1 ? "a" : "several", - ecount == 1 ? "" : "s"); - } - return ((count > 0) || (ecount > 0)) ? 1 : 0; + if (ecount > 0) { + if (cansee(mtmp->mx, mtmp->my) && flags.verbose && buf[0]) + pline1(buf); + else if (flags.verbose) + You_hear("%s slurping sound%s.", + ecount == 1 ? "a" : "several", + ecount == 1 ? "" : "s"); + } + return ((count > 0) || (ecount > 0)) ? 1 : 0; } void mpickgold(mtmp) - register struct monst *mtmp; + register struct monst *mtmp; { register struct obj *gold; int mat_idx; if ((gold = g_at(mtmp->mx, mtmp->my)) != 0) { - mat_idx = objects[gold->otyp].oc_material; + mat_idx = objects[gold->otyp].oc_material; obj_extract_self(gold); add_to_minv(mtmp, gold); - if (cansee(mtmp->mx, mtmp->my) ) { - if (flags.verbose && !mtmp->isgd) - pline("%s picks up some %s.", Monnam(mtmp), - mat_idx == GOLD ? "gold" : "money"); - newsym(mtmp->mx, mtmp->my); - } + if (cansee(mtmp->mx, mtmp->my) ) { + if (flags.verbose && !mtmp->isgd) + pline("%s picks up some %s.", Monnam(mtmp), + mat_idx == GOLD ? "gold" : "money"); + newsym(mtmp->mx, mtmp->my); + } } } boolean mpickstuff(mtmp, str) - register struct monst *mtmp; - register const char *str; + register struct monst *mtmp; + register const char *str; { - register struct obj *otmp, *otmp2; + register struct obj *otmp, *otmp2; /* prevent shopkeepers from leaving the door of their shop */ - if(mtmp->isshk && inhishop(mtmp)) return FALSE; + if(mtmp->isshk && inhishop(mtmp)) return FALSE; - for(otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { - otmp2 = otmp->nexthere; + for(otmp = level.objects[mtmp->mx][mtmp->my]; otmp; otmp = otmp2) { + otmp2 = otmp->nexthere; /* Nymphs take everything. Most monsters don't pick up corpses. */ - if (!str ? searches_for_item(mtmp,otmp) : - !!(index(str, otmp->oclass))) { - if (otmp->otyp == CORPSE && mtmp->data->mlet != S_NYMPH && - /* let a handful of corpse types thru to can_carry() */ - !touch_petrifies(&mons[otmp->corpsenm]) && - otmp->corpsenm != PM_LIZARD && - !acidic(&mons[otmp->corpsenm])) continue; - if (!touch_artifact(otmp,mtmp)) continue; - if (!can_carry(mtmp,otmp)) continue; - if (is_pool(mtmp->mx,mtmp->my)) continue; - if (cansee(mtmp->mx,mtmp->my) && flags.verbose) - pline("%s picks up %s.", Monnam(mtmp), - (distu(mtmp->mx, mtmp->my) <= 5) ? - doname(otmp) : distant_name(otmp, doname)); - obj_extract_self(otmp); /* remove from floor */ - (void) mpickobj(mtmp, otmp); /* may merge and free otmp */ - m_dowear(mtmp, FALSE); - newsym(mtmp->mx, mtmp->my); - return TRUE; /* pick only one object */ - } - } - return FALSE; + if (!str ? searches_for_item(mtmp,otmp) : + !!(index(str, otmp->oclass))) { + if (otmp->otyp == CORPSE && mtmp->data->mlet != S_NYMPH && + /* let a handful of corpse types thru to can_carry() */ + !touch_petrifies(&mons[otmp->corpsenm]) && + otmp->corpsenm != PM_LIZARD && + !acidic(&mons[otmp->corpsenm])) continue; + if (!touch_artifact(otmp,mtmp)) continue; + if (!can_carry(mtmp,otmp)) continue; + if (is_pool(mtmp->mx,mtmp->my)) continue; + if (cansee(mtmp->mx,mtmp->my) && flags.verbose) + pline("%s picks up %s.", Monnam(mtmp), + (distu(mtmp->mx, mtmp->my) <= 5) ? + doname(otmp) : distant_name(otmp, doname)); + obj_extract_self(otmp); /* remove from floor */ + (void) mpickobj(mtmp, otmp); /* may merge and free otmp */ + m_dowear(mtmp, FALSE); + newsym(mtmp->mx, mtmp->my); + return TRUE; /* pick only one object */ + } + } + return FALSE; } int curr_mon_load(mtmp) register struct monst *mtmp; { - register int curload = 0; - register struct obj *obj; + register int curload = 0; + register struct obj *obj; - for(obj = mtmp->minvent; obj; obj = obj->nobj) { - if(obj->otyp != BOULDER || !throws_rocks(mtmp->data)) - curload += obj->owt; - } + for(obj = mtmp->minvent; obj; obj = obj->nobj) { + if(obj->otyp != BOULDER || !throws_rocks(mtmp->data)) + curload += obj->owt; + } - return curload; + return curload; } int max_mon_load(mtmp) register struct monst *mtmp; { - register long maxload; - /* Base monster carrying capacity is equal to human maximum - * carrying capacity, or half human maximum if not strong. - * (for a polymorphed player, the value used would be the - * non-polymorphed carrying capacity instead of max/half max). - * This is then modified by the ratio between the monster weights - * and human weights. Corpseless monsters are given a capacity - * proportional to their size instead of weight. - */ - if (!mtmp->data->cwt) - maxload = (MAX_CARR_CAP * (long)mtmp->data->msize) / MZ_HUMAN; - else if (!strongmonst(mtmp->data) - || (strongmonst(mtmp->data) && (mtmp->data->cwt > WT_HUMAN))) - maxload = (MAX_CARR_CAP * (long)mtmp->data->cwt) / WT_HUMAN; - else maxload = MAX_CARR_CAP; /*strong monsters w/cwt <= WT_HUMAN*/ + register long maxload; + /* Base monster carrying capacity is equal to human maximum + * carrying capacity, or half human maximum if not strong. + * (for a polymorphed player, the value used would be the + * non-polymorphed carrying capacity instead of max/half max). + * This is then modified by the ratio between the monster weights + * and human weights. Corpseless monsters are given a capacity + * proportional to their size instead of weight. + */ + if (!mtmp->data->cwt) + maxload = (MAX_CARR_CAP * (long)mtmp->data->msize) / MZ_HUMAN; + else if (!strongmonst(mtmp->data) + || (strongmonst(mtmp->data) && (mtmp->data->cwt > WT_HUMAN))) + maxload = (MAX_CARR_CAP * (long)mtmp->data->cwt) / WT_HUMAN; + else maxload = MAX_CARR_CAP; /*strong monsters w/cwt <= WT_HUMAN*/ - if (!strongmonst(mtmp->data)) maxload /= 2; + if (!strongmonst(mtmp->data)) maxload /= 2; - if (maxload < 1) maxload = 1; + if (maxload < 1) maxload = 1; - return (int) maxload; + return (int) maxload; } /* for restricting monsters' object-pickup */ @@ -918,256 +937,256 @@ can_carry(mtmp,otmp) struct monst *mtmp; struct obj *otmp; { - int otyp = otmp->otyp, newload = otmp->owt; - struct permonst *mdat = mtmp->data; + int otyp = otmp->otyp, newload = otmp->owt; + struct permonst *mdat = mtmp->data; - if (notake(mdat)) return FALSE; /* can't carry anything */ + if (notake(mdat)) return FALSE; /* can't carry anything */ - if (otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]) && - !(mtmp->misc_worn_check & W_ARMG) && !resists_ston(mtmp)) - return FALSE; - if (otyp == CORPSE && is_rider(&mons[otmp->corpsenm])) - return FALSE; - if (objects[otyp].oc_material == SILVER && mon_hates_silver(mtmp) && - (otyp != BELL_OF_OPENING || !is_covetous(mdat))) - return FALSE; + if (otyp == CORPSE && touch_petrifies(&mons[otmp->corpsenm]) && + !(mtmp->misc_worn_check & W_ARMG) && !resists_ston(mtmp)) + return FALSE; + if (otyp == CORPSE && is_rider(&mons[otmp->corpsenm])) + return FALSE; + if (objects[otyp].oc_material == SILVER && mon_hates_silver(mtmp) && + (otyp != BELL_OF_OPENING || !is_covetous(mdat))) + return FALSE; - /* Steeds don't pick up stuff (to avoid shop abuse) */ - if (mtmp == u.usteed) return (FALSE); - if (mtmp->isshk) return(TRUE); /* no limit */ - if (mtmp->mpeaceful && !mtmp->mtame) return(FALSE); - /* otherwise players might find themselves obligated to violate - * their alignment if the monster takes something they need - */ + /* Steeds don't pick up stuff (to avoid shop abuse) */ + if (mtmp == u.usteed) return (FALSE); + if (mtmp->isshk) return(TRUE); /* no limit */ + if (mtmp->mpeaceful && !mtmp->mtame) return(FALSE); + /* otherwise players might find themselves obligated to violate + * their alignment if the monster takes something they need + */ - /* special--boulder throwers carry unlimited amounts of boulders */ - if (throws_rocks(mdat) && otyp == BOULDER) - return(TRUE); + /* special--boulder throwers carry unlimited amounts of boulders */ + if (throws_rocks(mdat) && otyp == BOULDER) + return(TRUE); - /* nymphs deal in stolen merchandise, but not boulders or statues */ - if (mdat->mlet == S_NYMPH) - return (boolean)(otmp->oclass != ROCK_CLASS); + /* nymphs deal in stolen merchandise, but not boulders or statues */ + if (mdat->mlet == S_NYMPH) + return (boolean)(otmp->oclass != ROCK_CLASS); - if (curr_mon_load(mtmp) + newload > max_mon_load(mtmp)) return FALSE; + if (curr_mon_load(mtmp) + newload > max_mon_load(mtmp)) return FALSE; - return(TRUE); + return(TRUE); } /* return number of acceptable neighbour positions */ int mfndpos(mon, poss, info, flag) - register struct monst *mon; - coord *poss; /* coord poss[9] */ - long *info; /* long info[9] */ - long flag; + register struct monst *mon; + coord *poss; /* coord poss[9] */ + long *info; /* long info[9] */ + long flag; { - struct permonst *mdat = mon->data; - register xchar x,y,nx,ny; - register int cnt = 0; - register uchar ntyp; - uchar nowtyp; - boolean wantpool,poolok,lavaok,nodiag; - boolean rockok = FALSE, treeok = FALSE, thrudoor; - int maxx, maxy; + struct permonst *mdat = mon->data; + register xchar x,y,nx,ny; + register int cnt = 0; + register uchar ntyp; + uchar nowtyp; + boolean wantpool,poolok,lavaok,nodiag; + boolean rockok = FALSE, treeok = FALSE, thrudoor; + int maxx, maxy; - x = mon->mx; - y = mon->my; - nowtyp = levl[x][y].typ; + x = mon->mx; + y = mon->my; + nowtyp = levl[x][y].typ; - nodiag = NODIAG(mdat - mons); - wantpool = mdat->mlet == S_EEL; - poolok = is_flyer(mdat) || is_clinger(mdat) || - (is_swimmer(mdat) && !wantpool); - lavaok = is_flyer(mdat) || is_clinger(mdat) || likes_lava(mdat); - thrudoor = ((flag & (ALLOW_WALL|BUSTDOOR)) != 0L); - if (flag & ALLOW_DIG) { - struct obj *mw_tmp; + nodiag = NODIAG(mdat - mons); + wantpool = mdat->mlet == S_EEL; + poolok = is_flyer(mdat) || is_clinger(mdat) || + (is_swimmer(mdat) && !wantpool); + lavaok = is_flyer(mdat) || is_clinger(mdat) || likes_lava(mdat); + thrudoor = ((flag & (ALLOW_WALL|BUSTDOOR)) != 0L); + if (flag & ALLOW_DIG) { + struct obj *mw_tmp; - /* need to be specific about what can currently be dug */ - if (!needspick(mdat)) { - rockok = treeok = TRUE; - } else if ((mw_tmp = MON_WEP(mon)) && mw_tmp->cursed && - mon->weapon_check == NO_WEAPON_WANTED) { - rockok = is_pick(mw_tmp); - treeok = is_axe(mw_tmp); - } else { - rockok = (m_carrying(mon, PICK_AXE) || - (m_carrying(mon, DWARVISH_MATTOCK) && - !which_armor(mon, W_ARMS))); - treeok = (m_carrying(mon, AXE) || - (m_carrying(mon, BATTLE_AXE) && - !which_armor(mon, W_ARMS))); - } - thrudoor |= rockok || treeok; - } + /* need to be specific about what can currently be dug */ + if (!needspick(mdat)) { + rockok = treeok = TRUE; + } else if ((mw_tmp = MON_WEP(mon)) && mw_tmp->cursed && + mon->weapon_check == NO_WEAPON_WANTED) { + rockok = is_pick(mw_tmp); + treeok = is_axe(mw_tmp); + } else { + rockok = (m_carrying(mon, PICK_AXE) || + (m_carrying(mon, DWARVISH_MATTOCK) && + !which_armor(mon, W_ARMS))); + treeok = (m_carrying(mon, AXE) || + (m_carrying(mon, BATTLE_AXE) && + !which_armor(mon, W_ARMS))); + } + thrudoor |= rockok || treeok; + } nexttry: /* eels prefer the water, but if there is no water nearby, - they will crawl over land */ - if(mon->mconf) { - flag |= ALLOW_ALL; - flag &= ~NOTONL; - } - if(!mon->mcansee) - flag |= ALLOW_SSM; - maxx = min(x+1,COLNO-1); - maxy = min(y+1,ROWNO-1); - for(nx = max(1,x-1); nx <= maxx; nx++) - for(ny = max(0,y-1); ny <= maxy; ny++) { - if(nx == x && ny == y) continue; - if(IS_ROCK(ntyp = levl[nx][ny].typ) && - !((flag & ALLOW_WALL) && may_passwall(nx,ny)) && - !((IS_TREE(ntyp) ? treeok : rockok) && may_dig(nx,ny))) continue; - /* KMH -- Added iron bars */ - if (ntyp == IRONBARS && !(flag & ALLOW_BARS)) continue; - if (IS_DOOR(ntyp) && !(amorphous(mdat) || can_fog(mon)) && - (((levl[nx][ny].doormask & D_CLOSED) && - !(flag & OPENDOOR)) || - ((levl[nx][ny].doormask & D_LOCKED) && - !(flag & UNLOCKDOOR))) && - !thrudoor) continue; - /* first diagonal checks (tight squeezes handled below) */ - if (nx != x && ny != y && (nodiag || - (IS_DOOR(nowtyp) && (levl[x][y].doormask & ~D_BROKEN)) || - (IS_DOOR(ntyp) && (levl[nx][ny].doormask & ~D_BROKEN)) || - ((IS_DOOR(nowtyp) || IS_DOOR(ntyp)) && Is_rogue_level(&u.uz)) || - /* mustn't pass between adjacent long worm segments, - but can attack that way */ - (m_at(x, ny) && m_at(nx, y) && worm_cross(x, y, nx, ny) && - !m_at(nx, ny) && (nx != u.ux || ny != u.uy)))) - continue; - if((is_pool(nx,ny) == wantpool || poolok) && - (lavaok || !is_lava(nx,ny))) { - int dispx, dispy; - boolean monseeu = (mon->mcansee && (!Invis || perceives(mdat))); - boolean checkobj = OBJ_AT(nx,ny); + they will crawl over land */ + if(mon->mconf) { + flag |= ALLOW_ALL; + flag &= ~NOTONL; + } + if(!mon->mcansee) + flag |= ALLOW_SSM; + maxx = min(x+1,COLNO-1); + maxy = min(y+1,ROWNO-1); + for(nx = max(1,x-1); nx <= maxx; nx++) + for(ny = max(0,y-1); ny <= maxy; ny++) { + if(nx == x && ny == y) continue; + if(IS_ROCK(ntyp = levl[nx][ny].typ) && + !((flag & ALLOW_WALL) && may_passwall(nx,ny)) && + !((IS_TREE(ntyp) ? treeok : rockok) && may_dig(nx,ny))) continue; + /* KMH -- Added iron bars */ + if (ntyp == IRONBARS && !(flag & ALLOW_BARS)) continue; + if (IS_DOOR(ntyp) && !(amorphous(mdat) || can_fog(mon)) && + (((levl[nx][ny].doormask & D_CLOSED) && + !(flag & OPENDOOR)) || + ((levl[nx][ny].doormask & D_LOCKED) && + !(flag & UNLOCKDOOR))) && + !thrudoor) continue; + /* first diagonal checks (tight squeezes handled below) */ + if (nx != x && ny != y && (nodiag || + (IS_DOOR(nowtyp) && (levl[x][y].doormask & ~D_BROKEN)) || + (IS_DOOR(ntyp) && (levl[nx][ny].doormask & ~D_BROKEN)) || + ((IS_DOOR(nowtyp) || IS_DOOR(ntyp)) && Is_rogue_level(&u.uz)) || + /* mustn't pass between adjacent long worm segments, + but can attack that way */ + (m_at(x, ny) && m_at(nx, y) && worm_cross(x, y, nx, ny) && + !m_at(nx, ny) && (nx != u.ux || ny != u.uy)))) + continue; + if((is_pool(nx,ny) == wantpool || poolok) && + (lavaok || !is_lava(nx,ny))) { + int dispx, dispy; + boolean monseeu = (mon->mcansee && (!Invis || perceives(mdat))); + boolean checkobj = OBJ_AT(nx,ny); - /* Displacement also displaces the Elbereth/scare monster, - * as long as you are visible. - */ - if(Displaced && monseeu && (mon->mux==nx) && (mon->muy==ny)) { - dispx = u.ux; - dispy = u.uy; - } else { - dispx = nx; - dispy = ny; - } + /* Displacement also displaces the Elbereth/scare monster, + * as long as you are visible. + */ + if(Displaced && monseeu && (mon->mux==nx) && (mon->muy==ny)) { + dispx = u.ux; + dispy = u.uy; + } else { + dispx = nx; + dispy = ny; + } - info[cnt] = 0; - if (onscary(dispx, dispy, mon)) { - if(!(flag & ALLOW_SSM)) continue; - info[cnt] |= ALLOW_SSM; - } - if((nx == u.ux && ny == u.uy) || - (nx == mon->mux && ny == mon->muy)) { - if (nx == u.ux && ny == u.uy) { - /* If it's right next to you, it found you, - * displaced or no. We must set mux and muy - * right now, so when we return we can tell - * that the ALLOW_U means to attack _you_ and - * not the image. - */ - mon->mux = u.ux; - mon->muy = u.uy; - } - if(!(flag & ALLOW_U)) continue; - info[cnt] |= ALLOW_U; - } else { - if(MON_AT(nx, ny)) { - struct monst *mtmp2 = m_at(nx, ny); - long mmflag = flag | mm_aggression(mon, mtmp2); + info[cnt] = 0; + if (onscary(dispx, dispy, mon)) { + if(!(flag & ALLOW_SSM)) continue; + info[cnt] |= ALLOW_SSM; + } + if((nx == u.ux && ny == u.uy) || + (nx == mon->mux && ny == mon->muy)) { + if (nx == u.ux && ny == u.uy) { + /* If it's right next to you, it found you, + * displaced or no. We must set mux and muy + * right now, so when we return we can tell + * that the ALLOW_U means to attack _you_ and + * not the image. + */ + mon->mux = u.ux; + mon->muy = u.uy; + } + if(!(flag & ALLOW_U)) continue; + info[cnt] |= ALLOW_U; + } else { + if(MON_AT(nx, ny)) { + struct monst *mtmp2 = m_at(nx, ny); + long mmflag = flag | mm_aggression(mon, mtmp2); - if (mmflag & ALLOW_M) { - info[cnt] |= ALLOW_M; - if (mtmp2->mtame) { - if (!(mmflag & ALLOW_TM)) continue; - info[cnt] |= ALLOW_TM; - } - } else { - mmflag = flag | mm_displacement(mon, mtmp2); - if (!(mmflag & ALLOW_MDISP)) continue; - info[cnt] |= ALLOW_MDISP; - } - } - /* Note: ALLOW_SANCT only prevents movement, not */ - /* attack, into a temple. */ - if(level.flags.has_temple && - *in_rooms(nx, ny, TEMPLE) && - !*in_rooms(x, y, TEMPLE) && - in_your_sanctuary((struct monst *)0, nx, ny)) { - if(!(flag & ALLOW_SANCT)) continue; - info[cnt] |= ALLOW_SANCT; - } - } - if(checkobj && sobj_at(CLOVE_OF_GARLIC, nx, ny)) { - if(flag & NOGARLIC) continue; - info[cnt] |= NOGARLIC; - } - if(checkobj && sobj_at(BOULDER, nx, ny)) { - if(!(flag & ALLOW_ROCK)) continue; - info[cnt] |= ALLOW_ROCK; - } - if (monseeu && onlineu(nx,ny)) { - if(flag & NOTONL) continue; - info[cnt] |= NOTONL; - } - /* check for diagonal tight squeeze */ - if (nx != x && ny != y && bad_rock(mdat, x, ny) && - bad_rock(mdat, nx, y) && cant_squeeze_thru(mon)) - continue; - /* The monster avoids a particular type of trap if it's familiar - * with the trap type. Pets get ALLOW_TRAPS and checking is - * done in dogmove.c. In either case, "harmless" traps are - * neither avoided nor marked in info[]. - */ - { register struct trap *ttmp = t_at(nx, ny); - if(ttmp) { - if(ttmp->ttyp >= TRAPNUM || ttmp->ttyp == 0) { + if (mmflag & ALLOW_M) { + info[cnt] |= ALLOW_M; + if (mtmp2->mtame) { + if (!(mmflag & ALLOW_TM)) continue; + info[cnt] |= ALLOW_TM; + } + } else { + mmflag = flag | mm_displacement(mon, mtmp2); + if (!(mmflag & ALLOW_MDISP)) continue; + info[cnt] |= ALLOW_MDISP; + } + } + /* Note: ALLOW_SANCT only prevents movement, not */ + /* attack, into a temple. */ + if(level.flags.has_temple && + *in_rooms(nx, ny, TEMPLE) && + !*in_rooms(x, y, TEMPLE) && + in_your_sanctuary((struct monst *)0, nx, ny)) { + if(!(flag & ALLOW_SANCT)) continue; + info[cnt] |= ALLOW_SANCT; + } + } + if(checkobj && sobj_at(CLOVE_OF_GARLIC, nx, ny)) { + if(flag & NOGARLIC) continue; + info[cnt] |= NOGARLIC; + } + if(checkobj && sobj_at(BOULDER, nx, ny)) { + if(!(flag & ALLOW_ROCK)) continue; + info[cnt] |= ALLOW_ROCK; + } + if (monseeu && onlineu(nx,ny)) { + if(flag & NOTONL) continue; + info[cnt] |= NOTONL; + } + /* check for diagonal tight squeeze */ + if (nx != x && ny != y && bad_rock(mdat, x, ny) && + bad_rock(mdat, nx, y) && cant_squeeze_thru(mon)) + continue; + /* The monster avoids a particular type of trap if it's familiar + * with the trap type. Pets get ALLOW_TRAPS and checking is + * done in dogmove.c. In either case, "harmless" traps are + * neither avoided nor marked in info[]. + */ + { register struct trap *ttmp = t_at(nx, ny); + if(ttmp) { + if(ttmp->ttyp >= TRAPNUM || ttmp->ttyp == 0) { impossible("A monster looked at a very strange trap of type %d.", ttmp->ttyp); - continue; - } - if ((ttmp->ttyp != RUST_TRAP - || mdat == &mons[PM_IRON_GOLEM]) - && ttmp->ttyp != STATUE_TRAP - && ((ttmp->ttyp != PIT - && ttmp->ttyp != SPIKED_PIT - && ttmp->ttyp != TRAPDOOR - && ttmp->ttyp != HOLE) - || (!is_flyer(mdat) - && !is_floater(mdat) - && !is_clinger(mdat)) - || Sokoban) - && (ttmp->ttyp != SLP_GAS_TRAP || - !resists_sleep(mon)) - && (ttmp->ttyp != BEAR_TRAP || - (mdat->msize > MZ_SMALL && - !amorphous(mdat) && !is_flyer(mdat) && - !is_whirly(mdat) && !unsolid(mdat))) - && (ttmp->ttyp != FIRE_TRAP || - !resists_fire(mon)) - && (ttmp->ttyp != SQKY_BOARD || !is_flyer(mdat)) - && (ttmp->ttyp != WEB || (!amorphous(mdat) && - !webmaker(mdat))) - && (ttmp->ttyp != ANTI_MAGIC || - !resists_magm(mon)) - ) { - if (!(flag & ALLOW_TRAPS)) { - if (mon->mtrapseen & (1L << (ttmp->ttyp - 1))) - continue; - } - info[cnt] |= ALLOW_TRAPS; - } - } - } - poss[cnt].x = nx; - poss[cnt].y = ny; - cnt++; - } - } - if(!cnt && wantpool && !is_pool(x,y)) { - wantpool = FALSE; - goto nexttry; - } - return(cnt); + continue; + } + if ((ttmp->ttyp != RUST_TRAP + || mdat == &mons[PM_IRON_GOLEM]) + && ttmp->ttyp != STATUE_TRAP + && ((ttmp->ttyp != PIT + && ttmp->ttyp != SPIKED_PIT + && ttmp->ttyp != TRAPDOOR + && ttmp->ttyp != HOLE) + || (!is_flyer(mdat) + && !is_floater(mdat) + && !is_clinger(mdat)) + || Sokoban) + && (ttmp->ttyp != SLP_GAS_TRAP || + !resists_sleep(mon)) + && (ttmp->ttyp != BEAR_TRAP || + (mdat->msize > MZ_SMALL && + !amorphous(mdat) && !is_flyer(mdat) && + !is_whirly(mdat) && !unsolid(mdat))) + && (ttmp->ttyp != FIRE_TRAP || + !resists_fire(mon)) + && (ttmp->ttyp != SQKY_BOARD || !is_flyer(mdat)) + && (ttmp->ttyp != WEB || (!amorphous(mdat) && + !webmaker(mdat))) + && (ttmp->ttyp != ANTI_MAGIC || + !resists_magm(mon)) + ) { + if (!(flag & ALLOW_TRAPS)) { + if (mon->mtrapseen & (1L << (ttmp->ttyp - 1))) + continue; + } + info[cnt] |= ALLOW_TRAPS; + } + } + } + poss[cnt].x = nx; + poss[cnt].y = ny; + cnt++; + } + } + if(!cnt && wantpool && !is_pool(x,y)) { + wantpool = FALSE; + goto nexttry; + } + return(cnt); } /* Monster against monster special attacks; for the specified monster @@ -1178,43 +1197,43 @@ impossible("A monster looked at a very strange trap of type %d.", ttmp->ttyp); STATIC_OVL long mm_aggression(magr, mdef) struct monst *magr, /* monster that is currently deciding where to move */ - *mdef; /* another monster which is next to it */ + *mdef; /* another monster which is next to it */ { - /* supposedly purple worms are attracted to shrieking because they - like to eat shriekers, so attack the latter when feasible */ - if (magr->data == &mons[PM_PURPLE_WORM] && - mdef->data == &mons[PM_SHRIEKER]) - return ALLOW_M|ALLOW_TM; - /* Various other combinations such as dog vs cat, cat vs rat, and - elf vs orc have been suggested. For the time being we don't - support those. */ - return 0L; + /* supposedly purple worms are attracted to shrieking because they + like to eat shriekers, so attack the latter when feasible */ + if (magr->data == &mons[PM_PURPLE_WORM] && + mdef->data == &mons[PM_SHRIEKER]) + return ALLOW_M|ALLOW_TM; + /* Various other combinations such as dog vs cat, cat vs rat, and + elf vs orc have been suggested. For the time being we don't + support those. */ + return 0L; } /* Monster displacing another monster out of the way */ STATIC_OVL long mm_displacement(magr, mdef) struct monst *magr, /* monster that is currently deciding where to move */ - *mdef; /* another monster which is next to it */ + *mdef; /* another monster which is next to it */ { - struct permonst *pa = magr->data, - *pd = mdef->data; + struct permonst *pa = magr->data, + *pd = mdef->data; - /* if attacker can't barge through, there's nothing to do; - or if defender can barge through too, don't let attacker - do so, otherwise they might just end up swapping places - again when defender gets its chance to move */ - if ((pa->mflags3 & M3_DISPLACES) != 0 && - (pd->mflags3 & M3_DISPLACES) == 0 && - /* no displacing grid bugs diagonally */ - !(magr->mx != mdef->mx && magr->my != mdef->my && - NODIAG(monsndx(pd))) && - /* no displacing trapped monsters or multi-location longworms */ - !mdef->mtrapped && (!mdef->wormno || !count_wsegs(mdef)) && - /* riders can move anything; others, same size or smaller only */ - (is_rider(pa) || pa->msize >= pd->msize)) - return ALLOW_MDISP; - return 0L; + /* if attacker can't barge through, there's nothing to do; + or if defender can barge through too, don't let attacker + do so, otherwise they might just end up swapping places + again when defender gets its chance to move */ + if ((pa->mflags3 & M3_DISPLACES) != 0 && + (pd->mflags3 & M3_DISPLACES) == 0 && + /* no displacing grid bugs diagonally */ + !(magr->mx != mdef->mx && magr->my != mdef->my && + NODIAG(monsndx(pd))) && + /* no displacing trapped monsters or multi-location longworms */ + !mdef->mtrapped && (!mdef->wormno || !count_wsegs(mdef)) && + /* riders can move anything; others, same size or smaller only */ + (is_rider(pa) || pa->msize >= pd->msize)) + return ALLOW_MDISP; + return 0L; } boolean @@ -1223,10 +1242,10 @@ register struct monst *mon; register int x,y; /* Is the square close enough for the monster to move or attack into? */ { - register int distance = dist2(mon->mx, mon->my, x, y); + register int distance = dist2(mon->mx, mon->my, x, y); - if (distance == 2 && NODIAG(mon->data - mons)) return 0; - return((boolean)(distance < 3)); + if (distance == 2 && NODIAG(mon->data - mons)) return 0; + return((boolean)(distance < 3)); } /* really free dead monsters */ @@ -1237,20 +1256,20 @@ dmonsfree() int count = 0; for (mtmp = &fmon; *mtmp;) { - freetmp = *mtmp; - if (freetmp->mhp <= 0 && !freetmp->isgd) { + freetmp = *mtmp; + if (freetmp->mhp <= 0 && !freetmp->isgd) { if (freetmp == context.polearm.hitmon) context.polearm.hitmon = NULL; - *mtmp = freetmp->nmon; - dealloc_monst(freetmp); - count++; - } else - mtmp = &(freetmp->nmon); + *mtmp = freetmp->nmon; + dealloc_monst(freetmp); + count++; + } else + mtmp = &(freetmp->nmon); } if (count != iflags.purge_monsters) - impossible("dmonsfree: %d removed doesn't match %d pending", - count, iflags.purge_monsters); + impossible("dmonsfree: %d removed doesn't match %d pending", + count, iflags.purge_monsters); iflags.purge_monsters = 0; } @@ -1263,9 +1282,9 @@ register struct monst *mtmp, *mtmp2; /* transfer the monster's inventory */ for (otmp = mtmp2->minvent; otmp; otmp = otmp->nobj) { - if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp) + if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp) debugpline0("replmon: minvent inconsistency"); - otmp->ocarry = mtmp2; + otmp->ocarry = mtmp2; } mtmp->minvent = 0; @@ -1276,14 +1295,14 @@ register struct monst *mtmp, *mtmp2; if (mtmp != u.usteed) /* don't place steed onto the map */ place_monster(mtmp2, mtmp2->mx, mtmp2->my); if (mtmp2->wormno) /* update level.monsters[wseg->wx][wseg->wy] */ - place_wsegs(mtmp2); /* locations to mtmp2 not mtmp. */ + place_wsegs(mtmp2); /* locations to mtmp2 not mtmp. */ if (emits_light(mtmp2->data)) { - /* since this is so rare, we don't have any `mon_move_light_source' */ - new_light_source(mtmp2->mx, mtmp2->my, - emits_light(mtmp2->data), - LS_MONSTER, monst_to_any(mtmp2)); - /* here we rely on the fact that `mtmp' hasn't actually been deleted */ - del_light_source(LS_MONSTER, monst_to_any(mtmp)); + /* since this is so rare, we don't have any `mon_move_light_source' */ + new_light_source(mtmp2->mx, mtmp2->my, + emits_light(mtmp2->data), + LS_MONSTER, monst_to_any(mtmp2)); + /* here we rely on the fact that `mtmp' hasn't actually been deleted */ + del_light_source(LS_MONSTER, monst_to_any(mtmp)); } mtmp2->nmon = fmon; fmon = mtmp2; @@ -1302,110 +1321,110 @@ relmon(mon, monst_list) register struct monst *mon; struct monst **monst_list; /* &migrating_mons or &mydogs or null */ { - register struct monst *mtmp; - boolean unhide = (monst_list != 0); - int mx = mon->mx, my = mon->my; + register struct monst *mtmp; + boolean unhide = (monst_list != 0); + int mx = mon->mx, my = mon->my; - if (!fmon) panic("relmon: no fmon available."); + if (!fmon) panic("relmon: no fmon available."); - if (unhide) { - /* can't remain hidden across level changes (exception: wizard - clone can continue imitating some other monster form); also, - might be imitating a boulder so need line-of-sight unblocking */ - mon->mundetected = 0; - if (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER) - seemimic(mon); - } + if (unhide) { + /* can't remain hidden across level changes (exception: wizard + clone can continue imitating some other monster form); also, + might be imitating a boulder so need line-of-sight unblocking */ + mon->mundetected = 0; + if (mon->m_ap_type && mon->m_ap_type != M_AP_MONSTER) + seemimic(mon); + } - remove_monster(mx, my); + remove_monster(mx, my); - if (mon == fmon) { - fmon = fmon->nmon; - } else { - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) - if (mtmp->nmon == mon) break; + if (mon == fmon) { + fmon = fmon->nmon; + } else { + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + if (mtmp->nmon == mon) break; - if (mtmp) mtmp->nmon = mon->nmon; - else panic("relmon: mon not in list."); - } + if (mtmp) mtmp->nmon = mon->nmon; + else panic("relmon: mon not in list."); + } - if (unhide) { - newsym(mx, my); - /* insert into mydogs or migrating_mons */ - mon->nmon = *monst_list; - *monst_list = mon; - } else { - /* orphan has no next monster */ - mon->nmon = 0; - } + if (unhide) { + newsym(mx, my); + /* insert into mydogs or migrating_mons */ + mon->nmon = *monst_list; + *monst_list = mon; + } else { + /* orphan has no next monster */ + mon->nmon = 0; + } } void copy_mextra(mtmp2, mtmp1) struct monst *mtmp2, *mtmp1; { - if(!mtmp2 || !mtmp1 || !mtmp1->mextra) return; + if(!mtmp2 || !mtmp1 || !mtmp1->mextra) return; - if (!mtmp2->mextra) mtmp2->mextra = newmextra(); - if (MNAME(mtmp1)) { - new_mname(mtmp2, (int)strlen(MNAME(mtmp1)) + 1); - Strcpy(MNAME(mtmp2), MNAME(mtmp1)); - } - if (EGD(mtmp1)) { - if (!EGD(mtmp2)) newegd(mtmp2); - (void)memcpy((genericptr_t)EGD(mtmp2), - (genericptr_t)EGD(mtmp1), - sizeof(struct egd)); - } - if (EPRI(mtmp1)) { - if (!EPRI(mtmp2)) newepri(mtmp2); - (void)memcpy((genericptr_t)EPRI(mtmp2), - (genericptr_t)EPRI(mtmp1), - sizeof(struct epri)); - } - if (ESHK(mtmp1)) { - if (!ESHK(mtmp2)) neweshk(mtmp2); - (void)memcpy((genericptr_t)ESHK(mtmp2), - (genericptr_t)ESHK(mtmp1), - sizeof(struct eshk)); - } - if (EMIN(mtmp1)) { - if (!EMIN(mtmp2)) newemin(mtmp2); - (void)memcpy((genericptr_t)EMIN(mtmp2), - (genericptr_t)EMIN(mtmp1), - sizeof(struct emin)); - } - if (EDOG(mtmp1)) { - if (!EDOG(mtmp2)) newedog(mtmp2); - (void)memcpy((genericptr_t)EDOG(mtmp2), - (genericptr_t)EDOG(mtmp1), - sizeof(struct edog)); - } - if (has_mcorpsenm(mtmp1)) MCORPSENM(mtmp2) = MCORPSENM(mtmp1); + if (!mtmp2->mextra) mtmp2->mextra = newmextra(); + if (MNAME(mtmp1)) { + new_mname(mtmp2, (int)strlen(MNAME(mtmp1)) + 1); + Strcpy(MNAME(mtmp2), MNAME(mtmp1)); + } + if (EGD(mtmp1)) { + if (!EGD(mtmp2)) newegd(mtmp2); + (void)memcpy((genericptr_t)EGD(mtmp2), + (genericptr_t)EGD(mtmp1), + sizeof(struct egd)); + } + if (EPRI(mtmp1)) { + if (!EPRI(mtmp2)) newepri(mtmp2); + (void)memcpy((genericptr_t)EPRI(mtmp2), + (genericptr_t)EPRI(mtmp1), + sizeof(struct epri)); + } + if (ESHK(mtmp1)) { + if (!ESHK(mtmp2)) neweshk(mtmp2); + (void)memcpy((genericptr_t)ESHK(mtmp2), + (genericptr_t)ESHK(mtmp1), + sizeof(struct eshk)); + } + if (EMIN(mtmp1)) { + if (!EMIN(mtmp2)) newemin(mtmp2); + (void)memcpy((genericptr_t)EMIN(mtmp2), + (genericptr_t)EMIN(mtmp1), + sizeof(struct emin)); + } + if (EDOG(mtmp1)) { + if (!EDOG(mtmp2)) newedog(mtmp2); + (void)memcpy((genericptr_t)EDOG(mtmp2), + (genericptr_t)EDOG(mtmp1), + sizeof(struct edog)); + } + if (has_mcorpsenm(mtmp1)) MCORPSENM(mtmp2) = MCORPSENM(mtmp1); } STATIC_OVL void dealloc_mextra(x) struct mextra *x; { - if (x) { - if (x->mname) free((genericptr_t)x->mname); - if (x->egd) free((genericptr_t)x->egd); - if (x->epri) free((genericptr_t)x->epri); - if (x->eshk) free((genericptr_t)x->eshk); - if (x->emin) free((genericptr_t)x->emin); - if (x->edog) free((genericptr_t)x->edog); - /* [no action needed for x->mcorpsenm] */ - free((genericptr_t)x); - } + if (x) { + if (x->mname) free((genericptr_t)x->mname); + if (x->egd) free((genericptr_t)x->egd); + if (x->epri) free((genericptr_t)x->epri); + if (x->eshk) free((genericptr_t)x->eshk); + if (x->emin) free((genericptr_t)x->emin); + if (x->edog) free((genericptr_t)x->edog); + /* [no action needed for x->mcorpsenm] */ + free((genericptr_t)x); + } } void dealloc_monst(mon) struct monst *mon; { - if (mon->mextra) dealloc_mextra(mon->mextra); - free((genericptr_t)mon); + if (mon->mextra) dealloc_mextra(mon->mextra); + free((genericptr_t)mon); } /* remove effects of mtmp from other data structures */ @@ -1414,21 +1433,21 @@ m_detach(mtmp, mptr) struct monst *mtmp; struct permonst *mptr; /* reflects mtmp->data _prior_ to mtmp's death */ { - if (mtmp->mleashed) m_unleash(mtmp, FALSE); - /* to prevent an infinite relobj-flooreffects-hmon-killed loop */ - mtmp->mtrapped = 0; - mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */ - relobj(mtmp, 0, FALSE); - remove_monster(mtmp->mx, mtmp->my); - if (emits_light(mptr)) - del_light_source(LS_MONSTER, monst_to_any(mtmp)); - newsym(mtmp->mx,mtmp->my); - unstuck(mtmp); - fill_pit(mtmp->mx, mtmp->my); + if (mtmp->mleashed) m_unleash(mtmp, FALSE); + /* to prevent an infinite relobj-flooreffects-hmon-killed loop */ + mtmp->mtrapped = 0; + mtmp->mhp = 0; /* simplify some tests: force mhp to 0 */ + relobj(mtmp, 0, FALSE); + remove_monster(mtmp->mx, mtmp->my); + if (emits_light(mptr)) + del_light_source(LS_MONSTER, monst_to_any(mtmp)); + newsym(mtmp->mx,mtmp->my); + unstuck(mtmp); + fill_pit(mtmp->mx, mtmp->my); - if(mtmp->isshk) shkgone(mtmp); - if(mtmp->wormno) wormgone(mtmp); - iflags.purge_monsters++; + if(mtmp->isshk) shkgone(mtmp); + if(mtmp->wormno) wormgone(mtmp); + iflags.purge_monsters++; } /* find the worn amulet of life saving which will save a monster */ @@ -1436,181 +1455,181 @@ struct obj * mlifesaver(mon) struct monst *mon; { - if (!nonliving(mon->data) || is_vampshifter(mon)) { - struct obj *otmp = which_armor(mon, W_AMUL); + if (!nonliving(mon->data) || is_vampshifter(mon)) { + struct obj *otmp = which_armor(mon, W_AMUL); - if (otmp && otmp->otyp == AMULET_OF_LIFE_SAVING) - return otmp; - } - return (struct obj *)0; + if (otmp && otmp->otyp == AMULET_OF_LIFE_SAVING) + return otmp; + } + return (struct obj *)0; } STATIC_OVL void lifesaved_monster(mtmp) struct monst *mtmp; { - boolean surviver; - struct obj *lifesave = mlifesaver(mtmp); + boolean surviver; + struct obj *lifesave = mlifesaver(mtmp); - if (lifesave) { - /* not canseemon; amulets are on the head, so you don't want - * to show this for a long worm with only a tail visible. - * Nor do you check invisibility, because glowing and - * disintegrating amulets are always visible. */ - if (cansee(mtmp->mx, mtmp->my)) { - pline("But wait..."); - pline("%s medallion begins to glow!", - s_suffix(Monnam(mtmp))); - makeknown(AMULET_OF_LIFE_SAVING); - /* amulet is visible, but monster might not be */ - if (canseemon(mtmp)) { - if (attacktype(mtmp->data, AT_EXPL) - || attacktype(mtmp->data, AT_BOOM)) - pline("%s reconstitutes!", Monnam(mtmp)); - else - pline("%s looks much better!", Monnam(mtmp)); - } - pline_The("medallion crumbles to dust!"); - } - m_useup(mtmp, lifesave); + if (lifesave) { + /* not canseemon; amulets are on the head, so you don't want + * to show this for a long worm with only a tail visible. + * Nor do you check invisibility, because glowing and + * disintegrating amulets are always visible. */ + if (cansee(mtmp->mx, mtmp->my)) { + pline("But wait..."); + pline("%s medallion begins to glow!", + s_suffix(Monnam(mtmp))); + makeknown(AMULET_OF_LIFE_SAVING); + /* amulet is visible, but monster might not be */ + if (canseemon(mtmp)) { + if (attacktype(mtmp->data, AT_EXPL) + || attacktype(mtmp->data, AT_BOOM)) + pline("%s reconstitutes!", Monnam(mtmp)); + else + pline("%s looks much better!", Monnam(mtmp)); + } + pline_The("medallion crumbles to dust!"); + } + m_useup(mtmp, lifesave); - surviver = !(mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); - mtmp->mcanmove = 1; - mtmp->mfrozen = 0; - if (mtmp->mtame && !mtmp->isminion) { - wary_dog(mtmp, !surviver); - } - if (mtmp->mhpmax <= 0) mtmp->mhpmax = 10; - mtmp->mhp = mtmp->mhpmax; - if (surviver) return; + surviver = !(mvitals[monsndx(mtmp->data)].mvflags & G_GENOD); + mtmp->mcanmove = 1; + mtmp->mfrozen = 0; + if (mtmp->mtame && !mtmp->isminion) { + wary_dog(mtmp, !surviver); + } + if (mtmp->mhpmax <= 0) mtmp->mhpmax = 10; + mtmp->mhp = mtmp->mhpmax; + if (surviver) return; - /* genocided monster can't be life-saved */ - if (cansee(mtmp->mx, mtmp->my)) - pline("Unfortunately, %s is still genocided...", - mon_nam(mtmp)); - } - mtmp->mhp = 0; + /* genocided monster can't be life-saved */ + if (cansee(mtmp->mx, mtmp->my)) + pline("Unfortunately, %s is still genocided...", + mon_nam(mtmp)); + } + mtmp->mhp = 0; } void mondead(mtmp) register struct monst *mtmp; { - struct permonst *mptr; - int tmp; + struct permonst *mptr; + int tmp; - lifesaved_monster(mtmp); - if (mtmp->mhp > 0) return; + lifesaved_monster(mtmp); + if (mtmp->mhp > 0) return; - if (is_vampshifter(mtmp)) { - int mndx = mtmp->cham; - int x = mtmp->mx, y = mtmp->my; - /* this only happens if shapeshifted */ - if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)) { - char buf[BUFSZ]; - boolean in_door = amorphous(mtmp->data) && - closed_door(mtmp->mx,mtmp->my); - Sprintf(buf, - "The %s%s suddenly %s and rises as %%s!", - (nonliving(mtmp->data) || - noncorporeal(mtmp->data) || - amorphous(mtmp->data)) ? "" : "seemingly dead ", - x_monnam(mtmp, ARTICLE_NONE, (char *)0, - SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION | - SUPPRESS_INVISIBLE | SUPPRESS_IT, FALSE), - (nonliving(mtmp->data) || - noncorporeal(mtmp->data) || - amorphous(mtmp->data)) ? - "reconstitutes" : "transforms"); - mtmp->mcanmove = 1; - mtmp->mfrozen = 0; - if (mtmp->mhpmax <= 0) mtmp->mhpmax = 10; - mtmp->mhp = mtmp->mhpmax; - /* this can happen if previously a fog cloud */ - if (u.uswallow && (mtmp == u.ustuck)) - expels(mtmp, mtmp->data, FALSE); - if (in_door) { - coord new_xy; - if (enexto(&new_xy, - mtmp->mx, mtmp->my, &mons[mndx])) { - rloc_to(mtmp, new_xy.x, new_xy.y); - } - } - newcham(mtmp, &mons[mndx], FALSE, FALSE); - if (mtmp->data == &mons[mndx]) - mtmp->cham = NON_PM; - else - mtmp->cham = mndx; - if ((!Blind && canseemon(mtmp)) || sensemon(mtmp)) - pline(buf, a_monnam(mtmp)); - newsym(x,y); - return; - } - } + if (is_vampshifter(mtmp)) { + int mndx = mtmp->cham; + int x = mtmp->mx, y = mtmp->my; + /* this only happens if shapeshifted */ + if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)) { + char buf[BUFSZ]; + boolean in_door = amorphous(mtmp->data) && + closed_door(mtmp->mx,mtmp->my); + Sprintf(buf, + "The %s%s suddenly %s and rises as %%s!", + (nonliving(mtmp->data) || + noncorporeal(mtmp->data) || + amorphous(mtmp->data)) ? "" : "seemingly dead ", + x_monnam(mtmp, ARTICLE_NONE, (char *)0, + SUPPRESS_SADDLE | SUPPRESS_HALLUCINATION | + SUPPRESS_INVISIBLE | SUPPRESS_IT, FALSE), + (nonliving(mtmp->data) || + noncorporeal(mtmp->data) || + amorphous(mtmp->data)) ? + "reconstitutes" : "transforms"); + mtmp->mcanmove = 1; + mtmp->mfrozen = 0; + if (mtmp->mhpmax <= 0) mtmp->mhpmax = 10; + mtmp->mhp = mtmp->mhpmax; + /* this can happen if previously a fog cloud */ + if (u.uswallow && (mtmp == u.ustuck)) + expels(mtmp, mtmp->data, FALSE); + if (in_door) { + coord new_xy; + if (enexto(&new_xy, + mtmp->mx, mtmp->my, &mons[mndx])) { + rloc_to(mtmp, new_xy.x, new_xy.y); + } + } + newcham(mtmp, &mons[mndx], FALSE, FALSE); + if (mtmp->data == &mons[mndx]) + mtmp->cham = NON_PM; + else + mtmp->cham = mndx; + if ((!Blind && canseemon(mtmp)) || sensemon(mtmp)) + pline(buf, a_monnam(mtmp)); + newsym(x,y); + return; + } + } - /* dead vault guard is actually kept at coordinate <0,0> until - his temporary corridor to/from the vault has been removed; - need to do this after life-saving and before m_detach() */ - if (mtmp->isgd && !grddead(mtmp)) return; + /* dead vault guard is actually kept at coordinate <0,0> until + his temporary corridor to/from the vault has been removed; + need to do this after life-saving and before m_detach() */ + if (mtmp->isgd && !grddead(mtmp)) return; - /* Player is thrown from his steed when it dies */ - if (mtmp == u.usteed) - dismount_steed(DISMOUNT_GENERIC); + /* Player is thrown from his steed when it dies */ + if (mtmp == u.usteed) + dismount_steed(DISMOUNT_GENERIC); - mptr = mtmp->data; /* save this for m_detach() */ - /* restore chameleon, lycanthropes to true form at death */ - if (mtmp->cham >= LOW_PM) { - set_mon_data(mtmp, &mons[mtmp->cham], -1); - mtmp->cham = NON_PM; - } - else if (mtmp->data == &mons[PM_WEREJACKAL]) - set_mon_data(mtmp, &mons[PM_HUMAN_WEREJACKAL], -1); - else if (mtmp->data == &mons[PM_WEREWOLF]) - set_mon_data(mtmp, &mons[PM_HUMAN_WEREWOLF], -1); - else if (mtmp->data == &mons[PM_WERERAT]) - set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT], -1); + mptr = mtmp->data; /* save this for m_detach() */ + /* restore chameleon, lycanthropes to true form at death */ + if (mtmp->cham >= LOW_PM) { + set_mon_data(mtmp, &mons[mtmp->cham], -1); + mtmp->cham = NON_PM; + } + else if (mtmp->data == &mons[PM_WEREJACKAL]) + set_mon_data(mtmp, &mons[PM_HUMAN_WEREJACKAL], -1); + else if (mtmp->data == &mons[PM_WEREWOLF]) + set_mon_data(mtmp, &mons[PM_HUMAN_WEREWOLF], -1); + else if (mtmp->data == &mons[PM_WERERAT]) + set_mon_data(mtmp, &mons[PM_HUMAN_WERERAT], -1); - /* if MAXMONNO monsters of a given type have died, and it - * can be done, extinguish that monster. - * - * mvitals[].died does double duty as total number of dead monsters - * and as experience factor for the player killing more monsters. - * this means that a dragon dying by other means reduces the - * experience the player gets for killing a dragon directly; this - * is probably not too bad, since the player likely finagled the - * first dead dragon via ring of conflict or pets, and extinguishing - * based on only player kills probably opens more avenues of abuse - * for rings of conflict and such. - */ - tmp = monsndx(mtmp->data); - if (mvitals[tmp].died < 255) mvitals[tmp].died++; + /* if MAXMONNO monsters of a given type have died, and it + * can be done, extinguish that monster. + * + * mvitals[].died does double duty as total number of dead monsters + * and as experience factor for the player killing more monsters. + * this means that a dragon dying by other means reduces the + * experience the player gets for killing a dragon directly; this + * is probably not too bad, since the player likely finagled the + * first dead dragon via ring of conflict or pets, and extinguishing + * based on only player kills probably opens more avenues of abuse + * for rings of conflict and such. + */ + tmp = monsndx(mtmp->data); + if (mvitals[tmp].died < 255) mvitals[tmp].died++; - /* if it's a (possibly polymorphed) quest leader, mark him as dead */ - if (mtmp->m_id == quest_status.leader_m_id) - quest_status.leader_is_dead = TRUE; + /* if it's a (possibly polymorphed) quest leader, mark him as dead */ + if (mtmp->m_id == quest_status.leader_m_id) + quest_status.leader_is_dead = TRUE; #ifdef MAIL - /* if the mail daemon dies, no more mail delivery. -3. */ - if (tmp == PM_MAIL_DAEMON) mvitals[tmp].mvflags |= G_GENOD; + /* if the mail daemon dies, no more mail delivery. -3. */ + if (tmp == PM_MAIL_DAEMON) mvitals[tmp].mvflags |= G_GENOD; #endif - if (mtmp->data->mlet == S_KOP) { - /* Dead Kops may come back. */ - switch(rnd(5)) { - case 1: /* returns near the stairs */ - (void) makemon(mtmp->data,xdnstair,ydnstair,NO_MM_FLAGS); - break; - case 2: /* randomly */ - (void) makemon(mtmp->data,0,0,NO_MM_FLAGS); - break; - default: - break; - } - } - if(mtmp->iswiz) wizdead(); - if(mtmp->data->msound == MS_NEMESIS) nemdead(); - if(glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) - unmap_object(mtmp->mx, mtmp->my); - m_detach(mtmp, mptr); + if (mtmp->data->mlet == S_KOP) { + /* Dead Kops may come back. */ + switch(rnd(5)) { + case 1: /* returns near the stairs */ + (void) makemon(mtmp->data,xdnstair,ydnstair,NO_MM_FLAGS); + break; + case 2: /* randomly */ + (void) makemon(mtmp->data,0,0,NO_MM_FLAGS); + break; + default: + break; + } + } + if(mtmp->iswiz) wizdead(); + if(mtmp->data->msound == MS_NEMESIS) nemdead(); + if(glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) + unmap_object(mtmp->mx, mtmp->my); + m_detach(mtmp, mptr); } /* TRUE if corpse might be dropped, magr may die if mon was swallowed */ @@ -1620,65 +1639,64 @@ struct monst *mon; struct monst *magr; /* killer, if swallowed */ boolean was_swallowed; /* digestion */ { - struct permonst *mdat = mon->data; - int i, tmp; + struct permonst *mdat = mon->data; + int i, tmp; - if (mdat == &mons[PM_VLAD_THE_IMPALER] || mdat->mlet == S_LICH) { - if (cansee(mon->mx, mon->my) && !was_swallowed) - pline("%s body crumbles into dust.", s_suffix(Monnam(mon))); - return FALSE; - } + if (mdat == &mons[PM_VLAD_THE_IMPALER] || mdat->mlet == S_LICH) { + if (cansee(mon->mx, mon->my) && !was_swallowed) + pline("%s body crumbles into dust.", s_suffix(Monnam(mon))); + return FALSE; + } - /* Gas spores always explode upon death */ - for(i = 0; i < NATTK; i++) { - if (mdat->mattk[i].aatyp == AT_BOOM) { - if (mdat->mattk[i].damn) - tmp = d((int)mdat->mattk[i].damn, - (int)mdat->mattk[i].damd); - else if(mdat->mattk[i].damd) - tmp = d((int)mdat->mlevel+1, (int)mdat->mattk[i].damd); - else tmp = 0; - if (was_swallowed && magr) { - if (magr == &youmonst) { - There("is an explosion in your %s!", - body_part(STOMACH)); - Sprintf(killer.name, "%s explosion", - s_suffix(mdat->mname)); - losehp(Maybe_Half_Phys(tmp), killer.name, KILLED_BY_AN); - } else { - You_hear("an explosion."); - magr->mhp -= tmp; - if (magr->mhp < 1) mondied(magr); - if (magr->mhp < 1) { /* maybe lifesaved */ - if (canspotmon(magr)) - pline("%s rips open!", Monnam(magr)); - } else if (canseemon(magr)) - pline("%s seems to have indigestion.", - Monnam(magr)); - } + /* Gas spores always explode upon death */ + for(i = 0; i < NATTK; i++) { + if (mdat->mattk[i].aatyp == AT_BOOM) { + if (mdat->mattk[i].damn) + tmp = d((int)mdat->mattk[i].damn, + (int)mdat->mattk[i].damd); + else if(mdat->mattk[i].damd) + tmp = d((int)mdat->mlevel+1, (int)mdat->mattk[i].damd); + else tmp = 0; + if (was_swallowed && magr) { + if (magr == &youmonst) { + There("is an explosion in your %s!", + body_part(STOMACH)); + Sprintf(killer.name, "%s explosion", + s_suffix(mdat->mname)); + losehp(Maybe_Half_Phys(tmp), killer.name, KILLED_BY_AN); + } else { + You_hear("an explosion."); + magr->mhp -= tmp; + if (magr->mhp < 1) mondied(magr); + if (magr->mhp < 1) { /* maybe lifesaved */ + if (canspotmon(magr)) + pline("%s rips open!", Monnam(magr)); + } else if (canseemon(magr)) + pline("%s seems to have indigestion.", + Monnam(magr)); + } - return FALSE; - } + return FALSE; + } - Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname)); - killer.format = KILLED_BY_AN; - explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS); - return (FALSE); - } - } + Sprintf(killer.name, "%s explosion", s_suffix(mdat->mname)); + killer.format = KILLED_BY_AN; + explode(mon->mx, mon->my, -1, tmp, MON_EXPLODE, EXPL_NOXIOUS); + return (FALSE); + } + } - /* must duplicate this below check in xkilled() since it results in - * creating no objects as well as no corpse - */ - if (LEVEL_SPECIFIC_NOCORPSE(mdat)) - return FALSE; + /* must duplicate this below check in xkilled() since it results in + * creating no objects as well as no corpse + */ + if (LEVEL_SPECIFIC_NOCORPSE(mdat)) + return FALSE; - if (((bigmonst(mdat) || mdat == &mons[PM_LIZARD]) && !mon->mcloned) || - is_golem(mdat) || is_mplayer(mdat) || is_rider(mdat)) - return TRUE; - tmp = 2 + ((mdat->geno & G_FREQ) < 2) + verysmall(mdat); - if (mon->mcloned) tmp += mvitals[monsndx(mdat)].died / 25; - return (boolean) !rn2(tmp); + if (((bigmonst(mdat) || mdat == &mons[PM_LIZARD]) && !mon->mcloned) || + is_golem(mdat) || is_mplayer(mdat) || is_rider(mdat)) + return TRUE; + tmp = 2 + ((mdat->geno & G_FREQ) < 2) + verysmall(mdat); + return (boolean) !rn2(tmp); } /* drop (perhaps) a cadaver and remove monster */ @@ -1686,12 +1704,12 @@ void mondied(mdef) register struct monst *mdef; { - mondead(mdef); - if (mdef->mhp > 0) return; /* lifesaved */ + mondead(mdef); + if (mdef->mhp > 0) return; /* lifesaved */ - if (corpse_chance(mdef, (struct monst *)0, FALSE) && - (accessible(mdef->mx, mdef->my) || is_pool(mdef->mx, mdef->my))) - (void) make_corpse(mdef,CORPSTAT_NONE); + if (corpse_chance(mdef, (struct monst *)0, FALSE) && + (accessible(mdef->mx, mdef->my) || is_pool(mdef->mx, mdef->my))) + (void) make_corpse(mdef,CORPSTAT_NONE); } /* monster disappears, not dies */ @@ -1699,17 +1717,17 @@ void mongone(mdef) register struct monst *mdef; { - mdef->mhp = 0; /* can skip some inventory bookkeeping */ - /* Player is thrown from his steed when it disappears */ - if (mdef == u.usteed) - dismount_steed(DISMOUNT_GENERIC); + mdef->mhp = 0; /* can skip some inventory bookkeeping */ + /* Player is thrown from his steed when it disappears */ + if (mdef == u.usteed) + dismount_steed(DISMOUNT_GENERIC); - /* drop special items like the Amulet so that a dismissed Kop or nurse - can't remove them from the game */ - mdrop_special_objs(mdef); - /* release rest of monster's inventory--it is removed from game */ - discard_minvent(mdef); - m_detach(mdef, mdef->data); + /* drop special items like the Amulet so that a dismissed Kop or nurse + can't remove them from the game */ + mdrop_special_objs(mdef); + /* release rest of monster's inventory--it is removed from game */ + discard_minvent(mdef); + m_detach(mdef, mdef->data); } /* drop a statue or rock and remove monster */ @@ -1717,74 +1735,74 @@ void monstone(mdef) register struct monst *mdef; { - struct obj *otmp, *obj, *oldminvent; - xchar x = mdef->mx, y = mdef->my; - boolean wasinside = FALSE; + struct obj *otmp, *obj, *oldminvent; + xchar x = mdef->mx, y = mdef->my; + boolean wasinside = FALSE; - /* we have to make the statue before calling mondead, to be able to - * put inventory in it, and we have to check for lifesaving before - * making the statue.... - */ - lifesaved_monster(mdef); - if (mdef->mhp > 0) return; + /* we have to make the statue before calling mondead, to be able to + * put inventory in it, and we have to check for lifesaving before + * making the statue.... + */ + lifesaved_monster(mdef); + if (mdef->mhp > 0) return; - mdef->mtrapped = 0; /* (see m_detach) */ + mdef->mtrapped = 0; /* (see m_detach) */ - if ((int)mdef->data->msize > MZ_TINY || - !rn2(2 + ((int) (mdef->data->geno & G_FREQ) > 2))) { - oldminvent = 0; - /* some objects may end up outside the statue */ - while ((obj = mdef->minvent) != 0) { - obj_extract_self(obj); - if (obj->owornmask) - update_mon_intrinsics(mdef, obj, FALSE, TRUE); - obj_no_longer_held(obj); - if (obj->owornmask & W_WEP) - setmnotwielded(mdef,obj); - obj->owornmask = 0L; - if (obj->otyp == BOULDER || + if ((int)mdef->data->msize > MZ_TINY || + !rn2(2 + ((int) (mdef->data->geno & G_FREQ) > 2))) { + oldminvent = 0; + /* some objects may end up outside the statue */ + while ((obj = mdef->minvent) != 0) { + obj_extract_self(obj); + if (obj->owornmask) + update_mon_intrinsics(mdef, obj, FALSE, TRUE); + obj_no_longer_held(obj); + if (obj->owornmask & W_WEP) + setmnotwielded(mdef,obj); + obj->owornmask = 0L; + if (obj->otyp == BOULDER || #if 0 /* monsters don't carry statues */ (obj->otyp == STATUE && mons[obj->corpsenm].msize >= mdef->data->msize) || #endif - obj_resists(obj, 0, 0)) { - if (flooreffects(obj, x, y, "fall")) continue; - place_object(obj, x, y); - } else { - if (obj->lamplit) end_burn(obj, TRUE); - obj->nobj = oldminvent; - oldminvent = obj; - } - } - /* defer statue creation until after inventory removal - so that saved monster traits won't retain any stale - item-conferred attributes */ - otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, CORPSTAT_NONE); - if (has_mname(mdef)) otmp = oname(otmp, MNAME(mdef)); - while ((obj = oldminvent) != 0) { - oldminvent = obj->nobj; - (void) add_to_container(otmp, obj); - } - /* Archeologists should not break unique statues */ - if (mdef->data->geno & G_UNIQ) - otmp->spe = 1; - otmp->owt = weight(otmp); - } else - otmp = mksobj_at(ROCK, x, y, TRUE, FALSE); + obj_resists(obj, 0, 0)) { + if (flooreffects(obj, x, y, "fall")) continue; + place_object(obj, x, y); + } else { + if (obj->lamplit) end_burn(obj, TRUE); + obj->nobj = oldminvent; + oldminvent = obj; + } + } + /* defer statue creation until after inventory removal + so that saved monster traits won't retain any stale + item-conferred attributes */ + otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, CORPSTAT_NONE); + if (has_mname(mdef)) otmp = oname(otmp, MNAME(mdef)); + while ((obj = oldminvent) != 0) { + oldminvent = obj->nobj; + (void) add_to_container(otmp, obj); + } + /* Archeologists should not break unique statues */ + if (mdef->data->geno & G_UNIQ) + otmp->spe = 1; + otmp->owt = weight(otmp); + } else + otmp = mksobj_at(ROCK, x, y, TRUE, FALSE); - stackobj(otmp); - /* mondead() already does this, but we must do it before the newsym */ - if(glyph_is_invisible(levl[x][y].glyph)) - unmap_object(x, y); - if (cansee(x, y)) newsym(x,y); - /* We don't currently trap the hero in the statue in this case but we could */ - if (u.uswallow && u.ustuck == mdef) wasinside = TRUE; - mondead(mdef); - if (wasinside) { - if (is_animal(mdef->data)) - You("%s through an opening in the new %s.", - locomotion(youmonst.data, "jump"), - xname(otmp)); - } + stackobj(otmp); + /* mondead() already does this, but we must do it before the newsym */ + if(glyph_is_invisible(levl[x][y].glyph)) + unmap_object(x, y); + if (cansee(x, y)) newsym(x,y); + /* We don't currently trap the hero in the statue in this case but we could */ + if (u.uswallow && u.ustuck == mdef) wasinside = TRUE; + mondead(mdef); + if (wasinside) { + if (is_animal(mdef->data)) + You("%s through an opening in the new %s.", + locomotion(youmonst.data, "jump"), + xname(otmp)); + } } /* another monster has killed the monster mdef */ @@ -1794,51 +1812,51 @@ register struct monst *mdef; const char *fltxt; int how; { - boolean be_sad = FALSE; /* true if unseen pet is killed */ + boolean be_sad = FALSE; /* true if unseen pet is killed */ - if ((mdef->wormno ? worm_known(mdef) : cansee(mdef->mx, mdef->my)) - && fltxt) - pline("%s is %s%s%s!", Monnam(mdef), - nonliving(mdef->data) ? "destroyed" : "killed", - *fltxt ? " by the " : "", - fltxt - ); - else - be_sad = (mdef->mtame != 0); + if ((mdef->wormno ? worm_known(mdef) : cansee(mdef->mx, mdef->my)) + && fltxt) + pline("%s is %s%s%s!", Monnam(mdef), + nonliving(mdef->data) ? "destroyed" : "killed", + *fltxt ? " by the " : "", + fltxt + ); + else + be_sad = (mdef->mtame != 0); - /* no corpses if digested or disintegrated */ - if(how == AD_DGST || how == -AD_RBRE) - mondead(mdef); - else - mondied(mdef); + /* no corpses if digested or disintegrated */ + if(how == AD_DGST || how == -AD_RBRE) + mondead(mdef); + else + mondied(mdef); - if (be_sad && mdef->mhp <= 0) - You("have a sad feeling for a moment, then it passes."); + if (be_sad && mdef->mhp <= 0) + You("have a sad feeling for a moment, then it passes."); } void unstuck(mtmp) register struct monst *mtmp; { - if(u.ustuck == mtmp) { - if(u.uswallow){ - u.ux = mtmp->mx; - u.uy = mtmp->my; - u.uswallow = 0; - u.uswldtim = 0; - if (Punished) placebc(); - vision_full_recalc = 1; - docrt(); - } - u.ustuck = 0; - } + if(u.ustuck == mtmp) { + if(u.uswallow){ + u.ux = mtmp->mx; + u.uy = mtmp->my; + u.uswallow = 0; + u.uswldtim = 0; + if (Punished) placebc(); + vision_full_recalc = 1; + docrt(); + } + u.ustuck = 0; + } } void killed(mtmp) register struct monst *mtmp; { - xkilled(mtmp, 1); + xkilled(mtmp, 1); } /* the player has killed the monster mtmp */ @@ -1851,180 +1869,180 @@ struct monst *mtmp; */ int dest; { - int tmp, mndx, x = mtmp->mx, y = mtmp->my; - struct permonst *mdat; - struct obj *otmp; - struct trap *t; - boolean wasinside = u.uswallow && (u.ustuck == mtmp); - boolean burycorpse = FALSE; + int tmp, mndx, x = mtmp->mx, y = mtmp->my; + struct permonst *mdat; + struct obj *otmp; + struct trap *t; + boolean wasinside = u.uswallow && (u.ustuck == mtmp); + boolean burycorpse = FALSE; - /* KMH, conduct */ - u.uconduct.killer++; + /* KMH, conduct */ + u.uconduct.killer++; - if (dest & 1) { - const char *verb = nonliving(mtmp->data) ? "destroy" : "kill"; + if (dest & 1) { + const char *verb = nonliving(mtmp->data) ? "destroy" : "kill"; - if (!wasinside && !canspotmon(mtmp)) - You("%s it!", verb); - else { - You("%s %s!", verb, - !mtmp->mtame ? mon_nam(mtmp) : - x_monnam(mtmp, - (has_mname(mtmp)) ? ARTICLE_NONE : ARTICLE_THE, - "poor", - (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, - FALSE)); - } - } + if (!wasinside && !canspotmon(mtmp)) + You("%s it!", verb); + else { + You("%s %s!", verb, + !mtmp->mtame ? mon_nam(mtmp) : + x_monnam(mtmp, + (has_mname(mtmp)) ? ARTICLE_NONE : ARTICLE_THE, + "poor", + (has_mname(mtmp)) ? SUPPRESS_SADDLE : 0, + FALSE)); + } + } - if (mtmp->mtrapped && (t = t_at(x, y)) != 0 && - (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { + if (mtmp->mtrapped && (t = t_at(x, y)) != 0 && + (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { - if (sobj_at(BOULDER, x, y)) - dest |= 2; /* - * Prevent corpses/treasure being created "on top" - * of the boulder that is about to fall in. This is - * out of order, but cannot be helped unless this - * whole routine is rearranged. - */ - if (m_carrying(mtmp, BOULDER)) - burycorpse = TRUE; - } + if (sobj_at(BOULDER, x, y)) + dest |= 2; /* + * Prevent corpses/treasure being created "on top" + * of the boulder that is about to fall in. This is + * out of order, but cannot be helped unless this + * whole routine is rearranged. + */ + if (m_carrying(mtmp, BOULDER)) + burycorpse = TRUE; + } - /* your pet knows who just killed it...watch out */ - if (mtmp->mtame && !mtmp->isminion) EDOG(mtmp)->killed_by_u = 1; + /* your pet knows who just killed it...watch out */ + if (mtmp->mtame && !mtmp->isminion) EDOG(mtmp)->killed_by_u = 1; - if (wasinside && thrownobj && thrownobj != uball) { - /* thrown object has killed hero's engulfer; add it to mon's - inventory now so that it will be placed with mon's other - stuff prior to lookhere/autopickup when hero is expelled - below (as a side-effect, this missile has immunity from - being consumed [for this shot/throw only]) */ - mpickobj(mtmp, thrownobj); - /* let throwing code know that missile has been disposed of */ - thrownobj = 0; - } + if (wasinside && thrownobj && thrownobj != uball) { + /* thrown object has killed hero's engulfer; add it to mon's + inventory now so that it will be placed with mon's other + stuff prior to lookhere/autopickup when hero is expelled + below (as a side-effect, this missile has immunity from + being consumed [for this shot/throw only]) */ + mpickobj(mtmp, thrownobj); + /* let throwing code know that missile has been disposed of */ + thrownobj = 0; + } - /* dispose of monster and make cadaver */ - if(stoned) monstone(mtmp); - else mondead(mtmp); + /* dispose of monster and make cadaver */ + if(stoned) monstone(mtmp); + else mondead(mtmp); - if (mtmp->mhp > 0) { /* monster lifesaved */ - /* Cannot put the non-visible lifesaving message in - * lifesaved_monster() since the message appears only when you - * kill it (as opposed to visible lifesaving which always - * appears). - */ - stoned = FALSE; - if (!cansee(x,y)) pline("Maybe not..."); - return; - } + if (mtmp->mhp > 0) { /* monster lifesaved */ + /* Cannot put the non-visible lifesaving message in + * lifesaved_monster() since the message appears only when you + * kill it (as opposed to visible lifesaving which always + * appears). + */ + stoned = FALSE; + if (!cansee(x,y)) pline("Maybe not..."); + return; + } - mdat = mtmp->data; /* note: mondead can change mtmp->data */ - mndx = monsndx(mdat); + mdat = mtmp->data; /* note: mondead can change mtmp->data */ + mndx = monsndx(mdat); - if (stoned) { - stoned = FALSE; - goto cleanup; - } + if (stoned) { + stoned = FALSE; + goto cleanup; + } - if((dest & 2) || LEVEL_SPECIFIC_NOCORPSE(mdat)) - goto cleanup; + if((dest & 2) || LEVEL_SPECIFIC_NOCORPSE(mdat)) + goto cleanup; #ifdef MAIL - if(mdat == &mons[PM_MAIL_DAEMON]) { - stackobj(mksobj_at(SCR_MAIL, x, y, FALSE, FALSE)); - } + if(mdat == &mons[PM_MAIL_DAEMON]) { + stackobj(mksobj_at(SCR_MAIL, x, y, FALSE, FALSE)); + } #endif - if (accessible(x, y) || is_pool(x, y)) { - struct obj *cadaver; - int otyp; + if (accessible(x, y) || is_pool(x, y)) { + struct obj *cadaver; + int otyp; - /* illogical but traditional "treasure drop" */ - if (!rn2(6) && !(mvitals[mndx].mvflags & G_NOCORPSE) && - /* no extra item from swallower or steed */ - (x != u.ux || y != u.uy) && - /* no extra item from kops--too easy to abuse */ - mdat->mlet != S_KOP && - /* reduced chance of item from cloned monster */ - (!mtmp->mcloned || !rn2(mvitals[mndx].died / 5 + 1))) { - otmp = mkobj(RANDOM_CLASS, TRUE); - /* don't create large objects from small monsters */ - otyp = otmp->otyp; - if (mdat->msize < MZ_HUMAN && otyp != FIGURINE && - /* oc_big is also oc_bimanual and oc_bulky */ - (otmp->owt > 30 || objects[otyp].oc_big)) { - delobj(otmp); - } else if (!flooreffects(otmp, x, y, - (dest & 1) ? "fall" : "")) { - place_object(otmp, x, y); - stackobj(otmp); - } - } - /* corpse--none if hero was inside the monster */ - if (!wasinside && corpse_chance(mtmp, (struct monst *)0, FALSE)) { - cadaver = make_corpse(mtmp, burycorpse ? - CORPSTAT_BURIED : CORPSTAT_NONE); - if (burycorpse && cadaver && cansee(x,y) && !mtmp->minvis && - cadaver->where == OBJ_BURIED && (dest & 1)) { - pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp))); - } - } - } - if (wasinside) spoteffects(TRUE); /* poor man's expels() */ - /* monster is gone, corpse or other object might now be visible */ - newsym(x, y); + /* illogical but traditional "treasure drop" */ + if (!rn2(6) && !(mvitals[mndx].mvflags & G_NOCORPSE) + /* no extra item from swallower or steed */ + && (x != u.ux || y != u.uy) + /* no extra item from kops--too easy to abuse */ + && mdat->mlet != S_KOP + /* no items from cloned monsters */ + && !mtmp->mcloned) { + otmp = mkobj(RANDOM_CLASS, TRUE); + /* don't create large objects from small monsters */ + otyp = otmp->otyp; + if (mdat->msize < MZ_HUMAN && otyp != FIGURINE && + /* oc_big is also oc_bimanual and oc_bulky */ + (otmp->owt > 30 || objects[otyp].oc_big)) { + delobj(otmp); + } else if (!flooreffects(otmp, x, y, + (dest & 1) ? "fall" : "")) { + place_object(otmp, x, y); + stackobj(otmp); + } + } + /* corpse--none if hero was inside the monster */ + if (!wasinside && corpse_chance(mtmp, (struct monst *)0, FALSE)) { + cadaver = make_corpse(mtmp, burycorpse ? + CORPSTAT_BURIED : CORPSTAT_NONE); + if (burycorpse && cadaver && cansee(x,y) && !mtmp->minvis && + cadaver->where == OBJ_BURIED && (dest & 1)) { + pline("%s corpse ends up buried.", s_suffix(Monnam(mtmp))); + } + } + } + if (wasinside) spoteffects(TRUE); /* poor man's expels() */ + /* monster is gone, corpse or other object might now be visible */ + newsym(x, y); cleanup: - /* punish bad behaviour */ - if(is_human(mdat) && (!always_hostile(mdat) && mtmp->malign <= 0) && - (mndx < PM_ARCHEOLOGIST || mndx > PM_WIZARD) && - u.ualign.type != A_CHAOTIC) { - HTelepat &= ~INTRINSIC; - change_luck(-2); - You("murderer!"); - if (Blind && !Blind_telepat) - see_monsters(); /* Can't sense monsters any more. */ - } - if((mtmp->mpeaceful && !rn2(2)) || mtmp->mtame) change_luck(-1); - if (is_unicorn(mdat) && - sgn(u.ualign.type) == sgn(mdat->maligntyp)) { - change_luck(-5); - You_feel("guilty..."); - } + /* punish bad behaviour */ + if(is_human(mdat) && (!always_hostile(mdat) && mtmp->malign <= 0) && + (mndx < PM_ARCHEOLOGIST || mndx > PM_WIZARD) && + u.ualign.type != A_CHAOTIC) { + HTelepat &= ~INTRINSIC; + change_luck(-2); + You("murderer!"); + if (Blind && !Blind_telepat) + see_monsters(); /* Can't sense monsters any more. */ + } + if((mtmp->mpeaceful && !rn2(2)) || mtmp->mtame) change_luck(-1); + if (is_unicorn(mdat) && + sgn(u.ualign.type) == sgn(mdat->maligntyp)) { + change_luck(-5); + You_feel("guilty..."); + } - /* give experience points */ - tmp = experience(mtmp, (int)mvitals[mndx].died); - more_experienced(tmp, 0); - newexplevel(); /* will decide if you go up */ + /* give experience points */ + tmp = experience(mtmp, (int)mvitals[mndx].died); + more_experienced(tmp, 0); + newexplevel(); /* will decide if you go up */ - /* adjust alignment points */ - if (mtmp->m_id == quest_status.leader_m_id) { /* REAL BAD! */ - adjalign(-(u.ualign.record+(int)ALIGNLIM/2)); - pline("That was %sa bad idea...", - u.uevent.qcompleted ? "probably " : ""); - } else if (mdat->msound == MS_NEMESIS) /* Real good! */ - adjalign((int)(ALIGNLIM/4)); - else if (mdat->msound == MS_GUARDIAN) { /* Bad */ - adjalign(-(int)(ALIGNLIM/8)); - if (!Hallucination) pline("That was probably a bad idea..."); - else pline("Whoopsie-daisy!"); - }else if (mtmp->ispriest) { - adjalign((p_coaligned(mtmp)) ? -2 : 2); - /* cancel divine protection for killing your priest */ - if (p_coaligned(mtmp)) u.ublessed = 0; - if (mdat->maligntyp == A_NONE) - adjalign((int)(ALIGNLIM / 4)); /* BIG bonus */ - } else if (mtmp->mtame) { - adjalign(-15); /* bad!! */ - /* your god is mighty displeased... */ - if (!Hallucination) You_hear("the rumble of distant thunder..."); - else You_hear("the studio audience applaud!"); - } else if (mtmp->mpeaceful) - adjalign(-5); + /* adjust alignment points */ + if (mtmp->m_id == quest_status.leader_m_id) { /* REAL BAD! */ + adjalign(-(u.ualign.record+(int)ALIGNLIM/2)); + pline("That was %sa bad idea...", + u.uevent.qcompleted ? "probably " : ""); + } else if (mdat->msound == MS_NEMESIS) /* Real good! */ + adjalign((int)(ALIGNLIM/4)); + else if (mdat->msound == MS_GUARDIAN) { /* Bad */ + adjalign(-(int)(ALIGNLIM/8)); + if (!Hallucination) pline("That was probably a bad idea..."); + else pline("Whoopsie-daisy!"); + }else if (mtmp->ispriest) { + adjalign((p_coaligned(mtmp)) ? -2 : 2); + /* cancel divine protection for killing your priest */ + if (p_coaligned(mtmp)) u.ublessed = 0; + if (mdat->maligntyp == A_NONE) + adjalign((int)(ALIGNLIM / 4)); /* BIG bonus */ + } else if (mtmp->mtame) { + adjalign(-15); /* bad!! */ + /* your god is mighty displeased... */ + if (!Hallucination) You_hear("the rumble of distant thunder..."); + else You_hear("the studio audience applaud!"); + } else if (mtmp->mpeaceful) + adjalign(-5); - /* malign was already adjusted for u.ualign.type and randomization */ - adjalign(mtmp->malign); + /* malign was already adjusted for u.ualign.type and randomization */ + adjalign(mtmp->malign); } /* changes the monster into a stone monster of the same type */ @@ -2034,44 +2052,44 @@ mon_to_stone(mtmp) register struct monst *mtmp; { if(mtmp->data->mlet == S_GOLEM) { - /* it's a golem, and not a stone golem */ - if(canseemon(mtmp)) - pline("%s solidifies...", Monnam(mtmp)); - if (newcham(mtmp, &mons[PM_STONE_GOLEM], FALSE, FALSE)) { - if(canseemon(mtmp)) - pline("Now it's %s.", an(mtmp->data->mname)); - } else { - if(canseemon(mtmp)) - pline("... and returns to normal."); - } + /* it's a golem, and not a stone golem */ + if(canseemon(mtmp)) + pline("%s solidifies...", Monnam(mtmp)); + if (newcham(mtmp, &mons[PM_STONE_GOLEM], FALSE, FALSE)) { + if(canseemon(mtmp)) + pline("Now it's %s.", an(mtmp->data->mname)); + } else { + if(canseemon(mtmp)) + pline("... and returns to normal."); + } } else - impossible("Can't polystone %s!", a_monnam(mtmp)); + impossible("Can't polystone %s!", a_monnam(mtmp)); } /* might place monst on far side of a wall or boulder */ void mnexto(mtmp) /* Make monster mtmp next to you (if possible) */ - struct monst *mtmp; + struct monst *mtmp; { - coord mm; - boolean couldspot = canspotmon(mtmp); + coord mm; + boolean couldspot = canspotmon(mtmp); - if (mtmp == u.usteed) { - /* Keep your steed in sync with you instead */ - mtmp->mx = u.ux; - mtmp->my = u.uy; - return; - } + if (mtmp == u.usteed) { + /* Keep your steed in sync with you instead */ + mtmp->mx = u.ux; + mtmp->my = u.uy; + return; + } - if(!enexto(&mm, u.ux, u.uy, mtmp->data)) return; - rloc_to(mtmp, mm.x, mm.y); - if (!in_mklev && (mtmp->mstrategy & STRAT_APPEARMSG)) { - mtmp->mstrategy &= ~STRAT_APPEARMSG; /* one chance only */ - if (!couldspot && canspotmon(mtmp)) - pline("%s suddenly %s!", Amonnam(mtmp), - !Blind ? "appears" : "arrives"); - } - return; + if(!enexto(&mm, u.ux, u.uy, mtmp->data)) return; + rloc_to(mtmp, mm.x, mm.y); + if (!in_mklev && (mtmp->mstrategy & STRAT_APPEARMSG)) { + mtmp->mstrategy &= ~STRAT_APPEARMSG; /* one chance only */ + if (!couldspot && canspotmon(mtmp)) + pline("%s suddenly %s!", Amonnam(mtmp), + !Blind ? "appears" : "arrives"); + } + return; } /* like mnexto() but requires destination to be directly accessible */ @@ -2079,20 +2097,20 @@ void maybe_mnexto(mtmp) struct monst *mtmp; { - coord mm; - struct permonst *ptr = mtmp->data; - boolean diagok = !NODIAG(ptr - mons); - int tryct = 20; + coord mm; + struct permonst *ptr = mtmp->data; + boolean diagok = !NODIAG(ptr - mons); + int tryct = 20; - do { - if (!enexto(&mm, u.ux, u.uy, ptr)) return; - if (couldsee(mm.x, mm.y) && - /* don't move grid bugs diagonally */ - (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) { - rloc_to(mtmp, mm.x, mm.y); - return; - } - } while (--tryct > 0); + do { + if (!enexto(&mm, u.ux, u.uy, ptr)) return; + if (couldsee(mm.x, mm.y) && + /* don't move grid bugs diagonally */ + (diagok || mm.x == mtmp->mx || mm.y == mtmp->my)) { + rloc_to(mtmp, mm.x, mm.y); + return; + } + } while (--tryct > 0); } /* mnearto() @@ -2107,41 +2125,41 @@ register struct monst *mtmp; xchar x, y; boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */ { - struct monst *othermon = (struct monst *)0; - xchar newx, newy; - coord mm; + struct monst *othermon = (struct monst *)0; + xchar newx, newy; + coord mm; - if ((mtmp->mx == x) && (mtmp->my == y)) return(FALSE); + if ((mtmp->mx == x) && (mtmp->my == y)) return(FALSE); - if (move_other && (othermon = m_at(x, y))) { - if (othermon->wormno) - remove_worm(othermon); - else - remove_monster(x, y); - } + if (move_other && (othermon = m_at(x, y))) { + if (othermon->wormno) + remove_worm(othermon); + else + remove_monster(x, y); + } - newx = x; - newy = y; + newx = x; + newy = y; - if (!goodpos(newx, newy, mtmp, 0)) { - /* actually we have real problems if enexto ever fails. - * migrating_mons that need to be placed will cause - * no end of trouble. - */ - if (!enexto(&mm, newx, newy, mtmp->data)) return(FALSE); - newx = mm.x; newy = mm.y; - } + if (!goodpos(newx, newy, mtmp, 0)) { + /* actually we have real problems if enexto ever fails. + * migrating_mons that need to be placed will cause + * no end of trouble. + */ + if (!enexto(&mm, newx, newy, mtmp->data)) return(FALSE); + newx = mm.x; newy = mm.y; + } - rloc_to(mtmp, newx, newy); + rloc_to(mtmp, newx, newy); - if (move_other && othermon) { - othermon->mx = othermon->my = 0; - (void) mnearto(othermon, x, y, FALSE); - if ((othermon->mx != x) || (othermon->my != y)) - return(TRUE); - } + if (move_other && othermon) { + othermon->mx = othermon->my = 0; + (void) mnearto(othermon, x, y, FALSE); + if ((othermon->mx != x) || (othermon->my != y)) + return(TRUE); + } - return(FALSE); + return(FALSE); } /* monster responds to player action; not the same as a passive attack */ @@ -2151,26 +2169,26 @@ m_respond(mtmp) register struct monst *mtmp; { if(mtmp->data->msound == MS_SHRIEK) { - if(!Deaf) { - pline("%s shrieks.", Monnam(mtmp)); - stop_occupation(); - } - if (!rn2(10)) { - if (!rn2(13)) - (void) makemon(&mons[PM_PURPLE_WORM], 0, 0, NO_MM_FLAGS); - else - (void) makemon((struct permonst *)0, 0, 0, NO_MM_FLAGS); + if(!Deaf) { + pline("%s shrieks.", Monnam(mtmp)); + stop_occupation(); + } + if (!rn2(10)) { + if (!rn2(13)) + (void) makemon(&mons[PM_PURPLE_WORM], 0, 0, NO_MM_FLAGS); + else + (void) makemon((struct permonst *)0, 0, 0, NO_MM_FLAGS); - } - aggravate(); + } + aggravate(); } if(mtmp->data == &mons[PM_MEDUSA]) { - register int i; - for(i = 0; i < NATTK; i++) - if(mtmp->data->mattk[i].aatyp == AT_GAZE) { - (void) gazemu(mtmp, &mtmp->data->mattk[i]); - break; - } + register int i; + for(i = 0; i < NATTK; i++) + if(mtmp->data->mattk[i].aatyp == AT_GAZE) { + (void) gazemu(mtmp, &mtmp->data->mattk[i]); + break; + } } } @@ -2178,75 +2196,75 @@ void setmangry(mtmp) register struct monst *mtmp; { - mtmp->mstrategy &= ~STRAT_WAITMASK; - if(!mtmp->mpeaceful) return; - if(mtmp->mtame) return; - mtmp->mpeaceful = 0; - if(mtmp->ispriest) { - if(p_coaligned(mtmp)) adjalign(-5); /* very bad */ - else adjalign(2); - } else - adjalign(-1); /* attacking peaceful monsters is bad */ - if (couldsee(mtmp->mx, mtmp->my)) { - if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd) - pline("%s gets angry!", Monnam(mtmp)); - else if (flags.verbose && !Deaf) growl(mtmp); - } + mtmp->mstrategy &= ~STRAT_WAITMASK; + if(!mtmp->mpeaceful) return; + if(mtmp->mtame) return; + mtmp->mpeaceful = 0; + if(mtmp->ispriest) { + if(p_coaligned(mtmp)) adjalign(-5); /* very bad */ + else adjalign(2); + } else + adjalign(-1); /* attacking peaceful monsters is bad */ + if (couldsee(mtmp->mx, mtmp->my)) { + if (humanoid(mtmp->data) || mtmp->isshk || mtmp->isgd) + pline("%s gets angry!", Monnam(mtmp)); + else if (flags.verbose && !Deaf) growl(mtmp); + } - /* attacking your own quest leader will anger his or her guardians */ - if (!context.mon_moving && /* should always be the case here */ - mtmp->data == &mons[quest_info(MS_LEADER)]) { - struct monst *mon; - struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)]; - int got_mad = 0; + /* attacking your own quest leader will anger his or her guardians */ + if (!context.mon_moving && /* should always be the case here */ + mtmp->data == &mons[quest_info(MS_LEADER)]) { + struct monst *mon; + struct permonst *q_guardian = &mons[quest_info(MS_GUARDIAN)]; + int got_mad = 0; - /* guardians will sense this attack even if they can't see it */ - for (mon = fmon; mon; mon = mon->nmon) { - if (DEADMONSTER(mon)) continue; - if (mon->data == q_guardian && mon->mpeaceful) { - mon->mpeaceful = 0; - if (canseemon(mon)) ++got_mad; - } - } - if (got_mad && !Hallucination) - pline_The("%s appear%s to be angry too...", - got_mad == 1 ? q_guardian->mname : - makeplural(q_guardian->mname), - got_mad == 1 ? "s" : ""); - } + /* guardians will sense this attack even if they can't see it */ + for (mon = fmon; mon; mon = mon->nmon) { + if (DEADMONSTER(mon)) continue; + if (mon->data == q_guardian && mon->mpeaceful) { + mon->mpeaceful = 0; + if (canseemon(mon)) ++got_mad; + } + } + if (got_mad && !Hallucination) + pline_The("%s appear%s to be angry too...", + got_mad == 1 ? q_guardian->mname : + makeplural(q_guardian->mname), + got_mad == 1 ? "s" : ""); + } } void wakeup(mtmp) register struct monst *mtmp; { - mtmp->msleeping = 0; - finish_meating(mtmp); - setmangry(mtmp); - if (mtmp->m_ap_type) { - seemimic(mtmp); - } else if (context.forcefight && !context.mon_moving && - mtmp->mundetected) { - mtmp->mundetected = 0; - newsym(mtmp->mx, mtmp->my); - } + mtmp->msleeping = 0; + finish_meating(mtmp); + setmangry(mtmp); + if (mtmp->m_ap_type) { + seemimic(mtmp); + } else if (context.forcefight && !context.mon_moving && + mtmp->mundetected) { + mtmp->mundetected = 0; + newsym(mtmp->mx, mtmp->my); + } } /* Wake up nearby monsters without angering them. */ void wake_nearby() { - register struct monst *mtmp; + register struct monst *mtmp; - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if (distu(mtmp->mx,mtmp->my) < u.ulevel * 20) { - mtmp->msleeping = 0; - mtmp->mstrategy &= ~STRAT_WAITMASK; - if (mtmp->mtame && !mtmp->isminion) - EDOG(mtmp)->whistletime = moves; - } - } + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if (distu(mtmp->mx,mtmp->my) < u.ulevel * 20) { + mtmp->msleeping = 0; + mtmp->mstrategy &= ~STRAT_WAITMASK; + if (mtmp->mtame && !mtmp->isminion) + EDOG(mtmp)->whistletime = moves; + } + } } /* Wake up monsters near some particular location. */ @@ -2254,15 +2272,15 @@ void wake_nearto(x, y, distance) register int x, y, distance; { - register struct monst *mtmp; + register struct monst *mtmp; - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if (distance == 0 || dist2(mtmp->mx, mtmp->my, x, y) < distance) { - mtmp->msleeping = 0; - mtmp->mstrategy &= ~STRAT_WAITMASK; - } - } + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if (distance == 0 || dist2(mtmp->mx, mtmp->my, x, y) < distance) { + mtmp->msleeping = 0; + mtmp->mstrategy &= ~STRAT_WAITMASK; + } + } } /* NOTE: we must check for mimicry before calling this routine */ @@ -2270,67 +2288,67 @@ void seemimic(mtmp) register struct monst *mtmp; { - unsigned old_app = mtmp->mappearance; - uchar old_ap_type = mtmp->m_ap_type; + unsigned old_app = mtmp->mappearance; + uchar old_ap_type = mtmp->m_ap_type; - if (has_mcorpsenm(mtmp)) freemcorpsenm(mtmp); + if (has_mcorpsenm(mtmp)) freemcorpsenm(mtmp); - mtmp->m_ap_type = M_AP_NOTHING; - mtmp->mappearance = 0; + mtmp->m_ap_type = M_AP_NOTHING; + mtmp->mappearance = 0; - /* - * Discovered mimics don't block light. - */ - if (((old_ap_type == M_AP_FURNITURE && - (old_app == S_hcdoor || old_app == S_vcdoor)) || - (old_ap_type == M_AP_OBJECT && old_app == BOULDER)) && - !does_block(mtmp->mx, mtmp->my, &levl[mtmp->mx][mtmp->my])) - unblock_point(mtmp->mx, mtmp->my); + /* + * Discovered mimics don't block light. + */ + if (((old_ap_type == M_AP_FURNITURE && + (old_app == S_hcdoor || old_app == S_vcdoor)) || + (old_ap_type == M_AP_OBJECT && old_app == BOULDER)) && + !does_block(mtmp->mx, mtmp->my, &levl[mtmp->mx][mtmp->my])) + unblock_point(mtmp->mx, mtmp->my); - newsym(mtmp->mx,mtmp->my); + newsym(mtmp->mx,mtmp->my); } /* force all chameleons to become normal */ void rescham() { - register struct monst *mtmp; - int mcham; + register struct monst *mtmp; + int mcham; - for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - mcham = (int) mtmp->cham; - if (mcham >= LOW_PM) { - (void) newcham(mtmp, &mons[mcham], - FALSE, FALSE); - mtmp->cham = NON_PM; - } - if(is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN) - new_were(mtmp); - if(mtmp->m_ap_type && cansee(mtmp->mx, mtmp->my)) { - seemimic(mtmp); - /* we pretend that the mimic doesn't */ - /* know that it has been unmasked. */ - mtmp->msleeping = 1; - } - } + for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + mcham = (int) mtmp->cham; + if (mcham >= LOW_PM) { + (void) newcham(mtmp, &mons[mcham], + FALSE, FALSE); + mtmp->cham = NON_PM; + } + if(is_were(mtmp->data) && mtmp->data->mlet != S_HUMAN) + new_were(mtmp); + if(mtmp->m_ap_type && cansee(mtmp->mx, mtmp->my)) { + seemimic(mtmp); + /* we pretend that the mimic doesn't */ + /* know that it has been unmasked. */ + mtmp->msleeping = 1; + } + } } /* Let the chameleons change again -dgk */ void restartcham() { - register struct monst *mtmp; + register struct monst *mtmp; - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - mtmp->cham = pm_to_cham(monsndx(mtmp->data)); - if (mtmp->data->mlet == S_MIMIC && mtmp->msleeping && - cansee(mtmp->mx, mtmp->my)) { - set_mimic_sym(mtmp); - newsym(mtmp->mx,mtmp->my); - } - } + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + mtmp->cham = pm_to_cham(monsndx(mtmp->data)); + if (mtmp->data->mlet == S_MIMIC && mtmp->msleeping && + cansee(mtmp->mx, mtmp->my)) { + set_mimic_sym(mtmp); + newsym(mtmp->mx,mtmp->my); + } + } } /* called when restoring a monster from a saved level; protection @@ -2340,19 +2358,19 @@ void restore_cham(mon) struct monst *mon; { - int mcham; + int mcham; - if (Protection_from_shape_changers) { - mcham = (int) mon->cham; - if (mcham >= LOW_PM) { - mon->cham = NON_PM; - (void) newcham(mon, &mons[mcham], FALSE, FALSE); - } else if (is_were(mon->data) && !is_human(mon->data)) { - new_were(mon); - } - } else if (mon->cham == NON_PM) { - mon->cham = pm_to_cham(monsndx(mon->data)); - } + if (Protection_from_shape_changers) { + mcham = (int) mon->cham; + if (mcham >= LOW_PM) { + mon->cham = NON_PM; + (void) newcham(mon, &mons[mcham], FALSE, FALSE); + } else if (is_were(mon->data) && !is_human(mon->data)) { + new_were(mon); + } + } else if (mon->cham == NON_PM) { + mon->cham = pm_to_cham(monsndx(mon->data)); + } } /* unwatched hiders may hide again; if so, a 1 is returned. */ @@ -2360,26 +2378,26 @@ STATIC_OVL boolean restrap(mtmp) register struct monst *mtmp; { - struct trap *t; + struct trap *t; - if (mtmp->mcan || mtmp->m_ap_type || - cansee(mtmp->mx, mtmp->my) || rn2(3) || (mtmp == u.ustuck) || - /* can't hide while trapped except in pits */ - (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0 && - !(t->ttyp == PIT || t->ttyp == SPIKED_PIT)) || - (sensemon(mtmp) && distu(mtmp->mx, mtmp->my) <= 2)) - return(FALSE); + if (mtmp->mcan || mtmp->m_ap_type || + cansee(mtmp->mx, mtmp->my) || rn2(3) || (mtmp == u.ustuck) || + /* can't hide while trapped except in pits */ + (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0 && + !(t->ttyp == PIT || t->ttyp == SPIKED_PIT)) || + (sensemon(mtmp) && distu(mtmp->mx, mtmp->my) <= 2)) + return(FALSE); - if(mtmp->data->mlet == S_MIMIC) { - set_mimic_sym(mtmp); - return(TRUE); - } else - if(levl[mtmp->mx][mtmp->my].typ == ROOM) { - mtmp->mundetected = 1; - return(TRUE); - } + if(mtmp->data->mlet == S_MIMIC) { + set_mimic_sym(mtmp); + return(TRUE); + } else + if(levl[mtmp->mx][mtmp->my].typ == ROOM) { + mtmp->mundetected = 1; + return(TRUE); + } - return(FALSE); + return(FALSE); } /* monster/hero tries to hide under something at the current location */ @@ -2387,33 +2405,33 @@ boolean hideunder(mtmp) struct monst *mtmp; { - struct trap *t; - boolean undetected = FALSE, - is_u = (mtmp == &youmonst); - xchar x = is_u ? u.ux : mtmp->mx, - y = is_u ? u.uy : mtmp->my; + struct trap *t; + boolean undetected = FALSE, + is_u = (mtmp == &youmonst); + xchar x = is_u ? u.ux : mtmp->mx, + y = is_u ? u.uy : mtmp->my; - if (mtmp == u.ustuck) { - ; /* can't hide if holding you or held by you */ - } else if (is_u ? (u.utrap && u.utraptype != TT_PIT) : - (mtmp->mtrapped && (t = t_at(x, y)) != 0 && - !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))) { - ; /* can't hide while stuck in a non-pit trap */ - } else if (mtmp->data->mlet == S_EEL) { - undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz)); - } else if (hides_under(mtmp->data) && OBJ_AT(x, y)) { - struct obj *otmp = level.objects[x][y]; + if (mtmp == u.ustuck) { + ; /* can't hide if holding you or held by you */ + } else if (is_u ? (u.utrap && u.utraptype != TT_PIT) : + (mtmp->mtrapped && (t = t_at(x, y)) != 0 && + !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))) { + ; /* can't hide while stuck in a non-pit trap */ + } else if (mtmp->data->mlet == S_EEL) { + undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz)); + } else if (hides_under(mtmp->data) && OBJ_AT(x, y)) { + struct obj *otmp = level.objects[x][y]; - /* most monsters won't hide under cockatrice corpse */ - if (otmp->nexthere || otmp->otyp != CORPSE || - (mtmp == &youmonst ? Stone_resistance : resists_ston(mtmp)) || - !touch_petrifies(&mons[otmp->corpsenm])) - undetected = TRUE; - } + /* most monsters won't hide under cockatrice corpse */ + if (otmp->nexthere || otmp->otyp != CORPSE || + (mtmp == &youmonst ? Stone_resistance : resists_ston(mtmp)) || + !touch_petrifies(&mons[otmp->corpsenm])) + undetected = TRUE; + } - if (is_u) u.uundetected = undetected; - else mtmp->mundetected = undetected; - return undetected; + if (is_u) u.uundetected = undetected; + else mtmp->mundetected = undetected; + return undetected; } /* called when returning to a previously visited level */ @@ -2424,17 +2442,17 @@ struct monst *mon; boolean hider_under = hides_under(mon->data) || mon->data->mlet == S_EEL; if ((is_hider(mon->data) || hider_under) && - !(mon->mundetected || mon->m_ap_type)) { - xchar x = mon->mx, y = mon->my; - char save_viz = viz_array[y][x]; + !(mon->mundetected || mon->m_ap_type)) { + xchar x = mon->mx, y = mon->my; + char save_viz = viz_array[y][x]; - /* override vision, forcing hero to be unable to see monster's spot */ - viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE); - if (is_hider(mon->data)) (void)restrap(mon); - /* try again if mimic missed its 1/3 chance to hide */ - if (mon->data->mlet == S_MIMIC && !mon->m_ap_type) (void)restrap(mon); - if (hider_under) (void)hideunder(mon); - viz_array[y][x] = save_viz; + /* override vision, forcing hero to be unable to see monster's spot */ + viz_array[y][x] &= ~(IN_SIGHT | COULD_SEE); + if (is_hider(mon->data)) (void)restrap(mon); + /* try again if mimic missed its 1/3 chance to hide */ + if (mon->data->mlet == S_MIMIC && !mon->m_ap_type) (void)restrap(mon); + if (hider_under) (void)hideunder(mon); + viz_array[y][x] = save_viz; } } @@ -2445,33 +2463,33 @@ void mon_animal_list(construct) boolean construct; { - if (construct) { - short animal_temp[SPECIAL_PM]; - int i, n; + if (construct) { + short animal_temp[SPECIAL_PM]; + int i, n; - /* if (animal_list) impossible("animal_list already exists"); */ + /* if (animal_list) impossible("animal_list already exists"); */ - for (n = 0, i = LOW_PM; i < SPECIAL_PM; i++) - if (is_animal(&mons[i])) animal_temp[n++] = i; - /* if (n == 0) animal_temp[n++] = NON_PM; */ + for (n = 0, i = LOW_PM; i < SPECIAL_PM; i++) + if (is_animal(&mons[i])) animal_temp[n++] = i; + /* if (n == 0) animal_temp[n++] = NON_PM; */ - animal_list = (short *)alloc(n * sizeof *animal_list); - (void) memcpy((genericptr_t)animal_list, - (genericptr_t)animal_temp, - n * sizeof *animal_list); - animal_list_count = n; - } else { /* release */ - if (animal_list) free((genericptr_t)animal_list), animal_list = 0; - animal_list_count = 0; - } + animal_list = (short *)alloc(n * sizeof *animal_list); + (void) memcpy((genericptr_t)animal_list, + (genericptr_t)animal_temp, + n * sizeof *animal_list); + animal_list_count = n; + } else { /* release */ + if (animal_list) free((genericptr_t)animal_list), animal_list = 0; + animal_list_count = 0; + } } STATIC_OVL int pick_animal() { - if (!animal_list) mon_animal_list(TRUE); + if (!animal_list) mon_animal_list(TRUE); - return animal_list[rn2(animal_list_count)]; + return animal_list[rn2(animal_list_count)]; } void @@ -2479,55 +2497,55 @@ decide_to_shapeshift(mon, shiftflags) struct monst *mon; int shiftflags; { - struct permonst *ptr; - unsigned was_female = mon->female; - boolean msg = FALSE; + struct permonst *ptr; + unsigned was_female = mon->female; + boolean msg = FALSE; - if ((shiftflags & SHIFT_MSG) || - ((shiftflags & SHIFT_SEENMSG) && sensemon(mon))) msg = TRUE; + if ((shiftflags & SHIFT_MSG) || + ((shiftflags & SHIFT_SEENMSG) && sensemon(mon))) msg = TRUE; - if (is_vampshifter(mon)) { - /* The vampire has to be in good health (mhp) to maintain - * its shifted form. + if (is_vampshifter(mon)) { + /* The vampire has to be in good health (mhp) to maintain + * its shifted form. * - * If we're shifted and getting low on hp, maybe shift back. - * If we're not already shifted and in good health, maybe shift. - */ - if ((mon->mhp <= mon->mhpmax / 6) && - rn2(4) && (mon->cham >= LOW_PM)) - (void) newcham(mon, &mons[mon->cham], FALSE, msg); - } else if (mon->data->mlet == S_VAMPIRE && mon->cham == NON_PM && - !rn2(6) && (mon->mhp > mon->mhpmax - ((mon->mhpmax / 10) + 1))) { - (void) newcham(mon, (struct permonst *)0, FALSE, msg); - } - /* override the 10% chance for sex change */ - ptr = mon->data; - if (!is_male(ptr) && !is_female(ptr) && !is_neuter(ptr)) - mon->female = was_female; + * If we're shifted and getting low on hp, maybe shift back. + * If we're not already shifted and in good health, maybe shift. + */ + if ((mon->mhp <= mon->mhpmax / 6) && + rn2(4) && (mon->cham >= LOW_PM)) + (void) newcham(mon, &mons[mon->cham], FALSE, msg); + } else if (mon->data->mlet == S_VAMPIRE && mon->cham == NON_PM && + !rn2(6) && (mon->mhp > mon->mhpmax - ((mon->mhpmax / 10) + 1))) { + (void) newcham(mon, (struct permonst *)0, FALSE, msg); + } + /* override the 10% chance for sex change */ + ptr = mon->data; + if (!is_male(ptr) && !is_female(ptr) && !is_neuter(ptr)) + mon->female = was_female; } STATIC_OVL int pickvampshape(mon) struct monst *mon; { - int mndx = mon->cham; + int mndx = mon->cham; - switch (mndx) { - case PM_VLAD_THE_IMPALER: - /* ensure Vlad can keep carrying the Candelabrum */ - if (mon_has_special(mon)) break; /* leave mndx as is */ - /*FALLTHRU*/ - case PM_VAMPIRE_LORD: /* vampire lord or Vlad can become wolf */ - if (!rn2(10)) { - mndx = PM_WOLF; - break; - } - /*FALLTHRU*/ - case PM_VAMPIRE: /* any vampire can become fog or bat */ - mndx = !rn2(4) ? PM_FOG_CLOUD : PM_VAMPIRE_BAT; - break; - } - return mndx; + switch (mndx) { + case PM_VLAD_THE_IMPALER: + /* ensure Vlad can keep carrying the Candelabrum */ + if (mon_has_special(mon)) break; /* leave mndx as is */ + /*FALLTHRU*/ + case PM_VAMPIRE_LORD: /* vampire lord or Vlad can become wolf */ + if (!rn2(10)) { + mndx = PM_WOLF; + break; + } + /*FALLTHRU*/ + case PM_VAMPIRE: /* any vampire can become fog or bat */ + mndx = !rn2(4) ? PM_FOG_CLOUD : PM_VAMPIRE_BAT; + break; + } + return mndx; } /* nonshapechangers who warrant special polymorph handling */ @@ -2535,8 +2553,8 @@ STATIC_OVL boolean isspecmon(mon) struct monst *mon; { - return (mon->isshk || mon->ispriest || mon->isgd || - mon->m_id == quest_status.leader_m_id); + return (mon->isshk || mon->ispriest || mon->isgd || + mon->m_id == quest_status.leader_m_id); } /* restrict certain special monsters (shopkeepers, aligned priests, @@ -2547,19 +2565,19 @@ validspecmon(mon, mndx) struct monst *mon; int mndx; { - if (mndx == NON_PM) return TRUE; /* caller wants random */ + if (mndx == NON_PM) return TRUE; /* caller wants random */ - if (!accept_newcham_form(mndx)) return FALSE; /* geno'd or !polyok */ + if (!accept_newcham_form(mndx)) return FALSE; /* geno'd or !polyok */ - if (isspecmon(mon)) { - struct permonst *ptr = &mons[mndx]; + if (isspecmon(mon)) { + struct permonst *ptr = &mons[mndx]; - /* reject notake because object manipulation is expected - and nohead because speech capability is expected */ - if (notake(ptr) || !has_head(ptr)) return FALSE; - /* [should we check ptr->msound here too?] */ - } - return TRUE; /* potential new form is ok */ + /* reject notake because object manipulation is expected + and nohead because speech capability is expected */ + if (notake(ptr) || !has_head(ptr)) return FALSE; + /* [should we check ptr->msound here too?] */ + } + return TRUE; /* potential new form is ok */ } /* prevent wizard mode user from specifying invalid vampshifter shape */ @@ -2568,138 +2586,138 @@ validvamp(mon, mndx_p, monclass) struct monst *mon; int *mndx_p, monclass; { - /* simplify caller's usage */ - if (!is_vampshifter(mon)) return validspecmon(mon, *mndx_p); + /* simplify caller's usage */ + if (!is_vampshifter(mon)) return validspecmon(mon, *mndx_p); - if (*mndx_p == PM_VAMPIRE || *mndx_p == PM_VAMPIRE_LORD || - *mndx_p == PM_VLAD_THE_IMPALER) { - /* player picked some type of vampire; use mon's self */ - *mndx_p = mon->cham; - return TRUE; - } - if (mon->cham == PM_VLAD_THE_IMPALER && mon_has_special(mon)) { - /* Vlad with Candelabrum; override choice, then accept it */ - *mndx_p = PM_VLAD_THE_IMPALER; - return TRUE; - } - /* basic vampires can't become wolves; any can become fog or bat */ - if (*mndx_p == PM_WOLF) return (mon->cham != PM_VAMPIRE); - if (*mndx_p == PM_FOG_CLOUD || *mndx_p == PM_VAMPIRE_BAT) return TRUE; + if (*mndx_p == PM_VAMPIRE || *mndx_p == PM_VAMPIRE_LORD || + *mndx_p == PM_VLAD_THE_IMPALER) { + /* player picked some type of vampire; use mon's self */ + *mndx_p = mon->cham; + return TRUE; + } + if (mon->cham == PM_VLAD_THE_IMPALER && mon_has_special(mon)) { + /* Vlad with Candelabrum; override choice, then accept it */ + *mndx_p = PM_VLAD_THE_IMPALER; + return TRUE; + } + /* basic vampires can't become wolves; any can become fog or bat */ + if (*mndx_p == PM_WOLF) return (mon->cham != PM_VAMPIRE); + if (*mndx_p == PM_FOG_CLOUD || *mndx_p == PM_VAMPIRE_BAT) return TRUE; - /* if we get here, specific type was no good; try by class */ - switch (monclass) { - case S_VAMPIRE: *mndx_p = mon->cham; break; - case S_BAT: *mndx_p = PM_VAMPIRE_BAT; break; - case S_VORTEX: *mndx_p = PM_FOG_CLOUD; break; - case S_DOG: if (mon->cham != PM_VAMPIRE) { - *mndx_p = PM_WOLF; - break; - } - /*FALLTHRU*/ - default: *mndx_p = NON_PM; break; - } - return (*mndx_p != NON_PM); + /* if we get here, specific type was no good; try by class */ + switch (monclass) { + case S_VAMPIRE: *mndx_p = mon->cham; break; + case S_BAT: *mndx_p = PM_VAMPIRE_BAT; break; + case S_VORTEX: *mndx_p = PM_FOG_CLOUD; break; + case S_DOG: if (mon->cham != PM_VAMPIRE) { + *mndx_p = PM_WOLF; + break; + } + /*FALLTHRU*/ + default: *mndx_p = NON_PM; break; + } + return (*mndx_p != NON_PM); } int select_newcham_form(mon) struct monst *mon; { - int mndx = NON_PM, tryct; + int mndx = NON_PM, tryct; - switch (mon->cham) { - case PM_SANDESTIN: - if (rn2(7)) mndx = pick_nasty(); - break; - case PM_DOPPELGANGER: - if (!rn2(7)) { - mndx = pick_nasty(); - } else if (rn2(3)) { /* role monsters */ - mndx = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, - PM_ARCHEOLOGIST); - } else if (!rn2(3)) { /* quest guardians */ - mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, - PM_STUDENT); - /* avoid own role's guardian */ - if (mndx == urole.guardnum) mndx = NON_PM; - } else { /* general humanoids */ - tryct = 5; - do { - mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM); - if (humanoid(&mons[mndx]) && polyok(&mons[mndx])) break; - } while (--tryct > 0); - if (!tryct) mndx = NON_PM; - } - break; - case PM_CHAMELEON: - if (!rn2(3)) mndx = pick_animal(); - break; - case PM_VLAD_THE_IMPALER: - case PM_VAMPIRE_LORD: - case PM_VAMPIRE: - mndx = pickvampshape(mon); - break; - case NON_PM: /* ordinary */ - { - struct obj *m_armr = which_armor(mon, W_ARM); + switch (mon->cham) { + case PM_SANDESTIN: + if (rn2(7)) mndx = pick_nasty(); + break; + case PM_DOPPELGANGER: + if (!rn2(7)) { + mndx = pick_nasty(); + } else if (rn2(3)) { /* role monsters */ + mndx = rn1(PM_WIZARD - PM_ARCHEOLOGIST + 1, + PM_ARCHEOLOGIST); + } else if (!rn2(3)) { /* quest guardians */ + mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, + PM_STUDENT); + /* avoid own role's guardian */ + if (mndx == urole.guardnum) mndx = NON_PM; + } else { /* general humanoids */ + tryct = 5; + do { + mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM); + if (humanoid(&mons[mndx]) && polyok(&mons[mndx])) break; + } while (--tryct > 0); + if (!tryct) mndx = NON_PM; + } + break; + case PM_CHAMELEON: + if (!rn2(3)) mndx = pick_animal(); + break; + case PM_VLAD_THE_IMPALER: + case PM_VAMPIRE_LORD: + case PM_VAMPIRE: + mndx = pickvampshape(mon); + break; + case NON_PM: /* ordinary */ + { + struct obj *m_armr = which_armor(mon, W_ARM); - if (m_armr && Is_dragon_scales(m_armr)) - mndx = (int)(Dragon_scales_to_pm(m_armr) - mons); - else if (m_armr && Is_dragon_mail(m_armr)) - mndx = (int)(Dragon_mail_to_pm(m_armr) - mons); - } - break; - } - /* for debugging: allow control of polymorphed monster */ - if (wizard && iflags.mon_polycontrol) { - char pprompt[BUFSZ], buf[BUFSZ]; - int monclass; + if (m_armr && Is_dragon_scales(m_armr)) + mndx = (int)(Dragon_scales_to_pm(m_armr) - mons); + else if (m_armr && Is_dragon_mail(m_armr)) + mndx = (int)(Dragon_mail_to_pm(m_armr) - mons); + } + break; + } + /* for debugging: allow control of polymorphed monster */ + if (wizard && iflags.mon_polycontrol) { + char pprompt[BUFSZ], buf[BUFSZ]; + int monclass; - Sprintf(pprompt, - "Change %s @ <%d,%d> into what kind of monster?", - noit_mon_nam(mon), (int)mon->mx, (int)mon->my); - tryct = 5; - do { - monclass = 0; - getlin(pprompt, buf); - mungspaces(buf); - /* for ESC, take form selected above (might be NON_PM) */ - if (*buf == '\033') break; - /* for "*", use NON_PM to pick an arbitrary shape below */ - if (!strcmp(buf, "*") || !strcmp(buf, "random")) { - mndx = NON_PM; - break; - } - mndx = name_to_mon(buf); - if (mndx == NON_PM) { - /* didn't get a type, so check whether it's a class - (single letter or text match with def_monsyms[]) */ - monclass = name_to_monclass(buf, &mndx); - if (monclass && mndx == NON_PM) - mndx = mkclass_poly(monclass); - } - if (mndx >= LOW_PM) { - /* got a specific type of monster; use it if we can */ - if (validvamp(mon, &mndx, monclass)) break; - /* can't; revert to random in case we exhaust tryct */ - mndx = NON_PM; - } + Sprintf(pprompt, + "Change %s @ <%d,%d> into what kind of monster?", + noit_mon_nam(mon), (int)mon->mx, (int)mon->my); + tryct = 5; + do { + monclass = 0; + getlin(pprompt, buf); + mungspaces(buf); + /* for ESC, take form selected above (might be NON_PM) */ + if (*buf == '\033') break; + /* for "*", use NON_PM to pick an arbitrary shape below */ + if (!strcmp(buf, "*") || !strcmp(buf, "random")) { + mndx = NON_PM; + break; + } + mndx = name_to_mon(buf); + if (mndx == NON_PM) { + /* didn't get a type, so check whether it's a class + (single letter or text match with def_monsyms[]) */ + monclass = name_to_monclass(buf, &mndx); + if (monclass && mndx == NON_PM) + mndx = mkclass_poly(monclass); + } + if (mndx >= LOW_PM) { + /* got a specific type of monster; use it if we can */ + if (validvamp(mon, &mndx, monclass)) break; + /* can't; revert to random in case we exhaust tryct */ + mndx = NON_PM; + } - pline("It can't become that."); - } while (--tryct > 0); - if (!tryct) pline1(thats_enough_tries); - if (is_vampshifter(mon) && !validvamp(mon, &mndx, monclass)) - mndx = pickvampshape(mon); /* don't resort to arbitrary */ - } + pline("It can't become that."); + } while (--tryct > 0); + if (!tryct) pline1(thats_enough_tries); + if (is_vampshifter(mon) && !validvamp(mon, &mndx, monclass)) + mndx = pickvampshape(mon); /* don't resort to arbitrary */ + } - /* if no form was specified above, pick one at random now */ - if (mndx == NON_PM) { - tryct = 50; - do { - mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM); - } while (--tryct > 0 && !validspecmon(mon, mndx)); - } - return mndx; + /* if no form was specified above, pick one at random now */ + if (mndx == NON_PM) { + tryct = 50; + do { + mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM); + } while (--tryct > 0 && !validspecmon(mon, mndx)); + } + return mndx; } /* this used to be inline within newcham() but monpolycontrol needs it too */ @@ -2707,18 +2725,18 @@ STATIC_OVL struct permonst * accept_newcham_form(mndx) int mndx; { - struct permonst *mdat; + struct permonst *mdat; - if (mndx == NON_PM) return 0; - mdat = &mons[mndx]; - if ((mvitals[mndx].mvflags & G_GENOD) != 0) return 0; - if (is_placeholder(mdat)) return 0; - /* select_newcham_form() might deliberately pick a player - character type (random selection never does) which - polyok() rejects, so we need a special case here */ - if (is_mplayer(mdat)) return mdat; - /* polyok() rules out M2_PNAME, M2_WERE, and all humans except Kops */ - return polyok(mdat) ? mdat : 0; + if (mndx == NON_PM) return 0; + mdat = &mons[mndx]; + if ((mvitals[mndx].mvflags & G_GENOD) != 0) return 0; + if (is_placeholder(mdat)) return 0; + /* select_newcham_form() might deliberately pick a player + character type (random selection never does) which + polyok() rejects, so we need a special case here */ + if (is_mplayer(mdat)) return mdat; + /* polyok() rules out M2_PNAME, M2_WERE, and all humans except Kops */ + return polyok(mdat) ? mdat : 0; } /* make a chameleon take on another shape, or a polymorph target @@ -2731,185 +2749,185 @@ struct permonst *mdat; boolean polyspot; /* change is the result of wand or spell of polymorph */ boolean msg; /* "The oldmon turns into a newmon!" */ { - int hpn, hpd; - int mndx, tryct; - struct permonst *olddata = mtmp->data; - char oldname[BUFSZ], newname[BUFSZ]; + int hpn, hpd; + int mndx, tryct; + struct permonst *olddata = mtmp->data; + char oldname[BUFSZ], newname[BUFSZ]; - /* Riders are immune to polymorph and green slime */ - if (is_rider(mtmp->data)) return 0; + /* Riders are immune to polymorph and green slime */ + if (is_rider(mtmp->data)) return 0; - if (msg) { - /* like Monnam() but never mention saddle */ - Strcpy(oldname, x_monnam(mtmp, ARTICLE_THE, (char *)0, - SUPPRESS_SADDLE, FALSE)); - oldname[0] = highc(oldname[0]); - } + if (msg) { + /* like Monnam() but never mention saddle */ + Strcpy(oldname, x_monnam(mtmp, ARTICLE_THE, (char *)0, + SUPPRESS_SADDLE, FALSE)); + oldname[0] = highc(oldname[0]); + } - /* mdat = 0 -> caller wants a random monster shape */ - if (mdat == 0) { - /* select_newcham_form() loops when resorting to random but - it doesn't always pick that so we still retry here too */ - tryct = 20; - do { - mndx = select_newcham_form(mtmp); - mdat = accept_newcham_form(mndx); - if (mdat) break; - } while (--tryct > 0); - if (!tryct) return 0; - } else if (mvitals[monsndx(mdat)].mvflags & G_GENOD) - return(0); /* passed in mdat is genocided */ + /* mdat = 0 -> caller wants a random monster shape */ + if (mdat == 0) { + /* select_newcham_form() loops when resorting to random but + it doesn't always pick that so we still retry here too */ + tryct = 20; + do { + mndx = select_newcham_form(mtmp); + mdat = accept_newcham_form(mndx); + if (mdat) break; + } while (--tryct > 0); + if (!tryct) return 0; + } else if (mvitals[monsndx(mdat)].mvflags & G_GENOD) + return(0); /* passed in mdat is genocided */ - if(is_male(mdat)) { - if(mtmp->female) mtmp->female = FALSE; - } else if (is_female(mdat)) { - if(!mtmp->female) mtmp->female = TRUE; - } else if (!is_neuter(mdat)) { - if(!rn2(10)) mtmp->female = !mtmp->female; - } + if(is_male(mdat)) { + if(mtmp->female) mtmp->female = FALSE; + } else if (is_female(mdat)) { + if(!mtmp->female) mtmp->female = TRUE; + } else if (!is_neuter(mdat)) { + if(!rn2(10)) mtmp->female = !mtmp->female; + } - if (In_endgame(&u.uz) && is_mplayer(olddata) && has_mname(mtmp)) { - /* mplayers start out as "Foo the Bar", but some of the - * titles are inappropriate when polymorphed, particularly - * into the opposite sex. players don't use ranks when - * polymorphed, so dropping the rank for mplayers seems - * reasonable. - */ - char *p = index(MNAME(mtmp), ' '); - if (p) { - *p = '\0'; - } - } + if (In_endgame(&u.uz) && is_mplayer(olddata) && has_mname(mtmp)) { + /* mplayers start out as "Foo the Bar", but some of the + * titles are inappropriate when polymorphed, particularly + * into the opposite sex. players don't use ranks when + * polymorphed, so dropping the rank for mplayers seems + * reasonable. + */ + char *p = index(MNAME(mtmp), ' '); + if (p) { + *p = '\0'; + } + } - if(mdat == mtmp->data) return(0); /* still the same monster */ + if(mdat == mtmp->data) return(0); /* still the same monster */ - if(mtmp->wormno) { /* throw tail away */ - wormgone(mtmp); - place_monster(mtmp, mtmp->mx, mtmp->my); - } - if (mtmp->m_ap_type && mdat->mlet != S_MIMIC) - seemimic(mtmp); /* revert to normal monster */ + if(mtmp->wormno) { /* throw tail away */ + wormgone(mtmp); + place_monster(mtmp, mtmp->mx, mtmp->my); + } + if (mtmp->m_ap_type && mdat->mlet != S_MIMIC) + seemimic(mtmp); /* revert to normal monster */ - /* (this code used to try to adjust the monster's health based on - a normal one of its type but there are too many special cases - which need to handled in order to do that correctly, so just - give the new form the same proportion of HP as its old one had) */ - hpn = mtmp->mhp; - hpd = mtmp->mhpmax; - /* set level and hit points */ - newmonhp(mtmp, monsndx(mdat)); - /* new hp: same fraction of max as before */ + /* (this code used to try to adjust the monster's health based on + a normal one of its type but there are too many special cases + which need to handled in order to do that correctly, so just + give the new form the same proportion of HP as its old one had) */ + hpn = mtmp->mhp; + hpd = mtmp->mhpmax; + /* set level and hit points */ + newmonhp(mtmp, monsndx(mdat)); + /* new hp: same fraction of max as before */ #ifndef LINT - mtmp->mhp = (int)(((long)hpn * (long)mtmp->mhp) / (long)hpd); + mtmp->mhp = (int)(((long)hpn * (long)mtmp->mhp) / (long)hpd); #endif - /* sanity check (potentional overflow) */ - if (mtmp->mhp < 0 || mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; - /* unlikely but not impossible; a 1HD creature with 1HP that changes - into a 0HD creature will require this statement */ - if (!mtmp->mhp) mtmp->mhp = 1; + /* sanity check (potentional overflow) */ + if (mtmp->mhp < 0 || mtmp->mhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; + /* unlikely but not impossible; a 1HD creature with 1HP that changes + into a 0HD creature will require this statement */ + if (!mtmp->mhp) mtmp->mhp = 1; - /* take on the new form... */ - set_mon_data(mtmp, mdat, 0); + /* take on the new form... */ + set_mon_data(mtmp, mdat, 0); - if (emits_light(olddata) != emits_light(mtmp->data)) { - /* used to give light, now doesn't, or vice versa, - or light's range has changed */ - if (emits_light(olddata)) - del_light_source(LS_MONSTER, monst_to_any(mtmp)); - if (emits_light(mtmp->data)) - new_light_source(mtmp->mx, mtmp->my, emits_light(mtmp->data), - LS_MONSTER, monst_to_any(mtmp)); - } - if (!mtmp->perminvis || pm_invisible(olddata)) - mtmp->perminvis = pm_invisible(mdat); - mtmp->minvis = mtmp->invis_blkd ? 0 : mtmp->perminvis; - if (mtmp->mundetected) (void) hideunder(mtmp); - if (u.ustuck == mtmp) { - if(u.uswallow) { - if(!attacktype(mdat,AT_ENGL)) { - /* Does mdat care? */ - if (!noncorporeal(mdat) && !amorphous(mdat) && - !is_whirly(mdat) && - (mdat != &mons[PM_YELLOW_LIGHT])) { - You("break out of %s%s!", mon_nam(mtmp), - (is_animal(mdat)? - "'s stomach" : "")); - mtmp->mhp = 1; /* almost dead */ - } - expels(mtmp, olddata, FALSE); - } else { - /* update swallow glyphs for new monster */ - swallowed(0); - } - } else if (!sticks(mdat) && !sticks(youmonst.data)) - unstuck(mtmp); - } + if (emits_light(olddata) != emits_light(mtmp->data)) { + /* used to give light, now doesn't, or vice versa, + or light's range has changed */ + if (emits_light(olddata)) + del_light_source(LS_MONSTER, monst_to_any(mtmp)); + if (emits_light(mtmp->data)) + new_light_source(mtmp->mx, mtmp->my, emits_light(mtmp->data), + LS_MONSTER, monst_to_any(mtmp)); + } + if (!mtmp->perminvis || pm_invisible(olddata)) + mtmp->perminvis = pm_invisible(mdat); + mtmp->minvis = mtmp->invis_blkd ? 0 : mtmp->perminvis; + if (mtmp->mundetected) (void) hideunder(mtmp); + if (u.ustuck == mtmp) { + if(u.uswallow) { + if(!attacktype(mdat,AT_ENGL)) { + /* Does mdat care? */ + if (!noncorporeal(mdat) && !amorphous(mdat) && + !is_whirly(mdat) && + (mdat != &mons[PM_YELLOW_LIGHT])) { + You("break out of %s%s!", mon_nam(mtmp), + (is_animal(mdat)? + "'s stomach" : "")); + mtmp->mhp = 1; /* almost dead */ + } + expels(mtmp, olddata, FALSE); + } else { + /* update swallow glyphs for new monster */ + swallowed(0); + } + } else if (!sticks(mdat) && !sticks(youmonst.data)) + unstuck(mtmp); + } #ifndef DCC30_BUG - if (mdat == &mons[PM_LONG_WORM] && (mtmp->wormno = get_wormno()) != 0) { + if (mdat == &mons[PM_LONG_WORM] && (mtmp->wormno = get_wormno()) != 0) { #else - /* DICE 3.0 doesn't like assigning and comparing mtmp->wormno in the - * same expression. - */ - if (mdat == &mons[PM_LONG_WORM] && - (mtmp->wormno = get_wormno(), mtmp->wormno != 0)) { + /* DICE 3.0 doesn't like assigning and comparing mtmp->wormno in the + * same expression. + */ + if (mdat == &mons[PM_LONG_WORM] && + (mtmp->wormno = get_wormno(), mtmp->wormno != 0)) { #endif - /* we can now create worms with tails - 11/91 */ - initworm(mtmp, rn2(5)); - if (count_wsegs(mtmp)) - place_worm_tail_randomly(mtmp, mtmp->mx, mtmp->my); - } + /* we can now create worms with tails - 11/91 */ + initworm(mtmp, rn2(5)); + if (count_wsegs(mtmp)) + place_worm_tail_randomly(mtmp, mtmp->mx, mtmp->my); + } - newsym(mtmp->mx,mtmp->my); + newsym(mtmp->mx,mtmp->my); - if (msg) { - char *save_mname = 0; + if (msg) { + char *save_mname = 0; - if (has_mname(mtmp)) { - save_mname = MNAME(mtmp); - MNAME(mtmp) = (char *)0; - } - Strcpy(newname, - (mdat == &mons[PM_GREEN_SLIME]) ? "slime" : - x_monnam(mtmp, ARTICLE_A, (char *)0,SUPPRESS_SADDLE, FALSE)); - if (!strcmpi(oldname,"it") && !strcmpi(newname,"it")) - (void) usmellmon(mdat); - else - pline("%s turns into %s!", oldname, newname); - if (save_mname) MNAME(mtmp) = save_mname; - } + if (has_mname(mtmp)) { + save_mname = MNAME(mtmp); + MNAME(mtmp) = (char *)0; + } + Strcpy(newname, + (mdat == &mons[PM_GREEN_SLIME]) ? "slime" : + x_monnam(mtmp, ARTICLE_A, (char *)0,SUPPRESS_SADDLE, FALSE)); + if (!strcmpi(oldname,"it") && !strcmpi(newname,"it")) + (void) usmellmon(mdat); + else + pline("%s turns into %s!", oldname, newname); + if (save_mname) MNAME(mtmp) = save_mname; + } - possibly_unwield(mtmp, polyspot); /* might lose use of weapon */ - mon_break_armor(mtmp, polyspot); - if (!(mtmp->misc_worn_check & W_ARMG)) - mselftouch(mtmp, "No longer petrify-resistant, ", - !context.mon_moving); - m_dowear(mtmp, FALSE); + possibly_unwield(mtmp, polyspot); /* might lose use of weapon */ + mon_break_armor(mtmp, polyspot); + if (!(mtmp->misc_worn_check & W_ARMG)) + mselftouch(mtmp, "No longer petrify-resistant, ", + !context.mon_moving); + m_dowear(mtmp, FALSE); - /* This ought to re-test can_carry() on each item in the inventory - * rather than just checking ex-giants & boulders, but that'd be - * pretty expensive to perform. If implemented, then perhaps - * minvent should be sorted in order to drop heaviest items first. - */ - /* former giants can't continue carrying boulders */ - if (mtmp->minvent && !throws_rocks(mdat)) { - register struct obj *otmp, *otmp2; + /* This ought to re-test can_carry() on each item in the inventory + * rather than just checking ex-giants & boulders, but that'd be + * pretty expensive to perform. If implemented, then perhaps + * minvent should be sorted in order to drop heaviest items first. + */ + /* former giants can't continue carrying boulders */ + if (mtmp->minvent && !throws_rocks(mdat)) { + register struct obj *otmp, *otmp2; - for (otmp = mtmp->minvent; otmp; otmp = otmp2) { - otmp2 = otmp->nobj; - if (otmp->otyp == BOULDER) { - /* this keeps otmp from being polymorphed in the - same zap that the monster that held it is polymorphed */ - if (polyspot) bypass_obj(otmp); - obj_extract_self(otmp); - /* probably ought to give some "drop" message here */ - if (flooreffects(otmp, mtmp->mx, mtmp->my, "")) continue; - place_object(otmp, mtmp->mx, mtmp->my); - } - } - } + for (otmp = mtmp->minvent; otmp; otmp = otmp2) { + otmp2 = otmp->nobj; + if (otmp->otyp == BOULDER) { + /* this keeps otmp from being polymorphed in the + same zap that the monster that held it is polymorphed */ + if (polyspot) bypass_obj(otmp); + obj_extract_self(otmp); + /* probably ought to give some "drop" message here */ + if (flooreffects(otmp, mtmp->mx, mtmp->my, "")) continue; + place_object(otmp, mtmp->mx, mtmp->my); + } + } + } - return(1); + return(1); } /* sometimes an egg will be special */ @@ -2935,9 +2953,9 @@ int mnum; * grow into queen bees. Ditto for [winged-]gargoyles. */ if (mnum == PM_KILLER_BEE || mnum == PM_GARGOYLE || - (lays_eggs(&mons[mnum]) && (BREEDER_EGG || - (mnum != PM_QUEEN_BEE && mnum != PM_WINGED_GARGOYLE)))) - return mnum; + (lays_eggs(&mons[mnum]) && (BREEDER_EGG || + (mnum != PM_QUEEN_BEE && mnum != PM_WINGED_GARGOYLE)))) + return mnum; return NON_PM; } @@ -2948,8 +2966,8 @@ int mnum; /* parent monster; caller must handle lays_eggs() check */ boolean force_ordinary; { if (force_ordinary || !BREEDER_EGG) { - if (mnum == PM_QUEEN_BEE) mnum = PM_KILLER_BEE; - else if (mnum == PM_WINGED_GARGOYLE) mnum = PM_GARGOYLE; + if (mnum == PM_QUEEN_BEE) mnum = PM_KILLER_BEE; + else if (mnum == PM_WINGED_GARGOYLE) mnum = PM_GARGOYLE; } return mnum; } @@ -2961,18 +2979,18 @@ dead_species(m_idx, egg) int m_idx; boolean egg; { - /* - * For monsters with both baby and adult forms, genociding either - * form kills all eggs of that monster. Monsters with more than - * two forms (small->large->giant mimics) are more or less ignored; - * fortunately, none of them have eggs. Species extinction due to - * overpopulation does not kill eggs. - */ - return (boolean) - (m_idx >= LOW_PM && - ((mvitals[m_idx].mvflags & G_GENOD) != 0 || - (egg && - (mvitals[big_to_little(m_idx)].mvflags & G_GENOD) != 0))); + /* + * For monsters with both baby and adult forms, genociding either + * form kills all eggs of that monster. Monsters with more than + * two forms (small->large->giant mimics) are more or less ignored; + * fortunately, none of them have eggs. Species extinction due to + * overpopulation does not kill eggs. + */ + return (boolean) + (m_idx >= LOW_PM && + ((mvitals[m_idx].mvflags & G_GENOD) != 0 || + (egg && + (mvitals[big_to_little(m_idx)].mvflags & G_GENOD) != 0))); } /* kill off any eggs of genocided monsters */ @@ -2980,70 +2998,70 @@ STATIC_OVL void kill_eggs(obj_list) struct obj *obj_list; { - struct obj *otmp; + struct obj *otmp; - for (otmp = obj_list; otmp; otmp = otmp->nobj) - if (otmp->otyp == EGG) { - if (dead_species(otmp->corpsenm, TRUE)) { - /* - * It seems we could also just catch this when - * it attempted to hatch, so we wouldn't have to - * search all of the objlists.. or stop all - * hatch timers based on a corpsenm. - */ - kill_egg(otmp); - } + for (otmp = obj_list; otmp; otmp = otmp->nobj) + if (otmp->otyp == EGG) { + if (dead_species(otmp->corpsenm, TRUE)) { + /* + * It seems we could also just catch this when + * it attempted to hatch, so we wouldn't have to + * search all of the objlists.. or stop all + * hatch timers based on a corpsenm. + */ + kill_egg(otmp); + } #if 0 /* not used */ - } else if (otmp->otyp == TIN) { - if (dead_species(otmp->corpsenm, FALSE)) - otmp->corpsenm = NON_PM; /* empty tin */ - } else if (otmp->otyp == CORPSE) { - if (dead_species(otmp->corpsenm, FALSE)) - ; /* not yet implemented... */ + } else if (otmp->otyp == TIN) { + if (dead_species(otmp->corpsenm, FALSE)) + otmp->corpsenm = NON_PM; /* empty tin */ + } else if (otmp->otyp == CORPSE) { + if (dead_species(otmp->corpsenm, FALSE)) + ; /* not yet implemented... */ #endif - } else if (Has_contents(otmp)) { - kill_eggs(otmp->cobj); - } + } else if (Has_contents(otmp)) { + kill_eggs(otmp->cobj); + } } /* kill all members of genocided species */ void kill_genocided_monsters() { - struct monst *mtmp, *mtmp2; - boolean kill_cham; - int mndx; + struct monst *mtmp, *mtmp2; + boolean kill_cham; + int mndx; - /* - * Called during genocide, and again upon level change. The latter - * catches up with any migrating monsters as they finally arrive at - * their intended destinations, so possessions get deposited there. - * - * Chameleon handling: - * 1) if chameleons have been genocided, destroy them - * regardless of current form; - * 2) otherwise, force every chameleon which is imitating - * any genocided species to take on a new form. - */ - for (mtmp = fmon; mtmp; mtmp = mtmp2) { - mtmp2 = mtmp->nmon; - if (DEADMONSTER(mtmp)) continue; - mndx = monsndx(mtmp->data); - kill_cham = (mtmp->cham >= LOW_PM && - (mvitals[mtmp->cham].mvflags & G_GENOD)); - if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham) { - if (mtmp->cham >= LOW_PM && !kill_cham) - (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE); - else - mondead(mtmp); - } - if (mtmp->minvent) kill_eggs(mtmp->minvent); - } + /* + * Called during genocide, and again upon level change. The latter + * catches up with any migrating monsters as they finally arrive at + * their intended destinations, so possessions get deposited there. + * + * Chameleon handling: + * 1) if chameleons have been genocided, destroy them + * regardless of current form; + * 2) otherwise, force every chameleon which is imitating + * any genocided species to take on a new form. + */ + for (mtmp = fmon; mtmp; mtmp = mtmp2) { + mtmp2 = mtmp->nmon; + if (DEADMONSTER(mtmp)) continue; + mndx = monsndx(mtmp->data); + kill_cham = (mtmp->cham >= LOW_PM && + (mvitals[mtmp->cham].mvflags & G_GENOD)); + if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham) { + if (mtmp->cham >= LOW_PM && !kill_cham) + (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE); + else + mondead(mtmp); + } + if (mtmp->minvent) kill_eggs(mtmp->minvent); + } - kill_eggs(invent); - kill_eggs(fobj); - kill_eggs(migrating_objs); - kill_eggs(level.buriedobjlist); + kill_eggs(invent); + kill_eggs(fobj); + kill_eggs(migrating_objs); + kill_eggs(level.buriedobjlist); } void @@ -3054,25 +3072,25 @@ int damtype, dam; int heal = 0, slow = 0; if (mon->data == &mons[PM_FLESH_GOLEM]) { - if (damtype == AD_ELEC) heal = dam / 6; - else if (damtype == AD_FIRE || damtype == AD_COLD) slow = 1; + if (damtype == AD_ELEC) heal = dam / 6; + else if (damtype == AD_FIRE || damtype == AD_COLD) slow = 1; } else if (mon->data == &mons[PM_IRON_GOLEM]) { - if (damtype == AD_ELEC) slow = 1; - else if (damtype == AD_FIRE) heal = dam; + if (damtype == AD_ELEC) slow = 1; + else if (damtype == AD_FIRE) heal = dam; } else { - return; + return; } if (slow) { - if (mon->mspeed != MSLOW) - mon_adjust_speed(mon, -1, (struct obj *)0); + if (mon->mspeed != MSLOW) + mon_adjust_speed(mon, -1, (struct obj *)0); } if (heal) { - if (mon->mhp < mon->mhpmax) { - mon->mhp += dam; - if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax; - if (cansee(mon->mx, mon->my)) - pline("%s seems healthier.", Monnam(mon)); - } + if (mon->mhp < mon->mhpmax) { + mon->mhp += dam; + if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax; + if (cansee(mon->mx, mon->my)) + pline("%s seems healthier.", Monnam(mon)); + } } } @@ -3080,55 +3098,55 @@ boolean angry_guards(silent) register boolean silent; { - register struct monst *mtmp; - register int ct = 0, nct = 0, sct = 0, slct = 0; + register struct monst *mtmp; + register int ct = 0, nct = 0, sct = 0, slct = 0; - for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if((mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) - && mtmp->mpeaceful) { - ct++; - if(cansee(mtmp->mx, mtmp->my) && mtmp->mcanmove) { - if (distu(mtmp->mx, mtmp->my) == 2) nct++; - else sct++; - } - if (mtmp->msleeping || mtmp->mfrozen) { - slct++; - mtmp->msleeping = mtmp->mfrozen = 0; - } - mtmp->mpeaceful = 0; - } - } - if(ct) { - if(!silent) { /* do we want pline msgs? */ - if(slct) pline_The("guard%s wake%s up!", - slct > 1 ? "s" : "", slct == 1 ? "s" : ""); - if(nct || sct) { - if(nct) pline_The("guard%s get%s angry!", - nct == 1 ? "" : "s", nct == 1 ? "s" : ""); - else if(!Blind) - You_see("%sangry guard%s approaching!", - sct == 1 ? "an " : "", sct > 1 ? "s" : ""); - } else - You_hear("the shrill sound of a guard's whistle."); - } - return(TRUE); - } - return(FALSE); + for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if((mtmp->data == &mons[PM_WATCHMAN] || + mtmp->data == &mons[PM_WATCH_CAPTAIN]) + && mtmp->mpeaceful) { + ct++; + if(cansee(mtmp->mx, mtmp->my) && mtmp->mcanmove) { + if (distu(mtmp->mx, mtmp->my) == 2) nct++; + else sct++; + } + if (mtmp->msleeping || mtmp->mfrozen) { + slct++; + mtmp->msleeping = mtmp->mfrozen = 0; + } + mtmp->mpeaceful = 0; + } + } + if(ct) { + if(!silent) { /* do we want pline msgs? */ + if(slct) pline_The("guard%s wake%s up!", + slct > 1 ? "s" : "", slct == 1 ? "s" : ""); + if(nct || sct) { + if(nct) pline_The("guard%s get%s angry!", + nct == 1 ? "" : "s", nct == 1 ? "s" : ""); + else if(!Blind) + You_see("%sangry guard%s approaching!", + sct == 1 ? "an " : "", sct > 1 ? "s" : ""); + } else + You_hear("the shrill sound of a guard's whistle."); + } + return(TRUE); + } + return(FALSE); } void pacify_guards() { - register struct monst *mtmp; + register struct monst *mtmp; - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) continue; - if (mtmp->data == &mons[PM_WATCHMAN] || - mtmp->data == &mons[PM_WATCH_CAPTAIN]) - mtmp->mpeaceful = 1; - } + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) continue; + if (mtmp->data == &mons[PM_WATCHMAN] || + mtmp->data == &mons[PM_WATCH_CAPTAIN]) + mtmp->mpeaceful = 1; + } } void @@ -3136,138 +3154,138 @@ mimic_hit_msg(mtmp, otyp) struct monst *mtmp; short otyp; { - short ap = mtmp->mappearance; + short ap = mtmp->mappearance; - switch(mtmp->m_ap_type) { - case M_AP_NOTHING: - case M_AP_FURNITURE: - case M_AP_MONSTER: - break; - case M_AP_OBJECT: - if (otyp == SPE_HEALING || otyp == SPE_EXTRA_HEALING) { - pline("%s seems a more vivid %s than before.", - The(simple_typename(ap)), - c_obj_colors[objects[ap].oc_color]); - } - break; - } + switch(mtmp->m_ap_type) { + case M_AP_NOTHING: + case M_AP_FURNITURE: + case M_AP_MONSTER: + break; + case M_AP_OBJECT: + if (otyp == SPE_HEALING || otyp == SPE_EXTRA_HEALING) { + pline("%s seems a more vivid %s than before.", + The(simple_typename(ap)), + c_obj_colors[objects[ap].oc_color]); + } + break; + } } boolean usmellmon(mdat) struct permonst *mdat; { - int mndx; - boolean nonspecific = FALSE; - boolean msg_given = FALSE; + int mndx; + boolean nonspecific = FALSE; + boolean msg_given = FALSE; - if (mdat) { - if (!olfaction(youmonst.data)) return FALSE; - mndx = monsndx(mdat); - switch (mndx) { - case PM_ROTHE: - case PM_MINOTAUR: - You("notice a bovine smell."); - msg_given = TRUE; - break; - case PM_CAVEMAN: - case PM_CAVEWOMAN: - case PM_BARBARIAN: - case PM_NEANDERTHAL: - You("smell body odor."); - msg_given = TRUE; - break; + if (mdat) { + if (!olfaction(youmonst.data)) return FALSE; + mndx = monsndx(mdat); + switch (mndx) { + case PM_ROTHE: + case PM_MINOTAUR: + You("notice a bovine smell."); + msg_given = TRUE; + break; + case PM_CAVEMAN: + case PM_CAVEWOMAN: + case PM_BARBARIAN: + case PM_NEANDERTHAL: + You("smell body odor."); + msg_given = TRUE; + break; /* - case PM_PESTILENCE: - case PM_FAMINE: - case PM_DEATH: - break; + case PM_PESTILENCE: + case PM_FAMINE: + case PM_DEATH: + break; */ - case PM_HORNED_DEVIL: - case PM_BALROG: - case PM_ASMODEUS: - case PM_DISPATER: - case PM_YEENOGHU: - case PM_ORCUS: - break; - case PM_HUMAN_WEREJACKAL: - case PM_HUMAN_WERERAT: - case PM_HUMAN_WEREWOLF: - case PM_WEREJACKAL: - case PM_WERERAT: - case PM_WEREWOLF: - case PM_OWLBEAR: - You("detect an odor reminiscent of an animal's den."); - msg_given = TRUE; - break; + case PM_HORNED_DEVIL: + case PM_BALROG: + case PM_ASMODEUS: + case PM_DISPATER: + case PM_YEENOGHU: + case PM_ORCUS: + break; + case PM_HUMAN_WEREJACKAL: + case PM_HUMAN_WERERAT: + case PM_HUMAN_WEREWOLF: + case PM_WEREJACKAL: + case PM_WERERAT: + case PM_WEREWOLF: + case PM_OWLBEAR: + You("detect an odor reminiscent of an animal's den."); + msg_given = TRUE; + break; /* - case PM_PURPLE_WORM: - break; + case PM_PURPLE_WORM: + break; */ - case PM_STEAM_VORTEX: - You("smell steam."); - msg_given = TRUE; - break; - case PM_GREEN_SLIME: - pline("%s stinks.", Something); - msg_given = TRUE; - break; - case PM_VIOLET_FUNGUS: - case PM_SHRIEKER: - You("smell mushrooms."); - msg_given = TRUE; - break; - /* These are here to avoid triggering the - nonspecific treatment through the default case below*/ - case PM_WHITE_UNICORN: - case PM_GRAY_UNICORN: - case PM_BLACK_UNICORN: - case PM_JELLYFISH: - break; - default: - nonspecific = TRUE; - break; - } + case PM_STEAM_VORTEX: + You("smell steam."); + msg_given = TRUE; + break; + case PM_GREEN_SLIME: + pline("%s stinks.", Something); + msg_given = TRUE; + break; + case PM_VIOLET_FUNGUS: + case PM_SHRIEKER: + You("smell mushrooms."); + msg_given = TRUE; + break; + /* These are here to avoid triggering the + nonspecific treatment through the default case below*/ + case PM_WHITE_UNICORN: + case PM_GRAY_UNICORN: + case PM_BLACK_UNICORN: + case PM_JELLYFISH: + break; + default: + nonspecific = TRUE; + break; + } - if (nonspecific) switch(mdat->mlet) { - case S_DOG: - You("notice a dog smell."); - msg_given = TRUE; - break; - case S_DRAGON: - You("smell a dragon!"); - msg_given = TRUE; - break; - case S_FUNGUS: - pline("%s smells moldy.", Something); - msg_given = TRUE; - break; - case S_UNICORN: - You("detect a%s odor reminiscent of a stable.", - (mndx == PM_PONY) ? "n" : " strong"); - msg_given = TRUE; - break; - case S_ZOMBIE: - You("smell rotting flesh."); - msg_given = TRUE; - break; - case S_EEL: - You("smell fish."); - msg_given = TRUE; - break; - case S_ORC: - if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC))) - You("notice an attractive smell."); - else - pline( - "A foul stench makes you feel a little nauseated."); - msg_given = TRUE; - break; - default: - break; - } - } - return (msg_given) ? TRUE : FALSE; + if (nonspecific) switch(mdat->mlet) { + case S_DOG: + You("notice a dog smell."); + msg_given = TRUE; + break; + case S_DRAGON: + You("smell a dragon!"); + msg_given = TRUE; + break; + case S_FUNGUS: + pline("%s smells moldy.", Something); + msg_given = TRUE; + break; + case S_UNICORN: + You("detect a%s odor reminiscent of a stable.", + (mndx == PM_PONY) ? "n" : " strong"); + msg_given = TRUE; + break; + case S_ZOMBIE: + You("smell rotting flesh."); + msg_given = TRUE; + break; + case S_EEL: + You("smell fish."); + msg_given = TRUE; + break; + case S_ORC: + if (maybe_polyd(is_orc(youmonst.data), Race_if(PM_ORC))) + You("notice an attractive smell."); + else + pline( + "A foul stench makes you feel a little nauseated."); + msg_given = TRUE; + break; + default: + break; + } + } + return (msg_given) ? TRUE : FALSE; } /*mon.c*/ diff --git a/src/monst.c b/src/monst.c index 2d2dbc5d1..791cd57c5 100644 --- a/src/monst.c +++ b/src/monst.c @@ -1820,7 +1820,7 @@ struct permonst _mons2[] = { * Puddings */ MON("gray ooze", S_PUDDING, - LVL(3, 1, 8, 0, 0), (G_GENO|2), + LVL(3, 1, 8, 0, 0), (G_GENO|G_NOCORPSE|2), A(ATTK(AT_BITE, AD_RUST, 2, 8), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(500, 250, MS_SILENT, MZ_MEDIUM), @@ -1829,7 +1829,7 @@ struct permonst _mons2[] = { M1_MINDLESS|M1_OMNIVORE|M1_ACID, M2_HOSTILE|M2_NEUTER, 0, CLR_GRAY), MON("brown pudding", S_PUDDING, - LVL(5, 3, 8, 0, 0), (G_GENO|1), + LVL(5, 3, 8, 0, 0), (G_GENO|G_NOCORPSE|1), A(ATTK(AT_BITE, AD_DCAY, 0, 0), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(500, 250, MS_SILENT, MZ_MEDIUM), @@ -1838,7 +1838,7 @@ struct permonst _mons2[] = { M1_MINDLESS|M1_OMNIVORE|M1_ACID, M2_HOSTILE|M2_NEUTER, 0, CLR_BROWN), MON("green slime", S_PUDDING, - LVL(6, 6, 6, 0, 0), (G_HELL|G_GENO|1), + LVL(6, 6, 6, 0, 0), (G_HELL|G_GENO|G_NOCORPSE|1), A(ATTK(AT_TUCH, AD_SLIM, 1, 4), ATTK(AT_NONE, AD_SLIM, 0, 0), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(400, 150, MS_SILENT, MZ_LARGE), @@ -1847,7 +1847,7 @@ struct permonst _mons2[] = { M1_MINDLESS|M1_OMNIVORE|M1_ACID|M1_POIS, M2_HOSTILE|M2_NEUTER, 0, CLR_GREEN), MON("black pudding", S_PUDDING, - LVL(10, 6, 6, 0, 0), (G_GENO|1), + LVL(10, 6, 6, 0, 0), (G_GENO|G_NOCORPSE|1), A(ATTK(AT_BITE, AD_CORR, 3, 8), ATTK(AT_NONE, AD_CORR, 0, 0), NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK), SIZ(900, 250, MS_SILENT, MZ_LARGE), diff --git a/src/objects.c b/src/objects.c index fdf018a14..d64649519 100644 --- a/src/objects.c +++ b/src/objects.c @@ -1,5 +1,4 @@ -/* NetHack 3.5 objects.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ -/* NetHack 3.5 objects.c $Date: 2011/07/28 04:00:20 $ $Revision: 1.23 $ */ +/* NetHack 3.5 objects.c $NHDT-Date: 1428802519 2015/04/12 01:35:19 $ $NHDT-Branch: master $:$NHDT-Revision: 1.34 $ */ /* Copyright (c) Mike Threepoint, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -374,9 +373,9 @@ ARMOR("splint mail", (char *)0, ARMOR("banded mail", (char *)0, 1, 0, 1, 0, 72, 5, 350, 90, 4, 1, ARM_SUIT, IRON, HI_METAL), ARMOR("dwarvish mithril-coat", (char *)0, - 1, 0, 0, 0, 10, 1, 150, 240, 4, 2, ARM_SUIT, MITHRIL, HI_METAL), + 1, 0, 0, 0, 10, 1, 150, 240, 4, 2, ARM_SUIT, MITHRIL, HI_SILVER), ARMOR("elven mithril-coat", (char *)0, - 1, 0, 0, 0, 15, 1, 150, 240, 5, 2, ARM_SUIT, MITHRIL, HI_METAL), + 1, 0, 0, 0, 15, 1, 150, 240, 5, 2, ARM_SUIT, MITHRIL, HI_SILVER), ARMOR("chain mail", (char *)0, 1, 0, 0, 0, 72, 5, 300, 75, 5, 1, ARM_SUIT, IRON, HI_METAL), ARMOR("orcish chain mail", "crude chain mail", @@ -670,11 +669,18 @@ FOOD("egg", 85, 1, 1, 1, FLESH, 80, CLR_WHITE), FOOD("meatball", 0, 1, 1, 0, FLESH, 5, CLR_BROWN), FOOD("meat stick", 0, 1, 1, 0, FLESH, 5, CLR_BROWN), FOOD("huge chunk of meat", 0,20,400, 0, FLESH,2000, CLR_BROWN), + /* special case because it's not mergable */ OBJECT(OBJ("meat ring", (char *)0), BITS(1,0,0,0,0,0,0,0,0,0,0,0,FLESH), 0, FOOD_CLASS, 0, 1, 5, 1, 0, 0, 0, 0, 5, CLR_BROWN), +/* pudding 'corpses' will turn into these and combine */ +FOOD("glob of gray ooze", 0, 2, 20, 0, FLESH, 20, CLR_GRAY), +FOOD("glob of brown pudding", 0, 2, 20, 0, FLESH, 20, CLR_BROWN), +FOOD("glob of green slime", 0, 2, 20, 0, FLESH, 20, CLR_GREEN), +FOOD("glob of black pudding", 0, 2, 20, 0, FLESH, 20, CLR_BLACK), + /* fruits & veggies */ FOOD("kelp frond", 0, 1, 1, 0, VEGGY, 30, CLR_GREEN), FOOD("eucalyptus leaf", 3, 1, 1, 0, VEGGY, 30, CLR_GREEN), diff --git a/src/objnam.c b/src/objnam.c index 1f9930803..3c5580c0d 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,5 +1,4 @@ -/* NetHack 3.5 objnam.c $NHDT-Date: 1428196817 2015/04/05 01:20:17 $ $NHDT-Branch: nhmall-booktribute $:$NHDT-Revision: 1.120 $ */ -/* NetHack 3.5 objnam.c $Date: 2011/10/27 02:24:54 $ $Revision: 1.101 $ */ +/* NetHack 3.5 objnam.c $NHDT-Date: 1426470349 2015/03/16 01:45:49 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.108 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -17,14 +16,14 @@ STATIC_DCL void FDECL(releaseobuf, (char *)); STATIC_DCL char *FDECL(minimal_xname, (struct obj *)); STATIC_DCL void FDECL(add_erosion_words, (struct obj *, char *)); STATIC_DCL boolean FDECL(singplur_lookup, (char *,char *,BOOLEAN_P, - const char *const *)); + const char *const *)); STATIC_DCL char *FDECL(singplur_compound, (char *)); STATIC_DCL char *FDECL(xname_flags, (struct obj *, unsigned)); struct Jitem { - int item; - const char *name; + int item; + const char *name; }; #define BSTRCMPI(base,ptr,str) ((ptr) < base || strcmpi((ptr),str)) @@ -33,26 +32,26 @@ struct Jitem { /* true for gems/rocks that should have " stone" appended to their names */ #define GemStone(typ) (typ == FLINT || \ - (objects[typ].oc_material == GEMSTONE && \ - (typ != DILITHIUM_CRYSTAL && typ != RUBY && \ - typ != DIAMOND && typ != SAPPHIRE && \ - typ != BLACK_OPAL && \ - typ != EMERALD && typ != OPAL))) + (objects[typ].oc_material == GEMSTONE && \ + (typ != DILITHIUM_CRYSTAL && typ != RUBY && \ + typ != DIAMOND && typ != SAPPHIRE && \ + typ != BLACK_OPAL && \ + typ != EMERALD && typ != OPAL))) STATIC_OVL struct Jitem Japanese_items[] = { - { SHORT_SWORD, "wakizashi" }, - { BROADSWORD, "ninja-to" }, - { FLAIL, "nunchaku" }, - { GLAIVE, "naginata" }, - { LOCK_PICK, "osaku" }, - { WOODEN_HARP, "koto" }, - { KNIFE, "shito" }, - { PLATE_MAIL, "tanko" }, - { HELMET, "kabuto" }, - { LEATHER_GLOVES, "yugake" }, - { FOOD_RATION, "gunyoki" }, - { POT_BOOZE, "sake" }, - {0, "" } + { SHORT_SWORD, "wakizashi" }, + { BROADSWORD, "ninja-to" }, + { FLAIL, "nunchaku" }, + { GLAIVE, "naginata" }, + { LOCK_PICK, "osaku" }, + { WOODEN_HARP, "koto" }, + { KNIFE, "shito" }, + { PLATE_MAIL, "tanko" }, + { HELMET, "kabuto" }, + { LEATHER_GLOVES, "yugake" }, + { FOOD_RATION, "gunyoki" }, + { POT_BOOZE, "sake" }, + {0, "" } }; STATIC_DCL const char *FDECL(Japanese_item_name,(int i)); @@ -62,15 +61,15 @@ strprepend(s,pref) register char *s; register const char *pref; { - register int i = (int)strlen(pref); + register int i = (int)strlen(pref); - if(i > PREFIX) { - impossible("PREFIX too short (for %d).", i); - return(s); - } - s -= i; - (void) strncpy(s, pref, i); /* do not copy trailing 0 */ - return(s); + if(i > PREFIX) { + impossible("PREFIX too short (for %d).", i); + return(s); + } + s -= i; + (void) strncpy(s, pref, i); /* do not copy trailing 0 */ + return(s); } /* manage a pool of BUFSZ buffers, so callers don't have to */ @@ -80,8 +79,8 @@ static int obufidx = 0; STATIC_OVL char * nextobuf() { - obufidx = (obufidx + 1) % NUMOBUF; - return obufs[obufidx]; + obufidx = (obufidx + 1) % NUMOBUF; + return obufs[obufidx]; } /* put the most recently allocated buffer back if possible */ @@ -89,85 +88,85 @@ STATIC_OVL void releaseobuf(bufp) char *bufp; { - /* caller may not know whether bufp is the most recently allocated - buffer; if it isn't, do nothing */ - if (bufp == obufs[obufidx]) - obufidx = (obufidx - 1 + NUMOBUF) % NUMOBUF; + /* caller may not know whether bufp is the most recently allocated + buffer; if it isn't, do nothing */ + if (bufp == obufs[obufidx]) + obufidx = (obufidx - 1 + NUMOBUF) % NUMOBUF; } char * obj_typename(otyp) register int otyp; { - char *buf = nextobuf(); - register struct objclass *ocl = &objects[otyp]; - register const char *actualn = OBJ_NAME(*ocl); - register const char *dn = OBJ_DESCR(*ocl); - register const char *un = ocl->oc_uname; - register int nn = ocl->oc_name_known; + char *buf = nextobuf(); + register struct objclass *ocl = &objects[otyp]; + register const char *actualn = OBJ_NAME(*ocl); + register const char *dn = OBJ_DESCR(*ocl); + register const char *un = ocl->oc_uname; + register int nn = ocl->oc_name_known; - if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp)) - actualn = Japanese_item_name(otyp); - switch(ocl->oc_class) { - case COIN_CLASS: - Strcpy(buf, "coin"); - break; - case POTION_CLASS: - Strcpy(buf, "potion"); - break; - case SCROLL_CLASS: - Strcpy(buf, "scroll"); - break; - case WAND_CLASS: - Strcpy(buf, "wand"); - break; - case SPBOOK_CLASS: - Strcpy(buf, "spellbook"); - break; - case RING_CLASS: - Strcpy(buf, "ring"); - break; - case AMULET_CLASS: - if(nn) - Strcpy(buf,actualn); - else - Strcpy(buf,"amulet"); - if(un) - Sprintf(eos(buf)," called %s",un); - if(dn) - Sprintf(eos(buf)," (%s)",dn); - return(buf); - default: - if(nn) { - Strcpy(buf, actualn); - if (GemStone(otyp)) - Strcat(buf, " stone"); - if(un) - Sprintf(eos(buf), " called %s", un); - if(dn) - Sprintf(eos(buf), " (%s)", dn); - } else { - Strcpy(buf, dn ? dn : actualn); - if(ocl->oc_class == GEM_CLASS) - Strcat(buf, (ocl->oc_material == MINERAL) ? - " stone" : " gem"); - if(un) - Sprintf(eos(buf), " called %s", un); - } - return(buf); - } - /* here for ring/scroll/potion/wand */ - if(nn) { - if (ocl->oc_unique) - Strcpy(buf, actualn); /* avoid spellbook of Book of the Dead */ - else - Sprintf(eos(buf), " of %s", actualn); - } - if(un) - Sprintf(eos(buf), " called %s", un); - if(dn) - Sprintf(eos(buf), " (%s)", dn); - return(buf); + if (Role_if(PM_SAMURAI) && Japanese_item_name(otyp)) + actualn = Japanese_item_name(otyp); + switch(ocl->oc_class) { + case COIN_CLASS: + Strcpy(buf, "coin"); + break; + case POTION_CLASS: + Strcpy(buf, "potion"); + break; + case SCROLL_CLASS: + Strcpy(buf, "scroll"); + break; + case WAND_CLASS: + Strcpy(buf, "wand"); + break; + case SPBOOK_CLASS: + Strcpy(buf, "spellbook"); + break; + case RING_CLASS: + Strcpy(buf, "ring"); + break; + case AMULET_CLASS: + if(nn) + Strcpy(buf,actualn); + else + Strcpy(buf,"amulet"); + if(un) + Sprintf(eos(buf)," called %s",un); + if(dn) + Sprintf(eos(buf)," (%s)",dn); + return(buf); + default: + if(nn) { + Strcpy(buf, actualn); + if (GemStone(otyp)) + Strcat(buf, " stone"); + if(un) + Sprintf(eos(buf), " called %s", un); + if(dn) + Sprintf(eos(buf), " (%s)", dn); + } else { + Strcpy(buf, dn ? dn : actualn); + if(ocl->oc_class == GEM_CLASS) + Strcat(buf, (ocl->oc_material == MINERAL) ? + " stone" : " gem"); + if(un) + Sprintf(eos(buf), " called %s", un); + } + return(buf); + } + /* here for ring/scroll/potion/wand */ + if(nn) { + if (ocl->oc_unique) + Strcpy(buf, actualn); /* avoid spellbook of Book of the Dead */ + else + Sprintf(eos(buf), " of %s", actualn); + } + if(un) + Sprintf(eos(buf), " called %s", un); + if(dn) + Sprintf(eos(buf), " (%s)", dn); + return(buf); } /* less verbose result than obj_typename(); either the actual name @@ -182,7 +181,7 @@ int otyp; bufp = obj_typename(otyp); objects[otyp].oc_uname = save_uname; if ((pp = strstri(bufp, " (")) != 0) - *pp = '\0'; /* strip the appended description */ + *pp = '\0'; /* strip the appended description */ return bufp; } @@ -192,7 +191,7 @@ register struct obj *obj; { if (!obj->oartifact || !has_oname(obj)) return FALSE; if (!program_state.gameover && !iflags.override_ID) { - if (not_fully_identified(obj)) return FALSE; + if (not_fully_identified(obj)) return FALSE; } return TRUE; } @@ -210,13 +209,13 @@ distant_name(obj, func) register struct obj *obj; char *FDECL((*func), (OBJ_P)); { - char *str; + char *str; - long save_Blinded = Blinded; - Blinded = 1; - str = (*func)(obj); - Blinded = save_Blinded; - return str; + long save_Blinded = Blinded; + Blinded = 1; + str = (*func)(obj); + Blinded = save_Blinded; + return str; } /* convert player specified fruit name into corresponding fruit juice name @@ -229,9 +228,9 @@ boolean juice; /* whether or not to append " juice" to the name */ const char *fruit_nam = strstri(pl_fruit, " of "); if (fruit_nam) - fruit_nam += 4; /* skip past " of " */ + fruit_nam += 4; /* skip past " of " */ else - fruit_nam = pl_fruit; /* use it as is */ + fruit_nam = pl_fruit; /* use it as is */ Sprintf(buf, "%s%s", makesingular(fruit_nam), juice ? " juice" : ""); return buf; @@ -249,288 +248,295 @@ xname_flags(obj, cxn_flags) register struct obj *obj; unsigned cxn_flags; /* bitmask of CXN_xxx values */ { - register char *buf; - register int typ = obj->otyp; - register struct objclass *ocl = &objects[typ]; - int nn = ocl->oc_name_known, omndx = obj->corpsenm; - const char *actualn = OBJ_NAME(*ocl); - const char *dn = OBJ_DESCR(*ocl); - const char *un = ocl->oc_uname; + register char *buf; + register int typ = obj->otyp; + register struct objclass *ocl = &objects[typ]; + int nn = ocl->oc_name_known, omndx = obj->corpsenm; + const char *actualn = OBJ_NAME(*ocl); + const char *dn = OBJ_DESCR(*ocl); + const char *un = ocl->oc_uname; boolean pluralize = (obj->quan != 1L) && !(cxn_flags & CXN_SINGULAR); - boolean known, dknown, bknown; + boolean known, dknown, bknown; - buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */ - if (Role_if(PM_SAMURAI) && Japanese_item_name(typ)) - actualn = Japanese_item_name(typ); + buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */ + if (Role_if(PM_SAMURAI) && Japanese_item_name(typ)) + actualn = Japanese_item_name(typ); - buf[0] = '\0'; - /* - * clean up known when it's tied to oc_name_known, eg after AD_DRIN - * This is only required for unique objects since the article - * printed for the object is tied to the combination of the two - * and printing the wrong article gives away information. - */ - if (!nn && ocl->oc_uses_known && ocl->oc_unique) obj->known = 0; - if (!Blind) obj->dknown = TRUE; - if (Role_if(PM_PRIEST)) obj->bknown = TRUE; + buf[0] = '\0'; + /* + * clean up known when it's tied to oc_name_known, eg after AD_DRIN + * This is only required for unique objects since the article + * printed for the object is tied to the combination of the two + * and printing the wrong article gives away information. + */ + if (!nn && ocl->oc_uses_known && ocl->oc_unique) obj->known = 0; + if (!Blind) obj->dknown = TRUE; + if (Role_if(PM_PRIEST)) obj->bknown = TRUE; - if (iflags.override_ID) { - known = dknown = bknown = TRUE; - nn = 1; - } else { - known = obj->known; - dknown = obj->dknown; - bknown = obj->bknown; - } + if (iflags.override_ID) { + known = dknown = bknown = TRUE; + nn = 1; + } else { + known = obj->known; + dknown = obj->dknown; + bknown = obj->bknown; + } - if (obj_is_pname(obj)) - goto nameit; - switch (obj->oclass) { - case AMULET_CLASS: - if (!dknown) - Strcpy(buf, "amulet"); - else if (typ == AMULET_OF_YENDOR || - typ == FAKE_AMULET_OF_YENDOR) - /* each must be identified individually */ - Strcpy(buf, known ? actualn : dn); - else if (nn) - Strcpy(buf, actualn); - else if (un) - Sprintf(buf,"amulet called %s", un); - else - Sprintf(buf,"%s amulet", dn); - break; - case WEAPON_CLASS: - if (is_poisonable(obj) && obj->opoisoned) - Strcpy(buf, "poisoned "); - case VENOM_CLASS: - case TOOL_CLASS: - if (typ == LENSES) - Strcpy(buf, "pair of "); + if (obj_is_pname(obj)) + goto nameit; + switch (obj->oclass) { + case AMULET_CLASS: + if (!dknown) + Strcpy(buf, "amulet"); + else if (typ == AMULET_OF_YENDOR || + typ == FAKE_AMULET_OF_YENDOR) + /* each must be identified individually */ + Strcpy(buf, known ? actualn : dn); + else if (nn) + Strcpy(buf, actualn); + else if (un) + Sprintf(buf,"amulet called %s", un); + else + Sprintf(buf,"%s amulet", dn); + break; + case WEAPON_CLASS: + if (is_poisonable(obj) && obj->opoisoned) + Strcpy(buf, "poisoned "); + case VENOM_CLASS: + case TOOL_CLASS: + if (typ == LENSES) + Strcpy(buf, "pair of "); - if (!dknown) - Strcat(buf, dn ? dn : actualn); - else if (nn) - Strcat(buf, actualn); - else if (un) { - Strcat(buf, dn ? dn : actualn); - Strcat(buf, " called "); - Strcat(buf, un); - } else - Strcat(buf, dn ? dn : actualn); - /* If we use an() here we'd have to remember never to use */ - /* it whenever calling doname() or xname(). */ - if (typ == FIGURINE && omndx != NON_PM) - Sprintf(eos(buf), " of a%s %s", - index(vowels, *mons[omndx].mname) ? "n" : "", - mons[omndx].mname); - break; - case ARMOR_CLASS: - /* depends on order of the dragon scales objects */ - if (typ >= GRAY_DRAGON_SCALES && typ <= YELLOW_DRAGON_SCALES) { - Sprintf(buf, "set of %s", actualn); - break; - } - if(is_boots(obj) || is_gloves(obj)) Strcpy(buf,"pair of "); + if (!dknown) + Strcat(buf, dn ? dn : actualn); + else if (nn) + Strcat(buf, actualn); + else if (un) { + Strcat(buf, dn ? dn : actualn); + Strcat(buf, " called "); + Strcat(buf, un); + } else + Strcat(buf, dn ? dn : actualn); + /* If we use an() here we'd have to remember never to use */ + /* it whenever calling doname() or xname(). */ + if (typ == FIGURINE && omndx != NON_PM) + Sprintf(eos(buf), " of a%s %s", + index(vowels, *mons[omndx].mname) ? "n" : "", + mons[omndx].mname); + break; + case ARMOR_CLASS: + /* depends on order of the dragon scales objects */ + if (typ >= GRAY_DRAGON_SCALES && typ <= YELLOW_DRAGON_SCALES) { + Sprintf(buf, "set of %s", actualn); + break; + } + if(is_boots(obj) || is_gloves(obj)) Strcpy(buf,"pair of "); - if(obj->otyp >= ELVEN_SHIELD && obj->otyp <= ORCISH_SHIELD - && !dknown) { - Strcpy(buf, "shield"); - break; - } - if(obj->otyp == SHIELD_OF_REFLECTION && !dknown) { - Strcpy(buf, "smooth shield"); - break; - } + if(obj->otyp >= ELVEN_SHIELD && obj->otyp <= ORCISH_SHIELD + && !dknown) { + Strcpy(buf, "shield"); + break; + } + if(obj->otyp == SHIELD_OF_REFLECTION && !dknown) { + Strcpy(buf, "smooth shield"); + break; + } - if(nn) Strcat(buf, actualn); - else if(un) { - if(is_boots(obj)) - Strcat(buf,"boots"); - else if(is_gloves(obj)) - Strcat(buf,"gloves"); - else if(is_cloak(obj)) - Strcpy(buf,"cloak"); - else if(is_helmet(obj)) - Strcpy(buf,"helmet"); - else if(is_shield(obj)) - Strcpy(buf,"shield"); - else - Strcpy(buf,"armor"); - Strcat(buf, " called "); - Strcat(buf, un); - } else Strcat(buf, dn); - break; - case FOOD_CLASS: - if (typ == SLIME_MOLD) { - register struct fruit *f; + if(nn) Strcat(buf, actualn); + else if(un) { + if(is_boots(obj)) + Strcat(buf,"boots"); + else if(is_gloves(obj)) + Strcat(buf,"gloves"); + else if(is_cloak(obj)) + Strcpy(buf,"cloak"); + else if(is_helmet(obj)) + Strcpy(buf,"helmet"); + else if(is_shield(obj)) + Strcpy(buf,"shield"); + else + Strcpy(buf,"armor"); + Strcat(buf, " called "); + Strcat(buf, un); + } else Strcat(buf, dn); + break; + case FOOD_CLASS: + if (typ == SLIME_MOLD) { + register struct fruit *f; - for(f=ffruit; f; f = f->nextf) { - if(f->fid == obj->spe) { - Strcpy(buf, f->fname); - break; - } - } - if (!f) { - impossible("Bad fruit #%d?", obj->spe); - Strcpy(buf, "fruit"); - } else if (pluralize) { - /* ick; already pluralized fruit names - are allowed--we want to try to avoid - adding a redundant plural suffix */ - Strcpy(buf, makeplural(makesingular(buf))); - pluralize = FALSE; - } - break; - } + for(f=ffruit; f; f = f->nextf) { + if(f->fid == obj->spe) { + Strcpy(buf, f->fname); + break; + } + } + if (!f) { + impossible("Bad fruit #%d?", obj->spe); + Strcpy(buf, "fruit"); + } else if (pluralize) { + /* ick; already pluralized fruit names + are allowed--we want to try to avoid + adding a redundant plural suffix */ + Strcpy(buf, makeplural(makesingular(buf))); + pluralize = FALSE; + } + break; + } + if (Is_pudding(obj)) { + Sprintf(buf, "%s%s", + obj->owt < 100 ? "small " + : obj->owt > 500 ? "very large " + : obj->owt > 300 ? "large " + : "", actualn); + break; + } - Strcpy(buf, actualn); - if (typ == TIN && known) - tin_details(obj, omndx, buf); - break; - case COIN_CLASS: - case CHAIN_CLASS: - Strcpy(buf, actualn); - break; - case ROCK_CLASS: - if (typ == STATUE && omndx != NON_PM) - Sprintf(buf, "%s%s of %s%s", - (Role_if(PM_ARCHEOLOGIST) && - (obj->spe & STATUE_HISTORIC)) ? "historic " : "", - actualn, - type_is_pname(&mons[omndx]) ? "" : - the_unique_pm(&mons[omndx]) ? "the " : - index(vowels, *mons[omndx].mname) ? "an " : "a ", - mons[omndx].mname); - else Strcpy(buf, actualn); - break; - case BALL_CLASS: - Sprintf(buf, "%sheavy iron ball", - (obj->owt > ocl->oc_weight) ? "very " : ""); - break; - case POTION_CLASS: - if (dknown && obj->odiluted) - Strcpy(buf, "diluted "); - if(nn || un || !dknown) { - Strcat(buf, "potion"); - if(!dknown) break; - if(nn) { - Strcat(buf, " of "); - if (typ == POT_WATER && - bknown && (obj->blessed || obj->cursed)) { - Strcat(buf, obj->blessed ? "holy " : "unholy "); - } - Strcat(buf, actualn); - } else { - Strcat(buf, " called "); - Strcat(buf, un); - } - } else { - Strcat(buf, dn); - Strcat(buf, " potion"); - } - break; - case SCROLL_CLASS: - Strcpy(buf, "scroll"); - if(!dknown) break; - if(nn) { - Strcat(buf, " of "); - Strcat(buf, actualn); - } else if(un) { - Strcat(buf, " called "); - Strcat(buf, un); - } else if (ocl->oc_magic) { - Strcat(buf, " labeled "); - Strcat(buf, dn); - } else { - Strcpy(buf, dn); - Strcat(buf, " scroll"); - } - break; - case WAND_CLASS: - if(!dknown) - Strcpy(buf, "wand"); - else if(nn) - Sprintf(buf, "wand of %s", actualn); - else if(un) - Sprintf(buf, "wand called %s", un); - else - Sprintf(buf, "%s wand", dn); - break; - case SPBOOK_CLASS: - if (typ == SPE_NOVEL) { /* 3.6 tribute */ - if (!dknown) { - Strcpy(buf, "book"); - } else if (nn) { - Strcpy(buf, actualn); - } else if (un) { - Sprintf(buf, "novel called %s", un); - } else - Sprintf(buf, "%s book", dn); - break; - } else - /* end of tribute */ - if (!dknown) { - Strcpy(buf, "spellbook"); - } else if (nn) { - if (typ != SPE_BOOK_OF_THE_DEAD) - Strcpy(buf, "spellbook of "); - Strcat(buf, actualn); - } else if (un) { - Sprintf(buf, "spellbook called %s", un); - } else - Sprintf(buf, "%s spellbook", dn); - break; - case RING_CLASS: - if(!dknown) - Strcpy(buf, "ring"); - else if(nn) - Sprintf(buf, "ring of %s", actualn); - else if(un) - Sprintf(buf, "ring called %s", un); - else - Sprintf(buf, "%s ring", dn); - break; - case GEM_CLASS: - { - const char *rock = - (ocl->oc_material == MINERAL) ? "stone" : "gem"; - if (!dknown) { - Strcpy(buf, rock); - } else if (!nn) { - if (un) Sprintf(buf,"%s called %s", rock, un); - else Sprintf(buf, "%s %s", dn, rock); - } else { - Strcpy(buf, actualn); - if (GemStone(typ)) Strcat(buf, " stone"); - } - break; - } - default: - Sprintf(buf,"glorkum %d %d %d", obj->oclass, typ, obj->spe); - } - if (pluralize) Strcpy(buf, makeplural(buf)); + Strcpy(buf, actualn); + if (typ == TIN && known) + tin_details(obj, omndx, buf); + break; + case COIN_CLASS: + case CHAIN_CLASS: + Strcpy(buf, actualn); + break; + case ROCK_CLASS: + if (typ == STATUE && omndx != NON_PM) + Sprintf(buf, "%s%s of %s%s", + (Role_if(PM_ARCHEOLOGIST) && + (obj->spe & STATUE_HISTORIC)) ? "historic " : "", + actualn, + type_is_pname(&mons[omndx]) ? "" : + the_unique_pm(&mons[omndx]) ? "the " : + index(vowels, *mons[omndx].mname) ? "an " : "a ", + mons[omndx].mname); + else Strcpy(buf, actualn); + break; + case BALL_CLASS: + Sprintf(buf, "%sheavy iron ball", + (obj->owt > ocl->oc_weight) ? "very " : ""); + break; + case POTION_CLASS: + if (dknown && obj->odiluted) + Strcpy(buf, "diluted "); + if(nn || un || !dknown) { + Strcat(buf, "potion"); + if(!dknown) break; + if(nn) { + Strcat(buf, " of "); + if (typ == POT_WATER && + bknown && (obj->blessed || obj->cursed)) { + Strcat(buf, obj->blessed ? "holy " : "unholy "); + } + Strcat(buf, actualn); + } else { + Strcat(buf, " called "); + Strcat(buf, un); + } + } else { + Strcat(buf, dn); + Strcat(buf, " potion"); + } + break; + case SCROLL_CLASS: + Strcpy(buf, "scroll"); + if(!dknown) break; + if(nn) { + Strcat(buf, " of "); + Strcat(buf, actualn); + } else if(un) { + Strcat(buf, " called "); + Strcat(buf, un); + } else if (ocl->oc_magic) { + Strcat(buf, " labeled "); + Strcat(buf, dn); + } else { + Strcpy(buf, dn); + Strcat(buf, " scroll"); + } + break; + case WAND_CLASS: + if(!dknown) + Strcpy(buf, "wand"); + else if(nn) + Sprintf(buf, "wand of %s", actualn); + else if(un) + Sprintf(buf, "wand called %s", un); + else + Sprintf(buf, "%s wand", dn); + break; + case SPBOOK_CLASS: + if (typ == SPE_NOVEL) { /* 3.6 tribute */ + if (!dknown) + Strcpy(buf, "book"); + else if (nn) + Strcpy(buf, actualn); + else if (un) + Sprintf(buf, "novel called %s", un); + else + Sprintf(buf, "%s book", dn); + break; + /* end of tribute */ + } else if (!dknown) { + Strcpy(buf, "spellbook"); + } else if (nn) { + if (typ != SPE_BOOK_OF_THE_DEAD) + Strcpy(buf, "spellbook of "); + Strcat(buf, actualn); + } else if (un) { + Sprintf(buf, "spellbook called %s", un); + } else + Sprintf(buf, "%s spellbook", dn); + break; + case RING_CLASS: + if(!dknown) + Strcpy(buf, "ring"); + else if(nn) + Sprintf(buf, "ring of %s", actualn); + else if(un) + Sprintf(buf, "ring called %s", un); + else + Sprintf(buf, "%s ring", dn); + break; + case GEM_CLASS: + { + const char *rock = + (ocl->oc_material == MINERAL) ? "stone" : "gem"; + if (!dknown) { + Strcpy(buf, rock); + } else if (!nn) { + if (un) Sprintf(buf,"%s called %s", rock, un); + else Sprintf(buf, "%s %s", dn, rock); + } else { + Strcpy(buf, actualn); + if (GemStone(typ)) Strcat(buf, " stone"); + } + break; + } + default: + Sprintf(buf,"glorkum %d %d %d", obj->oclass, typ, obj->spe); + } + if (pluralize) Strcpy(buf, makeplural(buf)); if (obj->otyp == T_SHIRT && program_state.gameover) { char tmpbuf[BUFSZ]; Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf)); } - if (has_oname(obj) && dknown) { - Strcat(buf, " named "); + if (has_oname(obj) && dknown) { + Strcat(buf, " named "); nameit: - Strcat(buf, ONAME(obj)); - } + Strcat(buf, ONAME(obj)); + } - if (!strncmpi(buf, "the ", 4)) buf += 4; - return(buf); + if (!strncmpi(buf, "the ", 4)) buf += 4; + return(buf); } /* similar to simple_typename but minimal_xname operates on a particular object rather than its general type; it formats the most basic info: - potion -- if description not known - brown potion -- if oc_name_known not set - potion of object detection -- if discovered + potion -- if description not known + brown potion -- if oc_name_known not set + potion of object detection -- if discovered */ static char * minimal_xname(obj) @@ -556,8 +562,8 @@ struct obj *obj; bareobj.dknown = obj->dknown; /* suppress known except for amulets (needed for fakes and real A-of-Y) */ bareobj.known = (obj->oclass == AMULET_CLASS) ? obj->known : - /* default is "on" for types which don't use it */ - !objects[otyp].oc_uses_known; + /* default is "on" for types which don't use it */ + !objects[otyp].oc_uses_known; bareobj.quan = 1L; /* don't want plural */ bareobj.corpsenm = NON_PM; /* suppress statue and figurine details */ bufp = distant_name(&bareobj, xname); /* xname(&bareobj) */ @@ -577,11 +583,11 @@ struct obj *obj; char *onm = xname(obj); if (m_shot.n > 1 && m_shot.o == obj->otyp) { - /* copy xname's result so that we can reuse its return buffer */ - Strcpy(tmpbuf, onm); - /* "the Nth arrow"; value will eventually be passed to an() or - The(), both of which correctly handle this "the " prefix */ - Sprintf(onm, "the %d%s %s", m_shot.i, ordin(m_shot.i), tmpbuf); + /* copy xname's result so that we can reuse its return buffer */ + Strcpy(tmpbuf, onm); + /* "the Nth arrow"; value will eventually be passed to an() or + The(), both of which correctly handle this "the " prefix */ + Sprintf(onm, "the %d%s %s", m_shot.i, ordin(m_shot.i), tmpbuf); } return onm; @@ -595,12 +601,12 @@ register struct obj *obj; { boolean known = (obj->known || iflags.override_ID); if (!obj->dknown && !iflags.override_ID) - return FALSE; + return FALSE; else if (obj->otyp == FAKE_AMULET_OF_YENDOR && !known) - return TRUE; /* lie */ + return TRUE; /* lie */ else - return (boolean)(objects[obj->otyp].oc_unique && - (known || obj->otyp == AMULET_OF_YENDOR)); + return (boolean)(objects[obj->otyp].oc_unique && + (known || obj->otyp == AMULET_OF_YENDOR)); } /* should monster type be prefixed with "the"? (mostly used for corpses) */ @@ -608,22 +614,22 @@ boolean the_unique_pm(ptr) struct permonst *ptr; { - boolean uniq; + boolean uniq; - /* even though monsters with personal names are unique, we want to - describe them as "Name" rather than "the Name" */ - if (type_is_pname(ptr)) return FALSE; + /* even though monsters with personal names are unique, we want to + describe them as "Name" rather than "the Name" */ + if (type_is_pname(ptr)) return FALSE; - uniq = (ptr->geno & G_UNIQ) ? TRUE : FALSE; - /* high priest is unique if it includes "of ", otherwise not - (caller needs to handle the 1st possibility; we assume the 2nd); - worm tail should be irrelevant but is included for completeness */ - if (ptr == &mons[PM_HIGH_PRIEST] || ptr == &mons[PM_LONG_WORM_TAIL]) - uniq = FALSE; - /* Wizard no longer needs this; he's flagged as unique these days */ - if (ptr == &mons[PM_WIZARD_OF_YENDOR]) - uniq = TRUE; - return uniq; + uniq = (ptr->geno & G_UNIQ) ? TRUE : FALSE; + /* high priest is unique if it includes "of ", otherwise not + (caller needs to handle the 1st possibility; we assume the 2nd); + worm tail should be irrelevant but is included for completeness */ + if (ptr == &mons[PM_HIGH_PRIEST] || ptr == &mons[PM_LONG_WORM_TAIL]) + uniq = FALSE; + /* Wizard no longer needs this; he's flagged as unique these days */ + if (ptr == &mons[PM_WIZARD_OF_YENDOR]) + uniq = TRUE; + return uniq; } STATIC_OVL void @@ -631,88 +637,88 @@ add_erosion_words(obj,prefix) struct obj *obj; char *prefix; { - boolean iscrys = (obj->otyp == CRYSKNIFE); - boolean rknown; + boolean iscrys = (obj->otyp == CRYSKNIFE); + boolean rknown; - rknown = (iflags.override_ID == 0) ? obj->rknown : TRUE; + rknown = (iflags.override_ID == 0) ? obj->rknown : TRUE; - if (!is_damageable(obj) && !iscrys) return; + if (!is_damageable(obj) && !iscrys) return; - /* The only cases where any of these bits do double duty are for - * rotted food and diluted potions, which are all not is_damageable(). - */ - if (obj->oeroded && !iscrys) { - switch (obj->oeroded) { - case 2: Strcat(prefix, "very "); break; - case 3: Strcat(prefix, "thoroughly "); break; - } - Strcat(prefix, is_rustprone(obj) ? "rusty " : "burnt "); - } - if (obj->oeroded2 && !iscrys) { - switch (obj->oeroded2) { - case 2: Strcat(prefix, "very "); break; - case 3: Strcat(prefix, "thoroughly "); break; - } - Strcat(prefix, is_corrodeable(obj) ? "corroded " : - "rotted "); - } - if (rknown && obj->oerodeproof) - Strcat(prefix, - iscrys ? "fixed " : - is_rustprone(obj) ? "rustproof " : - is_corrodeable(obj) ? "corrodeproof " : /* "stainless"? */ - is_flammable(obj) ? "fireproof " : ""); + /* The only cases where any of these bits do double duty are for + * rotted food and diluted potions, which are all not is_damageable(). + */ + if (obj->oeroded && !iscrys) { + switch (obj->oeroded) { + case 2: Strcat(prefix, "very "); break; + case 3: Strcat(prefix, "thoroughly "); break; + } + Strcat(prefix, is_rustprone(obj) ? "rusty " : "burnt "); + } + if (obj->oeroded2 && !iscrys) { + switch (obj->oeroded2) { + case 2: Strcat(prefix, "very "); break; + case 3: Strcat(prefix, "thoroughly "); break; + } + Strcat(prefix, is_corrodeable(obj) ? "corroded " : + "rotted "); + } + if (rknown && obj->oerodeproof) + Strcat(prefix, + iscrys ? "fixed " : + is_rustprone(obj) ? "rustproof " : + is_corrodeable(obj) ? "corrodeproof " : /* "stainless"? */ + is_flammable(obj) ? "fireproof " : ""); } char * doname(obj) register struct obj *obj; { - boolean ispoisoned = FALSE; - boolean known, cknown, bknown, lknown; - int omndx = obj->corpsenm; - char prefix[PREFIX]; - char tmpbuf[PREFIX+1]; - /* when we have to add something at the start of prefix instead of the - * end (Strcat is used on the end) - */ - register char *bp = xname(obj); + boolean ispoisoned = FALSE; + boolean known, cknown, bknown, lknown; + int omndx = obj->corpsenm; + char prefix[PREFIX]; + char tmpbuf[PREFIX+1]; + /* when we have to add something at the start of prefix instead of the + * end (Strcat is used on the end) + */ + register char *bp = xname(obj); if (iflags.override_ID) { known = cknown = bknown = lknown = TRUE; } else { - known = obj->known; - cknown = obj->cknown; - bknown = obj->bknown; - lknown = obj->lknown; - } + known = obj->known; + cknown = obj->cknown; + bknown = obj->bknown; + lknown = obj->lknown; + } - /* When using xname, we want "poisoned arrow", and when using - * doname, we want "poisoned +0 arrow". This kludge is about the only - * way to do it, at least until someone overhauls xname() and doname(), - * combining both into one function taking a parameter. - */ - /* must check opoisoned--someone can have a weirdly-named fruit */ - if (!strncmp(bp, "poisoned ", 9) && obj->opoisoned) { - bp += 9; - ispoisoned = TRUE; - } + /* When using xname, we want "poisoned arrow", and when using + * doname, we want "poisoned +0 arrow". This kludge is about the only + * way to do it, at least until someone overhauls xname() and doname(), + * combining both into one function taking a parameter. + */ + /* must check opoisoned--someone can have a weirdly-named fruit */ + if (!strncmp(bp, "poisoned ", 9) && obj->opoisoned) { + bp += 9; + ispoisoned = TRUE; + } - if(obj->quan != 1L) - Sprintf(prefix, "%ld ", obj->quan); - else if (obj->otyp == CORPSE) - /* skip article prefix for corpses [else corpse_xname() - would have to be taught how to strip it off again] */ - *prefix = '\0'; - else if (obj_is_pname(obj) || the_unique_obj(obj)) { - if (!strncmpi(bp, "the ", 4)) - bp += 4; - Strcpy(prefix, "the "); - } else - Strcpy(prefix, "a "); + if(obj->quan != 1L) + Sprintf(prefix, "%ld ", obj->quan); + else if (obj->otyp == CORPSE) + /* skip article prefix for corpses [else corpse_xname() + would have to be taught how to strip it off again] */ + *prefix = '\0'; + else if (obj_is_pname(obj) || the_unique_obj(obj)) { + if (!strncmpi(bp, "the ", 4)) + bp += 4; + Strcpy(prefix, "the "); + } else + Strcpy(prefix, "a "); - /* "empty" goes at the beginning, but item count goes at the end */ - if (cknown && + /* "empty" goes at the beginning, but item count goes at the end */ + if (cknown && /* bag of tricks: include "empty" prefix if it's known to be empty but its precise number of charges isn't known (when that is known, suffix of "(n:0)" will be appended, @@ -722,239 +728,245 @@ register struct obj *obj; (obj->otyp == BAG_OF_TRICKS ? (obj->spe == 0 && !obj->known) : /* not bag of tricks: empty if container which has no contents */ (Is_container(obj) || obj->otyp == STATUE) && !Has_contents(obj))) - Strcat(prefix, "empty "); + Strcat(prefix, "empty "); - if (bknown && - obj->oclass != COIN_CLASS && - (obj->otyp != POT_WATER || !objects[POT_WATER].oc_name_known - || (!obj->cursed && !obj->blessed))) { - /* allow 'blessed clear potion' if we don't know it's holy water; - * always allow "uncursed potion of water" - */ - if (obj->cursed) - Strcat(prefix, "cursed "); - else if (obj->blessed) - Strcat(prefix, "blessed "); - else if ((!known || !objects[obj->otyp].oc_charged || - (obj->oclass == ARMOR_CLASS || - obj->oclass == RING_CLASS)) - /* For most items with charges or +/-, if you know how many - * charges are left or what the +/- is, then you must have - * totally identified the item, so "uncursed" is unneccesary, - * because an identified object not described as "blessed" or - * "cursed" must be uncursed. - * - * If the charges or +/- is not known, "uncursed" must be - * printed to avoid ambiguity between an item whose curse - * status is unknown, and an item known to be uncursed. - */ + if (bknown && + obj->oclass != COIN_CLASS && + (obj->otyp != POT_WATER || !objects[POT_WATER].oc_name_known + || (!obj->cursed && !obj->blessed))) { + /* allow 'blessed clear potion' if we don't know it's holy water; + * always allow "uncursed potion of water" + */ + if (obj->cursed) + Strcat(prefix, "cursed "); + else if (obj->blessed) + Strcat(prefix, "blessed "); + else if ((!known || !objects[obj->otyp].oc_charged || + (obj->oclass == ARMOR_CLASS || + obj->oclass == RING_CLASS)) + /* For most items with charges or +/-, if you know how many + * charges are left or what the +/- is, then you must have + * totally identified the item, so "uncursed" is unneccesary, + * because an identified object not described as "blessed" or + * "cursed" must be uncursed. + * + * If the charges or +/- is not known, "uncursed" must be + * printed to avoid ambiguity between an item whose curse + * status is unknown, and an item known to be uncursed. + */ #ifdef MAIL - && obj->otyp != SCR_MAIL + && obj->otyp != SCR_MAIL #endif - && obj->otyp != FAKE_AMULET_OF_YENDOR - && obj->otyp != AMULET_OF_YENDOR - && !Role_if(PM_PRIEST)) - Strcat(prefix, "uncursed "); - } + && obj->otyp != FAKE_AMULET_OF_YENDOR + && obj->otyp != AMULET_OF_YENDOR + && !Role_if(PM_PRIEST)) + Strcat(prefix, "uncursed "); + } - if (lknown && Is_box(obj)) { - if (obj->obroken) - Strcat(prefix, "unlockable "); - else if (obj->olocked) - Strcat(prefix, "locked "); - else - Strcat(prefix, "unlocked "); - } + if (lknown && Is_box(obj)) { + if (obj->obroken) + Strcat(prefix, "unlockable "); + else if (obj->olocked) + Strcat(prefix, "locked "); + else + Strcat(prefix, "unlocked "); + } - if (obj->greased) Strcat(prefix, "greased "); + if (obj->greased) Strcat(prefix, "greased "); - if (cknown && Has_contents(obj)) { - /* we count all objects (obj->quantity); perhaps we should - count seperate stacks instead (or even introduce a user - preference option to choose between the two alternatives) - since it's somewhat odd so see "containing 1002 items" - when there are 2 scrolls plus 1000 gold pieces */ - long itemcount = count_contents(obj, FALSE, TRUE, TRUE); + if (cknown && Has_contents(obj)) { + /* we count all objects (obj->quantity); perhaps we should + count seperate stacks instead (or even introduce a user + preference option to choose between the two alternatives) + since it's somewhat odd so see "containing 1002 items" + when there are 2 scrolls plus 1000 gold pieces */ + long itemcount = count_contents(obj, FALSE, TRUE, TRUE); - Sprintf(eos(bp), " containing %ld item%s", - itemcount, plur(itemcount)); - } + Sprintf(eos(bp), " containing %ld item%s", + itemcount, plur(itemcount)); + } - switch(obj->oclass) { - case AMULET_CLASS: - if(obj->owornmask & W_AMUL) - Strcat(bp, " (being worn)"); - break; - case WEAPON_CLASS: - if(ispoisoned) - Strcat(prefix, "poisoned "); + switch(obj->oclass) { + case AMULET_CLASS: + if(obj->owornmask & W_AMUL) + Strcat(bp, " (being worn)"); + break; + case WEAPON_CLASS: + if(ispoisoned) + Strcat(prefix, "poisoned "); plus: - add_erosion_words(obj, prefix); - if(known) { - Strcat(prefix, sitoa(obj->spe)); - Strcat(prefix, " "); - } - break; - case ARMOR_CLASS: - if(obj->owornmask & W_ARMOR) - Strcat(bp, (obj == uskin) ? " (embedded in your skin)" : - " (being worn)"); - goto plus; - case TOOL_CLASS: - /* weptools already get this done when we go to the +n code */ - if (!is_weptool(obj)) - add_erosion_words(obj, prefix); - if(obj->owornmask & (W_TOOL /* blindfold */ | W_SADDLE)) { - Strcat(bp, " (being worn)"); - break; - } - if (obj->otyp == LEASH && obj->leashmon != 0) { - Strcat(bp, " (in use)"); - break; - } - if (is_weptool(obj)) - goto plus; - if (obj->otyp == CANDELABRUM_OF_INVOCATION) { - if (!obj->spe) - Strcpy(tmpbuf, "no"); - else - Sprintf(tmpbuf, "%d", obj->spe); - Sprintf(eos(bp), " (%s candle%s%s)", - tmpbuf, plur(obj->spe), - !obj->lamplit ? " attached" : ", lit"); - break; - } else if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || - obj->otyp == BRASS_LANTERN || Is_candle(obj)) { - if (Is_candle(obj) && - obj->age < 20L * (long)objects[obj->otyp].oc_cost) - Strcat(prefix, "partly used "); - if(obj->lamplit) - Strcat(bp, " (lit)"); - break; - } - if(objects[obj->otyp].oc_charged) - goto charges; - break; - case WAND_CLASS: - add_erosion_words(obj, prefix); + add_erosion_words(obj, prefix); + if(known) { + Strcat(prefix, sitoa(obj->spe)); + Strcat(prefix, " "); + } + break; + case ARMOR_CLASS: + if(obj->owornmask & W_ARMOR) + Strcat(bp, (obj == uskin) ? " (embedded in your skin)" : + " (being worn)"); + goto plus; + case TOOL_CLASS: + /* weptools already get this done when we go to the +n code */ + if (!is_weptool(obj)) + add_erosion_words(obj, prefix); + if(obj->owornmask & (W_TOOL /* blindfold */ | W_SADDLE)) { + Strcat(bp, " (being worn)"); + break; + } + if (obj->otyp == LEASH && obj->leashmon != 0) { + Strcat(bp, " (in use)"); + break; + } + if (is_weptool(obj)) + goto plus; + if (obj->otyp == CANDELABRUM_OF_INVOCATION) { + if (!obj->spe) + Strcpy(tmpbuf, "no"); + else + Sprintf(tmpbuf, "%d", obj->spe); + Sprintf(eos(bp), " (%s candle%s%s)", + tmpbuf, plur(obj->spe), + !obj->lamplit ? " attached" : ", lit"); + break; + } else if (obj->otyp == OIL_LAMP || obj->otyp == MAGIC_LAMP || + obj->otyp == BRASS_LANTERN || Is_candle(obj)) { + if (Is_candle(obj) && + obj->age < 20L * (long)objects[obj->otyp].oc_cost) + Strcat(prefix, "partly used "); + if(obj->lamplit) + Strcat(bp, " (lit)"); + break; + } + if(objects[obj->otyp].oc_charged) + goto charges; + break; + case WAND_CLASS: + add_erosion_words(obj, prefix); charges: - if(known) - Sprintf(eos(bp), " (%d:%d)", (int)obj->recharged, obj->spe); - break; - case POTION_CLASS: - if (obj->otyp == POT_OIL && obj->lamplit) - Strcat(bp, " (lit)"); - break; - case RING_CLASS: - add_erosion_words(obj, prefix); + if(known) + Sprintf(eos(bp), " (%d:%d)", (int)obj->recharged, obj->spe); + break; + case POTION_CLASS: + if (obj->otyp == POT_OIL && obj->lamplit) + Strcat(bp, " (lit)"); + break; + case RING_CLASS: + add_erosion_words(obj, prefix); ring: - if(obj->owornmask & W_RINGR) Strcat(bp, " (on right "); - if(obj->owornmask & W_RINGL) Strcat(bp, " (on left "); - if(obj->owornmask & W_RING) { - Strcat(bp, body_part(HAND)); - Strcat(bp, ")"); - } - if(known && objects[obj->otyp].oc_charged) { - Strcat(prefix, sitoa(obj->spe)); - Strcat(prefix, " "); - } - break; - case FOOD_CLASS: - if (obj->oeaten) - Strcat(prefix, "partly eaten "); - if (obj->otyp == CORPSE) { - Sprintf(prefix, "%s ", - corpse_xname(obj, prefix, - CXN_ARTICLE|CXN_NOCORPSE)); - } else if (obj->otyp == EGG) { + if(obj->owornmask & W_RINGR) Strcat(bp, " (on right "); + if(obj->owornmask & W_RINGL) Strcat(bp, " (on left "); + if(obj->owornmask & W_RING) { + Strcat(bp, body_part(HAND)); + Strcat(bp, ")"); + } + if(known && objects[obj->otyp].oc_charged) { + Strcat(prefix, sitoa(obj->spe)); + Strcat(prefix, " "); + } + break; + case FOOD_CLASS: + if (obj->oeaten) + Strcat(prefix, "partly eaten "); + if (obj->otyp == CORPSE) { + Sprintf(prefix, "%s ", + corpse_xname(obj, prefix, + CXN_ARTICLE|CXN_NOCORPSE)); + } else if (obj->otyp == EGG) { #if 0 /* corpses don't tell if they're stale either */ - if (known && stale_egg(obj)) - Strcat(prefix, "stale "); + if (known && stale_egg(obj)) + Strcat(prefix, "stale "); #endif - if (omndx >= LOW_PM && (known || - (mvitals[omndx].mvflags & MV_KNOWS_EGG))) { - Strcat(prefix, mons[omndx].mname); - Strcat(prefix, " "); - if (obj->spe) - Strcat(bp, " (laid by you)"); - } - } - if (obj->otyp == MEAT_RING) goto ring; - break; - case BALL_CLASS: - case CHAIN_CLASS: - add_erosion_words(obj, prefix); - if(obj->owornmask & W_BALL) - Strcat(bp, " (chained to you)"); - break; - } + if (omndx >= LOW_PM && (known || + (mvitals[omndx].mvflags & MV_KNOWS_EGG))) { + Strcat(prefix, mons[omndx].mname); + Strcat(prefix, " "); + if (obj->spe) + Strcat(bp, " (laid by you)"); + } + } + if (obj->otyp == MEAT_RING) goto ring; + break; + case BALL_CLASS: + case CHAIN_CLASS: + add_erosion_words(obj, prefix); + if(obj->owornmask & W_BALL) + Strcat(bp, " (chained to you)"); + break; + } - if((obj->owornmask & W_WEP) && !mrg_to_wielded) { - if (obj->quan != 1L) { - Strcat(bp, " (wielded)"); - } else { - const char *hand_s = body_part(HAND); + if((obj->owornmask & W_WEP) && !mrg_to_wielded) { + if (obj->quan != 1L) { + Strcat(bp, " (wielded)"); + } else { + const char *hand_s = body_part(HAND); - if (bimanual(obj)) hand_s = makeplural(hand_s); - Sprintf(eos(bp), " (weapon in %s)", hand_s); - } - } - if(obj->owornmask & W_SWAPWEP) { - if (u.twoweap) - Sprintf(eos(bp), " (wielded in other %s)", - body_part(HAND)); - else - Strcat(bp, " (alternate weapon; not wielded)"); - } - if(obj->owornmask & W_QUIVER){ - switch(obj->oclass){ - case WEAPON_CLASS: - if(is_ammo(obj)){ - if(objects[obj->otyp].oc_skill == -P_BOW){ - /* Ammo for a bow */ - Strcat(bp, " (in quiver)"); - break; - } else { - /* Ammo not for a bow */ - Strcat(bp, " (in quiver pouch)"); - break; - } - } else { - /* Weapons not considered ammo */ - Strcat(bp, " (at the ready)"); - break; - } + if (bimanual(obj)) hand_s = makeplural(hand_s); + Sprintf(eos(bp), " (weapon in %s)", hand_s); + } + } + if(obj->owornmask & W_SWAPWEP) { + if (u.twoweap) + Sprintf(eos(bp), " (wielded in other %s)", + body_part(HAND)); + else + Strcat(bp, " (alternate weapon; not wielded)"); + } + if(obj->owornmask & W_QUIVER){ + switch(obj->oclass){ + case WEAPON_CLASS: + if(is_ammo(obj)){ + if(objects[obj->otyp].oc_skill == -P_BOW){ + /* Ammo for a bow */ + Strcat(bp, " (in quiver)"); + break; + } else { + /* Ammo not for a bow */ + Strcat(bp, " (in quiver pouch)"); + break; + } + } else { + /* Weapons not considered ammo */ + Strcat(bp, " (at the ready)"); + break; + } - /* Small things and ammo not for a bow */ - case RING_CLASS: - case AMULET_CLASS: - case WAND_CLASS: - case COIN_CLASS: - case GEM_CLASS: - Strcat(bp, " (in quiver pouch)"); - break; - default: /* odd things */ - Strcat(bp, " (at the ready)"); - } - } - if (!iflags.suppress_price && is_unpaid(obj)) { - long quotedprice = unpaid_cost(obj, TRUE); + /* Small things and ammo not for a bow */ + case RING_CLASS: + case AMULET_CLASS: + case WAND_CLASS: + case COIN_CLASS: + case GEM_CLASS: + Strcat(bp, " (in quiver pouch)"); + break; + default: /* odd things */ + Strcat(bp, " (at the ready)"); + } + } + if (!iflags.suppress_price && is_unpaid(obj)) { + long quotedprice = unpaid_cost(obj, TRUE); - Sprintf(eos(bp), " (%s, %ld %s)", - obj->unpaid ? "unpaid" : "contents", - quotedprice, currency(quotedprice)); - } - if (!strncmp(prefix, "a ", 2) && - index(vowels, *(prefix+2) ? *(prefix+2) : *bp) - && (*(prefix+2) || (strncmp(bp, "uranium", 7) - && strncmp(bp, "unicorn", 7) - && strncmp(bp, "eucalyptus", 10)))) { - Strcpy(tmpbuf, prefix); - Strcpy(prefix, "an "); - Strcpy(prefix+3, tmpbuf+2); - } - bp = strprepend(bp, prefix); - return(bp); + Sprintf(eos(bp), " (%s, %ld %s)", + obj->unpaid ? "unpaid" : "contents", + quotedprice, currency(quotedprice)); + } + if (!strncmp(prefix, "a ", 2) && + index(vowels, *(prefix+2) ? *(prefix+2) : *bp) + && (*(prefix+2) || (strncmp(bp, "uranium", 7) + && strncmp(bp, "unicorn", 7) + && strncmp(bp, "eucalyptus", 10)))) { + Strcpy(tmpbuf, prefix); + Strcpy(prefix, "an "); + Strcpy(prefix+3, tmpbuf+2); + } + + /* show weight for items (debug tourist info) + * aum is stolen from Crawl's "Arbitrary Unit of Measure" */ + if (wizard) { + Sprintf(eos(bp), " (%d aum)", obj->owt); + } + bp = strprepend(bp, prefix); + return(bp); } /* used from invent.c */ @@ -967,32 +979,32 @@ register struct obj *otmp; /* check fundamental ID hallmarks first */ if (!otmp->known || !otmp->dknown || #ifdef MAIL - (!otmp->bknown && otmp->otyp != SCR_MAIL) || + (!otmp->bknown && otmp->otyp != SCR_MAIL) || #else - !otmp->bknown || + !otmp->bknown || #endif - !objects[otmp->otyp].oc_name_known) - return TRUE; + !objects[otmp->otyp].oc_name_known) + return TRUE; if ((!otmp->cknown && (Is_container(otmp) || otmp->otyp == STATUE)) || - (!otmp->lknown && Is_box(otmp))) - return TRUE; + (!otmp->lknown && Is_box(otmp))) + return TRUE; if (otmp->oartifact && undiscovered_artifact(otmp->oartifact)) - return TRUE; + return TRUE; /* otmp->rknown is the only item of interest if we reach here */ /* - * Note: if a revision ever allows scrolls to become fireproof or - * rings to become shockproof, this checking will need to be revised. - * `rknown' ID only matters if xname() will provide the info about it. - */ + * Note: if a revision ever allows scrolls to become fireproof or + * rings to become shockproof, this checking will need to be revised. + * `rknown' ID only matters if xname() will provide the info about it. + */ if (otmp->rknown || (otmp->oclass != ARMOR_CLASS && - otmp->oclass != WEAPON_CLASS && - !is_weptool(otmp) && /* (redunant) */ - otmp->oclass != BALL_CLASS)) /* (useless) */ - return FALSE; + otmp->oclass != WEAPON_CLASS && + !is_weptool(otmp) && /* (redunant) */ + otmp->oclass != BALL_CLASS)) /* (useless) */ + return FALSE; else /* lack of `rknown' only matters for vulnerable objects */ - return (boolean)(is_rustprone(otmp) || - is_corrodeable(otmp) || - is_flammable(otmp)); + return (boolean)(is_rustprone(otmp) || + is_corrodeable(otmp) || + is_flammable(otmp)); } char * @@ -1001,81 +1013,81 @@ struct obj *otmp; const char *adjective; unsigned cxn_flags; /* bitmask of CXN_xxx values */ { - char *nambuf = nextobuf(); - int omndx = otmp->corpsenm; - boolean ignore_quan = (cxn_flags & CXN_SINGULAR) != 0, - /* suppress "the" from "the unique monster corpse" */ - no_prefix = (cxn_flags & CXN_NO_PFX) != 0, - /* include "the" for "the woodchuck corpse */ - the_prefix = (cxn_flags & CXN_PFX_THE) != 0, - /* include "an" for "an ogre corpse */ - any_prefix = (cxn_flags & CXN_ARTICLE) != 0, - /* leave off suffix (do_name() appends "corpse" itself) */ - omit_corpse = (cxn_flags & CXN_NOCORPSE) != 0, - possessive = FALSE; - const char *mname; + char *nambuf = nextobuf(); + int omndx = otmp->corpsenm; + boolean ignore_quan = (cxn_flags & CXN_SINGULAR) != 0, + /* suppress "the" from "the unique monster corpse" */ + no_prefix = (cxn_flags & CXN_NO_PFX) != 0, + /* include "the" for "the woodchuck corpse */ + the_prefix = (cxn_flags & CXN_PFX_THE) != 0, + /* include "an" for "an ogre corpse */ + any_prefix = (cxn_flags & CXN_ARTICLE) != 0, + /* leave off suffix (do_name() appends "corpse" itself) */ + omit_corpse = (cxn_flags & CXN_NOCORPSE) != 0, + possessive = FALSE; + const char *mname; - if (omndx == NON_PM) { /* paranoia */ - mname = "thing"; - /* [Possible enhancement: check whether corpse has monster traits - attached in order to use priestname() for priests and minions.] */ - } else if (omndx == PM_ALIGNED_PRIEST) { - /* avoid "aligned priest"; it just exposes internal details */ - mname = "priest"; - } else { - mname = mons[omndx].mname; - if (the_unique_pm(&mons[omndx]) || type_is_pname(&mons[omndx])) { - mname = s_suffix(mname); - possessive = TRUE; - /* don't precede personal name like "Medusa" with an article */ - if (type_is_pname(&mons[omndx])) - no_prefix = TRUE; - /* always precede non-personal unique monster name like - "Oracle" with "the" unless explicitly overridden */ - else if (the_unique_pm(&mons[omndx]) && !no_prefix) - the_prefix = TRUE; - } - } - if (no_prefix) the_prefix = any_prefix = FALSE; - else if (the_prefix) any_prefix = FALSE; /* mutually exclusive */ + if (omndx == NON_PM) { /* paranoia */ + mname = "thing"; + /* [Possible enhancement: check whether corpse has monster traits + attached in order to use priestname() for priests and minions.] */ + } else if (omndx == PM_ALIGNED_PRIEST) { + /* avoid "aligned priest"; it just exposes internal details */ + mname = "priest"; + } else { + mname = mons[omndx].mname; + if (the_unique_pm(&mons[omndx]) || type_is_pname(&mons[omndx])) { + mname = s_suffix(mname); + possessive = TRUE; + /* don't precede personal name like "Medusa" with an article */ + if (type_is_pname(&mons[omndx])) + no_prefix = TRUE; + /* always precede non-personal unique monster name like + "Oracle" with "the" unless explicitly overridden */ + else if (the_unique_pm(&mons[omndx]) && !no_prefix) + the_prefix = TRUE; + } + } + if (no_prefix) the_prefix = any_prefix = FALSE; + else if (the_prefix) any_prefix = FALSE; /* mutually exclusive */ - *nambuf = '\0'; - /* can't use the() the way we use an() below because any capitalized - Name causes it to assume a personal name and return Name as-is; - that's usually the behavior wanted, but here we need to force "the" - to precede capitalized unique monsters (pnames are handled above) */ - if (the_prefix) Strcat(nambuf, "the "); + *nambuf = '\0'; + /* can't use the() the way we use an() below because any capitalized + Name causes it to assume a personal name and return Name as-is; + that's usually the behavior wanted, but here we need to force "the" + to precede capitalized unique monsters (pnames are handled above) */ + if (the_prefix) Strcat(nambuf, "the "); - if (!adjective || !*adjective) { - /* normal case: newt corpse */ - Strcat(nambuf, mname); - } else { - /* adjective positioning depends upon format of monster name */ - if (possessive) /* Medusa's cursed partly eaten corpse */ - Sprintf(eos(nambuf), "%s %s", mname, adjective); - else /* cursed partly eaten troll corpse */ - Sprintf(eos(nambuf), "%s %s", adjective, mname); - /* in case adjective has a trailing space, squeeze it out */ - mungspaces(nambuf); - /* doname() might include a count in the adjective argument; - if so, don't prepend an article */ - if (digit(*adjective)) any_prefix = FALSE; - } + if (!adjective || !*adjective) { + /* normal case: newt corpse */ + Strcat(nambuf, mname); + } else { + /* adjective positioning depends upon format of monster name */ + if (possessive) /* Medusa's cursed partly eaten corpse */ + Sprintf(eos(nambuf), "%s %s", mname, adjective); + else /* cursed partly eaten troll corpse */ + Sprintf(eos(nambuf), "%s %s", adjective, mname); + /* in case adjective has a trailing space, squeeze it out */ + mungspaces(nambuf); + /* doname() might include a count in the adjective argument; + if so, don't prepend an article */ + if (digit(*adjective)) any_prefix = FALSE; + } - if (!omit_corpse) { - Strcat(nambuf, " corpse"); - /* makeplural(nambuf) => append "s" to "corpse" */ - if (otmp->quan > 1L && !ignore_quan) { - Strcat(nambuf, "s"); - any_prefix = FALSE; /* avoid "a newt corpses" */ - } - } + if (!omit_corpse) { + Strcat(nambuf, " corpse"); + /* makeplural(nambuf) => append "s" to "corpse" */ + if (otmp->quan > 1L && !ignore_quan) { + Strcat(nambuf, "s"); + any_prefix = FALSE; /* avoid "a newt corpses" */ + } + } - /* it's safe to overwrite our nambuf after an() has copied - its old value into another buffer */ - if (any_prefix) Strcpy(nambuf, an(nambuf)); + /* it's safe to overwrite our nambuf after an() has copied + its old value into another buffer */ + if (any_prefix) Strcpy(nambuf, an(nambuf)); - return nambuf; + return nambuf; } /* xname doesn't include monster type for "corpse"; cxname does */ @@ -1083,9 +1095,9 @@ char * cxname(obj) struct obj *obj; { - if (obj->otyp == CORPSE) - return corpse_xname(obj, (const char *)0, CXN_NORMAL); - return xname(obj); + if (obj->otyp == CORPSE) + return corpse_xname(obj, (const char *)0, CXN_NORMAL); + return xname(obj); } /* like cxname, but ignores quantity */ @@ -1137,20 +1149,20 @@ struct obj *obj; /* format the object */ if (obj->otyp == CORPSE) { - buf = nextobuf(); - Strcpy(buf, corpse_xname(obj, (const char *)0, CXN_NORMAL)); + buf = nextobuf(); + Strcpy(buf, corpse_xname(obj, (const char *)0, CXN_NORMAL)); } else if (obj->otyp == SLIME_MOLD) { - /* concession to "most unique deaths competition" in the annual - devnull tournament, suppress player supplied fruit names because - those can be used to fake other objects and dungeon features */ - buf = nextobuf(); - Sprintf(buf, "deadly slime mold%s", plur(obj->quan)); + /* concession to "most unique deaths competition" in the annual + devnull tournament, suppress player supplied fruit names because + those can be used to fake other objects and dungeon features */ + buf = nextobuf(); + Sprintf(buf, "deadly slime mold%s", plur(obj->quan)); } else { - buf = xname(obj); + buf = xname(obj); } /* apply an article if appropriate; caller should always use KILLED_BY */ if (obj->quan == 1L && !strstri(buf, "'s ") && !strstri(buf, "s' ")) - buf = (obj_is_pname(obj) || the_unique_obj(obj)) ? the(buf) : an(buf); + buf = (obj_is_pname(obj) || the_unique_obj(obj)) ? the(buf) : an(buf); objects[obj->otyp].oc_name_known = save_ocknown; objects[obj->otyp].oc_uname = save_ocuname; @@ -1170,7 +1182,7 @@ unsigned lenlimit; { struct obj save_obj; char unamebuf[12], onamebuf[12], - *save_oname, *save_uname, *outbuf; + *save_oname, *save_uname, *outbuf; outbuf = (*func)(obj); if ((unsigned)strlen(outbuf) <= lenlimit) return outbuf; @@ -1178,40 +1190,40 @@ unsigned lenlimit; /* shorten called string to fairly small amount */ save_uname = objects[obj->otyp].oc_uname; if (save_uname && strlen(save_uname) >= sizeof unamebuf) { - (void) strncpy(unamebuf, save_uname, sizeof unamebuf - 4); - Strcpy(unamebuf + sizeof unamebuf - 4, "..."); - objects[obj->otyp].oc_uname = unamebuf; - releaseobuf(outbuf); - outbuf = (*func)(obj); - objects[obj->otyp].oc_uname = save_uname; /* restore called string */ - if ((unsigned)strlen(outbuf) <= lenlimit) return outbuf; + (void) strncpy(unamebuf, save_uname, sizeof unamebuf - 4); + Strcpy(unamebuf + sizeof unamebuf - 4, "..."); + objects[obj->otyp].oc_uname = unamebuf; + releaseobuf(outbuf); + outbuf = (*func)(obj); + objects[obj->otyp].oc_uname = save_uname; /* restore called string */ + if ((unsigned)strlen(outbuf) <= lenlimit) return outbuf; } /* shorten named string to fairly small amount */ save_oname = has_oname(obj) ? ONAME(obj) : 0; if (save_oname && strlen(save_oname) >= sizeof onamebuf) { - (void) strncpy(onamebuf, save_oname, sizeof onamebuf - 4); - Strcpy(onamebuf + sizeof onamebuf - 4, "..."); - ONAME(obj) = onamebuf; - releaseobuf(outbuf); - outbuf = (*func)(obj); - ONAME(obj) = save_oname; /* restore named string */ - if ((unsigned)strlen(outbuf) <= lenlimit) return outbuf; + (void) strncpy(onamebuf, save_oname, sizeof onamebuf - 4); + Strcpy(onamebuf + sizeof onamebuf - 4, "..."); + ONAME(obj) = onamebuf; + releaseobuf(outbuf); + outbuf = (*func)(obj); + ONAME(obj) = save_oname; /* restore named string */ + if ((unsigned)strlen(outbuf) <= lenlimit) return outbuf; } /* shorten both called and named strings; unamebuf and onamebuf have both already been populated */ if (save_uname && strlen(save_uname) >= sizeof unamebuf && - save_oname && strlen(save_oname) >= sizeof onamebuf) { - objects[obj->otyp].oc_uname = unamebuf; - ONAME(obj) = onamebuf; - releaseobuf(outbuf); - outbuf = (*func)(obj); - if ((unsigned)strlen(outbuf) <= lenlimit) { - objects[obj->otyp].oc_uname = save_uname; - ONAME(obj) = save_oname; - return outbuf; - } + save_oname && strlen(save_oname) >= sizeof onamebuf) { + objects[obj->otyp].oc_uname = unamebuf; + ONAME(obj) = onamebuf; + releaseobuf(outbuf); + outbuf = (*func)(obj); + if ((unsigned)strlen(outbuf) <= lenlimit) { + objects[obj->otyp].oc_uname = save_uname; + ONAME(obj) = save_oname; + return outbuf; + } } /* still long; strip several name-lengthening attributes; @@ -1222,10 +1234,10 @@ unsigned lenlimit; releaseobuf(outbuf); outbuf = (*func)(obj); if (altfunc && (unsigned)strlen(outbuf) > lenlimit) { - /* still long; use the alternate function (usually one of - the jackets around minimal_xname()) */ - releaseobuf(outbuf); - outbuf = (*altfunc)(obj); + /* still long; use the alternate function (usually one of + the jackets around minimal_xname()) */ + releaseobuf(outbuf); + outbuf = (*altfunc)(obj); } /* restore the object */ *obj = save_obj; @@ -1244,53 +1256,53 @@ singular(otmp, func) register struct obj *otmp; char *FDECL((*func), (OBJ_P)); { - long savequan; - char *nam; + long savequan; + char *nam; - /* using xname for corpses does not give the monster type */ - if (otmp->otyp == CORPSE && func == xname) func = cxname; + /* using xname for corpses does not give the monster type */ + if (otmp->otyp == CORPSE && func == xname) func = cxname; - savequan = otmp->quan; - otmp->quan = 1L; - nam = (*func)(otmp); - otmp->quan = savequan; - return nam; + savequan = otmp->quan; + otmp->quan = 1L; + nam = (*func)(otmp); + otmp->quan = savequan; + return nam; } char * an(str) register const char *str; { - char *buf = nextobuf(); + char *buf = nextobuf(); - buf[0] = '\0'; + buf[0] = '\0'; - if (strncmpi(str, "the ", 4) && - strcmp(str, "molten lava") && - strcmp(str, "iron bars") && - strcmp(str, "ice")) { - if (index(vowels, *str) && - strncmp(str, "one-", 4) && - strncmp(str, "useful", 6) && - strncmp(str, "unicorn", 7) && - strncmp(str, "uranium", 7) && - strncmp(str, "eucalyptus", 10)) - Strcpy(buf, "an "); - else - Strcpy(buf, "a "); - } + if (strncmpi(str, "the ", 4) && + strcmp(str, "molten lava") && + strcmp(str, "iron bars") && + strcmp(str, "ice")) { + if (index(vowels, *str) && + strncmp(str, "one-", 4) && + strncmp(str, "useful", 6) && + strncmp(str, "unicorn", 7) && + strncmp(str, "uranium", 7) && + strncmp(str, "eucalyptus", 10)) + Strcpy(buf, "an "); + else + Strcpy(buf, "a "); + } - Strcat(buf, str); - return buf; + Strcat(buf, str); + return buf; } char * An(str) const char *str; { - register char *tmp = an(str); - *tmp = highc(*tmp); - return tmp; + register char *tmp = an(str); + *tmp = highc(*tmp); + return tmp; } /* @@ -1301,47 +1313,47 @@ char * the(str) const char *str; { - char *buf = nextobuf(); - boolean insert_the = FALSE; + char *buf = nextobuf(); + boolean insert_the = FALSE; - if (!strncmpi(str, "the ", 4)) { - buf[0] = lowc(*str); - Strcpy(&buf[1], str+1); - return buf; - } else if (*str < 'A' || *str > 'Z') { - /* not a proper name, needs an article */ - insert_the = TRUE; - } else { - /* Probably a proper name, might not need an article */ - register char *tmp, *named, *called; - int l; + if (!strncmpi(str, "the ", 4)) { + buf[0] = lowc(*str); + Strcpy(&buf[1], str+1); + return buf; + } else if (*str < 'A' || *str > 'Z') { + /* not a proper name, needs an article */ + insert_the = TRUE; + } else { + /* Probably a proper name, might not need an article */ + register char *tmp, *named, *called; + int l; - /* some objects have capitalized adjectives in their names */ - if(((tmp = rindex(str, ' ')) || (tmp = rindex(str, '-'))) && - (tmp[1] < 'A' || tmp[1] > 'Z')) - insert_the = TRUE; - else if (tmp && index(str, ' ') < tmp) { /* has spaces */ - /* it needs an article if the name contains "of" */ - tmp = strstri(str, " of "); - named = strstri(str, " named "); - called = strstri(str, " called "); - if (called && (!named || called < named)) named = called; + /* some objects have capitalized adjectives in their names */ + if(((tmp = rindex(str, ' ')) || (tmp = rindex(str, '-'))) && + (tmp[1] < 'A' || tmp[1] > 'Z')) + insert_the = TRUE; + else if (tmp && index(str, ' ') < tmp) { /* has spaces */ + /* it needs an article if the name contains "of" */ + tmp = strstri(str, " of "); + named = strstri(str, " named "); + called = strstri(str, " called "); + if (called && (!named || called < named)) named = called; - if (tmp && (!named || tmp < named)) /* found an "of" */ - insert_the = TRUE; - /* stupid special case: lacks "of" but needs "the" */ - else if (!named && (l = strlen(str)) >= 31 && - !strcmp(&str[l - 31], "Platinum Yendorian Express Card")) - insert_the = TRUE; - } - } - if (insert_the) - Strcpy(buf, "the "); - else - buf[0] = '\0'; - Strcat(buf, str); + if (tmp && (!named || tmp < named)) /* found an "of" */ + insert_the = TRUE; + /* stupid special case: lacks "of" but needs "the" */ + else if (!named && (l = strlen(str)) >= 31 && + !strcmp(&str[l - 31], "Platinum Yendorian Express Card")) + insert_the = TRUE; + } + } + if (insert_the) + Strcpy(buf, "the "); + else + buf[0] = '\0'; + Strcat(buf, str); - return buf; + return buf; } char * @@ -1359,19 +1371,19 @@ aobjnam(otmp,verb) register struct obj *otmp; register const char *verb; { - register char *bp = cxname(otmp); - char prefix[PREFIX]; + register char *bp = cxname(otmp); + char prefix[PREFIX]; - if(otmp->quan != 1L) { - Sprintf(prefix, "%ld ", otmp->quan); - bp = strprepend(bp, prefix); - } + if(otmp->quan != 1L) { + Sprintf(prefix, "%ld ", otmp->quan); + bp = strprepend(bp, prefix); + } - if(verb) { - Strcat(bp, " "); - Strcat(bp, otense(otmp, verb)); - } - return(bp); + if(verb) { + Strcat(bp, " "); + Strcat(bp, otense(otmp, verb)); + } + return(bp); } /* combine yname and aobjnam eg "your count cxname(otmp)" */ @@ -1380,19 +1392,19 @@ yobjnam(obj,verb) struct obj *obj; const char *verb; { - char *s = aobjnam(obj, verb); + char *s = aobjnam(obj, verb); - /* leave off "your" for most of your artifacts, but prepend - * "your" for unique objects and "foo of bar" quest artifacts */ - if (!carried(obj) || !obj_is_pname(obj) || - obj->oartifact >= ART_ORB_OF_DETECTION) { - char *outbuf = shk_your(nextobuf(), obj); - int space_left = BUFSZ - 1 - strlen(outbuf); + /* leave off "your" for most of your artifacts, but prepend + * "your" for unique objects and "foo of bar" quest artifacts */ + if (!carried(obj) || !obj_is_pname(obj) || + obj->oartifact >= ART_ORB_OF_DETECTION) { + char *outbuf = shk_your(nextobuf(), obj); + int space_left = BUFSZ - 1 - strlen(outbuf); - s = strncat(outbuf, s, space_left); - } + s = strncat(outbuf, s, space_left); + } - return s; + return s; } /* combine Yname2 and aobjnam eg "Your count cxname(otmp)" */ @@ -1401,10 +1413,10 @@ Yobjnam2(obj,verb) struct obj *obj; const char *verb; { - register char *s = yobjnam(obj,verb); + register char *s = yobjnam(obj,verb); - *s = highc(*s); - return(s); + *s = highc(*s); + return(s); } /* like aobjnam, but prepend "The", not count, and use xname */ @@ -1413,13 +1425,13 @@ Tobjnam(otmp, verb) register struct obj *otmp; register const char *verb; { - char *bp = The(xname(otmp)); + char *bp = The(xname(otmp)); - if(verb) { - Strcat(bp, " "); - Strcat(bp, otense(otmp, verb)); - } - return(bp); + if(verb) { + Strcat(bp, " "); + Strcat(bp, otense(otmp, verb)); + } + return(bp); } /* capitalized variant of doname() */ @@ -1427,10 +1439,10 @@ char * Doname2(obj) register struct obj *obj; { - register char *s = doname(obj); + register char *s = doname(obj); - *s = highc(*s); - return(s); + *s = highc(*s); + return(s); } /* returns "[your ]xname(obj)" or "Foobar's xname(obj)" or "the xname(obj)" */ @@ -1438,19 +1450,19 @@ char * yname(obj) struct obj *obj; { - char *s = cxname(obj); + char *s = cxname(obj); - /* leave off "your" for most of your artifacts, but prepend - * "your" for unique objects and "foo of bar" quest artifacts */ - if (!carried(obj) || !obj_is_pname(obj) || - obj->oartifact >= ART_ORB_OF_DETECTION) { - char *outbuf = shk_your(nextobuf(), obj); - int space_left = BUFSZ - 1 - strlen(outbuf); + /* leave off "your" for most of your artifacts, but prepend + * "your" for unique objects and "foo of bar" quest artifacts */ + if (!carried(obj) || !obj_is_pname(obj) || + obj->oartifact >= ART_ORB_OF_DETECTION) { + char *outbuf = shk_your(nextobuf(), obj); + int space_left = BUFSZ - 1 - strlen(outbuf); - s = strncat(outbuf, s, space_left); - } + s = strncat(outbuf, s, space_left); + } - return s; + return s; } /* capitalized variant of yname() */ @@ -1458,10 +1470,10 @@ char * Yname2(obj) struct obj *obj; { - char *s = yname(obj); + char *s = yname(obj); - *s = highc(*s); - return s; + *s = highc(*s); + return s; } /* returns "your minimal_xname(obj)" @@ -1472,11 +1484,11 @@ char * ysimple_name(obj) struct obj *obj; { - char *outbuf = nextobuf(); - char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */ - int space_left = BUFSZ - 1 - strlen(s); + char *outbuf = nextobuf(); + char *s = shk_your(outbuf, obj); /* assert( s == outbuf ); */ + int space_left = BUFSZ - 1 - strlen(s); - return strncat(s, minimal_xname(obj), space_left); + return strncat(s, minimal_xname(obj), space_left); } /* capitalized variant of ysimple_name() */ @@ -1484,10 +1496,10 @@ char * Ysimple_name2(obj) struct obj *obj; { - char *s = ysimple_name(obj); + char *s = ysimple_name(obj); - *s = highc(*s); - return s; + *s = highc(*s); + return s; } /* "scroll" or "scrolls" */ @@ -1495,10 +1507,10 @@ char * simpleonames(obj) struct obj *obj; { - char *simpleoname = minimal_xname(obj); + char *simpleoname = minimal_xname(obj); - if (obj->quan != 1L) simpleoname = makeplural(simpleoname); - return simpleoname; + if (obj->quan != 1L) simpleoname = makeplural(simpleoname); + return simpleoname; } /* "a scroll" or "scrolls"; "a silver bell" or "the Bell of Opening" */ @@ -1506,20 +1518,20 @@ char * ansimpleoname(obj) struct obj *obj; { - char *simpleoname = simpleonames(obj); - int otyp = obj->otyp; + char *simpleoname = simpleonames(obj); + int otyp = obj->otyp; - /* prefix with "the" if a unique item, or a fake one imitating same, - has been formatted with its actual name (we let typename() handle - any `known' and `dknown' checking necessary) */ - if (otyp == FAKE_AMULET_OF_YENDOR) otyp = AMULET_OF_YENDOR; - if (objects[otyp].oc_unique && - !strcmp(simpleoname, OBJ_NAME(objects[otyp]))) - return the(simpleoname); + /* prefix with "the" if a unique item, or a fake one imitating same, + has been formatted with its actual name (we let typename() handle + any `known' and `dknown' checking necessary) */ + if (otyp == FAKE_AMULET_OF_YENDOR) otyp = AMULET_OF_YENDOR; + if (objects[otyp].oc_unique && + !strcmp(simpleoname, OBJ_NAME(objects[otyp]))) + return the(simpleoname); - /* simpleoname is singular if quan==1, plural otherwise */ - if (obj->quan == 1L) simpleoname = an(simpleoname); - return simpleoname; + /* simpleoname is singular if quan==1, plural otherwise */ + if (obj->quan == 1L) simpleoname = an(simpleoname); + return simpleoname; } /* "the scroll" or "the scrolls" */ @@ -1527,9 +1539,9 @@ char * thesimpleoname(obj) struct obj *obj; { - char *simpleoname = simpleonames(obj); + char *simpleoname = simpleonames(obj); - return the(simpleoname); + return the(simpleoname); } /* artifact's name without any object type or known/dknown/&c feedback */ @@ -1537,29 +1549,29 @@ char * bare_artifactname(obj) struct obj *obj; { - char *outbuf; + char *outbuf; - if (obj->oartifact) { - outbuf = nextobuf(); - Strcpy(outbuf, artiname(obj->oartifact)); - if (!strncmp(outbuf, "The ", 4)) outbuf[0] = lowc(outbuf[0]); - } else { - outbuf = xname(obj); - } - return outbuf; + if (obj->oartifact) { + outbuf = nextobuf(); + Strcpy(outbuf, artiname(obj->oartifact)); + if (!strncmp(outbuf, "The ", 4)) outbuf[0] = lowc(outbuf[0]); + } else { + outbuf = xname(obj); + } + return outbuf; } static const char *wrp[] = { - "wand", "ring", "potion", "scroll", "gem", "amulet", - "spellbook", "spell book", - /* for non-specific wishes */ - "weapon", "armor", "tool", "food", "comestible", + "wand", "ring", "potion", "scroll", "gem", "amulet", + "spellbook", "spell book", + /* for non-specific wishes */ + "weapon", "armor", "tool", "food", "comestible", }; static const char wrpsym[] = { - WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, GEM_CLASS, - AMULET_CLASS, SPBOOK_CLASS, SPBOOK_CLASS, - WEAPON_CLASS, ARMOR_CLASS, TOOL_CLASS, FOOD_CLASS, - FOOD_CLASS + WAND_CLASS, RING_CLASS, POTION_CLASS, SCROLL_CLASS, GEM_CLASS, + AMULET_CLASS, SPBOOK_CLASS, SPBOOK_CLASS, + WEAPON_CLASS, ARMOR_CLASS, TOOL_CLASS, FOOD_CLASS, + FOOD_CLASS }; /* return form of the verb (input plural) if xname(otmp) were the subject */ @@ -1576,7 +1588,7 @@ register const char *verb; * recomputing xname(otmp) at this time. */ if (!is_plural(otmp)) - return vtense((char *)0, verb); + return vtense((char *)0, verb); buf = nextobuf(); Strcpy(buf, verb); @@ -1586,22 +1598,22 @@ register const char *verb; /* various singular words that vtense would otherwise categorize as plural; also used by makesingular() to catch some special cases */ static const char * const special_subjs[] = { - "erinys", - "manes", /* this one is ambiguous */ - "Cyclops", - "Hippocrates", - "Pelias", - "aklys", - "amnesia", - "detect monsters", - "paralysis", - "shape changers", - "nemesis", - 0 - /* note: "detect monsters" and "shape changers" are normally - caught via "(s) of ", but they can be - wished for using the shorter form, so we include them here - to accomodate usage by makesingular during wishing */ + "erinys", + "manes", /* this one is ambiguous */ + "Cyclops", + "Hippocrates", + "Pelias", + "aklys", + "amnesia", + "detect monsters", + "paralysis", + "shape changers", + "nemesis", + 0 + /* note: "detect monsters" and "shape changers" are normally + caught via "(s) of ", but they can be + wished for using the shorter form, so we include them here + to accomodate usage by makesingular during wishing */ }; /* return form of the verb (input plural) for present tense 3rd person subj */ @@ -1626,51 +1638,51 @@ register const char *verb; * present tense form so we don't duplicate this code elsewhere. */ if (subj) { - if (!strncmpi(subj, "a ", 2) || !strncmpi(subj, "an ", 3)) - goto sing; - spot = (const char *)0; - for (sp = subj; (sp = index(sp, ' ')) != 0; ++sp) { - if (!strncmpi(sp, " of ", 4) || - !strncmpi(sp, " from ", 6) || - !strncmpi(sp, " called ", 8) || - !strncmpi(sp, " named ", 7) || - !strncmpi(sp, " labeled ", 9)) { - if (sp != subj) spot = sp - 1; - break; - } - } - len = (int) strlen(subj); - if (!spot) spot = subj + len - 1; + if (!strncmpi(subj, "a ", 2) || !strncmpi(subj, "an ", 3)) + goto sing; + spot = (const char *)0; + for (sp = subj; (sp = index(sp, ' ')) != 0; ++sp) { + if (!strncmpi(sp, " of ", 4) || + !strncmpi(sp, " from ", 6) || + !strncmpi(sp, " called ", 8) || + !strncmpi(sp, " named ", 7) || + !strncmpi(sp, " labeled ", 9)) { + if (sp != subj) spot = sp - 1; + break; + } + } + len = (int) strlen(subj); + if (!spot) spot = subj + len - 1; - /* - * plural: anything that ends in 's', but not '*us' or '*ss'. - * Guess at a few other special cases that makeplural creates. - */ - if ((lowc(*spot) == 's' && spot != subj && - !index("us", lowc(*(spot-1)))) || - !BSTRNCMPI(subj, spot-3, "eeth", 4) || - !BSTRNCMPI(subj, spot-3, "feet", 4) || - !BSTRNCMPI(subj, spot-1, "ia", 2) || - !BSTRNCMPI(subj, spot-1, "ae", 2)) { - /* check for special cases to avoid false matches */ - len = (int)(spot - subj) + 1; - for (spec = special_subjs; *spec; spec++) { - ltmp = strlen(*spec); - if (len == ltmp && !strncmpi(*spec, subj, len)) goto sing; - /* also check for - to catch things like "the invisible erinys" */ - if (len > ltmp && *(spot - ltmp) == ' ' && - !strncmpi(*spec, spot - ltmp + 1, ltmp)) goto sing; - } + /* + * plural: anything that ends in 's', but not '*us' or '*ss'. + * Guess at a few other special cases that makeplural creates. + */ + if ((lowc(*spot) == 's' && spot != subj && + !index("us", lowc(*(spot-1)))) || + !BSTRNCMPI(subj, spot-3, "eeth", 4) || + !BSTRNCMPI(subj, spot-3, "feet", 4) || + !BSTRNCMPI(subj, spot-1, "ia", 2) || + !BSTRNCMPI(subj, spot-1, "ae", 2)) { + /* check for special cases to avoid false matches */ + len = (int)(spot - subj) + 1; + for (spec = special_subjs; *spec; spec++) { + ltmp = strlen(*spec); + if (len == ltmp && !strncmpi(*spec, subj, len)) goto sing; + /* also check for + to catch things like "the invisible erinys" */ + if (len > ltmp && *(spot - ltmp) == ' ' && + !strncmpi(*spec, spot - ltmp + 1, ltmp)) goto sing; + } - return strcpy(buf, verb); - } - /* - * 3rd person plural doesn't end in telltale 's'; - * 2nd person singular behaves as if plural. - */ - if (!strcmpi(subj, "they") || !strcmpi(subj, "you")) - return strcpy(buf, verb); + return strcpy(buf, verb); + } + /* + * 3rd person plural doesn't end in telltale 's'; + * 2nd person singular behaves as if plural. + */ + if (!strcmpi(subj, "they") || !strcmpi(subj, "you")) + return strcpy(buf, verb); } sing: @@ -1679,69 +1691,69 @@ register const char *verb; bspot = buf + len - 1; if (!strcmpi(buf, "are")) { - Strcasecpy(buf, "is"); + Strcasecpy(buf, "is"); } else if (!strcmpi(buf, "have")) { - Strcasecpy(bspot-1, "s"); + Strcasecpy(bspot-1, "s"); } else if (index("zxs", lowc(*bspot)) || - (len >= 2 && lowc(*bspot) == 'h' && - index("cs", lowc(*(bspot-1)))) || - (len == 2 && lowc(*bspot) == 'o')) { - /* Ends in z, x, s, ch, sh; add an "es" */ - Strcasecpy(bspot+1, "es"); + (len >= 2 && lowc(*bspot) == 'h' && + index("cs", lowc(*(bspot-1)))) || + (len == 2 && lowc(*bspot) == 'o')) { + /* Ends in z, x, s, ch, sh; add an "es" */ + Strcasecpy(bspot+1, "es"); } else if (lowc(*bspot) == 'y' && !index(vowels, lowc(*(bspot-1)))) { - /* like "y" case in makeplural */ - Strcasecpy(bspot, "ies"); + /* like "y" case in makeplural */ + Strcasecpy(bspot, "ies"); } else { - Strcasecpy(bspot+1, "s"); + Strcasecpy(bspot+1, "s"); } return buf; } struct sing_plur { - const char *sing, *plur; + const char *sing, *plur; }; /* word pairs that don't fit into formula-based transformations; also some suffices which have very few--often one--matches or which aren't systematically reversible (knives, staves) */ static struct sing_plur one_off[] = { - { "child", "children" }, /* (for wise guys who give their food funny names) */ - { "cubus", "cubi" }, /* in-/suc-cubus */ - { "culus", "culi" }, /* homunculus */ - { "djinni", "djinn" }, - { "erinys", "erinyes" }, - { "foot", "feet" }, - { "fungus", "fungi" }, - { "knife", "knives" }, - { "labrum", "labra" }, /* candelabrum */ - { "louse", "lice" }, - { "mouse", "mice" }, - { "mumak", "mumakil" }, - { "nemesis", "nemeses" }, - { "rtex", "rtices" }, /* vortex */ - { "tooth", "teeth" }, - { "staff", "staves" }, - { 0, 0 } + { "child", "children" }, /* (for wise guys who give their food funny names) */ + { "cubus", "cubi" }, /* in-/suc-cubus */ + { "culus", "culi" }, /* homunculus */ + { "djinni", "djinn" }, + { "erinys", "erinyes" }, + { "foot", "feet" }, + { "fungus", "fungi" }, + { "knife", "knives" }, + { "labrum", "labra" }, /* candelabrum */ + { "louse", "lice" }, + { "mouse", "mice" }, + { "mumak", "mumakil" }, + { "nemesis", "nemeses" }, + { "rtex", "rtices" }, /* vortex */ + { "tooth", "teeth" }, + { "staff", "staves" }, + { 0, 0 } }; static const char *const as_is[] = { - /* makesingular() leaves these plural due to how they're used */ - "boots", "shoes", + /* makesingular() leaves these plural due to how they're used */ + "boots", "shoes", "gloves", "lenses", "scales", "eyes", - "gauntlets", - "iron bars", - /* both singular and plural are spelled the same */ - "deer", "fish", "tuna", "yaki", "-hai", - "krill", "manes", "ninja", "sheep", "ronin", "roshi", "shito", "tengu", - "ki-rin", "Nazgul", - "gunyoki", "piranha", "samurai", - "shuriken", - 0, - /* Note: "fish" and "piranha" are collective plurals, suitable - for "wiped out all ". For "3 ", they should be - "fishes" and "piranhas" instead. We settle for collective - variant instead of attempting to support both. */ + "gauntlets", + "iron bars", + /* both singular and plural are spelled the same */ + "deer", "fish", "tuna", "yaki", "-hai", + "krill", "manes", "ninja", "sheep", "ronin", "roshi", "shito", "tengu", + "ki-rin", "Nazgul", + "gunyoki", "piranha", "samurai", + "shuriken", + 0, + /* Note: "fish" and "piranha" are collective plurals, suitable + for "wiped out all ". For "3 ", they should be + "fishes" and "piranhas" instead. We settle for collective + variant instead of attempting to support both. */ }; /* singularize/pluralize decisiions common to both makesingular & makeplural */ @@ -1751,38 +1763,38 @@ char *basestr, *endstring; /* base string, pointer to eos(string) */ boolean to_plural; /* true => makeplural, false => makesingular */ const char *const *alt_as_is; /* another set like as_is[] */ { - const struct sing_plur *sp; - const char *same, *other, *const *as; - int al; + const struct sing_plur *sp; + const char *same, *other, *const *as; + int al; - for (as = as_is; *as; ++as) { - al = (int)strlen(*as); - if (!BSTRCMPI(basestr, endstring - al, *as)) - return TRUE; - } - if (alt_as_is) { - for (as = alt_as_is; *as; ++as) { - al = (int)strlen(*as); - if (!BSTRCMPI(basestr, endstring - al, *as)) - return TRUE; - } - } + for (as = as_is; *as; ++as) { + al = (int)strlen(*as); + if (!BSTRCMPI(basestr, endstring - al, *as)) + return TRUE; + } + if (alt_as_is) { + for (as = alt_as_is; *as; ++as) { + al = (int)strlen(*as); + if (!BSTRCMPI(basestr, endstring - al, *as)) + return TRUE; + } + } - for (sp = one_off; sp->sing; sp++) { - /* check whether endstring already matches */ - same = to_plural ? sp->plur : sp->sing; - al = (int)strlen(same); - if (!BSTRCMPI(basestr, endstring - al, same)) - return TRUE; /* use as-is */ - /* check whether it matches the inverse; if so, transform it */ - other = to_plural ? sp->sing : sp->plur; - al = (int)strlen(other); - if (!BSTRCMPI(basestr, endstring - al, other)) { - Strcasecpy(endstring - al, same); - return TRUE; /* one_off[] transformation */ - } - } - return FALSE; + for (sp = one_off; sp->sing; sp++) { + /* check whether endstring already matches */ + same = to_plural ? sp->plur : sp->sing; + al = (int)strlen(same); + if (!BSTRCMPI(basestr, endstring - al, same)) + return TRUE; /* use as-is */ + /* check whether it matches the inverse; if so, transform it */ + other = to_plural ? sp->sing : sp->plur; + al = (int)strlen(other); + if (!BSTRCMPI(basestr, endstring - al, other)) { + Strcasecpy(endstring - al, same); + return TRUE; /* one_off[] transformation */ + } + } + return FALSE; } /* searches for common compounds, ex. lump of royal jelly */ @@ -1792,37 +1804,37 @@ char *str; { /* if new entries are added, be sure to keep compound_start[] in sync */ static const char *const compounds[] = { - " of ", - " labeled ", - " called ", - " named ", - " above", /* lurkers above */ - " versus ", - " from ", - " in ", - " on ", - " a la ", - " with", /* " with "? */ - " de ", - " d'", - " du ", - "-in-", - "-at-", - 0 + " of ", + " labeled ", + " called ", + " named ", + " above", /* lurkers above */ + " versus ", + " from ", + " in ", + " on ", + " a la ", + " with", /* " with "? */ + " de ", + " d'", + " du ", + "-in-", + "-at-", + 0 }, /* list of first characters for all compounds[] entries */ - compound_start[] = " -"; + compound_start[] = " -"; const char *const *cmpd; char *p; for (p = str; *p; ++p) { - /* substring starting at p can only match if *p is found - within compound_start[] */ - if (!index(compound_start, *p)) continue; + /* substring starting at p can only match if *p is found + within compound_start[] */ + if (!index(compound_start, *p)) continue; - /* check current substring against all words in the compound[] list */ - for (cmpd = compounds; *cmpd; ++cmpd) - if (!strncmpi(p, *cmpd, (int)strlen(*cmpd))) return p; + /* check current substring against all words in the compound[] list */ + for (cmpd = compounds; *cmpd; ++cmpd) + if (!strncmpi(p, *cmpd, (int)strlen(*cmpd))) return p; } /* wasn't recognized as a compound phrase */ return 0; @@ -1847,151 +1859,151 @@ char * makeplural(oldstr) const char *oldstr; { - register char *spot; - char lo_c, *str = nextobuf(); - const char *excess = (char *)0; - int len; + register char *spot; + char lo_c, *str = nextobuf(); + const char *excess = (char *)0; + int len; - if (oldstr) while (*oldstr == ' ') oldstr++; - if (!oldstr || !*oldstr) { - impossible("plural of null?"); - Strcpy(str, "s"); - return str; - } - Strcpy(str, oldstr); + if (oldstr) while (*oldstr == ' ') oldstr++; + if (!oldstr || !*oldstr) { + impossible("plural of null?"); + Strcpy(str, "s"); + return str; + } + Strcpy(str, oldstr); - /* - * Skip changing "pair of" to "pairs of". According to Webster, usual - * English usage is use pairs for humans, e.g. 3 pairs of dancers, - * and pair for objects and non-humans, e.g. 3 pair of boots. We don't - * refer to pairs of humans in this game so just skip to the bottom. - */ - if (!strncmpi(str, "pair of ", 8)) - goto bottom; + /* + * Skip changing "pair of" to "pairs of". According to Webster, usual + * English usage is use pairs for humans, e.g. 3 pairs of dancers, + * and pair for objects and non-humans, e.g. 3 pair of boots. We don't + * refer to pairs of humans in this game so just skip to the bottom. + */ + if (!strncmpi(str, "pair of ", 8)) + goto bottom; - /* look for "foo of bar" so that we can focus on "foo" */ - if ((spot = singplur_compound(str)) != 0) { - excess = oldstr + (int)(spot - str); - *spot = '\0'; - } else - spot = eos(str); + /* look for "foo of bar" so that we can focus on "foo" */ + if ((spot = singplur_compound(str)) != 0) { + excess = oldstr + (int)(spot - str); + *spot = '\0'; + } else + spot = eos(str); - spot--; - while (spot > str && *spot == ' ') spot--; /* Strip blanks from end */ - *(spot+1) = 0; - /* Now spot is the last character of the string */ + spot--; + while (spot > str && *spot == ' ') spot--; /* Strip blanks from end */ + *(spot+1) = 0; + /* Now spot is the last character of the string */ - len = strlen(str); + len = strlen(str); - /* Single letters */ - if (len==1 || !letter(*spot)) { - Strcpy(spot+1, "'s"); - goto bottom; - } - - /* dispense with some words which don't need pluralization */ - { - static const char *const already_plural[] = { - "ae", /* algae, larvae, &c */ - "men", /* also catches women, watchmen */ - "matzot", - 0, - }; - - /* spot+1: synch up with makesingular's usage */ - if (singplur_lookup(str, spot + 1, TRUE, already_plural)) - goto bottom; - - /* more of same, but not suitable for blanket loop checking */ - if ((len == 2 && !strcmpi(str, "ya")) || - (len >= 3 && !strcmpi(spot-2, " ya"))) - goto bottom; + /* Single letters */ + if (len==1 || !letter(*spot)) { + Strcpy(spot+1, "'s"); + goto bottom; } - /* man/men ("Wiped out all cavemen.") */ - if (len >= 3 && !strcmpi(spot-2, "man") && - /* exclude shamans and humans */ - (len < 6 || strcmpi(spot-5, "shaman")) && - (len < 5 || strcmpi(spot-4, "human"))) { - Strcasecpy(spot-1, "en"); - goto bottom; - } - if (lowc(*spot) == 'f') { /* (staff handled via one_off[]) */ - lo_c = lowc(*(spot-1)); - if (len >= 3 && !strcmpi(spot-2, "erf")) { - /* avoid "nerf" -> "nerves", "serf" -> "serves" */ - ; /* fall through to default (append 's') */ - } else if (index("lr", lo_c) || index(vowels, lo_c)) { - /* [aeioulr]f to [aeioulr]ves */ - Strcasecpy(spot, "ves"); - goto bottom; - } - } - /* ium/ia (mycelia, baluchitheria) */ - if (len >= 3 && !strcmpi(spot-2, "ium")) { - Strcasecpy(spot-2, "ia"); - goto bottom; - } - /* algae, larvae, hyphae (another fungus part) */ - if ((len >= 4 && !strcmpi(spot-3, "alga")) || - (len >= 5 && (!strcmpi(spot-4, "hypha") || - !strcmpi(spot-4, "larva"))) || - (len >= 6 && !strcmpi(spot-5, "amoeba")) || - (len >= 8 && (!strcmpi(spot-7, "vertebra")))) { - /* a to ae */ - Strcasecpy(spot+1, "e"); - goto bottom; - } - /* fungus/fungi, homunculus/homunculi, but buses, lotuses, wumpuses */ - if (len > 3 && !strcmpi(spot-1, "us") && - !((len >= 5 && !strcmpi(spot-4, "lotus")) || - (len >= 6 && !strcmpi(spot-5, "wumpus")))) { - Strcasecpy(spot-1, "i"); - goto bottom; - } - /* sis/ses (nemesis) */ - if (len >= 3 && !strcmpi(spot-2, "sis")) { - Strcasecpy(spot-1, "es"); - goto bottom; - } - /* matzoh/matzot, possible food name */ - if (len >= 6 && (!strcmpi(spot-5, "matzoh") || - !strcmpi(spot-5, "matzah"))) { - Strcasecpy(spot-1, "ot"); /* oh/ah -> ot */ - goto bottom; - } - if (len >= 5 && (!strcmpi(spot-4, "matzo") || - !strcmpi(spot-4, "matza"))) { - Strcasecpy(spot, "ot"); /* o/a -> ot */ - goto bottom; - } + /* dispense with some words which don't need pluralization */ + { + static const char *const already_plural[] = { + "ae", /* algae, larvae, &c */ + "men", /* also catches women, watchmen */ + "matzot", + 0, + }; - /* note: -eau/-eaux (gateau, bordeau...) */ - /* note: ox/oxen, VAX/VAXen, goose/geese */ + /* spot+1: synch up with makesingular's usage */ + if (singplur_lookup(str, spot + 1, TRUE, already_plural)) + goto bottom; - lo_c = lowc(*spot); + /* more of same, but not suitable for blanket loop checking */ + if ((len == 2 && !strcmpi(str, "ya")) || + (len >= 3 && !strcmpi(spot-2, " ya"))) + goto bottom; + } - /* Ends in z, x, s, ch, sh; add an "es" */ - if (index("zxs", lo_c) || - (len >= 2 && lo_c == 'h' && index("cs", lowc(*(spot-1)))) || - /* Kludge to get "tomatoes" and "potatoes" right */ - (len >= 4 && !strcmpi(spot-2, "ato")) || - (len >= 5 && !strcmpi(spot-4, "dingo"))) { - Strcasecpy(spot+1, "es"); /* append es */ - goto bottom; - } - /* Ends in y preceded by consonant (note: also "qu") change to "ies" */ - if (lo_c == 'y' && - !index(vowels, lowc(*(spot-1)))) { - Strcasecpy(spot, "ies"); /* y -> ies */ - goto bottom; - } - /* Default: append an 's' */ - Strcasecpy(spot+1, "s"); + /* man/men ("Wiped out all cavemen.") */ + if (len >= 3 && !strcmpi(spot-2, "man") && + /* exclude shamans and humans */ + (len < 6 || strcmpi(spot-5, "shaman")) && + (len < 5 || strcmpi(spot-4, "human"))) { + Strcasecpy(spot-1, "en"); + goto bottom; + } + if (lowc(*spot) == 'f') { /* (staff handled via one_off[]) */ + lo_c = lowc(*(spot-1)); + if (len >= 3 && !strcmpi(spot-2, "erf")) { + /* avoid "nerf" -> "nerves", "serf" -> "serves" */ + ; /* fall through to default (append 's') */ + } else if (index("lr", lo_c) || index(vowels, lo_c)) { + /* [aeioulr]f to [aeioulr]ves */ + Strcasecpy(spot, "ves"); + goto bottom; + } + } + /* ium/ia (mycelia, baluchitheria) */ + if (len >= 3 && !strcmpi(spot-2, "ium")) { + Strcasecpy(spot-2, "ia"); + goto bottom; + } + /* algae, larvae, hyphae (another fungus part) */ + if ((len >= 4 && !strcmpi(spot-3, "alga")) || + (len >= 5 && (!strcmpi(spot-4, "hypha") || + !strcmpi(spot-4, "larva"))) || + (len >= 6 && !strcmpi(spot-5, "amoeba")) || + (len >= 8 && (!strcmpi(spot-7, "vertebra")))) { + /* a to ae */ + Strcasecpy(spot+1, "e"); + goto bottom; + } + /* fungus/fungi, homunculus/homunculi, but buses, lotuses, wumpuses */ + if (len > 3 && !strcmpi(spot-1, "us") && + !((len >= 5 && !strcmpi(spot-4, "lotus")) || + (len >= 6 && !strcmpi(spot-5, "wumpus")))) { + Strcasecpy(spot-1, "i"); + goto bottom; + } + /* sis/ses (nemesis) */ + if (len >= 3 && !strcmpi(spot-2, "sis")) { + Strcasecpy(spot-1, "es"); + goto bottom; + } + /* matzoh/matzot, possible food name */ + if (len >= 6 && (!strcmpi(spot-5, "matzoh") || + !strcmpi(spot-5, "matzah"))) { + Strcasecpy(spot-1, "ot"); /* oh/ah -> ot */ + goto bottom; + } + if (len >= 5 && (!strcmpi(spot-4, "matzo") || + !strcmpi(spot-4, "matza"))) { + Strcasecpy(spot, "ot"); /* o/a -> ot */ + goto bottom; + } + + /* note: -eau/-eaux (gateau, bordeau...) */ + /* note: ox/oxen, VAX/VAXen, goose/geese */ + + lo_c = lowc(*spot); + + /* Ends in z, x, s, ch, sh; add an "es" */ + if (index("zxs", lo_c) || + (len >= 2 && lo_c == 'h' && index("cs", lowc(*(spot-1)))) || + /* Kludge to get "tomatoes" and "potatoes" right */ + (len >= 4 && !strcmpi(spot-2, "ato")) || + (len >= 5 && !strcmpi(spot-4, "dingo"))) { + Strcasecpy(spot+1, "es"); /* append es */ + goto bottom; + } + /* Ends in y preceded by consonant (note: also "qu") change to "ies" */ + if (lo_c == 'y' && + !index(vowels, lowc(*(spot-1)))) { + Strcasecpy(spot, "ies"); /* y -> ies */ + goto bottom; + } + /* Default: append an 's' */ + Strcasecpy(spot+1, "s"); bottom: - if (excess) Strcat(str, excess); - return str; + if (excess) Strcat(str, excess); + return str; } /* @@ -2010,105 +2022,105 @@ char * makesingular(oldstr) const char *oldstr; { - register char *p, *bp; - const char *excess = 0; - char *str = nextobuf(); + register char *p, *bp; + const char *excess = 0; + char *str = nextobuf(); - if (oldstr) while (*oldstr == ' ') oldstr++; - if (!oldstr || !*oldstr) { - impossible("singular of null?"); - str[0] = '\0'; - return str; - } + if (oldstr) while (*oldstr == ' ') oldstr++; + if (!oldstr || !*oldstr) { + impossible("singular of null?"); + str[0] = '\0'; + return str; + } - bp = strcpy(str, oldstr); + bp = strcpy(str, oldstr); - /* check for "foo of bar" so that we can focus on "foo" */ - if ((p = singplur_compound(bp)) != 0) { - excess = oldstr + (int)(p - bp); - *p = '\0'; - } else - p = eos(bp); + /* check for "foo of bar" so that we can focus on "foo" */ + if ((p = singplur_compound(bp)) != 0) { + excess = oldstr + (int)(p - bp); + *p = '\0'; + } else + p = eos(bp); - /* dispense with some words which don't need singularization */ - if (singplur_lookup(bp, p, FALSE, special_subjs)) - goto bottom; + /* dispense with some words which don't need singularization */ + if (singplur_lookup(bp, p, FALSE, special_subjs)) + goto bottom; - /* remove -s or -es (boxes) or -ies (rubies) */ - if (p >= bp+1 && lowc(p[-1]) == 's') { - if (p >= bp+2 && lowc(p[-2]) == 'e') { - if (p >= bp+3 && lowc(p[-3]) == 'i') { /* "ies" */ - if (!BSTRCMPI(bp, p-7, "cookies") || - !BSTRCMPI(bp, p-4, "pies") || - !BSTRCMPI(bp, p-5, "mbies") || /* zombie */ - !BSTRCMPI(bp, p-5, "yries")) /* valkyrie */ - goto mins; - Strcasecpy(p-3, "y"); /* ies -> y */ - goto bottom; - } - /* wolves, but f to ves isn't fully reversible */ - if (p-4 >= bp && (index("lr", lowc(*(p-4))) || - index(vowels, lowc(*(p-4)))) && - !BSTRCMPI(bp, p-3, "ves")) { - if (!BSTRCMPI(bp, p-6, "cloves") || - !BSTRCMPI(bp, p-6, "nerves")) goto mins; - Strcasecpy(p-3, "f"); /* ves -> f */ - goto bottom; - } - /* note: nurses, axes but boxes, wumpuses */ - if (!BSTRCMPI(bp, p-4, "eses") || - !BSTRCMPI(bp, p-4, "oxes") || /* boxes, foxes */ - !BSTRCMPI(bp, p-4, "nxes") || /* lynxes */ - !BSTRCMPI(bp, p-4, "ches") || - !BSTRCMPI(bp, p-4, "uses") || /* lotuses */ - !BSTRCMPI(bp, p-4, "sses") || /* priestesses */ - !BSTRCMPI(bp, p-5, "atoes") || /* tomatoes */ - !BSTRCMPI(bp, p-7, "dingoes") || - !BSTRCMPI(bp, p-7, "Aleaxes")) { - *(p-2) = '\0'; /* drop es */ - goto bottom; - } /* else fall through to mins */ + /* remove -s or -es (boxes) or -ies (rubies) */ + if (p >= bp+1 && lowc(p[-1]) == 's') { + if (p >= bp+2 && lowc(p[-2]) == 'e') { + if (p >= bp+3 && lowc(p[-3]) == 'i') { /* "ies" */ + if (!BSTRCMPI(bp, p-7, "cookies") || + !BSTRCMPI(bp, p-4, "pies") || + !BSTRCMPI(bp, p-5, "mbies") || /* zombie */ + !BSTRCMPI(bp, p-5, "yries")) /* valkyrie */ + goto mins; + Strcasecpy(p-3, "y"); /* ies -> y */ + goto bottom; + } + /* wolves, but f to ves isn't fully reversible */ + if (p-4 >= bp && (index("lr", lowc(*(p-4))) || + index(vowels, lowc(*(p-4)))) && + !BSTRCMPI(bp, p-3, "ves")) { + if (!BSTRCMPI(bp, p-6, "cloves") || + !BSTRCMPI(bp, p-6, "nerves")) goto mins; + Strcasecpy(p-3, "f"); /* ves -> f */ + goto bottom; + } + /* note: nurses, axes but boxes, wumpuses */ + if (!BSTRCMPI(bp, p-4, "eses") || + !BSTRCMPI(bp, p-4, "oxes") || /* boxes, foxes */ + !BSTRCMPI(bp, p-4, "nxes") || /* lynxes */ + !BSTRCMPI(bp, p-4, "ches") || + !BSTRCMPI(bp, p-4, "uses") || /* lotuses */ + !BSTRCMPI(bp, p-4, "sses") || /* priestesses */ + !BSTRCMPI(bp, p-5, "atoes") || /* tomatoes */ + !BSTRCMPI(bp, p-7, "dingoes") || + !BSTRCMPI(bp, p-7, "Aleaxes")) { + *(p-2) = '\0'; /* drop es */ + goto bottom; + } /* else fall through to mins */ - /* ends in 's' but not 'es' */ - } else if (!BSTRCMPI(bp, p-2, "us")) { /* lotus, fungus... */ - if (BSTRCMPI(bp, p-6, "tengus") && /* but not these... */ - BSTRCMPI(bp, p-7, "hezrous")) - goto bottom; - } else if (!BSTRCMPI(bp, p-2, "ss") || - !BSTRCMPI(bp, p-5, " lens") || - (p-4 == bp && !strcmpi(p-4, "lens"))) { - goto bottom; - } - mins: - *(p-1) = '\0'; /* drop s */ + /* ends in 's' but not 'es' */ + } else if (!BSTRCMPI(bp, p-2, "us")) { /* lotus, fungus... */ + if (BSTRCMPI(bp, p-6, "tengus") && /* but not these... */ + BSTRCMPI(bp, p-7, "hezrous")) + goto bottom; + } else if (!BSTRCMPI(bp, p-2, "ss") || + !BSTRCMPI(bp, p-5, " lens") || + (p-4 == bp && !strcmpi(p-4, "lens"))) { + goto bottom; + } + mins: + *(p-1) = '\0'; /* drop s */ - } else { /* input doesn't end in 's' */ + } else { /* input doesn't end in 's' */ - if (!BSTRCMPI(bp, p-3, "men")) { - Strcasecpy(p-2, "an"); - goto bottom; - } - /* matzot -> matzo, algae -> alga */ - if (!BSTRCMPI(bp, p-6, "matzot") || - !BSTRCMPI(bp, p-2, "ae")) { - *(p-1) = '\0'; /* drop t/e */ - goto bottom; - } - /* balactheria -> balactherium */ - if (p-4 >= bp && !strcmpi(p-2, "ia") && - index("lr", lowc(*(p-3))) && lowc(*(p-4)) == 'e') { - Strcasecpy(p-1, "um"); /* a -> um */ - } + if (!BSTRCMPI(bp, p-3, "men")) { + Strcasecpy(p-2, "an"); + goto bottom; + } + /* matzot -> matzo, algae -> alga */ + if (!BSTRCMPI(bp, p-6, "matzot") || + !BSTRCMPI(bp, p-2, "ae")) { + *(p-1) = '\0'; /* drop t/e */ + goto bottom; + } + /* balactheria -> balactherium */ + if (p-4 >= bp && !strcmpi(p-2, "ia") && + index("lr", lowc(*(p-3))) && lowc(*(p-4)) == 'e') { + Strcasecpy(p-1, "um"); /* a -> um */ + } - /* here we cannot find the plural suffix */ - } + /* here we cannot find the plural suffix */ + } bottom: - /* if we stripped off a suffix (" of bar" from "foo of bar"), - put it back now [strcat() isn't actually 100% safe here...] */ - if (excess) Strcat(bp, excess); + /* if we stripped off a suffix (" of bar" from "foo of bar"), + put it back now [strcat() isn't actually 100% safe here...] */ + if (excess) Strcat(bp, excess); - return bp; + return bp; } /* compare user string against object name string using fuzzy matching */ @@ -2118,117 +2130,117 @@ const char *u_str; /* from user, so might be variant spelling */ const char *o_str; /* from objects[], so is in canonical form */ boolean retry_inverted; /* optional extra "of" handling */ { - static NEARDATA const char - detect_SP[] = "detect ", SP_detection[] = " detection"; - char *p, buf[BUFSZ]; + static NEARDATA const char + detect_SP[] = "detect ", SP_detection[] = " detection"; + char *p, buf[BUFSZ]; - /* ignore spaces & hyphens and upper/lower case when comparing */ - if (fuzzymatch(u_str, o_str, " -", TRUE)) return TRUE; + /* ignore spaces & hyphens and upper/lower case when comparing */ + if (fuzzymatch(u_str, o_str, " -", TRUE)) return TRUE; - if (retry_inverted) { - const char *u_of, *o_of; + if (retry_inverted) { + const char *u_of, *o_of; - /* when just one of the strings is in the form "foo of bar", - convert it into "bar foo" and perform another comparison */ - u_of = strstri(u_str, " of "); - o_of = strstri(o_str, " of "); - if (u_of && !o_of) { - Strcpy(buf, u_of + 4); - p = eos(strcat(buf, " ")); - while (u_str < u_of) *p++ = *u_str++; - *p = '\0'; - return fuzzymatch(buf, o_str, " -", TRUE); - } else if (o_of && !u_of) { - Strcpy(buf, o_of + 4); - p = eos(strcat(buf, " ")); - while (o_str < o_of) *p++ = *o_str++; - *p = '\0'; - return fuzzymatch(u_str, buf, " -", TRUE); - } - } + /* when just one of the strings is in the form "foo of bar", + convert it into "bar foo" and perform another comparison */ + u_of = strstri(u_str, " of "); + o_of = strstri(o_str, " of "); + if (u_of && !o_of) { + Strcpy(buf, u_of + 4); + p = eos(strcat(buf, " ")); + while (u_str < u_of) *p++ = *u_str++; + *p = '\0'; + return fuzzymatch(buf, o_str, " -", TRUE); + } else if (o_of && !u_of) { + Strcpy(buf, o_of + 4); + p = eos(strcat(buf, " ")); + while (o_str < o_of) *p++ = *o_str++; + *p = '\0'; + return fuzzymatch(u_str, buf, " -", TRUE); + } + } - /* [note: if something like "elven speed boots" ever gets added, these - special cases should be changed to call wishymatch() recursively in - order to get the "of" inversion handling] */ - if (!strncmp(o_str, "dwarvish ", 9)) { - if (!strncmpi(u_str, "dwarven ", 8)) - return fuzzymatch(u_str + 8, o_str + 9, " -", TRUE); - } else if (!strncmp(o_str, "elven ", 6)) { - if (!strncmpi(u_str, "elvish ", 7)) - return fuzzymatch(u_str + 7, o_str + 6, " -", TRUE); - else if (!strncmpi(u_str, "elfin ", 6)) - return fuzzymatch(u_str + 6, o_str + 6, " -", TRUE); - } else if (!strncmp(o_str, detect_SP, sizeof detect_SP - 1)) { - /* check for "detect " vs " detection" */ - if ((p = strstri(u_str, SP_detection)) != 0 && - !*(p + sizeof SP_detection - 1)) { - /* convert " detection" into "detect " */ - *p = '\0'; - Strcat(strcpy(buf, detect_SP), u_str); - /* "detect monster" -> "detect monsters" */ - if (!strcmpi(u_str, "monster")) Strcat(buf, "s"); - *p = ' '; - return fuzzymatch(buf, o_str, " -", TRUE); - } - } else if (strstri(o_str, SP_detection)) { - /* and the inverse, " detection" vs "detect " */ - if (!strncmpi(u_str, detect_SP, sizeof detect_SP - 1)) { - /* convert "detect s" into " detection" */ - p = makesingular(u_str + sizeof detect_SP - 1); - Strcat(strcpy(buf, p), SP_detection); - /* caller may be looping through objects[], so avoid - churning through all the obufs */ - releaseobuf(p); - return fuzzymatch(buf, o_str, " -", TRUE); - } - } else if (strstri(o_str, "ability")) { - /* when presented with "foo of bar", make singular() used to - singularize both foo & bar, but now only does so for foo */ - /* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */ - if ((p = strstri(u_str, "abilities")) != 0 && - !*(p + sizeof "abilities" - 1)) { - (void)strncpy(buf, u_str, (unsigned)(p - u_str)); - Strcpy(buf + (p - u_str), "ability"); - return fuzzymatch(buf, o_str, " -", TRUE); - } - } else if (!strcmp(o_str, "aluminum")) { - /* this special case doesn't really fit anywhere else... */ - /* (note that " wand" will have been stripped off by now) */ - if (!strcmpi(u_str, "aluminium")) - return fuzzymatch(u_str + 9, o_str + 8, " -", TRUE); - } + /* [note: if something like "elven speed boots" ever gets added, these + special cases should be changed to call wishymatch() recursively in + order to get the "of" inversion handling] */ + if (!strncmp(o_str, "dwarvish ", 9)) { + if (!strncmpi(u_str, "dwarven ", 8)) + return fuzzymatch(u_str + 8, o_str + 9, " -", TRUE); + } else if (!strncmp(o_str, "elven ", 6)) { + if (!strncmpi(u_str, "elvish ", 7)) + return fuzzymatch(u_str + 7, o_str + 6, " -", TRUE); + else if (!strncmpi(u_str, "elfin ", 6)) + return fuzzymatch(u_str + 6, o_str + 6, " -", TRUE); + } else if (!strncmp(o_str, detect_SP, sizeof detect_SP - 1)) { + /* check for "detect " vs " detection" */ + if ((p = strstri(u_str, SP_detection)) != 0 && + !*(p + sizeof SP_detection - 1)) { + /* convert " detection" into "detect " */ + *p = '\0'; + Strcat(strcpy(buf, detect_SP), u_str); + /* "detect monster" -> "detect monsters" */ + if (!strcmpi(u_str, "monster")) Strcat(buf, "s"); + *p = ' '; + return fuzzymatch(buf, o_str, " -", TRUE); + } + } else if (strstri(o_str, SP_detection)) { + /* and the inverse, " detection" vs "detect " */ + if (!strncmpi(u_str, detect_SP, sizeof detect_SP - 1)) { + /* convert "detect s" into " detection" */ + p = makesingular(u_str + sizeof detect_SP - 1); + Strcat(strcpy(buf, p), SP_detection); + /* caller may be looping through objects[], so avoid + churning through all the obufs */ + releaseobuf(p); + return fuzzymatch(buf, o_str, " -", TRUE); + } + } else if (strstri(o_str, "ability")) { + /* when presented with "foo of bar", make singular() used to + singularize both foo & bar, but now only does so for foo */ + /* catch "{potion(s),ring} of {gain,restore,sustain} abilities" */ + if ((p = strstri(u_str, "abilities")) != 0 && + !*(p + sizeof "abilities" - 1)) { + (void)strncpy(buf, u_str, (unsigned)(p - u_str)); + Strcpy(buf + (p - u_str), "ability"); + return fuzzymatch(buf, o_str, " -", TRUE); + } + } else if (!strcmp(o_str, "aluminum")) { + /* this special case doesn't really fit anywhere else... */ + /* (note that " wand" will have been stripped off by now) */ + if (!strcmpi(u_str, "aluminium")) + return fuzzymatch(u_str + 9, o_str + 8, " -", TRUE); + } - return FALSE; + return FALSE; } struct o_range { - const char *name, oclass; - int f_o_range, l_o_range; + const char *name, oclass; + int f_o_range, l_o_range; }; /* wishable subranges of objects */ STATIC_OVL NEARDATA const struct o_range o_ranges[] = { - { "bag", TOOL_CLASS, SACK, BAG_OF_TRICKS }, - { "lamp", TOOL_CLASS, OIL_LAMP, MAGIC_LAMP }, - { "candle", TOOL_CLASS, TALLOW_CANDLE, WAX_CANDLE }, - { "horn", TOOL_CLASS, TOOLED_HORN, HORN_OF_PLENTY }, - { "shield", ARMOR_CLASS, SMALL_SHIELD, SHIELD_OF_REFLECTION }, - { "hat", ARMOR_CLASS, FEDORA, DUNCE_CAP }, - { "helm", ARMOR_CLASS, ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY }, - { "gloves", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, - { "gauntlets", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, - { "boots", ARMOR_CLASS, LOW_BOOTS, LEVITATION_BOOTS }, - { "shoes", ARMOR_CLASS, LOW_BOOTS, IRON_SHOES }, - { "cloak", ARMOR_CLASS, MUMMY_WRAPPING, CLOAK_OF_DISPLACEMENT }, - { "shirt", ARMOR_CLASS, HAWAIIAN_SHIRT, T_SHIRT }, - { "dragon scales", - ARMOR_CLASS, GRAY_DRAGON_SCALES, YELLOW_DRAGON_SCALES }, - { "dragon scale mail", - ARMOR_CLASS, GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL }, - { "sword", WEAPON_CLASS, SHORT_SWORD, KATANA }, - { "venom", VENOM_CLASS, BLINDING_VENOM, ACID_VENOM }, - { "gray stone", GEM_CLASS, LUCKSTONE, FLINT }, - { "grey stone", GEM_CLASS, LUCKSTONE, FLINT }, + { "bag", TOOL_CLASS, SACK, BAG_OF_TRICKS }, + { "lamp", TOOL_CLASS, OIL_LAMP, MAGIC_LAMP }, + { "candle", TOOL_CLASS, TALLOW_CANDLE, WAX_CANDLE }, + { "horn", TOOL_CLASS, TOOLED_HORN, HORN_OF_PLENTY }, + { "shield", ARMOR_CLASS, SMALL_SHIELD, SHIELD_OF_REFLECTION }, + { "hat", ARMOR_CLASS, FEDORA, DUNCE_CAP }, + { "helm", ARMOR_CLASS, ELVEN_LEATHER_HELM, HELM_OF_TELEPATHY }, + { "gloves", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, + { "gauntlets", ARMOR_CLASS, LEATHER_GLOVES, GAUNTLETS_OF_DEXTERITY }, + { "boots", ARMOR_CLASS, LOW_BOOTS, LEVITATION_BOOTS }, + { "shoes", ARMOR_CLASS, LOW_BOOTS, IRON_SHOES }, + { "cloak", ARMOR_CLASS, MUMMY_WRAPPING, CLOAK_OF_DISPLACEMENT }, + { "shirt", ARMOR_CLASS, HAWAIIAN_SHIRT, T_SHIRT }, + { "dragon scales", + ARMOR_CLASS, GRAY_DRAGON_SCALES, YELLOW_DRAGON_SCALES }, + { "dragon scale mail", + ARMOR_CLASS, GRAY_DRAGON_SCALE_MAIL, YELLOW_DRAGON_SCALE_MAIL }, + { "sword", WEAPON_CLASS, SHORT_SWORD, KATANA }, + { "venom", VENOM_CLASS, BLINDING_VENOM, ACID_VENOM }, + { "gray stone", GEM_CLASS, LUCKSTONE, FLINT }, + { "grey stone", GEM_CLASS, LUCKSTONE, FLINT }, }; /* alternate spellings; if the difference is only the presence or @@ -2236,33 +2248,33 @@ STATIC_OVL NEARDATA const struct o_range o_ranges[] = { vs "pick-axe") then there is no need for inclusion in this list; likewise for ``"of" inversions'' ("boots of speed" vs "speed boots") */ struct alt_spellings { - const char *sp; - int ob; + const char *sp; + int ob; } spellings[] = { - { "pickax", PICK_AXE }, - { "whip", BULLWHIP }, - { "saber", SILVER_SABER }, - { "silver sabre", SILVER_SABER }, - { "smooth shield", SHIELD_OF_REFLECTION }, - { "grey dragon scale mail", GRAY_DRAGON_SCALE_MAIL }, - { "grey dragon scales", GRAY_DRAGON_SCALES }, - { "iron ball", HEAVY_IRON_BALL }, - { "lantern", BRASS_LANTERN }, - { "mattock", DWARVISH_MATTOCK }, - { "amulet of poison resistance", AMULET_VERSUS_POISON }, - { "potion of sleep", POT_SLEEPING }, - { "stone", ROCK }, - { "camera", EXPENSIVE_CAMERA }, - { "tee shirt", T_SHIRT }, - { "can", TIN }, - { "can opener", TIN_OPENER }, - { "kelp", KELP_FROND }, - { "eucalyptus", EUCALYPTUS_LEAF }, - { "hook", GRAPPLING_HOOK }, - { "grappling iron", GRAPPLING_HOOK }, - { "grapnel", GRAPPLING_HOOK }, - { "grapple", GRAPPLING_HOOK }, - { (const char *)0, 0 }, + { "pickax", PICK_AXE }, + { "whip", BULLWHIP }, + { "saber", SILVER_SABER }, + { "silver sabre", SILVER_SABER }, + { "smooth shield", SHIELD_OF_REFLECTION }, + { "grey dragon scale mail", GRAY_DRAGON_SCALE_MAIL }, + { "grey dragon scales", GRAY_DRAGON_SCALES }, + { "iron ball", HEAVY_IRON_BALL }, + { "lantern", BRASS_LANTERN }, + { "mattock", DWARVISH_MATTOCK }, + { "amulet of poison resistance", AMULET_VERSUS_POISON }, + { "potion of sleep", POT_SLEEPING }, + { "stone", ROCK }, + { "camera", EXPENSIVE_CAMERA }, + { "tee shirt", T_SHIRT }, + { "can", TIN }, + { "can opener", TIN_OPENER }, + { "kelp", KELP_FROND }, + { "eucalyptus", EUCALYPTUS_LEAF }, + { "hook", GRAPPLING_HOOK }, + { "grappling iron", GRAPPLING_HOOK }, + { "grapnel", GRAPPLING_HOOK }, + { "grapple", GRAPPLING_HOOK }, + { (const char *)0, 0 }, }; /* @@ -2277,756 +2289,771 @@ readobjnam(bp, no_wish) register char *bp; struct obj *no_wish; { - register char *p; - register int i; - register struct obj *otmp; - int cnt, spe, spesgn, typ, very, rechrg; - int blessed, uncursed, iscursed, ispoisoned, isgreased; - int eroded, eroded2, erodeproof; - int halfeaten, mntmp, contents; - int islit, unlabeled, ishistoric, isdiluted, trapped; - int tmp, tinv, tvariety; - struct fruit *f; - int ftype = context.current_fruit; - char fruitbuf[BUFSZ]; - /* Fruits may not mess up the ability to wish for real objects (since - * you can leave a fruit in a bones file and it will be added to - * another person's game), so they must be checked for last, after - * stripping all the possible prefixes and seeing if there's a real - * name in there. So we have to save the full original name. However, - * it's still possible to do things like "uncursed burnt Alaska", - * or worse yet, "2 burned 5 course meals", so we need to loop to - * strip off the prefixes again, this time stripping only the ones - * possible on food. - * We could get even more detailed so as to allow food names with - * prefixes that _are_ possible on food, so you could wish for - * "2 3 alarm chilis". Currently this isn't allowed; options.c - * automatically sticks 'candied' in front of such names. - */ + register char *p; + register int i; + register struct obj *otmp; + int cnt, spe, spesgn, typ, very, rechrg; + int blessed, uncursed, iscursed, ispoisoned, isgreased; + int eroded, eroded2, erodeproof; + int halfeaten, mntmp, contents; + int islit, unlabeled, ishistoric, isdiluted, trapped; + int tmp, tinv, tvariety; + struct fruit *f; + int ftype = context.current_fruit; + char fruitbuf[BUFSZ]; + /* Fruits may not mess up the ability to wish for real objects (since + * you can leave a fruit in a bones file and it will be added to + * another person's game), so they must be checked for last, after + * stripping all the possible prefixes and seeing if there's a real + * name in there. So we have to save the full original name. However, + * it's still possible to do things like "uncursed burnt Alaska", + * or worse yet, "2 burned 5 course meals", so we need to loop to + * strip off the prefixes again, this time stripping only the ones + * possible on food. + * We could get even more detailed so as to allow food names with + * prefixes that _are_ possible on food, so you could wish for + * "2 3 alarm chilis". Currently this isn't allowed; options.c + * automatically sticks 'candied' in front of such names. + */ - char oclass; - char *un, *dn, *actualn; - const char *name=0; + char oclass; + char *un, *dn, *actualn; + const char *name=0; - cnt = spe = spesgn = typ = very = rechrg = - blessed = uncursed = iscursed = - ispoisoned = isgreased = eroded = eroded2 = erodeproof = - halfeaten = islit = unlabeled = ishistoric = isdiluted = - trapped = 0; - tvariety = RANDOM_TIN; - mntmp = NON_PM; + cnt = spe = spesgn = typ = very = rechrg = + blessed = uncursed = iscursed = + ispoisoned = isgreased = eroded = eroded2 = erodeproof = + halfeaten = islit = unlabeled = ishistoric = isdiluted = + trapped = 0; + tvariety = RANDOM_TIN; + mntmp = NON_PM; #define UNDEFINED 0 #define EMPTY 1 #define SPINACH 2 - contents = UNDEFINED; - oclass = 0; - actualn = dn = un = 0; + contents = UNDEFINED; + oclass = 0; + actualn = dn = un = 0; - if (!bp) goto any; - /* first, remove extra whitespace they may have typed */ - (void)mungspaces(bp); - /* allow wishing for "nothing" to preserve wishless conduct... - [now requires "wand of nothing" if that's what was really wanted] */ - if (!strcmpi(bp, "nothing") || !strcmpi(bp, "nil") || - !strcmpi(bp, "none")) return no_wish; - /* save the [nearly] unmodified choice string */ - Strcpy(fruitbuf, bp); + if (!bp) goto any; + /* first, remove extra whitespace they may have typed */ + (void)mungspaces(bp); + /* allow wishing for "nothing" to preserve wishless conduct... + [now requires "wand of nothing" if that's what was really wanted] */ + if (!strcmpi(bp, "nothing") || !strcmpi(bp, "nil") || + !strcmpi(bp, "none")) return no_wish; + /* save the [nearly] unmodified choice string */ + Strcpy(fruitbuf, bp); - for(;;) { - register int l; + for(;;) { + register int l; - if (!bp || !*bp) goto any; - if (!strncmpi(bp, "an ", l=3) || - !strncmpi(bp, "a ", l=2)) { - cnt = 1; - } else if (!strncmpi(bp, "the ", l=4)) { - ; /* just increment `bp' by `l' below */ - } else if (!cnt && digit(*bp) && strcmp(bp, "0")) { - cnt = atoi(bp); - while(digit(*bp)) bp++; - while(*bp == ' ') bp++; - l = 0; - } else if (*bp == '+' || *bp == '-') { - spesgn = (*bp++ == '+') ? 1 : -1; - spe = atoi(bp); - while(digit(*bp)) bp++; - while(*bp == ' ') bp++; - l = 0; - } else if (!strncmpi(bp, "blessed ", l=8) || - !strncmpi(bp, "holy ", l=5)) { - blessed = 1; - } else if (!strncmpi(bp, "cursed ", l=7) || - !strncmpi(bp, "unholy ", l=7)) { - iscursed = 1; - } else if (!strncmpi(bp, "uncursed ", l=9)) { - uncursed = 1; - } else if (!strncmpi(bp, "rustproof ", l=10) || - !strncmpi(bp, "erodeproof ", l=11) || - !strncmpi(bp, "corrodeproof ", l=13) || - !strncmpi(bp, "fixed ", l=6) || - !strncmpi(bp, "fireproof ", l=10) || - !strncmpi(bp, "rotproof ", l=9)) { - erodeproof = 1; - } else if (!strncmpi(bp,"lit ", l=4) || - !strncmpi(bp,"burning ", l=8)) { - islit = 1; - } else if (!strncmpi(bp,"unlit ", l=6) || - !strncmpi(bp,"extinguished ", l=13)) { - islit = 0; - /* "unlabeled" and "blank" are synonymous */ - } else if (!strncmpi(bp,"unlabeled ", l=10) || - !strncmpi(bp,"unlabelled ", l=11) || - !strncmpi(bp,"blank ", l=6)) { - unlabeled = 1; - } else if(!strncmpi(bp, "poisoned ",l=9)) { - ispoisoned=1; - /* "trapped" recognized but not honored outside wizard mode */ - } else if(!strncmpi(bp, "trapped ",l=8)) { - trapped = 0; /* undo any previous "untrapped" */ - if (wizard) trapped = 1; - } else if(!strncmpi(bp, "untrapped ",l=10)) { - trapped = 2; /* not trapped */ - } else if(!strncmpi(bp, "greased ",l=8)) { - isgreased=1; - } else if (!strncmpi(bp, "very ", l=5)) { - /* very rusted very heavy iron ball */ - very = 1; - } else if (!strncmpi(bp, "thoroughly ", l=11)) { - very = 2; - } else if (!strncmpi(bp, "rusty ", l=6) || - !strncmpi(bp, "rusted ", l=7) || - !strncmpi(bp, "burnt ", l=6) || - !strncmpi(bp, "burned ", l=7)) { - eroded = 1 + very; - very = 0; - } else if (!strncmpi(bp, "corroded ", l=9) || - !strncmpi(bp, "rotted ", l=7)) { - eroded2 = 1 + very; - very = 0; - } else if (!strncmpi(bp, "partly eaten ", l=13) || - !strncmpi(bp, "partially eaten ", l=16)) { - halfeaten = 1; - } else if (!strncmpi(bp, "historic ", l=9)) { - ishistoric = 1; - } else if (!strncmpi(bp, "diluted ", l=8)) { - isdiluted = 1; - } else if(!strncmpi(bp, "empty ", l=6)) { - contents = EMPTY; - } else break; - bp += l; - } - if(!cnt) cnt = 1; /* %% what with "gems" etc. ? */ - if (strlen(bp) > 1) { - if ((p = rindex(bp, '(')) != 0) { - if (p > bp && p[-1] == ' ') p[-1] = 0; - else *p = 0; - p++; - if (!strcmpi(p, "lit)")) { - islit = 1; - } else { - spe = atoi(p); - while (digit(*p)) p++; - if (*p == ':') { - p++; - rechrg = spe; - spe = atoi(p); - while (digit(*p)) p++; - } - if (*p != ')') { - spe = rechrg = 0; - } else { - spesgn = 1; - p++; - if (*p) Strcat(bp, p); - } - } - } - } + if (!bp || !*bp) goto any; + if (!strncmpi(bp, "an ", l=3) || + !strncmpi(bp, "a ", l=2)) { + cnt = 1; + } else if (!strncmpi(bp, "the ", l=4)) { + ; /* just increment `bp' by `l' below */ + } else if (!cnt && digit(*bp) && strcmp(bp, "0")) { + cnt = atoi(bp); + while(digit(*bp)) bp++; + while(*bp == ' ') bp++; + l = 0; + } else if (*bp == '+' || *bp == '-') { + spesgn = (*bp++ == '+') ? 1 : -1; + spe = atoi(bp); + while(digit(*bp)) bp++; + while(*bp == ' ') bp++; + l = 0; + } else if (!strncmpi(bp, "blessed ", l=8) || + !strncmpi(bp, "holy ", l=5)) { + blessed = 1; + } else if (!strncmpi(bp, "cursed ", l=7) || + !strncmpi(bp, "unholy ", l=7)) { + iscursed = 1; + } else if (!strncmpi(bp, "uncursed ", l=9)) { + uncursed = 1; + } else if (!strncmpi(bp, "rustproof ", l=10) || + !strncmpi(bp, "erodeproof ", l=11) || + !strncmpi(bp, "corrodeproof ", l=13) || + !strncmpi(bp, "fixed ", l=6) || + !strncmpi(bp, "fireproof ", l=10) || + !strncmpi(bp, "rotproof ", l=9)) { + erodeproof = 1; + } else if (!strncmpi(bp,"lit ", l=4) || + !strncmpi(bp,"burning ", l=8)) { + islit = 1; + } else if (!strncmpi(bp,"unlit ", l=6) || + !strncmpi(bp,"extinguished ", l=13)) { + islit = 0; + /* "unlabeled" and "blank" are synonymous */ + } else if (!strncmpi(bp,"unlabeled ", l=10) || + !strncmpi(bp,"unlabelled ", l=11) || + !strncmpi(bp,"blank ", l=6)) { + unlabeled = 1; + } else if(!strncmpi(bp, "poisoned ",l=9)) { + ispoisoned=1; + /* "trapped" recognized but not honored outside wizard mode */ + } else if(!strncmpi(bp, "trapped ",l=8)) { + trapped = 0; /* undo any previous "untrapped" */ + if (wizard) trapped = 1; + } else if(!strncmpi(bp, "untrapped ",l=10)) { + trapped = 2; /* not trapped */ + } else if(!strncmpi(bp, "greased ",l=8)) { + isgreased=1; + } else if (!strncmpi(bp, "very ", l=5)) { + /* very rusted very heavy iron ball */ + very = 1; + } else if (!strncmpi(bp, "thoroughly ", l=11)) { + very = 2; + } else if (!strncmpi(bp, "rusty ", l=6) || + !strncmpi(bp, "rusted ", l=7) || + !strncmpi(bp, "burnt ", l=6) || + !strncmpi(bp, "burned ", l=7)) { + eroded = 1 + very; + very = 0; + } else if (!strncmpi(bp, "corroded ", l=9) || + !strncmpi(bp, "rotted ", l=7)) { + eroded2 = 1 + very; + very = 0; + } else if (!strncmpi(bp, "partly eaten ", l=13) || + !strncmpi(bp, "partially eaten ", l=16)) { + halfeaten = 1; + } else if (!strncmpi(bp, "historic ", l=9)) { + ishistoric = 1; + } else if (!strncmpi(bp, "diluted ", l=8)) { + isdiluted = 1; + } else if(!strncmpi(bp, "empty ", l=6)) { + contents = EMPTY; + } else break; + bp += l; + } + if(!cnt) cnt = 1; /* %% what with "gems" etc. ? */ + if (strlen(bp) > 1) { + if ((p = rindex(bp, '(')) != 0) { + if (p > bp && p[-1] == ' ') p[-1] = 0; + else *p = 0; + p++; + if (!strcmpi(p, "lit)")) { + islit = 1; + } else { + spe = atoi(p); + while (digit(*p)) p++; + if (*p == ':') { + p++; + rechrg = spe; + spe = atoi(p); + while (digit(*p)) p++; + } + if (*p != ')') { + spe = rechrg = 0; + } else { + spesgn = 1; + p++; + if (*p) Strcat(bp, p); + } + } + } + } /* otmp->spe is type schar; so we don't want spe to be any bigger or smaller. also, spe should always be positive -- some cheaters may try to confuse atoi() */ - if (spe < 0) { - spesgn = -1; /* cheaters get what they deserve */ - spe = abs(spe); - } - if (spe > SCHAR_LIM) - spe = SCHAR_LIM; - if (rechrg < 0 || rechrg > 7) rechrg = 7; /* recharge_limit */ + if (spe < 0) { + spesgn = -1; /* cheaters get what they deserve */ + spe = abs(spe); + } + if (spe > SCHAR_LIM) + spe = SCHAR_LIM; + if (rechrg < 0 || rechrg > 7) rechrg = 7; /* recharge_limit */ - /* now we have the actual name, as delivered by xname, say - green potions called whisky - scrolls labeled "QWERTY" - egg - fortune cookies - very heavy iron ball named hoei - wand of wishing - elven cloak - */ - if ((p = strstri(bp, " named ")) != 0) { - *p = 0; - name = p+7; - } - if ((p = strstri(bp, " called ")) != 0) { - *p = 0; - un = p+8; - /* "helmet called telepathy" is not "helmet" (a specific type) - * "shield called reflection" is not "shield" (a general type) - */ - for(i = 0; i < SIZE(o_ranges); i++) - if(!strcmpi(bp, o_ranges[i].name)) { - oclass = o_ranges[i].oclass; - goto srch; - } - } - if ((p = strstri(bp, " labeled ")) != 0) { - *p = 0; - dn = p+9; - } else if ((p = strstri(bp, " labelled ")) != 0) { - *p = 0; - dn = p+10; - } - if ((p = strstri(bp, " of spinach")) != 0) { - *p = 0; - contents = SPINACH; - } - - /* - Skip over "pair of ", "pairs of", "set of" and "sets of". - - Accept "3 pair of boots" as well as "3 pairs of boots". It is valid - English either way. See makeplural() for more on pair/pairs. - - We should only double count if the object in question is not - refered to as a "pair of". E.g. We should double if the player - types "pair of spears", but not if the player types "pair of - lenses". Luckily (?) all objects that are refered to as pairs - -- boots, gloves, and lenses -- are also not mergable, so cnt is - ignored anyway. - */ - if(!strncmpi(bp, "pair of ",8)) { - bp += 8; - cnt *= 2; - } else if(cnt > 1 && !strncmpi(bp, "pairs of ",9)) { - bp += 9; - cnt *= 2; - } else if (!strncmpi(bp, "set of ",7)) { - bp += 7; - } else if (!strncmpi(bp, "sets of ",8)) { - bp += 8; - } - - /* - * Find corpse type using "of" (figurine of an orc, tin of orc meat) - * Don't check if it's a wand or spellbook. - * (avoid "wand/finger of death" confusion). - */ - if (!strstri(bp, "wand ") - && !strstri(bp, "spellbook ") - && !strstri(bp, "finger ")) { - if (((p = strstri(bp, "tin of ")) != 0) && - (tmp = tin_variety_txt(p+7, &tinv)) && - (mntmp = name_to_mon(p+7+tmp)) >= LOW_PM) { - *(p+3) = 0; - tvariety = tinv; - } else if ((p = strstri(bp, " of ")) != 0 - && (mntmp = name_to_mon(p+4)) >= LOW_PM) - *p = 0; - } - /* Find corpse type w/o "of" (red dragon scale mail, yeti corpse) */ - if (strncmpi(bp, "samurai sword", 13)) /* not the "samurai" monster! */ - if (strncmpi(bp, "wizard lock", 11)) /* not the "wizard" monster! */ - if (strncmpi(bp, "ninja-to", 8)) /* not the "ninja" rank */ - if (strncmpi(bp, "master key", 10)) /* not the "master" rank */ - if (strncmpi(bp, "magenta", 7)) /* not the "mage" rank */ - if (mntmp < LOW_PM && strlen(bp) > 2 && - (mntmp = name_to_mon(bp)) >= LOW_PM) { - int mntmptoo, mntmplen; /* double check for rank title */ - char *obp = bp; - mntmptoo = title_to_mon(bp, (int *)0, &mntmplen); - bp += mntmp != mntmptoo ? (int)strlen(mons[mntmp].mname) : mntmplen; - if (*bp == ' ') bp++; - else if (!strncmpi(bp, "s ", 2)) bp += 2; - else if (!strncmpi(bp, "es ", 3)) bp += 3; - else if (!*bp && !actualn && !dn && !un && !oclass) { - /* no referent; they don't really mean a monster type */ - bp = obp; - mntmp = NON_PM; - } - } - - /* first change to singular if necessary */ - if (*bp) { - char *sng = makesingular(bp); - if (strcmp(bp, sng)) { - if (cnt == 1) cnt = 2; - Strcpy(bp, sng); - } - } - - /* Alternate spellings (pick-ax, silver sabre, &c) */ - { - struct alt_spellings *as = spellings; - - while (as->sp) { - if (fuzzymatch(bp, as->sp, " -", TRUE)) { - typ = as->ob; - goto typfnd; - } - as++; - } - /* can't use spellings list for this one due to shuffling */ - if (!strncmpi(bp, "grey spell", 10)) - *(bp + 2) = 'a'; - - if ((p = strstri(bp, "armour")) != 0) { - /* skip past "armo", then copy remainer beyond "u" */ - p += 4; - while ((*p = *(p + 1)) != '\0') ++p; /* self terminating */ - } + /* now we have the actual name, as delivered by xname, say + green potions called whisky + scrolls labeled "QWERTY" + egg + fortune cookies + very heavy iron ball named hoei + wand of wishing + elven cloak + */ + if ((p = strstri(bp, " named ")) != 0) { + *p = 0; + name = p+7; + } + if ((p = strstri(bp, " called ")) != 0) { + *p = 0; + un = p+8; + /* "helmet called telepathy" is not "helmet" (a specific type) + * "shield called reflection" is not "shield" (a general type) + */ + for(i = 0; i < SIZE(o_ranges); i++) + if(!strcmpi(bp, o_ranges[i].name)) { + oclass = o_ranges[i].oclass; + goto srch; + } + } + if ((p = strstri(bp, " labeled ")) != 0) { + *p = 0; + dn = p+9; + } else if ((p = strstri(bp, " labelled ")) != 0) { + *p = 0; + dn = p+10; + } + if ((p = strstri(bp, " of spinach")) != 0) { + *p = 0; + contents = SPINACH; } - /* dragon scales - assumes order of dragons */ - if(!strcmpi(bp, "scales") && - mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON) { - typ = GRAY_DRAGON_SCALES + mntmp - PM_GRAY_DRAGON; - mntmp = NON_PM; /* no monster */ - goto typfnd; - } + /* + Skip over "pair of ", "pairs of", "set of" and "sets of". - p = eos(bp); - if(!BSTRCMPI(bp, p-10, "holy water")) { - typ = POT_WATER; - if ((p-bp) >= 12 && *(p-12) == 'u') - iscursed = 1; /* unholy water */ - else blessed = 1; - goto typfnd; - } - if(unlabeled && !BSTRCMPI(bp, p-6, "scroll")) { - typ = SCR_BLANK_PAPER; - goto typfnd; - } - if(unlabeled && !BSTRCMPI(bp, p-9, "spellbook")) { - typ = SPE_BLANK_PAPER; - goto typfnd; - } - /* - * NOTE: Gold pieces are handled as objects nowadays, and therefore - * this section should probably be reconsidered as well as the entire - * gold/money concept. Maybe we want to add other monetary units as - * well in the future. (TH) - */ - if(!BSTRCMPI(bp, p-10, "gold piece") || !BSTRCMPI(bp, p-7, "zorkmid") || - !strcmpi(bp, "gold") || !strcmpi(bp, "money") || - !strcmpi(bp, "coin") || *bp == GOLD_SYM) { - if (cnt > 5000 && !wizard) cnt = 5000; - else if (cnt < 1) cnt = 1; - otmp = mksobj(GOLD_PIECE, FALSE, FALSE); - otmp->quan = (long) cnt; - otmp->owt = weight(otmp); - context.botl = 1; - return otmp; - } + Accept "3 pair of boots" as well as "3 pairs of boots". It is valid + English either way. See makeplural() for more on pair/pairs. - /* check for single character object class code ("/" for wand, &c) */ - if (strlen(bp) == 1 && - (i = def_char_to_objclass(*bp)) < MAXOCLASSES && - i > ILLOBJ_CLASS && (i != VENOM_CLASS || wizard)) { - oclass = i; - goto any; - } + We should only double count if the object in question is not + refered to as a "pair of". E.g. We should double if the player + types "pair of spears", but not if the player types "pair of + lenses". Luckily (?) all objects that are refered to as pairs + -- boots, gloves, and lenses -- are also not mergable, so cnt is + ignored anyway. + */ + if(!strncmpi(bp, "pair of ",8)) { + bp += 8; + cnt *= 2; + } else if(cnt > 1 && !strncmpi(bp, "pairs of ",9)) { + bp += 9; + cnt *= 2; + } else if (!strncmpi(bp, "set of ",7)) { + bp += 7; + } else if (!strncmpi(bp, "sets of ",8)) { + bp += 8; + } - /* Search for class names: XXXXX potion, scroll of XXXXX. Avoid */ - /* false hits on, e.g., rings for "ring mail". */ - if(strncmpi(bp, "enchant ", 8) && - strncmpi(bp, "destroy ", 8) && - strncmpi(bp, "detect food", 11) && - strncmpi(bp, "food detection", 14) && - strncmpi(bp, "ring mail", 9) && - strncmpi(bp, "studded leather armor", 21) && - strncmpi(bp, "leather armor", 13) && - strncmpi(bp, "tooled horn", 11) && - strncmpi(bp, "food ration", 11) && - strncmpi(bp, "meat ring", 9) - ) - for (i = 0; i < (int)(sizeof wrpsym); i++) { - register int j = strlen(wrp[i]); - if(!strncmpi(bp, wrp[i], j)){ - oclass = wrpsym[i]; - if(oclass != AMULET_CLASS) { - bp += j; - if(!strncmpi(bp, " of ", 4)) actualn = bp+4; - /* else if(*bp) ?? */ - } else - actualn = bp; - goto srch; - } - if(!BSTRCMPI(bp, p-j, wrp[i])){ - oclass = wrpsym[i]; - p -= j; - *p = 0; - if(p > bp && p[-1] == ' ') p[-1] = 0; - actualn = dn = bp; - goto srch; - } - } + /* intercept pudding globs here; they're a valid wish target, + * but we need them to not get treated like a corpse. + * + * also don't let player wish for multiple globs. + */ + if ((p = strstri(bp, "glob of ")) != 0 + || (p = strstri(bp, "globs of ")) != 0) { + int globoffset = (*(p+4) == 's') ? 9 : 8; + if ((mntmp = name_to_mon(p + globoffset)) >= PM_GRAY_OOZE + && mntmp <= PM_BLACK_PUDDING) { + mntmp = NON_PM; /* lie to ourselves */ + cnt = 0; /* force only one */ + } + } else { + /* + * Find corpse type using "of" (figurine of an orc, tin of orc meat) + * Don't check if it's a wand or spellbook. + * (avoid "wand/finger of death" confusion). + */ + if (!strstri(bp, "wand ") + && !strstri(bp, "spellbook ") + && !strstri(bp, "finger ")) { + if (((p = strstri(bp, "tin of ")) != 0) && + (tmp = tin_variety_txt(p + 7, &tinv)) && + (mntmp = name_to_mon(p + 7 + tmp)) >= LOW_PM) { + *(p + 3) = 0; + tvariety = tinv; + } else if ((p = strstri(bp, " of ")) != 0 + && (mntmp = name_to_mon(p + 4)) >= LOW_PM) + *p = 0; + } + } + /* Find corpse type w/o "of" (red dragon scale mail, yeti corpse) */ + if (strncmpi(bp, "samurai sword", 13)) /* not the "samurai" monster! */ + if (strncmpi(bp, "wizard lock", 11)) /* not the "wizard" monster! */ + if (strncmpi(bp, "ninja-to", 8)) /* not the "ninja" rank */ + if (strncmpi(bp, "master key", 10)) /* not the "master" rank */ + if (strncmpi(bp, "magenta", 7)) /* not the "mage" rank */ + if (mntmp < LOW_PM && strlen(bp) > 2 && + (mntmp = name_to_mon(bp)) >= LOW_PM) { + int mntmptoo, mntmplen; /* double check for rank title */ + char *obp = bp; + mntmptoo = title_to_mon(bp, (int *)0, &mntmplen); + bp += mntmp != mntmptoo ? (int)strlen(mons[mntmp].mname) : mntmplen; + if (*bp == ' ') bp++; + else if (!strncmpi(bp, "s ", 2)) bp += 2; + else if (!strncmpi(bp, "es ", 3)) bp += 3; + else if (!*bp && !actualn && !dn && !un && !oclass) { + /* no referent; they don't really mean a monster type */ + bp = obp; + mntmp = NON_PM; + } + } - /* Wishing in wizard mode can create traps and furniture. - * Part I: distinguish between trap and object for the two - * types of traps which have corresponding objects: bear trap - * and land mine. "beartrap" (object) and "bear trap" (trap) - * have a difference in spelling which we used to exploit by - * adding a special case in wishymatch(), but "land mine" is - * spelled the same either way so needs different handing. - * Since we need something else for land mine, we've dropped - * the bear trap hack so that both are handled exactly the - * same. To get an armed trap instead of a disarmed object, - * the player can prefix either the object name or the trap - * name with "trapped " (which ordinarily applies to chests - * and tins), or append something--anything at all except for - * " object", but " trap" is suggested--to either the trap - * name or the object name. - */ - if (wizard && (!strncmpi(bp, "bear", 4) || !strncmpi(bp, "land", 4))) { - boolean beartrap = (lowc(*bp) == 'b'); - char *zp = bp + 4; /* skip "bear"/"land" */ + /* first change to singular if necessary */ + if (*bp) { + char *sng = makesingular(bp); + if (strcmp(bp, sng)) { + if (cnt == 1) cnt = 2; + Strcpy(bp, sng); + } + } - if (*zp == ' ') ++zp; /* embedded space is optional */ - if (!strncmpi(zp, beartrap ? "trap" : "mine", 4)) { - zp += 4; - if (trapped == 2 || !strcmpi(zp, " object")) { - /* "untrapped " or " object" */ - typ = beartrap ? BEARTRAP : LAND_MINE; - goto typfnd; - } else if (trapped == 1 || *zp != '\0') { - /* "trapped " or " trap" (actually "*") */ - int idx = trap_to_defsym(beartrap ? BEAR_TRAP : LANDMINE); + /* Alternate spellings (pick-ax, silver sabre, &c) */ + { + struct alt_spellings *as = spellings; - /* use canonical trap spelling, skip object matching */ - Strcpy(bp, defsyms[idx].explanation); - goto wiztrap; - } - /* [no prefix or suffix; we're going to end up matching - the object name and getting a disarmed trap object] */ - } - } + while (as->sp) { + if (fuzzymatch(bp, as->sp, " -", TRUE)) { + typ = as->ob; + goto typfnd; + } + as++; + } + /* can't use spellings list for this one due to shuffling */ + if (!strncmpi(bp, "grey spell", 10)) + *(bp + 2) = 'a'; + + if ((p = strstri(bp, "armour")) != 0) { + /* skip past "armo", then copy remainer beyond "u" */ + p += 4; + while ((*p = *(p + 1)) != '\0') ++p; /* self terminating */ + } + } + + /* dragon scales - assumes order of dragons */ + if(!strcmpi(bp, "scales") && + mntmp >= PM_GRAY_DRAGON && mntmp <= PM_YELLOW_DRAGON) { + typ = GRAY_DRAGON_SCALES + mntmp - PM_GRAY_DRAGON; + mntmp = NON_PM; /* no monster */ + goto typfnd; + } + + p = eos(bp); + if(!BSTRCMPI(bp, p-10, "holy water")) { + typ = POT_WATER; + if ((p-bp) >= 12 && *(p-12) == 'u') + iscursed = 1; /* unholy water */ + else blessed = 1; + goto typfnd; + } + if(unlabeled && !BSTRCMPI(bp, p-6, "scroll")) { + typ = SCR_BLANK_PAPER; + goto typfnd; + } + if(unlabeled && !BSTRCMPI(bp, p-9, "spellbook")) { + typ = SPE_BLANK_PAPER; + goto typfnd; + } + /* + * NOTE: Gold pieces are handled as objects nowadays, and therefore + * this section should probably be reconsidered as well as the entire + * gold/money concept. Maybe we want to add other monetary units as + * well in the future. (TH) + */ + if(!BSTRCMPI(bp, p-10, "gold piece") || !BSTRCMPI(bp, p-7, "zorkmid") || + !strcmpi(bp, "gold") || !strcmpi(bp, "money") || + !strcmpi(bp, "coin") || *bp == GOLD_SYM) { + if (cnt > 5000 && !wizard) cnt = 5000; + else if (cnt < 1) cnt = 1; + otmp = mksobj(GOLD_PIECE, FALSE, FALSE); + otmp->quan = (long) cnt; + otmp->owt = weight(otmp); + context.botl = 1; + return otmp; + } + + /* check for single character object class code ("/" for wand, &c) */ + if (strlen(bp) == 1 && + (i = def_char_to_objclass(*bp)) < MAXOCLASSES && + i > ILLOBJ_CLASS && (i != VENOM_CLASS || wizard)) { + oclass = i; + goto any; + } + + /* Search for class names: XXXXX potion, scroll of XXXXX. Avoid */ + /* false hits on, e.g., rings for "ring mail". */ + if(strncmpi(bp, "enchant ", 8) && + strncmpi(bp, "destroy ", 8) && + strncmpi(bp, "detect food", 11) && + strncmpi(bp, "food detection", 14) && + strncmpi(bp, "ring mail", 9) && + strncmpi(bp, "studded leather armor", 21) && + strncmpi(bp, "leather armor", 13) && + strncmpi(bp, "tooled horn", 11) && + strncmpi(bp, "food ration", 11) && + strncmpi(bp, "meat ring", 9) + ) + for (i = 0; i < (int)(sizeof wrpsym); i++) { + register int j = strlen(wrp[i]); + if(!strncmpi(bp, wrp[i], j)){ + oclass = wrpsym[i]; + if(oclass != AMULET_CLASS) { + bp += j; + if(!strncmpi(bp, " of ", 4)) actualn = bp+4; + /* else if(*bp) ?? */ + } else + actualn = bp; + goto srch; + } + if(!BSTRCMPI(bp, p-j, wrp[i])){ + oclass = wrpsym[i]; + p -= j; + *p = 0; + if(p > bp && p[-1] == ' ') p[-1] = 0; + actualn = dn = bp; + goto srch; + } + } + + /* Wishing in wizard mode can create traps and furniture. + * Part I: distinguish between trap and object for the two + * types of traps which have corresponding objects: bear trap + * and land mine. "beartrap" (object) and "bear trap" (trap) + * have a difference in spelling which we used to exploit by + * adding a special case in wishymatch(), but "land mine" is + * spelled the same either way so needs different handing. + * Since we need something else for land mine, we've dropped + * the bear trap hack so that both are handled exactly the + * same. To get an armed trap instead of a disarmed object, + * the player can prefix either the object name or the trap + * name with "trapped " (which ordinarily applies to chests + * and tins), or append something--anything at all except for + * " object", but " trap" is suggested--to either the trap + * name or the object name. + */ + if (wizard && (!strncmpi(bp, "bear", 4) || !strncmpi(bp, "land", 4))) { + boolean beartrap = (lowc(*bp) == 'b'); + char *zp = bp + 4; /* skip "bear"/"land" */ + + if (*zp == ' ') ++zp; /* embedded space is optional */ + if (!strncmpi(zp, beartrap ? "trap" : "mine", 4)) { + zp += 4; + if (trapped == 2 || !strcmpi(zp, " object")) { + /* "untrapped " or " object" */ + typ = beartrap ? BEARTRAP : LAND_MINE; + goto typfnd; + } else if (trapped == 1 || *zp != '\0') { + /* "trapped " or " trap" (actually "*") */ + int idx = trap_to_defsym(beartrap ? BEAR_TRAP : LANDMINE); + + /* use canonical trap spelling, skip object matching */ + Strcpy(bp, defsyms[idx].explanation); + goto wiztrap; + } + /* [no prefix or suffix; we're going to end up matching + the object name and getting a disarmed trap object] */ + } + } retry: - /* "grey stone" check must be before general "stone" */ - for (i = 0; i < SIZE(o_ranges); i++) - if(!strcmpi(bp, o_ranges[i].name)) { - typ = rnd_class(o_ranges[i].f_o_range, o_ranges[i].l_o_range); - goto typfnd; - } + /* "grey stone" check must be before general "stone" */ + for (i = 0; i < SIZE(o_ranges); i++) + if(!strcmpi(bp, o_ranges[i].name)) { + typ = rnd_class(o_ranges[i].f_o_range, o_ranges[i].l_o_range); + goto typfnd; + } - if (!BSTRCMPI(bp, p-6, " stone")) { - p[-6] = 0; - oclass = GEM_CLASS; - dn = actualn = bp; - goto srch; - } else if (!strcmpi(bp, "looking glass")) { - ; /* avoid false hit on "* glass" */ - } else if (!BSTRCMPI(bp, p-6, " glass") || !strcmpi(bp, "glass")) { - register char *g = bp; - if (strstri(g, "broken")) return (struct obj *)0; - if (!strncmpi(g, "worthless ", 10)) g += 10; - if (!strncmpi(g, "piece of ", 9)) g += 9; - if (!strncmpi(g, "colored ", 8)) g += 8; - else if (!strncmpi(g, "coloured ", 9)) g += 9; - if (!strcmpi(g, "glass")) { /* choose random color */ - /* 9 different kinds */ - typ = LAST_GEM + rnd(9); - if (objects[typ].oc_class == GEM_CLASS) goto typfnd; - else typ = 0; /* somebody changed objects[]? punt */ - } else { /* try to construct canonical form */ - char tbuf[BUFSZ]; - Strcpy(tbuf, "worthless piece of "); - Strcat(tbuf, g); /* assume it starts with the color */ - Strcpy(bp, tbuf); - } - } + if (!BSTRCMPI(bp, p-6, " stone")) { + p[-6] = 0; + oclass = GEM_CLASS; + dn = actualn = bp; + goto srch; + } else if (!strcmpi(bp, "looking glass")) { + ; /* avoid false hit on "* glass" */ + } else if (!BSTRCMPI(bp, p-6, " glass") || !strcmpi(bp, "glass")) { + register char *g = bp; + if (strstri(g, "broken")) return (struct obj *)0; + if (!strncmpi(g, "worthless ", 10)) g += 10; + if (!strncmpi(g, "piece of ", 9)) g += 9; + if (!strncmpi(g, "colored ", 8)) g += 8; + else if (!strncmpi(g, "coloured ", 9)) g += 9; + if (!strcmpi(g, "glass")) { /* choose random color */ + /* 9 different kinds */ + typ = LAST_GEM + rnd(9); + if (objects[typ].oc_class == GEM_CLASS) goto typfnd; + else typ = 0; /* somebody changed objects[]? punt */ + } else { /* try to construct canonical form */ + char tbuf[BUFSZ]; + Strcpy(tbuf, "worthless piece of "); + Strcat(tbuf, g); /* assume it starts with the color */ + Strcpy(bp, tbuf); + } + } - actualn = bp; - if (!dn) dn = actualn; /* ex. "skull cap" */ + actualn = bp; + if (!dn) dn = actualn; /* ex. "skull cap" */ srch: - /* check real names of gems first */ - if(!oclass && actualn) { - for(i = bases[GEM_CLASS]; i <= LAST_GEM; i++) { - register const char *zn; + /* check real names of gems first */ + if(!oclass && actualn) { + for(i = bases[GEM_CLASS]; i <= LAST_GEM; i++) { + register const char *zn; - if((zn = OBJ_NAME(objects[i])) && !strcmpi(actualn, zn)) { - typ = i; - goto typfnd; - } - } - } - i = oclass ? bases[(int)oclass] : 1; - while(i < NUM_OBJECTS && (!oclass || objects[i].oc_class == oclass)){ - register const char *zn; + if((zn = OBJ_NAME(objects[i])) && !strcmpi(actualn, zn)) { + typ = i; + goto typfnd; + } + } + } + i = oclass ? bases[(int)oclass] : 1; + while(i < NUM_OBJECTS && (!oclass || objects[i].oc_class == oclass)){ + register const char *zn; - if (actualn && (zn = OBJ_NAME(objects[i])) != 0 && - wishymatch(actualn, zn, TRUE)) { - typ = i; - goto typfnd; - } - if (dn && (zn = OBJ_DESCR(objects[i])) != 0 && - wishymatch(dn, zn, FALSE)) { - /* don't match extra descriptions (w/o real name) */ - if (!OBJ_NAME(objects[i])) return (struct obj *)0; - typ = i; - goto typfnd; - } - if (un && (zn = objects[i].oc_uname) != 0 && - wishymatch(un, zn, FALSE)) { - typ = i; - goto typfnd; - } - i++; - } - if (actualn) { - struct Jitem *j = Japanese_items; - while(j->item) { - if (actualn && !strcmpi(actualn, j->name)) { - typ = j->item; - goto typfnd; - } - j++; - } - } - /* if we've stripped off "armor" and failed to match anything - in objects[], append "mail" and try again to catch misnamed - requests like "plate armor" and "yellow dragon scale armor" */ - if (oclass == ARMOR_CLASS && !strstri(bp, "mail")) { - /* modifying bp's string is ok; we're about to resort - to random armor if this also fails to match anything */ - Strcat(bp, " mail"); - goto retry; - } - if (!strcmpi(bp, "spinach")) { - contents = SPINACH; - typ = TIN; - goto typfnd; - } - /* Note: not strcmpi. 2 fruits, one capital, one not, are possible. - Also not strncmp. We used to ignore trailing text with it, but - that resulted in "grapefruit" matching "grape" if the latter came - earlier than the former in the fruit list. */ - { - char *fp; - int l, cntf; - int blessedf, iscursedf, uncursedf, halfeatenf; + if (actualn && (zn = OBJ_NAME(objects[i])) != 0 && + wishymatch(actualn, zn, TRUE)) { + typ = i; + goto typfnd; + } + if (dn && (zn = OBJ_DESCR(objects[i])) != 0 && + wishymatch(dn, zn, FALSE)) { + /* don't match extra descriptions (w/o real name) */ + if (!OBJ_NAME(objects[i])) return (struct obj *)0; + typ = i; + goto typfnd; + } + if (un && (zn = objects[i].oc_uname) != 0 && + wishymatch(un, zn, FALSE)) { + typ = i; + goto typfnd; + } + i++; + } + if (actualn) { + struct Jitem *j = Japanese_items; + while(j->item) { + if (actualn && !strcmpi(actualn, j->name)) { + typ = j->item; + goto typfnd; + } + j++; + } + } + /* if we've stripped off "armor" and failed to match anything + in objects[], append "mail" and try again to catch misnamed + requests like "plate armor" and "yellow dragon scale armor" */ + if (oclass == ARMOR_CLASS && !strstri(bp, "mail")) { + /* modifying bp's string is ok; we're about to resort + to random armor if this also fails to match anything */ + Strcat(bp, " mail"); + goto retry; + } + if (!strcmpi(bp, "spinach")) { + contents = SPINACH; + typ = TIN; + goto typfnd; + } + /* Note: not strcmpi. 2 fruits, one capital, one not, are possible. + Also not strncmp. We used to ignore trailing text with it, but + that resulted in "grapefruit" matching "grape" if the latter came + earlier than the former in the fruit list. */ + { + char *fp; + int l, cntf; + int blessedf, iscursedf, uncursedf, halfeatenf; - blessedf = iscursedf = uncursedf = halfeatenf = 0; - cntf = 0; + blessedf = iscursedf = uncursedf = halfeatenf = 0; + cntf = 0; - fp = fruitbuf; - for(;;) { - if (!fp || !*fp) break; - if (!strncmpi(fp, "an ", l=3) || - !strncmpi(fp, "a ", l=2)) { - cntf = 1; - } else if (!cntf && digit(*fp)) { - cntf = atoi(fp); - while(digit(*fp)) fp++; - while(*fp == ' ') fp++; - l = 0; - } else if (!strncmpi(fp, "blessed ", l=8)) { - blessedf = 1; - } else if (!strncmpi(fp, "cursed ", l=7)) { - iscursedf = 1; - } else if (!strncmpi(fp, "uncursed ", l=9)) { - uncursedf = 1; - } else if (!strncmpi(fp, "partly eaten ", l=13) || - !strncmpi(fp, "partially eaten ", l=16)) { - halfeatenf = 1; - } else break; - fp += l; - } + fp = fruitbuf; + for(;;) { + if (!fp || !*fp) break; + if (!strncmpi(fp, "an ", l=3) || + !strncmpi(fp, "a ", l=2)) { + cntf = 1; + } else if (!cntf && digit(*fp)) { + cntf = atoi(fp); + while(digit(*fp)) fp++; + while(*fp == ' ') fp++; + l = 0; + } else if (!strncmpi(fp, "blessed ", l=8)) { + blessedf = 1; + } else if (!strncmpi(fp, "cursed ", l=7)) { + iscursedf = 1; + } else if (!strncmpi(fp, "uncursed ", l=9)) { + uncursedf = 1; + } else if (!strncmpi(fp, "partly eaten ", l=13) || + !strncmpi(fp, "partially eaten ", l=16)) { + halfeatenf = 1; + } else break; + fp += l; + } - for(f=ffruit; f; f = f->nextf) { - /* match type: 0=none, 1=exact, 2=singular, 3=plural */ - int ftyp = 0; + for(f=ffruit; f; f = f->nextf) { + /* match type: 0=none, 1=exact, 2=singular, 3=plural */ + int ftyp = 0; - if (!strcmp(fp, f->fname)) ftyp = 1; - else if (!strcmp(fp, makesingular(f->fname))) ftyp = 2; - else if (!strcmp(fp, makeplural(f->fname))) ftyp = 3; - if (ftyp) { - typ = SLIME_MOLD; - blessed = blessedf; - iscursed = iscursedf; - uncursed = uncursedf; - halfeaten = halfeatenf; - /* adjust count if user explicitly asked for - singular amount (can't happen unless fruit - has been given an already pluralized name) - or for plural amount */ - if (ftyp == 2 && !cntf) cntf = 1; - else if (ftyp == 3 && !cntf) cntf = 2; - cnt = cntf; - ftype = f->fid; - goto typfnd; - } - } - } + if (!strcmp(fp, f->fname)) ftyp = 1; + else if (!strcmp(fp, makesingular(f->fname))) ftyp = 2; + else if (!strcmp(fp, makeplural(f->fname))) ftyp = 3; + if (ftyp) { + typ = SLIME_MOLD; + blessed = blessedf; + iscursed = iscursedf; + uncursed = uncursedf; + halfeaten = halfeatenf; + /* adjust count if user explicitly asked for + singular amount (can't happen unless fruit + has been given an already pluralized name) + or for plural amount */ + if (ftyp == 2 && !cntf) cntf = 1; + else if (ftyp == 3 && !cntf) cntf = 2; + cnt = cntf; + ftype = f->fid; + goto typfnd; + } + } + } - if(!oclass && actualn) { - short objtyp; + if(!oclass && actualn) { + short objtyp; - /* Perhaps it's an artifact specified by name, not type */ - name = artifact_name(actualn, &objtyp); - if(name) { - typ = objtyp; - goto typfnd; - } - } - /* Let wizards wish for traps and furniture. - * Must come after objects check so wizards can still wish for - * trap objects like beartraps. - * Disallow such topology tweaks for WIZKIT startup wishes. - */ + /* Perhaps it's an artifact specified by name, not type */ + name = artifact_name(actualn, &objtyp); + if(name) { + typ = objtyp; + goto typfnd; + } + } + /* Let wizards wish for traps and furniture. + * Must come after objects check so wizards can still wish for + * trap objects like beartraps. + * Disallow such topology tweaks for WIZKIT startup wishes. + */ wiztrap: - if (wizard && !program_state.wizkit_wishing) { - struct rm *lev; - int trap, x = u.ux, y = u.uy; + if (wizard && !program_state.wizkit_wishing) { + struct rm *lev; + int trap, x = u.ux, y = u.uy; - for (trap = NO_TRAP+1; trap < TRAPNUM; trap++) { - struct trap *t; - const char *tname; + for (trap = NO_TRAP+1; trap < TRAPNUM; trap++) { + struct trap *t; + const char *tname; - tname = defsyms[trap_to_defsym(trap)].explanation; - if (strncmpi(tname, bp, strlen(tname))) continue; - /* found it; avoid stupid mistakes */ - if ((trap == TRAPDOOR || trap == HOLE) && - !Can_fall_thru(&u.uz)) trap = ROCKTRAP; - if ((t = maketrap(x, y, trap)) != 0) { - trap = t->ttyp; - tname = defsyms[trap_to_defsym(trap)].explanation; - pline("%s%s.", An(tname), - (trap != MAGIC_PORTAL) ? "" : " to nowhere"); - } else - pline("Creation of %s failed.", an(tname)); - return(&zeroobj); - } + tname = defsyms[trap_to_defsym(trap)].explanation; + if (strncmpi(tname, bp, strlen(tname))) continue; + /* found it; avoid stupid mistakes */ + if ((trap == TRAPDOOR || trap == HOLE) && + !Can_fall_thru(&u.uz)) trap = ROCKTRAP; + if ((t = maketrap(x, y, trap)) != 0) { + trap = t->ttyp; + tname = defsyms[trap_to_defsym(trap)].explanation; + pline("%s%s.", An(tname), + (trap != MAGIC_PORTAL) ? "" : " to nowhere"); + } else + pline("Creation of %s failed.", an(tname)); + return(&zeroobj); + } - /* furniture and terrain */ - lev = &levl[x][y]; - p = eos(bp); - if (!BSTRCMPI(bp, p-8, "fountain")) { - lev->typ = FOUNTAIN; - level.flags.nfountains++; - if(!strncmpi(bp, "magic ", 6)) lev->blessedftn = 1; - pline("A %sfountain.", lev->blessedftn ? "magic " : ""); - newsym(x, y); - return(&zeroobj); - } - if (!BSTRCMPI(bp, p-6, "throne")) { - lev->typ = THRONE; - pline("A throne."); - newsym(x, y); - return(&zeroobj); - } - if (!BSTRCMPI(bp, p-4, "sink")) { - lev->typ = SINK; - level.flags.nsinks++; - pline("A sink."); - newsym(x, y); - return &zeroobj; - } - /* ("water" matches "potion of water" rather than terrain) */ - if (!BSTRCMPI(bp, p-4, "pool") || !BSTRCMPI(bp, p-4, "moat")) { - lev->typ = !BSTRCMPI(bp, p-4, "pool") ? POOL : MOAT; - del_engr_at(x, y); - pline("A %s.", (lev->typ == POOL) ? "pool" : "moat"); - /* Must manually make kelp! */ - water_damage_chain(level.objects[x][y], TRUE); - newsym(x, y); - return &zeroobj; - } - if (!BSTRCMPI(bp, p-4, "lava")) { /* also matches "molten lava" */ - lev->typ = LAVAPOOL; - del_engr_at(x, y); - pline("A pool of molten lava."); - if (!(Levitation || Flying)) (void) lava_effects(); - newsym(x, y); - return &zeroobj; - } + /* furniture and terrain */ + lev = &levl[x][y]; + p = eos(bp); + if (!BSTRCMPI(bp, p-8, "fountain")) { + lev->typ = FOUNTAIN; + level.flags.nfountains++; + if(!strncmpi(bp, "magic ", 6)) lev->blessedftn = 1; + pline("A %sfountain.", lev->blessedftn ? "magic " : ""); + newsym(x, y); + return(&zeroobj); + } + if (!BSTRCMPI(bp, p-6, "throne")) { + lev->typ = THRONE; + pline("A throne."); + newsym(x, y); + return(&zeroobj); + } + if (!BSTRCMPI(bp, p-4, "sink")) { + lev->typ = SINK; + level.flags.nsinks++; + pline("A sink."); + newsym(x, y); + return &zeroobj; + } + /* ("water" matches "potion of water" rather than terrain) */ + if (!BSTRCMPI(bp, p-4, "pool") || !BSTRCMPI(bp, p-4, "moat")) { + lev->typ = !BSTRCMPI(bp, p-4, "pool") ? POOL : MOAT; + del_engr_at(x, y); + pline("A %s.", (lev->typ == POOL) ? "pool" : "moat"); + /* Must manually make kelp! */ + water_damage_chain(level.objects[x][y], TRUE); + newsym(x, y); + return &zeroobj; + } + if (!BSTRCMPI(bp, p-4, "lava")) { /* also matches "molten lava" */ + lev->typ = LAVAPOOL; + del_engr_at(x, y); + pline("A pool of molten lava."); + if (!(Levitation || Flying)) (void) lava_effects(); + newsym(x, y); + return &zeroobj; + } - if (!BSTRCMPI(bp, p-5, "altar")) { - aligntyp al; + if (!BSTRCMPI(bp, p-5, "altar")) { + aligntyp al; - lev->typ = ALTAR; - if(!strncmpi(bp, "chaotic ", 8)) - al = A_CHAOTIC; - else if(!strncmpi(bp, "neutral ", 8)) - al = A_NEUTRAL; - else if(!strncmpi(bp, "lawful ", 7)) - al = A_LAWFUL; - else if(!strncmpi(bp, "unaligned ", 10)) - al = A_NONE; - else /* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */ - al = (!rn2(6)) ? A_NONE : rn2((int)A_LAWFUL+2) - 1; - lev->altarmask = Align2amask(al); - pline("%s altar.", An(align_str(al))); - newsym(x, y); - return(&zeroobj); - } + lev->typ = ALTAR; + if(!strncmpi(bp, "chaotic ", 8)) + al = A_CHAOTIC; + else if(!strncmpi(bp, "neutral ", 8)) + al = A_NEUTRAL; + else if(!strncmpi(bp, "lawful ", 7)) + al = A_LAWFUL; + else if(!strncmpi(bp, "unaligned ", 10)) + al = A_NONE; + else /* -1 - A_CHAOTIC, 0 - A_NEUTRAL, 1 - A_LAWFUL */ + al = (!rn2(6)) ? A_NONE : rn2((int)A_LAWFUL+2) - 1; + lev->altarmask = Align2amask(al); + pline("%s altar.", An(align_str(al))); + newsym(x, y); + return(&zeroobj); + } - if (!BSTRCMPI(bp, p-5, "grave") || - !BSTRCMPI(bp, p-9, "headstone")) { - make_grave(x, y, (char *)0); - pline("%s.", IS_GRAVE(lev->typ) ? "A grave" : - "Can't place a grave here"); - newsym(x, y); - return(&zeroobj); - } + if (!BSTRCMPI(bp, p-5, "grave") || + !BSTRCMPI(bp, p-9, "headstone")) { + make_grave(x, y, (char *)0); + pline("%s.", IS_GRAVE(lev->typ) ? "A grave" : + "Can't place a grave here"); + newsym(x, y); + return(&zeroobj); + } - if (!BSTRCMPI(bp, p-4, "tree")) { - lev->typ = TREE; - pline("A tree."); - newsym(x, y); - block_point(x, y); - return &zeroobj; - } + if (!BSTRCMPI(bp, p-4, "tree")) { + lev->typ = TREE; + pline("A tree."); + newsym(x, y); + block_point(x, y); + return &zeroobj; + } - if (!BSTRCMPI(bp, p-4, "bars")) { - lev->typ = IRONBARS; - pline("Iron bars."); - newsym(x, y); - return &zeroobj; - } - } + if (!BSTRCMPI(bp, p-4, "bars")) { + lev->typ = IRONBARS; + pline("Iron bars."); + newsym(x, y); + return &zeroobj; + } + } - if(!oclass) return((struct obj *)0); + if(!oclass) return((struct obj *)0); any: - if(!oclass) oclass = wrpsym[rn2((int)sizeof(wrpsym))]; + if(!oclass) oclass = wrpsym[rn2((int)sizeof(wrpsym))]; typfnd: - if (typ) oclass = objects[typ].oc_class; + if (typ) oclass = objects[typ].oc_class; - /* handle some objects that are only allowed in wizard mode */ - if (typ && !wizard) { - switch (typ) { - case AMULET_OF_YENDOR: - typ = FAKE_AMULET_OF_YENDOR; - break; - case CANDELABRUM_OF_INVOCATION: - typ = rnd_class(TALLOW_CANDLE, WAX_CANDLE); - break; - case BELL_OF_OPENING: - typ = BELL; - break; - case SPE_BOOK_OF_THE_DEAD: - typ = SPE_BLANK_PAPER; - break; - case MAGIC_LAMP: - typ = OIL_LAMP; - break; - default: - /* catch any other non-wishable objects (venom) */ - if (objects[typ].oc_nowish) return ((struct obj *)0); - break; - } - } + /* handle some objects that are only allowed in wizard mode */ + if (typ && !wizard) { + switch (typ) { + case AMULET_OF_YENDOR: + typ = FAKE_AMULET_OF_YENDOR; + break; + case CANDELABRUM_OF_INVOCATION: + typ = rnd_class(TALLOW_CANDLE, WAX_CANDLE); + break; + case BELL_OF_OPENING: + typ = BELL; + break; + case SPE_BOOK_OF_THE_DEAD: + typ = SPE_BLANK_PAPER; + break; + case MAGIC_LAMP: + typ = OIL_LAMP; + break; + default: + /* catch any other non-wishable objects (venom) */ + if (objects[typ].oc_nowish) return ((struct obj *)0); + break; + } + } if (typ && wizard) { if (typ == SPE_NOVEL) { @@ -3037,294 +3064,294 @@ typfnd: } } - /* - * Create the object, then fine-tune it. - */ - otmp = typ ? mksobj(typ, TRUE, FALSE) : mkobj(oclass, FALSE); - typ = otmp->otyp, oclass = otmp->oclass; /* what we actually got */ + /* + * Create the object, then fine-tune it. + */ + otmp = typ ? mksobj(typ, TRUE, FALSE) : mkobj(oclass, FALSE); + typ = otmp->otyp, oclass = otmp->oclass; /* what we actually got */ - if (islit && - (typ == OIL_LAMP || typ == MAGIC_LAMP || typ == BRASS_LANTERN || - Is_candle(otmp) || typ == POT_OIL)) { - place_object(otmp, u.ux, u.uy); /* make it viable light source */ - begin_burn(otmp, FALSE); - obj_extract_self(otmp); /* now release it for caller's use */ - } + if (islit && + (typ == OIL_LAMP || typ == MAGIC_LAMP || typ == BRASS_LANTERN || + Is_candle(otmp) || typ == POT_OIL)) { + place_object(otmp, u.ux, u.uy); /* make it viable light source */ + begin_burn(otmp, FALSE); + obj_extract_self(otmp); /* now release it for caller's use */ + } - /* if player specified a reasonable count, maybe honor it */ - if (cnt > 0 && objects[typ].oc_merge && - (wizard || cnt < rnd(6) || - (cnt <= 7 && Is_candle(otmp)) || - (cnt <= 20 && - ((oclass == WEAPON_CLASS && is_ammo(otmp)) - || typ == ROCK || is_missile(otmp))))) - otmp->quan = (long) cnt; + /* if player specified a reasonable count, maybe honor it */ + if (cnt > 0 && objects[typ].oc_merge && + (wizard || cnt < rnd(6) || + (cnt <= 7 && Is_candle(otmp)) || + (cnt <= 20 && + ((oclass == WEAPON_CLASS && is_ammo(otmp)) + || typ == ROCK || is_missile(otmp))))) + otmp->quan = (long) cnt; - if (oclass == VENOM_CLASS) otmp->spe = 1; + if (oclass == VENOM_CLASS) otmp->spe = 1; - if (spesgn == 0) { - spe = otmp->spe; - } else if (wizard) { - ; /* no alteration to spe */ - } else if (oclass == ARMOR_CLASS || oclass == WEAPON_CLASS || - is_weptool(otmp) || - (oclass==RING_CLASS && objects[typ].oc_charged)) { - if(spe > rnd(5) && spe > otmp->spe) spe = 0; - if(spe > 2 && Luck < 0) spesgn = -1; - } else { - if (oclass == WAND_CLASS) { - if (spe > 1 && spesgn == -1) spe = 1; - } else { - if (spe > 0 && spesgn == -1) spe = 0; - } - if (spe > otmp->spe) spe = otmp->spe; - } + if (spesgn == 0) { + spe = otmp->spe; + } else if (wizard) { + ; /* no alteration to spe */ + } else if (oclass == ARMOR_CLASS || oclass == WEAPON_CLASS || + is_weptool(otmp) || + (oclass==RING_CLASS && objects[typ].oc_charged)) { + if(spe > rnd(5) && spe > otmp->spe) spe = 0; + if(spe > 2 && Luck < 0) spesgn = -1; + } else { + if (oclass == WAND_CLASS) { + if (spe > 1 && spesgn == -1) spe = 1; + } else { + if (spe > 0 && spesgn == -1) spe = 0; + } + if (spe > otmp->spe) spe = otmp->spe; + } - if (spesgn == -1) spe = -spe; + if (spesgn == -1) spe = -spe; - /* set otmp->spe. This may, or may not, use spe... */ - switch (typ) { - case TIN: if (contents==EMPTY) { - otmp->corpsenm = NON_PM; - otmp->spe = 0; - } else if (contents==SPINACH) { - otmp->corpsenm = NON_PM; - otmp->spe = 1; - } - break; - case SLIME_MOLD: otmp->spe = ftype; - /* Fall through */ - case SKELETON_KEY: case CHEST: case LARGE_BOX: - case HEAVY_IRON_BALL: case IRON_CHAIN: case STATUE: - /* otmp->cobj already done in mksobj() */ - break; + /* set otmp->spe. This may, or may not, use spe... */ + switch (typ) { + case TIN: if (contents==EMPTY) { + otmp->corpsenm = NON_PM; + otmp->spe = 0; + } else if (contents==SPINACH) { + otmp->corpsenm = NON_PM; + otmp->spe = 1; + } + break; + case SLIME_MOLD: otmp->spe = ftype; + /* Fall through */ + case SKELETON_KEY: case CHEST: case LARGE_BOX: + case HEAVY_IRON_BALL: case IRON_CHAIN: case STATUE: + /* otmp->cobj already done in mksobj() */ + break; #ifdef MAIL - case SCR_MAIL: otmp->spe = 1; break; + case SCR_MAIL: otmp->spe = 1; break; #endif - case WAN_WISHING: - if (!wizard) { - otmp->spe = (rn2(10) ? -1 : 0); - break; - } - /* fall through, if wizard */ - default: otmp->spe = spe; - } + case WAN_WISHING: + if (!wizard) { + otmp->spe = (rn2(10) ? -1 : 0); + break; + } + /* fall through, if wizard */ + default: otmp->spe = spe; + } - /* set otmp->corpsenm or dragon scale [mail] */ - if (mntmp >= LOW_PM) { - if (mntmp == PM_LONG_WORM_TAIL) mntmp = PM_LONG_WORM; + /* set otmp->corpsenm or dragon scale [mail] */ + if (mntmp >= LOW_PM) { + if (mntmp == PM_LONG_WORM_TAIL) mntmp = PM_LONG_WORM; - switch (typ) { - case TIN: - otmp->spe = 0; /* No spinach */ - if (dead_species(mntmp, FALSE)) { - otmp->corpsenm = NON_PM; /* it's empty */ - } else if (!(mons[mntmp].geno & G_UNIQ) && - !(mvitals[mntmp].mvflags & G_NOCORPSE) && - mons[mntmp].cnutrit != 0) { - otmp->corpsenm = mntmp; - } - break; - case CORPSE: - if (!(mons[mntmp].geno & G_UNIQ) && - !(mvitals[mntmp].mvflags & G_NOCORPSE)) { - if (mons[mntmp].msound == MS_GUARDIAN) - mntmp = genus(mntmp,1); - set_corpsenm(otmp, mntmp); - } - break; - case FIGURINE: - if (!(mons[mntmp].geno & G_UNIQ) - && !is_human(&mons[mntmp]) + switch (typ) { + case TIN: + otmp->spe = 0; /* No spinach */ + if (dead_species(mntmp, FALSE)) { + otmp->corpsenm = NON_PM; /* it's empty */ + } else if (!(mons[mntmp].geno & G_UNIQ) && + !(mvitals[mntmp].mvflags & G_NOCORPSE) && + mons[mntmp].cnutrit != 0) { + otmp->corpsenm = mntmp; + } + break; + case CORPSE: + if (!(mons[mntmp].geno & G_UNIQ) && + !(mvitals[mntmp].mvflags & G_NOCORPSE)) { + if (mons[mntmp].msound == MS_GUARDIAN) + mntmp = genus(mntmp,1); + set_corpsenm(otmp, mntmp); + } + break; + case FIGURINE: + if (!(mons[mntmp].geno & G_UNIQ) + && !is_human(&mons[mntmp]) #ifdef MAIL - && mntmp != PM_MAIL_DAEMON + && mntmp != PM_MAIL_DAEMON #endif - ) - otmp->corpsenm = mntmp; - break; - case EGG: - mntmp = can_be_hatched(mntmp); - /* this also sets hatch timer if appropriate */ - set_corpsenm(otmp, mntmp); - break; - case STATUE: otmp->corpsenm = mntmp; - if (Has_contents(otmp) && verysmall(&mons[mntmp])) - delete_contents(otmp); /* no spellbook */ - otmp->spe = ishistoric ? STATUE_HISTORIC : 0; - break; - case SCALE_MAIL: - /* Dragon mail - depends on the order of objects */ - /* & dragons. */ - if (mntmp >= PM_GRAY_DRAGON && - mntmp <= PM_YELLOW_DRAGON) - otmp->otyp = GRAY_DRAGON_SCALE_MAIL + - mntmp - PM_GRAY_DRAGON; - break; - } + ) + otmp->corpsenm = mntmp; + break; + case EGG: + mntmp = can_be_hatched(mntmp); + /* this also sets hatch timer if appropriate */ + set_corpsenm(otmp, mntmp); + break; + case STATUE: otmp->corpsenm = mntmp; + if (Has_contents(otmp) && verysmall(&mons[mntmp])) + delete_contents(otmp); /* no spellbook */ + otmp->spe = ishistoric ? STATUE_HISTORIC : 0; + break; + case SCALE_MAIL: + /* Dragon mail - depends on the order of objects */ + /* & dragons. */ + if (mntmp >= PM_GRAY_DRAGON && + mntmp <= PM_YELLOW_DRAGON) + otmp->otyp = GRAY_DRAGON_SCALE_MAIL + + mntmp - PM_GRAY_DRAGON; + break; + } + } + + /* set blessed/cursed -- setting the fields directly is safe + * since weight() is called below and addinv() will take care + * of luck */ + if (iscursed) { + curse(otmp); + } else if (uncursed) { + otmp->blessed = 0; + otmp->cursed = (Luck < 0 && !wizard); + } else if (blessed) { + otmp->blessed = (Luck >= 0 || wizard); + otmp->cursed = (Luck < 0 && !wizard); + } else if (spesgn < 0) { + curse(otmp); + } + + /* set eroded */ + if (is_damageable(otmp) || otmp->otyp == CRYSKNIFE) { + if (eroded && (is_flammable(otmp) || is_rustprone(otmp))) + otmp->oeroded = eroded; + if (eroded2 && (is_corrodeable(otmp) || is_rottable(otmp))) + otmp->oeroded2 = eroded2; + + /* set erodeproof */ + if (erodeproof && !eroded && !eroded2) + otmp->oerodeproof = (Luck >= 0 || wizard); + } + + /* set otmp->recharged */ + if (oclass == WAND_CLASS) { + /* prevent wishing abuse */ + if (otmp->otyp == WAN_WISHING && !wizard) rechrg = 1; + otmp->recharged = (unsigned)rechrg; + } + + /* set poisoned */ + if (ispoisoned) { + if (is_poisonable(otmp)) + otmp->opoisoned = (Luck >= 0); + else if (oclass == FOOD_CLASS) + /* try to taint by making it as old as possible */ + otmp->age = 1L; + } + /* and [un]trapped */ + if (trapped) { + if (Is_box(otmp) || typ == TIN) + otmp->otrapped = (trapped == 1); + } + + if (isgreased) otmp->greased = 1; + + if (isdiluted && otmp->oclass == POTION_CLASS && + otmp->otyp != POT_WATER) + otmp->odiluted = 1; + + /* set tin variety */ + if (otmp->otyp == TIN && tvariety >= 0 && (rn2(4) || wizard)) + set_tin_variety(otmp, tvariety); + + if (name) { + const char *aname; + short objtyp; + + /* an artifact name might need capitalization fixing */ + aname = artifact_name(name, &objtyp); + if (aname && objtyp == otmp->otyp) name = aname; + + /* 3.6.0 tribute - fix up novel */ + if (otmp->otyp == SPE_NOVEL) { + int novidx = 0; + const char *novelname; + + novelname = lookup_novel(name, &novidx); + if (novelname) { + otmp->novelidx = novidx; + name = novelname; + } } - /* set blessed/cursed -- setting the fields directly is safe - * since weight() is called below and addinv() will take care - * of luck */ - if (iscursed) { - curse(otmp); - } else if (uncursed) { - otmp->blessed = 0; - otmp->cursed = (Luck < 0 && !wizard); - } else if (blessed) { - otmp->blessed = (Luck >= 0 || wizard); - otmp->cursed = (Luck < 0 && !wizard); - } else if (spesgn < 0) { - curse(otmp); - } + otmp = oname(otmp, name); + if (otmp->oartifact) { + otmp->quan = 1L; + u.uconduct.wisharti++; /* KMH, conduct */ + } + } - /* set eroded */ - if (is_damageable(otmp) || otmp->otyp == CRYSKNIFE) { - if (eroded && (is_flammable(otmp) || is_rustprone(otmp))) - otmp->oeroded = eroded; - if (eroded2 && (is_corrodeable(otmp) || is_rottable(otmp))) - otmp->oeroded2 = eroded2; + /* more wishing abuse: don't allow wishing for certain artifacts */ + /* and make them pay; charge them for the wish anyway! */ + if ((is_quest_artifact(otmp) || + (otmp->oartifact && rn2(nartifact_exist()) > 1)) && + !wizard) { + artifact_exists(otmp, safe_oname(otmp), FALSE); + obfree(otmp, (struct obj *) 0); + otmp = &zeroobj; + pline("For a moment, you feel %s in your %s, but it disappears!", + something, + makeplural(body_part(HAND))); + } - /* set erodeproof */ - if (erodeproof && !eroded && !eroded2) - otmp->oerodeproof = (Luck >= 0 || wizard); - } + if (halfeaten && otmp->oclass == FOOD_CLASS) { + if (otmp->otyp == CORPSE) + otmp->oeaten = mons[otmp->corpsenm].cnutrit; + else otmp->oeaten = objects[otmp->otyp].oc_nutrition; + /* (do this adjustment before setting up object's weight) */ + consume_oeaten(otmp, 1); + } + otmp->owt = weight(otmp); + if (very && otmp->otyp == HEAVY_IRON_BALL) otmp->owt += 160; - /* set otmp->recharged */ - if (oclass == WAND_CLASS) { - /* prevent wishing abuse */ - if (otmp->otyp == WAN_WISHING && !wizard) rechrg = 1; - otmp->recharged = (unsigned)rechrg; - } - - /* set poisoned */ - if (ispoisoned) { - if (is_poisonable(otmp)) - otmp->opoisoned = (Luck >= 0); - else if (oclass == FOOD_CLASS) - /* try to taint by making it as old as possible */ - otmp->age = 1L; - } - /* and [un]trapped */ - if (trapped) { - if (Is_box(otmp) || typ == TIN) - otmp->otrapped = (trapped == 1); - } - - if (isgreased) otmp->greased = 1; - - if (isdiluted && otmp->oclass == POTION_CLASS && - otmp->otyp != POT_WATER) - otmp->odiluted = 1; - - /* set tin variety */ - if (otmp->otyp == TIN && tvariety >= 0 && (rn2(4) || wizard)) - set_tin_variety(otmp, tvariety); - - if (name) { - const char *aname; - short objtyp; - - /* an artifact name might need capitalization fixing */ - aname = artifact_name(name, &objtyp); - if (aname && objtyp == otmp->otyp) name = aname; - - /* 3.6.0 tribute - fix up novel */ - if (otmp->otyp == SPE_NOVEL) { - int novidx = 0; - const char *novelname; - - novelname = lookup_novel(name, &novidx); - if (novelname) { - otmp->novelidx = novidx; - name = novelname; - } - } - - otmp = oname(otmp, name); - if (otmp->oartifact) { - otmp->quan = 1L; - u.uconduct.wisharti++; - } - } - - /* more wishing abuse: don't allow wishing for certain artifacts */ - /* and make them pay; charge them for the wish anyway! */ - if ((is_quest_artifact(otmp) || - (otmp->oartifact && rn2(nartifact_exist()) > 1)) && - !wizard) { - artifact_exists(otmp, safe_oname(otmp), FALSE); - obfree(otmp, (struct obj *) 0); - otmp = &zeroobj; - pline("For a moment, you feel %s in your %s, but it disappears!", - something, - makeplural(body_part(HAND))); - } - - if (halfeaten && otmp->oclass == FOOD_CLASS) { - if (otmp->otyp == CORPSE) - otmp->oeaten = mons[otmp->corpsenm].cnutrit; - else otmp->oeaten = objects[otmp->otyp].oc_nutrition; - /* (do this adjustment before setting up object's weight) */ - consume_oeaten(otmp, 1); - } - otmp->owt = weight(otmp); - if (very && otmp->otyp == HEAVY_IRON_BALL) otmp->owt += 160; - - return(otmp); + return(otmp); } int rnd_class(first,last) int first,last; { - int i, x, sum=0; + int i, x, sum=0; - if (first == last) - return (first); - for(i=first; i<=last; i++) - sum += objects[i].oc_prob; - if (!sum) /* all zero */ - return first + rn2(last-first+1); - x = rnd(sum); - for(i=first; i<=last; i++) - if (objects[i].oc_prob && (x -= objects[i].oc_prob) <= 0) - return i; - return 0; + if (first == last) + return (first); + for(i=first; i<=last; i++) + sum += objects[i].oc_prob; + if (!sum) /* all zero */ + return first + rn2(last-first+1); + x = rnd(sum); + for(i=first; i<=last; i++) + if (objects[i].oc_prob && (x -= objects[i].oc_prob) <= 0) + return i; + return 0; } STATIC_OVL const char * Japanese_item_name(i) int i; { - struct Jitem *j = Japanese_items; + struct Jitem *j = Japanese_items; - while(j->item) { - if (i == j->item) - return j->name; - j++; - } - return (const char *)0; + while(j->item) { + if (i == j->item) + return j->name; + j++; + } + return (const char *)0; } const char * suit_simple_name(suit) struct obj *suit; { - const char *suitnm, *esuitp; + const char *suitnm, *esuitp; - if (Is_dragon_mail(suit)) - return "dragon mail"; /* dragon scale mail */ - else if (Is_dragon_scales(suit)) - return "dragon scales"; - suitnm = OBJ_NAME(objects[suit->otyp]); - esuitp = eos((char *)suitnm); - if (strlen(suitnm) > 5 && !strcmp(esuitp - 5, " mail")) - return "mail"; /* most suits fall into this category */ - else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket")) - return "jacket"; /* leather jacket */ - /* suit is lame but armor is ambiguous and body armor is absurd */ - return "suit"; + if (Is_dragon_mail(suit)) + return "dragon mail"; /* dragon scale mail */ + else if (Is_dragon_scales(suit)) + return "dragon scales"; + suitnm = OBJ_NAME(objects[suit->otyp]); + esuitp = eos((char *)suitnm); + if (strlen(suitnm) > 5 && !strcmp(esuitp - 5, " mail")) + return "mail"; /* most suits fall into this category */ + else if (strlen(suitnm) > 7 && !strcmp(esuitp - 7, " jacket")) + return "jacket"; /* leather jacket */ + /* suit is lame but armor is ambiguous and body armor is absurd */ + return "suit"; } const char * @@ -3332,17 +3359,17 @@ cloak_simple_name(cloak) struct obj *cloak; { if (cloak) { - switch (cloak->otyp) { - case ROBE: - return "robe"; - case MUMMY_WRAPPING: - return "wrapping"; - case ALCHEMY_SMOCK: - return (objects[cloak->otyp].oc_name_known && - cloak->dknown) ? "smock" : "apron"; - default: - break; - } + switch (cloak->otyp) { + case ROBE: + return "robe"; + case MUMMY_WRAPPING: + return "wrapping"; + case ALCHEMY_SMOCK: + return (objects[cloak->otyp].oc_name_known && + cloak->dknown) ? "smock" : "apron"; + default: + break; + } } return "cloak"; } @@ -3371,12 +3398,12 @@ const char * mimic_obj_name(mtmp) struct monst *mtmp; { - if (mtmp->m_ap_type == M_AP_OBJECT && mtmp->mappearance != STRANGE_OBJECT) { - int idx = objects[mtmp->mappearance].oc_descr_idx; - if (mtmp->mappearance == GOLD_PIECE) return "gold"; - return obj_descr[idx].oc_name; - } - return "whatcha-may-callit"; + if (mtmp->m_ap_type == M_AP_OBJECT && mtmp->mappearance != STRANGE_OBJECT) { + int idx = objects[mtmp->mappearance].oc_descr_idx; + if (mtmp->mappearance == GOLD_PIECE) return "gold"; + return obj_descr[idx].oc_name; + } + return "whatcha-may-callit"; } /* @@ -3396,9 +3423,9 @@ const char *lastR; char *bufp, *endp; /* convert size_t (or int for ancient systems) to ordinary unsigned */ unsigned len, lenlimit, - len_qpfx = (unsigned)(qprefix ? strlen(qprefix) : 0), - len_qsfx = (unsigned)(qsuffix ? strlen(qsuffix) : 0), - len_lastR = (unsigned)strlen(lastR); + len_qpfx = (unsigned)(qprefix ? strlen(qprefix) : 0), + len_qsfx = (unsigned)(qsuffix ? strlen(qsuffix) : 0), + len_lastR = (unsigned)strlen(lastR); lenlimit = QBUFSZ - 1; endp = qbuf + lenlimit; @@ -3406,54 +3433,54 @@ const char *lastR; the result of short_oname() to be shorter than the length of the last resort string, but we ignore that possibility here) */ if (len_qpfx > lenlimit) - impossible("safe_qbuf: prefix too long (%u characters).", - len_qpfx); + impossible("safe_qbuf: prefix too long (%u characters).", + len_qpfx); else if (len_qpfx + len_qsfx > lenlimit) - impossible("safe_qbuf: suffix too long (%u + %u characters).", - len_qpfx, len_qsfx); + impossible("safe_qbuf: suffix too long (%u + %u characters).", + len_qpfx, len_qsfx); else if (len_qpfx + len_lastR + len_qsfx > lenlimit) - impossible("safe_qbuf: filler too long (%u + %u + %u characters).", - len_qpfx, len_lastR, len_qsfx); + impossible("safe_qbuf: filler too long (%u + %u + %u characters).", + len_qpfx, len_lastR, len_qsfx); /* the output buffer might be the same as the prefix if caller has already partially filled it */ if (qbuf == qprefix) { - /* prefix is already in the buffer */ - *endp = '\0'; + /* prefix is already in the buffer */ + *endp = '\0'; } else if (qprefix) { - /* put prefix into the buffer */ - (void)strncpy(qbuf, qprefix, lenlimit); - *endp = '\0'; + /* put prefix into the buffer */ + (void)strncpy(qbuf, qprefix, lenlimit); + *endp = '\0'; } else { - /* no prefix; output buffer starts out empty */ - qbuf[0] = '\0'; + /* no prefix; output buffer starts out empty */ + qbuf[0] = '\0'; } len = (unsigned)strlen(qbuf); if (len + len_lastR + len_qsfx > lenlimit) { - /* too long; skip formatting, last resort output is truncated */ - if (len < lenlimit) { - (void)strncpy(&qbuf[len], lastR, lenlimit - len); - *endp = '\0'; - len = (unsigned)strlen(qbuf); - if (qsuffix && len < lenlimit) { - (void)strncpy(&qbuf[len], qsuffix, lenlimit - len); - *endp = '\0'; - /* len = (unsigned)strlen(qbuf); */ - } - } + /* too long; skip formatting, last resort output is truncated */ + if (len < lenlimit) { + (void)strncpy(&qbuf[len], lastR, lenlimit - len); + *endp = '\0'; + len = (unsigned)strlen(qbuf); + if (qsuffix && len < lenlimit) { + (void)strncpy(&qbuf[len], qsuffix, lenlimit - len); + *endp = '\0'; + /* len = (unsigned)strlen(qbuf); */ + } + } } else { - /* suffix and last resort are guaranteed to fit */ - len += len_qsfx; /* include the pending suffix */ - /* format the object */ - bufp = short_oname(obj, func, altfunc, lenlimit - len); - if (len + strlen(bufp) <= lenlimit) - Strcat(qbuf, bufp); /* formatted name fits */ - else - Strcat(qbuf, lastR); /* use last resort */ - releaseobuf(bufp); + /* suffix and last resort are guaranteed to fit */ + len += len_qsfx; /* include the pending suffix */ + /* format the object */ + bufp = short_oname(obj, func, altfunc, lenlimit - len); + if (len + strlen(bufp) <= lenlimit) + Strcat(qbuf, bufp); /* formatted name fits */ + else + Strcat(qbuf, lastR); /* use last resort */ + releaseobuf(bufp); - if (qsuffix) Strcat(qbuf, qsuffix); + if (qsuffix) Strcat(qbuf, qsuffix); } /* assert( strlen(qbuf) < QBUFSZ ); */ return qbuf; diff --git a/src/pickup.c b/src/pickup.c index ff8bcff25..604d224c6 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -708,7 +708,7 @@ menu_item **pick_list; /* return list of items picked */ int how; /* type of query */ boolean FDECL((*allow), (OBJ_P));/* allow function */ { - int i, j, n; + int i, n; winid win; struct obj *curr, *last, fake_hero_object; struct obj **oarray; @@ -823,7 +823,7 @@ boolean FDECL((*allow), (OBJ_P));/* allow function */ if (n > 0) { menu_item *mi; - int i, k; + int k; /* fix up counts: -1 means no count used => pick all; if fake_hero_object was picked, discard that choice */ diff --git a/src/restore.c b/src/restore.c index d46adbb31..1caab6108 100644 --- a/src/restore.c +++ b/src/restore.c @@ -502,6 +502,13 @@ register struct obj *otmp; else otmp->spe = fruitadd(oldf->fname, (struct fruit *)0); } + +#ifdef SYSCF +#define SYSOPT_CHECK_SAVE_UID sysopt.check_save_uid +#else +#define SYSOPT_CHECK_SAVE_UID TRUE +#endif + STATIC_OVL boolean restgamestate(fd, stuckid, steedid) @@ -517,7 +524,7 @@ unsigned int *stuckid, *steedid; unsigned long uid; mread(fd, (genericptr_t) &uid, sizeof uid); - if (uid != (unsigned long)getuid()) { /* strange ... */ + if (SYSOPT_CHECK_SAVE_UID && uid != (unsigned long)getuid()) { /* strange ... */ /* for wizard mode, issue a reminder; for others, treat it as an attempt to cheat and refuse to restore this file */ pline("Saved game was not yours."); diff --git a/src/sp_lev.c b/src/sp_lev.c index e23c98871..60e2ea759 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -15,6 +15,11 @@ #include "sp_lev.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4244) +#endif + typedef void (*select_iter_func)(int, int, genericptr_t); extern void FDECL(mkmap, (lev_init *)); @@ -5032,7 +5037,7 @@ sp_lev *lvl; break; case SPO_SEL_LINE: { - struct opvar *tmp, *tmp2, *pt = selection_opvar(NULL); + struct opvar *tmp = NULL, *tmp2 = NULL, *pt = selection_opvar(NULL); schar x1,y1,x2,y2; if (!OV_pop_c(tmp)) panic("no ter sel linecoord1"); if (!OV_pop_c(tmp2)) panic("no ter sel linecoord2"); @@ -5050,7 +5055,7 @@ sp_lev *lvl; break; case SPO_SEL_RNDLINE: { - struct opvar *tmp, *tmp2, *tmp3, *pt = selection_opvar(NULL); + struct opvar *tmp = NULL, *tmp2 = NULL, *tmp3, *pt = selection_opvar(NULL); schar x1,y1,x2,y2; if (!OV_pop_i(tmp3)) panic("no ter sel randline1"); if (!OV_pop_c(tmp)) panic("no ter sel randline2"); @@ -5222,4 +5227,8 @@ const char *name; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + /*sp_lev.c*/ diff --git a/src/sys.c b/src/sys.c index 6ca0017f7..e698627be 100644 --- a/src/sys.c +++ b/src/sys.c @@ -67,6 +67,7 @@ sys_early_init() # endif #endif + sysopt.check_save_uid = 1; sysopt.seduce = 1; /* if it's compiled in, default to on */ sysopt_seduce_set(sysopt.seduce); } diff --git a/src/trap.c b/src/trap.c index e1a63b64d..aff2b9719 100644 --- a/src/trap.c +++ b/src/trap.c @@ -2215,7 +2215,7 @@ glovecheck: target = which_armor(mtmp, W_ARMG); (void) destroy_mitem(mtmp, SPBOOK_CLASS, AD_FIRE); (void) destroy_mitem(mtmp, POTION_CLASS, AD_FIRE); } - if (burn_floor_paper(mtmp->mx, mtmp->my, see_it, FALSE) && + if (burn_floor_objects(mtmp->mx, mtmp->my, see_it, FALSE) && !see_it && distu(mtmp->mx, mtmp->my) <= 3*3) You("smell smoke."); if (is_ice(mtmp->mx,mtmp->my)) @@ -2853,7 +2853,7 @@ struct obj *box; /* null for floor trap */ boolean see_it = !Blind; int num, alt; -/* Bug: for box case, the equivalent of burn_floor_paper() ought +/* Bug: for box case, the equivalent of burn_floor_objects() ought * to be done upon its contents. */ @@ -2898,7 +2898,7 @@ struct obj *box; /* null for floor trap */ destroy_item(SPBOOK_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); } - if (!box && burn_floor_paper(u.ux, u.uy, see_it, TRUE) && !see_it) + if (!box && burn_floor_objects(u.ux, u.uy, see_it, TRUE) && !see_it) You("smell paper burning."); if (is_ice(u.ux, u.uy)) melt_ice(u.ux, u.uy, (char *)0); diff --git a/src/vision.c b/src/vision.c index 8abf63c79..64661718b 100644 --- a/src/vision.c +++ b/src/vision.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 vision.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 vision.c $NHDT-Date: 1426449474 2015/03/15 19:57:54 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.14 $ */ /* NetHack 3.5 vision.c $Date: 2009/05/06 10:48:10 $ $Revision: 1.12 $ */ /* SCCS Id: @(#)vision.c 3.5 2007/11/05 */ /* Copyright (c) Dean Luick, with acknowledgements to Dave Cohrs, 1990. */ @@ -499,7 +499,7 @@ vision_recalc(control) char *next_rmin; /* min pointer for the new array */ char *next_rmax; /* max pointer for the new array */ char *ranges; /* circle ranges -- used for xray & night vision */ - int row; /* row counter (outer loop) */ + int row = 0; /* row counter (outer loop) */ int start, stop; /* inner loop starting/stopping index */ int dx, dy; /* one step from a lit door or lit wall (see below) */ register int col; /* inner loop counter */ @@ -513,10 +513,6 @@ vision_recalc(control) vision_full_recalc = 0; /* reset flag */ if (in_mklev || !iflags.vision_inited) return; -#ifdef GCC_WARN - row = 0; -#endif - /* * Either the light sources have been taken care of, or we must * recalculate them here. @@ -1655,18 +1651,15 @@ right_side(row, cb_row, cb_col, fb_row, fb_col, left, right_mark, limits) char *limits; /* points at range limit for current row, or NULL */ { register int i; - register char *rowp; + register char *rowp = NULL; int hit_stone = 0; int left_shadow, right_shadow, loc_right; int lblock_col; /* local block column (current row) */ int nrow, deeper; - char *row_min; /* left most */ - char *row_max; /* right most */ + char *row_min = NULL; /* left most */ + char *row_max = NULL; /* right most */ int lim_max; /* right most limit of circle */ -#ifdef GCC_WARN - rowp = 0; -#endif nrow = row + step; deeper = good_row(nrow) && (!limits || (*limits >= *(limits+1))); if(!vis_func) { @@ -1910,18 +1903,15 @@ left_side(row, cb_row, cb_col, fb_row, fb_col, left_mark, right, limits) char *limits; { register int i; - register char *rowp; + register char *rowp = NULL; int hit_stone = 0; int left_shadow, right_shadow, loc_left; int lblock_col; /* local block column (current row) */ int nrow, deeper; - char *row_min; /* left most */ - char *row_max; /* right most */ + char *row_min = NULL; /* left most */ + char *row_max = NULL; /* right most */ int lim_min; -#ifdef GCC_WARN - rowp = 0; -#endif nrow = row + step; deeper = good_row(nrow) && (!limits || (*limits >= *(limits+1))); if(!vis_func) { @@ -2192,20 +2182,17 @@ right_side(row, left, right_mark, limits) int right_mark; /* last (right side) visible spot on prev row */ char *limits; /* points at range limit for current row, or NULL */ { - int right; /* right limit of "could see" */ - int right_edge; /* right edge of an opening */ - int nrow; /* new row (calculate once) */ - int deeper; /* if TRUE, call self as needed */ - int result; /* set by q?_path() */ - register int i; /* loop counter */ + int right; /* right limit of "could see" */ + int right_edge; /* right edge of an opening */ + int nrow; /* new row (calculate once) */ + int deeper; /* if TRUE, call self as needed */ + int result; /* set by q?_path() */ + register int i; /* loop counter */ register char *rowp = NULL; /* row optimization */ char *row_min = NULL; /* left most [used by macro set_min()] */ char *row_max = NULL; /* right most [used by macro set_max()] */ - int lim_max; /* right most limit of circle */ + int lim_max; /* right most limit of circle */ -#ifdef GCC_WARN - rowp = row_min = row_max = 0; -#endif nrow = row + step; /* * Can go deeper if the row is in bounds and the next row is within @@ -2372,11 +2359,12 @@ left_side(row, left_mark, right, limits) int row, left_mark, right; char *limits; { - int left, left_edge, nrow, deeper, result; - register int i; + int left, left_edge, nrow, deeper, result; + register int i; register char *rowp = NULL; - char *row_min = NULL, *row_max = NULL; - int lim_min; + char *row_min = NULL; + char *row_max = NULL; + int lim_min; #ifdef GCC_WARN rowp = row_min = row_max = 0; diff --git a/src/zap.c b/src/zap.c index a2041199f..89438b6c2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -2112,18 +2112,19 @@ boolean ordinary; case FIRE_HORN: learn_it = TRUE; if (Fire_resistance) { - shieldeff(u.ux, u.uy); - You_feel("rather warm."); - ugolemeffects(AD_FIRE, d(12,6)); - } else { - pline("You've set yourself afire!"); - damage = d(12,6); + shieldeff(u.ux, u.uy); + You_feel("rather warm."); + ugolemeffects(AD_FIRE, d(12,6)); + } else { + pline("You've set yourself afire!"); + damage = d(12,6); } burn_away_slime(); (void) burnarmor(&youmonst); destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE); + destroy_item(FOOD_CLASS, AD_FIRE); /* only slime for now */ break; case WAN_COLD: @@ -3329,6 +3330,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */ if (!rn2(3)) (void)destroy_mitem(mon, POTION_CLASS, AD_FIRE); if (!rn2(3)) (void)destroy_mitem(mon, SCROLL_CLASS, AD_FIRE); if (!rn2(5)) (void)destroy_mitem(mon, SPBOOK_CLASS, AD_FIRE); + destroy_mitem(mon, FOOD_CLASS, AD_FIRE); /* carried slime */ } break; case ZT_COLD: @@ -3473,6 +3475,7 @@ xchar sx, sy; if (!rn2(3)) destroy_item(POTION_CLASS, AD_FIRE); if (!rn2(3)) destroy_item(SCROLL_CLASS, AD_FIRE); if (!rn2(5)) destroy_item(SPBOOK_CLASS, AD_FIRE); + destroy_item(FOOD_CLASS, AD_FIRE); } break; case ZT_COLD: @@ -3569,11 +3572,11 @@ xchar sx, sy; } /* - * burn scrolls and spellbooks on floor at position x,y - * return the number of scrolls and spellbooks burned + * burn objects (such as scrolls and spellbooks) on floor + * at position x,y; return the number of objects burned */ int -burn_floor_paper(x, y, give_feedback, u_caused) +burn_floor_objects(x, y, give_feedback, u_caused) int x, y; boolean give_feedback; /* caller needs to decide about visibility checks */ boolean u_caused; @@ -3585,37 +3588,39 @@ boolean u_caused; for (obj = level.objects[x][y]; obj; obj = obj2) { obj2 = obj->nexthere; - if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) { - if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL || - obj_resists(obj, 2, 100)) - continue; - scrquan = obj->quan; /* number present */ - delquan = 0L; /* number to destroy */ - for (i = scrquan; i > 0L; i--) - if (!rn2(3)) delquan++; - if (delquan) { - /* save name before potential delobj() */ - if (give_feedback) { - obj->quan = 1L; - Strcpy(buf1, (x == u.ux && y == u.uy) ? - xname(obj) : distant_name(obj, xname)); - obj->quan = 2L; - Strcpy(buf2, (x == u.ux && y == u.uy) ? - xname(obj) : distant_name(obj, xname)); - obj->quan = scrquan; - } - /* useupf(), which charges, only if hero caused damage */ - if (u_caused) useupf(obj, delquan); - else if (delquan < scrquan) obj->quan -= delquan; - else delobj(obj); - cnt += delquan; - if (give_feedback) { - if (delquan > 1L) - pline("%ld %s burn.", delquan, buf2); - else - pline("%s burns.", An(buf1)); - } - } + if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS + || (obj->oclass == FOOD_CLASS + && obj->otyp == GLOB_OF_GREEN_SLIME)) { + if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL || + obj_resists(obj, 2, 100)) + continue; + scrquan = obj->quan; /* number present */ + delquan = 0L; /* number to destroy */ + for (i = scrquan; i > 0L; i--) + if (!rn2(3)) delquan++; + if (delquan) { + /* save name before potential delobj() */ + if (give_feedback) { + obj->quan = 1L; + Strcpy(buf1, (x == u.ux && y == u.uy) ? + xname(obj) : distant_name(obj, xname)); + obj->quan = 2L; + Strcpy(buf2, (x == u.ux && y == u.uy) ? + xname(obj) : distant_name(obj, xname)); + obj->quan = scrquan; + } + /* useupf(), which charges, only if hero caused damage */ + if (u_caused) useupf(obj, delquan); + else if (delquan < scrquan) obj->quan -= delquan; + else delobj(obj); + cnt += delquan; + if (give_feedback) { + if (delquan > 1L) + pline("%ld %s burn.", delquan, buf2); + else + pline("%s burns.", An(buf1)); + } + } } } return cnt; @@ -4255,7 +4260,7 @@ short exploding_wand_typ; } if(OBJ_AT(x, y) && abstype == ZT_FIRE) - if (burn_floor_paper(x, y, FALSE, type > 0) && couldsee(x, y)) { + if (burn_floor_objects(x, y, FALSE, type > 0) && couldsee(x, y)) { newsym(x,y); You("%s of smoke.", !Blind ? "see a puff" : "smell a whiff"); @@ -4365,129 +4370,137 @@ const char * const destroy_strings[][3] = { /* also used in trap.c */ void destroy_item(osym, dmgtyp) -register int osym, dmgtyp; + register int osym, dmgtyp; { - register struct obj *obj, *obj2; - register int dmg, xresist, skip; - register long i, cnt, quan; - register int dindx; - const char *mult; - boolean physical_damage; + register struct obj *obj, *obj2; + register int dmg, xresist, skip; + register long i, cnt, quan; + register int dindx; + const char *mult; + boolean physical_damage; - for(obj = invent; obj; obj = obj2) { - obj2 = obj->nobj; - physical_damage = FALSE; - if(obj->oclass != osym) continue; /* test only objs of type osym */ - if(obj->oartifact) continue; /* don't destroy artifacts */ - if(obj->in_use && obj->quan == 1L) continue; /* not available */ - xresist = skip = 0; - /* lint suppression */ - dmg = dindx = 0; - quan = 0L; + for(obj = invent; obj; obj = obj2) { + obj2 = obj->nobj; + physical_damage = FALSE; + if(obj->oclass != osym) continue; /* test only objs of type osym */ + if(obj->oartifact) continue; /* don't destroy artifacts */ + if(obj->in_use && obj->quan == 1L) continue; /* not available */ + xresist = skip = 0; + /* lint suppression */ + dmg = dindx = 0; + quan = 0L; - switch(dmgtyp) { - case AD_COLD: - if(osym == POTION_CLASS && obj->otyp != POT_OIL) { - quan = obj->quan; - dindx = 0; - dmg = rnd(4); - } else skip++; - break; - case AD_FIRE: - xresist = (Fire_resistance && obj->oclass != POTION_CLASS); + switch(dmgtyp) { + case AD_COLD: + if(osym == POTION_CLASS && obj->otyp != POT_OIL) { + quan = obj->quan; + dindx = 0; + dmg = rnd(4); + } else skip++; + break; + case AD_FIRE: + xresist = (Fire_resistance + && obj->oclass != POTION_CLASS + && obj->otyp != GLOB_OF_GREEN_SLIME); - if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL) - skip++; - if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { - skip++; - if (!Blind) - pline("%s glows a strange %s, but remains intact.", - The(xname(obj)), hcolor("dark red")); - } - quan = obj->quan; - switch(osym) { - case POTION_CLASS: - dindx = (obj->otyp != POT_OIL) ? 1 : 2; - dmg = rnd(6); - break; - case SCROLL_CLASS: - dindx = 3; - dmg = 1; - break; - case SPBOOK_CLASS: - dindx = 4; - dmg = 1; - break; - default: - skip++; - break; - } - break; - case AD_ELEC: - xresist = (Shock_resistance && obj->oclass != RING_CLASS); - quan = obj->quan; - switch(osym) { - case RING_CLASS: - if(obj->otyp == RIN_SHOCK_RESISTANCE) - { skip++; break; } - dindx = 5; - dmg = 0; - break; - case WAND_CLASS: - if(obj->otyp == WAN_LIGHTNING) { skip++; break; } + if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL) + skip++; + if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { + skip++; + if (!Blind) + pline("%s glows a strange %s, but remains intact.", + The(xname(obj)), hcolor("dark red")); + } + quan = obj->quan; + switch(osym) { + case POTION_CLASS: + dindx = (obj->otyp != POT_OIL) ? 1 : 2; + dmg = rnd(6); + break; + case SCROLL_CLASS: + dindx = 3; + dmg = 1; + break; + case SPBOOK_CLASS: + dindx = 4; + dmg = 1; + break; + case FOOD_CLASS: + if (obj->otyp == GLOB_OF_GREEN_SLIME) { + dindx = obj->owt / 20; + dmg = 1; + } else { skip++; } + break; + default: + skip++; + break; + } + break; + case AD_ELEC: + xresist = (Shock_resistance && obj->oclass != RING_CLASS); + quan = obj->quan; + switch(osym) { + case RING_CLASS: + if(obj->otyp == RIN_SHOCK_RESISTANCE) + { skip++; break; } + dindx = 5; + dmg = 0; + break; + case WAND_CLASS: + if(obj->otyp == WAN_LIGHTNING) { skip++; break; } #if 0 - if (obj == current_wand) { skip++; break; } + if (obj == current_wand) { skip++; break; } #endif - dindx = 6; - dmg = rnd(10); - break; - default: - skip++; - break; - } - break; - default: - skip++; - break; - } - if(!skip) { - if (obj->in_use) --quan; /* one will be used up elsewhere */ - for(i = cnt = 0L; i < quan; i++) - if(!rn2(3)) cnt++; + dindx = 6; + dmg = rnd(10); + break; + default: + skip++; + break; + } + break; + default: + skip++; + break; + } + if(!skip) { + if (obj->in_use) --quan; /* one will be used up elsewhere */ + for(i = cnt = 0L; i < quan; i++) + if(!rn2(3)) cnt++; - if(!cnt) continue; - mult = (cnt == quan) ? "Your" : - (cnt == 1L) ? "One of your" : "Some of your"; - pline("%s %s %s!", mult, xname(obj), - destroy_strings[dindx][(cnt > 1L)]); - if(osym == POTION_CLASS && dmgtyp != AD_COLD) { - if (!breathless(youmonst.data) || haseyes(youmonst.data)) - potionbreathe(obj); - } - if (obj->owornmask) { - if (obj->owornmask & W_RING) /* ring being worn */ - Ring_gone(obj); - else - setnotworn(obj); - } - if (obj == current_wand) current_wand = 0; /* destroyed */ - for (i = 0; i < cnt; i++) - useup(obj); - if(dmg) { - if(xresist) You("aren't hurt!"); - else { - const char *how = destroy_strings[dindx][2]; - boolean one = (cnt == 1L); + if(!cnt) continue; + mult = (cnt == quan) ? (quan > 1) ? "All of your " : "Your" : + (cnt == 1L) ? "One of your" : "Some of your"; + pline("%s %s %s!", mult, xname(obj), + destroy_strings[dindx][(cnt > 1L)]); + if(osym == POTION_CLASS && dmgtyp != AD_COLD) { + if (!breathless(youmonst.data) || haseyes(youmonst.data)) + potionbreathe(obj); + } + if (obj->owornmask) { + if (obj->owornmask & W_RING) /* ring being worn */ + Ring_gone(obj); + else + setnotworn(obj); + } + if (obj == current_wand) current_wand = 0; /* destroyed */ + for (i = 0; i < cnt; i++) + useup(obj); + if(dmg) { + if(xresist) You("aren't hurt!"); + else { + const char *how = destroy_strings[dindx][2]; + boolean one = (cnt == 1L); - if (physical_damage) dmg = Maybe_Half_Phys(dmg); - losehp(dmg, one ? how : (const char *)makeplural(how), - one ? KILLED_BY_AN : KILLED_BY); - exercise(A_STR, FALSE); - } - } - } - } - return; + if (physical_damage) dmg = Maybe_Half_Phys(dmg); + losehp(dmg, one ? how : (const char *)makeplural(how), + one ? KILLED_BY_AN : KILLED_BY); + exercise(A_STR, FALSE); + } + } + } + } + return; } int @@ -4546,6 +4559,12 @@ int osym, dmgtyp; dindx = 4; tmp++; break; + case FOOD_CLASS: + if (obj->otyp == GLOB_OF_GREEN_SLIME) { + dindx = obj->owt / 20; + tmp++; + } else { skip++; } + break; default: skip++; break; diff --git a/sys/share/lev_lex.c b/sys/share/lev_lex.c index c5fdc4097..bfe700ceb 100644 --- a/sys/share/lev_lex.c +++ b/sys/share/lev_lex.c @@ -369,8 +369,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 197 -#define YY_END_OF_BUFFER 198 +#define YY_NUM_RULES 198 +#define YY_END_OF_BUFFER 199 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -378,123 +378,122 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[1049] = +static yyconst flex_int16_t yy_accept[1038] = { 0, - 0, 0, 0, 0, 198, 196, 192, 191, 196, 196, - 196, 196, 196, 196, 195, 181, 189, 196, 190, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 196, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 192, 196, 195, 2, 196, 192, 196, 196, 195, 181, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 192, 196, 195, 192, 191, 185, - 0, 182, 183, 0, 0, 179, 195, 178, 180, 181, + 0, 0, 0, 0, 199, 197, 193, 192, 197, 197, + 197, 197, 197, 197, 196, 182, 190, 197, 191, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 197, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 193, 197, 196, 2, 197, 193, 197, 197, 196, 182, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 193, 197, 193, 192, 186, 0, 183, 184, + 0, 0, 180, 196, 179, 181, 182, 196, 188, 187, - 195, 187, 186, 184, 188, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 39, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 55, 195, 195, 0, 0, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 185, 189, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 39, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 55, 196, 196, 0, 0, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 153, 195, 195, 192, 0, - 0, 3, 195, 2, 2, 0, 192, 0, 179, 195, - 178, 181, 195, 195, 195, 195, 195, 39, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 192, 0, 2, - 0, 0, 195, 194, 0, 194, 176, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 54, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 153, 196, 196, 193, 0, 0, 3, 196, + 2, 2, 0, 193, 0, 180, 196, 179, 182, 196, + 196, 196, 196, 39, 196, 196, 196, 196, 196, 196, + 193, 0, 2, 0, 0, 195, 0, 195, 177, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 54, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 0, 196, 103, 196, 83, - 195, 195, 195, 0, 195, 103, 195, 83, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 79, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 81, 195, 195, 195, - 195, 138, 195, 195, 195, 195, 127, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 16, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 125, 195, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 79, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 81, + 196, 196, 196, 196, 138, 196, 196, 196, 196, 127, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 16, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 125, 196, 196, 196, 196, 196, 196, 196, 196, - 195, 195, 195, 195, 195, 195, 195, 80, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 193, - 195, 195, 195, 58, 195, 195, 195, 22, 195, 40, - 195, 41, 195, 195, 195, 195, 49, 195, 195, 195, - 195, 56, 6, 195, 195, 195, 53, 195, 195, 195, - 36, 195, 195, 195, 195, 42, 195, 35, 195, 195, - 195, 195, 195, 21, 195, 0, 177, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 159, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 154, - 157, 113, 195, 195, 195, 195, 195, 195, 195, 195, + 80, 196, 196, 196, 196, 196, 196, 196, 196, 194, + 196, 196, 196, 58, 196, 196, 196, 22, 196, 40, + 196, 41, 196, 196, 196, 196, 49, 196, 196, 196, + 196, 56, 6, 196, 196, 196, 53, 196, 196, 196, + 36, 196, 196, 196, 196, 42, 196, 35, 196, 196, + 196, 196, 196, 21, 196, 0, 178, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 159, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 154, 157, 113, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 69, 196, 196, 196, 196, - 195, 195, 195, 195, 69, 195, 195, 195, 195, 195, - 195, 195, 195, 120, 195, 195, 67, 195, 195, 195, - 195, 160, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 118, 195, 195, 195, 106, 195, 195, 195, 195, - 195, 195, 195, 65, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 156, 195, 195, 195, 195, 195, 115, 15, - 0, 195, 195, 195, 195, 195, 195, 2, 0, 28, - 195, 59, 195, 195, 195, 195, 195, 13, 195, 195, - 195, 50, 195, 195, 7, 195, 195, 195, 195, 5, + 196, 196, 196, 196, 120, 196, 196, 67, 196, 196, + 196, 196, 160, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 118, 196, 196, 196, 106, 196, 196, 196, + 196, 196, 196, 196, 65, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 156, 196, 196, 196, 196, 196, 115, + 15, 0, 196, 196, 196, 196, 196, 28, 196, 59, + 196, 196, 196, 196, 196, 13, 196, 196, 196, 50, + 196, 196, 7, 196, 196, 196, 196, 5, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 30, 196, 196, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 30, - 195, 195, 195, 195, 195, 119, 152, 195, 195, 195, - 146, 195, 195, 161, 195, 195, 195, 195, 195, 140, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 155, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 11, 195, 195, 195, 195, - 195, 195, 195, 112, 195, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 124, 195, 12, 195, - 195, 195, 195, 195, 195, 195, 82, 114, 195, 195, + 196, 196, 196, 119, 152, 196, 196, 196, 146, 196, + 196, 161, 196, 196, 196, 196, 196, 140, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 155, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 11, 196, 196, 196, 196, 196, + 196, 196, 112, 196, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 124, 196, 12, 196, 196, + 196, 196, 196, 196, 196, 82, 114, 196, 196, 196, + 196, 196, 196, 196, 196, 128, 196, 196, 196, 196, - 195, 195, 195, 195, 195, 195, 128, 195, 195, 195, - 195, 195, 33, 195, 195, 195, 195, 195, 195, 195, - 195, 195, 29, 195, 195, 195, 195, 195, 195, 17, - 31, 195, 27, 195, 195, 195, 195, 57, 195, 195, - 195, 195, 145, 96, 195, 195, 126, 110, 86, 195, - 122, 72, 107, 195, 195, 195, 164, 195, 195, 87, - 195, 93, 129, 195, 74, 195, 195, 195, 195, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 134, 195, - 195, 108, 195, 195, 195, 195, 195, 195, 195, 195, - 195, 109, 167, 195, 195, 16, 195, 195, 195, 195, + 33, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 29, 196, 196, 196, 196, 196, 196, 17, 31, 196, + 27, 196, 196, 196, 196, 57, 196, 196, 196, 196, + 145, 96, 196, 196, 126, 110, 86, 196, 122, 72, + 107, 196, 196, 196, 196, 164, 196, 196, 87, 196, + 93, 129, 196, 74, 196, 196, 196, 196, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 134, 196, 196, + 108, 196, 196, 196, 196, 196, 196, 196, 196, 196, + 109, 167, 196, 196, 16, 196, 196, 196, 196, 77, + 196, 116, 196, 196, 196, 196, 196, 111, 196, 196, - 77, 195, 116, 195, 195, 195, 195, 195, 111, 195, - 195, 195, 151, 172, 195, 195, 78, 195, 195, 195, - 195, 195, 195, 195, 195, 1, 195, 57, 195, 195, - 195, 60, 195, 195, 195, 195, 195, 195, 195, 4, - 195, 19, 195, 195, 195, 195, 195, 62, 43, 195, - 46, 26, 195, 162, 98, 195, 195, 195, 195, 73, - 158, 195, 195, 97, 195, 195, 195, 92, 195, 195, - 195, 195, 144, 195, 195, 195, 195, 135, 195, 195, - 195, 195, 195, 20, 63, 139, 137, 195, 195, 195, - 195, 195, 195, 195, 117, 195, 131, 95, 195, 150, + 196, 151, 172, 196, 196, 78, 196, 196, 196, 196, + 196, 196, 196, 196, 1, 57, 196, 196, 196, 60, + 196, 196, 196, 196, 196, 196, 196, 4, 196, 19, + 196, 196, 196, 196, 196, 62, 43, 196, 46, 26, + 196, 162, 98, 196, 196, 196, 196, 196, 73, 158, + 196, 196, 97, 196, 196, 196, 92, 196, 196, 196, + 196, 144, 196, 196, 196, 196, 135, 196, 196, 196, + 196, 196, 20, 63, 139, 137, 196, 196, 196, 196, + 196, 196, 196, 117, 196, 131, 95, 196, 150, 196, + 196, 196, 196, 196, 100, 47, 89, 196, 196, 196, - 195, 195, 195, 195, 195, 100, 47, 89, 195, 195, - 195, 195, 195, 26, 195, 45, 195, 195, 34, 61, - 14, 8, 25, 195, 195, 195, 195, 195, 23, 195, - 168, 195, 195, 195, 101, 195, 66, 195, 75, 195, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, - 149, 9, 195, 195, 195, 195, 143, 195, 85, 68, - 195, 71, 195, 195, 195, 195, 175, 163, 130, 133, - 195, 105, 18, 195, 51, 195, 195, 195, 195, 195, - 195, 94, 141, 195, 195, 70, 173, 121, 195, 166, - 195, 174, 91, 132, 84, 147, 148, 170, 195, 195, + 196, 196, 196, 45, 196, 196, 34, 61, 14, 8, + 25, 196, 196, 196, 196, 196, 23, 196, 168, 196, + 196, 196, 101, 176, 196, 66, 196, 75, 196, 196, + 196, 196, 196, 196, 196, 196, 196, 196, 196, 149, + 9, 196, 196, 196, 196, 143, 196, 85, 68, 196, + 71, 196, 196, 196, 196, 175, 163, 130, 133, 196, + 105, 18, 196, 51, 196, 196, 196, 196, 196, 196, + 94, 141, 196, 196, 70, 173, 121, 196, 166, 196, + 174, 91, 132, 84, 147, 148, 170, 196, 196, 99, + 171, 90, 196, 64, 196, 10, 136, 24, 52, 196, - 99, 171, 90, 195, 64, 195, 10, 136, 24, 52, - 195, 195, 195, 195, 195, 76, 88, 123, 104, 195, - 165, 102, 195, 195, 195, 195, 195, 195, 195, 195, - 37, 38, 195, 195, 195, 142, 169, 195, 195, 195, - 195, 195, 195, 195, 48, 32, 44, 0 + 196, 196, 196, 196, 76, 88, 123, 104, 196, 165, + 102, 196, 196, 196, 196, 196, 196, 196, 196, 37, + 38, 196, 196, 196, 142, 169, 196, 196, 196, 196, + 196, 196, 196, 48, 32, 44, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -534,254 +533,252 @@ static yyconst flex_int32_t yy_meta[75] = 1, 2, 3, 2, 2, 1, 1, 2, 1, 1, 1, 2, 4, 2, 4, 1, 1, 1, 5, 5, 5, 6, 6, 5, 6, 5, 5, 6, 5, 5, - 5, 6, 6, 5, 6, 6, 5, 5, 5, 6, - 5, 6, 5, 6, 1, 2, 1, 6, 6, 6, + 6, 6, 6, 5, 6, 6, 5, 5, 6, 6, + 5, 6, 6, 6, 1, 2, 1, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 5, 6, 6 } ; -static yyconst flex_int16_t yy_base[1056] = +static yyconst flex_int16_t yy_base[1045] = { 0, - 0, 73, 102, 77, 1287, 1288, 75, 1288, 1283, 1268, - 1277, 0, 1237, 1267, 1266, 78, 66, 1263, 1262, 1248, - 1241, 57, 63, 59, 64, 101, 0, 63, 79, 119, - 94, 1256, 1242, 128, 127, 126, 1255, 104, 109, 118, - 133, 94, 139, 151, 1207, 95, 132, 1209, 157, 164, - 154, 100, 166, 1202, 173, 175, 176, 56, 1217, 1216, - 239, 1265, 226, 1288, 1264, 252, 248, 258, 271, 157, - 162, 120, 248, 216, 274, 1251, 201, 249, 296, 140, - 306, 301, 176, 265, 346, 352, 369, 232, 1288, 1288, - 1258, 1288, 0, 1253, 1252, 1247, 0, 1246, 1288, 278, + 0, 73, 102, 77, 1235, 1236, 75, 1236, 1231, 1216, + 1225, 0, 1185, 1215, 1214, 78, 66, 1211, 1210, 1196, + 1189, 57, 63, 59, 64, 101, 0, 63, 79, 119, + 94, 1204, 1190, 122, 123, 121, 1203, 104, 105, 100, + 124, 90, 129, 137, 1155, 84, 117, 1157, 139, 150, + 151, 151, 156, 1150, 163, 168, 166, 56, 1165, 1164, + 232, 1213, 216, 1236, 1212, 242, 248, 251, 264, 196, + 155, 167, 208, 228, 241, 1199, 249, 242, 195, 277, + 284, 223, 319, 334, 257, 1236, 1236, 1206, 1236, 0, + 1201, 1200, 1195, 0, 1194, 1236, 298, 1193, 1236, 1236, - 1245, 1288, 1288, 1288, 1288, 1221, 246, 1221, 234, 1233, - 1223, 1236, 1217, 1228, 1225, 1232, 260, 1218, 1216, 1218, - 1228, 0, 1219, 1223, 1204, 1210, 1198, 1204, 1208, 1207, - 1207, 246, 1209, 270, 1204, 301, 1202, 1195, 1201, 1213, - 1211, 1203, 306, 0, 1210, 1198, 347, 208, 301, 1154, - 1176, 1165, 1171, 1174, 317, 1154, 1158, 1154, 1157, 1156, - 1168, 1150, 1152, 338, 1148, 1142, 1139, 1144, 1143, 1149, - 1153, 1144, 1146, 1144, 1144, 300, 348, 280, 337, 1150, - 1132, 1135, 1143, 1128, 217, 345, 1147, 314, 26, 1135, - 1134, 1134, 1125, 360, 1135, 1139, 1125, 1141, 1136, 1139, + 1236, 1236, 1169, 263, 1169, 264, 1181, 1171, 1184, 1165, + 1176, 1173, 1180, 270, 1166, 1164, 1166, 1176, 0, 1167, + 1171, 1152, 1158, 1146, 1152, 1156, 1155, 1155, 280, 1157, + 292, 1152, 301, 1150, 1143, 1149, 1161, 1159, 1151, 259, + 0, 1158, 1146, 203, 304, 272, 1102, 1124, 1113, 1119, + 1122, 288, 1102, 1106, 1102, 1105, 1104, 1116, 1098, 1100, + 308, 1096, 1090, 1087, 1092, 1091, 1097, 1101, 1092, 1094, + 1092, 1092, 234, 281, 296, 299, 1098, 1080, 1083, 1091, + 1076, 81, 315, 1095, 324, 26, 1083, 1082, 1082, 1073, + 330, 1083, 1087, 1073, 1089, 1084, 1087, 281, 333, 1080, - 356, 359, 1132, 1134, 1130, 1122, 372, 259, 325, 1114, - 1113, 1115, 1116, 366, 376, 0, 1113, 349, 435, 1175, - 1174, 1288, 397, 1288, 1288, 1173, 442, 446, 449, 1160, - 0, 423, 404, 424, 316, 439, 440, 1159, 305, 441, - 442, 444, 445, 447, 448, 170, 450, 484, 0, 1288, - 1170, 0, 456, 1288, 1161, 1160, 1155, 1150, 1136, 1148, - 1143, 1127, 1128, 1144, 1126, 1120, 1137, 1123, 1120, 1132, - 0, 1124, 1134, 1123, 1131, 1112, 1113, 1128, 1126, 1114, - 1124, 1109, 1122, 1107, 1120, 1123, 1093, 1117, 1109, 1100, - 1115, 1109, 1105, 1103, 1109, 1103, 1104, 1094, 1091, 1105, + 1082, 1078, 1070, 342, 323, 321, 1062, 1061, 1063, 1064, + 345, 350, 0, 1061, 332, 407, 1123, 1122, 1236, 363, + 1236, 1236, 1121, 411, 415, 416, 1108, 0, 412, 390, + 396, 404, 415, 1107, 337, 410, 420, 417, 423, 424, + 0, 0, 1236, 1118, 0, 1236, 1109, 1108, 1103, 1098, + 1084, 1096, 1091, 1075, 1076, 1092, 1074, 1068, 1085, 1071, + 1068, 1080, 0, 1072, 1082, 1071, 1079, 1060, 1061, 1076, + 1074, 1062, 1072, 1057, 1070, 1055, 1068, 1071, 1041, 1065, + 1057, 1048, 1063, 1057, 1053, 1051, 1057, 1051, 1052, 1042, + 1039, 1053, 1039, 1040, 1043, 326, 1017, 0, 1022, 0, - 1091, 1092, 1095, 462, 1069, 0, 1074, 0, 1059, 1068, - 1058, 1060, 1051, 1055, 1053, 1047, 1055, 416, 1062, 1044, - 1048, 1059, 1042, 1048, 1043, 1052, 1038, 1042, 0, 1035, - 1034, 1044, 1034, 1047, 1031, 1048, 416, 1043, 1032, 427, - 1045, 1022, 1038, 1039, 1033, 1021, 0, 1036, 1030, 1033, - 1023, 0, 1016, 1017, 1025, 1028, 0, 1021, 1026, 1015, - 1027, 1017, 1022, 1021, 402, 1020, 1004, 1011, 1007, 1008, - 440, 1000, 1014, 1013, 1003, 1015, 1012, 1001, 999, 1003, - 1007, 426, 989, 1000, 1000, 1004, 985, 1002, 986, 989, - 997, 983, 438, 991, 979, 997, 983, 978, 0, 979, + 1007, 1016, 1006, 1008, 999, 1003, 1001, 995, 1003, 380, + 1010, 992, 996, 1007, 990, 996, 991, 1000, 987, 985, + 989, 0, 982, 981, 991, 981, 994, 978, 995, 380, + 990, 979, 389, 992, 969, 985, 986, 980, 968, 0, + 983, 977, 980, 970, 0, 963, 964, 972, 975, 0, + 968, 973, 962, 974, 964, 969, 968, 376, 967, 951, + 958, 954, 955, 394, 947, 961, 960, 950, 962, 959, + 948, 946, 950, 954, 390, 936, 947, 947, 951, 932, + 949, 933, 936, 944, 930, 394, 938, 926, 944, 930, + 925, 0, 926, 936, 919, 930, 923, 928, 916, 915, - 989, 972, 983, 976, 981, 969, 968, 0, 495, 487, - 481, 1004, 488, 490, 492, 493, 495, 496, 512, 1288, - 998, 1012, 1003, 0, 1012, 1003, 990, 0, 1008, 0, - 1008, 0, 989, 987, 986, 1000, 0, 999, 973, 997, - 989, 0, 977, 998, 980, 977, 0, 980, 490, 992, - 0, 993, 978, 977, 990, 986, 983, 0, 970, 972, - 983, 969, 983, 0, 974, 476, 1288, 938, 933, 932, - 944, 941, 942, 927, 941, 940, 928, 937, 936, 0, - 935, 934, 919, 925, 931, 926, 922, 912, 927, 0, - 0, 0, 915, 929, 924, 923, 915, 464, 921, 916, + 0, 452, 446, 445, 951, 438, 447, 451, 452, 1236, + 945, 959, 950, 0, 959, 950, 937, 0, 955, 0, + 955, 0, 936, 934, 933, 947, 0, 946, 920, 944, + 936, 0, 924, 945, 927, 924, 0, 927, 447, 939, + 0, 940, 925, 924, 937, 933, 930, 0, 917, 919, + 930, 916, 930, 0, 921, 465, 1236, 885, 880, 879, + 891, 888, 889, 874, 888, 887, 875, 884, 883, 0, + 882, 881, 866, 872, 878, 873, 869, 859, 866, 873, + 0, 0, 0, 861, 875, 870, 869, 861, 418, 867, + 862, 866, 860, 863, 848, 0, 901, 859, 838, 854, - 920, 914, 917, 902, 0, 955, 913, 892, 908, 900, - 896, 907, 908, 0, 907, 891, 0, 905, 908, 894, - 897, 0, 465, 887, 885, 879, 885, 893, 886, 899, - 884, 0, 890, 885, 893, 0, 883, 889, 892, 872, - 890, 458, 889, 0, 877, 866, 867, 871, 880, 864, - 878, 882, 878, 860, 865, 857, 873, 868, 857, 860, - 872, 856, 0, 853, 858, 860, 467, 859, 0, 1288, - 912, 507, 895, 516, 517, 521, 519, 1288, 910, 0, - 886, 0, 884, 888, 879, 872, 867, 0, 887, 878, - 866, 0, 872, 866, 0, 882, 875, 880, 875, 0, + 846, 842, 853, 854, 0, 853, 837, 0, 851, 854, + 840, 843, 0, 417, 833, 831, 825, 831, 839, 832, + 845, 830, 0, 836, 831, 839, 0, 829, 835, 838, + 818, 836, 413, 835, 0, 823, 812, 813, 817, 826, + 810, 824, 828, 824, 806, 811, 803, 819, 814, 803, + 806, 818, 802, 0, 799, 804, 806, 417, 805, 0, + 1236, 858, 460, 841, 464, 465, 468, 0, 833, 0, + 831, 835, 826, 819, 814, 0, 834, 825, 813, 0, + 819, 813, 0, 829, 822, 827, 822, 0, 817, 824, + 804, 811, 809, 807, 817, 804, 806, 0, 802, 808, - 870, 877, 857, 864, 862, 860, 870, 857, 859, 0, - 855, 861, 853, 858, 860, 0, 0, 830, 818, 828, - 0, 827, 826, 0, 817, 815, 824, 815, 808, 0, - 820, 820, 816, 817, 802, 816, 800, 796, 485, 0, - 812, 812, 810, 796, 799, 806, 806, 785, 804, 478, - 796, 792, 794, 790, 795, 782, 798, 794, 795, 795, - 778, 778, 791, 777, 789, 0, 788, 776, 790, 783, - 771, 772, 786, 0, 781, 765, 759, 777, 766, 772, - 768, 770, 765, 759, 775, 770, 0, 759, 0, 752, - 752, 751, 750, 750, 763, 763, 491, 0, 761, 760, + 800, 805, 807, 0, 0, 777, 765, 775, 0, 774, + 773, 0, 764, 762, 771, 762, 755, 0, 767, 767, + 763, 764, 749, 766, 762, 746, 742, 435, 0, 758, + 758, 756, 742, 745, 752, 752, 731, 750, 428, 742, + 738, 740, 736, 741, 728, 744, 740, 741, 741, 724, + 724, 737, 723, 735, 0, 734, 722, 736, 729, 717, + 718, 732, 0, 727, 711, 705, 723, 712, 718, 714, + 716, 711, 705, 721, 716, 0, 705, 0, 698, 698, + 697, 696, 696, 709, 709, 436, 0, 707, 706, 701, + 704, 689, 695, 692, 696, 0, 701, 717, 476, 477, - 755, 758, 743, 749, 746, 750, 0, 755, 771, 524, - 526, 532, 0, 772, 770, 764, 774, 773, 772, 765, - 761, 777, 0, 765, 771, 763, 756, 766, 750, 0, - 0, 720, 0, 88, 261, 336, 519, 0, 515, 523, - 514, 509, 0, 0, 507, 508, 0, 0, 0, 501, - 0, 0, 0, 500, 502, 511, 0, 512, 513, 0, - 501, 0, 0, 517, 0, 514, 513, 509, 523, 521, - 521, 518, 513, 515, 525, 516, 530, 521, 0, 525, - 531, 0, 515, 517, 535, 530, 518, 523, 537, 531, - 530, 0, 0, 533, 530, 0, 521, 527, 533, 530, + 0, 718, 716, 710, 720, 719, 718, 711, 707, 723, + 0, 711, 717, 709, 699, 691, 74, 0, 0, 110, + 0, 207, 230, 474, 467, 0, 467, 472, 462, 457, + 0, 0, 455, 456, 0, 0, 0, 449, 0, 0, + 0, 448, 450, 460, 440, 0, 462, 463, 0, 451, + 0, 0, 467, 0, 464, 463, 459, 473, 471, 471, + 468, 463, 465, 475, 466, 480, 471, 0, 475, 481, + 0, 465, 467, 485, 480, 468, 473, 487, 481, 480, + 0, 0, 483, 480, 0, 471, 477, 483, 480, 0, + 487, 505, 496, 486, 501, 488, 494, 0, 490, 500, - 0, 537, 555, 546, 536, 551, 538, 544, 0, 540, - 550, 551, 0, 0, 552, 556, 0, 559, 550, 561, - 561, 562, 563, 549, 569, 0, 604, 605, 606, 599, - 587, 0, 602, 593, 594, 596, 586, 596, 602, 0, - 605, 0, 608, 597, 614, 588, 601, 0, 0, 600, - 0, 0, 579, 0, 0, 587, 588, 589, 591, 0, - 0, 581, 577, 0, 586, 579, 582, 0, 596, 596, - 589, 585, 0, 594, 595, 607, 594, 0, 592, 606, - 592, 609, 609, 0, 0, 0, 0, 606, 601, 612, - 606, 614, 595, 616, 1288, 617, 0, 0, 619, 0, + 501, 0, 0, 502, 506, 0, 509, 500, 511, 511, + 512, 513, 499, 519, 0, 554, 555, 548, 536, 0, + 551, 542, 543, 544, 534, 544, 550, 0, 553, 0, + 556, 545, 562, 536, 549, 0, 0, 548, 0, 0, + 527, 0, 0, 535, 536, 537, 539, 539, 0, 0, + 530, 526, 0, 535, 528, 531, 0, 545, 545, 538, + 534, 0, 543, 544, 556, 543, 0, 541, 555, 541, + 558, 558, 0, 0, 0, 0, 555, 550, 561, 555, + 563, 544, 565, 1236, 566, 0, 0, 568, 0, 572, + 559, 568, 564, 552, 0, 0, 0, 574, 575, 576, - 623, 610, 619, 615, 603, 0, 0, 0, 625, 626, - 627, 627, 621, 667, 647, 0, 659, 660, 0, 0, - 0, 0, 0, 642, 668, 647, 656, 652, 0, 643, - 0, 640, 641, 632, 0, 632, 0, 636, 0, 645, - 630, 643, 634, 652, 635, 650, 638, 643, 653, 641, - 0, 0, 648, 654, 644, 659, 0, 660, 0, 0, - 661, 0, 650, 653, 660, 657, 0, 0, 0, 0, - 666, 0, 0, 696, 0, 697, 701, 703, 687, 701, - 689, 0, 0, 658, 673, 0, 0, 0, 660, 0, - 669, 0, 0, 0, 0, 0, 0, 0, 668, 663, + 576, 570, 595, 0, 607, 608, 0, 0, 0, 0, + 0, 590, 616, 595, 604, 600, 0, 591, 0, 588, + 589, 580, 0, 0, 580, 0, 584, 0, 593, 578, + 591, 582, 600, 583, 598, 586, 591, 601, 589, 0, + 0, 596, 602, 592, 607, 0, 608, 0, 0, 609, + 0, 598, 601, 608, 605, 0, 0, 0, 0, 614, + 0, 0, 644, 0, 645, 649, 651, 635, 649, 637, + 0, 0, 606, 621, 0, 0, 0, 608, 0, 617, + 0, 0, 0, 0, 0, 0, 0, 616, 611, 0, + 0, 0, 613, 0, 613, 0, 0, 0, 0, 652, - 0, 0, 0, 665, 0, 665, 0, 0, 0, 0, - 704, 705, 700, 701, 715, 0, 0, 0, 0, 686, - 0, 0, 687, 718, 712, 716, 708, 720, 694, 695, - 0, 0, 726, 730, 723, 0, 0, 718, 725, 720, - 718, 723, 724, 720, 0, 0, 0, 1288, 757, 759, - 765, 768, 774, 779, 784 + 653, 648, 649, 663, 0, 0, 0, 0, 634, 0, + 0, 635, 666, 660, 664, 656, 668, 642, 643, 0, + 0, 674, 678, 671, 0, 0, 666, 673, 668, 666, + 671, 672, 668, 0, 0, 0, 1236, 705, 707, 713, + 716, 722, 727, 732 } ; -static yyconst flex_int16_t yy_def[1056] = +static yyconst flex_int16_t yy_def[1045] = { 0, - 1048, 1, 1, 3, 1048, 1048, 1048, 1048, 1048, 1048, - 1049, 1050, 1051, 1048, 1052, 1052, 1048, 1048, 1048, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1048, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1048, 1053, 1052, 1048, 1048, 1054, 1054, 1054, 1052, 69, - 69, 69, 69, 1052, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 1054, 1053, 69, 1048, 1048, 1048, - 1049, 1048, 1050, 1048, 1055, 1048, 1052, 1052, 1048, 1052, + 1037, 1, 1, 3, 1037, 1037, 1037, 1037, 1037, 1037, + 1038, 1039, 1040, 1037, 1041, 1041, 1037, 1037, 1037, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1037, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1037, 1042, 1041, 1037, 1037, 1043, 1043, 1043, 1041, 69, + 69, 69, 69, 1041, 69, 69, 69, 69, 69, 69, + 69, 69, 1043, 1042, 1037, 1037, 1037, 1038, 1037, 1039, + 1037, 1044, 1037, 1041, 1041, 1037, 1041, 1041, 1037, 1037, - 1052, 1048, 1048, 1048, 1048, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1048, 1048, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1037, 1037, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1037, 1037, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1048, 1053, - 1053, 1048, 1052, 1048, 1048, 1048, 1054, 1054, 1054, 69, - 69, 69, 69, 69, 1052, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 1054, 86, 1048, - 1053, 86, 69, 1048, 1048, 1048, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1037, 1042, 1042, 1037, 1041, + 1037, 1037, 1037, 83, 83, 83, 69, 69, 69, 69, + 69, 1041, 69, 69, 69, 69, 69, 69, 69, 69, + 83, 84, 1037, 1042, 84, 1037, 1037, 1037, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1037, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1048, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 69, - 69, 1052, 69, 69, 69, 69, 69, 69, 69, 1048, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1048, 1048, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 69, 69, 1041, 69, 69, 69, 69, 1037, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1037, 1037, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1048, - 1048, 69, 1052, 69, 69, 69, 69, 1048, 1048, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1037, 1037, 69, 1041, 69, 69, 69, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 69, 69, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 69, - 69, 69, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 69, 69, 69, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1048, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 69, 69, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1037, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 69, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, - 1052, 1052, 1052, 1052, 1052, 1052, 1052, 0, 1048, 1048, - 1048, 1048, 1048, 1048, 1048 + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, + 1041, 1041, 1041, 1041, 1041, 1041, 0, 1037, 1037, 1037, + 1037, 1037, 1037, 1037 } ; -static yyconst flex_int16_t yy_nxt[1363] = +static yyconst flex_int16_t yy_nxt[1311] = { 0, 6, 7, 8, 9, 7, 10, 11, 6, 12, 6, 13, 14, 15, 6, 16, 17, 18, 19, 20, 21, @@ -790,152 +787,146 @@ static yyconst flex_int16_t yy_nxt[1363] = 37, 27, 27, 27, 38, 6, 6, 27, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 27, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 27, 27, 27, 61, 108, 88, 61, 61, 88, - 62, 85, 102, 103, 86, 110, 122, 99, 113, 109, - 114, 362, 100, 116, 123, 111, 117, 124, 112, 363, + 60, 27, 27, 27, 61, 105, 85, 61, 61, 85, + 62, 83, 99, 100, 84, 107, 119, 96, 110, 106, + 111, 355, 97, 113, 120, 108, 114, 121, 109, 356, - 115, 125, 118, 63, 64, 65, 66, 87, 147, 67, - 846, 126, 131, 68, 69, 67, 70, 215, 148, 216, - 71, 72, 73, 119, 74, 75, 132, 76, 77, 101, - 76, 78, 79, 120, 230, 80, 121, 127, 81, 82, - 76, 128, 83, 178, 76, 129, 135, 67, 143, 195, - 136, 130, 138, 139, 230, 107, 166, 179, 144, 167, - 137, 145, 168, 196, 140, 141, 99, 142, 149, 84, - 150, 232, 134, 76, 151, 152, 230, 155, 153, 154, - 156, 159, 180, 157, 230, 160, 158, 169, 161, 162, - 230, 233, 163, 181, 247, 164, 417, 182, 170, 173, + 112, 122, 115, 63, 64, 65, 66, 63, 144, 67, + 832, 123, 128, 68, 69, 67, 70, 212, 145, 213, + 71, 72, 73, 116, 74, 75, 129, 76, 77, 98, + 76, 78, 175, 117, 346, 79, 118, 124, 80, 81, + 132, 125, 82, 140, 133, 126, 176, 67, 135, 136, + 347, 127, 163, 141, 134, 164, 142, 833, 165, 152, + 137, 138, 153, 139, 146, 154, 147, 177, 155, 227, + 148, 149, 156, 76, 150, 151, 157, 166, 178, 158, + 159, 227, 179, 160, 230, 170, 161, 181, 167, 171, + 168, 182, 162, 172, 169, 183, 173, 185, 186, 189, - 171, 165, 192, 174, 172, 184, 193, 175, 101, 185, - 176, 188, 189, 186, 197, 230, 194, 304, 198, 187, - 190, 201, 148, 206, 238, 202, 191, 207, 212, 203, - 208, 199, 123, 88, 204, 205, 88, 209, 213, 210, - 219, 214, 211, 219, 223, 113, 220, 235, 128, 1048, - 225, 226, 129, 88, 225, 226, 227, 115, 130, 1048, - 225, 226, 230, 230, 259, 262, 234, 239, 260, 263, - 353, 125, 229, 225, 226, 228, 286, 287, 228, 230, - 109, 126, 228, 230, 228, 231, 354, 99, 230, 230, - 230, 230, 100, 847, 230, 271, 230, 230, 272, 230, + 192, 184, 104, 190, 194, 96, 187, 144, 195, 227, + 229, 198, 188, 191, 193, 199, 203, 145, 209, 200, + 204, 196, 227, 205, 201, 202, 231, 131, 210, 834, + 206, 211, 207, 216, 220, 208, 216, 227, 125, 217, + 106, 240, 126, 85, 222, 223, 224, 98, 127, 1037, + 222, 223, 1037, 222, 223, 227, 227, 110, 85, 232, + 235, 85, 835, 227, 122, 226, 222, 223, 225, 112, + 233, 225, 234, 114, 123, 225, 227, 225, 228, 115, + 120, 251, 227, 227, 227, 252, 331, 227, 292, 227, + 227, 227, 227, 227, 293, 254, 332, 227, 227, 255, - 230, 230, 289, 236, 230, 290, 117, 230, 230, 230, - 230, 230, 237, 230, 240, 230, 228, 212, 128, 230, - 230, 392, 241, 143, 393, 292, 278, 213, 130, 101, - 214, 242, 243, 144, 293, 300, 145, 412, 230, 343, - 268, 301, 230, 244, 245, 344, 246, 219, 225, 226, - 248, 147, 338, 249, 250, 251, 252, 305, 848, 252, - 306, 148, 339, 252, 252, 252, 252, 359, 307, 313, - 252, 252, 252, 314, 360, 252, 361, 252, 252, 315, - 252, 252, 252, 230, 394, 252, 324, 253, 252, 252, - 252, 128, 252, 395, 252, 241, 340, 252, 325, 326, + 227, 227, 236, 237, 227, 263, 140, 96, 264, 225, + 278, 279, 97, 296, 238, 138, 141, 239, 145, 142, + 216, 222, 223, 241, 281, 284, 242, 282, 297, 333, + 456, 298, 373, 334, 285, 227, 243, 244, 245, 299, + 305, 245, 374, 335, 306, 245, 245, 245, 245, 98, + 307, 227, 245, 245, 245, 336, 316, 245, 270, 245, + 245, 337, 245, 245, 338, 339, 340, 245, 317, 318, + 245, 245, 457, 319, 245, 348, 349, 352, 361, 245, + 387, 362, 350, 375, 353, 385, 354, 376, 386, 388, + 363, 364, 382, 393, 383, 365, 402, 366, 400, 401, - 341, 130, 345, 346, 347, 355, 356, 380, 368, 382, - 342, 369, 357, 383, 400, 407, 408, 381, 230, 252, - 370, 371, 389, 252, 390, 372, 402, 373, 384, 403, - 409, 391, 99, 404, 401, 405, 219, 232, 230, 219, - 281, 410, 220, 88, 225, 226, 227, 1048, 225, 226, - 1048, 225, 226, 230, 230, 230, 230, 413, 230, 230, - 411, 230, 230, 229, 230, 415, 466, 416, 525, 526, - 230, 273, 479, 283, 101, 498, 296, 480, 502, 418, - 466, 543, 414, 499, 281, 219, 225, 226, 248, 419, - 531, 249, 532, 544, 555, 230, 503, 570, 571, 281, + 395, 384, 377, 396, 227, 245, 273, 397, 216, 398, + 227, 216, 85, 394, 217, 224, 1037, 1037, 225, 225, + 225, 96, 225, 225, 227, 405, 229, 403, 260, 227, + 226, 227, 404, 406, 227, 407, 469, 227, 227, 489, + 493, 470, 516, 517, 522, 534, 523, 490, 287, 408, + 546, 288, 227, 409, 561, 562, 547, 535, 494, 227, + 227, 227, 423, 98, 563, 227, 227, 414, 589, 456, + 631, 653, 671, 565, 227, 672, 654, 695, 227, 227, + 590, 567, 227, 632, 696, 699, 749, 760, 566, 804, + 227, 227, 805, 761, 700, 568, 836, 837, 750, 598, - 556, 230, 230, 424, 230, 572, 230, 230, 467, 230, - 230, 601, 433, 574, 578, 579, 642, 682, 575, 664, - 683, 230, 467, 602, 665, 577, 230, 706, 460, 643, - 230, 230, 576, 230, 707, 230, 760, 771, 230, 710, - 230, 711, 580, 772, 815, 712, 230, 816, 761, 849, - 850, 828, 610, 827, 851, 829, 852, 853, 854, 855, - 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, - 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, - 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, - 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, + 817, 816, 838, 839, 840, 841, 842, 843, 844, 845, + 846, 457, 847, 848, 849, 850, 851, 852, 853, 854, + 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, + 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, + 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, + 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, + 895, 896, 897, 898, 899, 900, 901, 902, 227, 227, + 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, + 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, + 923, 924, 925, 926, 927, 928, 929, 840, 930, 931, - 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, - 906, 907, 908, 909, 910, 911, 912, 913, 230, 230, - 230, 915, 916, 917, 918, 919, 848, 920, 921, 922, - 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, - 933, 934, 935, 936, 937, 938, 939, 940, 914, 941, + 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, - 972, 230, 973, 974, 975, 976, 977, 978, 979, 980, - 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, + 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, + 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, + 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, + 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, + 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, + 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, - 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, - 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, - 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, - 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, - 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, - 1041, 1042, 1043, 1044, 1045, 1046, 1047, 91, 91, 91, - 91, 91, 91, 93, 93, 94, 94, 845, 94, 94, - 94, 97, 97, 97, 221, 221, 221, 221, 221, 221, - 228, 228, 228, 228, 255, 255, 844, 255, 255, 255, - 843, 842, 841, 840, 839, 838, 837, 836, 835, 834, + 1032, 1033, 1034, 1035, 1036, 88, 88, 88, 88, 88, + 88, 90, 90, 91, 91, 831, 91, 91, 91, 94, + 94, 94, 218, 218, 218, 218, 218, 218, 225, 225, + 225, 225, 247, 247, 830, 247, 247, 247, 829, 828, + 827, 826, 825, 824, 823, 822, 821, 820, 819, 818, + 815, 814, 813, 812, 811, 810, 809, 808, 807, 806, + 803, 802, 801, 800, 799, 798, 797, 796, 795, 794, + 793, 792, 791, 790, 789, 788, 787, 786, 785, 784, + 783, 782, 781, 780, 779, 778, 777, 776, 775, 774, + 773, 772, 771, 770, 769, 768, 767, 766, 765, 764, - 833, 832, 831, 830, 826, 825, 824, 823, 822, 821, - 820, 819, 818, 817, 814, 813, 812, 811, 810, 809, - 808, 807, 806, 805, 804, 803, 802, 801, 800, 799, - 798, 797, 796, 795, 794, 793, 792, 791, 790, 789, - 788, 787, 786, 785, 784, 783, 782, 781, 780, 779, - 778, 777, 776, 775, 774, 773, 770, 769, 768, 767, - 766, 765, 764, 763, 762, 759, 758, 757, 756, 755, - 754, 753, 752, 751, 750, 749, 748, 747, 746, 745, - 744, 743, 742, 741, 740, 739, 738, 737, 736, 735, - 734, 733, 732, 731, 730, 729, 728, 727, 726, 725, + 763, 762, 759, 758, 757, 756, 755, 754, 753, 752, + 751, 748, 747, 746, 745, 744, 743, 742, 741, 740, + 739, 738, 737, 736, 735, 734, 733, 732, 731, 730, + 729, 728, 727, 726, 725, 724, 723, 722, 721, 720, + 719, 718, 717, 716, 715, 714, 713, 712, 711, 710, + 709, 708, 707, 706, 705, 704, 703, 702, 701, 698, + 561, 697, 694, 693, 692, 691, 690, 689, 688, 687, + 686, 685, 684, 683, 682, 681, 680, 679, 678, 677, + 676, 675, 674, 673, 670, 669, 668, 667, 666, 665, + 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, - 724, 723, 722, 721, 720, 719, 718, 717, 716, 715, - 714, 713, 578, 709, 570, 708, 705, 704, 703, 702, - 701, 700, 699, 698, 697, 696, 695, 694, 693, 692, - 691, 690, 689, 688, 687, 686, 685, 684, 681, 680, - 679, 678, 677, 676, 675, 674, 673, 672, 671, 670, - 669, 668, 667, 666, 663, 662, 661, 660, 659, 658, - 657, 656, 655, 654, 653, 652, 651, 650, 649, 648, - 647, 646, 645, 644, 641, 640, 639, 638, 637, 636, - 635, 634, 633, 632, 631, 630, 629, 628, 627, 626, - 625, 624, 623, 622, 621, 620, 619, 618, 617, 616, + 652, 651, 650, 649, 648, 647, 646, 645, 644, 643, + 642, 641, 640, 639, 638, 637, 636, 635, 634, 633, + 630, 629, 628, 627, 626, 625, 624, 623, 622, 621, + 620, 619, 618, 617, 616, 615, 614, 613, 612, 611, + 610, 609, 608, 607, 606, 605, 604, 603, 602, 601, + 600, 599, 598, 597, 596, 595, 594, 593, 592, 591, + 588, 587, 586, 585, 584, 583, 582, 581, 580, 579, + 578, 577, 576, 575, 574, 573, 572, 571, 570, 569, + 568, 564, 560, 559, 558, 557, 556, 555, 554, 553, + 552, 551, 550, 549, 548, 545, 544, 543, 542, 541, - 615, 614, 613, 612, 611, 610, 609, 608, 607, 606, - 605, 604, 603, 600, 599, 598, 597, 596, 595, 594, - 593, 592, 591, 590, 589, 588, 587, 586, 585, 584, - 583, 582, 581, 580, 573, 569, 568, 567, 566, 565, - 564, 563, 562, 561, 560, 559, 558, 557, 554, 553, - 552, 551, 550, 549, 548, 547, 546, 545, 542, 541, - 540, 539, 538, 537, 536, 535, 534, 533, 530, 529, - 528, 527, 447, 524, 523, 522, 521, 520, 519, 518, - 517, 516, 515, 514, 513, 512, 511, 510, 509, 508, - 507, 506, 505, 504, 501, 500, 497, 496, 495, 494, + 540, 539, 538, 537, 536, 533, 532, 531, 530, 529, + 528, 527, 526, 525, 524, 521, 520, 519, 518, 437, + 515, 514, 513, 512, 511, 510, 509, 508, 507, 506, + 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, + 495, 492, 491, 488, 487, 486, 485, 484, 483, 482, + 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, + 471, 468, 467, 466, 465, 464, 463, 462, 461, 460, + 459, 458, 455, 454, 453, 452, 451, 450, 449, 448, + 447, 446, 445, 444, 443, 442, 441, 440, 439, 438, + 437, 436, 435, 434, 433, 432, 431, 430, 429, 428, - 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, - 483, 482, 481, 478, 477, 476, 475, 474, 473, 472, - 471, 470, 469, 468, 465, 464, 463, 462, 461, 460, - 459, 458, 457, 456, 455, 454, 453, 452, 451, 450, - 449, 448, 447, 446, 445, 444, 443, 442, 441, 440, - 439, 438, 437, 436, 435, 434, 433, 432, 431, 430, - 429, 428, 427, 426, 425, 424, 423, 422, 421, 257, - 420, 420, 250, 230, 230, 225, 222, 222, 406, 399, - 398, 397, 396, 388, 387, 386, 385, 379, 378, 377, - 376, 375, 374, 367, 366, 365, 364, 358, 352, 351, + 427, 426, 425, 424, 423, 422, 421, 420, 419, 418, + 417, 416, 415, 414, 413, 412, 411, 249, 410, 410, + 243, 227, 227, 222, 219, 219, 399, 392, 391, 390, + 389, 381, 380, 379, 378, 372, 371, 370, 369, 368, + 367, 360, 359, 358, 357, 351, 345, 344, 343, 342, + 341, 330, 329, 328, 327, 326, 325, 324, 323, 322, + 321, 320, 315, 314, 313, 312, 311, 310, 309, 308, + 304, 303, 302, 301, 300, 295, 294, 291, 290, 289, + 288, 287, 286, 283, 280, 277, 276, 275, 274, 273, + 272, 271, 270, 269, 268, 267, 266, 265, 262, 261, - 350, 349, 348, 337, 336, 335, 334, 333, 332, 331, - 330, 329, 328, 327, 323, 322, 321, 320, 319, 318, - 317, 316, 312, 311, 310, 309, 308, 303, 302, 299, - 298, 297, 296, 295, 294, 291, 288, 285, 284, 283, - 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, - 270, 269, 268, 267, 266, 265, 264, 261, 258, 257, - 98, 96, 256, 254, 92, 230, 224, 222, 218, 217, - 200, 183, 177, 146, 134, 133, 107, 106, 105, 104, - 98, 96, 95, 92, 90, 89, 1048, 5, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, + 260, 259, 258, 257, 256, 253, 250, 249, 95, 93, + 248, 246, 89, 227, 221, 219, 215, 214, 197, 180, + 174, 143, 131, 130, 104, 103, 102, 101, 95, 93, + 92, 89, 87, 86, 1037, 5, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048 + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037 } ; -static yyconst flex_int16_t yy_chk[1363] = +static yyconst flex_int16_t yy_chk[1311] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -946,147 +937,141 @@ static yyconst flex_int16_t yy_chk[1363] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 22, 7, 2, 4, 7, 2, 4, 17, 17, 4, 23, 28, 16, 24, 22, - 24, 189, 16, 25, 28, 23, 25, 29, 23, 189, + 24, 186, 16, 25, 28, 23, 25, 29, 23, 186, 24, 29, 25, 2, 3, 3, 3, 4, 38, 3, - 734, 29, 31, 3, 3, 3, 3, 58, 38, 58, + 717, 29, 31, 3, 3, 3, 3, 58, 38, 58, 3, 3, 3, 26, 3, 3, 31, 3, 3, 16, - 3, 3, 3, 26, 72, 3, 26, 30, 3, 3, - 3, 30, 3, 46, 3, 30, 34, 3, 36, 52, - 34, 30, 35, 35, 80, 72, 42, 46, 36, 42, - 34, 36, 42, 52, 35, 35, 70, 35, 39, 3, - 39, 70, 80, 3, 39, 39, 71, 40, 39, 39, - 40, 41, 47, 40, 246, 41, 40, 43, 41, 41, - 83, 71, 41, 47, 83, 41, 246, 47, 43, 44, + 3, 3, 46, 26, 182, 3, 26, 30, 3, 3, + 34, 30, 3, 36, 34, 30, 46, 3, 35, 35, + 182, 30, 42, 36, 34, 42, 36, 720, 42, 40, + 35, 35, 40, 35, 39, 40, 39, 47, 40, 71, + 39, 39, 41, 3, 39, 39, 41, 43, 47, 41, + 41, 72, 47, 41, 71, 44, 41, 49, 43, 44, + 43, 49, 41, 44, 43, 49, 44, 50, 50, 51, - 43, 41, 51, 44, 43, 49, 51, 44, 70, 49, - 44, 50, 50, 49, 53, 77, 51, 148, 53, 49, - 50, 55, 148, 56, 77, 55, 50, 56, 57, 55, - 56, 53, 77, 88, 55, 55, 88, 56, 57, 56, - 61, 57, 56, 61, 63, 74, 61, 74, 63, 67, - 67, 67, 63, 66, 66, 66, 66, 74, 63, 68, - 68, 68, 73, 78, 107, 109, 73, 78, 107, 109, - 185, 78, 68, 69, 69, 69, 132, 132, 69, 84, - 73, 78, 69, 69, 69, 69, 185, 100, 75, 69, - 69, 69, 100, 735, 69, 117, 69, 69, 117, 69, + 52, 49, 72, 51, 53, 70, 50, 144, 53, 79, + 70, 55, 50, 51, 52, 55, 56, 144, 57, 55, + 56, 53, 73, 56, 55, 55, 73, 79, 57, 722, + 56, 57, 56, 61, 63, 56, 61, 82, 63, 61, + 73, 82, 63, 66, 66, 66, 66, 70, 63, 67, + 67, 67, 68, 68, 68, 75, 78, 74, 85, 74, + 78, 85, 723, 77, 78, 68, 69, 69, 69, 74, + 75, 69, 77, 75, 78, 69, 69, 69, 69, 75, + 77, 104, 69, 69, 69, 104, 173, 69, 140, 69, + 69, 80, 69, 69, 140, 106, 173, 69, 81, 106, - 69, 69, 134, 75, 69, 134, 75, 69, 69, 69, - 79, 69, 75, 69, 79, 82, 69, 84, 79, 239, - 81, 208, 79, 82, 208, 136, 239, 84, 79, 100, - 84, 81, 81, 82, 136, 143, 82, 235, 69, 178, - 235, 143, 69, 81, 81, 178, 81, 85, 85, 85, - 85, 147, 176, 85, 86, 86, 86, 149, 736, 86, - 149, 147, 176, 86, 86, 86, 86, 188, 149, 155, - 86, 86, 86, 155, 188, 86, 188, 86, 86, 155, - 86, 86, 86, 87, 209, 86, 164, 87, 86, 86, - 86, 87, 86, 209, 86, 87, 177, 86, 164, 164, + 69, 69, 80, 80, 69, 114, 81, 97, 114, 69, + 129, 129, 97, 145, 80, 80, 81, 80, 145, 81, + 83, 83, 83, 83, 131, 133, 83, 131, 146, 174, + 296, 146, 198, 174, 133, 69, 84, 84, 84, 146, + 152, 84, 198, 174, 152, 84, 84, 84, 84, 97, + 152, 235, 84, 84, 84, 175, 161, 84, 235, 84, + 84, 175, 84, 84, 176, 176, 176, 84, 161, 161, + 84, 84, 296, 161, 84, 183, 183, 185, 191, 84, + 206, 191, 183, 199, 185, 205, 185, 199, 205, 206, + 191, 191, 204, 211, 204, 191, 220, 191, 215, 215, - 177, 87, 179, 179, 179, 186, 186, 201, 194, 202, - 177, 194, 186, 202, 214, 218, 218, 201, 233, 86, - 194, 194, 207, 86, 207, 194, 215, 194, 202, 215, - 223, 207, 232, 215, 214, 215, 219, 232, 234, 219, - 223, 233, 219, 227, 227, 227, 227, 228, 228, 228, - 229, 229, 229, 236, 237, 240, 241, 236, 242, 243, - 234, 244, 245, 229, 247, 244, 304, 245, 365, 365, - 253, 237, 318, 241, 232, 337, 243, 318, 340, 247, - 466, 382, 242, 337, 240, 248, 248, 248, 248, 253, - 371, 248, 371, 382, 393, 411, 340, 409, 409, 253, + 212, 204, 199, 212, 230, 84, 220, 212, 216, 212, + 231, 216, 224, 211, 216, 224, 225, 226, 224, 225, + 226, 229, 225, 226, 236, 232, 229, 230, 232, 233, + 226, 238, 231, 233, 237, 238, 310, 239, 240, 330, + 333, 310, 358, 358, 364, 375, 364, 330, 236, 239, + 386, 237, 406, 240, 402, 402, 386, 375, 333, 404, + 403, 407, 406, 229, 403, 408, 409, 404, 439, 456, + 489, 514, 533, 407, 563, 533, 514, 558, 565, 566, + 439, 409, 567, 489, 558, 566, 628, 639, 408, 686, + 699, 700, 686, 639, 567, 563, 724, 725, 628, 565, - 393, 410, 413, 411, 414, 410, 415, 416, 304, 417, - 418, 449, 413, 414, 419, 419, 498, 542, 415, 523, - 542, 572, 466, 449, 523, 418, 419, 567, 416, 498, - 574, 575, 417, 577, 567, 576, 639, 650, 710, 574, - 711, 576, 572, 650, 697, 577, 712, 697, 639, 737, - 739, 711, 575, 710, 740, 712, 741, 742, 745, 746, - 750, 754, 755, 756, 758, 759, 761, 764, 766, 767, - 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, - 778, 780, 781, 783, 784, 785, 786, 787, 788, 789, - 790, 791, 794, 795, 797, 798, 799, 800, 802, 803, + 700, 699, 727, 728, 729, 730, 733, 734, 738, 742, + 743, 456, 744, 745, 747, 748, 750, 753, 755, 756, + 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, + 767, 769, 770, 772, 773, 774, 775, 776, 777, 778, + 779, 780, 783, 784, 786, 787, 788, 789, 791, 792, + 793, 794, 795, 796, 797, 799, 800, 801, 804, 805, + 807, 808, 809, 810, 811, 812, 813, 814, 816, 817, + 818, 819, 821, 822, 823, 824, 825, 826, 827, 829, + 831, 832, 833, 834, 835, 838, 841, 844, 845, 846, + 847, 848, 851, 852, 854, 855, 856, 817, 858, 859, - 804, 805, 806, 807, 808, 810, 811, 812, 815, 816, - 818, 819, 820, 821, 822, 823, 824, 825, 827, 828, - 829, 830, 831, 833, 834, 835, 827, 836, 837, 838, - 839, 841, 843, 844, 845, 846, 847, 850, 853, 856, - 857, 858, 859, 862, 863, 865, 866, 867, 829, 869, - 870, 871, 872, 874, 875, 876, 877, 879, 880, 881, - 882, 883, 888, 889, 890, 891, 892, 893, 894, 896, - 899, 901, 902, 903, 904, 905, 909, 910, 911, 912, - 913, 914, 915, 917, 918, 924, 925, 926, 927, 928, - 930, 932, 933, 934, 936, 938, 940, 941, 942, 943, + 860, 861, 863, 864, 865, 866, 868, 869, 870, 871, + 872, 877, 878, 879, 880, 881, 882, 883, 885, 888, + 890, 891, 892, 893, 894, 898, 899, 900, 901, 902, + 903, 905, 906, 912, 913, 914, 915, 916, 918, 920, + 921, 922, 925, 927, 929, 930, 931, 932, 933, 934, + 935, 936, 937, 938, 939, 942, 943, 944, 945, 947, + 950, 952, 953, 954, 955, 960, 963, 965, 966, 967, + 968, 969, 970, 973, 974, 978, 980, 988, 989, 993, + 995, 1000, 1001, 1002, 1003, 1004, 1009, 1012, 1013, 1014, + 1015, 1016, 1017, 1018, 1019, 1022, 1023, 1024, 1027, 1028, - 944, 945, 946, 947, 948, 949, 950, 953, 954, 955, - 956, 958, 961, 963, 964, 965, 966, 971, 974, 976, - 977, 978, 979, 980, 981, 984, 985, 989, 991, 999, - 1000, 1004, 1006, 1011, 1012, 1013, 1014, 1015, 1020, 1023, - 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1033, 1034, 1035, - 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1049, 1049, 1049, - 1049, 1049, 1049, 1050, 1050, 1051, 1051, 732, 1051, 1051, - 1051, 1052, 1052, 1052, 1053, 1053, 1053, 1053, 1053, 1053, - 1054, 1054, 1054, 1054, 1055, 1055, 729, 1055, 1055, 1055, - 728, 727, 726, 725, 724, 722, 721, 720, 719, 718, + 1029, 1030, 1031, 1032, 1033, 1038, 1038, 1038, 1038, 1038, + 1038, 1039, 1039, 1040, 1040, 716, 1040, 1040, 1040, 1041, + 1041, 1041, 1042, 1042, 1042, 1042, 1042, 1042, 1043, 1043, + 1043, 1043, 1044, 1044, 715, 1044, 1044, 1044, 714, 713, + 712, 710, 709, 708, 707, 706, 705, 704, 703, 702, + 698, 697, 695, 694, 693, 692, 691, 690, 689, 688, + 685, 684, 683, 682, 681, 680, 679, 677, 675, 674, + 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, + 662, 661, 660, 659, 658, 657, 656, 654, 653, 652, + 651, 650, 649, 648, 647, 646, 645, 644, 643, 642, - 717, 716, 715, 714, 709, 708, 706, 705, 704, 703, - 702, 701, 700, 699, 696, 695, 694, 693, 692, 691, - 690, 688, 686, 685, 684, 683, 682, 681, 680, 679, - 678, 677, 676, 675, 673, 672, 671, 670, 669, 668, - 667, 665, 664, 663, 662, 661, 660, 659, 658, 657, - 656, 655, 654, 653, 652, 651, 649, 648, 647, 646, - 645, 644, 643, 642, 641, 638, 637, 636, 635, 634, - 633, 632, 631, 629, 628, 627, 626, 625, 623, 622, - 620, 619, 618, 615, 614, 613, 612, 611, 609, 608, - 607, 606, 605, 604, 603, 602, 601, 599, 598, 597, + 641, 640, 638, 637, 636, 635, 634, 633, 632, 631, + 630, 627, 626, 625, 624, 623, 622, 621, 620, 619, + 617, 616, 615, 614, 613, 611, 610, 608, 607, 606, + 603, 602, 601, 600, 599, 597, 596, 595, 594, 593, + 592, 591, 590, 589, 587, 586, 585, 584, 582, 581, + 579, 578, 577, 575, 574, 573, 572, 571, 569, 564, + 562, 559, 557, 556, 555, 553, 552, 551, 550, 549, + 548, 547, 546, 545, 544, 543, 542, 541, 540, 539, + 538, 537, 536, 534, 532, 531, 530, 529, 528, 526, + 525, 524, 522, 521, 520, 519, 518, 517, 516, 515, - 596, 594, 593, 591, 590, 589, 587, 586, 585, 584, - 583, 581, 579, 573, 571, 568, 566, 565, 564, 562, - 561, 560, 559, 558, 557, 556, 555, 554, 553, 552, - 551, 550, 549, 548, 547, 546, 545, 543, 541, 540, - 539, 538, 537, 535, 534, 533, 531, 530, 529, 528, - 527, 526, 525, 524, 521, 520, 519, 518, 516, 515, - 513, 512, 511, 510, 509, 508, 507, 506, 504, 503, - 502, 501, 500, 499, 497, 496, 495, 494, 493, 489, - 488, 487, 486, 485, 484, 483, 482, 481, 479, 478, - 477, 476, 475, 474, 473, 472, 471, 470, 469, 468, + 512, 511, 510, 509, 507, 506, 504, 503, 502, 501, + 500, 499, 498, 497, 495, 494, 493, 492, 491, 490, + 488, 487, 486, 485, 484, 480, 479, 478, 477, 476, + 475, 474, 473, 472, 471, 469, 468, 467, 466, 465, + 464, 463, 462, 461, 460, 459, 458, 455, 453, 452, + 451, 450, 449, 447, 446, 445, 444, 443, 442, 440, + 438, 436, 435, 434, 433, 431, 430, 429, 428, 426, + 425, 424, 423, 421, 419, 417, 416, 415, 413, 412, + 411, 405, 400, 399, 398, 397, 396, 395, 394, 393, + 391, 390, 389, 388, 387, 385, 384, 383, 382, 381, - 465, 463, 462, 461, 460, 459, 457, 456, 455, 454, - 453, 452, 450, 448, 446, 445, 444, 443, 441, 440, - 439, 438, 436, 435, 434, 433, 431, 429, 427, 426, - 425, 423, 422, 421, 412, 407, 406, 405, 404, 403, - 402, 401, 400, 398, 397, 396, 395, 394, 392, 391, - 390, 389, 388, 387, 386, 385, 384, 383, 381, 380, - 379, 378, 377, 376, 375, 374, 373, 372, 370, 369, - 368, 367, 366, 364, 363, 362, 361, 360, 359, 358, - 356, 355, 354, 353, 351, 350, 349, 348, 346, 345, - 344, 343, 342, 341, 339, 338, 336, 335, 334, 333, - - 332, 331, 330, 328, 327, 326, 325, 324, 323, 322, - 321, 320, 319, 317, 316, 315, 314, 313, 312, 311, - 310, 309, 307, 305, 303, 302, 301, 300, 299, 298, - 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, + 380, 379, 378, 377, 376, 374, 373, 372, 371, 370, + 369, 368, 367, 366, 365, 363, 362, 361, 360, 359, + 357, 356, 355, 354, 353, 352, 351, 349, 348, 347, + 346, 344, 343, 342, 341, 339, 338, 337, 336, 335, + 334, 332, 331, 329, 328, 327, 326, 325, 324, 323, + 321, 320, 319, 318, 317, 316, 315, 314, 313, 312, + 311, 309, 308, 307, 306, 305, 304, 303, 302, 301, + 299, 297, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, - 277, 276, 275, 274, 273, 272, 270, 269, 268, 267, - 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, - 256, 255, 251, 238, 230, 226, 221, 220, 217, 213, - 212, 211, 210, 206, 205, 204, 203, 200, 199, 198, - 197, 196, 195, 193, 192, 191, 190, 187, 184, 183, + 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, - 182, 181, 180, 175, 174, 173, 172, 171, 170, 169, - 168, 167, 166, 165, 163, 162, 161, 160, 159, 158, - 157, 156, 154, 153, 152, 151, 150, 146, 145, 142, - 141, 140, 139, 138, 137, 135, 133, 131, 130, 129, - 128, 127, 126, 125, 124, 123, 121, 120, 119, 118, - 116, 115, 114, 113, 112, 111, 110, 108, 106, 101, - 98, 96, 95, 94, 91, 76, 65, 62, 60, 59, - 54, 48, 45, 37, 33, 32, 21, 20, 19, 18, - 15, 14, 13, 11, 10, 9, 5, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, + 267, 266, 265, 264, 262, 261, 260, 259, 258, 257, + 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, + 244, 234, 227, 223, 218, 217, 214, 210, 209, 208, + 207, 203, 202, 201, 200, 197, 196, 195, 194, 193, + 192, 190, 189, 188, 187, 184, 181, 180, 179, 178, + 177, 172, 171, 170, 169, 168, 167, 166, 165, 164, + 163, 162, 160, 159, 158, 157, 156, 155, 154, 153, + 151, 150, 149, 148, 147, 143, 142, 139, 138, 137, + 136, 135, 134, 132, 130, 128, 127, 126, 125, 124, + 123, 122, 121, 120, 118, 117, 116, 115, 113, 112, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - 1048, 1048 + 111, 110, 109, 108, 107, 105, 103, 98, 95, 93, + 92, 91, 88, 76, 65, 62, 60, 59, 54, 48, + 45, 37, 33, 32, 21, 20, 19, 18, 15, 14, + 13, 11, 10, 9, 5, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, + + 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037 } ; static yy_state_type yy_last_accepting_state; @@ -1105,7 +1090,7 @@ int yy_flex_debug = 0; char *yytext; #line 1 "lev_comp.l" #line 2 "lev_comp.l" -/* NetHack 3.5 lev_comp.l $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 lev_comp.l $NHDT-Date: 1428240296 2015/04/05 13:24:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.13 $ */ /* NetHack 3.5 lev_comp.l $Date: 2009/05/06 10:54:31 $ $Revision: 1.9 $ */ /* SCCS Id: @(#)lev_lex.c 3.5 2002/03/27 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ @@ -1204,7 +1189,7 @@ FILE *orig_yyin = NULL; #define ST_RETF(y, x) do { savetoken(yytext); y; return x; } while (0); -#line 1207 "lex.yy.c" +#line 1193 "lex.yy.c" #define INITIAL 0 #define MAPC 1 @@ -1422,9 +1407,9 @@ YY_DECL } { -#line 104 "lev_comp.l" +#line 105 "lev_comp.l" -#line 1427 "lex.yy.c" +#line 1413 "lex.yy.c" while ( 1 ) /* loops until end-of-file is reached */ { @@ -1452,13 +1437,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1049 ) + if ( yy_current_state >= 1038 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 1288 ); + while ( yy_base[yy_current_state] != 1236 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1484,7 +1469,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 105 "lev_comp.l" +#line 106 "lev_comp.l" { savetoken(yytext); BEGIN(INITIAL); @@ -1498,7 +1483,7 @@ YY_RULE_SETUP case 2: /* rule 2 can match eol */ YY_RULE_SETUP -#line 114 "lev_comp.l" +#line 115 "lev_comp.l" { int len = yyleng; savetoken(yytext); @@ -1514,873 +1499,878 @@ YY_RULE_SETUP case 3: /* rule 3 can match eol */ YY_RULE_SETUP -#line 125 "lev_comp.l" +#line 126 "lev_comp.l" { savetoken(yytext); newline(); } YY_BREAK case 4: YY_RULE_SETUP -#line 126 "lev_comp.l" +#line 127 "lev_comp.l" ST_RET(MESSAGE_ID); YY_BREAK case 5: YY_RULE_SETUP -#line 127 "lev_comp.l" +#line 128 "lev_comp.l" ST_RET(NOMAP_ID); YY_BREAK case 6: YY_RULE_SETUP -#line 128 "lev_comp.l" +#line 129 "lev_comp.l" ST_RET(MAZE_ID); YY_BREAK case 7: YY_RULE_SETUP -#line 129 "lev_comp.l" +#line 130 "lev_comp.l" ST_RET(LEVEL_ID); YY_BREAK case 8: YY_RULE_SETUP -#line 130 "lev_comp.l" +#line 131 "lev_comp.l" ST_RET(LEV_INIT_ID); YY_BREAK case 9: YY_RULE_SETUP -#line 131 "lev_comp.l" +#line 132 "lev_comp.l" ST_RET(MAZE_GRID_ID); YY_BREAK case 10: YY_RULE_SETUP -#line 132 "lev_comp.l" +#line 133 "lev_comp.l" ST_RET(SOLID_FILL_ID); YY_BREAK case 11: YY_RULE_SETUP -#line 133 "lev_comp.l" +#line 134 "lev_comp.l" ST_RET(MINES_ID); YY_BREAK case 12: YY_RULE_SETUP -#line 134 "lev_comp.l" +#line 135 "lev_comp.l" ST_RET(ROGUELEV_ID); YY_BREAK case 13: YY_RULE_SETUP -#line 135 "lev_comp.l" +#line 136 "lev_comp.l" ST_RET(FLAGS_ID); YY_BREAK case 14: YY_RULE_SETUP -#line 136 "lev_comp.l" +#line 137 "lev_comp.l" ST_RET(GEOMETRY_ID); YY_BREAK case 15: /* rule 15 can match eol */ YY_RULE_SETUP -#line 137 "lev_comp.l" +#line 138 "lev_comp.l" { savetoken(yytext); BEGIN(MAPC); newline(); } YY_BREAK case 16: YY_RULE_SETUP -#line 138 "lev_comp.l" +#line 139 "lev_comp.l" ST_RET(object_ID); YY_BREAK case 17: YY_RULE_SETUP -#line 139 "lev_comp.l" +#line 140 "lev_comp.l" ST_RET(OBJECT_ID); YY_BREAK case 18: YY_RULE_SETUP -#line 140 "lev_comp.l" +#line 141 "lev_comp.l" ST_RET(COBJECT_ID); YY_BREAK case 19: YY_RULE_SETUP -#line 141 "lev_comp.l" +#line 142 "lev_comp.l" ST_RET(MONSTER_ID); YY_BREAK case 20: YY_RULE_SETUP -#line 142 "lev_comp.l" +#line 143 "lev_comp.l" ST_RET(monster_ID); YY_BREAK case 21: YY_RULE_SETUP -#line 143 "lev_comp.l" +#line 144 "lev_comp.l" ST_RET(TRAP_ID); YY_BREAK case 22: YY_RULE_SETUP -#line 144 "lev_comp.l" +#line 145 "lev_comp.l" ST_RET(DOOR_ID); YY_BREAK case 23: YY_RULE_SETUP -#line 145 "lev_comp.l" +#line 146 "lev_comp.l" ST_RET(ROOMDOOR_ID); YY_BREAK case 24: YY_RULE_SETUP -#line 146 "lev_comp.l" +#line 147 "lev_comp.l" ST_RET(DRAWBRIDGE_ID); YY_BREAK case 25: YY_RULE_SETUP -#line 147 "lev_comp.l" +#line 148 "lev_comp.l" ST_RET(MAZEWALK_ID); YY_BREAK case 26: YY_RULE_SETUP -#line 148 "lev_comp.l" +#line 149 "lev_comp.l" ST_RET(WALLIFY_ID); YY_BREAK case 27: YY_RULE_SETUP -#line 149 "lev_comp.l" +#line 150 "lev_comp.l" ST_RET(REGION_ID); YY_BREAK case 28: YY_RULE_SETUP -#line 150 "lev_comp.l" +#line 151 "lev_comp.l" ST_RET(ALTAR_ID); YY_BREAK case 29: YY_RULE_SETUP -#line 151 "lev_comp.l" +#line 152 "lev_comp.l" ST_RET(LADDER_ID); YY_BREAK case 30: YY_RULE_SETUP -#line 152 "lev_comp.l" +#line 153 "lev_comp.l" ST_RET(STAIR_ID); YY_BREAK case 31: YY_RULE_SETUP -#line 153 "lev_comp.l" +#line 154 "lev_comp.l" ST_RET(PORTAL_ID); YY_BREAK case 32: YY_RULE_SETUP -#line 154 "lev_comp.l" +#line 155 "lev_comp.l" ST_RET(TELEPRT_ID); YY_BREAK case 33: YY_RULE_SETUP -#line 155 "lev_comp.l" +#line 156 "lev_comp.l" ST_RET(BRANCH_ID); YY_BREAK case 34: YY_RULE_SETUP -#line 156 "lev_comp.l" +#line 157 "lev_comp.l" ST_RET(FOUNTAIN_ID); YY_BREAK case 35: YY_RULE_SETUP -#line 157 "lev_comp.l" +#line 158 "lev_comp.l" ST_RET(SINK_ID); YY_BREAK case 36: YY_RULE_SETUP -#line 158 "lev_comp.l" +#line 159 "lev_comp.l" ST_RET(POOL_ID); YY_BREAK case 37: YY_RULE_SETUP -#line 159 "lev_comp.l" +#line 160 "lev_comp.l" ST_RET(NON_DIGGABLE_ID); YY_BREAK case 38: YY_RULE_SETUP -#line 160 "lev_comp.l" +#line 161 "lev_comp.l" ST_RET(NON_PASSWALL_ID); YY_BREAK case 39: YY_RULE_SETUP -#line 161 "lev_comp.l" +#line 162 "lev_comp.l" ST_RET(IF_ID); YY_BREAK case 40: YY_RULE_SETUP -#line 162 "lev_comp.l" +#line 163 "lev_comp.l" ST_RET(ELSE_ID); YY_BREAK case 41: YY_RULE_SETUP -#line 163 "lev_comp.l" +#line 164 "lev_comp.l" ST_RET(EXIT_ID); YY_BREAK case 42: YY_RULE_SETUP -#line 164 "lev_comp.l" +#line 165 "lev_comp.l" ST_RET(ROOM_ID); YY_BREAK case 43: YY_RULE_SETUP -#line 165 "lev_comp.l" +#line 166 "lev_comp.l" ST_RET(SUBROOM_ID); YY_BREAK case 44: YY_RULE_SETUP -#line 166 "lev_comp.l" +#line 167 "lev_comp.l" ST_RET(RAND_CORRIDOR_ID); YY_BREAK case 45: YY_RULE_SETUP -#line 167 "lev_comp.l" +#line 168 "lev_comp.l" ST_RET(CORRIDOR_ID); YY_BREAK case 46: YY_RULE_SETUP -#line 168 "lev_comp.l" +#line 169 "lev_comp.l" ST_RET(TERRAIN_ID); YY_BREAK case 47: YY_RULE_SETUP -#line 169 "lev_comp.l" +#line 170 "lev_comp.l" ST_RET(terrain_ID); YY_BREAK case 48: YY_RULE_SETUP -#line 170 "lev_comp.l" +#line 171 "lev_comp.l" ST_RET(REPLACE_TERRAIN_ID); YY_BREAK case 49: YY_RULE_SETUP -#line 171 "lev_comp.l" +#line 172 "lev_comp.l" ST_RET(GOLD_ID); YY_BREAK case 50: YY_RULE_SETUP -#line 172 "lev_comp.l" +#line 173 "lev_comp.l" ST_RET(GRAVE_ID); YY_BREAK case 51: YY_RULE_SETUP -#line 173 "lev_comp.l" +#line 174 "lev_comp.l" ST_RET(ENGRAVING_ID); YY_BREAK case 52: YY_RULE_SETUP -#line 174 "lev_comp.l" +#line 175 "lev_comp.l" ST_RET(MINERALIZE_ID); YY_BREAK case 53: YY_RULE_SETUP -#line 175 "lev_comp.l" +#line 176 "lev_comp.l" ST_RET(NAME_ID); YY_BREAK case 54: YY_RULE_SETUP -#line 176 "lev_comp.l" +#line 177 "lev_comp.l" ST_RET(FOR_ID); YY_BREAK case 55: YY_RULE_SETUP -#line 177 "lev_comp.l" +#line 178 "lev_comp.l" ST_RET(TO_ID); YY_BREAK case 56: YY_RULE_SETUP -#line 178 "lev_comp.l" +#line 179 "lev_comp.l" ST_RET(LOOP_ID); YY_BREAK case 57: YY_RULE_SETUP -#line 179 "lev_comp.l" +#line 180 "lev_comp.l" ST_RET(SWITCH_ID); YY_BREAK case 58: YY_RULE_SETUP -#line 180 "lev_comp.l" +#line 181 "lev_comp.l" ST_RET(CASE_ID); YY_BREAK case 59: YY_RULE_SETUP -#line 181 "lev_comp.l" +#line 182 "lev_comp.l" ST_RET(BREAK_ID); YY_BREAK case 60: YY_RULE_SETUP -#line 182 "lev_comp.l" +#line 183 "lev_comp.l" ST_RET(DEFAULT_ID); YY_BREAK case 61: YY_RULE_SETUP -#line 183 "lev_comp.l" +#line 184 "lev_comp.l" ST_RET(FUNCTION_ID); YY_BREAK case 62: YY_RULE_SETUP -#line 184 "lev_comp.l" +#line 185 "lev_comp.l" ST_RET(SHUFFLE_ID); YY_BREAK case 63: YY_RULE_SETUP -#line 185 "lev_comp.l" +#line 186 "lev_comp.l" ST_RET(MONTYPE_ID); YY_BREAK case 64: YY_RULE_SETUP -#line 186 "lev_comp.l" +#line 187 "lev_comp.l" ST_RET(selection_ID); YY_BREAK case 65: YY_RULE_SETUP -#line 187 "lev_comp.l" +#line 188 "lev_comp.l" ST_RET(rect_ID); YY_BREAK case 66: YY_RULE_SETUP -#line 188 "lev_comp.l" +#line 189 "lev_comp.l" ST_RET(fillrect_ID); YY_BREAK case 67: YY_RULE_SETUP -#line 189 "lev_comp.l" +#line 190 "lev_comp.l" ST_RET(line_ID); YY_BREAK case 68: YY_RULE_SETUP -#line 190 "lev_comp.l" +#line 191 "lev_comp.l" ST_RET(randline_ID); YY_BREAK case 69: YY_RULE_SETUP -#line 191 "lev_comp.l" +#line 192 "lev_comp.l" ST_RET(grow_ID); YY_BREAK case 70: YY_RULE_SETUP -#line 192 "lev_comp.l" +#line 193 "lev_comp.l" ST_RET(flood_ID); YY_BREAK case 71: YY_RULE_SETUP -#line 193 "lev_comp.l" +#line 194 "lev_comp.l" ST_RET(rndcoord_ID); YY_BREAK case 72: YY_RULE_SETUP -#line 194 "lev_comp.l" +#line 195 "lev_comp.l" ST_RET(circle_ID); YY_BREAK case 73: YY_RULE_SETUP -#line 195 "lev_comp.l" +#line 196 "lev_comp.l" ST_RET(ellipse_ID); YY_BREAK case 74: YY_RULE_SETUP -#line 196 "lev_comp.l" +#line 197 "lev_comp.l" ST_RET(filter_ID); YY_BREAK case 75: YY_RULE_SETUP -#line 197 "lev_comp.l" +#line 198 "lev_comp.l" ST_RET(gradient_ID); YY_BREAK case 76: YY_RULE_SETUP -#line 198 "lev_comp.l" +#line 199 "lev_comp.l" ST_RET(complement_ID); YY_BREAK case 77: YY_RULE_SETUP -#line 199 "lev_comp.l" +#line 200 "lev_comp.l" { savetoken(yytext); yylval.i=SEL_GRADIENT_RADIAL; return GRADIENT_TYPE; } YY_BREAK case 78: YY_RULE_SETUP -#line 200 "lev_comp.l" +#line 201 "lev_comp.l" { savetoken(yytext); yylval.i=SEL_GRADIENT_SQUARE; return GRADIENT_TYPE; } YY_BREAK case 79: YY_RULE_SETUP -#line 201 "lev_comp.l" +#line 202 "lev_comp.l" { savetoken(yytext); yylval.i=DRY; return HUMIDITY_TYPE; } YY_BREAK case 80: YY_RULE_SETUP -#line 202 "lev_comp.l" +#line 203 "lev_comp.l" { savetoken(yytext); yylval.i=WET; return HUMIDITY_TYPE; } YY_BREAK case 81: YY_RULE_SETUP -#line 203 "lev_comp.l" +#line 204 "lev_comp.l" { savetoken(yytext); yylval.i=HOT; return HUMIDITY_TYPE; } YY_BREAK case 82: YY_RULE_SETUP -#line 204 "lev_comp.l" +#line 205 "lev_comp.l" { savetoken(yytext); yylval.i=SOLID; return HUMIDITY_TYPE; } YY_BREAK case 83: YY_RULE_SETUP -#line 205 "lev_comp.l" +#line 206 "lev_comp.l" { savetoken(yytext); yylval.i=ANY_LOC; return HUMIDITY_TYPE; } YY_BREAK case 84: YY_RULE_SETUP -#line 206 "lev_comp.l" +#line 207 "lev_comp.l" ST_RET(LEV); YY_BREAK case 85: YY_RULE_SETUP -#line 207 "lev_comp.l" +#line 208 "lev_comp.l" ST_RET(QUANTITY_ID); YY_BREAK case 86: YY_RULE_SETUP -#line 208 "lev_comp.l" +#line 209 "lev_comp.l" ST_RET(BURIED_ID); YY_BREAK case 87: YY_RULE_SETUP -#line 209 "lev_comp.l" +#line 210 "lev_comp.l" ST_RET(ERODED_ID); YY_BREAK case 88: YY_RULE_SETUP -#line 210 "lev_comp.l" +#line 211 "lev_comp.l" ST_RET(ERODEPROOF_ID); YY_BREAK case 89: YY_RULE_SETUP -#line 211 "lev_comp.l" +#line 212 "lev_comp.l" ST_RET(TRAPPED_ID); YY_BREAK case 90: YY_RULE_SETUP -#line 212 "lev_comp.l" +#line 213 "lev_comp.l" ST_RET(RECHARGED_ID); YY_BREAK case 91: YY_RULE_SETUP -#line 213 "lev_comp.l" +#line 214 "lev_comp.l" ST_RET(INVIS_ID); YY_BREAK case 92: YY_RULE_SETUP -#line 214 "lev_comp.l" +#line 215 "lev_comp.l" ST_RET(GREASED_ID); YY_BREAK case 93: YY_RULE_SETUP -#line 215 "lev_comp.l" +#line 216 "lev_comp.l" ST_RET(FEMALE_ID); YY_BREAK case 94: YY_RULE_SETUP -#line 216 "lev_comp.l" +#line 217 "lev_comp.l" ST_RET(CANCELLED_ID); YY_BREAK case 95: YY_RULE_SETUP -#line 217 "lev_comp.l" +#line 218 "lev_comp.l" ST_RET(REVIVED_ID); YY_BREAK case 96: YY_RULE_SETUP -#line 218 "lev_comp.l" +#line 219 "lev_comp.l" ST_RET(AVENGE_ID); YY_BREAK case 97: YY_RULE_SETUP -#line 219 "lev_comp.l" +#line 220 "lev_comp.l" ST_RET(FLEEING_ID); YY_BREAK case 98: YY_RULE_SETUP -#line 220 "lev_comp.l" +#line 221 "lev_comp.l" ST_RET(BLINDED_ID); YY_BREAK case 99: YY_RULE_SETUP -#line 221 "lev_comp.l" +#line 222 "lev_comp.l" ST_RET(PARALYZED_ID); YY_BREAK case 100: YY_RULE_SETUP -#line 222 "lev_comp.l" +#line 223 "lev_comp.l" ST_RET(STUNNED_ID); YY_BREAK case 101: YY_RULE_SETUP -#line 223 "lev_comp.l" +#line 224 "lev_comp.l" ST_RET(CONFUSED_ID); YY_BREAK case 102: YY_RULE_SETUP -#line 224 "lev_comp.l" +#line 225 "lev_comp.l" ST_RET(SEENTRAPS_ID); YY_BREAK case 103: YY_RULE_SETUP -#line 225 "lev_comp.l" +#line 226 "lev_comp.l" ST_RET(ALL_ID); YY_BREAK case 104: YY_RULE_SETUP -#line 226 "lev_comp.l" +#line 227 "lev_comp.l" ST_RETF((yylval.i=1), HORIZ_OR_VERT); YY_BREAK case 105: YY_RULE_SETUP -#line 227 "lev_comp.l" +#line 228 "lev_comp.l" { savetoken(yytext); yylval.i=2; return HORIZ_OR_VERT; } YY_BREAK case 106: YY_RULE_SETUP -#line 228 "lev_comp.l" +#line 229 "lev_comp.l" { savetoken(yytext); yylval.i=D_ISOPEN; return DOOR_STATE; } YY_BREAK case 107: YY_RULE_SETUP -#line 229 "lev_comp.l" +#line 230 "lev_comp.l" { savetoken(yytext); yylval.i=D_CLOSED; return DOOR_STATE; } YY_BREAK case 108: YY_RULE_SETUP -#line 230 "lev_comp.l" +#line 231 "lev_comp.l" { savetoken(yytext); yylval.i=D_LOCKED; return DOOR_STATE; } YY_BREAK case 109: YY_RULE_SETUP -#line 231 "lev_comp.l" +#line 232 "lev_comp.l" { savetoken(yytext); yylval.i=D_NODOOR; return DOOR_STATE; } YY_BREAK case 110: YY_RULE_SETUP -#line 232 "lev_comp.l" +#line 233 "lev_comp.l" { savetoken(yytext); yylval.i=D_BROKEN; return DOOR_STATE; } YY_BREAK case 111: YY_RULE_SETUP -#line 233 "lev_comp.l" +#line 234 "lev_comp.l" { savetoken(yytext); yylval.i=D_SECRET; return DOOR_STATE; } YY_BREAK case 112: YY_RULE_SETUP -#line 234 "lev_comp.l" +#line 235 "lev_comp.l" { savetoken(yytext); yylval.i=W_NORTH; return DIRECTION; } YY_BREAK case 113: YY_RULE_SETUP -#line 235 "lev_comp.l" +#line 236 "lev_comp.l" { savetoken(yytext); yylval.i=W_EAST; return DIRECTION; } YY_BREAK case 114: YY_RULE_SETUP -#line 236 "lev_comp.l" +#line 237 "lev_comp.l" { savetoken(yytext); yylval.i=W_SOUTH; return DIRECTION; } YY_BREAK case 115: YY_RULE_SETUP -#line 237 "lev_comp.l" +#line 238 "lev_comp.l" { savetoken(yytext); yylval.i=W_WEST; return DIRECTION; } YY_BREAK case 116: YY_RULE_SETUP -#line 238 "lev_comp.l" +#line 239 "lev_comp.l" { savetoken(yytext); yylval.i = -1; return RANDOM_TYPE; } YY_BREAK case 117: YY_RULE_SETUP -#line 239 "lev_comp.l" +#line 240 "lev_comp.l" { savetoken(yytext); yylval.i = -1; return RANDOM_TYPE_BRACKET; } YY_BREAK case 118: YY_RULE_SETUP -#line 240 "lev_comp.l" +#line 241 "lev_comp.l" { savetoken(yytext); yylval.i = -2; return NONE; } YY_BREAK case 119: YY_RULE_SETUP -#line 241 "lev_comp.l" +#line 242 "lev_comp.l" ST_RET(A_REGISTER); YY_BREAK case 120: YY_RULE_SETUP -#line 242 "lev_comp.l" +#line 243 "lev_comp.l" { savetoken(yytext); yylval.i=1; return LEFT_OR_RIGHT; } YY_BREAK case 121: YY_RULE_SETUP -#line 243 "lev_comp.l" +#line 244 "lev_comp.l" { savetoken(yytext); yylval.i=2; return LEFT_OR_RIGHT; } YY_BREAK case 122: YY_RULE_SETUP -#line 244 "lev_comp.l" +#line 245 "lev_comp.l" { savetoken(yytext); yylval.i=3; return CENTER; } YY_BREAK case 123: YY_RULE_SETUP -#line 245 "lev_comp.l" +#line 246 "lev_comp.l" { savetoken(yytext); yylval.i=4; return LEFT_OR_RIGHT; } YY_BREAK case 124: YY_RULE_SETUP -#line 246 "lev_comp.l" +#line 247 "lev_comp.l" { savetoken(yytext); yylval.i=5; return LEFT_OR_RIGHT; } YY_BREAK case 125: YY_RULE_SETUP -#line 247 "lev_comp.l" +#line 248 "lev_comp.l" { savetoken(yytext); yylval.i=1; return TOP_OR_BOT; } YY_BREAK case 126: YY_RULE_SETUP -#line 248 "lev_comp.l" +#line 249 "lev_comp.l" { savetoken(yytext); yylval.i=5; return TOP_OR_BOT; } YY_BREAK case 127: YY_RULE_SETUP -#line 249 "lev_comp.l" +#line 250 "lev_comp.l" { savetoken(yytext); yylval.i=1; return LIGHT_STATE; } YY_BREAK case 128: YY_RULE_SETUP -#line 250 "lev_comp.l" +#line 251 "lev_comp.l" { savetoken(yytext); yylval.i=0; return LIGHT_STATE; } YY_BREAK case 129: YY_RULE_SETUP -#line 251 "lev_comp.l" +#line 252 "lev_comp.l" { savetoken(yytext); yylval.i=1; return FILLING; } YY_BREAK case 130: YY_RULE_SETUP -#line 252 "lev_comp.l" +#line 253 "lev_comp.l" { savetoken(yytext); yylval.i=0; return FILLING; } YY_BREAK case 131: YY_RULE_SETUP -#line 253 "lev_comp.l" +#line 254 "lev_comp.l" { savetoken(yytext); yylval.i=0; return IRREGULAR; } YY_BREAK case 132: YY_RULE_SETUP -#line 254 "lev_comp.l" +#line 255 "lev_comp.l" { savetoken(yytext); yylval.i=1; return IRREGULAR; } YY_BREAK case 133: YY_RULE_SETUP -#line 255 "lev_comp.l" +#line 256 "lev_comp.l" { savetoken(yytext); yylval.i=1; return JOINED; } YY_BREAK case 134: YY_RULE_SETUP -#line 256 "lev_comp.l" +#line 257 "lev_comp.l" { savetoken(yytext); yylval.i=0; return JOINED; } YY_BREAK case 135: YY_RULE_SETUP -#line 257 "lev_comp.l" +#line 258 "lev_comp.l" { savetoken(yytext); yylval.i=1; return LIMITED; } YY_BREAK case 136: YY_RULE_SETUP -#line 258 "lev_comp.l" +#line 259 "lev_comp.l" { savetoken(yytext); yylval.i=0; return LIMITED; } YY_BREAK case 137: YY_RULE_SETUP -#line 259 "lev_comp.l" +#line 260 "lev_comp.l" { savetoken(yytext); yylval.i= AM_NONE; return ALIGNMENT; } YY_BREAK case 138: YY_RULE_SETUP -#line 260 "lev_comp.l" +#line 261 "lev_comp.l" { savetoken(yytext); yylval.i= AM_LAWFUL; return ALIGNMENT; } YY_BREAK case 139: YY_RULE_SETUP -#line 261 "lev_comp.l" +#line 262 "lev_comp.l" { savetoken(yytext); yylval.i= AM_NEUTRAL; return ALIGNMENT; } YY_BREAK case 140: YY_RULE_SETUP -#line 262 "lev_comp.l" +#line 263 "lev_comp.l" { savetoken(yytext); yylval.i= AM_CHAOTIC; return ALIGNMENT; } YY_BREAK case 141: YY_RULE_SETUP -#line 263 "lev_comp.l" +#line 264 "lev_comp.l" { savetoken(yytext); yylval.i= AM_SPLEV_CO; return ALIGNMENT; } YY_BREAK case 142: YY_RULE_SETUP -#line 264 "lev_comp.l" +#line 265 "lev_comp.l" { savetoken(yytext); yylval.i= AM_SPLEV_NONCO; return ALIGNMENT; } YY_BREAK case 143: YY_RULE_SETUP -#line 265 "lev_comp.l" +#line 266 "lev_comp.l" { savetoken(yytext); yylval.i=1; return MON_ATTITUDE; } YY_BREAK case 144: YY_RULE_SETUP -#line 266 "lev_comp.l" +#line 267 "lev_comp.l" { savetoken(yytext); yylval.i=0; return MON_ATTITUDE; } YY_BREAK case 145: YY_RULE_SETUP -#line 267 "lev_comp.l" +#line 268 "lev_comp.l" { savetoken(yytext); yylval.i=1; return MON_ALERTNESS; } YY_BREAK case 146: YY_RULE_SETUP -#line 268 "lev_comp.l" +#line 269 "lev_comp.l" { savetoken(yytext); yylval.i=0; return MON_ALERTNESS; } YY_BREAK case 147: YY_RULE_SETUP -#line 269 "lev_comp.l" +#line 270 "lev_comp.l" { savetoken(yytext); yylval.i= M_AP_FURNITURE; return MON_APPEARANCE; } YY_BREAK case 148: YY_RULE_SETUP -#line 270 "lev_comp.l" +#line 271 "lev_comp.l" { savetoken(yytext); yylval.i= M_AP_MONSTER; return MON_APPEARANCE; } YY_BREAK case 149: YY_RULE_SETUP -#line 271 "lev_comp.l" +#line 272 "lev_comp.l" { savetoken(yytext); yylval.i= M_AP_OBJECT; return MON_APPEARANCE; } YY_BREAK case 150: YY_RULE_SETUP -#line 272 "lev_comp.l" +#line 273 "lev_comp.l" { savetoken(yytext); yylval.i=2; return ALTAR_TYPE; } YY_BREAK case 151: YY_RULE_SETUP -#line 273 "lev_comp.l" +#line 274 "lev_comp.l" { savetoken(yytext); yylval.i=1; return ALTAR_TYPE; } YY_BREAK case 152: YY_RULE_SETUP -#line 274 "lev_comp.l" +#line 275 "lev_comp.l" { savetoken(yytext); yylval.i=0; return ALTAR_TYPE; } YY_BREAK case 153: YY_RULE_SETUP -#line 275 "lev_comp.l" +#line 276 "lev_comp.l" { savetoken(yytext); yylval.i=1; return UP_OR_DOWN; } YY_BREAK case 154: YY_RULE_SETUP -#line 276 "lev_comp.l" +#line 277 "lev_comp.l" { savetoken(yytext); yylval.i=0; return UP_OR_DOWN; } YY_BREAK case 155: YY_RULE_SETUP -#line 277 "lev_comp.l" +#line 278 "lev_comp.l" { savetoken(yytext); yylval.i=0; return BOOLEAN; } YY_BREAK case 156: YY_RULE_SETUP -#line 278 "lev_comp.l" +#line 279 "lev_comp.l" { savetoken(yytext); yylval.i=1; return BOOLEAN; } YY_BREAK case 157: YY_RULE_SETUP -#line 279 "lev_comp.l" +#line 280 "lev_comp.l" { savetoken(yytext); yylval.i=DUST; return ENGRAVING_TYPE; } YY_BREAK case 158: YY_RULE_SETUP -#line 280 "lev_comp.l" +#line 281 "lev_comp.l" { savetoken(yytext); yylval.i=ENGRAVE; return ENGRAVING_TYPE; } YY_BREAK case 159: YY_RULE_SETUP -#line 281 "lev_comp.l" +#line 282 "lev_comp.l" { savetoken(yytext); yylval.i=BURN; return ENGRAVING_TYPE; } YY_BREAK case 160: YY_RULE_SETUP -#line 282 "lev_comp.l" +#line 283 "lev_comp.l" { savetoken(yytext); yylval.i=MARK; return ENGRAVING_TYPE; } YY_BREAK case 161: YY_RULE_SETUP -#line 283 "lev_comp.l" +#line 284 "lev_comp.l" { savetoken(yytext); yylval.i=ENGR_BLOOD; return ENGRAVING_TYPE; } YY_BREAK case 162: YY_RULE_SETUP -#line 284 "lev_comp.l" +#line 285 "lev_comp.l" { savetoken(yytext); yylval.i=1; return CURSE_TYPE; } YY_BREAK case 163: YY_RULE_SETUP -#line 285 "lev_comp.l" +#line 286 "lev_comp.l" { savetoken(yytext); yylval.i=2; return CURSE_TYPE; } YY_BREAK case 164: YY_RULE_SETUP -#line 286 "lev_comp.l" +#line 287 "lev_comp.l" { savetoken(yytext); yylval.i=3; return CURSE_TYPE; } YY_BREAK case 165: YY_RULE_SETUP -#line 287 "lev_comp.l" +#line 288 "lev_comp.l" { savetoken(yytext); yylval.i=NOTELEPORT; return FLAG_TYPE; } YY_BREAK case 166: YY_RULE_SETUP -#line 288 "lev_comp.l" +#line 289 "lev_comp.l" { savetoken(yytext); yylval.i=HARDFLOOR; return FLAG_TYPE; } YY_BREAK case 167: YY_RULE_SETUP -#line 289 "lev_comp.l" +#line 290 "lev_comp.l" { savetoken(yytext); yylval.i=NOMMAP; return FLAG_TYPE; } YY_BREAK case 168: YY_RULE_SETUP -#line 290 "lev_comp.l" +#line 291 "lev_comp.l" { savetoken(yytext); yylval.i=ARBOREAL; return FLAG_TYPE; } /* KMH */ YY_BREAK case 169: YY_RULE_SETUP -#line 291 "lev_comp.l" +#line 292 "lev_comp.l" { savetoken(yytext); yylval.i=SHORTSIGHTED; return FLAG_TYPE; } YY_BREAK case 170: YY_RULE_SETUP -#line 292 "lev_comp.l" +#line 293 "lev_comp.l" { savetoken(yytext); yylval.i=MAZELEVEL; return FLAG_TYPE; } YY_BREAK case 171: YY_RULE_SETUP -#line 293 "lev_comp.l" +#line 294 "lev_comp.l" { savetoken(yytext); yylval.i=PREMAPPED; return FLAG_TYPE; } YY_BREAK case 172: YY_RULE_SETUP -#line 294 "lev_comp.l" +#line 295 "lev_comp.l" { savetoken(yytext); yylval.i=SHROUD; return FLAG_TYPE; } YY_BREAK case 173: YY_RULE_SETUP -#line 295 "lev_comp.l" +#line 296 "lev_comp.l" { savetoken(yytext); yylval.i=GRAVEYARD; return FLAG_TYPE; } YY_BREAK case 174: YY_RULE_SETUP -#line 296 "lev_comp.l" +#line 297 "lev_comp.l" { savetoken(yytext); yylval.i=ICEDPOOLS; return FLAG_TYPE; } YY_BREAK case 175: YY_RULE_SETUP -#line 297 "lev_comp.l" +#line 298 "lev_comp.l" { savetoken(yytext); yylval.i=SOLIDIFY; return FLAG_TYPE; } YY_BREAK case 176: YY_RULE_SETUP -#line 298 "lev_comp.l" +#line 299 "lev_comp.l" +{ savetoken(yytext); yylval.i=CORRMAZE; return FLAG_TYPE; } + YY_BREAK +case 177: +YY_RULE_SETUP +#line 300 "lev_comp.l" { char *p = strchr(yytext, 'd'); savetoken(yytext); if (p) { @@ -2392,124 +2382,124 @@ YY_RULE_SETUP return DICE; } YY_BREAK -case 177: +case 178: YY_RULE_SETUP -#line 308 "lev_comp.l" +#line 310 "lev_comp.l" { savetoken(yytext); yylval.i = atoi(yytext + 1); if (yylval.i < 0 || yylval.i > 100) lc_error("Unexpected percentile '%li%%'", yylval.i); return PERCENT; } YY_BREAK -case 178: -YY_RULE_SETUP -#line 312 "lev_comp.l" -{ savetoken(yytext); yylval.i=atoi(yytext); return MINUS_INTEGER; } - YY_BREAK case 179: YY_RULE_SETUP -#line 313 "lev_comp.l" -{ savetoken(yytext); yylval.i=atoi(yytext); return PLUS_INTEGER; } +#line 314 "lev_comp.l" +{ savetoken(yytext); yylval.i=atoi(yytext); return MINUS_INTEGER; } YY_BREAK case 180: YY_RULE_SETUP -#line 314 "lev_comp.l" +#line 315 "lev_comp.l" +{ savetoken(yytext); yylval.i=atoi(yytext); return PLUS_INTEGER; } + YY_BREAK +case 181: +YY_RULE_SETUP +#line 316 "lev_comp.l" { savetoken(yytext); yylval.i = atoi(yytext); if (yylval.i < 0 || yylval.i > 100) lc_error("Unexpected percentile '%li%%'", yylval.i); return SPERCENT; } YY_BREAK -case 181: +case 182: YY_RULE_SETUP -#line 318 "lev_comp.l" +#line 320 "lev_comp.l" { savetoken(yytext); yylval.i=atoi(yytext); return INTEGER; } YY_BREAK -case 182: -/* rule 182 can match eol */ +case 183: +/* rule 183 can match eol */ YY_RULE_SETUP -#line 319 "lev_comp.l" +#line 321 "lev_comp.l" { savetoken(yytext); yytext[yyleng-1] = 0; /* Discard the trailing \" */ yylval.map = (char *) alloc(strlen(yytext+1)+1); Strcpy(yylval.map, yytext+1); /* Discard the first \" */ return STRING; } YY_BREAK -case 183: -YY_RULE_SETUP -#line 324 "lev_comp.l" -{ savetoken(yytext); return handle_varstring_check(); } - YY_BREAK case 184: YY_RULE_SETUP -#line 325 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JE; return COMPARE_TYPE; } +#line 326 "lev_comp.l" +{ savetoken(yytext); return handle_varstring_check(); } YY_BREAK case 185: YY_RULE_SETUP -#line 326 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JNE; return COMPARE_TYPE; } +#line 327 "lev_comp.l" +{ savetoken(yytext); yylval.i = SPO_JE; return COMPARE_TYPE; } YY_BREAK case 186: YY_RULE_SETUP -#line 327 "lev_comp.l" +#line 328 "lev_comp.l" { savetoken(yytext); yylval.i = SPO_JNE; return COMPARE_TYPE; } YY_BREAK case 187: YY_RULE_SETUP -#line 328 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JLE; return COMPARE_TYPE; } +#line 329 "lev_comp.l" +{ savetoken(yytext); yylval.i = SPO_JNE; return COMPARE_TYPE; } YY_BREAK case 188: YY_RULE_SETUP -#line 329 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JGE; return COMPARE_TYPE; } +#line 330 "lev_comp.l" +{ savetoken(yytext); yylval.i = SPO_JLE; return COMPARE_TYPE; } YY_BREAK case 189: YY_RULE_SETUP -#line 330 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JL; return COMPARE_TYPE; } +#line 331 "lev_comp.l" +{ savetoken(yytext); yylval.i = SPO_JGE; return COMPARE_TYPE; } YY_BREAK case 190: YY_RULE_SETUP -#line 331 "lev_comp.l" -{ savetoken(yytext); yylval.i = SPO_JG; return COMPARE_TYPE; } +#line 332 "lev_comp.l" +{ savetoken(yytext); yylval.i = SPO_JL; return COMPARE_TYPE; } YY_BREAK case 191: -/* rule 191 can match eol */ -YY_RULE_SETUP -#line 332 "lev_comp.l" -{ newline(); } - YY_BREAK -case 192: YY_RULE_SETUP #line 333 "lev_comp.l" -{ advancepos(yytext); } +{ savetoken(yytext); yylval.i = SPO_JG; return COMPARE_TYPE; } + YY_BREAK +case 192: +/* rule 192 can match eol */ +YY_RULE_SETUP +#line 334 "lev_comp.l" +{ newline(); } YY_BREAK case 193: YY_RULE_SETUP -#line 334 "lev_comp.l" -{ savetoken(yytext); yylval.i = yytext[2]; return CHAR; } +#line 335 "lev_comp.l" +{ advancepos(yytext); } YY_BREAK case 194: YY_RULE_SETUP -#line 335 "lev_comp.l" -{ savetoken(yytext); yylval.i = yytext[1]; return CHAR; } +#line 336 "lev_comp.l" +{ savetoken(yytext); yylval.i = yytext[2]; return CHAR; } YY_BREAK case 195: YY_RULE_SETUP -#line 336 "lev_comp.l" -ST_RET(UNKNOWN_TYPE); +#line 337 "lev_comp.l" +{ savetoken(yytext); yylval.i = yytext[1]; return CHAR; } YY_BREAK case 196: YY_RULE_SETUP -#line 337 "lev_comp.l" -{ savetoken(yytext); return yytext[0]; } +#line 338 "lev_comp.l" +ST_RET(UNKNOWN_TYPE); YY_BREAK case 197: YY_RULE_SETUP -#line 338 "lev_comp.l" +#line 339 "lev_comp.l" +{ savetoken(yytext); return yytext[0]; } + YY_BREAK +case 198: +YY_RULE_SETUP +#line 340 "lev_comp.l" ECHO; YY_BREAK -#line 2512 "lex.yy.c" +#line 2503 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(MAPC): yyterminate(); @@ -2804,7 +2794,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1049 ) + if ( yy_current_state >= 1038 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -2832,11 +2822,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 1049 ) + if ( yy_current_state >= 1038 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 1048); + yy_is_jam = (yy_current_state == 1037); return yy_is_jam ? 0 : yy_current_state; } @@ -3508,7 +3498,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 337 "lev_comp.l" +#line 339 "lev_comp.l" #ifdef AMIGA diff --git a/sys/share/lev_yacc.c b/sys/share/lev_yacc.c index 376c48759..d2280994c 100644 --- a/sys/share/lev_yacc.c +++ b/sys/share/lev_yacc.c @@ -64,7 +64,7 @@ /* Copy the first part of user declarations. */ #line 1 "lev_comp.y" /* yacc.c:339 */ -/* NetHack 3.5 lev_comp.y $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */ +/* NetHack 3.5 lev_comp.y $NHDT-Date: 1428655167 2015/04/10 08:39:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */ /* NetHack 3.5 lev_comp.y $Date: 2009/05/06 10:54:31 $ $Revision: 1.8 $ */ /* SCCS Id: @(#)lev_yacc.c 3.5 2007/08/01 */ /* Copyright (c) 1989 by Jean-Christophe Collet */ @@ -88,6 +88,7 @@ #pragma alloca /* keep leading space! */ #endif +#define SPEC_LEV /* for USE_OLDARGS (sp_lev.h) */ #include "hack.h" #include "sp_lev.h" @@ -208,7 +209,7 @@ extern const char *fname; extern char curr_token[512]; -#line 212 "y.tab.c" /* yacc.c:339 */ +#line 213 "y.tab.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -600,7 +601,7 @@ extern int yydebug; typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 148 "lev_comp.y" /* yacc.c:355 */ +#line 149 "lev_comp.y" /* yacc.c:355 */ long i; char* map; @@ -637,7 +638,7 @@ union YYSTYPE char *varstr; } meth; -#line 641 "y.tab.c" /* yacc.c:355 */ +#line 642 "y.tab.c" /* yacc.c:355 */ }; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -652,7 +653,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 656 "y.tab.c" /* yacc.c:358 */ +#line 657 "y.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -967,47 +968,47 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 275, 275, 276, 279, 280, 283, 305, 310, 326, - 330, 336, 345, 354, 358, 384, 387, 394, 398, 405, - 408, 415, 416, 420, 423, 429, 433, 440, 443, 449, - 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, - 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, - 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, - 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, - 495, 496, 497, 498, 501, 502, 503, 504, 505, 506, - 507, 508, 509, 512, 513, 514, 515, 516, 517, 518, - 519, 520, 523, 524, 525, 528, 529, 532, 544, 550, - 556, 562, 568, 574, 580, 586, 592, 599, 606, 613, - 620, 627, 634, 643, 648, 655, 660, 667, 672, 679, - 683, 689, 694, 701, 705, 711, 715, 722, 744, 721, - 758, 803, 810, 813, 819, 825, 829, 838, 842, 837, - 899, 900, 904, 903, 916, 915, 930, 940, 941, 944, - 977, 976, 1002, 1001, 1031, 1030, 1061, 1060, 1086, 1095, - 1094, 1121, 1127, 1131, 1135, 1141, 1148, 1157, 1165, 1176, - 1175, 1191, 1190, 1207, 1210, 1216, 1226, 1232, 1241, 1247, - 1252, 1258, 1263, 1269, 1278, 1284, 1285, 1288, 1289, 1292, - 1296, 1302, 1303, 1306, 1312, 1318, 1326, 1327, 1330, 1331, - 1334, 1339, 1338, 1352, 1359, 1365, 1373, 1378, 1383, 1388, - 1393, 1398, 1403, 1408, 1413, 1418, 1423, 1428, 1433, 1438, - 1443, 1448, 1455, 1462, 1466, 1479, 1486, 1485, 1501, 1509, - 1515, 1523, 1528, 1533, 1538, 1543, 1548, 1553, 1558, 1563, - 1568, 1579, 1584, 1589, 1594, 1599, 1606, 1612, 1639, 1644, - 1651, 1655, 1661, 1667, 1673, 1683, 1693, 1708, 1718, 1721, - 1727, 1733, 1739, 1745, 1750, 1757, 1763, 1769, 1775, 1782, - 1781, 1805, 1808, 1814, 1820, 1824, 1829, 1836, 1842, 1849, - 1853, 1859, 1867, 1870, 1880, 1884, 1887, 1893, 1897, 1904, - 1908, 1912, 1918, 1919, 1922, 1923, 1926, 1927, 1928, 1934, - 1935, 1936, 1942, 1943, 1946, 1955, 1960, 1967, 1977, 1983, - 1987, 1991, 1998, 2007, 2013, 2017, 2023, 2027, 2035, 2039, - 2046, 2055, 2066, 2070, 2077, 2086, 2095, 2106, 2110, 2117, - 2126, 2135, 2144, 2153, 2159, 2163, 2170, 2179, 2189, 2198, - 2207, 2214, 2215, 2221, 2222, 2223, 2224, 2232, 2240, 2241, - 2242, 2243, 2244, 2245, 2248, 2254, 2262, 2291, 2292, 2295, - 2296, 2299, 2303, 2310, 2317, 2328, 2331, 2339, 2343, 2347, - 2351, 2355, 2360, 2364, 2368, 2372, 2376, 2380, 2384, 2388, - 2392, 2396, 2400, 2404, 2408, 2415, 2421, 2425, 2431, 2437, - 2438, 2439, 2442, 2446, 2450, 2454, 2460, 2461, 2464, 2465, - 2468, 2469, 2472, 2473, 2476, 2480, 2498 + 0, 276, 276, 277, 280, 281, 284, 306, 311, 332, + 336, 342, 352, 363, 369, 398, 401, 408, 412, 419, + 422, 429, 430, 434, 437, 443, 447, 454, 457, 463, + 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, + 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, + 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, + 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, + 509, 510, 511, 512, 515, 516, 517, 518, 519, 520, + 521, 522, 523, 526, 527, 528, 529, 530, 531, 532, + 533, 534, 537, 538, 539, 542, 543, 546, 558, 564, + 570, 576, 582, 588, 594, 600, 606, 614, 622, 630, + 638, 646, 654, 664, 669, 676, 681, 688, 693, 700, + 704, 710, 715, 722, 726, 732, 736, 743, 765, 742, + 779, 827, 834, 837, 843, 850, 854, 863, 867, 862, + 929, 930, 934, 933, 946, 945, 960, 970, 971, 974, + 1013, 1012, 1046, 1045, 1075, 1074, 1105, 1104, 1130, 1139, + 1138, 1165, 1171, 1176, 1181, 1188, 1195, 1204, 1212, 1224, + 1223, 1242, 1241, 1260, 1263, 1269, 1279, 1285, 1294, 1300, + 1305, 1311, 1316, 1322, 1333, 1339, 1340, 1343, 1344, 1347, + 1351, 1357, 1358, 1361, 1368, 1376, 1384, 1385, 1388, 1389, + 1392, 1397, 1396, 1410, 1417, 1423, 1431, 1436, 1442, 1448, + 1454, 1460, 1465, 1470, 1475, 1480, 1485, 1490, 1495, 1500, + 1505, 1510, 1518, 1525, 1529, 1542, 1549, 1548, 1564, 1572, + 1578, 1586, 1592, 1597, 1602, 1607, 1612, 1617, 1622, 1627, + 1632, 1643, 1648, 1653, 1658, 1663, 1670, 1676, 1705, 1710, + 1718, 1724, 1730, 1737, 1744, 1754, 1764, 1779, 1790, 1793, + 1799, 1805, 1811, 1817, 1822, 1829, 1836, 1842, 1848, 1855, + 1854, 1879, 1882, 1888, 1895, 1899, 1904, 1911, 1917, 1924, + 1928, 1935, 1943, 1946, 1956, 1960, 1963, 1969, 1973, 1980, + 1984, 1988, 1994, 1995, 1998, 1999, 2002, 2003, 2004, 2010, + 2011, 2012, 2018, 2019, 2022, 2031, 2036, 2043, 2053, 2059, + 2063, 2067, 2074, 2083, 2089, 2093, 2099, 2103, 2111, 2115, + 2122, 2131, 2142, 2146, 2153, 2162, 2171, 2182, 2186, 2193, + 2202, 2211, 2220, 2229, 2235, 2239, 2246, 2255, 2265, 2274, + 2283, 2290, 2291, 2297, 2301, 2305, 2309, 2317, 2326, 2330, + 2334, 2338, 2342, 2346, 2349, 2356, 2365, 2393, 2394, 2397, + 2398, 2401, 2405, 2412, 2419, 2430, 2433, 2441, 2445, 2449, + 2453, 2457, 2462, 2466, 2470, 2475, 2480, 2485, 2489, 2494, + 2499, 2503, 2507, 2512, 2516, 2523, 2529, 2533, 2539, 2546, + 2547, 2548, 2551, 2555, 2559, 2563, 2569, 2570, 2573, 2574, + 2577, 2578, 2581, 2582, 2585, 2589, 2607 }; #endif @@ -2442,7 +2443,7 @@ yyreduce: switch (yyn) { case 6: -#line 284 "lev_comp.y" /* yacc.c:1646 */ +#line 285 "lev_comp.y" /* yacc.c:1646 */ { if (fatal_error > 0) { (void) fprintf(stderr, @@ -2462,88 +2463,98 @@ yyreduce: vardef_free_all(variable_definitions); variable_definitions = NULL; } -#line 2466 "y.tab.c" /* yacc.c:1646 */ +#line 2467 "y.tab.c" /* yacc.c:1646 */ break; case 7: -#line 306 "lev_comp.y" /* yacc.c:1646 */ +#line 307 "lev_comp.y" /* yacc.c:1646 */ { start_level_def(&splev, (yyvsp[0].map)); (yyval.map) = (yyvsp[0].map); } -#line 2475 "y.tab.c" /* yacc.c:1646 */ +#line 2476 "y.tab.c" /* yacc.c:1646 */ break; case 8: -#line 311 "lev_comp.y" /* yacc.c:1646 */ +#line 312 "lev_comp.y" /* yacc.c:1646 */ { start_level_def(&splev, (yyvsp[-2].map)); if ((yyvsp[0].i) == -1) { - add_opvars(splev, "iiiiiiiio", LVLINIT_MAZEGRID,HWALL,0,0, 0,0,0,0, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + VA_PASS9(LVLINIT_MAZEGRID,HWALL,0,0, + 0,0,0,0, SPO_INITLEVEL)); } else { long bg = what_map_char((char) (yyvsp[0].i)); - add_opvars(splev, "iiiiiiiio", LVLINIT_SOLIDFILL, bg, 0,0, 0,0,0,0, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + VA_PASS9(LVLINIT_SOLIDFILL, bg, 0,0, + 0,0,0,0, SPO_INITLEVEL)); } - add_opvars(splev, "io", MAZELEVEL, SPO_LEVEL_FLAGS); + add_opvars(splev, "io", + VA_PASS2(MAZELEVEL, SPO_LEVEL_FLAGS)); max_x_map = COLNO-1; max_y_map = ROWNO; (yyval.map) = (yyvsp[-2].map); } -#line 2493 "y.tab.c" /* yacc.c:1646 */ +#line 2499 "y.tab.c" /* yacc.c:1646 */ break; case 9: -#line 327 "lev_comp.y" /* yacc.c:1646 */ +#line 333 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = -1; } -#line 2501 "y.tab.c" /* yacc.c:1646 */ +#line 2507 "y.tab.c" /* yacc.c:1646 */ break; case 10: -#line 331 "lev_comp.y" /* yacc.c:1646 */ +#line 337 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = what_map_char((char) (yyvsp[0].i)); } -#line 2509 "y.tab.c" /* yacc.c:1646 */ +#line 2515 "y.tab.c" /* yacc.c:1646 */ break; case 11: -#line 337 "lev_comp.y" /* yacc.c:1646 */ +#line 343 "lev_comp.y" /* yacc.c:1646 */ { long filling = (yyvsp[0].terr).ter; if (filling == INVALID_TYPE || filling >= MAX_TYPE) lc_error("INIT_MAP: Invalid fill char type."); - add_opvars(splev, "iiiiiiiio", LVLINIT_SOLIDFILL,filling,0,(long)(yyvsp[0].terr).lit, 0,0,0,0, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + LVLINIT_SOLIDFILL,filling,0,(long)(yyvsp[0].terr).lit, 0,0,0,0, SPO_INITLEVEL); max_x_map = COLNO-1; max_y_map = ROWNO; } -#line 2522 "y.tab.c" /* yacc.c:1646 */ +#line 2529 "y.tab.c" /* yacc.c:1646 */ break; case 12: -#line 346 "lev_comp.y" /* yacc.c:1646 */ +#line 353 "lev_comp.y" /* yacc.c:1646 */ { long filling = what_map_char((char) (yyvsp[0].i)); if (filling == INVALID_TYPE || filling >= MAX_TYPE) lc_error("INIT_MAP: Invalid fill char type."); - add_opvars(splev, "iiiiiiiio", LVLINIT_MAZEGRID,filling,0,0, 0,0,0,0, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + VA_PASS9(LVLINIT_MAZEGRID,filling,0,0, + 0,0,0,0, SPO_INITLEVEL)); max_x_map = COLNO-1; max_y_map = ROWNO; } -#line 2535 "y.tab.c" /* yacc.c:1646 */ +#line 2544 "y.tab.c" /* yacc.c:1646 */ break; case 13: -#line 355 "lev_comp.y" /* yacc.c:1646 */ +#line 364 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iiiiiiiio", LVLINIT_ROGUE,0,0,0,0,0,0,0, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + VA_PASS9(LVLINIT_ROGUE,0,0,0, + 0,0,0,0, SPO_INITLEVEL)); } -#line 2543 "y.tab.c" /* yacc.c:1646 */ +#line 2554 "y.tab.c" /* yacc.c:1646 */ break; case 14: -#line 359 "lev_comp.y" /* yacc.c:1646 */ +#line 370 "lev_comp.y" /* yacc.c:1646 */ { long fg = what_map_char((char) (yyvsp[-11].i)); long bg = what_map_char((char) (yyvsp[-9].i)); @@ -2562,411 +2573,421 @@ yyreduce: if (filling == INVALID_TYPE) lc_error("INIT_MAP: Invalid fill char type."); - add_opvars(splev, "iiiiiiiio", LVLINIT_MINES,filling,walled,lit, joined,smoothed,bg,fg, SPO_INITLEVEL); + add_opvars(splev, "iiiiiiiio", + VA_PASS9(LVLINIT_MINES,filling,walled,lit, + joined,smoothed,bg,fg, + SPO_INITLEVEL)); max_x_map = COLNO-1; max_y_map = ROWNO; } -#line 2570 "y.tab.c" /* yacc.c:1646 */ +#line 2584 "y.tab.c" /* yacc.c:1646 */ break; case 15: -#line 384 "lev_comp.y" /* yacc.c:1646 */ +#line 398 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 0; } -#line 2578 "y.tab.c" /* yacc.c:1646 */ +#line 2592 "y.tab.c" /* yacc.c:1646 */ break; case 16: -#line 388 "lev_comp.y" /* yacc.c:1646 */ +#line 402 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 2586 "y.tab.c" /* yacc.c:1646 */ +#line 2600 "y.tab.c" /* yacc.c:1646 */ break; case 17: -#line 394 "lev_comp.y" /* yacc.c:1646 */ +#line 408 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_COPY); + add_opvars(splev, "o", VA_PASS1(SPO_COPY)); (yyval.i) = 0; } -#line 2595 "y.tab.c" /* yacc.c:1646 */ +#line 2609 "y.tab.c" /* yacc.c:1646 */ break; case 18: -#line 399 "lev_comp.y" /* yacc.c:1646 */ +#line 413 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1; } -#line 2603 "y.tab.c" /* yacc.c:1646 */ +#line 2617 "y.tab.c" /* yacc.c:1646 */ break; case 19: -#line 405 "lev_comp.y" /* yacc.c:1646 */ +#line 419 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = -1; } -#line 2611 "y.tab.c" /* yacc.c:1646 */ +#line 2625 "y.tab.c" /* yacc.c:1646 */ break; case 20: -#line 409 "lev_comp.y" /* yacc.c:1646 */ +#line 423 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = what_map_char((char) (yyvsp[0].i)); } -#line 2619 "y.tab.c" /* yacc.c:1646 */ +#line 2633 "y.tab.c" /* yacc.c:1646 */ break; case 23: -#line 420 "lev_comp.y" /* yacc.c:1646 */ +#line 434 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", 0, SPO_LEVEL_FLAGS); + add_opvars(splev, "io", VA_PASS2(0, SPO_LEVEL_FLAGS)); } -#line 2627 "y.tab.c" /* yacc.c:1646 */ +#line 2641 "y.tab.c" /* yacc.c:1646 */ break; case 24: -#line 424 "lev_comp.y" /* yacc.c:1646 */ +#line 438 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (yyvsp[0].i), SPO_LEVEL_FLAGS); + add_opvars(splev, "io", VA_PASS2((yyvsp[0].i), SPO_LEVEL_FLAGS)); } -#line 2635 "y.tab.c" /* yacc.c:1646 */ +#line 2649 "y.tab.c" /* yacc.c:1646 */ break; case 25: -#line 430 "lev_comp.y" /* yacc.c:1646 */ +#line 444 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = ((yyvsp[-2].i) | (yyvsp[0].i)); } -#line 2643 "y.tab.c" /* yacc.c:1646 */ +#line 2657 "y.tab.c" /* yacc.c:1646 */ break; case 26: -#line 434 "lev_comp.y" /* yacc.c:1646 */ +#line 448 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 2651 "y.tab.c" /* yacc.c:1646 */ +#line 2665 "y.tab.c" /* yacc.c:1646 */ break; case 27: -#line 440 "lev_comp.y" /* yacc.c:1646 */ +#line 454 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 0; } -#line 2659 "y.tab.c" /* yacc.c:1646 */ +#line 2673 "y.tab.c" /* yacc.c:1646 */ break; case 28: -#line 444 "lev_comp.y" /* yacc.c:1646 */ +#line 458 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1 + (yyvsp[0].i); } -#line 2667 "y.tab.c" /* yacc.c:1646 */ +#line 2681 "y.tab.c" /* yacc.c:1646 */ break; case 29: -#line 450 "lev_comp.y" /* yacc.c:1646 */ +#line 464 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[-1].i); } -#line 2675 "y.tab.c" /* yacc.c:1646 */ +#line 2689 "y.tab.c" /* yacc.c:1646 */ break; case 97: -#line 533 "lev_comp.y" /* yacc.c:1646 */ +#line 547 "lev_comp.y" /* yacc.c:1646 */ { struct lc_vardefs *vd; if ((vd = vardef_defined(variable_definitions, (yyvsp[0].map), 1))) { if (!(vd->var_type & SPOVAR_ARRAY)) lc_error("Trying to shuffle non-array variable '%s'", (yyvsp[0].map)); } else lc_error("Trying to shuffle undefined variable '%s'", (yyvsp[0].map)); - add_opvars(splev, "so", (yyvsp[0].map), SPO_SHUFFLE_ARRAY); + add_opvars(splev, "so", VA_PASS2((yyvsp[0].map), SPO_SHUFFLE_ARRAY)); Free((yyvsp[0].map)); } -#line 2689 "y.tab.c" /* yacc.c:1646 */ +#line 2703 "y.tab.c" /* yacc.c:1646 */ break; case 98: -#line 545 "lev_comp.y" /* yacc.c:1646 */ +#line 559 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-2].map), SPOVAR_INT); - add_opvars(splev, "iso", 0, (yyvsp[-2].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-2].map), SPO_VAR_INIT)); Free((yyvsp[-2].map)); } -#line 2699 "y.tab.c" /* yacc.c:1646 */ +#line 2713 "y.tab.c" /* yacc.c:1646 */ break; case 99: -#line 551 "lev_comp.y" /* yacc.c:1646 */ +#line 565 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_SEL); - add_opvars(splev, "iso", 0, (yyvsp[-4].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-4].map), SPO_VAR_INIT)); Free((yyvsp[-4].map)); } -#line 2709 "y.tab.c" /* yacc.c:1646 */ +#line 2723 "y.tab.c" /* yacc.c:1646 */ break; case 100: -#line 557 "lev_comp.y" /* yacc.c:1646 */ +#line 571 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-2].map), SPOVAR_STRING); - add_opvars(splev, "iso", 0, (yyvsp[-2].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-2].map), SPO_VAR_INIT)); Free((yyvsp[-2].map)); } -#line 2719 "y.tab.c" /* yacc.c:1646 */ +#line 2733 "y.tab.c" /* yacc.c:1646 */ break; case 101: -#line 563 "lev_comp.y" /* yacc.c:1646 */ +#line 577 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_MAPCHAR); - add_opvars(splev, "iso", 0, (yyvsp[-4].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-4].map), SPO_VAR_INIT)); Free((yyvsp[-4].map)); } -#line 2729 "y.tab.c" /* yacc.c:1646 */ +#line 2743 "y.tab.c" /* yacc.c:1646 */ break; case 102: -#line 569 "lev_comp.y" /* yacc.c:1646 */ +#line 583 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_MONST); - add_opvars(splev, "iso", 0, (yyvsp[-4].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-4].map), SPO_VAR_INIT)); Free((yyvsp[-4].map)); } -#line 2739 "y.tab.c" /* yacc.c:1646 */ +#line 2753 "y.tab.c" /* yacc.c:1646 */ break; case 103: -#line 575 "lev_comp.y" /* yacc.c:1646 */ +#line 589 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_OBJ); - add_opvars(splev, "iso", 0, (yyvsp[-4].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-4].map), SPO_VAR_INIT)); Free((yyvsp[-4].map)); } -#line 2749 "y.tab.c" /* yacc.c:1646 */ +#line 2763 "y.tab.c" /* yacc.c:1646 */ break; case 104: -#line 581 "lev_comp.y" /* yacc.c:1646 */ +#line 595 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-2].map), SPOVAR_COORD); - add_opvars(splev, "iso", 0, (yyvsp[-2].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-2].map), SPO_VAR_INIT)); Free((yyvsp[-2].map)); } -#line 2759 "y.tab.c" /* yacc.c:1646 */ +#line 2773 "y.tab.c" /* yacc.c:1646 */ break; case 105: -#line 587 "lev_comp.y" /* yacc.c:1646 */ +#line 601 "lev_comp.y" /* yacc.c:1646 */ { variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-2].map), SPOVAR_REGION); - add_opvars(splev, "iso", 0, (yyvsp[-2].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-2].map), SPO_VAR_INIT)); Free((yyvsp[-2].map)); } -#line 2769 "y.tab.c" /* yacc.c:1646 */ +#line 2783 "y.tab.c" /* yacc.c:1646 */ break; case 106: -#line 593 "lev_comp.y" /* yacc.c:1646 */ - { - long n_items = (yyvsp[-1].i); - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_INT|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-4].map), SPO_VAR_INIT); - Free((yyvsp[-4].map)); - } -#line 2780 "y.tab.c" /* yacc.c:1646 */ - break; - - case 107: -#line 600 "lev_comp.y" /* yacc.c:1646 */ - { - long n_items = (yyvsp[-1].i); - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_COORD|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-4].map), SPO_VAR_INIT); - Free((yyvsp[-4].map)); - } -#line 2791 "y.tab.c" /* yacc.c:1646 */ - break; - - case 108: #line 607 "lev_comp.y" /* yacc.c:1646 */ { long n_items = (yyvsp[-1].i); - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_REGION|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-4].map), SPO_VAR_INIT); + variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_INT|SPOVAR_ARRAY); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-4].map), SPO_VAR_INIT)); Free((yyvsp[-4].map)); } -#line 2802 "y.tab.c" /* yacc.c:1646 */ +#line 2795 "y.tab.c" /* yacc.c:1646 */ + break; + + case 107: +#line 615 "lev_comp.y" /* yacc.c:1646 */ + { + long n_items = (yyvsp[-1].i); + variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_COORD|SPOVAR_ARRAY); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-4].map), SPO_VAR_INIT)); + Free((yyvsp[-4].map)); + } +#line 2807 "y.tab.c" /* yacc.c:1646 */ + break; + + case 108: +#line 623 "lev_comp.y" /* yacc.c:1646 */ + { + long n_items = (yyvsp[-1].i); + variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_REGION|SPOVAR_ARRAY); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-4].map), SPO_VAR_INIT)); + Free((yyvsp[-4].map)); + } +#line 2819 "y.tab.c" /* yacc.c:1646 */ break; case 109: -#line 614 "lev_comp.y" /* yacc.c:1646 */ +#line 631 "lev_comp.y" /* yacc.c:1646 */ { long n_items = (yyvsp[-1].i); variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-6].map), SPOVAR_MAPCHAR|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-6].map), SPO_VAR_INIT); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-6].map), SPO_VAR_INIT)); Free((yyvsp[-6].map)); } -#line 2813 "y.tab.c" /* yacc.c:1646 */ +#line 2831 "y.tab.c" /* yacc.c:1646 */ break; case 110: -#line 621 "lev_comp.y" /* yacc.c:1646 */ +#line 639 "lev_comp.y" /* yacc.c:1646 */ { long n_items = (yyvsp[-1].i); variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-6].map), SPOVAR_MONST|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-6].map), SPO_VAR_INIT); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-6].map), SPO_VAR_INIT)); Free((yyvsp[-6].map)); } -#line 2824 "y.tab.c" /* yacc.c:1646 */ +#line 2843 "y.tab.c" /* yacc.c:1646 */ break; case 111: -#line 628 "lev_comp.y" /* yacc.c:1646 */ +#line 647 "lev_comp.y" /* yacc.c:1646 */ { long n_items = (yyvsp[-1].i); variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-6].map), SPOVAR_OBJ|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-6].map), SPO_VAR_INIT); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-6].map), SPO_VAR_INIT)); Free((yyvsp[-6].map)); } -#line 2835 "y.tab.c" /* yacc.c:1646 */ - break; - - case 112: -#line 635 "lev_comp.y" /* yacc.c:1646 */ - { - long n_items = (yyvsp[-1].i); - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_STRING|SPOVAR_ARRAY); - add_opvars(splev, "iso", n_items, (yyvsp[-4].map), SPO_VAR_INIT); - Free((yyvsp[-4].map)); - } -#line 2846 "y.tab.c" /* yacc.c:1646 */ - break; - - case 113: -#line 644 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "O", (yyvsp[0].i)); - (yyval.i) = 1; - } #line 2855 "y.tab.c" /* yacc.c:1646 */ break; - case 114: -#line 649 "lev_comp.y" /* yacc.c:1646 */ + case 112: +#line 655 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "O", (yyvsp[0].i)); + long n_items = (yyvsp[-1].i); + variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_STRING|SPOVAR_ARRAY); + add_opvars(splev, "iso", + VA_PASS3(n_items, (yyvsp[-4].map), SPO_VAR_INIT)); + Free((yyvsp[-4].map)); + } +#line 2867 "y.tab.c" /* yacc.c:1646 */ + break; + + case 113: +#line 665 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "O", VA_PASS1((yyvsp[0].i))); + (yyval.i) = 1; + } +#line 2876 "y.tab.c" /* yacc.c:1646 */ + break; + + case 114: +#line 670 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "O", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2864 "y.tab.c" /* yacc.c:1646 */ +#line 2885 "y.tab.c" /* yacc.c:1646 */ break; case 115: -#line 656 "lev_comp.y" /* yacc.c:1646 */ +#line 677 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "M", (yyvsp[0].i)); + add_opvars(splev, "M", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1; } -#line 2873 "y.tab.c" /* yacc.c:1646 */ +#line 2894 "y.tab.c" /* yacc.c:1646 */ break; case 116: -#line 661 "lev_comp.y" /* yacc.c:1646 */ +#line 682 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "M", (yyvsp[0].i)); + add_opvars(splev, "M", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2882 "y.tab.c" /* yacc.c:1646 */ +#line 2903 "y.tab.c" /* yacc.c:1646 */ break; case 117: -#line 668 "lev_comp.y" /* yacc.c:1646 */ +#line 689 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "m", (yyvsp[0].i)); + add_opvars(splev, "m", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1; } -#line 2891 "y.tab.c" /* yacc.c:1646 */ +#line 2912 "y.tab.c" /* yacc.c:1646 */ break; case 118: -#line 673 "lev_comp.y" /* yacc.c:1646 */ +#line 694 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "m", (yyvsp[0].i)); + add_opvars(splev, "m", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2900 "y.tab.c" /* yacc.c:1646 */ +#line 2921 "y.tab.c" /* yacc.c:1646 */ break; case 119: -#line 680 "lev_comp.y" /* yacc.c:1646 */ +#line 701 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1; } -#line 2908 "y.tab.c" /* yacc.c:1646 */ +#line 2929 "y.tab.c" /* yacc.c:1646 */ break; case 120: -#line 684 "lev_comp.y" /* yacc.c:1646 */ +#line 705 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2916 "y.tab.c" /* yacc.c:1646 */ +#line 2937 "y.tab.c" /* yacc.c:1646 */ break; case 121: -#line 690 "lev_comp.y" /* yacc.c:1646 */ +#line 711 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "c", (yyvsp[0].i)); + add_opvars(splev, "c", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1; } -#line 2925 "y.tab.c" /* yacc.c:1646 */ +#line 2946 "y.tab.c" /* yacc.c:1646 */ break; case 122: -#line 695 "lev_comp.y" /* yacc.c:1646 */ +#line 716 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "c", (yyvsp[0].i)); + add_opvars(splev, "c", VA_PASS1((yyvsp[0].i))); (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2934 "y.tab.c" /* yacc.c:1646 */ +#line 2955 "y.tab.c" /* yacc.c:1646 */ break; case 123: -#line 702 "lev_comp.y" /* yacc.c:1646 */ +#line 723 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1; } -#line 2942 "y.tab.c" /* yacc.c:1646 */ +#line 2963 "y.tab.c" /* yacc.c:1646 */ break; case 124: -#line 706 "lev_comp.y" /* yacc.c:1646 */ +#line 727 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2950 "y.tab.c" /* yacc.c:1646 */ +#line 2971 "y.tab.c" /* yacc.c:1646 */ break; case 125: -#line 712 "lev_comp.y" /* yacc.c:1646 */ +#line 733 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1; } -#line 2958 "y.tab.c" /* yacc.c:1646 */ +#line 2979 "y.tab.c" /* yacc.c:1646 */ break; case 126: -#line 716 "lev_comp.y" /* yacc.c:1646 */ +#line 737 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1 + (yyvsp[-2].i); } -#line 2966 "y.tab.c" /* yacc.c:1646 */ +#line 2987 "y.tab.c" /* yacc.c:1646 */ break; case 127: -#line 722 "lev_comp.y" /* yacc.c:1646 */ +#line 743 "lev_comp.y" /* yacc.c:1646 */ { struct lc_funcdefs *funcdef; @@ -2988,32 +3009,32 @@ yyreduce: function_tmp_var_defs = variable_definitions; variable_definitions = NULL; } -#line 2992 "y.tab.c" /* yacc.c:1646 */ +#line 3013 "y.tab.c" /* yacc.c:1646 */ break; case 128: -#line 744 "lev_comp.y" /* yacc.c:1646 */ +#line 765 "lev_comp.y" /* yacc.c:1646 */ { /* nothing */ } -#line 3000 "y.tab.c" /* yacc.c:1646 */ +#line 3021 "y.tab.c" /* yacc.c:1646 */ break; case 129: -#line 748 "lev_comp.y" /* yacc.c:1646 */ +#line 769 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", 0, SPO_RETURN); + add_opvars(splev, "io", VA_PASS2(0, SPO_RETURN)); splev = function_splev_backup; in_function_definition--; curr_function = NULL; vardef_free_all(variable_definitions); variable_definitions = function_tmp_var_defs; } -#line 3013 "y.tab.c" /* yacc.c:1646 */ +#line 3034 "y.tab.c" /* yacc.c:1646 */ break; case 130: -#line 759 "lev_comp.y" /* yacc.c:1646 */ +#line 780 "lev_comp.y" /* yacc.c:1646 */ { struct lc_funcdefs *tmpfunc; tmpfunc = funcdef_defined(function_definitions, (yyvsp[-3].map), 1); @@ -3040,7 +3061,9 @@ yyreduce: { /* init function parameter variables */ struct lc_funcdefs_parm *tfp = tmpfunc->params; while (tfp) { - add_opvars(splev, "iso", 0, tfp->name, SPO_VAR_INIT); + add_opvars(splev, "iso", + VA_PASS3(0, tfp->name, + SPO_VAR_INIT)); tfp = tfp->next; } } @@ -3049,78 +3072,80 @@ yyreduce: set_opvar_int(jmp, splev->n_opcodes - jmp->vardata.l); } l = tmpfunc->addr - splev->n_opcodes - 2; - add_opvars(splev, "iio", nparams, l, SPO_CALL); + add_opvars(splev, "iio", + VA_PASS3(nparams, l, SPO_CALL)); tmpfunc->n_called++; } else { lc_error("Function '%s' not defined.", (yyvsp[-3].map)); } Free((yyvsp[-3].map)); } -#line 3060 "y.tab.c" /* yacc.c:1646 */ - break; - - case 131: -#line 804 "lev_comp.y" /* yacc.c:1646 */ - { - add_opcode(splev, SPO_EXIT, NULL); - } -#line 3068 "y.tab.c" /* yacc.c:1646 */ - break; - - case 132: -#line 810 "lev_comp.y" /* yacc.c:1646 */ - { - (yyval.i) = 100; - } -#line 3076 "y.tab.c" /* yacc.c:1646 */ - break; - - case 133: -#line 814 "lev_comp.y" /* yacc.c:1646 */ - { - (yyval.i) = (yyvsp[0].i); - } #line 3084 "y.tab.c" /* yacc.c:1646 */ break; + case 131: +#line 828 "lev_comp.y" /* yacc.c:1646 */ + { + add_opcode(splev, SPO_EXIT, NULL); + } +#line 3092 "y.tab.c" /* yacc.c:1646 */ + break; + + case 132: +#line 834 "lev_comp.y" /* yacc.c:1646 */ + { + (yyval.i) = 100; + } +#line 3100 "y.tab.c" /* yacc.c:1646 */ + break; + + case 133: +#line 838 "lev_comp.y" /* yacc.c:1646 */ + { + (yyval.i) = (yyvsp[0].i); + } +#line 3108 "y.tab.c" /* yacc.c:1646 */ + break; + case 134: -#line 820 "lev_comp.y" /* yacc.c:1646 */ +#line 844 "lev_comp.y" /* yacc.c:1646 */ { /* val > rn2(100) */ - add_opvars(splev, "iio", (long)(yyvsp[0].i), 100, SPO_RN2); + add_opvars(splev, "iio", + VA_PASS3((long)(yyvsp[0].i), 100, SPO_RN2)); (yyval.i) = SPO_JG; } -#line 3094 "y.tab.c" /* yacc.c:1646 */ +#line 3119 "y.tab.c" /* yacc.c:1646 */ break; case 135: -#line 826 "lev_comp.y" /* yacc.c:1646 */ +#line 851 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[-2].i); } -#line 3102 "y.tab.c" /* yacc.c:1646 */ +#line 3127 "y.tab.c" /* yacc.c:1646 */ break; case 136: -#line 830 "lev_comp.y" /* yacc.c:1646 */ +#line 855 "lev_comp.y" /* yacc.c:1646 */ { /* boolean, explicit foo != 0 */ - add_opvars(splev, "i", 0); + add_opvars(splev, "i", VA_PASS1(0)); (yyval.i) = SPO_JNE; } -#line 3112 "y.tab.c" /* yacc.c:1646 */ +#line 3137 "y.tab.c" /* yacc.c:1646 */ break; case 137: -#line 838 "lev_comp.y" /* yacc.c:1646 */ +#line 863 "lev_comp.y" /* yacc.c:1646 */ { is_inconstant_number = 0; } -#line 3120 "y.tab.c" /* yacc.c:1646 */ +#line 3145 "y.tab.c" /* yacc.c:1646 */ break; case 138: -#line 842 "lev_comp.y" /* yacc.c:1646 */ +#line 867 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *chkjmp; if (in_switch_statement > 0) @@ -3132,7 +3157,7 @@ yyreduce: switch_default_case = NULL; if (!is_inconstant_number) - add_opvars(splev, "o", SPO_RN2); + add_opvars(splev, "o", VA_PASS1(SPO_RN2)); is_inconstant_number = 0; chkjmp = New(struct opvar); @@ -3142,11 +3167,11 @@ yyreduce: add_opcode(splev, SPO_JMP, NULL); break_stmt_start(); } -#line 3146 "y.tab.c" /* yacc.c:1646 */ +#line 3171 "y.tab.c" /* yacc.c:1646 */ break; case 139: -#line 864 "lev_comp.y" /* yacc.c:1646 */ +#line 889 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *endjump = New(struct opvar); int i; @@ -3156,17 +3181,22 @@ yyreduce: add_opcode(splev, SPO_PUSH, endjump); add_opcode(splev, SPO_JMP, NULL); - set_opvar_int(switch_check_jump, splev->n_opcodes - switch_check_jump->vardata.l); + set_opvar_int(switch_check_jump, + splev->n_opcodes - switch_check_jump->vardata.l); for (i = 0; i < n_switch_case_list; i++) { - add_opvars(splev, "oio", SPO_COPY, switch_case_value[i], SPO_CMP); - set_opvar_int(switch_case_list[i], switch_case_list[i]->vardata.l - splev->n_opcodes-1); + add_opvars(splev, "oio", + VA_PASS3(SPO_COPY, + switch_case_value[i], SPO_CMP)); + set_opvar_int(switch_case_list[i], + switch_case_list[i]->vardata.l - splev->n_opcodes-1); add_opcode(splev, SPO_PUSH, switch_case_list[i]); add_opcode(splev, SPO_JE, NULL); } if (switch_default_case) { - set_opvar_int(switch_default_case, switch_default_case->vardata.l - splev->n_opcodes-1); + set_opvar_int(switch_default_case, + switch_default_case->vardata.l - splev->n_opcodes-1); add_opcode(splev, SPO_PUSH, switch_default_case); add_opcode(splev, SPO_JMP, NULL); } @@ -3180,11 +3210,11 @@ yyreduce: } -#line 3184 "y.tab.c" /* yacc.c:1646 */ +#line 3214 "y.tab.c" /* yacc.c:1646 */ break; case 142: -#line 904 "lev_comp.y" /* yacc.c:1646 */ +#line 934 "lev_comp.y" /* yacc.c:1646 */ { if (n_switch_case_list < MAX_SWITCH_CASES) { struct opvar *tmppush = New(struct opvar); @@ -3193,18 +3223,18 @@ yyreduce: switch_case_list[n_switch_case_list++] = tmppush; } else lc_error("Too many cases in a switch."); } -#line 3197 "y.tab.c" /* yacc.c:1646 */ +#line 3227 "y.tab.c" /* yacc.c:1646 */ break; case 143: -#line 913 "lev_comp.y" /* yacc.c:1646 */ +#line 943 "lev_comp.y" /* yacc.c:1646 */ { } -#line 3204 "y.tab.c" /* yacc.c:1646 */ +#line 3234 "y.tab.c" /* yacc.c:1646 */ break; case 144: -#line 916 "lev_comp.y" /* yacc.c:1646 */ +#line 946 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *tmppush = New(struct opvar); @@ -3214,18 +3244,18 @@ yyreduce: set_opvar_int(tmppush, splev->n_opcodes); switch_default_case = tmppush; } -#line 3218 "y.tab.c" /* yacc.c:1646 */ +#line 3248 "y.tab.c" /* yacc.c:1646 */ break; case 145: -#line 926 "lev_comp.y" /* yacc.c:1646 */ +#line 956 "lev_comp.y" /* yacc.c:1646 */ { } -#line 3225 "y.tab.c" /* yacc.c:1646 */ +#line 3255 "y.tab.c" /* yacc.c:1646 */ break; case 146: -#line 931 "lev_comp.y" /* yacc.c:1646 */ +#line 961 "lev_comp.y" /* yacc.c:1646 */ { if (!allow_break_statements) lc_error("Cannot use BREAK outside a statement block."); @@ -3233,11 +3263,11 @@ yyreduce: break_stmt_new(splev, splev->n_opcodes); } } -#line 3237 "y.tab.c" /* yacc.c:1646 */ +#line 3267 "y.tab.c" /* yacc.c:1646 */ break; case 149: -#line 945 "lev_comp.y" /* yacc.c:1646 */ +#line 975 "lev_comp.y" /* yacc.c:1646 */ { char buf[256], buf2[256]; @@ -3249,17 +3279,23 @@ yyreduce: /* first, define a variable for the for-loop end value */ snprintf(buf, 255, "%s end", (yyvsp[-4].map)); /* the value of which is already in stack (the 2nd math_expr) */ - add_opvars(splev, "iso", 0, buf, SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, buf, SPO_VAR_INIT)); - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-4].map), SPOVAR_INT); + variable_definitions = add_vardef_type(variable_definitions, + (yyvsp[-4].map), SPOVAR_INT); /* define the for-loop variable. value is in stack (1st math_expr) */ - add_opvars(splev, "iso", 0, (yyvsp[-4].map), SPO_VAR_INIT); + add_opvars(splev, "iso", VA_PASS3(0, (yyvsp[-4].map), SPO_VAR_INIT)); /* calculate value for the loop "step" variable */ snprintf(buf2, 255, "%s step", (yyvsp[-4].map)); - add_opvars(splev, "vvo", buf, (yyvsp[-4].map), SPO_MATH_SUB); /* end - start */ - add_opvars(splev, "o", SPO_MATH_SIGN); /* sign of that */ - add_opvars(splev, "iso", 0, buf2, SPO_VAR_INIT); /* save the sign into the step var */ + /* end - start */ + add_opvars(splev, "vvo", + VA_PASS3(buf, (yyvsp[-4].map), SPO_MATH_SUB)); + /* sign of that */ + add_opvars(splev, "o", VA_PASS1(SPO_MATH_SIGN)); + /* save the sign into the step var */ + add_opvars(splev, "iso", + VA_PASS3(0, buf2, SPO_VAR_INIT)); forloop_list[n_forloops].varname = strdup((yyvsp[-4].map)); forloop_list[n_forloops].jmp_point = splev->n_opcodes; @@ -3267,42 +3303,50 @@ yyreduce: n_forloops++; Free((yyvsp[-4].map)); } -#line 3271 "y.tab.c" /* yacc.c:1646 */ +#line 3307 "y.tab.c" /* yacc.c:1646 */ break; case 150: -#line 977 "lev_comp.y" /* yacc.c:1646 */ +#line 1013 "lev_comp.y" /* yacc.c:1646 */ { /* nothing */ break_stmt_start(); } -#line 3280 "y.tab.c" /* yacc.c:1646 */ +#line 3316 "y.tab.c" /* yacc.c:1646 */ break; case 151: -#line 982 "lev_comp.y" /* yacc.c:1646 */ +#line 1018 "lev_comp.y" /* yacc.c:1646 */ { char buf[256], buf2[256]; n_forloops--; snprintf(buf, 255, "%s step", forloop_list[n_forloops].varname); snprintf(buf2, 255, "%s end", forloop_list[n_forloops].varname); /* compare for-loop var to end value */ - add_opvars(splev, "vvo", forloop_list[n_forloops].varname, buf2, SPO_CMP); + add_opvars(splev, "vvo", + VA_PASS3(forloop_list[n_forloops].varname, + buf2, SPO_CMP)); /* var + step */ - add_opvars(splev, "vvo", buf, - forloop_list[n_forloops].varname, SPO_MATH_ADD); + add_opvars(splev, "vvo", + VA_PASS3(buf, forloop_list[n_forloops].varname, + SPO_MATH_ADD)); /* for-loop var = (for-loop var + step) */ - add_opvars(splev, "iso", 0, forloop_list[n_forloops].varname, SPO_VAR_INIT); + add_opvars(splev, "iso", + VA_PASS3(0, forloop_list[n_forloops].varname, + SPO_VAR_INIT)); /* jump back if compared values were not equal */ - add_opvars(splev, "io", forloop_list[n_forloops].jmp_point - splev->n_opcodes - 1, SPO_JNE); + add_opvars(splev, "io", + VA_PASS2( + forloop_list[n_forloops].jmp_point - splev->n_opcodes - 1, + SPO_JNE)); Free(forloop_list[n_forloops].varname); break_stmt_end(splev); } -#line 3302 "y.tab.c" /* yacc.c:1646 */ +#line 3346 "y.tab.c" /* yacc.c:1646 */ break; case 152: -#line 1002 "lev_comp.y" /* yacc.c:1646 */ +#line 1046 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *tmppush = New(struct opvar); @@ -3313,18 +3357,18 @@ yyreduce: set_opvar_int(tmppush, splev->n_opcodes); if_list[n_if_list++] = tmppush; - add_opvars(splev, "o", SPO_DEC); + add_opvars(splev, "o", VA_PASS1(SPO_DEC)); break_stmt_start(); } -#line 3320 "y.tab.c" /* yacc.c:1646 */ +#line 3364 "y.tab.c" /* yacc.c:1646 */ break; case 153: -#line 1016 "lev_comp.y" /* yacc.c:1646 */ +#line 1060 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *tmppush; - add_opvars(splev, "oio", SPO_COPY, 0, SPO_CMP); + add_opvars(splev, "oio", VA_PASS3(SPO_COPY, 0, SPO_CMP)); tmppush = (struct opvar *) if_list[--n_if_list]; set_opvar_int(tmppush, tmppush->vardata.l - splev->n_opcodes-1); @@ -3333,11 +3377,11 @@ yyreduce: add_opcode(splev, SPO_POP, NULL); /* get rid of the count value in stack */ break_stmt_end(splev); } -#line 3337 "y.tab.c" /* yacc.c:1646 */ +#line 3381 "y.tab.c" /* yacc.c:1646 */ break; case 154: -#line 1031 "lev_comp.y" /* yacc.c:1646 */ +#line 1075 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *tmppush2 = New(struct opvar); @@ -3357,11 +3401,11 @@ yyreduce: add_opcode(splev, reverse_jmp_opcode( (yyvsp[-1].i) ), NULL); } -#line 3361 "y.tab.c" /* yacc.c:1646 */ +#line 3405 "y.tab.c" /* yacc.c:1646 */ break; case 155: -#line 1051 "lev_comp.y" /* yacc.c:1646 */ +#line 1095 "lev_comp.y" /* yacc.c:1646 */ { if (n_if_list > 0) { struct opvar *tmppush; @@ -3369,11 +3413,11 @@ yyreduce: set_opvar_int(tmppush, splev->n_opcodes - tmppush->vardata.l); } else lc_error("IF: Huh?! No start address?"); } -#line 3373 "y.tab.c" /* yacc.c:1646 */ +#line 3417 "y.tab.c" /* yacc.c:1646 */ break; case 156: -#line 1061 "lev_comp.y" /* yacc.c:1646 */ +#line 1105 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *tmppush2 = New(struct opvar); @@ -3393,19 +3437,19 @@ yyreduce: add_opcode(splev, reverse_jmp_opcode( (yyvsp[0].i) ), NULL); } -#line 3397 "y.tab.c" /* yacc.c:1646 */ +#line 3441 "y.tab.c" /* yacc.c:1646 */ break; case 157: -#line 1081 "lev_comp.y" /* yacc.c:1646 */ +#line 1125 "lev_comp.y" /* yacc.c:1646 */ { /* do nothing */ } -#line 3405 "y.tab.c" /* yacc.c:1646 */ +#line 3449 "y.tab.c" /* yacc.c:1646 */ break; case 158: -#line 1087 "lev_comp.y" /* yacc.c:1646 */ +#line 1131 "lev_comp.y" /* yacc.c:1646 */ { if (n_if_list > 0) { struct opvar *tmppush; @@ -3413,11 +3457,11 @@ yyreduce: set_opvar_int(tmppush, splev->n_opcodes - tmppush->vardata.l); } else lc_error("IF: Huh?! No start address?"); } -#line 3417 "y.tab.c" /* yacc.c:1646 */ +#line 3461 "y.tab.c" /* yacc.c:1646 */ break; case 159: -#line 1095 "lev_comp.y" /* yacc.c:1646 */ +#line 1139 "lev_comp.y" /* yacc.c:1646 */ { if (n_if_list > 0) { struct opvar *tmppush = New(struct opvar); @@ -3434,11 +3478,11 @@ yyreduce: if_list[n_if_list++] = tmppush; } else lc_error("IF: Huh?! No else-part address?"); } -#line 3438 "y.tab.c" /* yacc.c:1646 */ +#line 3482 "y.tab.c" /* yacc.c:1646 */ break; case 160: -#line 1112 "lev_comp.y" /* yacc.c:1646 */ +#line 1156 "lev_comp.y" /* yacc.c:1646 */ { if (n_if_list > 0) { struct opvar *tmppush; @@ -3446,146 +3490,155 @@ yyreduce: set_opvar_int(tmppush, splev->n_opcodes - tmppush->vardata.l); } else lc_error("IF: Huh?! No end address?"); } -#line 3450 "y.tab.c" /* yacc.c:1646 */ +#line 3494 "y.tab.c" /* yacc.c:1646 */ break; case 161: -#line 1122 "lev_comp.y" /* yacc.c:1646 */ +#line 1166 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_MESSAGE); + add_opvars(splev, "o", VA_PASS1(SPO_MESSAGE)); } -#line 3458 "y.tab.c" /* yacc.c:1646 */ +#line 3502 "y.tab.c" /* yacc.c:1646 */ break; case 162: -#line 1128 "lev_comp.y" /* yacc.c:1646 */ +#line 1172 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iiiiiio", -1, 0, -1, -1, -1, -1, SPO_CORRIDOR); + add_opvars(splev, "iiiiiio", + VA_PASS7(-1, 0, -1, -1, -1, -1, SPO_CORRIDOR)); } -#line 3466 "y.tab.c" /* yacc.c:1646 */ +#line 3511 "y.tab.c" /* yacc.c:1646 */ break; case 163: -#line 1132 "lev_comp.y" /* yacc.c:1646 */ +#line 1177 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iiiiiio", -1, (yyvsp[0].i), -1, -1, -1, -1, SPO_CORRIDOR); + add_opvars(splev, "iiiiiio", + VA_PASS7(-1, (yyvsp[0].i), -1, -1, -1, -1, SPO_CORRIDOR)); } -#line 3474 "y.tab.c" /* yacc.c:1646 */ +#line 3520 "y.tab.c" /* yacc.c:1646 */ break; case 164: -#line 1136 "lev_comp.y" /* yacc.c:1646 */ +#line 1182 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iiiiiio", -1, -1, -1, -1, -1, -1, SPO_CORRIDOR); + add_opvars(splev, "iiiiiio", + VA_PASS7(-1, -1, -1, -1, -1, -1, SPO_CORRIDOR)); } -#line 3482 "y.tab.c" /* yacc.c:1646 */ +#line 3529 "y.tab.c" /* yacc.c:1646 */ break; case 165: -#line 1142 "lev_comp.y" /* yacc.c:1646 */ +#line 1189 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiiiiio", - (yyvsp[-2].corpos).room, (yyvsp[-2].corpos).door, (yyvsp[-2].corpos).wall, - (yyvsp[0].corpos).room, (yyvsp[0].corpos).door, (yyvsp[0].corpos).wall, - SPO_CORRIDOR); + VA_PASS7((yyvsp[-2].corpos).room, (yyvsp[-2].corpos).door, (yyvsp[-2].corpos).wall, + (yyvsp[0].corpos).room, (yyvsp[0].corpos).door, (yyvsp[0].corpos).wall, + SPO_CORRIDOR)); } -#line 3493 "y.tab.c" /* yacc.c:1646 */ +#line 3540 "y.tab.c" /* yacc.c:1646 */ break; case 166: -#line 1149 "lev_comp.y" /* yacc.c:1646 */ +#line 1196 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiiiiio", - (yyvsp[-2].corpos).room, (yyvsp[-2].corpos).door, (yyvsp[-2].corpos).wall, - -1, -1, (long)(yyvsp[0].i), - SPO_CORRIDOR); + VA_PASS7((yyvsp[-2].corpos).room, (yyvsp[-2].corpos).door, (yyvsp[-2].corpos).wall, + -1, -1, (long)(yyvsp[0].i), + SPO_CORRIDOR)); } -#line 3504 "y.tab.c" /* yacc.c:1646 */ +#line 3551 "y.tab.c" /* yacc.c:1646 */ break; case 167: -#line 1158 "lev_comp.y" /* yacc.c:1646 */ +#line 1205 "lev_comp.y" /* yacc.c:1646 */ { (yyval.corpos).room = (yyvsp[-5].i); (yyval.corpos).wall = (yyvsp[-3].i); (yyval.corpos).door = (yyvsp[-1].i); } -#line 3514 "y.tab.c" /* yacc.c:1646 */ +#line 3561 "y.tab.c" /* yacc.c:1646 */ break; case 168: -#line 1166 "lev_comp.y" /* yacc.c:1646 */ +#line 1213 "lev_comp.y" /* yacc.c:1646 */ { if (((yyvsp[-2].i) < 100) && ((yyvsp[-3].i) == OROOM)) lc_error("Only typed rooms can have a chance."); else { - add_opvars(splev, "iii", (long)(yyvsp[-3].i), (long)(yyvsp[-2].i), (long)(yyvsp[0].i)); + add_opvars(splev, "iii", + VA_PASS3((long)(yyvsp[-3].i), (long)(yyvsp[-2].i), (long)(yyvsp[0].i))); } } -#line 3526 "y.tab.c" /* yacc.c:1646 */ +#line 3574 "y.tab.c" /* yacc.c:1646 */ break; case 169: -#line 1176 "lev_comp.y" /* yacc.c:1646 */ +#line 1224 "lev_comp.y" /* yacc.c:1646 */ { - long flags = (yyvsp[0].i); - if (flags == -1) flags = (1 << 0); - add_opvars(splev, "iiiiiiio", flags, ERR, ERR, - (yyvsp[-3].crd).x, (yyvsp[-3].crd).y, (yyvsp[-1].sze).width, (yyvsp[-1].sze).height, SPO_SUBROOM); + long rflags = (yyvsp[0].i); + + if (rflags == -1) rflags = (1 << 0); + add_opvars(splev, "iiiiiiio", + VA_PASS8(rflags, ERR, ERR, + (yyvsp[-3].crd).x, (yyvsp[-3].crd).y, (yyvsp[-1].sze).width, (yyvsp[-1].sze).height, + SPO_SUBROOM)); break_stmt_start(); } -#line 3538 "y.tab.c" /* yacc.c:1646 */ +#line 3589 "y.tab.c" /* yacc.c:1646 */ break; case 170: -#line 1184 "lev_comp.y" /* yacc.c:1646 */ +#line 1235 "lev_comp.y" /* yacc.c:1646 */ { break_stmt_end(splev); add_opcode(splev, SPO_ENDROOM, NULL); } -#line 3547 "y.tab.c" /* yacc.c:1646 */ +#line 3598 "y.tab.c" /* yacc.c:1646 */ break; case 171: -#line 1191 "lev_comp.y" /* yacc.c:1646 */ +#line 1242 "lev_comp.y" /* yacc.c:1646 */ { - long flags = (yyvsp[-2].i); - if (flags == -1) flags = (1 << 0); - add_opvars(splev, "iiiiiiio", flags, - (yyvsp[-3].crd).x, (yyvsp[-3].crd).y, (yyvsp[-5].crd).x, (yyvsp[-5].crd).y, - (yyvsp[-1].sze).width, (yyvsp[-1].sze).height, SPO_ROOM); + long rflags = (yyvsp[-2].i); + + if (rflags == -1) rflags = (1 << 0); + add_opvars(splev, "iiiiiiio", + VA_PASS8(rflags, + (yyvsp[-3].crd).x, (yyvsp[-3].crd).y, (yyvsp[-5].crd).x, (yyvsp[-5].crd).y, + (yyvsp[-1].sze).width, (yyvsp[-1].sze).height, SPO_ROOM)); break_stmt_start(); } -#line 3560 "y.tab.c" /* yacc.c:1646 */ +#line 3613 "y.tab.c" /* yacc.c:1646 */ break; case 172: -#line 1200 "lev_comp.y" /* yacc.c:1646 */ +#line 1253 "lev_comp.y" /* yacc.c:1646 */ { break_stmt_end(splev); add_opcode(splev, SPO_ENDROOM, NULL); } -#line 3569 "y.tab.c" /* yacc.c:1646 */ +#line 3622 "y.tab.c" /* yacc.c:1646 */ break; case 173: -#line 1207 "lev_comp.y" /* yacc.c:1646 */ +#line 1260 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 1; } -#line 3577 "y.tab.c" /* yacc.c:1646 */ +#line 3630 "y.tab.c" /* yacc.c:1646 */ break; case 174: -#line 1211 "lev_comp.y" /* yacc.c:1646 */ +#line 1264 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 3585 "y.tab.c" /* yacc.c:1646 */ +#line 3638 "y.tab.c" /* yacc.c:1646 */ break; case 175: -#line 1217 "lev_comp.y" /* yacc.c:1646 */ +#line 1270 "lev_comp.y" /* yacc.c:1646 */ { if ( (yyvsp[-3].i) < 1 || (yyvsp[-3].i) > 5 || (yyvsp[-1].i) < 1 || (yyvsp[-1].i) > 5 ) { @@ -3595,19 +3648,19 @@ yyreduce: (yyval.crd).y = (yyvsp[-1].i); } } -#line 3599 "y.tab.c" /* yacc.c:1646 */ +#line 3652 "y.tab.c" /* yacc.c:1646 */ break; case 176: -#line 1227 "lev_comp.y" /* yacc.c:1646 */ +#line 1280 "lev_comp.y" /* yacc.c:1646 */ { (yyval.crd).x = (yyval.crd).y = ERR; } -#line 3607 "y.tab.c" /* yacc.c:1646 */ +#line 3660 "y.tab.c" /* yacc.c:1646 */ break; case 177: -#line 1233 "lev_comp.y" /* yacc.c:1646 */ +#line 1286 "lev_comp.y" /* yacc.c:1646 */ { if ( (yyvsp[-3].i) < 0 || (yyvsp[-1].i) < 0) { lc_error("Invalid subroom position (%li,%li)!", (yyvsp[-3].i), (yyvsp[-1].i)); @@ -3616,340 +3669,350 @@ yyreduce: (yyval.crd).y = (yyvsp[-1].i); } } -#line 3620 "y.tab.c" /* yacc.c:1646 */ +#line 3673 "y.tab.c" /* yacc.c:1646 */ break; case 178: -#line 1242 "lev_comp.y" /* yacc.c:1646 */ +#line 1295 "lev_comp.y" /* yacc.c:1646 */ { (yyval.crd).x = (yyval.crd).y = ERR; } -#line 3628 "y.tab.c" /* yacc.c:1646 */ +#line 3681 "y.tab.c" /* yacc.c:1646 */ break; case 179: -#line 1248 "lev_comp.y" /* yacc.c:1646 */ +#line 1301 "lev_comp.y" /* yacc.c:1646 */ { (yyval.crd).x = (yyvsp[-3].i); (yyval.crd).y = (yyvsp[-1].i); } -#line 3637 "y.tab.c" /* yacc.c:1646 */ +#line 3690 "y.tab.c" /* yacc.c:1646 */ break; case 180: -#line 1253 "lev_comp.y" /* yacc.c:1646 */ +#line 1306 "lev_comp.y" /* yacc.c:1646 */ { (yyval.crd).x = (yyval.crd).y = ERR; } -#line 3645 "y.tab.c" /* yacc.c:1646 */ +#line 3698 "y.tab.c" /* yacc.c:1646 */ break; case 181: -#line 1259 "lev_comp.y" /* yacc.c:1646 */ +#line 1312 "lev_comp.y" /* yacc.c:1646 */ { (yyval.sze).width = (yyvsp[-3].i); (yyval.sze).height = (yyvsp[-1].i); } -#line 3654 "y.tab.c" /* yacc.c:1646 */ +#line 3707 "y.tab.c" /* yacc.c:1646 */ break; case 182: -#line 1264 "lev_comp.y" /* yacc.c:1646 */ +#line 1317 "lev_comp.y" /* yacc.c:1646 */ { (yyval.sze).height = (yyval.sze).width = ERR; } -#line 3662 "y.tab.c" /* yacc.c:1646 */ +#line 3715 "y.tab.c" /* yacc.c:1646 */ break; case 183: -#line 1270 "lev_comp.y" /* yacc.c:1646 */ +#line 1323 "lev_comp.y" /* yacc.c:1646 */ { /* ERR means random here */ if ((yyvsp[-2].i) == ERR && (yyvsp[0].i) != ERR) { lc_error("If the door wall is random, so must be its pos!"); } else { - add_opvars(splev, "iiiio", (long)(yyvsp[0].i), (long)(yyvsp[-4].i), (long)(yyvsp[-6].i), (long)(yyvsp[-2].i), SPO_ROOM_DOOR); + add_opvars(splev, "iiiio", + VA_PASS5((long)(yyvsp[0].i), (long)(yyvsp[-4].i), (long)(yyvsp[-6].i), + (long)(yyvsp[-2].i), SPO_ROOM_DOOR)); } } -#line 3675 "y.tab.c" /* yacc.c:1646 */ +#line 3730 "y.tab.c" /* yacc.c:1646 */ break; case 184: -#line 1279 "lev_comp.y" /* yacc.c:1646 */ +#line 1334 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (long)(yyvsp[-2].i), SPO_DOOR); + add_opvars(splev, "io", VA_PASS2((long)(yyvsp[-2].i), SPO_DOOR)); } -#line 3683 "y.tab.c" /* yacc.c:1646 */ +#line 3738 "y.tab.c" /* yacc.c:1646 */ break; case 189: -#line 1293 "lev_comp.y" /* yacc.c:1646 */ +#line 1348 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 3691 "y.tab.c" /* yacc.c:1646 */ +#line 3746 "y.tab.c" /* yacc.c:1646 */ break; case 190: -#line 1297 "lev_comp.y" /* yacc.c:1646 */ +#line 1352 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = ((yyvsp[-2].i) | (yyvsp[0].i)); } -#line 3699 "y.tab.c" /* yacc.c:1646 */ +#line 3754 "y.tab.c" /* yacc.c:1646 */ break; case 193: -#line 1307 "lev_comp.y" /* yacc.c:1646 */ +#line 1362 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ciisiio", 0, 0, 1, (char *)0, 0, 0, SPO_MAP); + add_opvars(splev, "ciisiio", + VA_PASS7(0, 0, 1, (char *)0, 0, 0, SPO_MAP)); max_x_map = COLNO-1; max_y_map = ROWNO; } -#line 3709 "y.tab.c" /* yacc.c:1646 */ - break; - - case 194: -#line 1313 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "cii", SP_COORD_PACK(((yyvsp[-4].i)),((yyvsp[-2].i))), 1, (long)(yyvsp[-1].i)); - scan_map((yyvsp[0].map), splev); - Free((yyvsp[0].map)); - } -#line 3719 "y.tab.c" /* yacc.c:1646 */ - break; - - case 195: -#line 1319 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "ii", 2, (long)(yyvsp[-1].i)); - scan_map((yyvsp[0].map), splev); - Free((yyvsp[0].map)); - } -#line 3729 "y.tab.c" /* yacc.c:1646 */ - break; - - case 200: -#line 1335 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "io", 0, SPO_MONSTER); - } -#line 3737 "y.tab.c" /* yacc.c:1646 */ - break; - - case 201: -#line 1339 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "io", 1, SPO_MONSTER); - in_container_obj++; - break_stmt_start(); - } -#line 3747 "y.tab.c" /* yacc.c:1646 */ - break; - - case 202: -#line 1345 "lev_comp.y" /* yacc.c:1646 */ - { - break_stmt_end(splev); - in_container_obj--; - add_opvars(splev, "o", SPO_END_MONINVENT); - } -#line 3757 "y.tab.c" /* yacc.c:1646 */ - break; - - case 203: -#line 1353 "lev_comp.y" /* yacc.c:1646 */ - { - /* nothing */ - } #line 3765 "y.tab.c" /* yacc.c:1646 */ break; + case 194: +#line 1369 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "cii", + VA_PASS3(SP_COORD_PACK(((yyvsp[-4].i)),((yyvsp[-2].i))), + 1, (long)(yyvsp[-1].i))); + scan_map((yyvsp[0].map), splev); + Free((yyvsp[0].map)); + } +#line 3777 "y.tab.c" /* yacc.c:1646 */ + break; + + case 195: +#line 1377 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "ii", VA_PASS2(2, (long)(yyvsp[-1].i))); + scan_map((yyvsp[0].map), splev); + Free((yyvsp[0].map)); + } +#line 3787 "y.tab.c" /* yacc.c:1646 */ + break; + + case 200: +#line 1393 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "io", VA_PASS2(0, SPO_MONSTER)); + } +#line 3795 "y.tab.c" /* yacc.c:1646 */ + break; + + case 201: +#line 1397 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "io", VA_PASS2(1, SPO_MONSTER)); + in_container_obj++; + break_stmt_start(); + } +#line 3805 "y.tab.c" /* yacc.c:1646 */ + break; + + case 202: +#line 1403 "lev_comp.y" /* yacc.c:1646 */ + { + break_stmt_end(splev); + in_container_obj--; + add_opvars(splev, "o", VA_PASS1(SPO_END_MONINVENT)); + } +#line 3815 "y.tab.c" /* yacc.c:1646 */ + break; + + case 203: +#line 1411 "lev_comp.y" /* yacc.c:1646 */ + { + /* nothing */ + } +#line 3823 "y.tab.c" /* yacc.c:1646 */ + break; + case 204: -#line 1359 "lev_comp.y" /* yacc.c:1646 */ +#line 1417 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *stopit = New(struct opvar); set_opvar_int(stopit, SP_M_V_END); add_opcode(splev, SPO_PUSH, stopit); (yyval.i) = 0x0000; } -#line 3776 "y.tab.c" /* yacc.c:1646 */ +#line 3834 "y.tab.c" /* yacc.c:1646 */ break; case 205: -#line 1366 "lev_comp.y" /* yacc.c:1646 */ +#line 1424 "lev_comp.y" /* yacc.c:1646 */ { if (( (yyvsp[-2].i) & (yyvsp[0].i) )) lc_error("MONSTER extra info defined twice."); (yyval.i) = ( (yyvsp[-2].i) | (yyvsp[0].i) ); } -#line 3786 "y.tab.c" /* yacc.c:1646 */ +#line 3844 "y.tab.c" /* yacc.c:1646 */ break; case 206: -#line 1374 "lev_comp.y" /* yacc.c:1646 */ +#line 1432 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_M_V_NAME); + add_opvars(splev, "i", VA_PASS1(SP_M_V_NAME)); (yyval.i) = 0x0001; } -#line 3795 "y.tab.c" /* yacc.c:1646 */ +#line 3853 "y.tab.c" /* yacc.c:1646 */ break; case 207: -#line 1379 "lev_comp.y" /* yacc.c:1646 */ +#line 1437 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_M_V_PEACEFUL); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[0].i), SP_M_V_PEACEFUL)); (yyval.i) = 0x0002; } -#line 3804 "y.tab.c" /* yacc.c:1646 */ +#line 3863 "y.tab.c" /* yacc.c:1646 */ break; case 208: -#line 1384 "lev_comp.y" /* yacc.c:1646 */ +#line 1443 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_M_V_ASLEEP); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[0].i), SP_M_V_ASLEEP)); (yyval.i) = 0x0004; } -#line 3813 "y.tab.c" /* yacc.c:1646 */ +#line 3873 "y.tab.c" /* yacc.c:1646 */ break; case 209: -#line 1389 "lev_comp.y" /* yacc.c:1646 */ +#line 1449 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_M_V_ALIGN); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[0].i), SP_M_V_ALIGN)); (yyval.i) = 0x0008; } -#line 3822 "y.tab.c" /* yacc.c:1646 */ +#line 3883 "y.tab.c" /* yacc.c:1646 */ break; case 210: -#line 1394 "lev_comp.y" /* yacc.c:1646 */ +#line 1455 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", (long)(yyvsp[-1].i), SP_M_V_APPEAR); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[-1].i), SP_M_V_APPEAR)); (yyval.i) = 0x0010; } -#line 3831 "y.tab.c" /* yacc.c:1646 */ +#line 3893 "y.tab.c" /* yacc.c:1646 */ break; case 211: -#line 1399 "lev_comp.y" /* yacc.c:1646 */ +#line 1461 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_FEMALE); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_FEMALE)); (yyval.i) = 0x0020; } -#line 3840 "y.tab.c" /* yacc.c:1646 */ +#line 3902 "y.tab.c" /* yacc.c:1646 */ break; case 212: -#line 1404 "lev_comp.y" /* yacc.c:1646 */ +#line 1466 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_INVIS); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_INVIS)); (yyval.i) = 0x0040; } -#line 3849 "y.tab.c" /* yacc.c:1646 */ +#line 3911 "y.tab.c" /* yacc.c:1646 */ break; case 213: -#line 1409 "lev_comp.y" /* yacc.c:1646 */ +#line 1471 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_CANCELLED); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_CANCELLED)); (yyval.i) = 0x0080; } -#line 3858 "y.tab.c" /* yacc.c:1646 */ +#line 3920 "y.tab.c" /* yacc.c:1646 */ break; case 214: -#line 1414 "lev_comp.y" /* yacc.c:1646 */ +#line 1476 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_REVIVED); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_REVIVED)); (yyval.i) = 0x0100; } -#line 3867 "y.tab.c" /* yacc.c:1646 */ +#line 3929 "y.tab.c" /* yacc.c:1646 */ break; case 215: -#line 1419 "lev_comp.y" /* yacc.c:1646 */ +#line 1481 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_AVENGE); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_AVENGE)); (yyval.i) = 0x0200; } -#line 3876 "y.tab.c" /* yacc.c:1646 */ +#line 3938 "y.tab.c" /* yacc.c:1646 */ break; case 216: -#line 1424 "lev_comp.y" /* yacc.c:1646 */ +#line 1486 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_M_V_FLEEING); + add_opvars(splev, "i", VA_PASS1(SP_M_V_FLEEING)); (yyval.i) = 0x0400; } -#line 3885 "y.tab.c" /* yacc.c:1646 */ +#line 3947 "y.tab.c" /* yacc.c:1646 */ break; case 217: -#line 1429 "lev_comp.y" /* yacc.c:1646 */ +#line 1491 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_M_V_BLINDED); + add_opvars(splev, "i", VA_PASS1(SP_M_V_BLINDED)); (yyval.i) = 0x0800; } -#line 3894 "y.tab.c" /* yacc.c:1646 */ +#line 3956 "y.tab.c" /* yacc.c:1646 */ break; case 218: -#line 1434 "lev_comp.y" /* yacc.c:1646 */ +#line 1496 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_M_V_PARALYZED); + add_opvars(splev, "i", VA_PASS1(SP_M_V_PARALYZED)); (yyval.i) = 0x1000; } -#line 3903 "y.tab.c" /* yacc.c:1646 */ +#line 3965 "y.tab.c" /* yacc.c:1646 */ break; case 219: -#line 1439 "lev_comp.y" /* yacc.c:1646 */ +#line 1501 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_STUNNED); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_STUNNED)); (yyval.i) = 0x2000; } -#line 3912 "y.tab.c" /* yacc.c:1646 */ +#line 3974 "y.tab.c" /* yacc.c:1646 */ break; case 220: -#line 1444 "lev_comp.y" /* yacc.c:1646 */ +#line 1506 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_M_V_CONFUSED); + add_opvars(splev, "ii", VA_PASS2(1, SP_M_V_CONFUSED)); (yyval.i) = 0x4000; } -#line 3921 "y.tab.c" /* yacc.c:1646 */ +#line 3983 "y.tab.c" /* yacc.c:1646 */ break; case 221: -#line 1449 "lev_comp.y" /* yacc.c:1646 */ +#line 1511 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_M_V_SEENTRAPS); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[0].i), SP_M_V_SEENTRAPS)); (yyval.i) = 0x8000; } -#line 3930 "y.tab.c" /* yacc.c:1646 */ +#line 3993 "y.tab.c" /* yacc.c:1646 */ break; case 222: -#line 1456 "lev_comp.y" /* yacc.c:1646 */ +#line 1519 "lev_comp.y" /* yacc.c:1646 */ { int token = get_trap_type((yyvsp[0].map)); if (token == ERR || token == 0) lc_error("Unknown trap type '%s'!", (yyvsp[0].map)); (yyval.i) = (1L << (token - 1)); } -#line 3941 "y.tab.c" /* yacc.c:1646 */ +#line 4004 "y.tab.c" /* yacc.c:1646 */ break; case 223: -#line 1463 "lev_comp.y" /* yacc.c:1646 */ +#line 1526 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (long) ~0; } -#line 3949 "y.tab.c" /* yacc.c:1646 */ +#line 4012 "y.tab.c" /* yacc.c:1646 */ break; case 224: -#line 1467 "lev_comp.y" /* yacc.c:1646 */ +#line 1530 "lev_comp.y" /* yacc.c:1646 */ { int token = get_trap_type((yyvsp[-2].map)); if (token == ERR || token == 0) @@ -3960,231 +4023,233 @@ yyreduce: (yyval.i) = ((1L << (token - 1)) | (yyvsp[0].i)); } -#line 3964 "y.tab.c" /* yacc.c:1646 */ +#line 4027 "y.tab.c" /* yacc.c:1646 */ break; case 225: -#line 1480 "lev_comp.y" /* yacc.c:1646 */ +#line 1543 "lev_comp.y" /* yacc.c:1646 */ { long cnt = 0; if (in_container_obj) cnt |= SP_OBJ_CONTENT; - add_opvars(splev, "io", cnt, SPO_OBJECT); + add_opvars(splev, "io", VA_PASS2(cnt, SPO_OBJECT)); } -#line 3974 "y.tab.c" /* yacc.c:1646 */ +#line 4037 "y.tab.c" /* yacc.c:1646 */ break; case 226: -#line 1486 "lev_comp.y" /* yacc.c:1646 */ +#line 1549 "lev_comp.y" /* yacc.c:1646 */ { long cnt = SP_OBJ_CONTAINER; if (in_container_obj) cnt |= SP_OBJ_CONTENT; - add_opvars(splev, "io", cnt, SPO_OBJECT); + add_opvars(splev, "io", VA_PASS2(cnt, SPO_OBJECT)); in_container_obj++; break_stmt_start(); } -#line 3986 "y.tab.c" /* yacc.c:1646 */ +#line 4049 "y.tab.c" /* yacc.c:1646 */ break; case 227: -#line 1494 "lev_comp.y" /* yacc.c:1646 */ +#line 1557 "lev_comp.y" /* yacc.c:1646 */ { break_stmt_end(splev); in_container_obj--; add_opcode(splev, SPO_POP_CONTAINER, NULL); } -#line 3996 "y.tab.c" /* yacc.c:1646 */ +#line 4059 "y.tab.c" /* yacc.c:1646 */ break; case 228: -#line 1502 "lev_comp.y" /* yacc.c:1646 */ +#line 1565 "lev_comp.y" /* yacc.c:1646 */ { if (( (yyvsp[0].i) & 0x4000) && in_container_obj) lc_error("Object cannot have a coord when contained."); else if (!( (yyvsp[0].i) & 0x4000) && !in_container_obj) lc_error("Object needs a coord when not contained."); } -#line 4005 "y.tab.c" /* yacc.c:1646 */ +#line 4068 "y.tab.c" /* yacc.c:1646 */ break; case 229: -#line 1509 "lev_comp.y" /* yacc.c:1646 */ +#line 1572 "lev_comp.y" /* yacc.c:1646 */ { struct opvar *stopit = New(struct opvar); set_opvar_int(stopit, SP_O_V_END); add_opcode(splev, SPO_PUSH, stopit); (yyval.i) = 0x00; } -#line 4016 "y.tab.c" /* yacc.c:1646 */ +#line 4079 "y.tab.c" /* yacc.c:1646 */ break; case 230: -#line 1516 "lev_comp.y" /* yacc.c:1646 */ +#line 1579 "lev_comp.y" /* yacc.c:1646 */ { if (( (yyvsp[-2].i) & (yyvsp[0].i) )) lc_error("OBJECT extra info '%s' defined twice.", curr_token); (yyval.i) = ( (yyvsp[-2].i) | (yyvsp[0].i) ); } -#line 4026 "y.tab.c" /* yacc.c:1646 */ - break; - - case 231: -#line 1524 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_O_V_CURSE); - (yyval.i) = 0x0001; - } -#line 4035 "y.tab.c" /* yacc.c:1646 */ - break; - - case 232: -#line 1529 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", SP_O_V_CORPSENM); - (yyval.i) = 0x0002; - } -#line 4044 "y.tab.c" /* yacc.c:1646 */ - break; - - case 233: -#line 1534 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", SP_O_V_SPE); - (yyval.i) = 0x0004; - } -#line 4053 "y.tab.c" /* yacc.c:1646 */ - break; - - case 234: -#line 1539 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", SP_O_V_NAME); - (yyval.i) = 0x0008; - } -#line 4062 "y.tab.c" /* yacc.c:1646 */ - break; - - case 235: -#line 1544 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", SP_O_V_QUAN); - (yyval.i) = 0x0010; - } -#line 4071 "y.tab.c" /* yacc.c:1646 */ - break; - - case 236: -#line 1549 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "ii", 1, SP_O_V_BURIED); - (yyval.i) = 0x0020; - } -#line 4080 "y.tab.c" /* yacc.c:1646 */ - break; - - case 237: -#line 1554 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "ii", (long)(yyvsp[0].i), SP_O_V_LIT); - (yyval.i) = 0x0040; - } #line 4089 "y.tab.c" /* yacc.c:1646 */ break; - case 238: -#line 1559 "lev_comp.y" /* yacc.c:1646 */ + case 231: +#line 1587 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_O_V_ERODED); + add_opvars(splev, "ii", + VA_PASS2((long)(yyvsp[0].i), SP_O_V_CURSE)); + (yyval.i) = 0x0001; + } +#line 4099 "y.tab.c" /* yacc.c:1646 */ + break; + + case 232: +#line 1593 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1(SP_O_V_CORPSENM)); + (yyval.i) = 0x0002; + } +#line 4108 "y.tab.c" /* yacc.c:1646 */ + break; + + case 233: +#line 1598 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1(SP_O_V_SPE)); + (yyval.i) = 0x0004; + } +#line 4117 "y.tab.c" /* yacc.c:1646 */ + break; + + case 234: +#line 1603 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1(SP_O_V_NAME)); + (yyval.i) = 0x0008; + } +#line 4126 "y.tab.c" /* yacc.c:1646 */ + break; + + case 235: +#line 1608 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1(SP_O_V_QUAN)); + (yyval.i) = 0x0010; + } +#line 4135 "y.tab.c" /* yacc.c:1646 */ + break; + + case 236: +#line 1613 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_BURIED)); + (yyval.i) = 0x0020; + } +#line 4144 "y.tab.c" /* yacc.c:1646 */ + break; + + case 237: +#line 1618 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "ii", VA_PASS2((long)(yyvsp[0].i), SP_O_V_LIT)); + (yyval.i) = 0x0040; + } +#line 4153 "y.tab.c" /* yacc.c:1646 */ + break; + + case 238: +#line 1623 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1(SP_O_V_ERODED)); (yyval.i) = 0x0080; } -#line 4098 "y.tab.c" /* yacc.c:1646 */ +#line 4162 "y.tab.c" /* yacc.c:1646 */ break; case 239: -#line 1564 "lev_comp.y" /* yacc.c:1646 */ +#line 1628 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", -1, SP_O_V_ERODED); + add_opvars(splev, "ii", VA_PASS2(-1, SP_O_V_ERODED)); (yyval.i) = 0x0080; } -#line 4107 "y.tab.c" /* yacc.c:1646 */ +#line 4171 "y.tab.c" /* yacc.c:1646 */ break; case 240: -#line 1569 "lev_comp.y" /* yacc.c:1646 */ +#line 1633 "lev_comp.y" /* yacc.c:1646 */ { if ((yyvsp[0].i) == D_LOCKED) { - add_opvars(splev, "ii", 1, SP_O_V_LOCKED); + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_LOCKED)); (yyval.i) = 0x0100; } else if ((yyvsp[0].i) == D_BROKEN) { - add_opvars(splev, "ii", 1, SP_O_V_BROKEN); + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_BROKEN)); (yyval.i) = 0x0200; } else - lc_error("OBJECT state can only be locked or broken."); + lc_error("DOOR state can only be locked or broken."); } -#line 4122 "y.tab.c" /* yacc.c:1646 */ +#line 4186 "y.tab.c" /* yacc.c:1646 */ break; case 241: -#line 1580 "lev_comp.y" /* yacc.c:1646 */ +#line 1644 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_O_V_TRAPPED); + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_TRAPPED)); (yyval.i) = 0x0400; } -#line 4131 "y.tab.c" /* yacc.c:1646 */ +#line 4195 "y.tab.c" /* yacc.c:1646 */ break; case 242: -#line 1585 "lev_comp.y" /* yacc.c:1646 */ +#line 1649 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_O_V_RECHARGED); + add_opvars(splev, "i", VA_PASS1(SP_O_V_RECHARGED)); (yyval.i) = 0x0800; } -#line 4140 "y.tab.c" /* yacc.c:1646 */ +#line 4204 "y.tab.c" /* yacc.c:1646 */ break; case 243: -#line 1590 "lev_comp.y" /* yacc.c:1646 */ +#line 1654 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_O_V_INVIS); + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_INVIS)); (yyval.i) = 0x1000; } -#line 4149 "y.tab.c" /* yacc.c:1646 */ +#line 4213 "y.tab.c" /* yacc.c:1646 */ break; case 244: -#line 1595 "lev_comp.y" /* yacc.c:1646 */ +#line 1659 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "ii", 1, SP_O_V_GREASED); + add_opvars(splev, "ii", VA_PASS2(1, SP_O_V_GREASED)); (yyval.i) = 0x2000; } -#line 4158 "y.tab.c" /* yacc.c:1646 */ +#line 4222 "y.tab.c" /* yacc.c:1646 */ break; case 245: -#line 1600 "lev_comp.y" /* yacc.c:1646 */ +#line 1664 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", SP_O_V_COORD); + add_opvars(splev, "i", VA_PASS1(SP_O_V_COORD)); (yyval.i) = 0x4000; } -#line 4167 "y.tab.c" /* yacc.c:1646 */ +#line 4231 "y.tab.c" /* yacc.c:1646 */ break; case 246: -#line 1607 "lev_comp.y" /* yacc.c:1646 */ +#line 1671 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (long)(yyvsp[-2].i), SPO_TRAP); + add_opvars(splev, "io", VA_PASS2((long)(yyvsp[-2].i), SPO_TRAP)); } -#line 4175 "y.tab.c" /* yacc.c:1646 */ +#line 4239 "y.tab.c" /* yacc.c:1646 */ break; case 247: -#line 1613 "lev_comp.y" /* yacc.c:1646 */ +#line 1677 "lev_comp.y" /* yacc.c:1646 */ { - long d, state = 0; + long dir, state = 0; + /* convert dir from a DIRECTION to a DB_DIR */ - d = (yyvsp[-2].i); - switch(d) { - case W_NORTH: d = DB_NORTH; break; - case W_SOUTH: d = DB_SOUTH; break; - case W_EAST: d = DB_EAST; break; - case W_WEST: d = DB_WEST; break; + dir = (yyvsp[-2].i); + switch (dir) { + case W_NORTH: dir = DB_NORTH; break; + case W_SOUTH: dir = DB_SOUTH; break; + case W_EAST: dir = DB_EAST; break; + case W_WEST: dir = DB_WEST; break; default: lc_error("Invalid drawbridge direction."); break; @@ -4198,222 +4263,231 @@ yyreduce: state = -1; else lc_error("A drawbridge can only be open, closed or random!"); - add_opvars(splev, "iio", state, d, SPO_DRAWBRIDGE); + add_opvars(splev, "iio", + VA_PASS3(state, dir, SPO_DRAWBRIDGE)); } -#line 4204 "y.tab.c" /* yacc.c:1646 */ +#line 4270 "y.tab.c" /* yacc.c:1646 */ break; case 248: -#line 1640 "lev_comp.y" /* yacc.c:1646 */ +#line 1706 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiio", - (long)(yyvsp[0].i), 1, 0, SPO_MAZEWALK); + VA_PASS4((long)(yyvsp[0].i), 1, 0, SPO_MAZEWALK)); } -#line 4213 "y.tab.c" /* yacc.c:1646 */ +#line 4279 "y.tab.c" /* yacc.c:1646 */ break; case 249: -#line 1645 "lev_comp.y" /* yacc.c:1646 */ +#line 1711 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiio", - (long)(yyvsp[-3].i), (long)(yyvsp[-1].i), (long)(yyvsp[0].i), SPO_MAZEWALK); + VA_PASS4((long)(yyvsp[-3].i), (long)(yyvsp[-1].i), + (long)(yyvsp[0].i), SPO_MAZEWALK)); } -#line 4222 "y.tab.c" /* yacc.c:1646 */ +#line 4289 "y.tab.c" /* yacc.c:1646 */ break; case 250: -#line 1652 "lev_comp.y" /* yacc.c:1646 */ +#line 1719 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "rio", SP_REGION_PACK(-1,-1,-1,-1), 0, SPO_WALLIFY); + add_opvars(splev, "rio", + VA_PASS3(SP_REGION_PACK(-1,-1,-1,-1), + 0, SPO_WALLIFY)); } -#line 4230 "y.tab.c" /* yacc.c:1646 */ +#line 4299 "y.tab.c" /* yacc.c:1646 */ break; case 251: -#line 1656 "lev_comp.y" /* yacc.c:1646 */ +#line 1725 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", 1, SPO_WALLIFY); + add_opvars(splev, "io", VA_PASS2(1, SPO_WALLIFY)); } -#line 4238 "y.tab.c" /* yacc.c:1646 */ +#line 4307 "y.tab.c" /* yacc.c:1646 */ break; case 252: -#line 1662 "lev_comp.y" /* yacc.c:1646 */ +#line 1731 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (long)(yyvsp[0].i), SPO_LADDER); + add_opvars(splev, "io", + VA_PASS2((long)(yyvsp[0].i), SPO_LADDER)); } -#line 4246 "y.tab.c" /* yacc.c:1646 */ +#line 4316 "y.tab.c" /* yacc.c:1646 */ break; case 253: -#line 1668 "lev_comp.y" /* yacc.c:1646 */ +#line 1738 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (long)(yyvsp[0].i), SPO_STAIR); + add_opvars(splev, "io", + VA_PASS2((long)(yyvsp[0].i), SPO_STAIR)); } -#line 4254 "y.tab.c" /* yacc.c:1646 */ +#line 4325 "y.tab.c" /* yacc.c:1646 */ break; case 254: -#line 1674 "lev_comp.y" /* yacc.c:1646 */ +#line 1745 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiiii iiiii iiso", - (yyvsp[-4].lregn).x1, (yyvsp[-4].lregn).y1, (yyvsp[-4].lregn).x2, (yyvsp[-4].lregn).y2, (yyvsp[-4].lregn).area, - (yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, - (long)(((yyvsp[0].i)) ? LR_UPSTAIR : LR_DOWNSTAIR), - 0, (char *)0, SPO_LEVREGION); + VA_PASS14((yyvsp[-4].lregn).x1, (yyvsp[-4].lregn).y1, (yyvsp[-4].lregn).x2, (yyvsp[-4].lregn).y2, (yyvsp[-4].lregn).area, + (yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, + (long)(((yyvsp[0].i)) ? LR_UPSTAIR : LR_DOWNSTAIR), + 0, (char *)0, SPO_LEVREGION)); } -#line 4266 "y.tab.c" /* yacc.c:1646 */ +#line 4337 "y.tab.c" /* yacc.c:1646 */ break; case 255: -#line 1684 "lev_comp.y" /* yacc.c:1646 */ +#line 1755 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiiii iiiii iiso", - (yyvsp[-4].lregn).x1, (yyvsp[-4].lregn).y1, (yyvsp[-4].lregn).x2, (yyvsp[-4].lregn).y2, (yyvsp[-4].lregn).area, - (yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, - LR_PORTAL, 0, (yyvsp[0].map), SPO_LEVREGION); + VA_PASS14((yyvsp[-4].lregn).x1, (yyvsp[-4].lregn).y1, (yyvsp[-4].lregn).x2, (yyvsp[-4].lregn).y2, (yyvsp[-4].lregn).area, + (yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, + LR_PORTAL, 0, (yyvsp[0].map), SPO_LEVREGION)); Free((yyvsp[0].map)); } -#line 4278 "y.tab.c" /* yacc.c:1646 */ +#line 4349 "y.tab.c" /* yacc.c:1646 */ break; case 256: -#line 1694 "lev_comp.y" /* yacc.c:1646 */ +#line 1765 "lev_comp.y" /* yacc.c:1646 */ { - long rtype = 0; + long rtyp = 0; switch((yyvsp[0].i)) { - case -1: rtype = LR_TELE; break; - case 0: rtype = LR_DOWNTELE; break; - case 1: rtype = LR_UPTELE; break; + case -1: rtyp = LR_TELE; break; + case 0: rtyp = LR_DOWNTELE; break; + case 1: rtyp = LR_UPTELE; break; } add_opvars(splev, "iiiii iiiii iiso", - (yyvsp[-3].lregn).x1, (yyvsp[-3].lregn).y1, (yyvsp[-3].lregn).x2, (yyvsp[-3].lregn).y2, (yyvsp[-3].lregn).area, - (yyvsp[-1].lregn).x1, (yyvsp[-1].lregn).y1, (yyvsp[-1].lregn).x2, (yyvsp[-1].lregn).y2, (yyvsp[-1].lregn).area, - rtype, 0, (char *)0, SPO_LEVREGION); + VA_PASS14((yyvsp[-3].lregn).x1, (yyvsp[-3].lregn).y1, (yyvsp[-3].lregn).x2, (yyvsp[-3].lregn).y2, (yyvsp[-3].lregn).area, + (yyvsp[-1].lregn).x1, (yyvsp[-1].lregn).y1, (yyvsp[-1].lregn).x2, (yyvsp[-1].lregn).y2, (yyvsp[-1].lregn).area, + rtyp, 0, (char *)0, SPO_LEVREGION)); } -#line 4295 "y.tab.c" /* yacc.c:1646 */ +#line 4366 "y.tab.c" /* yacc.c:1646 */ break; case 257: -#line 1709 "lev_comp.y" /* yacc.c:1646 */ +#line 1780 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "iiiii iiiii iiso", - (yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, - (yyvsp[0].lregn).x1, (yyvsp[0].lregn).y1, (yyvsp[0].lregn).x2, (yyvsp[0].lregn).y2, (yyvsp[0].lregn).area, - (long)LR_BRANCH, 0, (char *)0, SPO_LEVREGION); + VA_PASS14((yyvsp[-2].lregn).x1, (yyvsp[-2].lregn).y1, (yyvsp[-2].lregn).x2, (yyvsp[-2].lregn).y2, (yyvsp[-2].lregn).area, + (yyvsp[0].lregn).x1, (yyvsp[0].lregn).y1, (yyvsp[0].lregn).x2, (yyvsp[0].lregn).y2, (yyvsp[0].lregn).area, + (long)LR_BRANCH, 0, + (char *)0, SPO_LEVREGION)); } -#line 4306 "y.tab.c" /* yacc.c:1646 */ +#line 4378 "y.tab.c" /* yacc.c:1646 */ break; case 258: -#line 1718 "lev_comp.y" /* yacc.c:1646 */ +#line 1790 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = -1; } -#line 4314 "y.tab.c" /* yacc.c:1646 */ +#line 4386 "y.tab.c" /* yacc.c:1646 */ break; case 259: -#line 1722 "lev_comp.y" /* yacc.c:1646 */ +#line 1794 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 4322 "y.tab.c" /* yacc.c:1646 */ +#line 4394 "y.tab.c" /* yacc.c:1646 */ break; case 260: -#line 1728 "lev_comp.y" /* yacc.c:1646 */ +#line 1800 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_FOUNTAIN); + add_opvars(splev, "o", VA_PASS1(SPO_FOUNTAIN)); } -#line 4330 "y.tab.c" /* yacc.c:1646 */ +#line 4402 "y.tab.c" /* yacc.c:1646 */ break; case 261: -#line 1734 "lev_comp.y" /* yacc.c:1646 */ +#line 1806 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SINK); + add_opvars(splev, "o", VA_PASS1(SPO_SINK)); } -#line 4338 "y.tab.c" /* yacc.c:1646 */ +#line 4410 "y.tab.c" /* yacc.c:1646 */ break; case 262: -#line 1740 "lev_comp.y" /* yacc.c:1646 */ +#line 1812 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_POOL); + add_opvars(splev, "o", VA_PASS1(SPO_POOL)); } -#line 4346 "y.tab.c" /* yacc.c:1646 */ +#line 4418 "y.tab.c" /* yacc.c:1646 */ break; case 263: -#line 1746 "lev_comp.y" /* yacc.c:1646 */ +#line 1818 "lev_comp.y" /* yacc.c:1646 */ { (yyval.terr).lit = -2; (yyval.terr).ter = what_map_char((char) (yyvsp[0].i)); } -#line 4355 "y.tab.c" /* yacc.c:1646 */ +#line 4427 "y.tab.c" /* yacc.c:1646 */ break; case 264: -#line 1751 "lev_comp.y" /* yacc.c:1646 */ +#line 1823 "lev_comp.y" /* yacc.c:1646 */ { (yyval.terr).lit = (yyvsp[-1].i); (yyval.terr).ter = what_map_char((char) (yyvsp[-3].i)); } -#line 4364 "y.tab.c" /* yacc.c:1646 */ +#line 4436 "y.tab.c" /* yacc.c:1646 */ break; case 265: -#line 1758 "lev_comp.y" /* yacc.c:1646 */ +#line 1830 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (yyvsp[0].i), SPO_REPLACETERRAIN); + add_opvars(splev, "io", + VA_PASS2((yyvsp[0].i), SPO_REPLACETERRAIN)); } -#line 4372 "y.tab.c" /* yacc.c:1646 */ +#line 4445 "y.tab.c" /* yacc.c:1646 */ break; case 266: -#line 1764 "lev_comp.y" /* yacc.c:1646 */ +#line 1837 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_TERRAIN); + add_opvars(splev, "o", VA_PASS1(SPO_TERRAIN)); } -#line 4380 "y.tab.c" /* yacc.c:1646 */ +#line 4453 "y.tab.c" /* yacc.c:1646 */ break; case 267: -#line 1770 "lev_comp.y" /* yacc.c:1646 */ +#line 1843 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_NON_DIGGABLE); + add_opvars(splev, "o", VA_PASS1(SPO_NON_DIGGABLE)); } -#line 4388 "y.tab.c" /* yacc.c:1646 */ +#line 4461 "y.tab.c" /* yacc.c:1646 */ break; case 268: -#line 1776 "lev_comp.y" /* yacc.c:1646 */ +#line 1849 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_NON_PASSWALL); + add_opvars(splev, "o", VA_PASS1(SPO_NON_PASSWALL)); } -#line 4396 "y.tab.c" /* yacc.c:1646 */ +#line 4469 "y.tab.c" /* yacc.c:1646 */ break; case 269: -#line 1782 "lev_comp.y" /* yacc.c:1646 */ +#line 1855 "lev_comp.y" /* yacc.c:1646 */ { long irr; long rt = (yyvsp[-1].i); - long flags = (yyvsp[0].i); - if (flags == -1) flags = (1 << 0); - if (!(( flags ) & 1)) rt += MAXRTYPE+1; - irr = ((( flags ) & 2) != 0); + long rflags = (yyvsp[0].i); + + if (rflags == -1) rflags = (1 << 0); + if (!(rflags & 1)) rt += MAXRTYPE+1; + irr = ((rflags & 2) != 0); add_opvars(splev, "iiio", - (long)(yyvsp[-3].i), rt, flags, SPO_REGION); - (yyval.i) = (irr || (flags & 1) || rt != OROOM); + VA_PASS4((long)(yyvsp[-3].i), rt, rflags, SPO_REGION)); + (yyval.i) = (irr || (rflags & 1) || rt != OROOM); break_stmt_start(); } -#line 4413 "y.tab.c" /* yacc.c:1646 */ +#line 4487 "y.tab.c" /* yacc.c:1646 */ break; case 270: -#line 1795 "lev_comp.y" /* yacc.c:1646 */ +#line 1869 "lev_comp.y" /* yacc.c:1646 */ { break_stmt_end(splev); if ( (yyvsp[-1].i) ) { @@ -4421,94 +4495,96 @@ yyreduce: } else if ( (yyvsp[0].i) ) lc_error("Cannot use lev statements in non-permanent REGION"); } -#line 4425 "y.tab.c" /* yacc.c:1646 */ +#line 4499 "y.tab.c" /* yacc.c:1646 */ break; case 271: -#line 1805 "lev_comp.y" /* yacc.c:1646 */ +#line 1879 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = 0; } -#line 4433 "y.tab.c" /* yacc.c:1646 */ +#line 4507 "y.tab.c" /* yacc.c:1646 */ break; case 272: -#line 1809 "lev_comp.y" /* yacc.c:1646 */ +#line 1883 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 4441 "y.tab.c" /* yacc.c:1646 */ +#line 4515 "y.tab.c" /* yacc.c:1646 */ break; case 273: -#line 1815 "lev_comp.y" /* yacc.c:1646 */ +#line 1889 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iio", (long)(yyvsp[0].i), (long)(yyvsp[-2].i), SPO_ALTAR); + add_opvars(splev, "iio", + VA_PASS3((long)(yyvsp[0].i), (long)(yyvsp[-2].i), SPO_ALTAR)); } -#line 4449 "y.tab.c" /* yacc.c:1646 */ +#line 4524 "y.tab.c" /* yacc.c:1646 */ break; case 274: -#line 1821 "lev_comp.y" /* yacc.c:1646 */ +#line 1896 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", 2, SPO_GRAVE); + add_opvars(splev, "io", VA_PASS2(2, SPO_GRAVE)); } -#line 4457 "y.tab.c" /* yacc.c:1646 */ +#line 4532 "y.tab.c" /* yacc.c:1646 */ break; case 275: -#line 1825 "lev_comp.y" /* yacc.c:1646 */ +#line 1900 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "sio", - (char *)0, 1, SPO_GRAVE); + VA_PASS3((char *)0, 1, SPO_GRAVE)); } -#line 4466 "y.tab.c" /* yacc.c:1646 */ +#line 4541 "y.tab.c" /* yacc.c:1646 */ break; case 276: -#line 1830 "lev_comp.y" /* yacc.c:1646 */ +#line 1905 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "sio", - (char *)0, 0, SPO_GRAVE); + VA_PASS3((char *)0, 0, SPO_GRAVE)); } -#line 4475 "y.tab.c" /* yacc.c:1646 */ +#line 4550 "y.tab.c" /* yacc.c:1646 */ break; case 277: -#line 1837 "lev_comp.y" /* yacc.c:1646 */ +#line 1912 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_GOLD); + add_opvars(splev, "o", VA_PASS1(SPO_GOLD)); } -#line 4483 "y.tab.c" /* yacc.c:1646 */ +#line 4558 "y.tab.c" /* yacc.c:1646 */ break; case 278: -#line 1843 "lev_comp.y" /* yacc.c:1646 */ +#line 1918 "lev_comp.y" /* yacc.c:1646 */ { add_opvars(splev, "io", - (long)(yyvsp[-2].i), SPO_ENGRAVING); + VA_PASS2((long)(yyvsp[-2].i), SPO_ENGRAVING)); } -#line 4492 "y.tab.c" /* yacc.c:1646 */ +#line 4567 "y.tab.c" /* yacc.c:1646 */ break; case 279: -#line 1850 "lev_comp.y" /* yacc.c:1646 */ +#line 1925 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_MINERALIZE); + add_opvars(splev, "o", VA_PASS1(SPO_MINERALIZE)); } -#line 4500 "y.tab.c" /* yacc.c:1646 */ +#line 4575 "y.tab.c" /* yacc.c:1646 */ break; case 280: -#line 1854 "lev_comp.y" /* yacc.c:1646 */ +#line 1929 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iiiio", -1L, -1L, -1L, -1L, SPO_MINERALIZE); + add_opvars(splev, "iiiio", + VA_PASS5(-1L, -1L, -1L, -1L, SPO_MINERALIZE)); } -#line 4508 "y.tab.c" /* yacc.c:1646 */ +#line 4584 "y.tab.c" /* yacc.c:1646 */ break; case 281: -#line 1860 "lev_comp.y" /* yacc.c:1646 */ +#line 1936 "lev_comp.y" /* yacc.c:1646 */ { int token = get_trap_type((yyvsp[0].map)); if (token == ERR) @@ -4516,11 +4592,11 @@ yyreduce: (yyval.i) = token; Free((yyvsp[0].map)); } -#line 4520 "y.tab.c" /* yacc.c:1646 */ +#line 4596 "y.tab.c" /* yacc.c:1646 */ break; case 283: -#line 1871 "lev_comp.y" /* yacc.c:1646 */ +#line 1947 "lev_comp.y" /* yacc.c:1646 */ { int token = get_room_type((yyvsp[0].map)); if (token == ERR) { @@ -4530,288 +4606,288 @@ yyreduce: (yyval.i) = token; Free((yyvsp[0].map)); } -#line 4534 "y.tab.c" /* yacc.c:1646 */ +#line 4610 "y.tab.c" /* yacc.c:1646 */ break; case 285: -#line 1884 "lev_comp.y" /* yacc.c:1646 */ +#line 1960 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = -1; } -#line 4542 "y.tab.c" /* yacc.c:1646 */ +#line 4618 "y.tab.c" /* yacc.c:1646 */ break; case 286: -#line 1888 "lev_comp.y" /* yacc.c:1646 */ +#line 1964 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 4550 "y.tab.c" /* yacc.c:1646 */ +#line 4626 "y.tab.c" /* yacc.c:1646 */ break; case 287: -#line 1894 "lev_comp.y" /* yacc.c:1646 */ +#line 1970 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 4558 "y.tab.c" /* yacc.c:1646 */ +#line 4634 "y.tab.c" /* yacc.c:1646 */ break; case 288: -#line 1898 "lev_comp.y" /* yacc.c:1646 */ +#line 1974 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[-2].i) | (yyvsp[0].i); } -#line 4566 "y.tab.c" /* yacc.c:1646 */ +#line 4642 "y.tab.c" /* yacc.c:1646 */ break; case 289: -#line 1905 "lev_comp.y" /* yacc.c:1646 */ +#line 1981 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = ((yyvsp[0].i) << 0); } -#line 4574 "y.tab.c" /* yacc.c:1646 */ +#line 4650 "y.tab.c" /* yacc.c:1646 */ break; case 290: -#line 1909 "lev_comp.y" /* yacc.c:1646 */ +#line 1985 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = ((yyvsp[0].i) << 1); } -#line 4582 "y.tab.c" /* yacc.c:1646 */ +#line 4658 "y.tab.c" /* yacc.c:1646 */ break; case 291: -#line 1913 "lev_comp.y" /* yacc.c:1646 */ +#line 1989 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = ((yyvsp[0].i) << 2); } -#line 4590 "y.tab.c" /* yacc.c:1646 */ +#line 4666 "y.tab.c" /* yacc.c:1646 */ break; case 298: -#line 1929 "lev_comp.y" /* yacc.c:1646 */ +#line 2005 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = - MAX_REGISTERS - 1; } -#line 4598 "y.tab.c" /* yacc.c:1646 */ +#line 4674 "y.tab.c" /* yacc.c:1646 */ break; case 301: -#line 1937 "lev_comp.y" /* yacc.c:1646 */ +#line 2013 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = - MAX_REGISTERS - 1; } -#line 4606 "y.tab.c" /* yacc.c:1646 */ +#line 4682 "y.tab.c" /* yacc.c:1646 */ break; case 304: -#line 1947 "lev_comp.y" /* yacc.c:1646 */ +#line 2023 "lev_comp.y" /* yacc.c:1646 */ { if ( (yyvsp[-1].i) >= 3 ) lc_error("Register Index overflow!"); else (yyval.i) = - (yyvsp[-1].i) - 1; } -#line 4617 "y.tab.c" /* yacc.c:1646 */ +#line 4693 "y.tab.c" /* yacc.c:1646 */ break; case 305: -#line 1956 "lev_comp.y" /* yacc.c:1646 */ +#line 2032 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "s", (yyvsp[0].map)); + add_opvars(splev, "s", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4626 "y.tab.c" /* yacc.c:1646 */ +#line 4702 "y.tab.c" /* yacc.c:1646 */ break; case 306: -#line 1961 "lev_comp.y" /* yacc.c:1646 */ +#line 2037 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_STRING); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4637 "y.tab.c" /* yacc.c:1646 */ +#line 4713 "y.tab.c" /* yacc.c:1646 */ break; case 307: -#line 1968 "lev_comp.y" /* yacc.c:1646 */ +#line 2044 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_STRING|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4648 "y.tab.c" /* yacc.c:1646 */ +#line 4724 "y.tab.c" /* yacc.c:1646 */ break; case 308: -#line 1978 "lev_comp.y" /* yacc.c:1646 */ +#line 2054 "lev_comp.y" /* yacc.c:1646 */ { /* nothing */ } -#line 4656 "y.tab.c" /* yacc.c:1646 */ +#line 4732 "y.tab.c" /* yacc.c:1646 */ break; case 309: -#line 1984 "lev_comp.y" /* yacc.c:1646 */ +#line 2060 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "c", (yyvsp[0].i)); + add_opvars(splev, "c", VA_PASS1((yyvsp[0].i))); } -#line 4664 "y.tab.c" /* yacc.c:1646 */ +#line 4740 "y.tab.c" /* yacc.c:1646 */ break; case 310: -#line 1988 "lev_comp.y" /* yacc.c:1646 */ +#line 2064 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_RNDCOORD); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_RNDCOORD)); } -#line 4672 "y.tab.c" /* yacc.c:1646 */ +#line 4748 "y.tab.c" /* yacc.c:1646 */ break; case 311: -#line 1992 "lev_comp.y" /* yacc.c:1646 */ +#line 2068 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_COORD); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4683 "y.tab.c" /* yacc.c:1646 */ +#line 4759 "y.tab.c" /* yacc.c:1646 */ break; case 312: -#line 1999 "lev_comp.y" /* yacc.c:1646 */ +#line 2075 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_COORD|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4694 "y.tab.c" /* yacc.c:1646 */ +#line 4770 "y.tab.c" /* yacc.c:1646 */ break; case 313: -#line 2008 "lev_comp.y" /* yacc.c:1646 */ +#line 2084 "lev_comp.y" /* yacc.c:1646 */ { if ((yyvsp[-3].i) < 0 || (yyvsp[-1].i) < 0 || (yyvsp[-3].i) >= COLNO || (yyvsp[-1].i) >= ROWNO) lc_error("Coordinates (%li,%li) out of map range!", (yyvsp[-3].i), (yyvsp[-1].i)); (yyval.i) = SP_COORD_PACK((yyvsp[-3].i), (yyvsp[-1].i)); } -#line 4704 "y.tab.c" /* yacc.c:1646 */ +#line 4780 "y.tab.c" /* yacc.c:1646 */ break; case 314: -#line 2014 "lev_comp.y" /* yacc.c:1646 */ +#line 2090 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = SP_COORD_PACK_RANDOM(0); } -#line 4712 "y.tab.c" /* yacc.c:1646 */ +#line 4788 "y.tab.c" /* yacc.c:1646 */ break; case 315: -#line 2018 "lev_comp.y" /* yacc.c:1646 */ +#line 2094 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = SP_COORD_PACK_RANDOM( (yyvsp[-1].i) ); } -#line 4720 "y.tab.c" /* yacc.c:1646 */ +#line 4796 "y.tab.c" /* yacc.c:1646 */ break; case 316: -#line 2024 "lev_comp.y" /* yacc.c:1646 */ +#line 2100 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (yyvsp[0].i); } -#line 4728 "y.tab.c" /* yacc.c:1646 */ +#line 4804 "y.tab.c" /* yacc.c:1646 */ break; case 317: -#line 2028 "lev_comp.y" /* yacc.c:1646 */ +#line 2104 "lev_comp.y" /* yacc.c:1646 */ { if (((yyvsp[-2].i) & (yyvsp[0].i))) lc_warning("Humidity flag used twice."); (yyval.i) = ((yyvsp[-2].i) | (yyvsp[0].i)); } -#line 4738 "y.tab.c" /* yacc.c:1646 */ +#line 4814 "y.tab.c" /* yacc.c:1646 */ break; case 318: -#line 2036 "lev_comp.y" /* yacc.c:1646 */ +#line 2112 "lev_comp.y" /* yacc.c:1646 */ { /* nothing */ } -#line 4746 "y.tab.c" /* yacc.c:1646 */ +#line 4822 "y.tab.c" /* yacc.c:1646 */ break; case 319: -#line 2040 "lev_comp.y" /* yacc.c:1646 */ +#line 2116 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_REGION); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4757 "y.tab.c" /* yacc.c:1646 */ +#line 4833 "y.tab.c" /* yacc.c:1646 */ break; case 320: -#line 2047 "lev_comp.y" /* yacc.c:1646 */ +#line 2123 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_REGION|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4768 "y.tab.c" /* yacc.c:1646 */ +#line 4844 "y.tab.c" /* yacc.c:1646 */ break; case 321: -#line 2056 "lev_comp.y" /* yacc.c:1646 */ +#line 2132 "lev_comp.y" /* yacc.c:1646 */ { long r = SP_REGION_PACK((yyvsp[-7].i), (yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].i)); if ( (yyvsp[-7].i) > (yyvsp[-3].i) || (yyvsp[-5].i) > (yyvsp[-1].i) ) lc_error("Region start > end: (%li,%li,%li,%li)!", (yyvsp[-7].i), (yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].i)); - add_opvars(splev, "r", r); + add_opvars(splev, "r", VA_PASS1(r)); (yyval.i) = r; } -#line 4781 "y.tab.c" /* yacc.c:1646 */ +#line 4857 "y.tab.c" /* yacc.c:1646 */ break; case 322: -#line 2067 "lev_comp.y" /* yacc.c:1646 */ +#line 2143 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "m", (yyvsp[0].i)); + add_opvars(splev, "m", VA_PASS1((yyvsp[0].i))); } -#line 4789 "y.tab.c" /* yacc.c:1646 */ +#line 4865 "y.tab.c" /* yacc.c:1646 */ break; case 323: -#line 2071 "lev_comp.y" /* yacc.c:1646 */ +#line 2147 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_MAPCHAR); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4800 "y.tab.c" /* yacc.c:1646 */ +#line 4876 "y.tab.c" /* yacc.c:1646 */ break; case 324: -#line 2078 "lev_comp.y" /* yacc.c:1646 */ +#line 2154 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_MAPCHAR|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4811 "y.tab.c" /* yacc.c:1646 */ +#line 4887 "y.tab.c" /* yacc.c:1646 */ break; case 325: -#line 2087 "lev_comp.y" /* yacc.c:1646 */ +#line 2163 "lev_comp.y" /* yacc.c:1646 */ { if (what_map_char((char) (yyvsp[0].i)) != INVALID_TYPE) (yyval.i) = SP_MAPCHAR_PACK(what_map_char((char) (yyvsp[0].i)), -2); @@ -4820,11 +4896,11 @@ yyreduce: (yyval.i) = SP_MAPCHAR_PACK(STONE, -2); } } -#line 4824 "y.tab.c" /* yacc.c:1646 */ +#line 4900 "y.tab.c" /* yacc.c:1646 */ break; case 326: -#line 2096 "lev_comp.y" /* yacc.c:1646 */ +#line 2172 "lev_comp.y" /* yacc.c:1646 */ { if (what_map_char((char) (yyvsp[-3].i)) != INVALID_TYPE) (yyval.i) = SP_MAPCHAR_PACK(what_map_char((char) (yyvsp[-3].i)), (yyvsp[-1].i)); @@ -4833,41 +4909,41 @@ yyreduce: (yyval.i) = SP_MAPCHAR_PACK(STONE, (yyvsp[-1].i)); } } -#line 4837 "y.tab.c" /* yacc.c:1646 */ +#line 4913 "y.tab.c" /* yacc.c:1646 */ break; case 327: -#line 2107 "lev_comp.y" /* yacc.c:1646 */ +#line 2183 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "M", (yyvsp[0].i)); + add_opvars(splev, "M", VA_PASS1((yyvsp[0].i))); } -#line 4845 "y.tab.c" /* yacc.c:1646 */ +#line 4921 "y.tab.c" /* yacc.c:1646 */ break; case 328: -#line 2111 "lev_comp.y" /* yacc.c:1646 */ +#line 2187 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_MONST); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4856 "y.tab.c" /* yacc.c:1646 */ +#line 4932 "y.tab.c" /* yacc.c:1646 */ break; case 329: -#line 2118 "lev_comp.y" /* yacc.c:1646 */ +#line 2194 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_MONST|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4867 "y.tab.c" /* yacc.c:1646 */ +#line 4943 "y.tab.c" /* yacc.c:1646 */ break; case 330: -#line 2127 "lev_comp.y" /* yacc.c:1646 */ +#line 2203 "lev_comp.y" /* yacc.c:1646 */ { long m = get_monster_id((yyvsp[0].map), (char)0); if (m == ERR) { @@ -4876,11 +4952,11 @@ yyreduce: } else (yyval.i) = SP_MONST_PACK(m, def_monsyms[(int)mons[m].mlet].sym); } -#line 4880 "y.tab.c" /* yacc.c:1646 */ +#line 4956 "y.tab.c" /* yacc.c:1646 */ break; case 331: -#line 2136 "lev_comp.y" /* yacc.c:1646 */ +#line 2212 "lev_comp.y" /* yacc.c:1646 */ { if (check_monster_char((char) (yyvsp[0].i))) (yyval.i) = SP_MONST_PACK(-1, (yyvsp[0].i)); @@ -4889,11 +4965,11 @@ yyreduce: (yyval.i) = -1; } } -#line 4893 "y.tab.c" /* yacc.c:1646 */ +#line 4969 "y.tab.c" /* yacc.c:1646 */ break; case 332: -#line 2145 "lev_comp.y" /* yacc.c:1646 */ +#line 2221 "lev_comp.y" /* yacc.c:1646 */ { long m = get_monster_id((yyvsp[-1].map), (char) (yyvsp[-3].i)); if (m == ERR) { @@ -4902,49 +4978,49 @@ yyreduce: } else (yyval.i) = SP_MONST_PACK(m, (yyvsp[-3].i)); } -#line 4906 "y.tab.c" /* yacc.c:1646 */ +#line 4982 "y.tab.c" /* yacc.c:1646 */ break; case 333: -#line 2154 "lev_comp.y" /* yacc.c:1646 */ +#line 2230 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = -1; } -#line 4914 "y.tab.c" /* yacc.c:1646 */ +#line 4990 "y.tab.c" /* yacc.c:1646 */ break; case 334: -#line 2160 "lev_comp.y" /* yacc.c:1646 */ +#line 2236 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "O", (yyvsp[0].i)); + add_opvars(splev, "O", VA_PASS1((yyvsp[0].i))); } -#line 4922 "y.tab.c" /* yacc.c:1646 */ +#line 4998 "y.tab.c" /* yacc.c:1646 */ break; case 335: -#line 2164 "lev_comp.y" /* yacc.c:1646 */ +#line 2240 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_OBJ); vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); Free((yyvsp[0].map)); } -#line 4933 "y.tab.c" /* yacc.c:1646 */ +#line 5009 "y.tab.c" /* yacc.c:1646 */ break; case 336: -#line 2171 "lev_comp.y" /* yacc.c:1646 */ +#line 2247 "lev_comp.y" /* yacc.c:1646 */ { check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_OBJ|SPOVAR_ARRAY); vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); Free((yyvsp[-3].map)); } -#line 4944 "y.tab.c" /* yacc.c:1646 */ +#line 5020 "y.tab.c" /* yacc.c:1646 */ break; case 337: -#line 2180 "lev_comp.y" /* yacc.c:1646 */ +#line 2256 "lev_comp.y" /* yacc.c:1646 */ { long m = get_object_id((yyvsp[0].map), (char)0); if (m == ERR) { @@ -4954,11 +5030,11 @@ yyreduce: (yyval.i) = SP_OBJ_PACK(m, 1); /* obj class != 0 to force generation of a specific item */ } -#line 4958 "y.tab.c" /* yacc.c:1646 */ +#line 5034 "y.tab.c" /* yacc.c:1646 */ break; case 338: -#line 2190 "lev_comp.y" /* yacc.c:1646 */ +#line 2266 "lev_comp.y" /* yacc.c:1646 */ { if (check_object_char((char) (yyvsp[0].i))) (yyval.i) = SP_OBJ_PACK(-1, (yyvsp[0].i)); @@ -4967,11 +5043,11 @@ yyreduce: (yyval.i) = -1; } } -#line 4971 "y.tab.c" /* yacc.c:1646 */ +#line 5047 "y.tab.c" /* yacc.c:1646 */ break; case 339: -#line 2199 "lev_comp.y" /* yacc.c:1646 */ +#line 2275 "lev_comp.y" /* yacc.c:1646 */ { long m = get_object_id((yyvsp[-1].map), (char) (yyvsp[-3].i)); if (m == ERR) { @@ -4980,188 +5056,207 @@ yyreduce: } else (yyval.i) = SP_OBJ_PACK(m, (yyvsp[-3].i)); } -#line 4984 "y.tab.c" /* yacc.c:1646 */ - break; - - case 340: -#line 2208 "lev_comp.y" /* yacc.c:1646 */ - { - (yyval.i) = -1; - } -#line 4992 "y.tab.c" /* yacc.c:1646 */ - break; - - case 341: -#line 2214 "lev_comp.y" /* yacc.c:1646 */ - { } -#line 4998 "y.tab.c" /* yacc.c:1646 */ - break; - - case 342: -#line 2216 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "o", SPO_MATH_ADD); - } -#line 5006 "y.tab.c" /* yacc.c:1646 */ - break; - - case 343: -#line 2221 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "i", (yyvsp[0].i) ); } -#line 5012 "y.tab.c" /* yacc.c:1646 */ - break; - - case 344: -#line 2222 "lev_comp.y" /* yacc.c:1646 */ - { is_inconstant_number = 1; } -#line 5018 "y.tab.c" /* yacc.c:1646 */ - break; - - case 345: -#line 2223 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "i", (yyvsp[-1].i) ); } -#line 5024 "y.tab.c" /* yacc.c:1646 */ - break; - - case 346: -#line 2225 "lev_comp.y" /* yacc.c:1646 */ - { - check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_INT); - vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); - Free((yyvsp[0].map)); - is_inconstant_number = 1; - } -#line 5036 "y.tab.c" /* yacc.c:1646 */ - break; - - case 347: -#line 2233 "lev_comp.y" /* yacc.c:1646 */ - { - check_vardef_type(variable_definitions, (yyvsp[-3].map), SPOVAR_INT|SPOVAR_ARRAY); - vardef_used(variable_definitions, (yyvsp[-3].map)); - add_opvars(splev, "v", (yyvsp[-3].map)); - Free((yyvsp[-3].map)); - is_inconstant_number = 1; - } -#line 5048 "y.tab.c" /* yacc.c:1646 */ - break; - - case 348: -#line 2240 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "o", SPO_MATH_ADD); } -#line 5054 "y.tab.c" /* yacc.c:1646 */ - break; - - case 349: -#line 2241 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "o", SPO_MATH_SUB); } #line 5060 "y.tab.c" /* yacc.c:1646 */ break; + case 340: +#line 2284 "lev_comp.y" /* yacc.c:1646 */ + { + (yyval.i) = -1; + } +#line 5068 "y.tab.c" /* yacc.c:1646 */ + break; + + case 341: +#line 2290 "lev_comp.y" /* yacc.c:1646 */ + { } +#line 5074 "y.tab.c" /* yacc.c:1646 */ + break; + + case 342: +#line 2292 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_ADD)); + } +#line 5082 "y.tab.c" /* yacc.c:1646 */ + break; + + case 343: +#line 2298 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1((yyvsp[0].i))); + } +#line 5090 "y.tab.c" /* yacc.c:1646 */ + break; + + case 344: +#line 2302 "lev_comp.y" /* yacc.c:1646 */ + { + is_inconstant_number = 1; + } +#line 5098 "y.tab.c" /* yacc.c:1646 */ + break; + + case 345: +#line 2306 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1((yyvsp[-1].i))); + } +#line 5106 "y.tab.c" /* yacc.c:1646 */ + break; + + case 346: +#line 2310 "lev_comp.y" /* yacc.c:1646 */ + { + check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_INT); + vardef_used(variable_definitions, (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); + Free((yyvsp[0].map)); + is_inconstant_number = 1; + } +#line 5118 "y.tab.c" /* yacc.c:1646 */ + break; + + case 347: +#line 2318 "lev_comp.y" /* yacc.c:1646 */ + { + check_vardef_type(variable_definitions, + (yyvsp[-3].map), SPOVAR_INT|SPOVAR_ARRAY); + vardef_used(variable_definitions, (yyvsp[-3].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[-3].map))); + Free((yyvsp[-3].map)); + is_inconstant_number = 1; + } +#line 5131 "y.tab.c" /* yacc.c:1646 */ + break; + + case 348: +#line 2327 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_ADD)); + } +#line 5139 "y.tab.c" /* yacc.c:1646 */ + break; + + case 349: +#line 2331 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_SUB)); + } +#line 5147 "y.tab.c" /* yacc.c:1646 */ + break; + case 350: -#line 2242 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "o", SPO_MATH_MUL); } -#line 5066 "y.tab.c" /* yacc.c:1646 */ +#line 2335 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_MUL)); + } +#line 5155 "y.tab.c" /* yacc.c:1646 */ break; case 351: -#line 2243 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "o", SPO_MATH_DIV); } -#line 5072 "y.tab.c" /* yacc.c:1646 */ +#line 2339 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_DIV)); + } +#line 5163 "y.tab.c" /* yacc.c:1646 */ break; case 352: -#line 2244 "lev_comp.y" /* yacc.c:1646 */ - { add_opvars(splev, "o", SPO_MATH_MOD); } -#line 5078 "y.tab.c" /* yacc.c:1646 */ +#line 2343 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_MATH_MOD)); + } +#line 5171 "y.tab.c" /* yacc.c:1646 */ break; case 353: -#line 2245 "lev_comp.y" /* yacc.c:1646 */ +#line 2346 "lev_comp.y" /* yacc.c:1646 */ { } -#line 5084 "y.tab.c" /* yacc.c:1646 */ +#line 5177 "y.tab.c" /* yacc.c:1646 */ break; case 354: -#line 2249 "lev_comp.y" /* yacc.c:1646 */ +#line 2350 "lev_comp.y" /* yacc.c:1646 */ { - if (!strcmp("int", (yyvsp[0].map)) || !strcmp("integer", (yyvsp[0].map))) { - (yyval.i) = (int)'i'; - } else lc_error("Unknown function parameter type '%s'", (yyvsp[0].map)); - } -#line 5094 "y.tab.c" /* yacc.c:1646 */ + if (!strcmp("int", (yyvsp[0].map)) || !strcmp("integer", (yyvsp[0].map))) { + (yyval.i) = (int)'i'; + } else + lc_error("Unknown function parameter type '%s'", (yyvsp[0].map)); + } +#line 5188 "y.tab.c" /* yacc.c:1646 */ break; case 355: -#line 2255 "lev_comp.y" /* yacc.c:1646 */ +#line 2357 "lev_comp.y" /* yacc.c:1646 */ { - if (!strcmp("str", (yyvsp[0].map)) || !strcmp("string", (yyvsp[0].map))) { - (yyval.i) = (int)'s'; - } else lc_error("Unknown function parameter type '%s'", (yyvsp[0].map)); - } -#line 5104 "y.tab.c" /* yacc.c:1646 */ + if (!strcmp("str", (yyvsp[0].map)) || !strcmp("string", (yyvsp[0].map))) { + (yyval.i) = (int)'s'; + } else + lc_error("Unknown function parameter type '%s'", (yyvsp[0].map)); + } +#line 5199 "y.tab.c" /* yacc.c:1646 */ break; case 356: -#line 2263 "lev_comp.y" /* yacc.c:1646 */ +#line 2366 "lev_comp.y" /* yacc.c:1646 */ { - struct lc_funcdefs_parm *tmp = New(struct lc_funcdefs_parm); + struct lc_funcdefs_parm *tmp = New(struct lc_funcdefs_parm); - if (!curr_function) - lc_error("Function parameters outside function definition."); - else if (!tmp) - lc_error("Could not alloc function params."); - else { - tmp->name = strdup((yyvsp[-2].map)); - tmp->parmtype = (char) (yyvsp[0].i); - tmp->next = curr_function->params; - curr_function->params = tmp; - curr_function->n_params++; - { - long vt; - switch (tmp->parmtype) { - case 'i': vt = SPOVAR_INT; break; - case 's': vt = SPOVAR_STRING; break; - default: lc_error("Unknown func param conversion."); break; - } - variable_definitions = add_vardef_type(variable_definitions, (yyvsp[-2].map), vt); - } - } - Free((yyvsp[-2].map)); + if (!curr_function) { + lc_error("Function parameters outside function definition."); + } else if (!tmp) { + lc_error("Could not alloc function params."); + } else { + long vt; + tmp->name = strdup((yyvsp[-2].map)); + tmp->parmtype = (char) (yyvsp[0].i); + tmp->next = curr_function->params; + curr_function->params = tmp; + curr_function->n_params++; + switch (tmp->parmtype) { + case 'i': vt = SPOVAR_INT; break; + case 's': vt = SPOVAR_STRING; break; + default: lc_error("Unknown func param conversion."); break; } -#line 5134 "y.tab.c" /* yacc.c:1646 */ + variable_definitions = add_vardef_type( + variable_definitions, + (yyvsp[-2].map), vt); + } + Free((yyvsp[-2].map)); + } +#line 5229 "y.tab.c" /* yacc.c:1646 */ break; case 361: -#line 2300 "lev_comp.y" /* yacc.c:1646 */ +#line 2402 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (int)'i'; } -#line 5142 "y.tab.c" /* yacc.c:1646 */ +#line 5237 "y.tab.c" /* yacc.c:1646 */ break; case 362: -#line 2304 "lev_comp.y" /* yacc.c:1646 */ +#line 2406 "lev_comp.y" /* yacc.c:1646 */ { (yyval.i) = (int)'s'; } -#line 5150 "y.tab.c" /* yacc.c:1646 */ +#line 5245 "y.tab.c" /* yacc.c:1646 */ break; case 363: -#line 2311 "lev_comp.y" /* yacc.c:1646 */ +#line 2413 "lev_comp.y" /* yacc.c:1646 */ { char tmpbuf[2]; tmpbuf[0] = (char) (yyvsp[0].i); tmpbuf[1] = '\0'; (yyval.map) = strdup(tmpbuf); } -#line 5161 "y.tab.c" /* yacc.c:1646 */ +#line 5256 "y.tab.c" /* yacc.c:1646 */ break; case 364: -#line 2318 "lev_comp.y" /* yacc.c:1646 */ +#line 2420 "lev_comp.y" /* yacc.c:1646 */ { long len = strlen( (yyvsp[-2].map) ); char *tmp = (char *)alloc(len + 2); @@ -5169,249 +5264,256 @@ yyreduce: Free( (yyvsp[-2].map) ); (yyval.map) = tmp; } -#line 5173 "y.tab.c" /* yacc.c:1646 */ +#line 5268 "y.tab.c" /* yacc.c:1646 */ break; case 365: -#line 2328 "lev_comp.y" /* yacc.c:1646 */ +#line 2430 "lev_comp.y" /* yacc.c:1646 */ { (yyval.map) = strdup(""); } -#line 5181 "y.tab.c" /* yacc.c:1646 */ +#line 5276 "y.tab.c" /* yacc.c:1646 */ break; case 366: -#line 2332 "lev_comp.y" /* yacc.c:1646 */ +#line 2434 "lev_comp.y" /* yacc.c:1646 */ { char *tmp = strdup( (yyvsp[0].map) ); Free( (yyvsp[0].map) ); (yyval.map) = tmp; } -#line 5191 "y.tab.c" /* yacc.c:1646 */ +#line 5286 "y.tab.c" /* yacc.c:1646 */ break; case 367: -#line 2340 "lev_comp.y" /* yacc.c:1646 */ +#line 2442 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_POINT); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_POINT)); } -#line 5199 "y.tab.c" /* yacc.c:1646 */ +#line 5294 "y.tab.c" /* yacc.c:1646 */ break; case 368: -#line 2344 "lev_comp.y" /* yacc.c:1646 */ +#line 2446 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_RECT); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_RECT)); } -#line 5207 "y.tab.c" /* yacc.c:1646 */ +#line 5302 "y.tab.c" /* yacc.c:1646 */ break; case 369: -#line 2348 "lev_comp.y" /* yacc.c:1646 */ +#line 2450 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_FILLRECT); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_FILLRECT)); } -#line 5215 "y.tab.c" /* yacc.c:1646 */ +#line 5310 "y.tab.c" /* yacc.c:1646 */ break; case 370: -#line 2352 "lev_comp.y" /* yacc.c:1646 */ +#line 2454 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_LINE); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_LINE)); } -#line 5223 "y.tab.c" /* yacc.c:1646 */ +#line 5318 "y.tab.c" /* yacc.c:1646 */ break; case 371: -#line 2356 "lev_comp.y" /* yacc.c:1646 */ +#line 2458 "lev_comp.y" /* yacc.c:1646 */ { /* randline (x1,y1),(x2,y2), roughness */ - add_opvars(splev, "o", SPO_SEL_RNDLINE); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_RNDLINE)); } -#line 5232 "y.tab.c" /* yacc.c:1646 */ +#line 5327 "y.tab.c" /* yacc.c:1646 */ break; case 372: -#line 2361 "lev_comp.y" /* yacc.c:1646 */ +#line 2463 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", W_ANY, SPO_SEL_GROW); + add_opvars(splev, "io", VA_PASS2(W_ANY, SPO_SEL_GROW)); } -#line 5240 "y.tab.c" /* yacc.c:1646 */ +#line 5335 "y.tab.c" /* yacc.c:1646 */ break; case 373: -#line 2365 "lev_comp.y" /* yacc.c:1646 */ +#line 2467 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", (yyvsp[-3].i), SPO_SEL_GROW); + add_opvars(splev, "io", VA_PASS2((yyvsp[-3].i), SPO_SEL_GROW)); } -#line 5248 "y.tab.c" /* yacc.c:1646 */ +#line 5343 "y.tab.c" /* yacc.c:1646 */ break; case 374: -#line 2369 "lev_comp.y" /* yacc.c:1646 */ +#line 2471 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "iio", (yyvsp[-3].i), SPOFILTER_PERCENT, SPO_SEL_FILTER); + add_opvars(splev, "iio", + VA_PASS3((yyvsp[-3].i), SPOFILTER_PERCENT, SPO_SEL_FILTER)); } -#line 5256 "y.tab.c" /* yacc.c:1646 */ +#line 5352 "y.tab.c" /* yacc.c:1646 */ break; case 375: -#line 2373 "lev_comp.y" /* yacc.c:1646 */ +#line 2476 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", SPOFILTER_SELECTION, SPO_SEL_FILTER); + add_opvars(splev, "io", + VA_PASS2(SPOFILTER_SELECTION, SPO_SEL_FILTER)); } -#line 5264 "y.tab.c" /* yacc.c:1646 */ +#line 5361 "y.tab.c" /* yacc.c:1646 */ break; case 376: -#line 2377 "lev_comp.y" /* yacc.c:1646 */ +#line 2481 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "io", SPOFILTER_MAPCHAR, SPO_SEL_FILTER); + add_opvars(splev, "io", + VA_PASS2(SPOFILTER_MAPCHAR, SPO_SEL_FILTER)); } -#line 5272 "y.tab.c" /* yacc.c:1646 */ +#line 5370 "y.tab.c" /* yacc.c:1646 */ break; case 377: -#line 2381 "lev_comp.y" /* yacc.c:1646 */ +#line 2486 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "o", SPO_SEL_FLOOD); + add_opvars(splev, "o", VA_PASS1(SPO_SEL_FLOOD)); } -#line 5280 "y.tab.c" /* yacc.c:1646 */ +#line 5378 "y.tab.c" /* yacc.c:1646 */ break; case 378: -#line 2385 "lev_comp.y" /* yacc.c:1646 */ +#line 2490 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "oio", SPO_COPY, 1, SPO_SEL_ELLIPSE); - } -#line 5288 "y.tab.c" /* yacc.c:1646 */ - break; - - case 379: -#line 2389 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "oio", SPO_COPY, (yyvsp[-1].i), SPO_SEL_ELLIPSE); - } -#line 5296 "y.tab.c" /* yacc.c:1646 */ - break; - - case 380: -#line 2393 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "io", 1, SPO_SEL_ELLIPSE); - } -#line 5304 "y.tab.c" /* yacc.c:1646 */ - break; - - case 381: -#line 2397 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "io", (yyvsp[-1].i), SPO_SEL_ELLIPSE); - } -#line 5312 "y.tab.c" /* yacc.c:1646 */ - break; - - case 382: -#line 2401 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "iio", (yyvsp[-5].i), (yyvsp[-11].i), SPO_SEL_GRADIENT); - } -#line 5320 "y.tab.c" /* yacc.c:1646 */ - break; - - case 383: -#line 2405 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "o", SPO_SEL_COMPLEMENT); - } -#line 5328 "y.tab.c" /* yacc.c:1646 */ - break; - - case 384: -#line 2409 "lev_comp.y" /* yacc.c:1646 */ - { - check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_SEL); - vardef_used(variable_definitions, (yyvsp[0].map)); - add_opvars(splev, "v", (yyvsp[0].map)); - Free((yyvsp[0].map)); - } -#line 5339 "y.tab.c" /* yacc.c:1646 */ - break; - - case 385: -#line 2416 "lev_comp.y" /* yacc.c:1646 */ - { - /* nothing */ - } -#line 5347 "y.tab.c" /* yacc.c:1646 */ - break; - - case 386: -#line 2422 "lev_comp.y" /* yacc.c:1646 */ - { - /* nothing */ - } -#line 5355 "y.tab.c" /* yacc.c:1646 */ - break; - - case 387: -#line 2426 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "o", SPO_SEL_ADD); - } -#line 5363 "y.tab.c" /* yacc.c:1646 */ - break; - - case 388: -#line 2432 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "iio", (yyvsp[0].dice).num, (yyvsp[0].dice).die, SPO_DICE); - } -#line 5371 "y.tab.c" /* yacc.c:1646 */ - break; - - case 392: -#line 2443 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", (yyvsp[0].i) ); - } -#line 5379 "y.tab.c" /* yacc.c:1646 */ - break; - - case 393: -#line 2447 "lev_comp.y" /* yacc.c:1646 */ - { - add_opvars(splev, "i", (yyvsp[0].i) ); + add_opvars(splev, "oio", + VA_PASS3(SPO_COPY, 1, SPO_SEL_ELLIPSE)); } #line 5387 "y.tab.c" /* yacc.c:1646 */ break; - case 394: -#line 2451 "lev_comp.y" /* yacc.c:1646 */ + case 379: +#line 2495 "lev_comp.y" /* yacc.c:1646 */ { - add_opvars(splev, "i", (yyvsp[0].i) ); + add_opvars(splev, "oio", + VA_PASS3(SPO_COPY, (yyvsp[-1].i), SPO_SEL_ELLIPSE)); } -#line 5395 "y.tab.c" /* yacc.c:1646 */ +#line 5396 "y.tab.c" /* yacc.c:1646 */ break; - case 395: -#line 2455 "lev_comp.y" /* yacc.c:1646 */ + case 380: +#line 2500 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "io", VA_PASS2(1, SPO_SEL_ELLIPSE)); + } +#line 5404 "y.tab.c" /* yacc.c:1646 */ + break; + + case 381: +#line 2504 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "io", VA_PASS2((yyvsp[-1].i), SPO_SEL_ELLIPSE)); + } +#line 5412 "y.tab.c" /* yacc.c:1646 */ + break; + + case 382: +#line 2508 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "iio", + VA_PASS3((yyvsp[-5].i), (yyvsp[-11].i), SPO_SEL_GRADIENT)); + } +#line 5421 "y.tab.c" /* yacc.c:1646 */ + break; + + case 383: +#line 2513 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_SEL_COMPLEMENT)); + } +#line 5429 "y.tab.c" /* yacc.c:1646 */ + break; + + case 384: +#line 2517 "lev_comp.y" /* yacc.c:1646 */ + { + check_vardef_type(variable_definitions, (yyvsp[0].map), SPOVAR_SEL); + vardef_used(variable_definitions, (yyvsp[0].map)); + add_opvars(splev, "v", VA_PASS1((yyvsp[0].map))); + Free((yyvsp[0].map)); + } +#line 5440 "y.tab.c" /* yacc.c:1646 */ + break; + + case 385: +#line 2524 "lev_comp.y" /* yacc.c:1646 */ { /* nothing */ } -#line 5403 "y.tab.c" /* yacc.c:1646 */ +#line 5448 "y.tab.c" /* yacc.c:1646 */ + break; + + case 386: +#line 2530 "lev_comp.y" /* yacc.c:1646 */ + { + /* nothing */ + } +#line 5456 "y.tab.c" /* yacc.c:1646 */ + break; + + case 387: +#line 2534 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "o", VA_PASS1(SPO_SEL_ADD)); + } +#line 5464 "y.tab.c" /* yacc.c:1646 */ + break; + + case 388: +#line 2540 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "iio", + VA_PASS3((yyvsp[0].dice).num, (yyvsp[0].dice).die, SPO_DICE)); + } +#line 5473 "y.tab.c" /* yacc.c:1646 */ + break; + + case 392: +#line 2552 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1((yyvsp[0].i))); + } +#line 5481 "y.tab.c" /* yacc.c:1646 */ + break; + + case 393: +#line 2556 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1((yyvsp[0].i))); + } +#line 5489 "y.tab.c" /* yacc.c:1646 */ + break; + + case 394: +#line 2560 "lev_comp.y" /* yacc.c:1646 */ + { + add_opvars(splev, "i", VA_PASS1((yyvsp[0].i))); + } +#line 5497 "y.tab.c" /* yacc.c:1646 */ + break; + + case 395: +#line 2564 "lev_comp.y" /* yacc.c:1646 */ + { + /* nothing */ + } +#line 5505 "y.tab.c" /* yacc.c:1646 */ break; case 404: -#line 2477 "lev_comp.y" /* yacc.c:1646 */ +#line 2586 "lev_comp.y" /* yacc.c:1646 */ { (yyval.lregn) = (yyvsp[0].lregn); } -#line 5411 "y.tab.c" /* yacc.c:1646 */ +#line 5513 "y.tab.c" /* yacc.c:1646 */ break; case 405: -#line 2481 "lev_comp.y" /* yacc.c:1646 */ +#line 2590 "lev_comp.y" /* yacc.c:1646 */ { if ((yyvsp[-7].i) <= 0 || (yyvsp[-7].i) >= COLNO) lc_error("Region (%li,%li,%li,%li) out of level range (x1)!", (yyvsp[-7].i), (yyvsp[-5].i), (yyvsp[-3].i), (yyvsp[-1].i)); @@ -5427,11 +5529,11 @@ yyreduce: (yyval.lregn).y2 = (yyvsp[-1].i); (yyval.lregn).area = 1; } -#line 5431 "y.tab.c" /* yacc.c:1646 */ +#line 5533 "y.tab.c" /* yacc.c:1646 */ break; case 406: -#line 2499 "lev_comp.y" /* yacc.c:1646 */ +#line 2608 "lev_comp.y" /* yacc.c:1646 */ { /* This series of if statements is a hack for MSC 5.1. It seems that its tiny little brain cannot compile if these are all one big if statement. */ @@ -5449,11 +5551,11 @@ yyreduce: (yyval.lregn).x2 = (yyvsp[-3].i); (yyval.lregn).y2 = (yyvsp[-1].i); } -#line 5453 "y.tab.c" /* yacc.c:1646 */ +#line 5555 "y.tab.c" /* yacc.c:1646 */ break; -#line 5457 "y.tab.c" /* yacc.c:1646 */ +#line 5559 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -5681,7 +5783,7 @@ yyreturn: #endif return yyresult; } -#line 2519 "lev_comp.y" /* yacc.c:1906 */ +#line 2628 "lev_comp.y" /* yacc.c:1906 */ /*lev_comp.y*/ diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index e9b3aade0..412b6f9eb 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 pcmain.c $NHDT-Date: 1426966701 2015/03/21 19:38:21 $ $NHDT-Branch: master $:$NHDT-Revision: 1.51 $ */ +/* NetHack 3.5 pcmain.c $NHDT-Date: 1427337317 2015/03/26 02:35:17 $ $NHDT-Branch: derek-farming $:$NHDT-Revision: 1.52 $ */ /* NetHack 3.5 pcmain.c $Date: 2012/01/20 03:41:31 $ $Revision: 1.48 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -106,244 +106,271 @@ int argc; char *argv[]; { - register int fd; - register char *dir; + register int fd; + register char *dir; #if defined(WIN32) - char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ]; - boolean save_getreturn_status = getreturn_enabled; + char* envp = NULL; + char* sptr = NULL; + char fnamebuf[BUFSZ], encodedfnamebuf[BUFSZ]; + boolean save_getreturn_status = getreturn_enabled; #endif #ifdef NOCWD_ASSUMPTIONS - char failbuf[BUFSZ]; + char failbuf[BUFSZ]; #endif - boolean resuming = FALSE; /* assume new game */ + boolean resuming = FALSE; /* assume new game */ #if defined(__BORLANDC__) && !defined(_WIN32) - startup(); + startup(); #endif #ifdef TOS - long clock_time; - if (*argv[0]) { /* only a CLI can give us argv[0] */ - hname = argv[0]; - run_from_desktop = FALSE; - } else + long clock_time; + if (*argv[0]) { /* only a CLI can give us argv[0] */ + hname = argv[0]; + run_from_desktop = FALSE; + } else #endif - hname = "NetHack"; /* used for syntax messages */ + hname = "NetHack"; /* used for syntax messages */ - choose_windows(DEFAULT_WINDOW_SYS); + choose_windows(DEFAULT_WINDOW_SYS); #if !defined(AMIGA) && !defined(GNUDOS) - /* Save current directory and make sure it gets restored when - * the game is exited. - */ - if (getcwd(orgdir, sizeof orgdir) == (char *)0) - error("NetHack: current directory path too long"); + /* Save current directory and make sure it gets restored when + * the game is exited. + */ + if (getcwd(orgdir, sizeof orgdir) == (char *)0) + error("NetHack: current directory path too long"); # ifndef NO_SIGNAL - signal(SIGINT, (SIG_RET_TYPE) nethack_exit); /* restore original directory */ + signal(SIGINT, (SIG_RET_TYPE) nethack_exit); /* restore original directory */ # endif #endif /* !AMIGA && !GNUDOS */ - dir = nh_getenv("NETHACKDIR"); - if (dir == (char *)0) - dir = nh_getenv("HACKDIR"); + dir = nh_getenv("NETHACKDIR"); + if (dir == (char *)0) + dir = nh_getenv("HACKDIR"); #ifdef EXEPATH - if (dir == (char *)0) - dir = exepath(argv[0]); + if (dir == (char *)0) + dir = exepath(argv[0]); #endif - if (dir != (char *)0) { - (void) strncpy(hackdir, dir, PATHLEN - 1); - hackdir[PATHLEN-1] = '\0'; + if (dir != (char *)0) { + (void) strncpy(hackdir, dir, PATHLEN - 1); + hackdir[PATHLEN-1] = '\0'; #ifdef NOCWD_ASSUMPTIONS - { - int prefcnt; + { + int prefcnt; - fqn_prefix[0] = (char *)alloc(strlen(hackdir)+2); - Strcpy(fqn_prefix[0], hackdir); - append_slash(fqn_prefix[0]); - for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) - fqn_prefix[prefcnt] = fqn_prefix[0]; - } + fqn_prefix[0] = (char *)alloc(strlen(hackdir)+2); + Strcpy(fqn_prefix[0], hackdir); + append_slash(fqn_prefix[0]); + for (prefcnt = 1; prefcnt < PREFIX_COUNT; prefcnt++) + fqn_prefix[prefcnt] = fqn_prefix[0]; + +# if defined(WIN32) || defined(MSDOS) + /* sysconf should be searched for in this location */ + envp = nh_getenv("COMMONPROGRAMFILES"); + if (envp) { + if ((sptr = index(envp, ';')) != 0) *sptr = '\0'; + if (strlen(envp) > 0) { + fqn_prefix[SYSCONFPREFIX] = (char *)alloc(strlen(envp) + 10); + Strcpy(fqn_prefix[SYSCONFPREFIX], envp); + append_slash(fqn_prefix[SYSCONFPREFIX]); + Strcat(fqn_prefix[SYSCONFPREFIX], "NetHack\\"); + } + } + + /* user's home directory should default to this - unless overridden */ + envp = nh_getenv("USERPROFILE"); + if (envp) { + if ((sptr = index(envp, ';')) != 0) *sptr = '\0'; + if (strlen(envp) > 0) { + fqn_prefix[CONFIGPREFIX] = (char *)alloc(strlen(envp)+2); + Strcpy(fqn_prefix[CONFIGPREFIX], envp); + append_slash(fqn_prefix[CONFIGPREFIX]); + } + } +# endif + } #endif #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdirx (dir, 1); + chdirx (dir, 1); #endif - } + } #ifdef AMIGA # ifdef CHDIR - /* - * If we're dealing with workbench, change the directory. Otherwise - * we could get "Insert disk in drive 0" messages. (Must be done - * before initoptions()).... - */ - if(argc == 0) - chdirx(HACKDIR, 1); + /* + * If we're dealing with workbench, change the directory. Otherwise + * we could get "Insert disk in drive 0" messages. (Must be done + * before initoptions()).... + */ + if(argc == 0) + chdirx(HACKDIR, 1); # endif - ami_wininit_data(); + ami_wininit_data(); #endif #ifdef WIN32CON - save_getreturn_status = getreturn_enabled; - raw_clear_screen(); - getreturn_enabled = TRUE; + save_getreturn_status = getreturn_enabled; + raw_clear_screen(); + getreturn_enabled = TRUE; #endif - initoptions(); + initoptions(); #ifdef NOCWD_ASSUMPTIONS - if (!validate_prefix_locations(failbuf)) { - raw_printf("Some invalid directory locations were specified:\n\t%s\n", - failbuf); - nethack_exit(EXIT_FAILURE); - } + if (!validate_prefix_locations(failbuf)) { + raw_printf("Some invalid directory locations were specified:\n\t%s\n", + failbuf); + nethack_exit(EXIT_FAILURE); + } #endif #if defined(TOS) && defined(TEXTCOLOR) - if (iflags.BIOS && iflags.use_color) - set_colors(); + if (iflags.BIOS && iflags.use_color) + set_colors(); #endif - if (!hackdir[0]) + if (!hackdir[0]) #if !defined(LATTICE) && !defined(AMIGA) - Strcpy(hackdir, orgdir); + Strcpy(hackdir, orgdir); #else - Strcpy(hackdir, HACKDIR); + Strcpy(hackdir, HACKDIR); #endif - if(argc > 1) { - if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') { - /* avoid matching "-dec" for DECgraphics; since the man page - * says -d directory, hope nobody's using -desomething_else - */ - argc--; - argv++; - dir = argv[0]+2; - if(*dir == '=' || *dir == ':') dir++; - if(!*dir && argc > 1) { - argc--; - argv++; - dir = argv[0]; - } - if(!*dir) - error("Flag -d must be followed by a directory name."); - Strcpy(hackdir, dir); - } - if (argc > 1) { + if(argc > 1) { + if (!strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') { + /* avoid matching "-dec" for DECgraphics; since the man page + * says -d directory, hope nobody's using -desomething_else + */ + argc--; + argv++; + dir = argv[0]+2; + if(*dir == '=' || *dir == ':') dir++; + if(!*dir && argc > 1) { + argc--; + argv++; + dir = argv[0]; + } + if(!*dir) + error("Flag -d must be followed by a directory name."); + Strcpy(hackdir, dir); + } + if (argc > 1) { - /* - * Now we know the directory containing 'record' and - * may do a prscore(). - */ - if (!strncmp(argv[1], "-s", 2)) { + /* + * Now we know the directory containing 'record' and + * may do a prscore(). + */ + if (!strncmp(argv[1], "-s", 2)) { #if defined(MSWIN_GRAPHICS) || defined(WIN32CON) - int sfd = (int)_fileno(stdout); - redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0; + int sfd = (int)_fileno(stdout); + redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0; # ifdef MSWIN_GRAPHICS - if (!redirect_stdout) { - raw_printf("-s is not supported for the Graphical Interface\n"); - nethack_exit(EXIT_SUCCESS); - } + if (!redirect_stdout) { + raw_printf("-s is not supported for the Graphical Interface\n"); + nethack_exit(EXIT_SUCCESS); + } # endif #endif #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdirx(hackdir,0); + chdirx(hackdir,0); #endif #ifdef SYSCF - initoptions(); + initoptions(); #endif - prscore(argc, argv); - nethack_exit(EXIT_SUCCESS); - } + prscore(argc, argv); + nethack_exit(EXIT_SUCCESS); + } #ifdef MSWIN_GRAPHICS - if (!strncmpi(argv[1], "-clearreg", 6)) { /* clear registry */ - mswin_destroy_reg(); - nethack_exit(EXIT_SUCCESS); - } + if (!strncmpi(argv[1], "-clearreg", 6)) { /* clear registry */ + mswin_destroy_reg(); + nethack_exit(EXIT_SUCCESS); + } #endif - /* Don't initialize the window system just to print usage */ - if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) { - nhusage(); - nethack_exit(EXIT_SUCCESS); - } - } - } + /* Don't initialize the window system just to print usage */ + if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) { + nhusage(); + nethack_exit(EXIT_SUCCESS); + } + } + } #ifdef WIN32 - getreturn_enabled = save_getreturn_status; + getreturn_enabled = save_getreturn_status; #endif - /* - * It seems you really want to play. - */ + /* + * It seems you really want to play. + */ #ifdef TOS - if (comp_times((long)time(&clock_time))) - error("Your clock is incorrectly set!"); + if (comp_times((long)time(&clock_time))) + error("Your clock is incorrectly set!"); #endif - if (!dlb_init()) { - pline( + if (!dlb_init()) { + pline( "%s\n%s\n%s\n%s\n\nNetHack was unable to open the required file \"%s\".%s", - copyright_banner_line(1), copyright_banner_line(2), - copyright_banner_line(3), copyright_banner_line(4), DLBFILE, + copyright_banner_line(1), copyright_banner_line(2), + copyright_banner_line(3), copyright_banner_line(4), DLBFILE, #ifdef WIN32 - "\nAre you perhaps trying to run NetHack within a zip utility?"); + "\nAre you perhaps trying to run NetHack within a zip utility?"); #else - ""); + ""); #endif - error("dlb_init failure."); - } + error("dlb_init failure."); + } - u.uhp = 1; /* prevent RIP on early quits */ - u.ux = 0; /* prevent flush_screen() */ + u.uhp = 1; /* prevent RIP on early quits */ + u.ux = 0; /* prevent flush_screen() */ - /* chdir shouldn't be called before this point to keep the - * code parallel to other ports. - */ + /* chdir shouldn't be called before this point to keep the + * code parallel to other ports. + */ #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) - chdirx(hackdir,1); + chdirx(hackdir,1); #endif #ifdef MSDOS - /* We do this early for MSDOS because there are several - * display/tile related options that affect init_nhwindows() - */ - process_options(argc, argv); + /* We do this early for MSDOS because there are several + * display/tile related options that affect init_nhwindows() + */ + process_options(argc, argv); #endif #if defined(MSDOS) || defined(WIN32) - /* Player didn't specify any symbol set so use IBM defaults */ - if (!symset[PRIMARY].name) { - load_symset("IBMGraphics_2", PRIMARY); - } - if (!symset[ROGUESET].name) { - load_symset("RogueEpyx", ROGUESET); - } + /* Player didn't specify any symbol set so use IBM defaults */ + if (!symset[PRIMARY].name) { + load_symset("IBMGraphics_2", PRIMARY); + } + if (!symset[ROGUESET].name) { + load_symset("RogueEpyx", ROGUESET); + } #endif #ifdef MSDOS - init_nhwindows(&argc,argv); + init_nhwindows(&argc,argv); #else - init_nhwindows(&argc,argv); - process_options(argc, argv); + init_nhwindows(&argc,argv); + process_options(argc, argv); #endif #ifdef WIN32CON - toggle_mouse_support(); /* must come after process_options */ + toggle_mouse_support(); /* must come after process_options */ #endif #ifdef MFLOPPY - set_lock_and_bones(); + set_lock_and_bones(); # ifndef AMIGA - copybones(FROMPERM); + copybones(FROMPERM); # endif #endif - /* strip role,race,&c suffix; calls askname() if plname[] is empty - or holds a generic user name like "player" or "games" */ - plnamesuffix(); - set_playmode(); /* sets plname to "wizard" for wizard mode */ + /* strip role,race,&c suffix; calls askname() if plname[] is empty + or holds a generic user name like "player" or "games" */ + plnamesuffix(); + set_playmode(); /* sets plname to "wizard" for wizard mode */ #if 0 - /* unlike Unix where the game might be invoked with a script - which forces a particular character name for each player - using a shared account, we always allow player to rename - the character during role/race/&c selection */ - iflags.renameallowed = TRUE; + /* unlike Unix where the game might be invoked with a script + which forces a particular character name for each player + using a shared account, we always allow player to rename + the character during role/race/&c selection */ + iflags.renameallowed = TRUE; #else /* until the getlock code is resolved, override askname()'s setting of renameallowed; when False, player_selection() @@ -352,138 +379,138 @@ char *argv[]; #endif #if defined(PC_LOCKING) - /* 3.3.0 added this to support detection of multiple games - * under the same plname on the same machine in a windowed - * or multitasking environment. - * - * That allows user confirmation prior to overwriting the - * level files of a game in progress. - * - * Also prevents an aborted game's level files from being - * overwritten without confirmation when a user starts up - * another game with the same player name. - */ + /* 3.3.0 added this to support detection of multiple games + * under the same plname on the same machine in a windowed + * or multitasking environment. + * + * That allows user confirmation prior to overwriting the + * level files of a game in progress. + * + * Also prevents an aborted game's level files from being + * overwritten without confirmation when a user starts up + * another game with the same player name. + */ # if defined(WIN32) - /* Obtain the name of the logged on user and incorporate - * it into the name. */ - Sprintf(fnamebuf, "%s-%s", get_username(0), plname); - (void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", - '%', fnamebuf, encodedfnamebuf, BUFSZ); - Sprintf(lock, "%s",encodedfnamebuf); - /* regularize(lock); */ /* we encode now, rather than substitute */ + /* Obtain the name of the logged on user and incorporate + * it into the name. */ + Sprintf(fnamebuf, "%s-%s", get_username(0), plname); + (void)fname_encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.", + '%', fnamebuf, encodedfnamebuf, BUFSZ); + Sprintf(lock, "%s",encodedfnamebuf); + /* regularize(lock); */ /* we encode now, rather than substitute */ # else - Strcpy(lock,plname); - regularize(lock); + Strcpy(lock,plname); + regularize(lock); # endif - getlock(); + getlock(); #else /* What follows is !PC_LOCKING */ # ifdef AMIGA /* We'll put the bones & levels in the user specified directory -jhsa */ - Strcat(lock,plname); - Strcat(lock,".99"); + Strcat(lock,plname); + Strcat(lock,".99"); # else # ifndef MFLOPPY - /* I'm not sure what, if anything, is left here, but MFLOPPY has - * conflicts with set_lock_and_bones() in files.c. - */ - Strcpy(lock,plname); - Strcat(lock,".99"); - regularize(lock); /* is this necessary? */ - /* not compatible with full path a la AMIGA */ + /* I'm not sure what, if anything, is left here, but MFLOPPY has + * conflicts with set_lock_and_bones() in files.c. + */ + Strcpy(lock,plname); + Strcat(lock,".99"); + regularize(lock); /* is this necessary? */ + /* not compatible with full path a la AMIGA */ # endif # endif #endif /* PC_LOCKING */ - /* Set up level 0 file to keep the game state. - */ - fd = create_levelfile(0, (char *)0); - if (fd < 0) { - raw_print("Cannot create lock file"); - } else { + /* Set up level 0 file to keep the game state. + */ + fd = create_levelfile(0, (char *)0); + if (fd < 0) { + raw_print("Cannot create lock file"); + } else { #ifdef WIN32 - hackpid = GetCurrentProcessId(); + hackpid = GetCurrentProcessId(); #else - hackpid = 1; + hackpid = 1; #endif - write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); + write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); nhclose(fd); - } + } #ifdef MFLOPPY - level_info[0].where = ACTIVE; + level_info[0].where = ACTIVE; #endif - /* - * Initialize the vision system. This must be before mklev() on a - * new game or before a level restore on a saved game. - */ - vision_init(); + /* + * Initialize the vision system. This must be before mklev() on a + * new game or before a level restore on a saved game. + */ + vision_init(); - display_gamewindows(); + display_gamewindows(); #ifdef WIN32 - getreturn_enabled = TRUE; + getreturn_enabled = TRUE; #endif - /* - * First, try to find and restore a save file for specified character. - * We'll return here if new game player_selection() renames the hero. - */ + /* + * First, try to find and restore a save file for specified character. + * We'll return here if new game player_selection() renames the hero. + */ attempt_restore: - if ((fd = restore_saved_game()) >= 0) { + if ((fd = restore_saved_game()) >= 0) { #ifndef NO_SIGNAL - (void) signal(SIGINT, (SIG_RET_TYPE) done1); + (void) signal(SIGINT, (SIG_RET_TYPE) done1); #endif #ifdef NEWS - if(iflags.news){ - display_file(NEWS, FALSE); - iflags.news = FALSE; - } + if(iflags.news){ + display_file(NEWS, FALSE); + iflags.news = FALSE; + } #endif - pline("Restoring save file..."); - mark_synch(); /* flush output */ + pline("Restoring save file..."); + mark_synch(); /* flush output */ - if (dorecover(fd)) { - resuming = TRUE; /* not starting new game */ - if (discover) - You("are in non-scoring discovery mode."); - if (discover || wizard) { - if(yn("Do you want to keep the save file?") == 'n') - (void) delete_savefile(); - else { - nh_compress(fqname(SAVEF, SAVEPREFIX, 0)); - } - } - } - } + if (dorecover(fd)) { + resuming = TRUE; /* not starting new game */ + if (discover) + You("are in non-scoring discovery mode."); + if (discover || wizard) { + if(yn("Do you want to keep the save file?") == 'n') + (void) delete_savefile(); + else { + nh_compress(fqname(SAVEF, SAVEPREFIX, 0)); + } + } + } + } - if (!resuming) { - /* new game: start by choosing role, race, etc; - player might change the hero's name while doing that, - in which case we try to restore under the new name - and skip selection this time if that didn't succeed */ - if (!iflags.renameinprogress) { - player_selection(); - if (iflags.renameinprogress) { - /* player has renamed the hero while selecting role; - discard current lock file and create another for - the new character name */ + if (!resuming) { + /* new game: start by choosing role, race, etc; + player might change the hero's name while doing that, + in which case we try to restore under the new name + and skip selection this time if that didn't succeed */ + if (!iflags.renameinprogress) { + player_selection(); + if (iflags.renameinprogress) { + /* player has renamed the hero while selecting role; + discard current lock file and create another for + the new character name */ #if 0 /* this needs to be reconciled with the getlock mess above... */ - delete_levelfile(0); /* remove empty lock file */ - getlock(); + delete_levelfile(0); /* remove empty lock file */ + getlock(); #endif - goto attempt_restore; - } - } - newgame(); - if (discover) - You("are in non-scoring discovery mode."); - } + goto attempt_restore; + } + } + newgame(); + if (discover) + You("are in non-scoring discovery mode."); + } #ifndef NO_SIGNAL - (void) signal(SIGINT, SIG_IGN); + (void) signal(SIGINT, SIG_IGN); #endif #ifdef OS2 - gettty(); /* somehow ctrl-P gets turned back on during startup ... */ + gettty(); /* somehow ctrl-P gets turned back on during startup ... */ #endif - return resuming; + return resuming; } STATIC_OVL void @@ -491,172 +518,172 @@ process_options(argc, argv) int argc; char *argv[]; { - int i; + int i; - /* - * Process options. - */ - while(argc > 1 && argv[1][0] == '-'){ - argv++; - argc--; - switch(argv[0][1]){ - case 'a': - if (argv[0][2]) { - if ((i = str2align(&argv[0][2])) >= 0) - flags.initalign = i; - } else if (argc > 1) { - argc--; - argv++; - if ((i = str2align(argv[0])) >= 0) - flags.initalign = i; - } - break; - case 'D': - wizard = TRUE, discover = FALSE; - break; - case 'X': - discover = TRUE, wizard = FALSE; - break; + /* + * Process options. + */ + while(argc > 1 && argv[1][0] == '-'){ + argv++; + argc--; + switch(argv[0][1]){ + case 'a': + if (argv[0][2]) { + if ((i = str2align(&argv[0][2])) >= 0) + flags.initalign = i; + } else if (argc > 1) { + argc--; + argv++; + if ((i = str2align(argv[0])) >= 0) + flags.initalign = i; + } + break; + case 'D': + wizard = TRUE, discover = FALSE; + break; + case 'X': + discover = TRUE, wizard = FALSE; + break; #ifdef NEWS - case 'n': - iflags.news = FALSE; - break; + case 'n': + iflags.news = FALSE; + break; #endif - case 'u': - if(argv[0][2]) - (void) strncpy(plname, argv[0]+2, sizeof(plname)-1); - else if(argc > 1) { - argc--; - argv++; - (void) strncpy(plname, argv[0], sizeof(plname)-1); - } else - raw_print("Player name expected after -u"); - break; + case 'u': + if(argv[0][2]) + (void) strncpy(plname, argv[0]+2, sizeof(plname)-1); + else if(argc > 1) { + argc--; + argv++; + (void) strncpy(plname, argv[0], sizeof(plname)-1); + } else + raw_print("Player name expected after -u"); + break; #ifndef AMIGA - case 'I': - case 'i': - if (!strncmpi(argv[0]+1, "IBM", 3)) { - load_symset("IBMGraphics", PRIMARY); - load_symset("RogueIBM", ROGUESET); - switch_symbols(TRUE); - } - break; - /* case 'D': */ - case 'd': - if (!strncmpi(argv[0]+1, "DEC", 3)) { - load_symset("DECGraphics", PRIMARY); - switch_symbols(TRUE); - } - break; + case 'I': + case 'i': + if (!strncmpi(argv[0]+1, "IBM", 3)) { + load_symset("IBMGraphics", PRIMARY); + load_symset("RogueIBM", ROGUESET); + switch_symbols(TRUE); + } + break; + /* case 'D': */ + case 'd': + if (!strncmpi(argv[0]+1, "DEC", 3)) { + load_symset("DECGraphics", PRIMARY); + switch_symbols(TRUE); + } + break; #endif - case 'g': - if (argv[0][2]) { - if ((i = str2gend(&argv[0][2])) >= 0) - flags.initgend = i; - } else if (argc > 1) { - argc--; - argv++; - if ((i = str2gend(argv[0])) >= 0) - flags.initgend = i; - } - break; - case 'p': /* profession (role) */ - if (argv[0][2]) { - if ((i = str2role(&argv[0][2])) >= 0) - flags.initrole = i; - } else if (argc > 1) { - argc--; - argv++; - if ((i = str2role(argv[0])) >= 0) - flags.initrole = i; - } - break; - case 'r': /* race */ - if (argv[0][2]) { - if ((i = str2race(&argv[0][2])) >= 0) - flags.initrace = i; - } else if (argc > 1) { - argc--; - argv++; - if ((i = str2race(argv[0])) >= 0) - flags.initrace = i; - } - break; + case 'g': + if (argv[0][2]) { + if ((i = str2gend(&argv[0][2])) >= 0) + flags.initgend = i; + } else if (argc > 1) { + argc--; + argv++; + if ((i = str2gend(argv[0])) >= 0) + flags.initgend = i; + } + break; + case 'p': /* profession (role) */ + if (argv[0][2]) { + if ((i = str2role(&argv[0][2])) >= 0) + flags.initrole = i; + } else if (argc > 1) { + argc--; + argv++; + if ((i = str2role(argv[0])) >= 0) + flags.initrole = i; + } + break; + case 'r': /* race */ + if (argv[0][2]) { + if ((i = str2race(&argv[0][2])) >= 0) + flags.initrace = i; + } else if (argc > 1) { + argc--; + argv++; + if ((i = str2race(argv[0])) >= 0) + flags.initrace = i; + } + break; #ifdef MFLOPPY # ifndef AMIGA - /* Player doesn't want to use a RAM disk - */ - case 'R': - ramdisk = FALSE; - break; + /* Player doesn't want to use a RAM disk + */ + case 'R': + ramdisk = FALSE; + break; # endif #endif #ifdef AMIGA - /* interlaced and non-interlaced screens */ - case 'L': - bigscreen = 1; - break; - case 'l': - bigscreen = -1; - break; + /* interlaced and non-interlaced screens */ + case 'L': + bigscreen = 1; + break; + case 'l': + bigscreen = -1; + break; #endif - case '@': - flags.randomall = 1; - break; - default: - if ((i = str2role(&argv[0][1])) >= 0) { - flags.initrole = i; - break; - } else raw_printf("\nUnknown switch: %s", argv[0]); - /* FALL THROUGH */ - case '?': - nhusage(); - nethack_exit(EXIT_SUCCESS); - } - } + case '@': + flags.randomall = 1; + break; + default: + if ((i = str2role(&argv[0][1])) >= 0) { + flags.initrole = i; + break; + } else raw_printf("\nUnknown switch: %s", argv[0]); + /* FALL THROUGH */ + case '?': + nhusage(); + nethack_exit(EXIT_SUCCESS); + } + } } STATIC_OVL void nhusage() { - char buf1[BUFSZ], buf2[BUFSZ], *bufptr; + char buf1[BUFSZ], buf2[BUFSZ], *bufptr; - buf1[0] = '\0'; - bufptr = buf1; + buf1[0] = '\0'; + bufptr = buf1; #define ADD_USAGE(s) if ((strlen(buf1) + strlen(s)) < (BUFSZ - 1)) Strcat(bufptr, s); - /* -role still works for those cases which aren't already taken, but - * is deprecated and will not be listed here. - */ - (void) Sprintf(buf2, + /* -role still works for those cases which aren't already taken, but + * is deprecated and will not be listed here. + */ + (void) Sprintf(buf2, "\nUsage:\n%s [-d dir] -s [-r race] [-p profession] [maxrank] [name]...\n or", - hname); - ADD_USAGE(buf2); + hname); + ADD_USAGE(buf2); - (void) Sprintf(buf2, - "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]", - hname); - ADD_USAGE(buf2); + (void) Sprintf(buf2, + "\n%s [-d dir] [-u name] [-r race] [-p profession] [-[DX]]", + hname); + ADD_USAGE(buf2); #ifdef NEWS - ADD_USAGE(" [-n]"); + ADD_USAGE(" [-n]"); #endif #ifndef AMIGA - ADD_USAGE(" [-I] [-i] [-d]"); + ADD_USAGE(" [-I] [-i] [-d]"); #endif #ifdef MFLOPPY # ifndef AMIGA - ADD_USAGE(" [-R]"); + ADD_USAGE(" [-R]"); # endif #endif #ifdef AMIGA - ADD_USAGE(" [-[lL]]"); + ADD_USAGE(" [-[lL]]"); #endif - if (!iflags.window_inited) - raw_printf("%s\n",buf1); - else - (void) printf("%s\n",buf1); + if (!iflags.window_inited) + raw_printf("%s\n",buf1); + else + (void) printf("%s\n",buf1); #undef ADD_USAGE } @@ -667,24 +694,24 @@ char *dir; boolean wr; { # ifdef AMIGA - static char thisdir[] = ""; + static char thisdir[] = ""; # else - static char thisdir[] = "."; + static char thisdir[] = "."; # endif - if(dir && chdir(dir) < 0) { - error("Cannot chdir to %s.", dir); - } + if(dir && chdir(dir) < 0) { + error("Cannot chdir to %s.", dir); + } # ifndef AMIGA - /* Change the default drive as well. - */ - chdrive(dir); + /* Change the default drive as well. + */ + chdrive(dir); # endif - /* warn the player if we can't write the record file */ - /* perhaps we should also test whether . is writable */ - /* unfortunately the access system-call is worthless */ - if (wr) check_recordfile(dir ? dir : thisdir); + /* warn the player if we can't write the record file */ + /* perhaps we should also test whether . is writable */ + /* unfortunately the access system-call is worthless */ + if (wr) check_recordfile(dir ? dir : thisdir); } #endif /* CHDIR */ @@ -703,8 +730,8 @@ port_help() boolean authorize_wizard_mode() { - if (!strcmp(plname, WIZARD_NAME)) return TRUE; - return FALSE; + if (!strcmp(plname, WIZARD_NAME)) return TRUE; + return FALSE; } #ifdef EXEPATH @@ -720,28 +747,28 @@ char exepathbuf[EXEPATHBUFSZ]; char *exepath(str) char *str; { - char *tmp, *tmp2; - int bsize; + char *tmp, *tmp2; + int bsize; - if (!str) return (char *)0; - bsize = EXEPATHBUFSZ; - tmp = exepathbuf; + if (!str) return (char *)0; + bsize = EXEPATHBUFSZ; + tmp = exepathbuf; # ifndef WIN32 - Strcpy (tmp, str); + Strcpy (tmp, str); # else - #ifdef UNICODE - { - TCHAR wbuf[BUFSZ]; - GetModuleFileName((HANDLE)0, wbuf, BUFSZ); - WideCharToMultiByte(CP_ACP, 0, wbuf, -1, tmp, bsize, NULL, NULL); - } - #else - *(tmp + GetModuleFileName((HANDLE)0, tmp, bsize)) = '\0'; - #endif + #ifdef UNICODE + { + TCHAR wbuf[BUFSZ]; + GetModuleFileName((HANDLE)0, wbuf, BUFSZ); + WideCharToMultiByte(CP_ACP, 0, wbuf, -1, tmp, bsize, NULL, NULL); + } + #else + *(tmp + GetModuleFileName((HANDLE)0, tmp, bsize)) = '\0'; + #endif # endif - tmp2 = strrchr(tmp, PATH_SEPARATOR); - if (tmp2) *tmp2 = '\0'; - return tmp; + tmp2 = strrchr(tmp, PATH_SEPARATOR); + if (tmp2) *tmp2 = '\0'; + return tmp; } #endif /* EXEPATH */ diff --git a/sys/unix/sysconf b/sys/unix/sysconf index 50fa74085..aff14b8c7 100644 --- a/sys/unix/sysconf +++ b/sys/unix/sysconf @@ -35,6 +35,9 @@ MAXPLAYERS=10 # Uncomment the next line to disable the SEDUCE option. #SEDUCE=0 +# Uncomment to disable savefile UID checking. +#CHECK_SAVE_UID=0 + # Record (high score) file options. # CAUTION: changing these after people have started playing games can # lead to lost high scores! diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 6ab51fae9..e21988c70 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 winmenu.c $NHDT-Date: 1427881480 2015/04/01 09:44:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.5 $ */ +/* NetHack 3.5 winmenu.c $NHDT-Date: 1428828477 2015/04/12 08:47:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */ /* NetHack 3.5 winmenu.c $Date: 2009/05/06 10:55:53 $ $Revision: 1.5 $ */ /* SCCS Id: @(#)winmenu.c 3.5 1996/08/15 */ /* Copyright (c) Dean Luick, 1992 */ @@ -249,9 +249,13 @@ menu_key(w, event, params, num_params) return; } else if (ch == MENU_SEARCH) { /* search */ if (menu_info->how == PICK_ANY || menu_info->how == PICK_ONE) { - char buf[BUFSZ]; - X11_getlin("Search for:", buf); - if (!*buf || *buf == '\033') return; + char buf[BUFSZ+2], tmpbuf[BUFSZ]; + + X11_getlin("Search for:", tmpbuf); + if (!*tmpbuf || *tmpbuf == '\033') return; + /* convert "string" into "*string*" for use with pmatch() */ + Sprintf(buf, "*%s*", tmpbuf); + if (menu_info->how == PICK_ANY) { invert_match(wp, buf); return; @@ -395,10 +399,12 @@ menu_search(w, client_data, call_data) { struct xwindow *wp = (struct xwindow *) client_data; struct menu_info_t *menu_info = wp->menu_information; + char buf[BUFSZ+2], tmpbuf[BUFSZ]; - char buf[BUFSZ]; - X11_getlin("Search for:", buf); - if (!*buf || *buf == '\033') return; + X11_getlin("Search for:", tmpbuf); + if (!*tmpbuf || *tmpbuf == '\033') return; + /* convert "string" into "*string*" for use with pmatch() */ + Sprintf(buf, "*%s*", tmpbuf); if (menu_info->how == PICK_ANY) invert_match(wp, buf); @@ -479,7 +485,7 @@ invert_all(wp) static void invert_match(wp, match) struct xwindow *wp; - char *match; + char *match; /* wildcard pattern for pmatch() */ { x11_menu_item *curr; int count; @@ -488,7 +494,7 @@ invert_match(wp, match) reset_menu_count(wp->menu_information); for (count = 0, curr = wp->menu_information->curr_menu.base; curr; curr = curr->next, count++) - if (curr->identifier.a_void != 0 && strstri(curr->str, match)) { + if (curr->identifier.a_void != 0 && pmatchi(match, curr->str)) { invert_line(wp, curr, count, -1L); changed = TRUE; } @@ -503,7 +509,7 @@ invert_match(wp, match) static void select_match(wp, match) struct xwindow *wp; - char *match; + char *match; /* wildcard pattern for pmatch() */ { x11_menu_item *curr; int count; @@ -511,11 +517,12 @@ select_match(wp, match) reset_menu_count(wp->menu_information); for (count = 0, curr = wp->menu_information->curr_menu.base; curr; curr = curr->next, count++) - if (curr->identifier.a_void != 0 && strstri(curr->str, match)) { + if (curr->identifier.a_void != 0 && pmatchi(match, curr->str)) { if (!curr->selected) { invert_line(wp, curr, count, -1L); #ifndef USE_FWF - XawListChange(wp->w, wp->menu_information->curr_menu.list_pointer, + XawListChange(wp->w, + wp->menu_information->curr_menu.list_pointer, 0, 0, True); #endif } diff --git a/win/share/objects.txt b/win/share/objects.txt index 09f3747f3..257a277e6 100644 --- a/win/share/objects.txt +++ b/win/share/objects.txt @@ -4726,7 +4726,83 @@ P = (108, 145, 182) MMMMMMAAAAAMMMMM MMMMMMMMMMMMMMMM } -# tile 248 (kelp frond) +# tile 248 (glob of gray ooze) +{ + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMPPPPPPMMMMM + MMMMMPPPPPPPMMMM + MMMPPPPPPPPMMMMM + MMMMPPPPPPPPMMMM + MMPPPPPPPPPPMMMM + MMMPPPPPPPPPPMMM + MMPMPPPPPPPMPAMM + MMPPPPAMPMPPAMMM + MMMAAAMAAAAAMMMM + MMMMMMMMMMMMMMMM +} +# tile 249 (glob of brown pudding) +{ + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMJJJJJJMMMMM + MMMMMJJJJJJJMMMM + MMMJJJJJJJJMMMMM + MMMMJJJJJJJJMMMM + MMJJJJJJJJJJMMMM + MMMJJJJJJJJJJMMM + MMJMJJJJJJJMJAMM + MMJJJJAMJMJJAMMM + MMMAAAMAAAAAMMMM + MMMMMMMMMMMMMMMM +} +# tile 250 (glob of green slime) +{ + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMFFFFFFMMMMM + MMMMMFFFFFFFMMMM + MMMFFFFFFFFMMMMM + MMMMFFFFFFFFMMMM + MMFFFFFFFFFFMMMM + MMMFFFFFFFFFFMMM + MMFMFFFFFFFMFAMM + MMFFFFAMFMFFAMMM + MMMAAAMAAAAAMMMM + MMMMMMMMMMMMMMMM +} +# tile 251 (glob of black pudding) +{ + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMMMMMMMMMMMM + MMMMMAAAAAAMMMMM + MMMMMADAAAAAMMMM + MMMAAAAADAAMMMMM + MMMMAAAAADAAMMMM + MMAAAAAAAAAAMMMM + MMMAAADAAAAAAMMM + MMAMAAAAAADMAAMM + MMAAAAAMAMAAAMMM + MMMAAAMAAAAAMMMM + MMMMMMMMMMMMMMMM +} +# tile 252 (kelp frond) { MMMMFAMMMMMMMMMM MMMMFFAMMMMMMMMM @@ -4745,7 +4821,7 @@ P = (108, 145, 182) MMMMMFFFFAMMMMMM MMMMMMFFFFAMMMMM } -# tile 249 (eucalyptus leaf) +# tile 253 (eucalyptus leaf) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4764,7 +4840,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 250 (apple) +# tile 254 (apple) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4783,7 +4859,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 251 (orange) +# tile 255 (orange) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4802,7 +4878,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 252 (pear) +# tile 256 (pear) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4821,7 +4897,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 253 (melon) +# tile 257 (melon) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4840,7 +4916,7 @@ P = (108, 145, 182) MMMMMMAAAMMMMMMM MMMMMMMMMMMMMMMM } -# tile 254 (banana) +# tile 258 (banana) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4859,7 +4935,7 @@ P = (108, 145, 182) MMMMMAAAAAMMMMMM MMMMMMMMMMMMMMMM } -# tile 255 (carrot) +# tile 259 (carrot) { MMMMMMMMMMMMMMMM MMMMMMMMMMFMMFMM @@ -4878,7 +4954,7 @@ P = (108, 145, 182) MMMAMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 256 (sprig of wolfsbane) +# tile 260 (sprig of wolfsbane) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4897,7 +4973,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 257 (clove of garlic) +# tile 261 (clove of garlic) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4916,7 +4992,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 258 (slime mold) +# tile 262 (slime mold) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4935,7 +5011,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 259 (lump of royal jelly) +# tile 263 (lump of royal jelly) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4954,7 +5030,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 260 (cream pie) +# tile 264 (cream pie) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4973,7 +5049,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 261 (candy bar) +# tile 265 (candy bar) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -4992,7 +5068,7 @@ P = (108, 145, 182) MMMMAMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 262 (fortune cookie) +# tile 266 (fortune cookie) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5011,7 +5087,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 263 (pancake) +# tile 267 (pancake) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5030,7 +5106,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 264 (lembas wafer) +# tile 268 (lembas wafer) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5049,7 +5125,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 265 (cram ration) +# tile 269 (cram ration) { MMMMMMMMMMMMMMMM MMMJKAMMMMMMMMMM @@ -5068,7 +5144,7 @@ P = (108, 145, 182) MMMMMAAAAAAMMMMM MMMMMMMMMMMMMMMM } -# tile 266 (food ration) +# tile 270 (food ration) { MMMJJAMMMMMMMMMM MMMBPAMMMMMMMMMM @@ -5087,7 +5163,7 @@ P = (108, 145, 182) MMMMKKKKKKKKKAMM MMMMMAAAAAAAAMMM } -# tile 267 (K-ration) +# tile 271 (K-ration) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5106,7 +5182,7 @@ P = (108, 145, 182) MMMMKKKKKKKKKAMM MMMMMAAAAAAAAMMM } -# tile 268 (C-ration) +# tile 272 (C-ration) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5125,7 +5201,7 @@ P = (108, 145, 182) MMMMKKKKKKKKKAMM MMMMMAAAAAAAAMMM } -# tile 269 (tin) +# tile 273 (tin) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5144,7 +5220,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 270 (ruby / gain ability) +# tile 274 (ruby / gain ability) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5163,7 +5239,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 271 (pink / restore ability) +# tile 275 (pink / restore ability) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5182,7 +5258,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 272 (orange / confusion) +# tile 276 (orange / confusion) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5201,7 +5277,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 273 (yellow / blindness) +# tile 277 (yellow / blindness) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5220,7 +5296,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 274 (emerald / paralysis) +# tile 278 (emerald / paralysis) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5239,7 +5315,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 275 (dark green / speed) +# tile 279 (dark green / speed) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5258,7 +5334,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 276 (cyan / levitation) +# tile 280 (cyan / levitation) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5277,7 +5353,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 277 (sky blue / hallucination) +# tile 281 (sky blue / hallucination) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5296,7 +5372,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 278 (brilliant blue / invisibility) +# tile 282 (brilliant blue / invisibility) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5315,7 +5391,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 279 (magenta / see invisible) +# tile 283 (magenta / see invisible) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5334,7 +5410,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 280 (purple-red / healing) +# tile 284 (purple-red / healing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5353,7 +5429,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 281 (puce / extra healing) +# tile 285 (puce / extra healing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5372,7 +5448,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 282 (milky / gain level) +# tile 286 (milky / gain level) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5391,7 +5467,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 283 (swirly / enlightenment) +# tile 287 (swirly / enlightenment) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5410,7 +5486,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 284 (bubbly / monster detection) +# tile 288 (bubbly / monster detection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5429,7 +5505,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 285 (smoky / object detection) +# tile 289 (smoky / object detection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5448,7 +5524,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 286 (cloudy / gain energy) +# tile 290 (cloudy / gain energy) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5467,7 +5543,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 287 (effervescent / sleeping) +# tile 291 (effervescent / sleeping) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5486,7 +5562,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 288 (black / full healing) +# tile 292 (black / full healing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5505,7 +5581,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 289 (golden / polymorph) +# tile 293 (golden / polymorph) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5524,7 +5600,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 290 (brown / booze) +# tile 294 (brown / booze) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5543,7 +5619,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 291 (fizzy / sickness) +# tile 295 (fizzy / sickness) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5562,7 +5638,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 292 (dark / fruit juice) +# tile 296 (dark / fruit juice) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5581,7 +5657,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 293 (white / acid) +# tile 297 (white / acid) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5600,7 +5676,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 294 (murky / oil) +# tile 298 (murky / oil) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5619,7 +5695,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 295 (clear / water) +# tile 299 (clear / water) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5638,7 +5714,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 296 (ZELGO MER / enchant armor) +# tile 300 (ZELGO MER / enchant armor) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5657,7 +5733,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 297 (JUYED AWK YACC / destroy armor) +# tile 301 (JUYED AWK YACC / destroy armor) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5676,7 +5752,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 298 (NR 9 / confuse monster) +# tile 302 (NR 9 / confuse monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5695,7 +5771,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 299 (XIXAXA XOXAXA XUXAXA / scare monster) +# tile 303 (XIXAXA XOXAXA XUXAXA / scare monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5714,7 +5790,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 300 (PRATYAVAYAH / remove curse) +# tile 304 (PRATYAVAYAH / remove curse) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5733,7 +5809,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 301 (DAIYEN FOOELS / enchant weapon) +# tile 305 (DAIYEN FOOELS / enchant weapon) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5752,7 +5828,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 302 (LEP GEX VEN ZEA / create monster) +# tile 306 (LEP GEX VEN ZEA / create monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5771,7 +5847,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 303 (PRIRUTSENIE / taming) +# tile 307 (PRIRUTSENIE / taming) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5790,7 +5866,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 304 (ELBIB YLOH / genocide) +# tile 308 (ELBIB YLOH / genocide) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5809,7 +5885,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 305 (VERR YED HORRE / light) +# tile 309 (VERR YED HORRE / light) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5828,7 +5904,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 306 (VENZAR BORGAVVE / teleportation) +# tile 310 (VENZAR BORGAVVE / teleportation) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5847,7 +5923,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 307 (THARR / gold detection) +# tile 311 (THARR / gold detection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5866,7 +5942,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 308 (YUM YUM / food detection) +# tile 312 (YUM YUM / food detection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5885,7 +5961,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 309 (KERNOD WEL / identify) +# tile 313 (KERNOD WEL / identify) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5904,7 +5980,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 310 (ELAM EBOW / magic mapping) +# tile 314 (ELAM EBOW / magic mapping) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5923,7 +5999,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 311 (DUAM XNAHT / amnesia) +# tile 315 (DUAM XNAHT / amnesia) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5942,7 +6018,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 312 (ANDOVA BEGARIN / fire) +# tile 316 (ANDOVA BEGARIN / fire) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5961,7 +6037,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 313 (KIRJE / earth) +# tile 317 (KIRJE / earth) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5980,7 +6056,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 314 (VE FORBRYDERNE / punishment) +# tile 318 (VE FORBRYDERNE / punishment) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -5999,7 +6075,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 315 (HACKEM MUCHE / charging) +# tile 319 (HACKEM MUCHE / charging) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6018,7 +6094,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 316 (VELOX NEB / stinking cloud) +# tile 320 (VELOX NEB / stinking cloud) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6037,7 +6113,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 317 (FOOBIE BLETCH) +# tile 321 (FOOBIE BLETCH) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6056,7 +6132,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 318 (TEMOV) +# tile 322 (TEMOV) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6075,7 +6151,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 319 (GARVEN DEH) +# tile 323 (GARVEN DEH) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6094,7 +6170,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 320 (READ ME) +# tile 324 (READ ME) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6113,7 +6189,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 321 (stamped / mail) +# tile 325 (stamped / mail) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6132,7 +6208,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 322 (unlabeled / blank paper) +# tile 326 (unlabeled / blank paper) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6151,7 +6227,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 323 (parchment / dig) +# tile 327 (parchment / dig) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6170,7 +6246,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 324 (vellum / magic missile) +# tile 328 (vellum / magic missile) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6189,7 +6265,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 325 (ragged / fireball) +# tile 329 (ragged / fireball) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6208,7 +6284,7 @@ P = (108, 145, 182) MMMMMMOOJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 326 (dog eared / cone of cold) +# tile 330 (dog eared / cone of cold) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6227,7 +6303,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 327 (mottled / sleep) +# tile 331 (mottled / sleep) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6246,7 +6322,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 328 (stained / finger of death) +# tile 332 (stained / finger of death) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6265,7 +6341,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 329 (cloth / light) +# tile 333 (cloth / light) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6284,7 +6360,7 @@ P = (108, 145, 182) MMMMMMMPPPAAMMMM MMMMMMMMMMMMMMMM } -# tile 330 (leathery / detect monsters) +# tile 334 (leathery / detect monsters) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6303,7 +6379,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 331 (white / healing) +# tile 335 (white / healing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6322,7 +6398,7 @@ P = (108, 145, 182) MMMMMMMPNNAAMMMM MMMMMMMMMMMMMMMM } -# tile 332 (pink / knock) +# tile 336 (pink / knock) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6341,7 +6417,7 @@ P = (108, 145, 182) MMMMMMMIIIAAMMMM MMMMMMMMMMMMMMMM } -# tile 333 (red / force bolt) +# tile 337 (red / force bolt) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6360,7 +6436,7 @@ P = (108, 145, 182) MMMMMMMDDDAAMMMM MMMMMMMMMMMMMMMM } -# tile 334 (orange / confuse monster) +# tile 338 (orange / confuse monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6379,7 +6455,7 @@ P = (108, 145, 182) MMMMMMMCCCAAMMMM MMMMMMMMMMMMMMMM } -# tile 335 (yellow / cure blindness) +# tile 339 (yellow / cure blindness) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6398,7 +6474,7 @@ P = (108, 145, 182) MMMMMMMHHHAAMMMM MMMMMMMMMMMMMMMM } -# tile 336 (velvet / drain life) +# tile 340 (velvet / drain life) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6417,7 +6493,7 @@ P = (108, 145, 182) MMMMMMMEEEAAMMMM MMMMMMMMMMMMMMMM } -# tile 337 (light green / slow monster) +# tile 341 (light green / slow monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6436,7 +6512,7 @@ P = (108, 145, 182) MMMMMMMGGGAAMMMM MMMMMMMMMMMMMMMM } -# tile 338 (dark green / wizard lock) +# tile 342 (dark green / wizard lock) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6455,7 +6531,7 @@ P = (108, 145, 182) MMMMMMMFFFAAMMMM MMMMMMMMMMMMMMMM } -# tile 339 (turquoise / create monster) +# tile 343 (turquoise / create monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6474,7 +6550,7 @@ P = (108, 145, 182) MMMMMMMFBBAAMMMM MMMMMMMMMMMMMMMM } -# tile 340 (cyan / detect food) +# tile 344 (cyan / detect food) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6493,7 +6569,7 @@ P = (108, 145, 182) MMMMMMMBBBAAMMMM MMMMMMMMMMMMMMMM } -# tile 341 (light blue / cause fear) +# tile 345 (light blue / cause fear) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6512,7 +6588,7 @@ P = (108, 145, 182) MMMMMMMBBBAAMMMM MMMMMMMMMMMMMMMM } -# tile 342 (dark blue / clairvoyance) +# tile 346 (dark blue / clairvoyance) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6531,7 +6607,7 @@ P = (108, 145, 182) MMMMMMMEEEAAMMMM MMMMMMMMMMMMMMMM } -# tile 343 (indigo / cure sickness) +# tile 347 (indigo / cure sickness) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6550,7 +6626,7 @@ P = (108, 145, 182) MMMMMMMEEEAAMMMM MMMMMMMMMMMMMMMM } -# tile 344 (magenta / charm monster) +# tile 348 (magenta / charm monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6569,7 +6645,7 @@ P = (108, 145, 182) MMMMMMMIIIAAMMMM MMMMMMMMMMMMMMMM } -# tile 345 (purple / haste self) +# tile 349 (purple / haste self) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6588,7 +6664,7 @@ P = (108, 145, 182) MMMMMMMIIIAAMMMM MMMMMMMMMMMMMMMM } -# tile 346 (violet / detect unseen) +# tile 350 (violet / detect unseen) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6607,7 +6683,7 @@ P = (108, 145, 182) MMMMMMMIIIAAMMMM MMMMMMMMMMMMMMMM } -# tile 347 (tan / levitation) +# tile 351 (tan / levitation) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6626,7 +6702,7 @@ P = (108, 145, 182) MMMMMMMKKKAAMMMM MMMMMMMMMMMMMMMM } -# tile 348 (plaid / extra healing) +# tile 352 (plaid / extra healing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6645,7 +6721,7 @@ P = (108, 145, 182) MMMMMMMEFDAAMMMM MMMMMMMMMMMMMMMM } -# tile 349 (light brown / restore ability) +# tile 353 (light brown / restore ability) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6664,7 +6740,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 350 (dark brown / invisibility) +# tile 354 (dark brown / invisibility) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6683,7 +6759,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 351 (gray / detect treasure) +# tile 355 (gray / detect treasure) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6702,7 +6778,7 @@ P = (108, 145, 182) MMMMMMMPPPAAMMMM MMMMMMMMMMMMMMMM } -# tile 352 (wrinkled / remove curse) +# tile 356 (wrinkled / remove curse) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6721,7 +6797,7 @@ P = (108, 145, 182) MMMMMMJJKKAAMMMM MMMMMMMMMMMMMMMM } -# tile 353 (dusty / magic mapping) +# tile 357 (dusty / magic mapping) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6740,7 +6816,7 @@ P = (108, 145, 182) MKAKAMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 354 (bronze / identify) +# tile 358 (bronze / identify) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6759,7 +6835,7 @@ P = (108, 145, 182) MMMMMMMCCCAAMMMM MMMMMMMMMMMMMMMM } -# tile 355 (copper / turn undead) +# tile 359 (copper / turn undead) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6778,7 +6854,7 @@ P = (108, 145, 182) MMMMMMMJCJAAMMMM MMMMMMMMMMMMMMMM } -# tile 356 (silver / polymorph) +# tile 360 (silver / polymorph) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6797,7 +6873,7 @@ P = (108, 145, 182) MMMMMMMPPPAAMMMM MMMMMMMMMMMMMMMM } -# tile 357 (gold / teleport away) +# tile 361 (gold / teleport away) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6816,7 +6892,7 @@ P = (108, 145, 182) MMMMMMMHHHAAMMMM MMMMMMMMMMMMMMMM } -# tile 358 (glittering / create familiar) +# tile 362 (glittering / create familiar) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6835,7 +6911,7 @@ P = (108, 145, 182) MMMMMMMPPPANMMMM MMMMMMMNMMMMMMMM } -# tile 359 (shining / cancellation) +# tile 363 (shining / cancellation) { MMMMNMMMMMMMMMMM MMMMMMMNMMMMMMMM @@ -6854,7 +6930,7 @@ P = (108, 145, 182) MMMMMMMPPPAAMMMM MMMMMMMMMMMMMMMM } -# tile 360 (dull / protection) +# tile 364 (dull / protection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6873,7 +6949,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 361 (thin / jumping) +# tile 365 (thin / jumping) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6892,7 +6968,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 362 (thick / stone to flesh) +# tile 366 (thick / stone to flesh) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6911,7 +6987,7 @@ P = (108, 145, 182) MMMMMMMJJJAAMMMM MMMMMMMMMMMMMMMM } -# tile 363 (plain / blank paper) +# tile 367 (plain / blank paper) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6949,7 +7025,6 @@ P = (108, 145, 182) MMMMMMMEEEAAMMMM MMMMMMMMMMMMMMMM } -# tile 364 (papyrus / Book of the Dead) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6968,7 +7043,7 @@ P = (108, 145, 182) MMMMMMMAAAMMMMMM MMMMMMMMMMMMMMMM } -# tile 365 (glass / light) +# tile 369 (glass / light) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -6987,7 +7062,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 366 (balsa / secret door detection) +# tile 370 (balsa / secret door detection) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7006,7 +7081,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 367 (crystal / enlightenment) +# tile 371 (crystal / enlightenment) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7025,7 +7100,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 368 (maple / create monster) +# tile 372 (maple / create monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7044,7 +7119,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 369 (pine / wishing) +# tile 373 (pine / wishing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7063,7 +7138,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 370 (oak / nothing) +# tile 374 (oak / nothing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7082,7 +7157,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 371 (ebony / striking) +# tile 375 (ebony / striking) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7101,7 +7176,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 372 (marble / make invisible) +# tile 376 (marble / make invisible) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7120,7 +7195,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 373 (tin / slow monster) +# tile 377 (tin / slow monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7139,7 +7214,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 374 (brass / speed monster) +# tile 378 (brass / speed monster) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7158,7 +7233,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 375 (copper / undead turning) +# tile 379 (copper / undead turning) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7177,7 +7252,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 376 (silver / polymorph) +# tile 380 (silver / polymorph) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7196,7 +7271,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 377 (platinum / cancellation) +# tile 381 (platinum / cancellation) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7215,7 +7290,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 378 (iridium / teleportation) +# tile 382 (iridium / teleportation) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7234,7 +7309,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 379 (zinc / opening) +# tile 383 (zinc / opening) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7253,7 +7328,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 380 (aluminum / locking) +# tile 384 (aluminum / locking) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7272,7 +7347,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 381 (uranium / probing) +# tile 385 (uranium / probing) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7291,7 +7366,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 382 (iron / digging) +# tile 386 (iron / digging) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7310,7 +7385,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 383 (steel / magic missile) +# tile 387 (steel / magic missile) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7329,7 +7404,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 384 (hexagonal / fire) +# tile 388 (hexagonal / fire) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7348,7 +7423,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 385 (short / cold) +# tile 389 (short / cold) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7367,7 +7442,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 386 (runed / sleep) +# tile 390 (runed / sleep) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7386,7 +7461,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 387 (long / death) +# tile 391 (long / death) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMNOM @@ -7405,7 +7480,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 388 (curved / lightning) +# tile 392 (curved / lightning) { MMMMMMMMMMMMMMMM MMMMMMMNOMMMMMMM @@ -7424,7 +7499,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 389 (forked) +# tile 393 (forked) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7443,7 +7518,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 390 (spiked) +# tile 394 (spiked) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7462,7 +7537,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 391 (jeweled) +# tile 395 (jeweled) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7481,7 +7556,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 392 (gold piece) +# tile 396 (gold piece) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7500,7 +7575,7 @@ P = (108, 145, 182) MMMMMMMMMHAMMMMM MMMMMMMMMMMHAMMM } -# tile 393 (white / dilithium crystal) +# tile 397 (white / dilithium crystal) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7519,7 +7594,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 394 (white / diamond) +# tile 398 (white / diamond) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7538,7 +7613,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 395 (red / ruby) +# tile 399 (red / ruby) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7557,7 +7632,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 396 (orange / jacinth) +# tile 400 (orange / jacinth) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7576,7 +7651,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 397 (blue / sapphire) +# tile 401 (blue / sapphire) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7595,7 +7670,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 398 (black / black opal) +# tile 402 (black / black opal) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7614,7 +7689,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 399 (green / emerald) +# tile 403 (green / emerald) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7633,7 +7708,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 400 (green / turquoise) +# tile 404 (green / turquoise) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7652,7 +7727,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 401 (yellow / citrine) +# tile 405 (yellow / citrine) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7671,7 +7746,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 402 (green / aquamarine) +# tile 406 (green / aquamarine) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7690,7 +7765,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 403 (yellowish brown / amber) +# tile 407 (yellowish brown / amber) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7709,7 +7784,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 404 (yellowish brown / topaz) +# tile 408 (yellowish brown / topaz) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7728,7 +7803,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 405 (black / jet) +# tile 409 (black / jet) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7747,7 +7822,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 406 (white / opal) +# tile 410 (white / opal) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7766,7 +7841,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 407 (yellow / chrysoberyl) +# tile 411 (yellow / chrysoberyl) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7785,7 +7860,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 408 (red / garnet) +# tile 412 (red / garnet) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7804,7 +7879,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 409 (violet / amethyst) +# tile 413 (violet / amethyst) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7823,7 +7898,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 410 (red / jasper) +# tile 414 (red / jasper) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7842,7 +7917,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 411 (violet / fluorite) +# tile 415 (violet / fluorite) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7861,7 +7936,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 412 (black / obsidian) +# tile 416 (black / obsidian) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7880,7 +7955,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 413 (orange / agate) +# tile 417 (orange / agate) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7899,7 +7974,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 414 (green / jade) +# tile 418 (green / jade) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7918,7 +7993,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 415 (white / worthless piece of white glass) +# tile 419 (white / worthless piece of white glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7937,7 +8012,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 416 (blue / worthless piece of blue glass) +# tile 420 (blue / worthless piece of blue glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7956,7 +8031,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 417 (red / worthless piece of red glass) +# tile 421 (red / worthless piece of red glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7975,7 +8050,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 418 (yellowish brown / worthless piece of yellowish brown glass) +# tile 422 (yellowish brown / worthless piece of yellowish brown glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -7994,7 +8069,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 419 (orange / worthless piece of orange glass) +# tile 423 (orange / worthless piece of orange glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8013,7 +8088,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 420 (yellow / worthless piece of yellow glass) +# tile 424 (yellow / worthless piece of yellow glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8032,7 +8107,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 421 (black / worthless piece of black glass) +# tile 425 (black / worthless piece of black glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8051,7 +8126,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 422 (green / worthless piece of green glass) +# tile 426 (green / worthless piece of green glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8070,7 +8145,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 423 (violet / worthless piece of violet glass) +# tile 427 (violet / worthless piece of violet glass) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8089,7 +8164,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 424 (gray / luckstone) +# tile 428 (gray / luckstone) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8108,7 +8183,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 425 (gray / loadstone) +# tile 429 (gray / loadstone) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8127,7 +8202,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 426 (gray / touchstone) +# tile 430 (gray / touchstone) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8146,7 +8221,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 427 (gray / flint) +# tile 431 (gray / flint) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8165,7 +8240,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 428 (rock) +# tile 432 (rock) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8184,7 +8259,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 429 (boulder) +# tile 433 (boulder) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8203,7 +8278,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 430 (statue) +# tile 434 (statue) { MMMMMMMMMMMMMMMM MMMMMMMMJJMMMMMM @@ -8222,7 +8297,7 @@ P = (108, 145, 182) MMMMMJJJJJJAAMMM MMMMMMMMMMMMMMMM } -# tile 431 (heavy iron ball) +# tile 435 (heavy iron ball) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8241,7 +8316,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 432 (iron chain) +# tile 436 (iron chain) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8260,7 +8335,7 @@ P = (108, 145, 182) MMMMMMMMMMMPPMPA MMMMMMMMMMMMAAMM } -# tile 433 (splash of venom / blinding venom) +# tile 437 (splash of venom / blinding venom) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM @@ -8279,7 +8354,7 @@ P = (108, 145, 182) MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM } -# tile 434 (splash of venom / acid venom) +# tile 438 (splash of venom / acid venom) { MMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMM diff --git a/win/share/renumtiles.pl b/win/share/renumtiles.pl new file mode 100644 index 000000000..0220484e2 --- /dev/null +++ b/win/share/renumtiles.pl @@ -0,0 +1,87 @@ +#!/bin/perl +# +# $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ +# $Date: 2002/01/05 21:06:02 $ $Revision: 1.1 $ +# + +sub bail($); + +use Getopt::Std; + +# TODO: switch to Getopt::Long so we can parse normal arguments too +$Getopt::Std::STANDARD_HELP_VERSION = TRUE; +$main::VERSION = 1.0; + +my %commands = ( + 'd' => 'debug mode; parse objects.txt to stdout instead of updating', +); + +getopts(join('', keys(%commands))); + +my $debug = (defined($opt_d) && $opt_d == 1); +my $tilecount = 0; +my $outfile = $debug ? "-" : "objects.txt"; +my $infile = $debug ? "objects.txt" : "objects.bak"; + + +unless ($debug) { + if (-e "$infile") { die "something didn't clean up objects.bak from last time; stopping\n"; } + rename($outfile,$infile) or die "couldn't move objects.txt to objects.bak; stopping\n"; +} + +open(INFILE, "<$infile") or bail("couldn't open $infile; bailing"); +open(OUTFILE, ">$outfile") or bail("couldn't open $outfile; bailing"); + +while (my $line = ) +{ + if (my ($tiletext) = $line =~ /^# tile \d+ (.*)/) + { + $line = "# tile $tilecount $tiletext\n"; + $tilecount++; + } + + print OUTFILE $line; +} + +close(INFILE); +close(OUTFILE); + +unless ($debug) { unlink $infile; } + +exit; + +sub main::HELP_MESSAGE() +{ + print <<"STARTHELP"; +Usage: renumtiles.pl [OPTIONS] + +STARTHELP + foreach $cmd (keys(%commands)) { + printf("%10s %s\n", '-'.$cmd, $commands{$cmd}); + } + print <<"ENDHELP"; + +\t--help display this help message and exit +\t--version display version and exit +ENDHELP + exit; +} + +sub main::VERSION_MESSAGE() +{ + my ($objglob, $optpackage, $ver, $switches) = @_; + print <<"STARTHELP"; +renumtiles $ver -- tile-renumbering utility for NetHack +STARTHELP +} + +sub bail($) +{ + unless ($debug) { + unlink $outfile; + rename ($infile,$outfile); + } + shift; + die "$_\n"; +} + diff --git a/win/tty/wintty.c b/win/tty/wintty.c index bcf4041e0..3a531d0f1 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1,4 +1,4 @@ -/* NetHack 3.5 wintty.c $NHDT-Date: 1428394244 2015/04/07 08:10:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.84 $ */ +/* NetHack 3.5 wintty.c $NHDT-Date: 1428828474 2015/04/12 08:47:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.85 $ */ /* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -1664,20 +1664,24 @@ struct WinDesc *cw; tty_nhbell(); break; } else { - char searchbuf[BUFSZ], tmpbuf[BUFSZ]; + char searchbuf[BUFSZ+2], tmpbuf[BUFSZ]; boolean on_curr_page = FALSE; int lineno = 0; + tty_getlin("Search for:", tmpbuf); if (!tmpbuf[0] || tmpbuf[0] == '\033') break; Sprintf(searchbuf, "*%s*", tmpbuf); + for (curr = cw->mlist; curr; curr = curr->next) { if (on_curr_page) lineno++; if (curr == page_start) on_curr_page = TRUE; else if (curr == page_end) on_curr_page = FALSE; - if (curr->identifier.a_void && pmatch(searchbuf, curr->str)) { - toggle_menu_curr(window, curr, lineno, on_curr_page, counting, count); + if (curr->identifier.a_void + && pmatchi(searchbuf, curr->str)) { + toggle_menu_curr(window, curr, lineno, + on_curr_page, counting, count); if (cw->how == PICK_ONE) { finished = TRUE; break;