diff --git a/src/js/game/blueprint.js b/src/js/game/blueprint.js index 40c3dff8..23686fa8 100644 --- a/src/js/game/blueprint.js +++ b/src/js/game/blueprint.js @@ -34,7 +34,14 @@ export class Blueprint { * Serialize */ serialize() { - return this.serializer.serializeEntityArray(this.entities); + let data = this.serializer.serializeEntityArray(this.entities); + // Remove unneeded fields + for (let i = 0; i < data.length; ++i) { + const entry = data[i]; + delete entry.uid; + delete entry.components.WiredPins; + } + return data; } /** @@ -59,6 +66,10 @@ export class Blueprint { if (value.components == undefined || value.components.StaticMapEntity == undefined) { return; } + const staticData = value.components.StaticMapEntity; + if (staticData.code == undefined || staticData.origin == undefined) { + return; + } const result = new SerializerInternal().deserializeEntity(root, value); if (typeof result === "string") { throw new Error(result); diff --git a/src/js/game/hud/parts/blueprint_placer.js b/src/js/game/hud/parts/blueprint_placer.js index ee391087..67f1b02f 100644 --- a/src/js/game/hud/parts/blueprint_placer.js +++ b/src/js/game/hud/parts/blueprint_placer.js @@ -10,10 +10,10 @@ import { Blueprint } from "../../blueprint"; import { enumMouseButton } from "../../camera"; import { KEYMAPPINGS } from "../../key_action_mapper"; import { BaseHUDPart } from "../base_hud_part"; -import { Entity } from "../../entity"; import { DynamicDomAttach } from "../dynamic_dom_attach"; import { globalConfig } from "../../../core/config"; import { paste } from "../../../core/clipboard_paste"; +import { compressX64, decompressX64 } from "../../../core/lzstring"; const copy = require("clipboard-copy"); @@ -223,7 +223,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart { const serializedBP = this.currentBlueprint.get().serialize(); try { const json = JSON.stringify(serializedBP); - await copy(json); + await copy(compressX64(json)); this.root.soundProxy.playUi(SOUNDS.copy); logger.debug("Copied blueprint to clipboard"); } catch (e) { @@ -239,7 +239,7 @@ export class HUDBlueprintPlacer extends BaseHUDPart { let json; try { let data = await paste(); - json = JSON.parse(data); + json = JSON.parse(decompressX64(data.trim())); logger.debug("Received data from clipboard"); } catch (e) { logger.error("Paste from clipboard failed:", e.message);