fix: initialize heights array if not already set in HeightmapGenerator (#1277)
Some checks are pending
Deploy static content to Pages / deploy (push) Waiting to run

This commit is contained in:
Marc Emmanuel 2026-01-22 18:28:09 +01:00 committed by GitHub
parent b228a8f610
commit 81c1ba2963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View file

@ -560,9 +560,7 @@ class HeightmapGenerator {
if(!ctx) { if(!ctx) {
throw new Error("Could not get canvas context"); throw new Error("Could not get canvas context");
} }
if(!this.heights) { this.heights = this.heights || new Uint8Array(cellsX * cellsY);
throw new Error("Heights array is not initialized");
}
ctx.drawImage(img, 0, 0, cellsX, cellsY); ctx.drawImage(img, 0, 0, cellsX, cellsY);
const imageData = ctx.getImageData(0, 0, cellsX, cellsY); const imageData = ctx.getImageData(0, 0, cellsX, cellsY);
this.setGraph(graph); this.setGraph(graph);

View file

@ -6,7 +6,7 @@ import { rn } from "./numberUtils";
* @param {number} decimals - Number of decimal places (default is 1) * @param {number} decimals - Number of decimal places (default is 1)
* @returns {string} - The string with rounded numbers * @returns {string} - The string with rounded numbers
*/ */
export const round = (inputString: string, decimals: number = 1) => { export const round = (inputString: string = "", decimals: number = 1) => {
return inputString.replace(/[\d\.-][\d\.e-]*/g, (n: string) => { return inputString.replace(/[\d\.-][\d\.e-]*/g, (n: string) => {
return rn(parseFloat(n), decimals).toString(); return rn(parseFloat(n), decimals).toString();
}); });