2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/sim/objloop.cpp,v 1.32 2000/02/19 12:36:58 toml Exp $
44 #include <dbmem.h> // must be last header!
46 /////////////////////////////////////////////////////////////
47 // OBJECT SYSTEM LOOP CLIENT
48 ////////////////////////////////////////////////////////////
50 static IObjectSystem
* ObjSys
;
51 static ILinkManagerInternal
* LinkMan
;
58 #define MY_GUID LOOPID_ObjSys
63 typedef struct _StateRecord
69 ////////////////////////////////////////
70 // VERIFY LINK LOCK COUNT
73 static void verify_links()
77 long count
= LinkMan
->GetLockCount();
78 AssertMsg1(count
== 0,"Link Lock Count is %d\n",count
);
86 ////////////////////////////////////////
87 // DATABASE MESSAGE HANDLER
90 #define DB_TO_OBJNOTIF(x) ((x)|kObjNotifyDatabase) // DB and obj notify messages are coincidentally the same
92 static void db_message(DispatchData
* msg
)
95 static BOOL first_reset
= TRUE
;
102 IObjectSystem_DatabaseNotify(ObjSys
,DB_TO_OBJNOTIF(msg
->subtype
),msg
->data
);
104 switch (DB_MSG(msg
->subtype
))
114 if (msg
->subtype
& kDBMap
) // only do this when wr_num_cells has changed
116 // I realize that this shouldn't really be here, but constraints
117 // blew up when I tried to put it in physloop and put it after
118 // WR for database messages. Plus it's like 39 hours till E3
120 PhysRefSystemResize();
125 case kDatabasePostLoad
:
127 if (msg
->subtype
& kObjPartConcrete
)
137 ////////////////////////////////////////
139 // LOOP/DISPATCH callback
140 // Here's where we do the dirty work.
143 #pragma off(unreferenced)
144 static eLoopMessageResult LGAPI
_LoopFunc(void* data
, eLoopMessage msg
, tLoopMessageData hdata
)
146 // useful stuff for most clients
147 eLoopMessageResult result
= kLoopDispatchContinue
;
148 StateRecord
* state
= (StateRecord
*)data
;
156 ObjSys
= AppGetObj(IObjectSystem
);
157 LinkMan
= AppGetObj(ILinkManagerInternal
);
158 PropertyInterfacesInit();
161 ModelNumberPropInit();
162 CollisionTypePropInit();
166 ExtraLightPropInit();
175 SafeRelease(LinkMan
);
177 AnimLightPropRelease();
179 ModelNumberPropTerm();
182 PropertyInterfacesTerm();
185 case kMsgNormalFrame
:
194 db_message(info
.dispatch
);
204 ////////////////////////////////////////////////////////////
206 // Loop client factory function.
209 #pragma off(unreferenced)
210 static ILoopClient
* LGAPI
_CreateClient(sLoopClientDesc
* pDesc
, tLoopClientData data
)
213 // allocate space for our state, and fill out the fields
214 state
= (StateRecord
*)Malloc(sizeof(StateRecord
));
215 state
->context
= (Context
*)data
;
217 return CreateSimpleLoopClient(_LoopFunc
,state
,&ObjSysLoopClientDesc
);
219 #pragma on(unreferenced)
226 sLoopClientDesc ObjSysLoopClientDesc
=
229 "Object system client",
231 kMsgEnd
|kMsgDatabase
|kMsgsFrame
|kMsgsAppOuter
|kMsgsMode
,
239 { kConstrainBefore
, &LOOPID_SimFinish
, kMsgsFrame
},
240 { kConstrainAfter
, &LOOPID_Physics
, kMsgsFrame
},
241 { kConstrainAfter
, &LOOPID_Wr
, kMsgDatabase
},
243 {kNullConstraint
} // terminator