wc3maptranslator 4.0.0 → 4.0.2
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/LICENSE.md +23 -23
- package/dist/AngleConverter.d.ts +3 -0
- package/dist/AngleConverter.d.ts.map +1 -0
- package/dist/AngleConverter.js +12 -0
- package/dist/AngleConverter.js.map +1 -0
- package/dist/CommonInterfaces.d.ts +17 -0
- package/dist/CommonInterfaces.d.ts.map +1 -0
- package/dist/CommonInterfaces.js +3 -0
- package/dist/CommonInterfaces.js.map +1 -0
- package/dist/HexBuffer.d.ts +15 -0
- package/dist/HexBuffer.d.ts.map +1 -0
- package/{lib/HexBuffer.ts → dist/HexBuffer.js} +71 -81
- package/dist/HexBuffer.js.map +1 -0
- package/dist/W3Buffer.d.ts +14 -0
- package/dist/W3Buffer.d.ts.map +1 -0
- package/{lib/W3Buffer.ts → dist/W3Buffer.js} +63 -69
- package/dist/W3Buffer.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/{index.js → dist/index.js} +1 -1
- package/dist/index.js.map +1 -0
- package/dist/translators/CamerasTranslator.d.ts +23 -0
- package/dist/translators/CamerasTranslator.d.ts.map +1 -0
- package/{lib/translators/CamerasTranslator.ts → dist/translators/CamerasTranslator.js} +76 -101
- package/dist/translators/CamerasTranslator.js.map +1 -0
- package/dist/translators/DoodadsTranslator.d.ts +23 -0
- package/dist/translators/DoodadsTranslator.d.ts.map +1 -0
- package/{lib/translators/DoodadsTranslator.ts → dist/translators/DoodadsTranslator.js} +146 -178
- package/dist/translators/DoodadsTranslator.js.map +1 -0
- package/dist/translators/ImportsTranslator.d.ts +16 -0
- package/dist/translators/ImportsTranslator.d.ts.map +1 -0
- package/{lib/translators/ImportsTranslator.ts → dist/translators/ImportsTranslator.js} +62 -78
- package/dist/translators/ImportsTranslator.js.map +1 -0
- package/dist/translators/InfoTranslator.d.ts +124 -0
- package/dist/translators/InfoTranslator.d.ts.map +1 -0
- package/{lib/translators/InfoTranslator.ts → dist/translators/InfoTranslator.js} +422 -584
- package/dist/translators/InfoTranslator.js.map +1 -0
- package/dist/translators/ObjectsTranslator.d.ts +23 -0
- package/dist/translators/ObjectsTranslator.d.ts.map +1 -0
- package/{lib/translators/ObjectsTranslator.ts → dist/translators/ObjectsTranslator.js} +91 -125
- package/dist/translators/ObjectsTranslator.js.map +1 -0
- package/dist/translators/RegionsTranslator.d.ts +22 -0
- package/dist/translators/RegionsTranslator.d.ts.map +1 -0
- package/{lib/translators/RegionsTranslator.ts → dist/translators/RegionsTranslator.js} +96 -123
- package/dist/translators/RegionsTranslator.js.map +1 -0
- package/dist/translators/SoundsTranslator.d.ts +35 -0
- package/dist/translators/SoundsTranslator.d.ts.map +1 -0
- package/{lib/translators/SoundsTranslator.ts → dist/translators/SoundsTranslator.js} +183 -237
- package/dist/translators/SoundsTranslator.js.map +1 -0
- package/dist/translators/StringsTranslator.d.ts +7 -0
- package/dist/translators/StringsTranslator.d.ts.map +1 -0
- package/{lib/translators/StringsTranslator.ts → dist/translators/StringsTranslator.js} +44 -49
- package/dist/translators/StringsTranslator.js.map +1 -0
- package/dist/translators/TerrainTranslator.d.ts +33 -0
- package/dist/translators/TerrainTranslator.d.ts.map +1 -0
- package/{lib/translators/TerrainTranslator.ts → dist/translators/TerrainTranslator.js} +221 -276
- package/dist/translators/TerrainTranslator.js.map +1 -0
- package/dist/translators/UnitsTranslator.d.ts +40 -0
- package/dist/translators/UnitsTranslator.d.ts.map +1 -0
- package/{lib/translators/UnitsTranslator.ts → dist/translators/UnitsTranslator.js} +199 -261
- package/dist/translators/UnitsTranslator.js.map +1 -0
- package/{lib/translators/index.ts → dist/translators/index.d.ts} +11 -10
- package/dist/translators/index.d.ts.map +1 -0
- package/dist/translators/index.js +23 -0
- package/dist/translators/index.js.map +1 -0
- package/package.json +4 -2
- package/.codeclimate.yml +0 -12
- package/.editorconfig +0 -8
- package/.eslintignore +0 -5
- package/.eslintrc +0 -55
- package/.github/workflows/codeql-analysis.yml +0 -54
- package/.nycrc +0 -18
- package/.travis.yml +0 -23
- package/CHANGELOG.md +0 -73
- package/index.ts +0 -14
- package/lib/AngleConverter.ts +0 -7
- package/lib/CommonInterfaces.ts +0 -22
- package/test/.mocharc.json +0 -4
- package/test/AngleConverterTest.ts +0 -18
- package/test/HexBufferTest.ts +0 -170
- package/test/TranslatorReversion.ts +0 -218
- package/test/W3BufferTest.ts +0 -50
- package/test/data/cameras.json +0 -16
- package/test/data/doodads.json +0 -2730
- package/test/data/imports.json +0 -386
- package/test/data/info.json +0 -250
- package/test/data/obj-abilities.json +0 -4892
- package/test/data/obj-buffs.json +0 -38
- package/test/data/obj-destructables.json +0 -31
- package/test/data/obj-doodads.json +0 -38
- package/test/data/obj-items.json +0 -31
- package/test/data/obj-units.json +0 -40
- package/test/data/obj-upgrades.json +0 -38
- package/test/data/regions.json +0 -206
- package/test/data/sounds.json +0 -50
- package/test/data/strings.json +0 -115
- package/test/data/terrain.json +0 -1
- package/test/data/units.json +0 -452
- package/test/data/war3map.doo +0 -0
- package/test/data/war3map.imp +0 -0
- package/test/data/war3map.j +0 -3442
- package/test/data/war3map.shd +0 -0
- package/test/data/war3map.w3a +0 -0
- package/test/data/war3map.w3b +0 -0
- package/test/data/war3map.w3c +0 -0
- package/test/data/war3map.w3d +0 -0
- package/test/data/war3map.w3e +0 -0
- package/test/data/war3map.w3h +0 -0
- package/test/data/war3map.w3i +0 -0
- package/test/data/war3map.w3q +0 -0
- package/test/data/war3map.w3r +0 -0
- package/test/data/war3map.w3s +0 -0
- package/test/data/war3map.w3t +0 -0
- package/test/data/war3map.w3u +0 -0
- package/test/data/war3map.wts +0 -631
- package/test/data/war3mapUnits.doo +0 -0
- package/tsconfig.json +0 -25
- package/tslint.json +0 -47
|
@@ -1,276 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
result.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
result.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const arr_layerHeight = [];
|
|
223
|
-
|
|
224
|
-
while(!outBufferToJSON.isExhausted()) {
|
|
225
|
-
const groundHeight = outBufferToJSON.readShort();
|
|
226
|
-
const waterHeightAndBoundary = outBufferToJSON.readShort();
|
|
227
|
-
const flagsAndGroundTexture = outBufferToJSON.readByte();
|
|
228
|
-
const groundAndCliffVariation = outBufferToJSON.readByte();
|
|
229
|
-
const cliffTextureAndLayerHeight = outBufferToJSON.readByte();
|
|
230
|
-
|
|
231
|
-
// parse out different bits (based on documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain)
|
|
232
|
-
const waterHeight = waterHeightAndBoundary & 32767;
|
|
233
|
-
const boundaryFlag = (waterHeightAndBoundary & 0x4000) === 0x4000;
|
|
234
|
-
const flags = flagsAndGroundTexture & 240;
|
|
235
|
-
const groundTexture = flagsAndGroundTexture & 15;
|
|
236
|
-
const groundVariation = groundAndCliffVariation & 248;
|
|
237
|
-
const cliffVariation = groundAndCliffVariation & 7;
|
|
238
|
-
const cliffTexture = cliffTextureAndLayerHeight & 240;
|
|
239
|
-
const layerHeight = cliffTextureAndLayerHeight & 15;
|
|
240
|
-
|
|
241
|
-
arr_groundHeight.push(groundHeight);
|
|
242
|
-
arr_waterHeight.push(waterHeight);
|
|
243
|
-
arr_boundaryFlag.push(boundaryFlag);
|
|
244
|
-
arr_flags.push(flags);
|
|
245
|
-
arr_groundTexture.push(groundTexture);
|
|
246
|
-
arr_groundVariation.push(groundVariation);
|
|
247
|
-
arr_cliffVariation.push(cliffVariation);
|
|
248
|
-
arr_cliffTexture.push(cliffTexture);
|
|
249
|
-
arr_layerHeight.push(layerHeight);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function convertArrayOfArraysIntoFlatArray(arr) {
|
|
253
|
-
return arr.reduce((a, b) => {
|
|
254
|
-
return [...a, ...b]
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// The map was read in "backwards" because wc3 maps have origin (0,0)
|
|
259
|
-
// at the bottom left instead of top left as we desire. Flip the rows
|
|
260
|
-
// vertically to fix this.
|
|
261
|
-
result.groundHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundHeight, result.map.width + 1).reverse())
|
|
262
|
-
result.waterHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_waterHeight, result.map.width + 1).reverse())
|
|
263
|
-
result.boundaryFlag = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_boundaryFlag, result.map.width + 1).reverse())
|
|
264
|
-
result.flags = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_flags, result.map.width + 1).reverse())
|
|
265
|
-
result.groundTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundTexture, result.map.width + 1).reverse())
|
|
266
|
-
result.groundVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundVariation, result.map.width + 1).reverse())
|
|
267
|
-
result.cliffVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffVariation, result.map.width + 1).reverse())
|
|
268
|
-
result.cliffTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffTexture, result.map.width + 1).reverse())
|
|
269
|
-
result.layerHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_layerHeight, result.map.width + 1).reverse())
|
|
270
|
-
|
|
271
|
-
return {
|
|
272
|
-
errors: [],
|
|
273
|
-
json: result
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TerrainTranslator = void 0;
|
|
4
|
+
const HexBuffer_1 = require("../HexBuffer");
|
|
5
|
+
const W3Buffer_1 = require("../W3Buffer");
|
|
6
|
+
function splitLargeArrayIntoWidthArrays(array, width) {
|
|
7
|
+
const rows = [];
|
|
8
|
+
for (let i = 0; i < array.length / width; i++) {
|
|
9
|
+
rows.push(array.slice(i * width, (i + 1) * width));
|
|
10
|
+
}
|
|
11
|
+
return rows;
|
|
12
|
+
}
|
|
13
|
+
class TerrainTranslator {
|
|
14
|
+
static jsonToWar(terrainJson) {
|
|
15
|
+
const outBufferToWar = new HexBuffer_1.HexBuffer();
|
|
16
|
+
/*
|
|
17
|
+
* Header
|
|
18
|
+
*/
|
|
19
|
+
outBufferToWar.addChars('W3E!'); // file id
|
|
20
|
+
outBufferToWar.addInt(11); // file version
|
|
21
|
+
outBufferToWar.addChar(terrainJson.tileset); // base tileset
|
|
22
|
+
outBufferToWar.addInt(+terrainJson.customTileset); // 1 = using custom tileset, 0 = not
|
|
23
|
+
/*
|
|
24
|
+
* Tiles
|
|
25
|
+
*/
|
|
26
|
+
outBufferToWar.addInt(terrainJson.tilePalette.length);
|
|
27
|
+
terrainJson.tilePalette.forEach((tile) => {
|
|
28
|
+
outBufferToWar.addChars(tile);
|
|
29
|
+
});
|
|
30
|
+
/*
|
|
31
|
+
* Cliffs
|
|
32
|
+
*/
|
|
33
|
+
outBufferToWar.addInt(terrainJson.cliffTilePalette.length);
|
|
34
|
+
terrainJson.cliffTilePalette.forEach((cliffTile) => {
|
|
35
|
+
outBufferToWar.addChars(cliffTile);
|
|
36
|
+
});
|
|
37
|
+
/*
|
|
38
|
+
* Map size data
|
|
39
|
+
*/
|
|
40
|
+
outBufferToWar.addInt(terrainJson.map.width + 1);
|
|
41
|
+
outBufferToWar.addInt(terrainJson.map.height + 1);
|
|
42
|
+
/*
|
|
43
|
+
* Map offset
|
|
44
|
+
*/
|
|
45
|
+
outBufferToWar.addFloat(terrainJson.map.offset.x);
|
|
46
|
+
outBufferToWar.addFloat(terrainJson.map.offset.y);
|
|
47
|
+
/*
|
|
48
|
+
* Tile points
|
|
49
|
+
*/
|
|
50
|
+
// Partition the terrainJson masks into "chunks" (i.e. rows) of (width+1) length,
|
|
51
|
+
// reverse that list of rows (due to vertical flipping), and then write the rows out
|
|
52
|
+
const rows = {
|
|
53
|
+
groundHeight: splitLargeArrayIntoWidthArrays(terrainJson.groundHeight, terrainJson.map.width + 1),
|
|
54
|
+
waterHeight: splitLargeArrayIntoWidthArrays(terrainJson.waterHeight, terrainJson.map.width + 1),
|
|
55
|
+
boundaryFlag: splitLargeArrayIntoWidthArrays(terrainJson.boundaryFlag, terrainJson.map.width + 1),
|
|
56
|
+
flags: splitLargeArrayIntoWidthArrays(terrainJson.flags, terrainJson.map.width + 1),
|
|
57
|
+
groundTexture: splitLargeArrayIntoWidthArrays(terrainJson.groundTexture, terrainJson.map.width + 1),
|
|
58
|
+
groundVariation: splitLargeArrayIntoWidthArrays(terrainJson.groundVariation, terrainJson.map.width + 1),
|
|
59
|
+
cliffVariation: splitLargeArrayIntoWidthArrays(terrainJson.cliffVariation, terrainJson.map.width + 1),
|
|
60
|
+
cliffTexture: splitLargeArrayIntoWidthArrays(terrainJson.cliffTexture, terrainJson.map.width + 1),
|
|
61
|
+
layerHeight: splitLargeArrayIntoWidthArrays(terrainJson.layerHeight, terrainJson.map.width + 1)
|
|
62
|
+
};
|
|
63
|
+
rows.groundHeight.reverse();
|
|
64
|
+
rows.waterHeight.reverse();
|
|
65
|
+
rows.boundaryFlag.reverse();
|
|
66
|
+
rows.flags.reverse();
|
|
67
|
+
rows.groundTexture.reverse();
|
|
68
|
+
rows.groundVariation.reverse();
|
|
69
|
+
rows.cliffVariation.reverse();
|
|
70
|
+
rows.cliffTexture.reverse();
|
|
71
|
+
rows.layerHeight.reverse();
|
|
72
|
+
for (let i = 0; i < rows.groundHeight.length; i++) {
|
|
73
|
+
for (let j = 0; j < rows.groundHeight[i].length; j++) {
|
|
74
|
+
// these bit operations are based off documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain
|
|
75
|
+
const groundHeight = rows.groundHeight[i][j];
|
|
76
|
+
const waterHeight = rows.waterHeight[i][j];
|
|
77
|
+
const boundaryFlag = rows.boundaryFlag[i][j];
|
|
78
|
+
const flags = rows.flags[i][j];
|
|
79
|
+
const groundTexture = rows.groundTexture[i][j];
|
|
80
|
+
const groundVariation = rows.groundVariation[i][j];
|
|
81
|
+
const cliffVariation = rows.cliffVariation[i][j];
|
|
82
|
+
const cliffTexture = rows.cliffTexture[i][j];
|
|
83
|
+
const layerHeight = rows.layerHeight[i][j];
|
|
84
|
+
const hasBoundaryFlag = boundaryFlag ? 0x4000 : 0;
|
|
85
|
+
outBufferToWar.addShort(groundHeight);
|
|
86
|
+
outBufferToWar.addShort(waterHeight | hasBoundaryFlag);
|
|
87
|
+
outBufferToWar.addByte(flags | groundTexture);
|
|
88
|
+
outBufferToWar.addByte(groundVariation | cliffVariation);
|
|
89
|
+
outBufferToWar.addByte(cliffTexture | layerHeight);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
errors: [],
|
|
94
|
+
buffer: outBufferToWar.getBuffer()
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
static warToJson(buffer) {
|
|
98
|
+
// create buffer
|
|
99
|
+
const result = {
|
|
100
|
+
tileset: '',
|
|
101
|
+
customTileset: false,
|
|
102
|
+
tilePalette: [],
|
|
103
|
+
cliffTilePalette: [],
|
|
104
|
+
map: {
|
|
105
|
+
width: 1,
|
|
106
|
+
height: 1,
|
|
107
|
+
offset: {
|
|
108
|
+
x: 0,
|
|
109
|
+
y: 0
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
groundHeight: [],
|
|
113
|
+
waterHeight: [],
|
|
114
|
+
boundaryFlag: [],
|
|
115
|
+
flags: [],
|
|
116
|
+
groundTexture: [],
|
|
117
|
+
groundVariation: [],
|
|
118
|
+
cliffVariation: [],
|
|
119
|
+
cliffTexture: [],
|
|
120
|
+
layerHeight: []
|
|
121
|
+
};
|
|
122
|
+
const outBufferToJSON = new W3Buffer_1.W3Buffer(buffer);
|
|
123
|
+
/**
|
|
124
|
+
* Header
|
|
125
|
+
*/
|
|
126
|
+
const w3eHeader = outBufferToJSON.readChars(4); // W3E!
|
|
127
|
+
const version = outBufferToJSON.readInt(); // 0B 00 00 00
|
|
128
|
+
const tileset = outBufferToJSON.readChars(1); // tileset
|
|
129
|
+
const customTileset = (outBufferToJSON.readInt() === 1);
|
|
130
|
+
result.tileset = tileset;
|
|
131
|
+
result.customTileset = customTileset;
|
|
132
|
+
/**
|
|
133
|
+
* Tiles
|
|
134
|
+
*/
|
|
135
|
+
const numTilePalettes = outBufferToJSON.readInt();
|
|
136
|
+
const tilePalettes = [];
|
|
137
|
+
for (let i = 0; i < numTilePalettes; i++) {
|
|
138
|
+
tilePalettes.push(outBufferToJSON.readChars(4));
|
|
139
|
+
}
|
|
140
|
+
result.tilePalette = tilePalettes;
|
|
141
|
+
/**
|
|
142
|
+
* Cliffs
|
|
143
|
+
*/
|
|
144
|
+
const numCliffTilePalettes = outBufferToJSON.readInt();
|
|
145
|
+
const cliffPalettes = [];
|
|
146
|
+
for (let i = 0; i < numCliffTilePalettes; i++) {
|
|
147
|
+
const cliffPalette = outBufferToJSON.readChars(4);
|
|
148
|
+
cliffPalettes.push(cliffPalette);
|
|
149
|
+
}
|
|
150
|
+
result.cliffTilePalette = cliffPalettes;
|
|
151
|
+
/**
|
|
152
|
+
* map dimensions
|
|
153
|
+
*/
|
|
154
|
+
const width = outBufferToJSON.readInt() - 1;
|
|
155
|
+
const height = outBufferToJSON.readInt() - 1;
|
|
156
|
+
result.map = { width, height, offset: { x: 0, y: 0 } };
|
|
157
|
+
const offsetX = outBufferToJSON.readFloat();
|
|
158
|
+
const offsetY = outBufferToJSON.readFloat();
|
|
159
|
+
result.map.offset = { x: offsetX, y: offsetY };
|
|
160
|
+
/**
|
|
161
|
+
* map tiles
|
|
162
|
+
*/
|
|
163
|
+
const arr_groundHeight = [];
|
|
164
|
+
const arr_waterHeight = [];
|
|
165
|
+
const arr_boundaryFlag = [];
|
|
166
|
+
const arr_flags = [];
|
|
167
|
+
const arr_groundTexture = [];
|
|
168
|
+
const arr_groundVariation = [];
|
|
169
|
+
const arr_cliffVariation = [];
|
|
170
|
+
const arr_cliffTexture = [];
|
|
171
|
+
const arr_layerHeight = [];
|
|
172
|
+
while (!outBufferToJSON.isExhausted()) {
|
|
173
|
+
const groundHeight = outBufferToJSON.readShort();
|
|
174
|
+
const waterHeightAndBoundary = outBufferToJSON.readShort();
|
|
175
|
+
const flagsAndGroundTexture = outBufferToJSON.readByte();
|
|
176
|
+
const groundAndCliffVariation = outBufferToJSON.readByte();
|
|
177
|
+
const cliffTextureAndLayerHeight = outBufferToJSON.readByte();
|
|
178
|
+
// parse out different bits (based on documentation from https://github.com/stijnherfst/HiveWE/wiki/war3map.w3e-Terrain)
|
|
179
|
+
const waterHeight = waterHeightAndBoundary & 32767;
|
|
180
|
+
const boundaryFlag = (waterHeightAndBoundary & 0x4000) === 0x4000;
|
|
181
|
+
const flags = flagsAndGroundTexture & 240;
|
|
182
|
+
const groundTexture = flagsAndGroundTexture & 15;
|
|
183
|
+
const groundVariation = groundAndCliffVariation & 248;
|
|
184
|
+
const cliffVariation = groundAndCliffVariation & 7;
|
|
185
|
+
const cliffTexture = cliffTextureAndLayerHeight & 240;
|
|
186
|
+
const layerHeight = cliffTextureAndLayerHeight & 15;
|
|
187
|
+
arr_groundHeight.push(groundHeight);
|
|
188
|
+
arr_waterHeight.push(waterHeight);
|
|
189
|
+
arr_boundaryFlag.push(boundaryFlag);
|
|
190
|
+
arr_flags.push(flags);
|
|
191
|
+
arr_groundTexture.push(groundTexture);
|
|
192
|
+
arr_groundVariation.push(groundVariation);
|
|
193
|
+
arr_cliffVariation.push(cliffVariation);
|
|
194
|
+
arr_cliffTexture.push(cliffTexture);
|
|
195
|
+
arr_layerHeight.push(layerHeight);
|
|
196
|
+
}
|
|
197
|
+
function convertArrayOfArraysIntoFlatArray(arr) {
|
|
198
|
+
return arr.reduce((a, b) => {
|
|
199
|
+
return [...a, ...b];
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// The map was read in "backwards" because wc3 maps have origin (0,0)
|
|
203
|
+
// at the bottom left instead of top left as we desire. Flip the rows
|
|
204
|
+
// vertically to fix this.
|
|
205
|
+
result.groundHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundHeight, result.map.width + 1).reverse());
|
|
206
|
+
result.waterHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_waterHeight, result.map.width + 1).reverse());
|
|
207
|
+
result.boundaryFlag = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_boundaryFlag, result.map.width + 1).reverse());
|
|
208
|
+
result.flags = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_flags, result.map.width + 1).reverse());
|
|
209
|
+
result.groundTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundTexture, result.map.width + 1).reverse());
|
|
210
|
+
result.groundVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_groundVariation, result.map.width + 1).reverse());
|
|
211
|
+
result.cliffVariation = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffVariation, result.map.width + 1).reverse());
|
|
212
|
+
result.cliffTexture = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_cliffTexture, result.map.width + 1).reverse());
|
|
213
|
+
result.layerHeight = convertArrayOfArraysIntoFlatArray(splitLargeArrayIntoWidthArrays(arr_layerHeight, result.map.width + 1).reverse());
|
|
214
|
+
return {
|
|
215
|
+
errors: [],
|
|
216
|
+
json: result
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.TerrainTranslator = TerrainTranslator;
|
|
221
|
+
//# sourceMappingURL=TerrainTranslator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerrainTranslator.js","sourceRoot":"","sources":["../../src/translators/TerrainTranslator.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,0CAAuC;AAgCvC,SAAS,8BAA8B,CAAC,KAAY,EAAE,KAAa;IAC/D,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC,GAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;KACpD;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAsB,iBAAiB;IAE5B,MAAM,CAAC,SAAS,CAAC,WAAoB;QACxC,MAAM,cAAc,GAAG,IAAI,qBAAS,EAAE,CAAC;QAEvC;;WAEG;QACH,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU;QAC3C,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe;QAC1C,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;QAC5D,cAAc,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,oCAAoC;QAEvF;;WAEG;QACH,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACtD,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH;;WAEG;QACH,cAAc,CAAC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7I,MAAM,CAAC,YAAY,GAAG,iCAAiC,CAAC,8BAA8B,CAAC,gBAAgB,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QACzI,MAAM,CAAC,WAAW,GAAG,iCAAiC,CAAC,8BAA8B,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAEvI,OAAO;YACH,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,MAAM;SACf,CAAC;IACN,CAAC;CACJ;AA1OD,8CA0OC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { WarResult, JsonResult, angle } from '../CommonInterfaces';
|
|
3
|
+
interface Unit {
|
|
4
|
+
type: string;
|
|
5
|
+
variation: number;
|
|
6
|
+
position: number[];
|
|
7
|
+
rotation: angle;
|
|
8
|
+
scale: number[];
|
|
9
|
+
hero: Hero;
|
|
10
|
+
inventory: Inventory[];
|
|
11
|
+
abilities: Abilities[];
|
|
12
|
+
player: number;
|
|
13
|
+
hitpoints: number;
|
|
14
|
+
mana: number;
|
|
15
|
+
gold: number;
|
|
16
|
+
targetAcquisition: number;
|
|
17
|
+
color: number;
|
|
18
|
+
id: number;
|
|
19
|
+
}
|
|
20
|
+
interface Hero {
|
|
21
|
+
level: number;
|
|
22
|
+
str: number;
|
|
23
|
+
agi: number;
|
|
24
|
+
int: number;
|
|
25
|
+
}
|
|
26
|
+
interface Inventory {
|
|
27
|
+
slot: number;
|
|
28
|
+
type: string;
|
|
29
|
+
}
|
|
30
|
+
interface Abilities {
|
|
31
|
+
ability: string;
|
|
32
|
+
active: boolean;
|
|
33
|
+
level: number;
|
|
34
|
+
}
|
|
35
|
+
export declare abstract class UnitsTranslator {
|
|
36
|
+
static jsonToWar(unitsJson: Unit[]): WarResult;
|
|
37
|
+
static warToJson(buffer: Buffer): JsonResult<Unit[]>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=UnitsTranslator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnitsTranslator.d.ts","sourceRoot":"","sources":["../../src/translators/UnitsTranslator.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAElE,UAAU,IAAI;IACV,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;CACd;AAED,UAAU,IAAI;IACV,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACf;AAED,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,SAAS;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,8BAAsB,eAAe;WAEnB,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,SAAS;WA8FvC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;CA4H9D"}
|