fix(aiplayer): Initialize uninitialized variables in Generals AIPlayer::getPlayerStructureBounds - #3426
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. Walkthrough
ChangesStructure Bounds Initialization
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to Both variants now return initialized bounds when a player is missing, while preserving valid-player bounds calculations; no actionable merge risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f4d98897-eaff-4b15-9678-83eb8e49724f
📒 Files selected for processing (2)
Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppGeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
fec4990 to
fac88a1
Compare
Variables
bounds->lo.yandobjBounds.lo.yin functionAIPlayer::getPlayerStructureBoundsare not initialized due to a typo. This only affects the Generals version. This PR fixes that, refactors some of the surrounding code and replicates the changes to Zero Hour. The code changes should not affect the game logic.See commits for clean diffs.
I checked when the variables would be left uninitialized and in my testing I encountered only one scenario with the following callstack:
This happens in matches with one or more ai players and this code gets executed just at the 'wrong' time where a player has already died (no structures or units), but they're still considered the 'current' enemy to an ai player (this gets updated every N frames).
The uninitialized values that I observed with the Steam binary were always very close to 0. I also checked ~2000 gentool replays with one or more ai players and didn't see a mismatch because of this change.