From 48088f40f8ea2d70370b8de45f420455f1312812 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Mon, 17 Feb 2020 01:34:36 -0500 Subject: [PATCH] Fix up list monitor names during deserialization --- src/serialization/sb3.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index 412a758eb..d49365671 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -1098,6 +1098,20 @@ const deserializeMonitor = function (monitorData, runtime, targets, extensions) // This will be undefined for extension blocks const monitorBlockInfo = runtime.monitorBlockInfo[monitorData.opcode]; + // Due to a bug (see https://github.com/LLK/scratch-vm/pull/2322), renamed list monitors may have been serialized + // with an outdated/incorrect LIST parameter. Fix it up to use the current name of the actual corresponding list. + if (monitorData.opcode === 'data_listcontents') { + const listTarget = monitorData.targetId ? + targets.find(t => t.id === monitorData.targetId) : + targets.find(t => t.isStage); + if ( + listTarget && + Object.prototype.hasOwnProperty.call(listTarget.variables, monitorData.id) + ) { + monitorData.params.LIST = listTarget.variables[monitorData.id].name; + } + } + // Convert the serialized monitorData params into the block fields structure const fields = {}; for (const paramKey in monitorData.params) {