Add optional integer reading utility and update version compatibility for spline repeaters.

This commit is contained in:
2026-05-13 03:41:00 +02:00
parent 02d4cfbcea
commit 386fd2f387

View File

@@ -767,6 +767,24 @@ function readOptionalPositiveInteger(
return integerValue;
}
function readOptionalInteger(
value: unknown,
label: string,
fallback: number
): number {
if (value === undefined) {
return fallback;
}
const integerValue = expectFiniteNumber(value, label);
if (!Number.isInteger(integerValue)) {
throw new Error(`${label} must be an integer.`);
}
return integerValue;
}
function readOptionalPositiveIntegerWithMax(
value: unknown,
label: string,
@@ -6562,6 +6580,7 @@ export function migrateSceneDocument(source: unknown): SceneDocument {
source.version !== PATH_ROAD_PREVIEW_SCENE_DOCUMENT_VERSION &&
source.version !== DYNAMIC_TERRAIN_LAYERS_SCENE_DOCUMENT_VERSION &&
source.version !== SPLINE_ROAD_EDGES_SCENE_DOCUMENT_VERSION &&
source.version !== SPLINE_REPEATERS_SCENE_DOCUMENT_VERSION &&
source.version !== NPC_TARGETING_SCENE_DOCUMENT_VERSION
) {
throw new Error(