Do the controls for a player-type object
| 2280 | |
| 2281 | // Do the controls for a player-type object |
| 2282 | void 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; |
no test coverage detected