Modifies EventManager unit loops

develop
Josh Cooper 2021-08-19 18:31:09 -07:00 committed by Myk
parent 88b5bf7a80
commit 1107c03b86
1 changed files with 4 additions and 8 deletions

@ -302,8 +302,7 @@ void DFHack::EventManager::onStateChange(color_ostream& out, state_change_event
buildings.insert(b->id); buildings.insert(b->id);
} }
lastSyndromeTime = -1; lastSyndromeTime = -1;
for ( size_t a = 0; a < df::global::world->units.all.size(); ++a ) { for ( df::unit* unit : df::global::world->units.all ) {
df::unit* unit = df::global::world->units.all[a];
for ( size_t b = 0; b < unit->syndromes.active.size(); ++b ) { for ( size_t b = 0; b < unit->syndromes.active.size(); ++b ) {
df::unit_syndrome* syndrome = unit->syndromes.active[b]; df::unit_syndrome* syndrome = unit->syndromes.active[b];
int32_t startTime = syndrome->year*ticksPerYear + syndrome->year_time; int32_t startTime = syndrome->year*ticksPerYear + syndrome->year_time;
@ -599,8 +598,7 @@ static void manageUnitDeathEvent(color_ostream& out) {
auto &handler = iter.second; auto &handler = iter.second;
if(tick - eventLastTick[handler.eventHandler] >= handler.freq) { if(tick - eventLastTick[handler.eventHandler] >= handler.freq) {
eventLastTick[handler.eventHandler] = tick; eventLastTick[handler.eventHandler] = tick;
for ( size_t a = 0; a < df::global::world->units.all.size(); ++a ) { for ( df::unit *unit : df::global::world->units.all ) {
df::unit* unit = df::global::world->units.all[a];
//if ( unit->counters.death_id == -1 ) { //if ( unit->counters.death_id == -1 ) {
if ( Units::isActive(unit) ) { if ( Units::isActive(unit) ) {
livingUnits.insert(unit->id); livingUnits.insert(unit->id);
@ -747,8 +745,7 @@ static void manageSyndromeEvent(color_ostream& out) {
auto &handler = iter.second; auto &handler = iter.second;
if (tick - eventLastTick[handler.eventHandler] >= handler.freq) { if (tick - eventLastTick[handler.eventHandler] >= handler.freq) {
eventLastTick[handler.eventHandler] = tick; eventLastTick[handler.eventHandler] = tick;
for ( auto a = df::global::world->units.all.begin(); a != df::global::world->units.all.end(); ++a ) { for ( df::unit *unit : df::global::world->units.all ) {
df::unit* unit = *a;
/* /*
if ( unit->flags1.bits.inactive ) if ( unit->flags1.bits.inactive )
continue; continue;
@ -876,8 +873,7 @@ static void updateReportToRelevantUnits() {
return; return;
reportToRelevantUnitsTime = df::global::world->frame_counter; reportToRelevantUnitsTime = df::global::world->frame_counter;
for ( size_t a = 0; a < df::global::world->units.all.size(); ++a ) { for ( df::unit *unit : df::global::world->units.all ) {
df::unit* unit = df::global::world->units.all[a];
for ( int16_t b = df::enum_traits<df::unit_report_type>::first_item_value; b <= df::enum_traits<df::unit_report_type>::last_item_value; ++b ) { for ( int16_t b = df::enum_traits<df::unit_report_type>::first_item_value; b <= df::enum_traits<df::unit_report_type>::last_item_value; ++b ) {
if ( b == df::unit_report_type::Sparring ) if ( b == df::unit_report_type::Sparring )
continue; continue;