1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-18 22:09:20 +00:00

Ensure that layerToMergeAt is not less than 0.

This commit is contained in:
hexagonhexagon 2020-06-30 17:46:48 -04:00
parent c05661ceb8
commit 36a4677c21

View File

@ -536,7 +536,8 @@ export class ShapeDefinition extends BasicSerializableObject {
gapsBetweenShapes.push(topShapeLowestLayerByQuad[quad] - bottomShapeHighestLayerByQuad[quad]);
}
const smallestGapBetweenShapes = Math.min(...gapsBetweenShapes);
const layerToMergeAt = 1 - smallestGapBetweenShapes;
// Can't merge at a layer lower than 0
const layerToMergeAt = Math.max(1 - smallestGapBetweenShapes, 0);
const mergedLayers = this.internalCloneLayers();
for (let layer = mergedLayers.length; layer < layerToMergeAt + topShapeLayers.length; ++layer) {