Merge branch 'upstream' into dev-submaps

This commit is contained in:
Mészáros Gergely 2022-04-13 17:29:41 +02:00
commit f99edae5db
4 changed files with 44 additions and 39 deletions

View file

@ -1,19 +1,24 @@
"use strict"
"use strict";
window.Formats = (function () {
async function csvParser (file, separator=",") {
async function csvParser(file, separator = ",") {
const txt = await file.text();
const rows = txt.split("\n");
const headers = rows.shift().split(separator).map(x => x.toLowerCase());
const data = rows.filter(a => a.trim()!=="").map(r=>r.split(separator));
const headers = rows
.shift()
.split(separator)
.map(x => x.toLowerCase());
const data = rows.filter(a => a.trim() !== "").map(r => r.split(separator));
return {
headers,
data,
iterator: function* (sortf){
const dataset = sortf? this.data.sort(sortf):this.data;
for (const d of dataset)
yield Object.fromEntries(d.map((a, i) => [this.headers[i], a]));
}};
iterator: function* (sortf) {
const dataset = sortf ? this.data.sort(sortf) : this.data;
for (const d of dataset) yield Object.fromEntries(d.map((a, i) => [this.headers[i], a]));
}
};
}
return {csvParser};
})();

View file

@ -459,7 +459,7 @@ async function parseLoadedData(data) {
invalidReligions.forEach(r => {
const invalidCells = cells.i.filter(i => cells.religion[i] === r);
invalidCells.forEach(i => (cells.religion[i] = 0));
ERROR && console.error("Data Integrity Check. Invalid religion", c, "is assigned to cells", invalidCells);
ERROR && console.error("Data Integrity Check. Invalid religion", r, "is assigned to cells", invalidCells);
});
const invalidFeatures = [...new Set(cells.f)].filter(f => f && !pack.features[f]);