refactor(bitflags): Simplify conditions with testForAny, testForAll and remove unexpected assert in BitFlags::testForAll#2476
Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom Mar 21, 2026
Conversation
2 tasks
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/Common/BitFlags.h | Removes DEBUG_ASSERTCRASH from testForAll when called with zero flags, enabling vacuous-truth semantics (empty set → always true) required by the callers below. |
| GeneralsMD/Code/GameEngine/Include/Common/BitFlags.h | Mirrors the Generals BitFlags.h change — removes same DEBUG_ASSERTCRASH from testForAll for Zero Hour. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Die/DieModule.cpp | Simplifies exempt/required status guards: replaces manual any()-guard + testForAny/testForAll with direct testForNone/testForAll calls, leveraging correct empty-set semantics. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/DieModule.cpp | Identical simplification to Generals DieModule.cpp — semantically equivalent refactor for Zero Hour. |
| Generals/Code/GameEngine/Source/GameLogic/Object/Upgrade/UpgradeModule.cpp | Simplifies the conflicting-upgrade guard from !keyMask.any() |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/UpgradeModule.cpp | Mirrors the Generals UpgradeModule.cpp simplification for Zero Hour. |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp | Drops the redundant m_requiredStatus.any() guard before testForAll, relying on the now-correct vacuous-truth return of testForAll with an empty argument. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["testForAll(that)"] --> B{"that is empty?"}
B -- "Before PR (assert fires)" --> C["DEBUG_ASSERTCRASH ❌"]
B -- "After PR (assert removed)" --> D["Return true (vacuous)"]
B -- "that has bits" --> E["Flip self, AND with that, return empty?"]
F["isDieApplicable"] --> G{"!testForNone(exemptStatus)"}
G -- "true: exempt bit set" --> H["return false"]
G -- "false: no exempt bits" --> I{"!testForAll(requiredStatus)"}
I -- "true: missing required bit" --> J["return false"]
I -- "false: all required bits set" --> K["return true"]
L["testUpgradeConditions"] --> M{"testForNone(conflicting)"}
M -- "false: conflict found" --> N["skip activation block"]
M -- "true: no conflict" --> O{"activation.any()"}
O -- "true" --> P["check activation conditions"]
Last reviewed commit: "Replicate in General..."
…nd remove unexpected assert in BitFlags::testForAll
12fc6e7 to
795dcd8
Compare
Author
|
Replicated in Generals with conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change simplifies a few conditions with testForAny, testForAll and removes the unexpected assert in
BitFlags::testForAllTODO