@rhyster/wow-casc-dbc 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1808,8 +1808,19 @@ class DBDParser {
1808
1808
  data[column.name] = cell.string;
1809
1809
  }
1810
1810
  } else if (column.type === "float") {
1811
- assert__default(typeof cell.data === "number", `Invalid data type for float column ${column.name}`);
1812
- data[column.name] = castFloat(cell.data, srcSize, srcSigned);
1811
+ if (column.arraySize) {
1812
+ assert__default(typeof cell.data === "bigint", `Invalid data type for float array column ${column.name}`);
1813
+ const values = [];
1814
+ const castBuffer = Buffer.from(cell.data.toString(16).padStart(8 * column.arraySize, "0"), "hex");
1815
+ for (let i = 0; i < column.arraySize; i += 1) {
1816
+ const value = castBuffer.readFloatLE(i * 4);
1817
+ values.push(Math.round(value * 100) / 100);
1818
+ }
1819
+ data[column.name] = values;
1820
+ } else {
1821
+ assert__default(typeof cell.data === "number", `Invalid data type for float column ${column.name}`);
1822
+ data[column.name] = castFloat(cell.data, srcSize, srcSigned);
1823
+ }
1813
1824
  } else if (typeof cell.data === "number") {
1814
1825
  data[column.name] = castIntegerBySize(
1815
1826
  cell.data,
package/dist/index.mjs CHANGED
@@ -1796,8 +1796,19 @@ class DBDParser {
1796
1796
  data[column.name] = cell.string;
1797
1797
  }
1798
1798
  } else if (column.type === "float") {
1799
- assert(typeof cell.data === "number", `Invalid data type for float column ${column.name}`);
1800
- data[column.name] = castFloat(cell.data, srcSize, srcSigned);
1799
+ if (column.arraySize) {
1800
+ assert(typeof cell.data === "bigint", `Invalid data type for float array column ${column.name}`);
1801
+ const values = [];
1802
+ const castBuffer = Buffer.from(cell.data.toString(16).padStart(8 * column.arraySize, "0"), "hex");
1803
+ for (let i = 0; i < column.arraySize; i += 1) {
1804
+ const value = castBuffer.readFloatLE(i * 4);
1805
+ values.push(Math.round(value * 100) / 100);
1806
+ }
1807
+ data[column.name] = values;
1808
+ } else {
1809
+ assert(typeof cell.data === "number", `Invalid data type for float column ${column.name}`);
1810
+ data[column.name] = castFloat(cell.data, srcSize, srcSigned);
1811
+ }
1801
1812
  } else if (typeof cell.data === "number") {
1802
1813
  data[column.name] = castIntegerBySize(
1803
1814
  cell.data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rhyster/wow-casc-dbc",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Fetch World of Warcraft data files from CASC and parse DBC/DB2 files.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,16 +40,16 @@
40
40
  "@types/async": "^3.2.24",
41
41
  "@types/cli-progress": "^3.11.5",
42
42
  "@types/jest": "^29.5.12",
43
- "@types/node": "^20.12.2",
44
- "@typescript-eslint/eslint-plugin": "^7.4.0",
45
- "@typescript-eslint/parser": "^7.4.0",
43
+ "@types/node": "^20.12.7",
44
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
45
+ "@typescript-eslint/parser": "^7.7.1",
46
46
  "eslint": "^8.57.0",
47
47
  "eslint-config-airbnb-base": "^15.0.0",
48
48
  "eslint-config-airbnb-typescript": "^18.0.0",
49
49
  "jest": "^29.7.0",
50
50
  "ts-jest": "^29.1.2",
51
51
  "ts-node": "^10.9.2",
52
- "typescript": "^5.4.3",
52
+ "typescript": "^5.4.5",
53
53
  "unbuild": "^2.0.0"
54
54
  },
55
55
  "dependencies": {