feat(client): Add EasyMilitaryDrag option to leave builders out of drag selections - #3219
feat(client): Add EasyMilitaryDrag option to leave builders out of drag selections#3219triatomic wants to merge 3 commits into
Conversation
…ctions Options.ini: EasyMilitaryDrag = Yes drops builders from a drag selection, so boxing over a base picks up the army without dragging workers off their jobs. Covers KINDOF_DOZER and KINDOF_IGNORES_SELECT_ALL - the same kinds Select All already disqualifies - which also catches GLA Workers. Only drags are affected: point selection, double click, control groups and select-matching all behave as before. Holding Ctrl inverts the filter for that one drag, boxing only the builders, and cancels force attack mode for that selection since Ctrl drives both. A box holding only builders selects them after all via a second pass with the filter suspended - tested against units surviving, not list emptiness, so a building in the box cannot silently win over the workers standing next to it. Works in both Zero Hour and Generals: everything lives in the shared selection code.
PR Summary by QodoAdd EasyMilitaryDrag builder filtering to box selection
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp | Adds the fallback selection pass and now aligns its survivor test with downstream ownership and containment filtering. |
| Core/GameEngine/Source/GameClient/SelectionInfo.cpp | Implements normal and Ctrl-inverted builder filtering while coordinating force-attack and existing drawable-selection behavior. |
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Parses the opt-in EasyMilitaryDrag setting with a disabled default. |
| Generals/Code/GameEngine/Source/Common/GlobalData.cpp | Initializes and caches the preference for the Generals runtime. |
| GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | Initializes and caches the preference for the Zero Hour runtime. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Drag[Drag selection] --> Enabled{EasyMilitaryDrag enabled?}
Enabled -- No --> Normal[Normal selection]
Enabled -- Yes --> Ctrl{Ctrl held?}
Ctrl -- Yes --> Builders[Keep builders only]
Ctrl -- No --> Military[Filter builders]
Military --> Survivor{Owned uncontained unit survives?}
Survivor -- Yes --> Select[Complete selection]
Survivor -- No --> Retry[Repeat without builder filter]
Retry --> Select
Builders --> Select
Reviews (3): Last reviewed commit: "fix(client): Exclude contained riders fr..." | Re-trigger Greptile
…fallback Addresses both review findings: - Constructing OptionPreferences reparses Options.ini from disk, and the selection path did it on every click or drag, twice with Ctrl held. The option now lives in GlobalData next to the other cached client options and refreshes with them; the input path reads the cached copy. - The builders-only fallback tested for any surviving non-structure, but a foreign unit in the box satisfies that test and is then rejected by the ownership filtering downstream - suppressing the fallback and leaving the boxed builders unselected. Only locally controlled units count now.
A rider in a non enclosing container such as the Overlord's bunker is a visible, locally controlled non structure, but the final selection loop discards contained objects - so it satisfied the fallback test while never surviving selection, suppressing the builders-only pass. Count only uncontained units.
Adds an opt-in client option dropping builders from drag selections. Defaults off; retail behavior unless set in Options.ini.
EasyMilitaryDrag (
= Yes) — boxing over your base picks up the army without dragging workers off their jobs. CoversKINDOF_DOZERandKINDOF_IGNORES_SELECT_ALL— the same kinds Select All already disqualifies (which also catches GLA Workers). Only drags are affected: point selection, double click, control groups and select-matching behave as before.Holding Ctrl inverts the filter for that one drag — boxing only the builders — and cancels force-attack mode for that selection, since Ctrl drives both. A box holding only builders still selects them via a second pass with the filter suspended, tested against "no units survived" rather than list emptiness so a building in the box cannot silently win over the workers beside it.
Works in both Zero Hour and Generals — everything lives in the shared selection code.
This option ships in the Contra mod's engine fork and has been played there; this PR is the port onto current main with both follow-up fixes folded in. Code was written with LLM assistance and human-reviewed, adapted and playtested by the author.
Prepared for Squash and Merge.