Fix up list monitor names during deserialization

This commit is contained in:
adroitwhiz 2020-02-17 01:34:36 -05:00
parent 8faad67439
commit 48088f40f8

View file

@ -1098,6 +1098,20 @@ const deserializeMonitor = function (monitorData, runtime, targets, extensions)
// This will be undefined for extension blocks // This will be undefined for extension blocks
const monitorBlockInfo = runtime.monitorBlockInfo[monitorData.opcode]; 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 // Convert the serialized monitorData params into the block fields structure
const fields = {}; const fields = {};
for (const paramKey in monitorData.params) { for (const paramKey in monitorData.params) {