mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Log a warning for currentCostume out of range when incorrect project is being serialized.
This commit is contained in:
parent
c27b624401
commit
bb8463f14a
1 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue