Skip to content

bugfix(physics): Prevent building crash damage from dealing damage to other objects#2723

Merged
xezon merged 3 commits into
TheSuperHackers:mainfrom
Stubbjax:fix-dead-unit-building-crash-damage
May 20, 2026
Merged

bugfix(physics): Prevent building crash damage from dealing damage to other objects#2723
xezon merged 3 commits into
TheSuperHackers:mainfrom
Stubbjax:fix-dead-unit-building-crash-damage

Conversation

@Stubbjax
Copy link
Copy Markdown

This change prevents collateral damage caused by VehicleCrashesIntoBuildingWeapon when a dead vehicle collides with a building. This fix is supplemental to #2204.

Before

The Tank Hunters receive damage if the dead Helix collides with the Bunker

INJURED.mp4

After

The Tank Hunters no longer receive damage if the dead Helix collides with the Bunker

HEALTHY.mp4

@Stubbjax Stubbjax self-assigned this May 17, 2026
@Stubbjax Stubbjax added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour NoRetail This fix or change is not applicable with Retail game compatibility labels May 17, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR fixes an unintended splash-damage side effect from VehicleCrashesIntoBuildingWeapon, guarded behind #if !RETAIL_COMPATIBLE_CRC, so the retail CRC path is unchanged. The fix is a direct supplement to #2204.

  • Instead of createAndFireTempWeapon (which fires an area weapon and can hit nearby units), the new path calls other->attemptDamage directly, targeting only the specific building that was collided with, then fires the fire FX on the crashing vehicle.
  • A null-guard for weaponTemplate is included, preventing crashes when the template is absent or set to None.
  • The same change is applied identically in both Generals/ and GeneralsMD/ to cover the base game and Zero Hour expansion.

Confidence Score: 5/5

The change is safe to merge — the retail CRC path is untouched, and the new non-retail path is well-guarded and tightly scoped.

The fix is logically correct: other is already confirmed non-null (checked via isKindOf(KINDOF_STRUCTURE) just above), weaponTemplate is now null-guarded, and damage is applied only to the collided building. No unguarded dereferences, no regression risk on the retail path, and both game variants (Generals and Zero Hour) receive the identical fix.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp Adds direct single-target damage path for vehicle-building crashes behind !RETAIL_COMPATIBLE_CRC; null-guards the weapon template and fires FX on the crashing vehicle.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp Identical change as the Generals/ counterpart applied to the Zero Hour expansion, with the same null-guard and direct damage approach.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[onCollide triggered] --> B{other is KINDOF_STRUCTURE?}
    B -- No --> C[Apply non-building crash weapon\nvia createAndFireTempWeapon]
    B -- Yes --> D{obj is KINDOF_VEHICLE?}
    D -- No --> E[destroyObject obj]
    D -- Yes --> F{RETAIL_COMPATIBLE_CRC?}
    F -- Yes --> G[createAndFireTempWeapon\nArea damage: hits nearby units]
    F -- No --> H{weaponTemplate != nullptr?}
    H -- No --> E
    H -- Yes --> I[Build DamageInfo from\nprimary damage + type/death]
    I --> J[other->attemptDamage\nOnly damages the building]
    J --> K[FXList::doFXObj on obj\nFire FX on crashing vehicle]
    K --> E
    G --> E
Loading

Reviews (4): Last reviewed commit: "tweak: Assign source player mask" | Re-trigger Greptile

@Stubbjax Stubbjax force-pushed the fix-dead-unit-building-crash-damage branch from 439ebf3 to c70ab6b Compare May 20, 2026 05:51
@xezon xezon changed the title bugfix: Prevent building crash damage from dealing damage to other objects bugfix(physics): Prevent building crash damage from dealing damage to other objects May 20, 2026
@xezon xezon merged commit f8476f0 into TheSuperHackers:main May 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker NoRetail This fix or change is not applicable with Retail game compatibility ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants