privatize ldns library (only used for drill(1))
[dragonfly.git] / games / hack / hack.worn.c
bloba754aee2c5d5924c11d8b40c565edb8e52b329dc
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.worn.c - version 1.0.2 */
3 /* $FreeBSD: src/games/hack/hack.worn.c,v 1.3 1999/11/16 02:57:14 billf Exp $ */
5 #include "hack.h"
7 struct worn {
8 long w_mask;
9 struct obj **w_obj;
10 } worn[] = {
11 { W_ARM, &uarm },
12 { W_ARM2, &uarm2 },
13 { W_ARMH, &uarmh },
14 { W_ARMS, &uarms },
15 { W_ARMG, &uarmg },
16 { W_RINGL, &uleft },
17 { W_RINGR, &uright },
18 { W_WEP, &uwep },
19 { W_BALL, &uball },
20 { W_CHAIN, &uchain },
21 { 0, 0 }
24 void
25 setworn(struct obj *obj, long mask)
27 struct worn *wp;
28 struct obj *oobj;
30 for (wp = worn; wp->w_mask; wp++)
31 if (wp->w_mask & mask) {
32 oobj = *(wp->w_obj);
33 if (oobj && !(oobj->owornmask & wp->w_mask))
34 impossible("Setworn: mask = %ld.", wp->w_mask);
35 if (oobj)
36 oobj->owornmask &= ~wp->w_mask;
37 if (obj && oobj && wp->w_mask == W_ARM) {
38 if (uarm2)
39 impossible("Setworn: uarm2 set?");
40 else
41 setworn(uarm, W_ARM2);
43 *(wp->w_obj) = obj;
44 if (obj)
45 obj->owornmask |= wp->w_mask;
47 if (uarm2 && !uarm) {
48 uarm = uarm2;
49 uarm2 = 0;
50 uarm->owornmask ^= (W_ARM | W_ARM2);
54 /* called e.g. when obj is destroyed */
55 void
56 setnotworn(struct obj *obj)
58 struct worn *wp;
60 for (wp = worn; wp->w_mask; wp++)
61 if (obj == *(wp->w_obj)) {
62 *(wp->w_obj) = NULL;
63 obj->owornmask &= ~wp->w_mask;
65 if (uarm2 && !uarm) {
66 uarm = uarm2;
67 uarm2 = 0;
68 uarm->owornmask ^= (W_ARM | W_ARM2);