Log a warning for currentCostume out of range when incorrect project is being serialized.

This commit is contained in:
Karishma Chadha 2019-01-08 13:26:06 -05:00
parent c27b624401
commit bb8463f14a

View file

@ -447,6 +447,13 @@ const serializeTarget = function (target, extensions) {
obj.broadcasts = vars.broadcasts;
[obj.blocks, targetExtensions] = serializeBlocks(target.blocks);
obj.comments = serializeComments(target.comments);
// TODO remove this check/patch when (#1901) is fixed
if (target.currentCostume < 0 || target.currentCostume >= target.costumes.length) {
log.warn(`currentCostume property for target ${target.name} is out of range`);
target.currentCostume = MathUtil.clamp(target.currentCostume, 0, target.costumes.length - 1);
}
obj.currentCostume = target.currentCostume;
obj.costumes = target.costumes.map(serializeCostume);
obj.sounds = target.sounds.map(serializeSound);