Skip to content

test(neutronmissile): Add debug draw for nuke missile radius - #3160

Open
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/test-nuke-missile-radius
Open

test(neutronmissile): Add debug draw for nuke missile radius#3160
xezon wants to merge 1 commit into
TheSuperHackers:mainfrom
xezon:xezon/test-nuke-missile-radius

Conversation

@xezon

@xezon xezon commented Aug 16, 2026

Copy link
Copy Markdown

This change adds a debug draw for the nuke missile radius in RTS_DEBUG.

Can be toggled with particle path debug CTRL+SHIFT+B

Base code was generated by Claude Opus and tweaked by hand.

sshot_20260816_174324_617

Can be toggled with particle path debug CTRL+SHIFT+B
@xezon xezon added China Affects China faction Debug Is mostly debug functionality labels Aug 16, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Outer radius ring omitted 🐞 Bug ≡ Correctness
Description
displayBlastRadii() draws the outer-radius ring only when minDamage > 0, even though doBlast() still
uses outerRadius to scan/compute falloff damage when minDamage == 0. This can hide the real affected
area in the new debug visualization and mislead tuning/debugging.
Code

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[R332-335]

+	if (blastInfo->minDamage > 0.0f)
+	{
+		drawDebugRadiusRing( missilePos, blastInfo->outerRadius, tileWidth, duration, outerColor );
+	}
Evidence
The new code conditions the outer ring on minDamage, but the actual blast logic still uses
outerRadius for iteration and falloff regardless of minDamage, so the outer radius remains
semantically meaningful even when minDamage is zero.

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[318-336]
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[364-414]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The debug visualization draws the outer ring only when `blastInfo->minDamage > 0.0f`. But `doBlast()` still iterates/scans objects in `outerRadius` and computes falloff using `outerRadius` even when `minDamage == 0.0f`.

## Issue Context
This makes the debug ring omit the meaningful outer boundary for weapons where damage falls off to 0 at the edge.

## Fix Focus Areas
- Update the condition in `displayBlastRadii()` to use `blastInfo->outerRadius` (and optionally `blastInfo->maxDamage || blastInfo->minDamage`) rather than requiring `minDamage > 0`.
- file: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[318-336]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. Unclamped icon tile width 🐞 Bug ☼ Reliability
Description
drawDebugRadiusRing() clamps tileWidth only for segment count, but passes the raw tileWidth into
addIcon(); if DebugProjectileTileWidth is configured as 0 or negative, icons become
degenerate/unintended and the ring can disappear or render incorrectly. This makes the new debug
feature fragile to configuration values.
Code

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[R312-315]

+		pos.z = TheTerrainLogic->getGroundHeight( pos.x, pos.y );
+
+		addIcon( &pos, tileWidth, numFramesDuration, color );
+	}
Evidence
The configuration value is not clamped on load, and the debug-icon renderer uses width directly, so
passing non-positive widths through can produce degenerate or unintended geometry and break the
visualization.

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[293-316]
GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp[511-526]
GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDebugIcons.cpp[188-205]
GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDebugIcons.cpp[263-270]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`drawDebugRadiusRing()` uses `max(tileWidth, 1.0f)` to avoid divide-by-zero in segment calculation, but still calls `addIcon(..., tileWidth, ...)` with the original value.

## Issue Context
`DebugProjectileTileWidth` is parsed as a raw `Real` with no validation, and the renderer uses `width/2` directly when building quads.

## Fix Focus Areas
- Sanitize width once (e.g., `Real iconWidth = max(tileWidth, 1.0f);`) and use `iconWidth` for both segment calculation and the `addIcon()` call.
- file: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[293-316]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +332 to +335
if (blastInfo->minDamage > 0.0f)
{
drawDebugRadiusRing( missilePos, blastInfo->outerRadius, tileWidth, duration, outerColor );
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Outer radius ring omitted 🐞 Bug ≡ Correctness

displayBlastRadii() draws the outer-radius ring only when minDamage > 0, even though doBlast() still
uses outerRadius to scan/compute falloff damage when minDamage == 0. This can hide the real affected
area in the new debug visualization and mislead tuning/debugging.
Agent Prompt
## Issue description
The debug visualization draws the outer ring only when `blastInfo->minDamage > 0.0f`. But `doBlast()` still iterates/scans objects in `outerRadius` and computes falloff using `outerRadius` even when `minDamage == 0.0f`.

## Issue Context
This makes the debug ring omit the meaningful outer boundary for weapons where damage falls off to 0 at the edge.

## Fix Focus Areas
- Update the condition in `displayBlastRadii()` to use `blastInfo->outerRadius` (and optionally `blastInfo->maxDamage || blastInfo->minDamage`) rather than requiring `minDamage > 0`.
- file: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[318-336]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +312 to +315
pos.z = TheTerrainLogic->getGroundHeight( pos.x, pos.y );

addIcon( &pos, tileWidth, numFramesDuration, color );
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

2. Unclamped icon tile width 🐞 Bug ☼ Reliability

drawDebugRadiusRing() clamps tileWidth only for segment count, but passes the raw tileWidth into
addIcon(); if DebugProjectileTileWidth is configured as 0 or negative, icons become
degenerate/unintended and the ring can disappear or render incorrectly. This makes the new debug
feature fragile to configuration values.
Agent Prompt
## Issue description
`drawDebugRadiusRing()` uses `max(tileWidth, 1.0f)` to avoid divide-by-zero in segment calculation, but still calls `addIcon(..., tileWidth, ...)` with the original value.

## Issue Context
`DebugProjectileTileWidth` is parsed as a raw `Real` with no validation, and the renderer uses `width/2` directly when building quads.

## Fix Focus Areas
- Sanitize width once (e.g., `Real iconWidth = max(tileWidth, 1.0f);`) and use `iconWidth` for both segment calculation and the `addIcon()` call.
- file: GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp[293-316]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add RTS_DEBUG blast-radius debug draw for Neutron Missile

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Render Neutron Missile inner/outer blast radii as debug icon rings in RTS_DEBUG.
• Gate drawing behind Projectile Path debug toggle (CTRL+SHIFT+B).
• Use configurable debug tile width to control ring sampling density and icon sizing.
Diagram

graph TD
  A["NeutronMissileSlowDeathBehavior::doBlast"] --> B{"RTS_DEBUG && DebugProjectilePath?"} -->|"yes"| C["displayBlastRadii"] --> D["drawDebugRadiusRing"] --> E["TerrainLogic.getGroundHeight"] --> F["addIcon (debug overlay)"]
  B -->|"no"| G["Normal blast processing"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract shared debug-ring utility
  • ➕ Avoids duplicating math/sampling logic if other weapons add radius visualizations
  • ➕ Central place to tune segment clamping, duration defaults, and color conventions
  • ➖ Requires choosing/creating a common debug utility location and wiring includes
  • ➖ Slightly more upfront refactor than a localized debug addition
2. Use a line/primitive debug renderer instead of icons
  • ➕ Smoother-looking circles with fewer draw calls than many icons
  • ➕ More flexible (thickness, anti-aliasing, multiple rings)
  • ➖ May require additional rendering plumbing if a suitable primitive debug API isn’t already exposed
  • ➖ Less consistent with existing debug icon-based tooling (tile width, durations)

Recommendation: The current approach (icon ring drawing behind the existing projectile-path debug toggle) is a pragmatic, low-risk way to visualize blast radii quickly and consistently with existing debug tooling. If similar radius visualizations are expected to spread to other weapons, consider extracting drawDebugRadiusRing into a shared debug helper to reduce duplication.

Files changed (1) +55 / -0

Enhancement (1) +55 / -0
NeutronMissileSlowDeathUpdate.cppAdd RTS_DEBUG icon-ring rendering for neutron blast inner/outer radii +55/-0

Add RTS_DEBUG icon-ring rendering for neutron blast inner/outer radii

• Adds RTS_DEBUG-only helpers to draw circular debug rings using existing addIcon rendering, sampling points around the circumference and projecting onto terrain height. Hooks the visualization into doBlast when m_debugProjectilePath is enabled, drawing inner (full damage) and outer (falloff) radii using distinct colors and debug tile width for sizing.

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/NeutronMissileSlowDeathUpdate.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

China Affects China faction Debug Is mostly debug functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant