diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index a962672c9..e4048d45d 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -34,11 +34,7 @@ import { PlayerUpdate, UnitUpdate, } from "./GameUpdates"; -import { - MOTION_PLANS_SCHEMA_VERSION, - MotionPlanRecord, - unpackMotionPlans, -} from "./MotionPlans"; +import { MotionPlanRecord, unpackMotionPlans } from "./MotionPlans"; import { TerrainMapData } from "./TerrainMapLoader"; import { TerraNulliusImpl } from "./TerraNulliusImpl"; import { UnitGrid, UnitPredicate } from "./UnitGrid"; @@ -725,12 +721,8 @@ export class GameView implements GameMap { } if (gu.packedMotionPlans) { - const { schemaVersion, records } = unpackMotionPlans( - gu.packedMotionPlans, - ); - if (schemaVersion === MOTION_PLANS_SCHEMA_VERSION) { - this.applyMotionPlanRecords(records); - } + const records = unpackMotionPlans(gu.packedMotionPlans); + this.applyMotionPlanRecords(records); } if (gu.updates === null) { diff --git a/src/core/game/MotionPlans.ts b/src/core/game/MotionPlans.ts index fbcf0858f..4417d0212 100644 --- a/src/core/game/MotionPlans.ts +++ b/src/core/game/MotionPlans.ts @@ -1,7 +1,5 @@ import { TileRef } from "./GameMap"; -export const MOTION_PLANS_SCHEMA_VERSION = 4; - export enum PackedMotionPlanKind { GridPathSet = 1, TrainRailPathSet = 2, @@ -41,7 +39,7 @@ export type MotionPlanRecord = GridPathPlan | TrainRailPathPlan; export function packMotionPlans( records: readonly MotionPlanRecord[], ): Uint32Array { - let totalWords = 2; + let totalWords = 1; for (const record of records) { switch (record.kind) { case "grid": { @@ -59,10 +57,9 @@ export function packMotionPlans( } const out = new Uint32Array(totalWords); - out[0] = MOTION_PLANS_SCHEMA_VERSION >>> 0; - out[1] = records.length >>> 0; + out[0] = records.length >>> 0; - let offset = 2; + let offset = 1; for (const record of records) { switch (record.kind) { case "grid": { @@ -120,19 +117,14 @@ export function packMotionPlans( return out; } -export function unpackMotionPlans(packed: Uint32Array): { - schemaVersion: number; - records: MotionPlanRecord[]; -} { - if (packed.length < 2) { - return { schemaVersion: 0, records: [] }; +export function unpackMotionPlans(packed: Uint32Array): MotionPlanRecord[] { + if (packed.length < 1) { + return []; } - const schemaVersion = packed[0] >>> 0; - const recordCount = packed[1] >>> 0; - + const recordCount = packed[0] >>> 0; const records: MotionPlanRecord[] = []; - let offset = 2; + let offset = 1; for (let i = 0; i < recordCount && offset + 1 < packed.length; i++) { const kind = packed[offset] >>> 0; @@ -216,5 +208,5 @@ export function unpackMotionPlans(packed: Uint32Array): { offset += wordCount; } - return { schemaVersion, records }; + return records; }