mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
fix: data integrity checks - better Stripping issue detection, v1.107.1
This commit is contained in:
parent
5bb33311fb
commit
22636b1b62
5 changed files with 21 additions and 7 deletions
|
|
@ -8149,7 +8149,7 @@
|
||||||
<script defer src="libs/rgbquant.min.js"></script>
|
<script defer src="libs/rgbquant.min.js"></script>
|
||||||
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
<script defer src="libs/jquery.ui.touch-punch.min.js"></script>
|
||||||
<script defer src="modules/io/save.js?v=1.100.00"></script>
|
<script defer src="modules/io/save.js?v=1.100.00"></script>
|
||||||
<script defer src="modules/io/load.js?v=1.105.24"></script>
|
<script defer src="modules/io/load.js?v=1.107.1"></script>
|
||||||
<script defer src="modules/io/cloud.js?v=1.106.0"></script>
|
<script defer src="modules/io/cloud.js?v=1.106.0"></script>
|
||||||
<script defer src="modules/io/export.js?v=1.100.00"></script>
|
<script defer src="modules/io/export.js?v=1.100.00"></script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -489,12 +489,16 @@ async function parseLoadedData(data, mapVersion) {
|
||||||
if (textureHref) updateTextureSelectValue(textureHref);
|
if (textureHref) updateTextureSelectValue(textureHref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data integrity checks
|
||||||
{
|
{
|
||||||
const cells = pack.cells;
|
const {cells, vertices} = pack;
|
||||||
|
|
||||||
if (pack.cells.i.length !== pack.cells.state.length) {
|
const cellsMismatch = cells.i.length !== cells.state.length;
|
||||||
const message = "[Data integrity] Striping issue detected. To fix edit the heightmap in ERASE mode";
|
const featureVerticesMismatch = pack.features.some(f => f?.vertices?.some(vertex => !vertices.p[vertex]));
|
||||||
ERROR && console.error(message);
|
|
||||||
|
if (cellsMismatch || featureVerticesMismatch) {
|
||||||
|
const message = "[Data integrity] Striping issue detected. To fix try to edit the heightmap in ERASE mode";
|
||||||
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const invalidStates = [...new Set(cells.state)].filter(s => !pack.states[s] || pack.states[s].removed);
|
const invalidStates = [...new Set(cells.state)].filter(s => !pack.states[s] || pack.states[s].removed);
|
||||||
|
|
@ -745,7 +749,7 @@ async function parseLoadedData(data, mapVersion) {
|
||||||
$("#alert").dialog({
|
$("#alert").dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
title: "Loading error",
|
title: "Loading error",
|
||||||
maxWidth: "50em",
|
maxWidth: "40em",
|
||||||
buttons: {
|
buttons: {
|
||||||
"Clear cache": () => cleanupData(),
|
"Clear cache": () => cleanupData(),
|
||||||
"Select file": function () {
|
"Select file": function () {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,11 @@ function drawFeatures() {
|
||||||
|
|
||||||
function getFeaturePath(feature) {
|
function getFeaturePath(feature) {
|
||||||
const points = feature.vertices.map(vertex => pack.vertices.p[vertex]);
|
const points = feature.vertices.map(vertex => pack.vertices.p[vertex]);
|
||||||
|
if (points.some(point => point === undefined)) {
|
||||||
|
ERROR && console.error("Undefined point in getFeaturePath");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
const simplifiedPoints = simplify(points, 0.3);
|
const simplifiedPoints = simplify(points, 0.3);
|
||||||
const clippedPoints = clipPoly(simplifiedPoints, 1);
|
const clippedPoints = clipPoly(simplifiedPoints, 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@
|
||||||
// clip polygon by graph bbox
|
// clip polygon by graph bbox
|
||||||
function clipPoly(points, secure = 0) {
|
function clipPoly(points, secure = 0) {
|
||||||
if (points.length < 2) return points;
|
if (points.length < 2) return points;
|
||||||
|
if (points.some(point => point === undefined)) {
|
||||||
|
ERROR && console.error("Undefined point in clipPoly", points);
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
return polygonclip(points, [0, 0, graphWidth, graphHeight], secure);
|
return polygonclip(points, [0, 0, graphWidth, graphHeight], secure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
|
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "1.106.7";
|
const VERSION = "1.107.1";
|
||||||
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
|
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue