2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
6 // $Header: r:/t2repos/thief2/src/dark/drksloop.cpp,v 1.38 1999/12/22 18:45:25 PATMAC Exp $
48 // Must be last header
51 /////////////////////////////////////////////////////////////
52 // DARK SIMULATION LOOP CLIENT
53 ////////////////////////////////////////////////////////////
58 // These are just here to separate out boiler-plate code and leave it untouched
61 #define MY_FACTORY DarkSimLoopFactory
62 #define MY_GUID LOOPID_DarkSim
68 typedef struct _StateRecord
70 Context
* context
; // a pointer to the context data I got.
71 // State fields go here
73 BOOL is_first_game_frame
;
76 ////////////////////////////////////////
78 // LOOP/DISPATCH callback
79 // Here's where we do the dirty work.
83 static void db_message(DispatchData
* msg
)
88 AutoAppIPtr(Inventory
);
89 pInventory
->DatabaseNotify(msg
->subtype
,data
.load
);
91 DarkAutomapDatabaseNotify( msg
->subtype
, data
.load
);
93 switch (DB_MSG(msg
->subtype
))
95 case kDatabasePostLoad
:
96 case kDatabaseDefault
:
97 InitProjectileArchetype();
98 InitParticleArchetype();
99 DarkReactionsPostLoad();
105 #pragma off(unreferenced)
106 static eLoopMessageResult LGAPI
_LoopFunc(void* data
, eLoopMessage msg
, tLoopMessageData hdata
)
108 // useful stuff for most clients
109 eLoopMessageResult result
= kLoopDispatchContinue
;
110 StateRecord
* state
= (StateRecord
*)data
;
127 state
->in_game_mode
= IsEqualGUID(*info
.mode
->to
.pID
, LOOPID_GameMode
);
128 if (state
->in_game_mode
)
129 { // center so mouse look around will work
131 dark_start_gamemode(msg
== kMsgResumeMode
);
132 if ( msg
== kMsgEnterMode
) {
133 state
->is_first_game_frame
= TRUE
;
139 case kMsgSuspendMode
:
140 if (state
->in_game_mode
)
142 dark_end_gamemode(msg
== kMsgSuspendMode
);
143 state
->in_game_mode
= FALSE
;
147 case kMsgNormalFrame
:
148 if (SimStateCheckFlags(kSimGameSpec
))
150 dark_sim_update_frame();
152 UpdateBowAttack(GetSimFrameTime());
153 UpdateWeaponAttack();
154 PickLockPerFrameCallback(GetSimFrameTime());
156 if ( state
->in_game_mode
&& state
->is_first_game_frame
) {
157 state
->is_first_game_frame
= FALSE
;
158 DarkAutomapFirstFrameInit();
163 db_message(info
.dispatch
);
173 ////////////////////////////////////////////////////////////
175 // Loop client factory function.
178 #pragma off(unreferenced)
179 static ILoopClient
* LGAPI
_CreateClient(const sLoopClientDesc
* desc
, tLoopClientData data
)
182 // allocate space for our state, and fill out the fields
183 state
= (StateRecord
*)malloc(sizeof(StateRecord
));
184 state
->context
= (Context
*)data
;
185 state
->is_first_game_frame
= FALSE
;
187 return CreateSimpleLoopClient(_LoopFunc
,state
,desc
);
189 #pragma on(unreferenced)
195 sLoopClientDesc DarkSimLoopClientDesc
=
198 "Dark Simulation", // NAME
199 kPriorityNormal
, // PRIORITY
200 kMsgEnd
| kMsgsMode
| kMsgsFrameMid
| kMsgsAppOuter
| kMsgDatabase
, // INTERESTS
208 {kConstrainAfter
, &LOOPID_Physics
, kMsgsFrame
},
209 {kConstrainBefore
, &LOOPID_SimFinish
, kMsgsFrame
},
210 {kConstrainAfter
, &LOOPID_UI
, kMsgsMode
},
211 {kConstrainAfter
, &LOOPID_Game
, kMsgsMode
},
212 {kConstrainAfter
, &LOOPID_ObjSys
, kMsgDatabase
},
213 {kConstrainAfter
, &LOOPID_Biped
, kMsgsAppOuter
},
214 {kConstrainBefore
, &LOOPID_Biped
, kMsgsFrame
},
215 {kConstrainAfter
, &LOOPID_Player
, kMsgsFrame
},
216 {kNullConstraint
} // terminator