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

Function Osiris_ProcessTimers

Descent3/OsirisLoadandBind.cpp:2296–2401  ·  view source on GitHub ↗

Osiris_ProcessTimers Purpose: This function checks all timers currently running, if any need to be signaled it signals them.

Source from the content-addressed store, hash-verified

2294// Purpose:
2295// This function checks all timers currently running, if any need to be signaled it signals them.
2296void Osiris_ProcessTimers(void) {
2297 object *obj;
2298 bool signal, kill;
2299 tOSIRISEventInfo ei;
2300
2301 for (int i = 0; i < MAX_OSIRIS_TIMERS; i++) {
2302 signal = false;
2303 kill = false;
2304
2305 if (OsirisTimers[i].flags & OITF_USED) {
2306
2307 if (OsirisTimers[i].flags & OITF_CANCELONDEAD) {
2308 obj = ObjGet(OsirisTimers[i].objhandle_detonator);
2309 if (!obj || (obj->type == OBJ_GHOST) ||
2310 (obj->type == OBJ_PLAYER && Players[obj->id].flags & (PLAYER_FLAGS_DYING | PLAYER_FLAGS_DEAD))) {
2311 // the detontator died...cancel the timer!
2312 OsirisTimers[i].flags &= ~OITF_USED;
2313 OsirisTimers[i].repeat_count = 0;
2314
2315 tOSIRISEventInfo ei;
2316 ei.evt_timercancel.detonated = 1;
2317 ei.evt_timercancel.handle = OsirisTimers[i].handle;
2318
2319 if (OsirisTimers[i].flags & OITF_TRIGGERTIMER) {
2320 Osiris_CallTriggerEvent(OsirisTimers[i].trignum, EVT_TIMERCANCEL, &ei);
2321 } else if (OsirisTimers[i].flags & OITF_LEVELTIMER) {
2322 Osiris_CallLevelEvent(EVT_TIMERCANCEL, &ei);
2323 } else {
2324 object *obj = ObjGet(OsirisTimers[i].objhandle);
2325 if (obj)
2326 Osiris_CallEvent(obj, EVT_TIMERCANCEL, &ei);
2327 }
2328
2329 mprintf(0, "OSIRIS TIMER: Cancelling Timer (%d/%d)\n", OsirisTimers[i].handle, i);
2330 continue;
2331 }
2332 }
2333
2334 if (OsirisTimers[i].timer_next_signal <= Gametime) {
2335 // this timer needs to be signaled
2336 signal = true;
2337
2338 if (OsirisTimers[i].flags & OITF_REPEATCALL) {
2339 // this is a repeater
2340 if (OsirisTimers[i].repeat_count != -1) {
2341 // it has a finite repeat
2342 OsirisTimers[i].repeat_count--;
2343 if (OsirisTimers[i].repeat_count <= 0) {
2344 // remove the timer
2345 kill = true;
2346 OsirisTimers[i].repeat_count = 0;
2347 } else {
2348 // adjust for next signal
2349 OsirisTimers[i].timer_next_signal += OsirisTimers[i].timer_interval;
2350 }
2351 } else {
2352 // infinite repeat
2353 OsirisTimers[i].timer_next_signal += OsirisTimers[i].timer_interval;

Callers 1

GameFrameFunction · 0.85

Calls 4

ObjGetFunction · 0.85
Osiris_CallTriggerEventFunction · 0.85
Osiris_CallLevelEventFunction · 0.85
Osiris_CallEventFunction · 0.85

Tested by

no test coverage detected