Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
#define NO_DEBUG_CRC

#include "Common/PerfTimer.h"
#include "Common/Player.h"
#include "Common/ThingTemplate.h"
#include "Common/Xfer.h"
#include "GameClient/FXList.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/Module/AIUpdate.h"
#include "GameLogic/Module/BodyModule.h"
Expand Down Expand Up @@ -1262,7 +1264,26 @@ void PhysicsBehavior::onCollide( Object *other, const Coord3D *loc, const Coord3
// fall into a nonbuilding -- whatever. if we're a vehicle, quietly do a little damage.
if (obj->isKindOf(KINDOF_VEHICLE))
{
#if RETAIL_COMPATIBLE_CRC
TheWeaponStore->createAndFireTempWeapon(getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate, obj, obj->getPosition());
#else
// TheSuperHackers @bugfix Stubbjax 19/04/2026 Prevent non-building collisions from repeatedly dealing collateral damage to other objects.
const WeaponTemplate* weaponTemplate = getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate;
if (weaponTemplate != nullptr)
{
WeaponBonus nullBonus;

DamageInfo damageInfo;
damageInfo.in.m_damageType = weaponTemplate->getDamageType();
damageInfo.in.m_deathType = weaponTemplate->getDeathType();
damageInfo.in.m_sourceID = obj->getID();
damageInfo.in.m_sourcePlayerMask = obj->getControllingPlayer() ? obj->getControllingPlayer()->getPlayerMask() : 0;
damageInfo.in.m_amount = weaponTemplate->getPrimaryDamage(nullBonus);
Comment on lines +1270 to +1281
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 The DamageInfo is populated without setting m_sourcePlayerMask. In the standard weapon path (dealDamageInternal), this field is populated from the source object's controlling player. Object.cpp reads it to decide whether to trigger a radar alert for the locally-controlled owner, and ScriptConditions.cpp uses it to resolve which player last damaged a unit. With the field left at its default of 0, crash-damage hits will skip radar warnings on the victim's side and any script trigger keyed on "attacked by player X" will fail to identify the attacker.

Suggested change
// TheSuperHackers @bugfix Stubbjax 19/04/2026 Prevent non-building collisions from repeatedly dealing collateral damage to other objects.
const WeaponTemplate* weaponTemplate = getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate;
if (weaponTemplate != nullptr)
{
WeaponBonus nullBonus;
DamageInfo damageInfo;
damageInfo.in.m_damageType = weaponTemplate->getDamageType();
damageInfo.in.m_deathType = weaponTemplate->getDeathType();
damageInfo.in.m_sourceID = obj->getID();
damageInfo.in.m_amount = weaponTemplate->getPrimaryDamage(nullBonus);
// TheSuperHackers @bugfix Stubbjax 19/04/2026 Prevent non-building collisions from repeatedly dealing collateral damage to other objects.
const WeaponTemplate* weaponTemplate = getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate;
if (weaponTemplate != nullptr)
{
WeaponBonus nullBonus;
DamageInfo damageInfo;
damageInfo.in.m_damageType = weaponTemplate->getDamageType();
damageInfo.in.m_deathType = weaponTemplate->getDeathType();
damageInfo.in.m_sourceID = obj->getID();
damageInfo.in.m_sourcePlayerMask = obj->getControllingPlayer() ? obj->getControllingPlayer()->getPlayerMask() : 0;
damageInfo.in.m_amount = weaponTemplate->getPrimaryDamage(nullBonus);
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp
Line: 1269-1279

Comment:
The `DamageInfo` is populated without setting `m_sourcePlayerMask`. In the standard weapon path (`dealDamageInternal`), this field is populated from the source object's controlling player. `Object.cpp` reads it to decide whether to trigger a radar alert for the locally-controlled owner, and `ScriptConditions.cpp` uses it to resolve which player last damaged a unit. With the field left at its default of 0, crash-damage hits will skip radar warnings on the victim's side and any script trigger keyed on "attacked by player X" will fail to identify the attacker.

```suggestion
						// TheSuperHackers @bugfix Stubbjax 19/04/2026 Prevent non-building collisions from repeatedly dealing collateral damage to other objects.
						const WeaponTemplate* weaponTemplate = getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate;
						if (weaponTemplate != nullptr)
						{
							WeaponBonus nullBonus;

							DamageInfo damageInfo;
							damageInfo.in.m_damageType = weaponTemplate->getDamageType();
							damageInfo.in.m_deathType = weaponTemplate->getDeathType();
							damageInfo.in.m_sourceID = obj->getID();
							damageInfo.in.m_sourcePlayerMask = obj->getControllingPlayer() ? obj->getControllingPlayer()->getPlayerMask() : 0;
							damageInfo.in.m_amount = weaponTemplate->getPrimaryDamage(nullBonus);
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Greptile is complaining


other->attemptDamage(&damageInfo);
FXList::doFXObj(weaponTemplate->getFireFX(obj->getVeterancyLevel()), obj);
}
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
#define NO_DEBUG_CRC

#include "Common/PerfTimer.h"
#include "Common/Player.h"
#include "Common/ThingTemplate.h"
#include "Common/Xfer.h"
#include "GameClient/FXList.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/Module/AIUpdate.h"
#include "GameLogic/Module/BodyModule.h"
Expand Down Expand Up @@ -1387,7 +1389,26 @@ void PhysicsBehavior::onCollide( Object *other, const Coord3D *loc, const Coord3
// fall into a nonbuilding -- whatever. if we're a vehicle, quietly do a little damage.
if (obj->isKindOf(KINDOF_VEHICLE))
{
#if RETAIL_COMPATIBLE_CRC
TheWeaponStore->createAndFireTempWeapon(getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate, obj, obj->getPosition());
#else
// TheSuperHackers @bugfix Stubbjax 19/04/2026 Prevent non-building collisions from repeatedly dealing collateral damage to other objects.
const WeaponTemplate* weaponTemplate = getPhysicsBehaviorModuleData()->m_vehicleCrashesIntoNonBuildingWeaponTemplate;
if (weaponTemplate != nullptr)
{
WeaponBonus nullBonus;

DamageInfo damageInfo;
damageInfo.in.m_damageType = weaponTemplate->getDamageType();
damageInfo.in.m_deathType = weaponTemplate->getDeathType();
damageInfo.in.m_sourceID = obj->getID();
damageInfo.in.m_sourcePlayerMask = obj->getControllingPlayer() ? obj->getControllingPlayer()->getPlayerMask() : 0;
damageInfo.in.m_amount = weaponTemplate->getPrimaryDamage(nullBonus);
Comment thread
greptile-apps[bot] marked this conversation as resolved.

other->attemptDamage(&damageInfo);
FXList::doFXObj(weaponTemplate->getFireFX(obj->getVeterancyLevel()), obj);
}
#endif
}
}
}
Expand Down
Loading