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.
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
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.10usOVT_EconomyInfo::FindOverride
- 265.50usAfter:
OVT_EconomyInfo::UpdateOverride
- 5.50usOVT_EconomyInfo::FindOverride
- 3.70usOne 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