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

Standardize factory alt behavior #4177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hihoman23
Copy link
Member

@hihoman23 hihoman23 commented Jan 15, 2025

Work done

Alt-queued units in factories will now always be queued after the current unit that is being built, even when not in repeat mode.

Addresses Issue(s)

Test steps

  • Test around with alt queues in factories with and without repeat mode, also with both buildmenus.

@WatchTheFort WatchTheFort requested a review from sprunk January 16, 2025 20:34
luaui/Widgets/gui_gridmenu.lua Outdated Show resolved Hide resolved
luaui/Widgets/cmd_factory_alt_behaviour.lua Outdated Show resolved Hide resolved
if isFactory[unitDefID] and buildOpts[unitDefID][-cmdID] then
factoryExists = true
if not cmdOpts.internal then
cmdOpts.coded = cmdOpts.coded + CMD.OPT_INTERNAL -- prevent repeating command
Copy link
Collaborator

Choose a reason for hiding this comment

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

I slightly dislike using INTERNAL over ALT but I suppose that ship had already sailed.

Copy link
Member Author

Choose a reason for hiding this comment

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

What could be done to prevent this? I assume the factory will repeat commands, unless it has INTERNAL in the params.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can skip factories who are on repeat (since they already handle Alt correctly) and then for the remaining non-repeat ones you don't need to add internal since they won't repeat anyway.

luaui/Widgets/cmd_factory_alt_behaviour.lua Outdated Show resolved Hide resolved
spGiveOrderToUnit(unitID, CMD_INSERT, {currentCmdID and 1 or 0, cmdID, cmdOpts.coded}, {"ctrl", "alt"})
end
end
return factoryExists
Copy link
Collaborator

Choose a reason for hiding this comment

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

In theory this makes any fac in selection eat the entire order for all the other units. Sounds fine though.

Copy link
Member Author

Choose a reason for hiding this comment

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

It only does this if the unit is in the build options, so when it's relevant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but if you have a factory and a mobile unit who both have the same buildoption. Consider:

buildoptions = {
[1] = "leginfestor"

What happens if you have both selected and give a mobile build order while holding alt? Right now it looks like it's going to drop the mobile order but insert it in the factory instead.

Copy link
Member Author

@hihoman23 hihoman23 Jan 21, 2025

Choose a reason for hiding this comment

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

This is a weird one: in this case the factory already eats the command (in current master), even without alt (in both buildmenus). I would fix this in a future PR.

luaui/Widgets/cmd_factory_alt_behaviour.lua Outdated Show resolved Hide resolved
if not cmdOpts.internal then
cmdOpts.coded = cmdOpts.coded + CMD.OPT_INTERNAL -- prevent repeating command
end
local currentCmdID, targetID = spGetUnitWorkerTask(unitID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what happens if there is a unit in queue but the factory isn't actually building it (opening animation, area blocked, etc). There may be a minor behaviour difference compared to native engine insert. Sounds fine though.

Copy link
Member Author

@hihoman23 hihoman23 left a comment

Choose a reason for hiding this comment

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

Factories get extremely glitchy when wait is issued and insert is used, where I also found bugs. I would wait to avoid this bugs before merging.

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.

Make Alt + Lab queue behaviour consistent
2 participants