Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site amdahl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!amdahl!gam From: gam@amdahl.UUCP (gam) Newsgroups: net.sources Subject: hack: changes for SVR2 (1 of 3) Message-ID: <873@amdahl.UUCP> Date: Sun, 6-Jan-85 04:16:27 EST Article-I.D.: amdahl.873 Posted: Sun Jan 6 04:16:27 1985 Date-Received: Tue, 8-Jan-85 02:47:09 EST Distribution: net Organization: Blue Mouse Trailer Resort, Hellmouth, CA Lines: 1117 I have gotten hack to compile successfully under Sys V Rel 2 and the three shars following are the files with relevant changes. Hack has not been played extensively here so I don't know how well I have debugged it. Among other things, I have used the System V 'drand48(3)' routines for random number generation. Also some "linting" has been done. If you have any problems, post them to net.sources.bugs. ------------------- close cover before striking match ------------------ : This is a shar archive. Extract with sh, not csh. echo x - hack.do.c sed -e 's/^X//' > hack.do.c << '!Funky!Stuff!' X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ X X#includeX#include X#include "hack.h" X#include "def.func_tab.h" X Xextern char *getenv(),*parse(),*getlogin(),*lowc(),*unctrl(); Xextern int float_down(); Xextern char *nomovemsg, *catmore; Xextern struct obj *splitobj(), *addinv(); Xextern boolean hmon(); X X/* Routines to do various user commands */ X Xint done1(); X Xdodrink() { X register struct obj *otmp,*objs; X register struct monst *mtmp; X register int unkn = 0, nothing = 0; X X otmp = getobj("!", "drink"); X if(!otmp) return(0); X switch(otmp->otyp){ X case POT_RESTORE_STRENGTH: X unkn++; X pline("Wow! This makes you feel great!"); X if(u.ustr < u.ustrmax) { X u.ustr = u.ustrmax; X flags.botl = 1; X } X break; X case POT_BOOZE: X unkn++; X pline("Ooph! This tastes like liquid fire!"); X Confusion += d(3,8); X /* the whiskey makes us feel better */ X if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey"); X if(!rn2(4)) { X pline("You pass out."); X multi = -rnd(15); X nomovemsg = "You awake with a headache."; X } X break; X case POT_INVISIBILITY: X if(Invis) X nothing++; X else { X if(!Blind) X pline("Gee! All of a sudden, you can't see yourself."); X else X pline("You feel rather airy."), unkn++; X newsym(u.ux,u.uy); X } X Invis += rn1(15,31); X break; X case POT_FRUIT_JUICE: X pline("This tastes like fruit juice."); X lesshungry(20); X break; X case POT_HEALING: X pline("You begin to feel better."); X flags.botl = 1; X u.uhp += rnd(10); X if(u.uhp > u.uhpmax) X u.uhp = ++u.uhpmax; X if(Blind) Blind = 1; /* see on next move */ X if(Sick) Sick = 0; X break; X case POT_PARALYSIS: X pline("Your feet are frozen to the floor!"); X nomul(-(rn1(10,25))); X break; X case POT_MONSTER_DETECTION: X if(!fmon) { X strange_feeling(otmp); X return(1); X } else { X cls(); X for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) X if(mtmp->mx > 0) X at(mtmp->mx,mtmp->my,mtmp->data->mlet); X prme(); X pline("You sense the presence of monsters."); X more(); X docrt(); X } X break; X case POT_OBJECT_DETECTION: X if(!fobj) { X strange_feeling(otmp); X return(1); X } else { X for(objs = fobj; objs; objs = objs->nobj) X if(objs->ox != u.ux || objs->oy != u.uy) X goto outobjmap; X pline("You sense the presence of objects close nearby."); X break; X outobjmap: X cls(); X for(objs = fobj; objs; objs = objs->nobj) X at(objs->ox,objs->oy,objs->olet); X prme(); X pline("You sense the presence of objects."); X more(); X docrt(); X } X break; X case POT_SICKNESS: X pline("Yech! This stuff tastes like poison."); X if(Poison_resistance) X pline("(But in fact it was biologically contaminated orange juice.)"); X losestr(rn1(4,3)); X losehp(rnd(10), "poison potion"); X break; X case POT_CONFUSION: X if(!Confusion) X pline("Huh, What? Where am I?"); X else X nothing++; X Confusion += rn1(7,16); X break; X case POT_GAIN_STRENGTH: X pline("Wow do you feel strong!"); X if(u.ustr == 118) break; X if(u.ustr > 17) u.ustr += rnd(118-u.ustr); X else u.ustr++; X if(u.ustr > u.ustrmax) u.ustrmax = u.ustr; X flags.botl = 1; X break; X case POT_SPEED: X if(Wounded_legs) { X if((Wounded_legs & BOTH_SIDES) == BOTH_SIDES) X pline("Your legs feel somewhat better."); X else X pline("Your leg feels somewhat better."); X Wounded_legs = 0; X unkn++; X break; X } X if(!(Fast & ~INTRINSIC)) X pline("You are suddenly moving much faster."); X else X pline("Your legs get new energy."), unkn++; X Fast += rn1(10,100); X break; X case POT_BLINDNESS: X if(!Blind) X pline("A cloud of darkness falls upon you."); X else X nothing++; X Blind += rn1(100,250); X seeoff(0); X break; X case POT_GAIN_LEVEL: X pluslvl(); X break; X case POT_EXTRA_HEALING: X pline("You feel much better."); X flags.botl = 1; X u.uhp += d(2,20)+1; X if(u.uhp > u.uhpmax) X u.uhp = (u.uhpmax += 2); X if(Blind) Blind = 1; X if(Sick) Sick = 0; X break; X case POT_LEVITATION: X if(!Levitation) X float_up(); X else X nothing++; X Levitation += rnd(100); X u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down; X break; X default: X pline("What a funny potion! (%d)", otmp->otyp); X impossible(); X return(0); X } X if(nothing) { X unkn++; X pline("You have a peculiar feeling for a moment, then it passes."); X } X if(otmp->dknown && !objects[otmp->otyp].oc_name_known) { X if(!unkn) { X objects[otmp->otyp].oc_name_known = 1; X u.urexp += 10; X } else if(!objects[otmp->otyp].oc_uname) X docall(otmp); X } X useup(otmp); X return(1); X} X Xpluslvl() X{ X register num; X X pline("You feel more experienced."); X num = rnd(10); X u.uhpmax += num; X u.uhp += num; X u.uexp = (10*pow(u.ulevel-1))+1; X pline("Welcome to level %d.", ++u.ulevel); X flags.botl = 1; X} X Xstrange_feeling(obj) Xregister struct obj *obj; X{ X pline("You have a strange feeling for a moment, then it passes."); X if(!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname) X docall(obj); X useup(obj); X} X Xdodrop() { X register struct obj *obj; X X obj = getobj("0$#", "drop"); X if(!obj) return(0); X if(obj->olet == '$') { X if(obj->quan == 0) X pline("You didn't drop any gold pieces."); X else { X mkgold((int) obj->quan, u.ux, u.uy); X pline("You dropped %u gold piece%s.", X obj->quan, plur(obj->quan)); X if(Invis) newsym(u.ux, u.uy); X } X free((char *) obj); X return(1); X } X return(drop(obj)); X} X Xdrop(obj) register struct obj *obj; { X if(obj->owornmask & (W_ARMOR | W_RING)){ X pline("You cannot drop something you are wearing."); X return(0); X } X if(obj == uwep) { X if(uwep->cursed) { X pline("Your weapon is welded to your hand!"); X return(0); X } X setuwep((struct obj *) 0); X } X pline("You dropped %s.", doname(obj)); X dropx(obj); X return(1); X} X Xdropx(obj) register struct obj *obj; { X if(obj->otyp == CRYSKNIFE) X obj->otyp = WORM_TOOTH; X freeinv(obj); X obj->ox = u.ux; X obj->oy = u.uy; X obj->nobj = fobj; X fobj = obj; X if(Invis) newsym(u.ux,u.uy); X subfrombill(obj); X stackobj(obj); X} X X/* drop several things */ Xdoddrop() { X return(ggetobj("drop", drop, 0)); X} X Xrhack(cmd) Xregister char *cmd; X{ X register struct func_tab *tlist = list; X boolean firsttime = FALSE; X register res; X X if(!cmd) { X firsttime = TRUE; X flags.nopick = 0; X cmd = parse(); X } X if(!*cmd || *cmd == 0377) X return; /* probably we just had an interrupt */ X if(movecm(cmd)) { X walk: X if(multi) flags.mv = 1; X domove(); X return; X } X if(movecm(lowc(cmd))) { X flags.run = 1; X rush: X if(firsttime){ X if(!multi) multi = COLNO; X u.last_str_turn = 0; X } X flags.mv = 1; X#ifdef QUEST X if(flags.run >= 4) finddir(); X if(firsttime){ X u.ux0 = u.ux + u.dx; X u.uy0 = u.uy + u.dy; X } X#endif QUEST X domove(); X return; X } X if((*cmd == 'f' && movecm(cmd+1)) || X movecm(unctrl(cmd))) { X flags.run = 2; X goto rush; X } X if(*cmd == 'F' && movecm(lowc(cmd+1))) { X flags.run = 3; X goto rush; X } X if(*cmd == 'm' && movecm(cmd+1)) { X flags.run = 0; X flags.nopick = 1; X goto walk; X } X if(*cmd == 'M' && movecm(lowc(cmd+1))) { X flags.run = 1; X flags.nopick = 1; X goto rush; X } X#ifdef QUEST X if(*cmd == cmd[1] && (*cmd == 'f' || *cmd == 'F')) { X flags.run = 4; X if(*cmd == 'F') flags.run += 2; X if(cmd[2] == '-') flags.run += 1; X goto rush; X } X#endif QUEST X while(tlist->f_char) { X if(*cmd == tlist->f_char){ X res = (*(tlist->f_funct))(0); X if(!res) { X flags.move = 0; X multi = 0; X } X return; X } X tlist++; X } X pline("Unknown command '%s'",cmd); X multi = flags.move = 0; X} X Xdoredraw() X{ X docrt(); X return(0); X} X Xdohelp() X{ X if(child(1)){ X execl(catmore,"more","help",(char *)0); X exit(1); X } X return(0); X} X X#ifdef SHELL Xdosh(){ Xregister char *str; X if(child(0)) { X (void) chdir(getenv("HOME")); X if(str = getenv("SHELL")) execl(str,str,(char *) 0); X if(strcmp("player", getlogin())) X execl("/bin/sh","sh",(char *) 0); X pline("sh: cannot execute."); X exit(1); X } X return(0); X} X#endif SHELL X X#ifdef BSD X#include X#endif BSD X Xchild(wt) { Xregister int f = fork(); X if(f == 0){ /* child */ X settty((char *) 0); X (void) setuid(getuid()); X return(1); X } X if(f == -1) { /* cannot fork */ X pline("Fork failed. Try again."); X return(0); X } X /* fork succeeded; wait for child to exit */ X (void) signal(SIGINT,SIG_IGN); X (void) signal(SIGQUIT,SIG_IGN); X#ifdef BSD X (void) wait((union wait *) 0); X#else X (void) wait((int *) 0); X#endif BSD X setctty(); X (void) signal(SIGINT, (void (*)()) done1); X#ifdef WIZARD X if(wizard) (void) signal(SIGQUIT,SIG_DFL); X#endif WIZARD X if(wt) getret(); X docrt(); X return(0); X} X Xdodown() X{ X if(u.ux != xdnstair || u.uy != ydnstair) { X pline("You can't go down here."); X return(0); X } X if(u.ustuck) { X pline("You are being held, and cannot go down."); X return(1); X } X if(Levitation) { X pline("You're floating high above the stairs."); X return(0); X } X X goto_level(dlevel+1, TRUE); X return(1); X} X Xdoup() X{ X if(u.ux != xupstair || u.uy != yupstair) { X pline("You can't go up here."); X return(0); X } X if(u.ustuck) { X pline("You are being held, and cannot go up."); X return(1); X } X if(inv_weight() + 5 > 0) { X pline("Your load is too heavy to climb the stairs."); X return(1); X } X X goto_level(dlevel-1, TRUE); X return(1); X} X Xgoto_level(newlevel, at_stairs) Xregister int newlevel; Xregister boolean at_stairs; X{ X register fd; X register boolean up = (newlevel < dlevel); X X if(newlevel <= 0) done("escaped"); /* in fact < 0 is impossible */ X if(newlevel == dlevel) return; /* this cannot happen either */ X X glo(dlevel); X fd = creat(lock,FMASK); X if(fd < 0) { X /* X * This is not quite impossible: e.g., we may have X * exceeded our quota. If that is the case then we X * cannot leave this level, and cannot save either. X */ X pline("A mysterious force prevents you from going %d.", X up ? "up" : "down"); X return; X } X X if(Punished) unplacebc(); X keepdogs(); X seeoff(1); X flags.nscrinh = 1; X u.ux = FAR; /* hack */ X (void) inshop(); /* probably was a trapdoor */ X X savelev(fd); X (void) close(fd); X X dlevel = newlevel; X if(maxdlevel < dlevel) X maxdlevel = dlevel; X glo(dlevel); X if((fd = open(lock,0)) < 0) X mklev(); X else { X (void) getlev(fd); X (void) close(fd); X } X X if(at_stairs) { X if(up) { X u.ux = xdnstair; X u.uy = ydnstair; X if(!u.ux) { /* entering a maze from below? */ X u.ux = xupstair; /* this will confuse the player! */ X u.uy = yupstair; X } X if(Punished){ X pline("With great effort you climb the stairs"); X placebc(1); X } X } else { X u.ux = xupstair; X u.uy = yupstair; X if(inv_weight() + 5 > 0 || Punished){ X pline("You fall down the stairs."); X losehp(rnd(3), "fall"); X if(Punished) { X if(uwep != uball && rn2(3)){ X pline("... and are hit by the iron ball"); X losehp(rnd(20), "iron ball"); X } X placebc(1); X } X selftouch("Falling, you"); X } X } X } else { /* trapdoor or level_tele */ X do { X u.ux = rnd(COLNO-1); X u.uy = rn2(ROWNO); X } while(levl[u.ux][u.uy].typ != ROOM || X m_at(u.ux,u.uy)); X if(Punished){ X if(uwep != uball && !up /* %% */ && rn2(5)){ X pline("The iron ball falls on your head."); X losehp(rnd(25), "iron ball"); X } X placebc(1); X } X selftouch("Falling, you"); X } X (void) inshop(); X#ifdef TRACK X initrack(); X#endif TRACK X X losedogs(); X flags.nscrinh = 0; X setsee(); X docrt(); X pickup(); X read_engr_at(u.ux,u.uy); X} X Xdonull() { X return(1); /* Do nothing, but let other things happen */ X} X Xstruct monst *bhit(), *boomhit(); Xdothrow() X{ X register struct obj *obj; X register struct monst *mon; X register tmp; X X obj = getobj("#)", "throw"); /* it is also possible to throw food */ X /* (or jewels, or iron balls ... ) */ X if(!obj || !getdir()) X return(0); X if(obj->owornmask & (W_ARMOR | W_RING)){ X pline("You can't throw something you are wearing"); X return(0); X } X if(obj == uwep){ X if(obj->cursed){ X pline("Your weapon is welded to your hand"); X return(1); X } X if(obj->quan > 1) X setuwep(splitobj(obj, 1)); X else X setuwep((struct obj *) 0); X } X else if(obj->quan > 1) X (void) splitobj(obj, 1); X freeinv(obj); X if(u.uswallow) { X mon = u.ustuck; X bhitpos.x = mon->mx; X bhitpos.y = mon->my; X } else if(obj->otyp == BOOMERANG) { X mon = boomhit(u.dx,u.dy); X /* boomhit delivers -1 if the thing was caught */ X if((int) mon == -1) { X (void) addinv(obj); X return(1); X } X } else X mon = bhit(u.dx,u.dy, X (!Punished || obj != uball) ? 8 : X !u.ustuck ? 5 : 1, X obj->olet); X if(mon) { X /* awake monster if sleeping */ X wakeup(mon); X X if(obj->olet == WEAPON_SYM) { X tmp = -1+u.ulevel+mon->data->ac+abon(); X if(obj->otyp < ROCK) { X if(!uwep || X uwep->otyp != obj->otyp+(BOW-ARROW)) X tmp -= 4; X else { X tmp += uwep->spe; X } X } else X if(obj->otyp == BOOMERANG) tmp += 4; X tmp += obj->spe; X if(u.uswallow || tmp >= rnd(20)) { X if(hmon(mon,obj,1) == TRUE){ X /* mon still alive */ X#ifndef NOWORM X cutworm(mon,bhitpos.x,bhitpos.y,obj->otyp); X#endif NOWORM X } else mon = 0; X /* weapons thrown disappear sometimes */ X if(obj->otyp < BOOMERANG && rn2(3)) { X /* check bill; free */ X obfree(obj, (struct obj *) 0); X return(1); X } X } else miss(objects[obj->otyp].oc_name, mon); X } else if(obj->otyp == HEAVY_IRON_BALL) { X tmp = -1+u.ulevel+mon->data->ac+abon(); X if(!Punished || obj != uball) tmp += 2; X if(u.utrap) tmp -= 2; X if(u.uswallow || tmp >= rnd(20)) { X if(hmon(mon,obj,1) == FALSE) X mon = 0; /* he died */ X } else miss("iron ball", mon); X } else { X if(cansee(bhitpos.x,bhitpos.y)) X pline("You miss %s.",monnam(mon)); X else pline("You miss it."); X if(obj->olet == FOOD_SYM && mon->data->mlet == 'd') X if(tamedog(mon,obj)) return(1); X if(obj->olet == GEM_SYM && mon->data->mlet == 'u'){ X if(obj->dknown && objects[obj->otyp].oc_name_known){ X if(objects[obj->otyp].g_val > 0){ X u.uluck += 5; X goto valuable; X } else { X pline("%s is not interested in your junk.", X Monnam(mon)); X } X } else { /* value unknown to @ */ X u.uluck++; X valuable: X pline("%s graciously accepts your gift.", X Monnam(mon)); X mpickobj(mon, obj); X rloc(mon); X return(1); X } X } X } X } X obj->ox = bhitpos.x; X obj->oy = bhitpos.y; X obj->nobj = fobj; X fobj = obj; X /* prevent him from throwing articles to the exit and escaping */ X /* subfrombill(obj); */ X stackobj(obj); X if(Punished && obj == uball && X (bhitpos.x != u.ux || bhitpos.y != u.uy)){ X freeobj(uchain); X unpobj(uchain); X if(u.utrap){ X if(u.utraptype == TT_PIT) X pline("The ball pulls you out of the pit!"); X else { X register int side = X rn2(3) ? LEFT_SIDE : RIGHT_SIDE; X pline("The ball pulls you out of the bear trap."); X pline("Your %s leg is severely damaged.", X (side == LEFT_SIDE) ? "left" : "right"); X Wounded_legs |= side + rnd(1000); X losehp(2, "thrown ball"); X } X u.utrap = 0; X } X unsee(); X uchain->nobj = fobj; X fobj = uchain; X u.ux = uchain->ox = bhitpos.x - u.dx; X u.uy = uchain->oy = bhitpos.y - u.dy; X setsee(); X (void) inshop(); X } X if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y); X return(1); X} X Xgetdir() X{ Xchar buf[2]; X pline("What direction?"); X buf[0] = readchar(); X buf[1] = 0; X return(movecm(buf)); X} X X/* split obj so that it gets size num */ X/* remainder is put in the object structure delivered by this call */ Xstruct obj * Xsplitobj(obj, num) register struct obj *obj; register int num; { Xregister struct obj *otmp; X otmp = newobj(0); X *otmp = *obj; /* copies whole structure */ X otmp->o_id = flags.ident++; X otmp->onamelth = 0; X obj->quan = num; X obj->owt = weight(obj); X otmp->quan -= num; X otmp->owt = weight(otmp); /* -= obj->owt ? */ X obj->nobj = otmp; X if(obj->unpaid) splitbill(obj,otmp); X return(otmp); X} X Xchar * Xlowc(str) Xregister char *str; X{ X static char buf[2]; X X if(*str >= 'A' && *str <= 'Z') *buf = *str+'a'-'A'; X else *buf = *str; X buf[1] = 0; X return(buf); X} X Xchar * Xunctrl(str) Xregister char *str; X{ X static char buf[2]; X if(*str >= ('A' & 037) && *str <= ('Z' & 037)) X *buf = *str + 0140; X else *buf = *str; X buf[1] = 0; X return(buf); X} !Funky!Stuff! echo x - hack.h sed -e 's/^X//' > hack.h << '!Funky!Stuff!' X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ X X#include "mklev.h" X#include "hack.onames.h" X X#define ON 1 X#define OFF 0 X X#define index strchr X Xextern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg, X *uleft, *uright, *fcobj; Xextern struct obj *uchain; /* defined iff PUNISHED */ Xextern struct obj *uball; /* defined if PUNISHED */ Xstruct obj *o_at(), *getobj(), *sobj_at(); X Xstruct flag { X unsigned ident; /* social security number for each monster */ X unsigned topl:2; /* a top line (message) has been printed */ X /* 0: top line empty; 2: no --More-- reqd. */ X unsigned cbreak:1; /* in cbreak mode, rogue format */ X unsigned oneline:1; /* give inventories 1 line at a time */ X unsigned move:1; X unsigned mv:1; X unsigned run:3; /* 0: h (etc), 1: H (etc), 2: fh (etc) */ X /* 3: FH, 4: ff+, 5: ff-, 6: FF+, 7: FF- */ X unsigned nopick:1; /* do not pickup objects */ X unsigned echo:1; /* 1 to echo characters */ X unsigned botl:1; /* partially redo status line */ X unsigned botlx:1; /* print an entirely new bottom line */ X unsigned nscrinh:1; /* inhibit nscr() in pline(); */ X}; Xextern struct flag flags; X Xstruct prop { X#define TIMEOUT 007777 /* mask */ X#define LEFT_RING W_RINGL /* 010000L */ X#define RIGHT_RING W_RINGR /* 020000L */ X#define INTRINSIC 040000L X#define LEFT_SIDE LEFT_RING X#define RIGHT_SIDE RIGHT_RING X#define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE) X long p_flgs; X int (*p_tofn)(); /* called after timeout */ X}; X Xstruct you { X xchar ux, uy; X schar dx, dy; /* direction of fast move */ X#ifdef QUEST X schar di; /* direction of FF */ X xchar ux0, uy0; /* initial position FF */ X#endif QUEST X xchar udisx, udisy; /* last display pos */ X char usym; /* usually '@' */ X schar uluck; X int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */ X /* +: turn right, -: turn left */ X unsigned udispl:1; /* @ on display */ X unsigned ulevel:5; X#ifdef QUEST X unsigned uhorizon:7; X#endif QUEST X unsigned utrap:3; /* trap timeout */ X unsigned utraptype:1; /* defined if utrap nonzero */ X#define TT_BEARTRAP 0 X#define TT_PIT 1 X unsigned uinshop:1; X X X/* perhaps these #define's should also be generated by makedefs */ X#define TELEPAT LAST_RING /* not a ring */ X#define Telepat u.uprops[TELEPAT].p_flgs X#define FAST (LAST_RING+1) /* not a ring */ X#define Fast u.uprops[FAST].p_flgs X#define CONFUSION (LAST_RING+2) /* not a ring */ X#define Confusion u.uprops[CONFUSION].p_flgs X#define INVIS (LAST_RING+3) /* not a ring */ X#define Invis u.uprops[INVIS].p_flgs X#define GLIB (LAST_RING+4) /* not a ring */ X#define Glib u.uprops[GLIB].p_flgs X#define PUNISHED (LAST_RING+5) /* not a ring */ X#define Punished u.uprops[PUNISHED].p_flgs X#define SICK (LAST_RING+6) /* not a ring */ X#define Sick u.uprops[SICK].p_flgs X#define BLIND (LAST_RING+7) /* not a ring */ X#define Blind u.uprops[BLIND].p_flgs X#define WOUNDED_LEGS (LAST_RING+8) /* not a ring */ X#define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs X#define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */ X unsigned umconf:1; X char *usick_cause; X struct prop uprops[LAST_RING+9]; X X unsigned uswallow:1; /* set if swallowed by a monster */ X unsigned uswldtim:4; /* time you have been swallowed */ X unsigned uhs:3; /* hunger state - see hack.eat.c */ X schar ustr,ustrmax; X schar udaminc; X schar uac; X int uhp,uhpmax; X long int ugold,ugold0,uexp,urexp; X int uhunger; /* refd only in eat.c and shk.c */ X int uinvault; X struct monst *ustuck; X int nr_killed[CMNUM+2]; /* used for experience bookkeeping */ X}; X Xextern struct you u; X Xextern char *traps[]; Xextern char *plur(), *monnam(), *Monnam(), *amonnam(), *Amonnam(), X *doname(), *aobjnam(); Xextern char readchar(); Xextern char vowels[]; X Xextern xchar curx,cury; /* cursor location on screen */ X Xextern coord bhitpos; /* place where thrown weapon falls to the ground */ X Xextern xchar seehx,seelx,seehy,seely; /* where to see*/ Xextern char *save_cm,*killer; X Xextern xchar dlevel, maxdlevel; /* dungeon level */ X Xextern long moves; X Xextern int multi; X X Xextern char lock[]; X X X#define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2))) X X#define PL_CSIZ 20 /* sizeof pl_character */ X#define MAX_CARR_CAP 120 /* so that boulders can be heavier */ X#define FAR (COLNO+2) /* position outside screen */ X Xextern void exit(), X perror(), X qsort(), X free(); !Funky!Stuff! echo x - hack.lev.c sed -e 's/^X//' > hack.lev.c << '!Funky!Stuff!' X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ X X#include "hack.h" X#include X#include Xextern struct monst *restmonchn(); Xextern struct obj *restobjchn(); Xextern struct obj *billobjs; Xextern char *itoa(); X Xextern char nul[]; X#ifndef NOWORM X#include "def.wseg.h" X Xextern struct wseg *wsegs[32], *wheads[32]; Xextern long wgrowtime[32]; X#endif NOWORM X X#include "savelev.h" X Xgetlev(fd) X{ X register struct gen *gtmp; X#ifndef NOWORM X register struct wseg *wtmp; X#endif NOWORM X register tmp; X long omoves; X X if(fd<0 || read(fd, (char *) levl, sizeof(levl)) != sizeof(levl)) X return(1); X fgold = 0; X ftrap = 0; X mread(fd, (char *)&omoves, sizeof(omoves)); /* 0 from MKLEV */ X mread(fd, (char *)&xupstair, sizeof(xupstair)); X mread(fd, (char *)&yupstair, sizeof(yupstair)); X mread(fd, (char *)&xdnstair, sizeof(xdnstair)); X mread(fd, (char *)&ydnstair, sizeof(ydnstair)); X X fmon = restmonchn(fd); X if(omoves) { X /* regenerate animals while on another level */ X long tmoves = (moves > omoves) ? moves-omoves : 0; X register struct monst *mtmp, *mtmp2; X extern char genocided[]; X X for(mtmp = fmon; mtmp; mtmp = mtmp2) { X mtmp2 = mtmp->nmon; X if(index(genocided, mtmp->data->mlet)) { X mondead(mtmp); X continue; X } X if(index("ViT", mtmp->data->mlet)) X mtmp->mhp += tmoves; X else X mtmp->mhp += tmoves/20; X if(mtmp->mhp > mtmp->orig_hp) X mtmp->mhp = mtmp->orig_hp; X } X } X X setshk(); X setgd(); X gtmp = newgen(); X mread(fd, (char *)gtmp, sizeof(struct gen)); X while(gtmp->gx) { X gtmp->ngen = fgold; X fgold = gtmp; X gtmp = newgen(); X mread(fd, (char *)gtmp, sizeof(struct gen)); X } X mread(fd, (char *)gtmp, sizeof(struct gen)); X while(gtmp->gx) { X gtmp->ngen = ftrap; X ftrap = gtmp; X gtmp = newgen(); X mread(fd, (char *)gtmp, sizeof(struct gen)); X } X free((char *) gtmp); X fobj = restobjchn(fd); X billobjs = restobjchn(fd); X rest_engravings(fd); X#ifndef QUEST X mread(fd, (char *)rooms, sizeof(rooms)); X mread(fd, (char *)doors, sizeof(doors)); X#endif QUEST X if(!omoves) return(0); /* from MKLEV */ X#ifndef NOWORM X mread(fd, (char *)wsegs, sizeof(wsegs)); X for(tmp = 1; tmp < 32; tmp++) if(wsegs[tmp]){ X wheads[tmp] = wsegs[tmp] = wtmp = newseg(); X while(1) { X mread(fd, (char *)wtmp, sizeof(struct wseg)); X if(!wtmp->nseg) break; X wheads[tmp]->nseg = wtmp = newseg(); X wheads[tmp] = wtmp; X } X } X mread(fd, (char *)wgrowtime, sizeof(wgrowtime)); X#endif NOWORM X return(0); X} X Xmread(fd, buf, len) Xregister fd; Xregister char *buf; Xregister unsigned len; X{ Xregister int rlen; X rlen = read(fd, buf, len); X if(rlen != len){ X pline("Read %d instead of %d bytes\n", rlen, len); X panic("Cannot read %d bytes from file #%d\n", len, fd); X } X} X X#ifdef BSD X#include X# define NZ(stat) (stat.w_status != 0) /* non-zero status */ X# define SIG(stat) (stat.w_termsig) /* terminated by signal */ X# define EXIT(stat) (stat.w_retcode) /* non-zero exit code */ X# define CDUMP(stat) (stat.w_coredump) /* dumped core */ X#else X# define NZ(stat) (stat != 0) X# define SIG(stat) ( (stat & 0xff00) ? 0 : (stat & 0x0f) ) X# define EXIT(stat) ( (stat & 0x00ff) ? 0 : ((stat >> 8) & 0x0f) ) X# define CDUMP(stat) (stat & 0200) X#endif BSD X X Xmklev() X{ X register int fd; X int fork_val; X char type[2]; X#ifdef BSD X union wait status; X#else X int status; X#endif BSD X extern char fut_geno[]; X X if(getbones()) return; X if(dlevel < rn1(3, 26)) type[0] = 'a'; /* normal level */ X else type[0] = 'b'; /* maze */ X type[1] = 0; X fork_val = fork(); X switch(fork_val){ X case 0: X (void) signal(SIGINT, SIG_IGN); X (void) signal(SIGQUIT, SIG_IGN); X execl("./mklev", "mklev", lock, type, itoa(dlevel), fut_geno, X#ifdef WIZARD X wizard ? "w" : X#endif WIZARD X "", (char *) 0); X exit(2); X case -1: X settty("Cannot fork!\n"); X exit(1); X default: X (void) fflush(stdout); /* You fell into a trap ... */ X (void) wait(&status); X } X if(NZ(status)) { X if(CDUMP(status)) { X settty("Mklev dumped core. Exiting...\n"); X#ifdef DEBUG Xfprintf(stderr, "signal was %d\n", SIG(status)); X#endif X exit(1); X } X if(SIG(status)) { X settty("Mklev killed by a signal. Exiting...\n"); X exit(1); X } X if(EXIT(status)) { X if(EXIT(status) == 2) { X settty("Cannot execl mklev.\n"); X exit(1); X } X pline("Mklev failed. Let's try again."); X mklev(); X return; X } X } X if((fd = open(lock, 0)) < 0) { X pline("Can't open %s!", lock); X mklev(); X return; X } X (void) getlev(fd); X (void) close(fd); X} !Funky!Stuff! exit -- Gordon A. Moffett ...!{ihnp4,hplabs,sun}!amdahl!gam "Her name was McGill, and she called herself Lil, but everyone knew her as Nancy...."