diff options
author | jkh <jkh@FreeBSD.org> | 1994-09-04 04:03:31 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1994-09-04 04:03:31 +0000 |
commit | 057afceb86e030ad65b0130436860d9a18066186 (patch) | |
tree | a0ced9c9b9278eb776d89cd2565c27ddcf020b51 /games/hack/hack.worn.c | |
parent | eedec95276cdb8aef98e92c5371000f10b8d6ba7 (diff) | |
download | FreeBSD-src-057afceb86e030ad65b0130436860d9a18066186.zip FreeBSD-src-057afceb86e030ad65b0130436860d9a18066186.tar.gz |
Bring in the 4.4 Lite games directory, modulo man page changes and segregation
of the x11 based games. I'm not going to tag the originals with bsd_44_lite
and do this in two stages since it's just not worth it for this collection,
and I've got directory renames to deal with that way. Bleah.
Submitted by: jkh
Diffstat (limited to 'games/hack/hack.worn.c')
-rw-r--r-- | games/hack/hack.worn.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/games/hack/hack.worn.c b/games/hack/hack.worn.c new file mode 100644 index 0000000..bfec47f --- /dev/null +++ b/games/hack/hack.worn.c @@ -0,0 +1,65 @@ +/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ +/* hack.worn.c - version 1.0.2 */ + +#include "hack.h" + +struct worn { + long w_mask; + struct obj **w_obj; +} worn[] = { + { W_ARM, &uarm }, + { W_ARM2, &uarm2 }, + { W_ARMH, &uarmh }, + { W_ARMS, &uarms }, + { W_ARMG, &uarmg }, + { W_RINGL, &uleft }, + { W_RINGR, &uright }, + { W_WEP, &uwep }, + { W_BALL, &uball }, + { W_CHAIN, &uchain }, + { 0, 0 } +}; + +setworn(obj, mask) +register struct obj *obj; +long mask; +{ + register struct worn *wp; + register struct obj *oobj; + + for(wp = worn; wp->w_mask; wp++) if(wp->w_mask & mask) { + oobj = *(wp->w_obj); + if(oobj && !(oobj->owornmask & wp->w_mask)) + impossible("Setworn: mask = %ld.", wp->w_mask); + if(oobj) oobj->owornmask &= ~wp->w_mask; + if(obj && oobj && wp->w_mask == W_ARM){ + if(uarm2) { + impossible("Setworn: uarm2 set?"); + } else + setworn(uarm, W_ARM2); + } + *(wp->w_obj) = obj; + if(obj) obj->owornmask |= wp->w_mask; + } + if(uarm2 && !uarm) { + uarm = uarm2; + uarm2 = 0; + uarm->owornmask ^= (W_ARM | W_ARM2); + } +} + +/* called e.g. when obj is destroyed */ +setnotworn(obj) register struct obj *obj; { + register struct worn *wp; + + for(wp = worn; wp->w_mask; wp++) + if(obj == *(wp->w_obj)) { + *(wp->w_obj) = 0; + obj->owornmask &= ~wp->w_mask; + } + if(uarm2 && !uarm) { + uarm = uarm2; + uarm2 = 0; + uarm->owornmask ^= (W_ARM | W_ARM2); + } +} |