1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
   2: /* hack.worn.c - version 1.0.2 */
   3: 
   4: #include "hack.h"
   5: 
   6: struct worn {
   7:     long w_mask;
   8:     struct obj **w_obj;
   9: } worn[] = {
  10:     { W_ARM, &uarm },
  11:     { W_ARM2, &uarm2 },
  12:     { W_ARMH, &uarmh },
  13:     { W_ARMS, &uarms },
  14:     { W_ARMG, &uarmg },
  15:     { W_RINGL, &uleft },
  16:     { W_RINGR, &uright },
  17:     { W_WEP, &uwep },
  18:     { W_BALL, &uball },
  19:     { W_CHAIN, &uchain },
  20:     { 0, 0 }
  21: };
  22: 
  23: setworn(obj, mask)
  24: register struct obj *obj;
  25: long mask;
  26: {
  27:     register struct worn *wp;
  28:     register struct obj *oobj;
  29: 
  30:     for(wp = worn; wp->w_mask; wp++) if(wp->w_mask & mask) {
  31:         oobj = *(wp->w_obj);
  32:         if(oobj && !(oobj->owornmask & wp->w_mask))
  33:             impossible("Setworn: mask = %ld.", wp->w_mask);
  34:         if(oobj) oobj->owornmask &= ~wp->w_mask;
  35:         if(obj && oobj && wp->w_mask == W_ARM){
  36:             if(uarm2) {
  37:                 impossible("Setworn: uarm2 set?");
  38:             } else
  39:                 setworn(uarm, W_ARM2);
  40:         }
  41:         *(wp->w_obj) = obj;
  42:         if(obj) obj->owornmask |= wp->w_mask;
  43:     }
  44:     if(uarm2 && !uarm) {
  45:         uarm = uarm2;
  46:         uarm2 = 0;
  47:         uarm->owornmask ^= (W_ARM | W_ARM2);
  48:     }
  49: }
  50: 
  51: /* called e.g. when obj is destroyed */
  52: setnotworn(obj) register struct obj *obj; {
  53:     register struct worn *wp;
  54: 
  55:     for(wp = worn; wp->w_mask; wp++)
  56:         if(obj == *(wp->w_obj)) {
  57:             *(wp->w_obj) = 0;
  58:             obj->owornmask &= ~wp->w_mask;
  59:         }
  60:     if(uarm2 && !uarm) {
  61:         uarm = uarm2;
  62:         uarm2 = 0;
  63:         uarm->owornmask ^= (W_ARM | W_ARM2);
  64:     }
  65: }

Defined functions

setnotworn defined in line 52; used 1 times

Defined variables

worn defined in line 9; used 2 times

Defined struct's

worn defined in line 6; used 4 times
  • in line 27(2), 53(2)
Last modified: 1985-10-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1934
Valid CSS Valid XHTML 1.0 Strict