The loader keeps no migrations any more: an asset of the old type autotile (before #131) is an unknown type and dropped, and a tilemap layer with the cell map of the first version (before #134) loads empty; every project is saved in the current format, and the two tests now pin that the old shapes are not read (#137)
game-maker / gate (push) Successful in 1m49s
game-maker / suite (push) Successful in 6m19s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-18 15:12:07 +02:00
1 parent bffa508ee7
commit c91c18f495
4 files changed
+13 -47

No files matched your search

+3 -15
View File
@@ -28,7 +28,7 @@ import type {
TilemapLayer,
} from '../model/Asset';
import { parseCellKey } from '../model/tilemap';
import { decodeCells, encodeCells, isStoredCells } from './tilemapCells';
import { decodeCells, encodeCells } from './tilemapCells';
import { isAssetType } from '../model/AssetTypes';
import { isFontFile } from '../model/font';
import { isSoundFile } from '../model/sound';
@@ -80,7 +80,7 @@ import { SHADER_KEY, shaderParamDefs } from '../properties/shaders';
*/
export function deserializeProject(raw: unknown, fallbackId = ''): Project {
const r = asRecord(raw);
const rawAssets = (Array.isArray(r.assets) ? r.assets : []).map(asRecord).map(migrateAsset);
const rawAssets = (Array.isArray(r.assets) ? r.assets : []).map(asRecord);
// Pass 1: asset ids and their effective schemas, needed to coerce overrides in pass 2.
const schemas = new Map<string, PropertySchema>();
@@ -524,8 +524,7 @@ function normalizeLayers(raw: unknown): TilemapLayer[] {
for (const item of Array.isArray(raw) ? raw : []) {
const l = asRecord(item);
if (typeof l.id !== 'string' || !l.id || layers.some((o) => o.id === l.id)) continue;
// Projects saved before #134 hold the map itself; it is taken over as it is.
const stored = isStoredCells(l) ? decodeCells(l) : asRecord(l.cells);
const stored = decodeCells(l);
const cells: Record<string, string> = {};
for (const [key, value] of Object.entries(stored))
if (parseCellKey(key) && typeof value === 'string' && value !== '') cells[key] = value;
@@ -550,17 +549,6 @@ function normalizeBag(raw: unknown, schema: PropertySchema, sparse: boolean): Pr
return bag;
}
/**
* A tile was called an autotile before it could be a plain one (#131). Such an asset had no kind
* but the autotile blocks, and one written without a kind meant a floor – which it has to stay now
* that a missing kind means a plain tile.
*/
function migrateAsset(a: Record<string, unknown>): Record<string, unknown> {
if (a.type !== 'autotile') return a;
const props = asRecord(a.props);
return { ...a, type: 'tile', props: { ...props, kind: props.kind ?? 'floor' } };
}
function asRecord(value: unknown): Record<string, unknown> {
return value && typeof value === 'object' ? (value as Record<string, unknown>) : {};
}