mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Added Migrator for 1006 to 1007
This commit is contained in:
parent
9665213174
commit
2edfafab2d
@ -11,6 +11,7 @@ import { SavegameInterface_V1003 } from "./schemas/1003";
|
||||
import { SavegameInterface_V1004 } from "./schemas/1004";
|
||||
import { SavegameInterface_V1005 } from "./schemas/1005";
|
||||
import { SavegameInterface_V1006 } from "./schemas/1006";
|
||||
import { SavegameInterface_V1007 } from "./schemas/1007";
|
||||
|
||||
const logger = createLogger("savegame");
|
||||
|
||||
@ -51,7 +52,7 @@ export class Savegame extends ReadWriteProxy {
|
||||
* @returns {number}
|
||||
*/
|
||||
static getCurrentVersion() {
|
||||
return 1006;
|
||||
return 1007;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,6 +121,11 @@ export class Savegame extends ReadWriteProxy {
|
||||
data.version = 1006;
|
||||
}
|
||||
|
||||
if (data.version === 1006) {
|
||||
SavegameInterface_V1007.migrate1006to1007(data);
|
||||
data.version = 1007;
|
||||
}
|
||||
|
||||
return ExplainedResult.good();
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import { SavegameInterface_V1003 } from "./schemas/1003";
|
||||
import { SavegameInterface_V1004 } from "./schemas/1004";
|
||||
import { SavegameInterface_V1005 } from "./schemas/1005";
|
||||
import { SavegameInterface_V1006 } from "./schemas/1006";
|
||||
import { SavegameInterface_V1007 } from "./schemas/1007";
|
||||
|
||||
/** @type {Object.<number, typeof BaseSavegameInterface>} */
|
||||
export const savegameInterfaces = {
|
||||
@ -17,6 +18,7 @@ export const savegameInterfaces = {
|
||||
1004: SavegameInterface_V1004,
|
||||
1005: SavegameInterface_V1005,
|
||||
1006: SavegameInterface_V1006,
|
||||
1007: SavegameInterface_V1007,
|
||||
};
|
||||
|
||||
const logger = createLogger("savegame_interface_registry");
|
||||
|
||||
34
src/js/savegame/schemas/1007.js
Normal file
34
src/js/savegame/schemas/1007.js
Normal file
@ -0,0 +1,34 @@
|
||||
import { createLogger } from "../../core/logging.js";
|
||||
import { SavegameInterface_V1006 } from "./1006.js";
|
||||
|
||||
const schema = require("./1007.json");
|
||||
const logger = createLogger("savegame_interface/1006");
|
||||
|
||||
export class SavegameInterface_V1007 extends SavegameInterface_V1006 {
|
||||
getVersion() {
|
||||
return 1007;
|
||||
}
|
||||
|
||||
getSchemaUncached() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../savegame_typedefs.js").SavegameData} data
|
||||
*/
|
||||
static migrate1006to1007(data) {
|
||||
logger.log("Migrating 1006 to 1007");
|
||||
const dump = data.dump;
|
||||
if (!dump) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const waypoints = dump.waypoints.waypoints;
|
||||
|
||||
// clear ejector slots
|
||||
for (let i = 0; i < waypoints.length; ++i) {
|
||||
const waypoint = waypoints[i];
|
||||
waypoint.layer = "regular";
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/js/savegame/schemas/1007.json
Normal file
5
src/js/savegame/schemas/1007.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"type": "object",
|
||||
"required": [],
|
||||
"additionalProperties": true
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user