ArmaOverthrow / Overthrow.Arma4

A dynamic and persistent revolution platform for Arma Reforger (and eventually Arma 4)
MIT License
45 stars 17 forks source link

Fix: EconomyInfo fixes & optimization #57

Closed rekterakathom closed 1 week ago

rekterakathom commented 3 weeks ago

In OVT_EconomyInfo, m_fOverrideCounter is never reset, and override is updated every frame(?). Now it is set to update every second with a working timer. This is pretty significant because finding the override means checking the components of every entity within 50 meters, which is a really slow operation.

Average timings from the script profiler:

Before: OVT_EconomyInfo::UpdateOverride - 386.10us OVT_EconomyInfo::FindOverride - 265.50us

After: OVT_EconomyInfo::UpdateOverride - 5.50us OVT_EconomyInfo::FindOverride - 3.70us

One potential side-effect of this PR is that finding buildings for the UI override might sometimes be noticeably delayed, but I believe that this slight annoyance is worth it, and reading the code I believe this is what was originally intended anyway.

Edit: Further optimized FindOverride by casting only when necessary and managing a single pointer instead of always creating a new one