mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Reworked waypoints
This commit is contained in:
@@ -13,6 +13,7 @@ import { getSavegameInterface, savegameInterfaces } from "./savegame_interface_r
|
||||
import { SavegameInterface_V1001 } from "./schemas/1001";
|
||||
import { SavegameInterface_V1002 } from "./schemas/1002";
|
||||
import { SavegameInterface_V1003 } from "./schemas/1003";
|
||||
import { SavegameInterface_V1004 } from "./schemas/1004";
|
||||
|
||||
const logger = createLogger("savegame");
|
||||
|
||||
@@ -44,7 +45,7 @@ export class Savegame extends ReadWriteProxy {
|
||||
* @returns {number}
|
||||
*/
|
||||
static getCurrentVersion() {
|
||||
return 1003;
|
||||
return 1004;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +99,11 @@ export class Savegame extends ReadWriteProxy {
|
||||
data.version = 1003;
|
||||
}
|
||||
|
||||
if (data.version === 1003) {
|
||||
SavegameInterface_V1004.migrate1003to1004(data);
|
||||
data.version = 1004;
|
||||
}
|
||||
|
||||
return ExplainedResult.good();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createLogger } from "../core/logging";
|
||||
import { SavegameInterface_V1001 } from "./schemas/1001";
|
||||
import { SavegameInterface_V1002 } from "./schemas/1002";
|
||||
import { SavegameInterface_V1003 } from "./schemas/1003";
|
||||
import { SavegameInterface_V1004 } from "./schemas/1004";
|
||||
|
||||
/** @type {Object.<number, typeof BaseSavegameInterface>} */
|
||||
export const savegameInterfaces = {
|
||||
@@ -11,6 +12,7 @@ export const savegameInterfaces = {
|
||||
1001: SavegameInterface_V1001,
|
||||
1002: SavegameInterface_V1002,
|
||||
1003: SavegameInterface_V1003,
|
||||
1004: SavegameInterface_V1004,
|
||||
};
|
||||
|
||||
const logger = createLogger("savegame_interface_registry");
|
||||
|
||||
36
src/js/savegame/schemas/1004.js
Normal file
36
src/js/savegame/schemas/1004.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createLogger } from "../../core/logging.js";
|
||||
import { SavegameInterface_V1003 } from "./1003.js";
|
||||
|
||||
const schema = require("./1004.json");
|
||||
const logger = createLogger("savegame_interface/1004");
|
||||
|
||||
export class SavegameInterface_V1004 extends SavegameInterface_V1003 {
|
||||
getVersion() {
|
||||
return 1004;
|
||||
}
|
||||
|
||||
getSchemaUncached() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../savegame_typedefs.js").SavegameData} data
|
||||
*/
|
||||
static migrate1003to1004(data) {
|
||||
logger.log("Migrating 1003 to 1004");
|
||||
const dump = data.dump;
|
||||
if (!dump) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The hub simply has an empty label
|
||||
const waypointData = dump.waypoints.waypoints;
|
||||
for (let i = 0; i < waypointData.length; ++i) {
|
||||
const waypoint = waypointData[i];
|
||||
if (!waypoint.deletable) {
|
||||
waypoint.label = null;
|
||||
}
|
||||
delete waypoint.deletable;
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/js/savegame/schemas/1004.json
Normal file
5
src/js/savegame/schemas/1004.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": [],
|
||||
"additionalProperties": true
|
||||
}
|
||||
Reference in New Issue
Block a user