Skip to content

Commit

Permalink
Tolerate sb3 targets without comments and blocks without inputs
Browse files Browse the repository at this point in the history
Fixes 1032296687
  • Loading branch information
GarboMuffin committed Jul 22, 2024
1 parent e6a9481 commit 1ac63ff
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/packager/minify/sb3.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ const optimizeSb3Json = (projectData) => {
blockPool.addReference(block.next);
}

for (const input of Object.values(block.inputs)) {
for (let i = 1; i < input.length; i++) {
const inputValue = input[i];
if (typeof inputValue === 'string') {
blockPool.addReference(inputValue);
if (block.inputs) {
for (const input of Object.values(block.inputs)) {
for (let i = 1; i < input.length; i++) {
const inputValue = input[i];
if (typeof inputValue === 'string') {
blockPool.addReference(inputValue);
}
}
}
}
Expand Down Expand Up @@ -114,11 +116,13 @@ const optimizeSb3Json = (projectData) => {
block.next = blockPool.getNewId(block.next);
}

for (const input of Object.values(block.inputs)) {
for (let i = 1; i < input.length; i++) {
const inputValue = input[i];
if (typeof inputValue === 'string') {
input[i] = blockPool.getNewId(inputValue);
if (block.inputs) {
for (const input of Object.values(block.inputs)) {
for (let i = 1; i < input.length; i++) {
const inputValue = input[i];
if (typeof inputValue === 'string') {
input[i] = blockPool.getNewId(inputValue);
}
}
}
}
Expand All @@ -132,11 +136,13 @@ const optimizeSb3Json = (projectData) => {
delete block.y;
delete block.comment;
}
for (const [commentId, comment] of Object.entries(target.comments)) {
const text = comment.text;
const isSpecial = text.includes(' // _twconfig_') || text.includes(' // _gamepad_');
if (isSpecial) {
newComments[commentId] = comment;
if (target.comments) {
for (const [commentId, comment] of Object.entries(target.comments)) {
const text = comment.text;
const isSpecial = text.includes(' // _twconfig_') || text.includes(' // _gamepad_');
if (isSpecial) {
newComments[commentId] = comment;
}
}
}

Expand Down

0 comments on commit 1ac63ff

Please sign in to comment.