MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoFlyingControl

Function DoFlyingControl

Descent3/object.cpp:2282–2462  ·  view source on GitHub ↗

Do the controls for a player-type object

Source from the content-addressed store, hash-verified

2280
2281// Do the controls for a player-type object
2282void DoFlyingControl(object *objp) {
2283 game_controls controls;
2284
2285 if (Dedicated_server)
2286 return;
2287
2288 ASSERT(objp->control_type == CT_FLYING);
2289
2290 if ((objp->type != OBJ_PLAYER && objp->type != OBJ_OBSERVER) || objp->id != Player_num)
2291 return;
2292
2293 if (Timedemo_frame != -1) {
2294 matrix temp_mat, rot_mat;
2295
2296 if (Timedemo_frame == 0) {
2297 Timedemo_timecount = 0;
2298 } else {
2299 Timedemo_timecount += Frametime;
2300 }
2301
2302 vm_AnglesToMatrix(&temp_mat, 0, 65536 / 360, 0);
2303
2304 rot_mat = objp->orient * temp_mat;
2305
2306 ObjSetOrient(objp, &rot_mat);
2307
2308 Timedemo_frame++;
2309 if (Timedemo_frame == 360) {
2310 // Calculate timedemo framerate
2311
2312 float fps = 1.0 / (Timedemo_timecount / 360.0);
2313 AddHUDMessage(TXT_TIMEDEMO, fps);
2314 Timedemo_frame = -1;
2315 }
2316
2317 return;
2318 }
2319 if (Demo_flags == DF_PLAYBACK) {
2320 // If we are playing back a demo, bail early and don't process controls
2321 return;
2322 }
2323
2324 // Read the controllers
2325 ReadPlayerControls(&controls);
2326
2327 if ((objp->type == OBJ_PLAYER) && (Players[objp->id].controller_bitflags != 0xffffffff)) {
2328 player *pp = &Players[objp->id];
2329 if (!(pp->controller_bitflags & PCBF_FORWARD)) {
2330 if (controls.forward_thrust > 0.0f)
2331 controls.forward_thrust = 0.0f;
2332 }
2333 if (!(pp->controller_bitflags & PCBF_REVERSE)) {
2334 if (controls.forward_thrust < 0.0f)
2335 controls.forward_thrust = 0.0f;
2336 }
2337 if (!(pp->controller_bitflags & PCBF_LEFT)) {
2338 if (controls.sideways_thrust < 0.0f)
2339 controls.sideways_thrust = 0.0f;

Callers 1

ObjDoFrameFunction · 0.85

Calls 9

ObjSetOrientFunction · 0.85
AddHUDMessageFunction · 0.85
ReadPlayerControlsFunction · 0.85
CallGameDLLFunction · 0.85
DoPlayerAfterburnControlFunction · 0.85
FireWeaponFromPlayerFunction · 0.85
FireFlareFromPlayerFunction · 0.85
CheckRearViewFunction · 0.85
vm_AnglesToMatrixFunction · 0.50

Tested by

no test coverage detected