Skip to content

Implemented GetUnitFactoryBuilding() method#2995

Open
PexoDev wants to merge 2 commits into
beyond-all-reason:masterfrom
PexoDev:feature/issue-2892-GetUnitFactoryBuilding
Open

Implemented GetUnitFactoryBuilding() method#2995
PexoDev wants to merge 2 commits into
beyond-all-reason:masterfrom
PexoDev:feature/issue-2892-GetUnitFactoryBuilding

Conversation

@PexoDev

@PexoDev PexoDev commented May 31, 2026

Copy link
Copy Markdown

As per #2892 - added a new method to fetch factory's ID of given unit being build.

As discussed in the issue's thread - this covers factories exclusively and doesn't account for mobile builders.

Comment thread rts/Lua/LuaSyncedRead.cpp Outdated

@sprunk sprunk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks technically correct but polling all units to check if they're the factory is going to be relatively expensive. Would be ideal if buildees had a pointer to the fac.

Comment thread rts/Lua/LuaSyncedRead.cpp Outdated
@PexoDev

PexoDev commented Jun 4, 2026

Copy link
Copy Markdown
Author

I understand, makes sense.
I'll look into it further when I have a moment to spare.

Comment thread rts/Lua/LuaSyncedRead.cpp

if (unit->producingFactory == nullptr)
return 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should probably also return if !LuaUtils::IsUnitInLos(L, unit->producingFactory) at this point

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.

2 participants