This fixes errors to do with setting a sprite's costume number to zero or below, using two approaches:
Avoid fatal errors when costume is null — (minimally) increased guarding in renderer
Don't get into the incorrect situation where costume is null in the first place!
The latter part improves compatibility: in Scratch, a sprite's costume number wraps on both ends of its bounding range, > this.costumes.length and <= 0. In Leopard, we were only properly wrapping on the positive end — this PR fixes that with the same wrap algorithm used in scratch-vm.
I've reverted the commit which affects the renderer because I'm not well familiar with the code paths and it's not necessary to change the renderer to avoid the circumstance which brought about errors there.
This fixes errors to do with setting a sprite's costume number to zero or below, using two approaches:
Avoid fatal errors when costume is null — (minimally) increased guarding in rendererThe latter part improves compatibility: in Scratch, a sprite's costume number wraps on both ends of its bounding range,
> this.costumes.length
and<= 0
. In Leopard, we were only properly wrapping on the positive end — this PR fixes that with the same wrap algorithm used in scratch-vm.Thanks, @tmickel :P LLK/scratch-vm#87