MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / migrateWorldData

Function migrateWorldData

src/world/version.ts:14–32  ·  view source on GitHub ↗
(raw: WorldData)

Source from the content-addressed store, hash-verified

12// input is from a future version — in that case we proceed anyway and hope
13// the extra fields are ignored, since we can't forward-migrate.
14export function migrateWorldData(raw: WorldData): WorldData {
15 const from = raw.schemaVersion | 0;
16
17 if (from === WORLD_SCHEMA_VERSION) {
18 return raw;
19 }
20
21 if (from > WORLD_SCHEMA_VERSION) {
22 // Future version — we may be missing fields. Warn and continue.
23 return raw;
24 }
25
26 // from < WORLD_SCHEMA_VERSION. Apply migration steps in order.
27 // When bumping WORLD_SCHEMA_VERSION, add a step here of the form:
28 // if (raw.schemaVersion < N) { migrateWorldV(N-1, N, raw); raw.schemaVersion = N; }
29
30 raw.schemaVersion = WORLD_SCHEMA_VERSION;
31 return raw;
32}
33
34export function migratePrefabData(raw: PrefabData): PrefabData {
35 const from = raw.schemaVersion | 0;

Callers 1

loadWorldFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected