Skip to content

feat: Add option to allow a crate to be picked up multiple times in the one frame#2297

Open
Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Stubbjax:add-multi-pickup-crate-option
Open

feat: Add option to allow a crate to be picked up multiple times in the one frame#2297
Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Stubbjax:add-multi-pickup-crate-option

Conversation

@Stubbjax
Copy link

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 Overview

Greptile Summary

Added an AllowMultiPickup configuration option to the CrateCollide module, allowing mod creators to enable the original retail behavior where crates can be collected by multiple objects in the same frame. The field defaults to No to maintain the bugfix behavior from PR #2279.

  • Added new m_allowMultiPickup boolean field to CrateCollideModuleData class in both Generals and GeneralsMD codebases
  • Modified the destroyed-crate validation check in isValidToExecute() to respect the new flag
  • When AllowMultiPickup = Yes, crates can be collected multiple times per frame (retail behavior)
  • When AllowMultiPickup is unset or No (default), the bugfix from bugfix(cratecollide): Prevent crates from being collected multiple times in a single frame #2279 applies and prevents multi-collection

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are minimal, well-tested pattern replication across both codebases, properly default to safe behavior, and correctly extend the existing bugfix with an opt-in configuration flag
  • No files require special attention

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp Initialized m_allowMultiPickup to FALSE, added INI parser field, and updated validation logic to conditionally allow multi-pickup
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp Initialized m_allowMultiPickup to FALSE, added INI parser field, and updated validation logic to conditionally allow multi-pickup (Zero Hour version)

Sequence Diagram

sequenceDiagram
    participant Object1 as Colliding Object 1
    participant Object2 as Colliding Object 2
    participant Crate as CrateCollide Module
    participant Logic as Game Logic
    
    Note over Object1,Logic: Same Frame - Multiple Collisions
    
    Object1->>Crate: onCollide(Object1)
    Crate->>Crate: isValidToExecute(Object1)
    alt AllowMultiPickup = No (default)
        Crate->>Crate: Check isDestroyed()
        Note over Crate: FALSE - not destroyed yet
    end
    Crate->>Crate: executeCrateBehavior(Object1)
    Crate->>Logic: destroyObject(crate)
    Note over Crate: Crate marked as destroyed
    
    Object2->>Crate: onCollide(Object2)
    Crate->>Crate: isValidToExecute(Object2)
    alt AllowMultiPickup = Yes
        Note over Crate: Skip destroyed check, allow pickup
        Crate->>Crate: executeCrateBehavior(Object2)
    else AllowMultiPickup = No (default)
        Crate->>Crate: Check isDestroyed()
        Note over Crate: TRUE - already destroyed
        Crate-->>Object2: Return FALSE (prevent pickup)
    end
Loading

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.

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