Page MenuHomeWildfire Games

Check for lastPos existence in Combat-Approaching-MovementUpdate [fix rP22425]
ClosedPublic

Authored by wraitii on Aug 17 2020, 9:45 AM.

Details

Summary

As noted by Freagarach on rP22425.

lastPos isn't guaranteed to exist.

Test Plan

Run the replay and read through the code.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wraitii requested review of this revision.Aug 17 2020, 9:55 AM

Are there more places in UnitAI that can benefit from a check?

Are there more places in UnitAI that can benefit from a check?

Not that I've found. The other places that don't check are explicitly in the "hunt-gathering" state where lastPos ought to always exist <=> lasPos not existing is a different bug.

Freagarach accepted this revision.Aug 17 2020, 10:08 AM

I came to the same conclusion :)

You could clean it up a little by not creating the variable and combine the condition with the if-else a few lines earlier.

This revision is now accepted and ready to land.Aug 17 2020, 10:08 AM

Uhm, what happens when there is no lastPos and an entity gets movementUpdate.failure? They're stuck then, right?

wraitii updated this revision to Diff 13216.Aug 17 2020, 10:37 AM

Uhm, what happens when there is no lastPos and an entity gets movementUpdate.failure? They're stuck then, right?

Mh, you're correct. Can only happen with formations, but then we do have entities stuck in their state.

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1356/display/redirect

wraitii requested review of this revision.Aug 17 2020, 10:52 AM
Freagarach added inline comments.Aug 17 2020, 10:56 AM
binaries/data/mods/public/simulation/components/UnitAI.js
1897 ↗(On Diff #13216)

We'd still want to try and find a new target?

wraitii added inline comments.Aug 17 2020, 11:08 AM
binaries/data/mods/public/simulation/components/UnitAI.js
1897 ↗(On Diff #13216)

This can only happen when in formation, so aborting seemed reasonable enough to me, but I'm not too sure.

wraitii updated this revision to Diff 13236.Aug 18 2020, 8:46 AM

After a good night's sleep it obviously makes more sense to do this.

Freagarach accepted this revision.Aug 18 2020, 8:59 AM

Looks good now, playtesting reveals no errors.

This revision is now accepted and ready to land.Aug 18 2020, 8:59 AM

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1369/display/redirect