constify channel parameter
[dfdiff.git] / games / hack / hack.worn.c
blob50f3ba12ced929a42a8228e0cfca3e3558ec196c
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 $ */
4 /* $DragonFly: src/games/hack/hack.worn.c,v 1.3 2006/08/21 19:45:32 pavalos Exp $ */
6 #include "hack.h"
8 struct worn {
9 long w_mask;
10 struct obj **w_obj;
11 } worn[] = {
12 { W_ARM, &uarm },
13 { W_ARM2, &uarm2 },
14 { W_ARMH, &uarmh },
15 { W_ARMS, &uarms },
16 { W_ARMG, &uarmg },
17 { W_RINGL, &uleft },
18 { W_RINGR, &uright },
19 { W_WEP, &uwep },
20 { W_BALL, &uball },
21 { W_CHAIN, &uchain },
22 { 0, 0 }
25 void
26 setworn(struct obj *obj, long mask)
28 struct worn *wp;
29 struct obj *oobj;
31 for(wp = worn; wp->w_mask; wp++) 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) oobj->owornmask &= ~wp->w_mask;
36 if(obj && oobj && wp->w_mask == W_ARM){
37 if(uarm2) {
38 impossible("Setworn: uarm2 set?");
39 } else
40 setworn(uarm, W_ARM2);
42 *(wp->w_obj) = obj;
43 if(obj) obj->owornmask |= wp->w_mask;
45 if(uarm2 && !uarm) {
46 uarm = uarm2;
47 uarm2 = 0;
48 uarm->owornmask ^= (W_ARM | W_ARM2);
52 /* called e.g. when obj is destroyed */
53 void
54 setnotworn(struct obj *obj)
56 struct worn *wp;
58 for(wp = worn; wp->w_mask; wp++)
59 if(obj == *(wp->w_obj)) {
60 *(wp->w_obj) = 0;
61 obj->owornmask &= ~wp->w_mask;
63 if(uarm2 && !uarm) {
64 uarm = uarm2;
65 uarm2 = 0;
66 uarm->owornmask ^= (W_ARM | W_ARM2);