Skip to content

bugfix(worldbuilder): Match imported scripts to the correct player - #3408

Draft
OmarAglan wants to merge 1 commit into
TheSuperHackers:mainfrom
OmarAglan:bugfix/worldbuilder-script-player-matching
Draft

OmarAglan wants to merge 1 commit into
TheSuperHackers:mainfrom
OmarAglan:bugfix/worldbuilder-script-player-matching

Conversation

@OmarAglan

@OmarAglan OmarAglan commented Oct 3, 2026 •

Copy link
Copy Markdown

Relates to #555.

Fixes player-name matching when importing scripts in both WorldBuilder versions.

The lookup previously compared current side i with imported player j, then selected side j. Different player ordering could assign scripts to the wrong player. More imported players than existing sides could also cause an invalid side access.

Compare current side j with imported player i instead. Single-list imports retain the existing selected-player behavior.

Validation:

  • Both VC6 Release WorldBuilder targets build.
  • Extracted production code passes 2,433 routing checks per game.
  • Tests cover reordered players, missing players, unequal counts, neutral players and single-list selection.
  • Baseline tests reproduce the incorrect assignment and invalid side access.

AI assistance was used for implementation and local verification.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7655365a-79d8-4b30-ad50-e416cfb477ed
📥 Commits

Reviewing files that changed from the base of the PR and between 5ae042c and 6d06903.

📒 Files selected for processing (2)
  • Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.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.


Walkthrough

The script import loops in both WorldBuilder versions now compare current map-side names with imported player names using the corresponding loop indices.

Changes

Script import name matching

Layer / File(s) Summary
Compare imported and current player names
Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp, GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
Both import loops now compare the current side at index j with the imported player name at index i. Existing unmatched-player handling remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 6d069

Script imports now match player names to the intended map sides, and the one-list case targets the sole side. No merge-blocking risk remains beyond normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 6d069

The change affects 2 systems.

Changed systems: Generals, GeneralsMD

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — Generals (service) was modified; 1 changed file maps to changed impact.
  • observed — GeneralsMD (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp: The import loop now compares current side j's player name with imported player name i; previously it compared side i's name with imported name j.
  • observed — Modified behavior in GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp: The import-side matching loop now compares each current side name at index j with the imported player name at index i. Previously, it read the current side at index i and compared it with imported name j.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: matching imported scripts to the correct player.
Description check ✅ Passed The description explains the player-name matching fix, its impact, and validation performed.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant