You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bugfix(scripts): Read Zero Hour script chunks and version 4 polygon triggers when importing scripts - #3601
Zero Hour writes ScriptAction and ScriptActionFalse chunks as version 2 and Condition chunks as version 4. These versions add a name key after the type. The Generals readers ignored the chunk version and read this name key as the parameter count, so opening a Zero Hour map in the Generals World Builder loaded broken scripts.
This change reads and skips the name key in all three readers.
The Generals script action and condition types are the first entries of the Zero Hour lists, in the same order, so the type number alone identifies them. Types past the end of the Generals list only exist in Zero Hour. They are turned into NO_OP actions or CONDITION_FALSE conditions. Their parameters are not read; closing the chunk skips them.
The new version constants are added after K_SCRIPTS_DATA_VERSION_1 so its implicit value, which is written as the PlayerScriptsList version, does not change.
Writing is unchanged. Generals still writes action version 1 and condition version 3.
Polygon triggers in script import
The script import in the World Builder (ScriptDialog::ParsePolygonTriggersDataChunk) has its own polygon trigger reader. It did not read the layer name that version 4 polygon triggers add after the trigger name, so importing scripts from a map with version 4 triggers (for example water areas from Zero Hour maps) read the rest of each trigger at the wrong position. This is a retail bug in both World Builders.
The reader now reads the layer name for version 4 triggers and sets it on the trigger, like PolygonTrigger::ParsePolygonTriggersDataChunk does. In the Zero Hour World Builder, the imported triggers are also added to the layer list, the same way map loading does it.
AI USE
Used AI in implementing the fix after several rounds of review and simplifying
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Script loading now reads versioned name keys and handles out-of-range condition and action types. Both WorldBuilder variants read layer names from version 4 or later polygon-trigger chunks and assign them to parsed polygon triggers.
Condition parsing reads the version 4 name key. It maps out-of-range types to CONDITION_FALSE and permits their payloads to remain unread.
Action type parsing Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp
Normal and false-action parsing use a shared helper to read action types and version 2 name keys. Out-of-range types map to NO_OP, and their payloads can remain unread.
TheSuperHackers/GeneralsGameCode#3578: Both changes modify script data parsing, including how parameter counts are read for condition and action chunks.
Suggested reviewers: xezon
Merge Risk: Moderate · previous review 05c1c
Resolve parameter-count validation and name-key handling before merging: affected imports can corrupt memory or execute the wrong script behavior. Imported trigger layers also remain inconsistent in Zero Hour’s layer controls and are lost during script export.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: reading Zero Hour script chunks and version 4 polygon triggers during script import in the World Builder. The changeset matches this. The Scripts.cpp changes add name-…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description states the problem and fix for the changeset: Zero Hour ScriptAction, ScriptActionFalse, and Condition chunks add a name key that the Generals readers misread, and the change reads and…
Full details: Title check
Explanation
The title names the main change: reading Zero Hour script chunks and version 4 polygon triggers during script import in the World Builder. The changeset matches this. The Scripts.cpp changes add name-key handling for action version 2 and condition version 4, and ScriptDialog.cpp reads the layer name for version 4 polygon triggers. The title uses a conventional bugfix prefix and is specific.
Full details: Description check
Explanation
The description states the problem and fix for the changeset: Zero Hour ScriptAction, ScriptActionFalse, and Condition chunks add a name key that the Generals readers misread, and the change reads and skips it in all three readers. It also covers the NO_OP/CONDITION_FALSE mapping for Zero Hour-only types, the version constants, the unchanged writing behavior, and the ScriptDialog::ParsePolygonTriggersDataChunk layer-name fix. This matches the Scripts.cpp and ScriptDialog.cpp summaries and the PR objectives, so the description is specific and on-topic.
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.
OmarAglan
changed the title
bugfix(scripts): Read Zero Hour script action and condition chunks in Generals
bugfix(scripts): Read Zero Hour script chunks and version 4 polygon triggers when importing scripts
Oct 26, 2026
The reason will be displayed to describe this comment to others. Learn more.
done removed the reference
and to answer "What was the user facing consequence of this not loaded?"
before this fix, importing scripts in World Builder from a file with version 4 polygon triggers skipped the layer name, so the trigger ID, water and river flags, point count and points were all read from the wrong position. The imported trigger areas came in broken
The reason will be displayed to describe this comment to others. Learn more.
Instead of allocating params here to just throw them away in the next op, try seek forward the DataChunkInput file pointer and avoid the allocation and.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The description still says the parameters of unknown types are read and then deleted. The code now leaves them for the chunk close to skip. Can you update that sentence?
The description still says the parameters of unknown types are read and then deleted. The code now leaves them for the chunk close to skip. Can you update that sentence?
i tend to leave the pr title and description update as last step, as it can change multiple times, that's being said, i updated the pr description nonetheless.
The reason will be displayed to describe this comment to others. Learn more.
Yes maybe we should merge the code first and then mitigate the data serialization edge cases?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScriptIs related to Script Engine, SCBWorldBuilderRelates to World Builder
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zero Hour writes ScriptAction and ScriptActionFalse chunks as version 2 and Condition chunks as version 4. These versions add a name key after the type. The Generals readers ignored the chunk version and read this name key as the parameter count, so opening a Zero Hour map in the Generals World Builder loaded broken scripts.
This change reads and skips the name key in all three readers.
The Generals script action and condition types are the first entries of the Zero Hour lists, in the same order, so the type number alone identifies them. Types past the end of the Generals list only exist in Zero Hour. They are turned into NO_OP actions or CONDITION_FALSE conditions. Their parameters are not read; closing the chunk skips them.
The new version constants are added after K_SCRIPTS_DATA_VERSION_1 so its implicit value, which is written as the PlayerScriptsList version, does not change.
Writing is unchanged. Generals still writes action version 1 and condition version 3.
Polygon triggers in script import
The script import in the World Builder (ScriptDialog::ParsePolygonTriggersDataChunk) has its own polygon trigger reader. It did not read the layer name that version 4 polygon triggers add after the trigger name, so importing scripts from a map with version 4 triggers (for example water areas from Zero Hour maps) read the rest of each trigger at the wrong position. This is a retail bug in both World Builders.
The reader now reads the layer name for version 4 triggers and sets it on the trigger, like PolygonTrigger::ParsePolygonTriggersDataChunk does. In the Zero Hour World Builder, the imported triggers are also added to the layer list, the same way map loading does it.
AI USE
Used AI in implementing the fix after several rounds of review and simplifying