Bring back storage dev stuff

This commit is contained in:
Andrei Andreev 2022-11-29 23:48:02 +01:00 committed by Andrei Andreev
parent 5ed97221d1
commit cbd5706e59
4 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,7 @@ import { sha512_256 } from "js-sha512";
import { DC } from "./constants";
import FullScreenAnimationHandler from "./full-screen-animation-handler";
export const DEV = false;
export const DEV = true;
/* eslint-disable no-console */
// Disabling no-console here seems

View File

@ -1522,7 +1522,6 @@ GameStorage.devMigrations = {
],
patch(player) {
if (!isDevEnvironment()) return;
player.options.testVersion = player.options.testVersion || 0;
for (let version = player.options.testVersion; version < this.patches.length; version++) {
const patch = this.patches[version];

View File

@ -1,4 +1,5 @@
import { deepmergeAll } from "@/utility/deepmerge";
import { DEV } from "../devtools";
import { GameStorage } from "./storage";
// WARNING: Don't use state accessors and functions from global scope here, that's not safe in long-term
@ -80,6 +81,8 @@ GameStorage.migrations = {
13: player => {
// 12.3 is currently on live, will be updated to 13 after release
if (DEV) GameStorage.devMigrations.setLatestTestVersion(player);
// Last update version check, fix emoji/cancer issue,
// change diff value from 1/10 of a second to 1/1000 of a second, delete pointless properties from player
// And all other kinds of stuff

View File

@ -1,6 +1,7 @@
import * as ADNotations from "@antimatter-dimensions/notations";
import { deepmergeAll } from "@/utility/deepmerge";
import { DEV } from "../devtools";
export const GameStorage = {
currentSlot: 0,
@ -16,7 +17,7 @@ export const GameStorage = {
offlineTicks: undefined,
get localStorageKey() {
return isDevEnvironment() ? "dimensionTestSave" : "dimensionSave";
return DEV ? "dimensionTestSave" : "dimensionSave";
},
load() {
@ -210,10 +211,16 @@ export const GameStorage = {
const checkString = this.checkPlayerObject(playerObject);
if (playerObject === Player.defaultStart || checkString !== "") {
if (DEV && checkString !== "") {
// eslint-disable-next-line no-console
console.log(`Savefile was invalid and has been reset - ${checkString}`);
}
player = deepmergeAll([{}, Player.defaultStart]);
player.records.gameCreatedTime = Date.now();
player.lastUpdate = Date.now();
if (isDevEnvironment()) this.devMigrations.setLatestTestVersion(player);
if (DEV) {
this.devMigrations.setLatestTestVersion(player);
}
} else {
const isPreviousVersionSave = playerObject.version < 13;
player = this.migrations.patch(playerObject);
@ -221,12 +228,14 @@ export const GameStorage = {
// Needed to check some notification about reality unlock study.
EventHub.dispatch(GAME_EVENT.SAVE_CONVERTED_FROM_PREVIOUS_VERSION);
}
this.devMigrations.patch(player);
if (DEV) {
this.devMigrations.patch(player);
}
}
this.saves[this.currentSlot] = player;
if (isDevEnvironment()) {
if (DEV) {
guardFromNaNValues(player);
}