2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
24 // structure descriptor fun
25 char *access_bit_names
[] = {
26 "MED", "SCI", "R&D", "CREW", "CARGO",
27 "REC","HYD A","HYD B","HYD D","SHUTTLE",
28 "CRYO", "MED ANNEX", "SECURITY", "BRIDGE", "CARGO2",
29 "CREW2", "RICKENBACHER", "RICK ROOM","OPS OVERRIDE",
32 static sFieldDesc keyinfo_fields
[] =
34 { "MasterBit", kFieldTypeBool
, FieldLocation(sKeyInfo
,master_bit
) },
35 { "RegionID", kFieldTypeBits
, FieldLocation(sKeyInfo
,region_mask
), FullFieldNames(access_bit_names
) },
36 { "LockID", kFieldTypeInt
, FieldLocation(sKeyInfo
,lock_id
), kFieldFlagUnsigned
},
39 static sStructDesc keyinfo_struct
= StructDescBuild(sKeyInfo
,kStructFlagNone
,keyinfo_fields
);
46 // The message that gets broadcast whenever a player gets a new key:
47 static cNetMsg
*g_pAddKeyMsg
= NULL
;
49 // Some other player has gotten a key; I get it too...
50 void handleDPCAddKey(uint region_mask
)
53 AutoAppIPtr(DPCPlayer
);
54 ObjID keyring
= pDPCPlayer
->GetEquip(PlayerObject(), kEquipFakeKeys
);
56 if (!KeySrcProp
->IsRelevant(keyring
)) {
57 Warning(("Object %d doesn't seem to be a key ring!\n", keyring
));
60 KeySrcProp
->Get(keyring
, &skip
);
61 skip
->region_mask
|= region_mask
;
62 KeySrcProp
->Set(keyring
, skip
);
65 static sNetMsgDesc sAddKeyDesc
=
78 BOOL
DPCKeyContainsListener(eContainsEvent event
, ObjID containee
, ObjID new_obj
, eContainType
, ContainCBData
)
81 sKeyInfo
*skip1
, *skip2
;
83 // we only care about combining
84 if ((event
!= kContainQueryCombine
) && (event
!= kContainCombine
))
87 // we only care about keys
88 // is this better done after we filter on event?
89 if (!KeySrcProp
->IsRelevant(containee
) || !KeySrcProp
->IsRelevant(new_obj
))
92 KeySrcProp
->Get(containee
, &skip1
);
93 KeySrcProp
->Get(new_obj
, &skip2
);
97 case kContainQueryCombine
:
98 // only let them merge if their lock_id's are non zero.
99 if ((skip1
->lock_id
!= 0) || (skip2
->lock_id
!= 0))
103 case kContainCombine
:
104 // just binary OR in the bits of the doomed key
105 skip1
->region_mask
= skip2
->region_mask
| skip1
->region_mask
;
106 KeySrcProp
->Set(containee
, skip1
);
107 g_pAddKeyMsg
->Send(OBJ_NULL
, skip2
->region_mask
);
113 void DPCKeyInit(void)
115 AutoAppIPtr(ContainSys
);
116 StructDescRegister(&keyinfo_struct
);
118 pContainSys
->Listen(OBJ_NULL
,DPCKeyContainsListener
,NULL
);
119 g_pAddKeyMsg
= new cNetMsg(&sAddKeyDesc
);
122 void DPCKeyTerm(void)