Skip to content

feat(cratecollide): Add INI field to allow a crate to be picked up multiple times in one frame#2297

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
Stubbjax:add-multi-pickup-crate-option
Feb 16, 2026
Merged

feat(cratecollide): Add INI field to allow a crate to be picked up multiple times in one frame#2297
xezon merged 2 commits intoTheSuperHackers:mainfrom
Stubbjax:add-multi-pickup-crate-option

Conversation

@Stubbjax
Copy link

@Stubbjax Stubbjax commented Feb 12, 2026

This change is a follow-up to #2279 and adds an AllowMultiPickup field to the CrateCollide module. When assigned a value of Yes, a crate can be collected by multiple colliding objects in a single frame, effectively replicating the original retail behaviour. The field defaults to a value of No when unassigned.

This feature was requested as some mods rely on the original behaviour.

Usage:

Behavior = MoneyCrateCollide ModuleTag_X
  AllowMultiPickup = Yes ; Allows collection by multiple objects on the same frame
End

@Stubbjax Stubbjax self-assigned this Feb 12, 2026
@Stubbjax Stubbjax added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Mod Relates to Mods or modding labels Feb 12, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 12, 2026

Greptile Summary

This PR adds an AllowMultiPickup configuration field to the CrateCollide module, allowing mod creators to control whether crates can be picked up by multiple objects in a single frame. The implementation:

  • Adds the m_allowMultiPickup boolean field to CrateCollideModuleData in both Generals and GeneralsMD codebases
  • Defaults to true when PRESERVE_RETAIL_BEHAVIOR is enabled (the current default), replicating original game behavior
  • Adds INI parser support via the AllowMultiPickup configuration key
  • Modifies the isValidToExecute() validation to check !md->m_allowMultiPickup alongside the destroyed state check

This is a follow-up to PR #2279, which prevented the multi-pickup bug by checking if a crate is destroyed. This PR allows mod creators to opt back into the original behavior when needed, while maintaining the bugfix as the default for new configurations.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are minimal, well-scoped, and follow established patterns in the codebase. The implementation correctly adds a new configuration field with proper initialization, INI parsing, and logical integration. The default value preserves retail behavior, and the changes are consistently applied across both Generals and GeneralsMD codebases. The logic is straightforward and doesn't introduce any security vulnerabilities or breaking changes.
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp Initialized m_allowMultiPickup based on PRESERVE_RETAIL_BEHAVIOR, added INI parser entry, updated logic to allow multi-pickup when flag is enabled
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp Initialized m_allowMultiPickup based on PRESERVE_RETAIL_BEHAVIOR, added INI parser entry, updated logic (identical to Generals version)

Flowchart

flowchart TD
    A[Object collides with crate] --> B{isValidToExecute check}
    B --> C{Is crate destroyed?}
    C -->|No| D[Continue validation checks]
    C -->|Yes| E{Is AllowMultiPickup enabled?}
    E -->|Yes| D
    E -->|No| F[Return FALSE - prevent pickup]
    D --> G{Other validation checks pass?}
    G -->|Yes| H[Execute crate behavior]
    G -->|No| F
    H --> I[Destroy crate object]
    
    style E fill:#e1f5ff
    style I fill:#ffe1e1
Loading

Last reviewed commit: 247bb19

Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

This looks fine to me.

m_executeAnimationFades = TRUE;
m_isBuildingPickup = FALSE;
m_isHumanOnlyPickup = FALSE;
m_allowMultiPickup = FALSE;
Copy link

Choose a reason for hiding this comment

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

m_allowMultiPickup = (PRESERVE_RETAIL_BEHAVIOR != 0);

The init value needs to be true when preserving retail behavior, so that legacy INI files work as usual, meaning Mods do not need to be adapted to work correctly.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, though I'm a little concerned about setting a precedent here. Is a non-retail compatible CRC build expected to be fully compatible with all mods? How do we determine or predict which bugs a particular mod might rely on? Do we need to retroactively apply this consideration across previous fixes?

Copy link

Choose a reason for hiding this comment

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

Ideally, for feature-like things, if PRESERVE_RETAIL_BEHAVIOR is 1. We have not been that strict historically, but it is very welcome if we know that Mods break with our changes. For this particular change, hanfield has told us that it break a Mod and therefore it is wise to handle it gracefully.

We can retroactively apply it to other changes we made if we know that it is helping Mods run normally.

Copy link
Author

Choose a reason for hiding this comment

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

In that case we'll be effectively forgoing the fix for active publishers currently preserving retail behaviour such as Generals Online in favour of supporting abandoned mods played on a non-RETAIL_COMPATIBLE_CRC client (which seems like a rather unlikely combination). Is this a reasonable compromise?

Copy link

@xezon xezon Feb 16, 2026

Choose a reason for hiding this comment

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

The problem is, if a Mod adds these new INI entries to make their Mod work normally with the new executable, then it will crash on boot with retail executable, because the INI parser will throw on unknown INI fields.

Copy link
Author

Choose a reason for hiding this comment

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

Won't that be the case for any mod that makes use of a new INI field, irrespective of any preprocessor directives?

Copy link

Choose a reason for hiding this comment

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

If PRESERVE_RETAIL_BEHAVIOR is 1 it allows Mod creator to build INI Mod without strict new Executable requirement. Once we require set new INI fields to restore Retail behavior, they cannot easily go back to make the INI Mod work with the retail executable. This is a disadvantage, for example for testing if something was already broken with the retail executable.

@xezon xezon changed the title feat: Add option to allow a crate to be picked up multiple times in the one frame feat(cratecollide): Add INI field to allow a crate to be picked up multiple times in one frame Feb 16, 2026
@xezon xezon merged commit 0ef19ad into TheSuperHackers:main Feb 16, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Mod Relates to Mods or modding ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants