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

Function CheckRearView

Descent3/object.cpp:2246–2276  ·  view source on GitHub ↗

Deal with the player's rear view

Source from the content-addressed store, hash-verified

2244
2245// Deal with the player's rear view
2246void CheckRearView(int down_count, bool down_state) {
2247 player *player = &Players[Player_num];
2248
2249#define LEAVE_TIME (1.0 / 16) // How long until we decide key is down
2250
2251 static bool leave_mode;
2252 static float entry_time;
2253
2254 if (down_count) { // key/button has gone down
2255
2256 if (player->flags & PLAYER_FLAGS_REARVIEW) { // rear view was active, so turn it off
2257 player->flags &= ~PLAYER_FLAGS_REARVIEW;
2258 } else { // rear view wasn't active, so turn it on
2259 player->flags |= PLAYER_FLAGS_REARVIEW;
2260 leave_mode = 0; // means wait for another key
2261 entry_time = Gametime;
2262 }
2263 } else { // key didn't go down this frame; check if it used to be down
2264
2265 if (down_state) { // key is still down
2266
2267 if (!leave_mode && ((Gametime - entry_time) > LEAVE_TIME))
2268 leave_mode = 1;
2269 } else {
2270
2271 if (leave_mode && (player->flags & PLAYER_FLAGS_REARVIEW)) {
2272 player->flags &= ~PLAYER_FLAGS_REARVIEW;
2273 }
2274 }
2275 }
2276}
2277
2278extern int Timedemo_frame;
2279float Timedemo_timecount;

Callers 1

DoFlyingControlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected