Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logic for army pool detection and disband blocking #4412

Merged

Conversation

relent0r
Copy link
Contributor

@relent0r relent0r commented Nov 16, 2022

Closes #4411
This PR is designed for the next major patch release, should not be included in a hotfix.

Description of changes

This PR changes adds an ArmyPool detection to the PlatoonDisband function. It is being put in place to stop units from accidentally disbanding the ArmyPool.
This is a relatively brute force method but any units trying to disband the army pool should not be treated as playing nice. I've added a warning for the AI developer so they will know when one of their units are doing this.

Note : because this sets the bool in the InitializeSkirmishSystems function then this has no impact to Sorian.

Test setup for the changes

Start a skirmish with the default AI. If a units or platoon trys to disband the ArmyPool it will be blocked and a warning will be logged.
From my own testing I saw some interesting results. On a map like Point of Reach V4 I got 800 instances of this warning, where as another 10km map with no water I got none for the test.

@Garanas Garanas added this to the Development iteration I milestone Nov 16, 2022
@@ -247,6 +247,10 @@ Platoon = Class(moho.platoon_methods) {

---@param self Platoon
PlatoonDisband = function(self)
if self.ArmyPool then
WARN('AI WARNING: Platoon trying to disband ArmyPool')
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a traceback to have an idea where it got called from with: reprsl(debug.traceback())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I haven't used that before. What sort of information would I expect it to give me?
From testing I couldn't get much information as to where the platoon disband came from without adding logs into the corresponding function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The complete stacktrace. Best to try it out and see what happens, just add that snippet to pieces of code. Note that it is expensive and should strictly be used to make (tracking of) errors more obvious.

Copy link
Contributor Author

@relent0r relent0r Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It dumps this.

info: stack traceback:
info:         g:\code\fa\lua\platoon.lua(253): in function <g:\code\fa\lua\platoon.lua:250>
info:         (tail call): ?
info:         g:\code\fa\lua\platoon.lua(3852): in function <g:\code\fa\lua\platoon.lua:3751>

Which in this scenario tells me which function it happened in and which function called it. So it does help identify where it came from. The why is a different story :) But will very useful. I'll leave this commented out given its expense so that AI Devs can re-enable when troubleshooting (i had no idea it existed until you pointed it out so chances are others wont) as it will identify correctly where the problem came from.

I'm pretty confident callbacks and queued commands are responsible for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears a recursive call is responsible: that is what a tail call is. Glad you're aware of it now. Note that you can keep it enabled in cases like these, where something happens that shouldn't be happening - it will make it easier to investigate game logs.

@Garanas Garanas merged commit cd5ca04 into FAForever:deploy/fafdevelop Nov 18, 2022
@relent0r relent0r deleted the fix/ai-armypool-disbandblock branch September 14, 2023 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI ArmyPool being disbanded during games.
2 participants