Repository navigation
bugfix(scripts): Read Zero Hour script chunks and version 4 polygon triggers when importing scripts #3601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OmarAglan
wants to merge
2
commits into
TheSuperHackers:main
Choose a base branch
from
OmarAglan:bugfix/scripts-read-zh-script-chunks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−8
Open
bugfix(scripts): Read Zero Hour script chunks and version 4 polygon triggers when importing scripts #3601
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
| #include "EditGroup.h" | ||
| #include "EditParameter.h" | ||
| #include "ExportScriptsOptions.h" | ||
| #include "LayersList.h" | ||
| #include "Common/ThingFactory.h" | ||
| #include "WaypointOptions.h" | ||
| #include "Common/UnicodeString.h" | ||
|
|
@@ -1560,11 +1561,14 @@ void ScriptDialog::OnLoad() | |
| } | ||
| PolygonTrigger *pTrig; | ||
| PolygonTrigger *pNextTrig; | ||
| TheLayersList->disableUpdates(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? |
||
| for (pTrig=m_firstTrigger; pTrig; pTrig = pNextTrig) { | ||
| pNextTrig = pTrig->getNext(); | ||
| pTrig->setNextPoly(nullptr); | ||
| PolygonTrigger::addPolygonTrigger(pTrig); | ||
| TheLayersList->addPolygonTriggerToLayersList(pTrig, pTrig->getLayerName()); | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this added? Generals still does not do this. |
||
| } | ||
| TheLayersList->enableUpdates(); | ||
|
|
||
| ScriptList *scripts[MAX_PLAYER_COUNT]; | ||
| Int count = ScriptList::getReadScripts(scripts); | ||
|
|
@@ -1863,6 +1867,7 @@ Bool ScriptDialog::ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunk | |
| Int triggerID; | ||
| // Int maxTriggerId = 0; | ||
| AsciiString triggerName; | ||
| AsciiString layerName; | ||
| // Remove any existing polygon triggers, if any. | ||
| ScriptDialog *pThis = (ScriptDialog *)userData; | ||
| pThis->m_firstTrigger = nullptr; | ||
|
|
@@ -1874,6 +1879,10 @@ Bool ScriptDialog::ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunk | |
| count--; | ||
| Bool isWater = false; | ||
| triggerName = file.readAsciiString(); | ||
| // TheSuperHackers @bugfix Read the layer name of version 4 triggers. | ||
| if (info->version >= K_TRIGGERS_VERSION_4) { | ||
|
xezon marked this conversation as resolved.
Resolved
|
||
| layerName = file.readAsciiString(); | ||
| } | ||
| triggerID = file.readInt(); | ||
| if (info->version >= K_TRIGGERS_VERSION_2) { | ||
| isWater = file.readByte(); | ||
|
|
@@ -1887,6 +1896,9 @@ Bool ScriptDialog::ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunk | |
| numPoints = file.readInt(); | ||
| PolygonTrigger *pTrig = newInstance(PolygonTrigger)(numPoints+1); | ||
| pTrig->setTriggerName(triggerName); | ||
| if (info->version >= K_TRIGGERS_VERSION_4) { | ||
| pTrig->setLayerName(layerName); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| pTrig->setWaterArea(isWater); | ||
| pTrig->setRiver(isRiver); | ||
| pTrig->setRiverStart(riverStart); | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we merge the code from ZH first or what is the plan here?
ZH code will be colliding with the new changes made here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zh reader cant be taken as is yet, it matches the type again through m_internalNameKey, which gen does not have
this PR follows the same layout as zh
to know when Scripts.cpp moves to Core this code is simply replaced by the zh version.
thats being said, if you want and rather unify Scripts.cpp first, i can draft this pr or make another one that do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
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?