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

Function TelComHandleAllEvents

Descent3/TelCom.cpp:2552–2744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2550#define TELCOM_FRAMERATE_CAP 25.0f
2551void GameFrame(void);
2552void TelComHandleAllEvents(tTelComInfo *tcs) {
2553 static float last_frame_time = 0;
2554 float frame_time;
2555
2556 volatile float curr_time = timer_GetTime();
2557 volatile float next_time = last_frame_time + (1 / TELCOM_FRAMERATE_CAP);
2558
2559 if (curr_time < next_time) {
2560 Sleep((next_time - curr_time) * 1000.0f);
2561 }
2562 if (last_frame_time == 0) {
2563 frame_time = 0.1f;
2564 }
2565 frame_time = curr_time - last_frame_time;
2566 last_frame_time = curr_time;
2567
2568 // First handle all events that the TelCom system has waiting
2569 tTCEvent event;
2570 while (TelComPopEvent(&event)) {
2571 // handle the event
2572 switch (event.id) {
2573 case -1:
2574 mprintf(0, "TelCom Error: Trying to process an event of type -1\n");
2575 Int3(); // Hey!! How'd we pop off a -1!!! Get Jeff
2576 break;
2577 case TEVT_TCQUIT: {
2578 // the user wants to quit out of the TelCom
2579 tcs->current_status = TS_OFF;
2580 } break;
2581 case TEVT_SCREENSHOT: {
2582 // take a screenshot
2583 mprintf(0, "Taking Screenshot\n");
2584 DoScreenshot();
2585 } break;
2586 case TEVT_TCNEXT: {
2587 // the user wants to go to the next screen
2588 if (TelcomAdvanceScreen() && tcs->current_status == TS_MISSION && !Telcom_called_from_game) {
2589 // exit out of TelCom
2590 tcs->state = TCS_POWEROFF;
2591 }
2592 } break;
2593 case TEVT_TCPREV: {
2594 // the user wants to go to the prev screen
2595 TelcomBackupScreen();
2596 } break;
2597 case TEVT_TCJUMP: {
2598 int screen = event.parms[0];
2599 ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS);
2600
2601 // the user wants to jump to a screen
2602 TelComJumpScreen(screen);
2603 } break;
2604 case TEVT_FAKEKEYPRESS: {
2605 TelComHandleKeyPress(event.parms[0], true, TC_current_screen);
2606 } break;
2607 default:
2608 mprintf(0, "TelCom System Warning: Unhandled event %d\n", event.id);
2609 break;

Callers 8

TelComMainFunction · 0.85
TelComMainMenuFunction · 0.85
TelComSingleShipSelectFunction · 0.85
TelComGoalStatusFunction · 0.85
TelComCargoFunction · 0.85
TelComAutoMapFunction · 0.85
PlayBriefingFunction · 0.85
PBLoopCallbackFunction · 0.85

Calls 15

TelComPopEventFunction · 0.85
DoScreenshotFunction · 0.85
TelcomAdvanceScreenFunction · 0.85
TelcomBackupScreenFunction · 0.85
TelComJumpScreenFunction · 0.85
TelComHandleKeyPressFunction · 0.85
ddio_KeyInKeyFunction · 0.85
ddio_MouseGetStateFunction · 0.85
HotSpotLFunction · 0.85

Tested by

no test coverage detected