MCPcopy Create free account
hub / github.com/DFHack/dfhack / manageEvents

Method manageEvents

library/modules/EventManager.cpp:409–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409void DFHack::EventManager::manageEvents(color_ostream& out) {
410 static const std::array<eventManager_t, EventType::EVENT_MAX> eventManager = compileManagerArray();
411 if ( !gameLoaded ) {
412 return;
413 }
414 if (!df::global::world)
415 return;
416
417 CoreSuspender suspender;
418
419 int32_t tick = df::global::world->frame_counter;
420 TRACE(log,out).print("processing events at tick {}\n", tick);
421
422 auto &core = Core::getInstance();
423 auto &counters = core.perf_counters;
424 for ( size_t a = 0; a < EventType::EVENT_MAX; a++ ) {
425 if ( handlers[a].empty() )
426 continue;
427 int32_t eventFrequency = -100;
428 if ( a != EventType::TICK )
429 for (auto &[_,handle] : handlers[a]) {
430 if (handle.freq < eventFrequency || eventFrequency == -100 )
431 eventFrequency = handle.freq;
432 }
433 else eventFrequency = 1;
434
435 if ( tick >= eventLastTick[a] && tick - eventLastTick[a] < eventFrequency )
436 continue;
437
438 uint32_t start_ms = core.p->getTickCount();
439 eventManager[a](out);
440 eventLastTick[a] = tick;
441 counters.incCounter(counters.event_manager_event_total_ms[a], start_ms);
442 }
443}
444
445static void manageTickEvent(color_ostream& out) {
446 if (!df::global::world)

Callers

nothing calls this directly

Calls 5

compileManagerArrayFunction · 0.85
getTickCountMethod · 0.80
incCounterMethod · 0.80
printMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected