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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/aibrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ AIBrain = Class(moho.aibrain_methods) {
-- TURNING OFF AI POOL PLATOON, I MAY JUST REMOVE THAT PLATOON FUNCTIONALITY LATER
local poolPlatoon = self:GetPlatoonUniquelyNamed('ArmyPool')
if poolPlatoon then
poolPlatoon.ArmyPool = true
poolPlatoon:TurnOffPoolAI()
end

Expand Down
5 changes: 5 additions & 0 deletions lua/platoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ Platoon = Class(moho.platoon_methods) {

---@param self Platoon
PlatoonDisband = function(self)
if self.ArmyPool then
WARN('AI WARNING: Platoon trying to disband ArmyPool')
--LOG(reprsl(debug.traceback()))
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.

end
local aiBrain = self:GetBrain()
if self.BuilderHandle then
self.BuilderHandle:RemoveHandle(self)
Expand Down