From ad8eccef55aa92ac698d9fbf873c6e8363604845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=97=D0=BB=20=D0=93=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BE=D1=80=27=D1=94=D0=B2?= Date: Thu, 11 Jul 2024 10:36:44 +0300 Subject: [PATCH] Avoid direct HubGoals#storedShapes access Use getShapesStored and getShapesStoredByKey when possible instead. Only covers usages outside of hub goals. --- src/js/game/hud/parts/statistics_handle.js | 6 ++---- src/js/platform/achievement_provider.js | 7 ++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/js/game/hud/parts/statistics_handle.js b/src/js/game/hud/parts/statistics_handle.js index 71181c81..574f1f4e 100644 --- a/src/js/game/hud/parts/statistics_handle.js +++ b/src/js/game/hud/parts/statistics_handle.js @@ -1,6 +1,6 @@ import { makeOffscreenBuffer } from "../../../core/buffer_utils"; import { globalConfig } from "../../../core/config"; -import { clamp, formatBigNumber, round2Digits } from "../../../core/utils"; +import { clamp, formatBigNumber } from "../../../core/utils"; import { T } from "../../../translations"; import { enumAnalyticsDataSource } from "../../production_analytics"; import { GameRoot } from "../../root"; @@ -92,9 +92,7 @@ export class HUDShapeStatisticsHandle { switch (dataSource) { case enumAnalyticsDataSource.stored: { - this.counter.innerText = formatBigNumber( - this.root.hubGoals.storedShapes[this.definition.getHash()] || 0 - ); + this.counter.innerText = formatBigNumber(this.root.hubGoals.getShapesStored(this.definition)); break; } case enumAnalyticsDataSource.delivered: diff --git a/src/js/platform/achievement_provider.js b/src/js/platform/achievement_provider.js index 3b60ad95..485ef730 100644 --- a/src/js/platform/achievement_provider.js +++ b/src/js/platform/achievement_provider.js @@ -5,10 +5,10 @@ import { GameRoot } from "../game/root"; import { THEMES } from "../game/theme"; /* typehints:end */ +import { globalConfig } from "../core/config"; +import { ShapeItem } from "../game/items/shape_item"; import { enumAnalyticsDataSource } from "../game/production_analytics"; import { ShapeDefinition } from "../game/shape_definition"; -import { ShapeItem } from "../game/items/shape_item"; -import { globalConfig } from "../core/config"; export const ACHIEVEMENTS = { belt500Tiles: "belt500Tiles", @@ -423,7 +423,8 @@ export class AchievementCollection { return { init: ({ key }) => this.unlock(key, ShapeDefinition.fromShortKey(SHAPE_BP)), isValid: definition => - definition.cachedHash === SHAPE_BP && this.root.hubGoals.storedShapes[SHAPE_BP] >= count, + definition.cachedHash === SHAPE_BP && + this.root.hubGoals.getShapesStoredByKey(SHAPE_BP) >= count, signal: "shapeDelivered", }; }