Page MenuHomeWildfire Games

Fix UnitAI range queries - allow queries to ignore sizes - partial revert of rP24217
ClosedPublic

Authored by wraitii on Jan 23 2021, 11:25 AM.

Details

Summary

Units currently appear to "miss" targets that enter their LoS right now. The cause is rP24217: range queries now return units farther away, and those units might actually be out of range if distance is computed center-to-center, which both UnitAI and LOS do. This means that code relying on range query updates is possibly broken, and indeed units miss things (see ticket).

I would like to update UnitAI to calculate distance properly but can't: LOS remains problematic for now (see D3083)


This simply introduces an optional revert of rP24217, by allowing queries to ignore sizes, like they did before. It fixes UnitAI queries.
I also use this for Build Restrictions and Auras, where the new feature was doubtful (mostly because if affects structures, which can have different sizes, and this harms readability of the templates for balancing purposes).

This therefore reverts rP24643, rP24349 (with the exception of the iber monument footprint), and the template changes in rP24217 itself.

It also reduces alertRaiser ranges slightly, this was missed in the original diff.


NB: this very much does not reopen #3381. In fact, buildings will see entities much earlier than entities see buildings, because the former account for their own size while the latter don't. I don't think it's a huge deal for balancing purposes, it shouldn't change much for raiding.
MAYBE we want to bump stonethrower range a little (they sit at 80).

Reported by: Freagarach

Test Plan

Make sure that all cases of ExecuteQuery*, CreateActiveQuery* are updated in JS. Check that I have not forgotten a commit to revert. Play a few games. And of course reproduce the OG bug.

Event Timeline

wraitii created this revision.Jan 23 2021, 11:25 AM
Owners added subscribers: Restricted Owners Package, Restricted Owners Package.Jan 23 2021, 11:25 AM

Build has FAILED

builderr-debug-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui_dbg.a(precompiled.o) has no symbols
ld: warning: text-based stub file /System/Library/Frameworks//CoreAudio.framework/CoreAudio.tbd and library file /System/Library/Frameworks//CoreAudio.framework/CoreAudio are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Fram

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/3023/display/redirect
See console output for more information: https://jenkins.wildfiregames.com/job/macos-differential/3023/display/redirectconsole

wraitii added inline comments.Jan 23 2021, 11:32 AM
source/simulation2/components/ICmpRangeManager.h
165

I am not massively happy about this, I could bump the max, but that will have possibly adverse effects on compile time & it's fixed by D2818

Build has FAILED

builderr-debug-gcc7.txt
In file included from ../../../source/simulation2/components/tests/test_RangeManager.cpp:17:
/zpool0/gcc7/source/simulation2/components/tests/test_RangeManager.h: In member function 'void TestCmpRangeManager::test_queries()':
/zpool0/gcc7/source/simulation2/components/tests/test_RangeManager.h:233:104: error: no matching function for call to 'ICmpRangeManager::ExecuteQuery(int, CFixed<int, 2147483647, 32, 15, 16, 65536>, CFixed<int, 2147483647, 32, 15, 16, 65536>, <brace-enclosed initializer list>, int)'
   std::vector<entity_id_t> nearby = cmp->ExecuteQuery(100, fixed::FromInt(0), fixed::FromInt(4), {1}, 0);
                                                                                                        ^
In file included from /zpool0/gcc7/source/simulation2/components/tests/test_RangeManager.h:20,
                 from ../../../source/simulation2/components/tests/test_RangeManager.cpp:17:
../../../source/simulation2/components/ICmpRangeManager.h:123:35:

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/4681/display/redirect
See console output for more information: https://jenkins.wildfiregames.com/job/docker-differential/4681/display/redirectconsole

wraitii requested review of this revision.Jan 23 2021, 11:37 AM
wraitii updated this revision to Diff 15638.Jan 23 2021, 12:57 PM

Fix tests.

Build is green

builderr-debug-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas_dbg.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui_dbg.a(precompiled.o) has no symbols
ld: warning: text-based stub file /System/Library/Frameworks//CoreAudio.framework/CoreAudio.tbd and library file /System/Library/Frameworks//CoreAudio.framework/CoreAudio are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Fram

See https://jenkins.wildfiregames.com/job/macos-differential/3024/display/redirect for more details.

Silier added inline comments.Jan 23 2021, 2:54 PM
binaries/data/mods/public/simulation/components/UnitAI.js
4443

this should be false, there is visibile check

Stan added a subscriber: Stan.Jan 23 2021, 4:03 PM

Is there a way to test what broke and forces the revert of this?

wraitii marked an inline comment as done.Jan 23 2021, 4:22 PM
In D3456#152814, @Stan wrote:

Is there a way to test what broke and forces the revert of this?

Not without a test map. The problem is that:

  • The LOS computes visibility by using the center-to-center range
  • The range queries now returned all results in edge-to-edge distance range.
  • UnitAI only considers changes in the range query (it doesn't retry things for entities that are already in the range query results, usually)
  • Therefore, the range query returned entities that were sometimes not actually visible to the unit, breaking the UnitAI code.

And sometimes a stronger variant of the last case when unitAI did additional range checks, but the LOS thing is the real RB here.
So we can't really meaningfully test this without LOS and range queries working properly, which we can't really do without a map RN (I mean it's technically possible I guess, but really, really annoying).

binaries/data/mods/public/simulation/components/UnitAI.js
4532

same here most likely

6562

this one is fine

wraitii updated this revision to Diff 15644.Jan 23 2021, 4:22 PM

Fix Angen's remarks.

Build is green

builderr-debug-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2_dbg.a(precompiled.o) has no symbols
../../../source/graphics/ShaderProgram.cpp:86:15: warning: 'Reload' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
        virtual void Reload()
                     ^
../../../source/graphics/ShaderProgram.h:124:15: note: overridden virtual function is here
        virtual void Reload() = 0;
                     ^
../../../source/graphics/ShaderProgram.cpp:118:15: warning: 'Bind' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
        virtual void Bind()
                     ^
../../../source/graphics/ShaderProgram.h:135:15: note: overridden virtual function is here
        virtual void Bind() = 0;
                     ^
../../../source/graphics/ShaderProgram.cpp:128:15: warning: 'Unbind' overrides a

See https://jenkins.wildfiregames.com/job/macos-differential/3026/display/redirect for more details.

Silier added inline comments.Jan 23 2021, 7:53 PM
binaries/data/mods/public/simulation/components/UnitAI.js
4482

??

This revision was not accepted when it landed; it landed in state Needs Review.Jan 23 2021, 7:57 PM
This revision was automatically updated to reflect the committed changes.