Skip to content

Fix/unit queue distribution#386

Open
andy5995 wants to merge 3 commits intodevelopfrom
fix/unit-queue-distribution
Open

Fix/unit queue distribution#386
andy5995 wants to merge 3 commits intodevelopfrom
fix/unit-queue-distribution

Conversation

@andy5995
Copy link
Copy Markdown
Collaborator

Fixes #254

Will need a little more testing, but looks great so far!

andy5995 and others added 2 commits March 27, 2026 05:50
When multiple production buildings are selected and the player issues a produce
command, the resources should be fairly distributed across all buildings,
prioritizing those not currently producing.

This fix has two parts:

1. Commander: Sort selected units before issuing commands
   - Non-producing buildings get priority
   - Among same production status, prefer buildings with fewer queued commands

2. Unit: Defer resource costs until command becomes active
   - Only deduct resources when a command starts executing
   - Queued commands don't consume resources until they become the current command
   - This allows multiple commands to be queued without prematurely consuming all resources

Scenario that is now fixed:
- Player selects 3 barracks: 2 producing, 1 idle
- Player issues produce command with enough resources for 1 unit
- Previously: One of the producing barracks would get it (wrong)
- Now: The idle barracks gets sorted first and receives the command
- Resources are only deducted when the idle barracks' command becomes active

Fixes #254

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Sort units by queue size (fewest commands first) to prioritize idle/underutilized buildings
- Use round-robin cycling to fairly distribute commands across selected units
- Ensure immediate resource deduction to prevent queueing without resources
@andy5995 andy5995 added this to the v3.14.0 milestone Mar 27, 2026
@andy5995 andy5995 force-pushed the fix/unit-queue-distribution branch from 2b9bcfd to ad1086d Compare March 29, 2026 13:21
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.

Units always get queued on the same building when there's not enough resources.

1 participant