From b17cb6952b00ea135596691d7442e1ab8efb55f6 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 31 Oct 2020 12:19:51 +0100 Subject: [PATCH] Update changelog and minor fixes --- src/js/changelog.js | 2 ++ src/js/core/config.js | 3 ++- src/js/savegame/savegame_compressor.js | 24 +++++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/js/changelog.js b/src/js/changelog.js index 84f0bc07..3a93bb96 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -5,6 +5,8 @@ export const CHANGELOG = [ entries: [ "Fixed stacking bug for level 26 which required restarting the game", "Fix reward notification being too long sometimes (by LeopoldTal)", + "Use locale decimal separator on belt reader display (by LeopoldTal)", + "Vastly improved performance when saving games (by LeopoldTal)", "Updated translations", ], }, diff --git a/src/js/core/config.js b/src/js/core/config.js index a7df2a90..4169a0c2 100644 --- a/src/js/core/config.js +++ b/src/js/core/config.js @@ -26,7 +26,8 @@ export const THIRDPARTY_URLS = { }, }; -export const A_B_TESTING_LINK_TYPE = Math.random() > 0.5 ? "steam_1_pr" : "steam_2_npr"; +// export const A_B_TESTING_LINK_TYPE = Math.random() > 0.95 ? "steam_1_pr" : "steam_2_npr"; +export const A_B_TESTING_LINK_TYPE = "steam_2_npr"; export const globalConfig = { // Size of a single tile in Pixels. diff --git a/src/js/savegame/savegame_compressor.js b/src/js/savegame/savegame_compressor.js index ac82ebda..b0b92aa8 100644 --- a/src/js/savegame/savegame_compressor.js +++ b/src/js/savegame/savegame_compressor.js @@ -59,6 +59,12 @@ if (G_IS_DEV) { } } +/** + * @param {any} obj + * @param {Map} keys + * @param {Map} values + * @returns {any[]|object|number|string} + */ function compressObjectInternal(obj, keys, values) { if (Array.isArray(obj)) { let result = []; @@ -89,14 +95,21 @@ function compressObjectInternal(obj, keys, values) { return obj; } +/** + * @param {Map} hashMap + * @returns {Array} + */ function indexMapToArray(hashMap) { - const result = []; + const result = new Array(hashMap.size); hashMap.forEach((index, key) => { result[index] = key; }); return result; } +/** + * @param {object} obj + */ export function compressObject(obj) { const keys = new Map(); const values = new Map(); @@ -108,6 +121,12 @@ export function compressObject(obj) { }; } +/** + * @param {object} obj + * @param {string[]} keys + * @param {any[]} values + * @returns {object} + */ function decompressObjectInternal(obj, keys = [], values = []) { if (Array.isArray(obj)) { let result = []; @@ -130,6 +149,9 @@ function decompressObjectInternal(obj, keys = [], values = []) { return obj; } +/** + * @param {object} obj + */ export function decompressObject(obj) { if (obj.keys && obj.values && obj.data) { const keys = obj.keys;