wc3maptranslator 4.0.3 → 5.0.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/README.md +62 -43
- package/dist/src/AngleConverter.d.ts +3 -2
- package/dist/src/AngleConverter.d.ts.map +1 -1
- package/dist/src/AngleConverter.js.map +1 -1
- package/dist/src/CommonInterfaces.d.ts +12 -8
- package/dist/src/CommonInterfaces.d.ts.map +1 -1
- package/dist/src/CommonInterfaces.js +17 -0
- package/dist/src/CommonInterfaces.js.map +1 -1
- package/dist/src/HexBuffer.d.ts +5 -2
- package/dist/src/HexBuffer.d.ts.map +1 -1
- package/dist/src/HexBuffer.js +34 -34
- package/dist/src/HexBuffer.js.map +1 -1
- package/dist/src/PlayerBitfield.d.ts +30 -0
- package/dist/src/PlayerBitfield.d.ts.map +1 -0
- package/dist/src/PlayerBitfield.js +56 -0
- package/dist/src/PlayerBitfield.js.map +1 -0
- package/dist/src/TranslatorMappings.d.ts +12 -0
- package/dist/src/TranslatorMappings.d.ts.map +1 -0
- package/dist/src/TranslatorMappings.js +47 -0
- package/dist/src/TranslatorMappings.js.map +1 -0
- package/dist/src/W3Buffer.d.ts +4 -1
- package/dist/src/W3Buffer.d.ts.map +1 -1
- package/dist/src/W3Buffer.js +13 -9
- package/dist/src/W3Buffer.js.map +1 -1
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +162 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/index.d.ts +10 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/translators/CamerasTranslator.d.ts +9 -4
- package/dist/src/translators/CamerasTranslator.d.ts.map +1 -1
- package/dist/src/translators/CamerasTranslator.js +25 -24
- package/dist/src/translators/CamerasTranslator.js.map +1 -1
- package/dist/src/translators/DoodadsTranslator.d.ts +22 -9
- package/dist/src/translators/DoodadsTranslator.d.ts.map +1 -1
- package/dist/src/translators/DoodadsTranslator.js +101 -109
- package/dist/src/translators/DoodadsTranslator.js.map +1 -1
- package/dist/src/translators/ImportsTranslator.d.ts +5 -13
- package/dist/src/translators/ImportsTranslator.d.ts.map +1 -1
- package/dist/src/translators/ImportsTranslator.js +15 -41
- package/dist/src/translators/ImportsTranslator.js.map +1 -1
- package/dist/src/translators/InfoTranslator.d.ts +98 -10
- package/dist/src/translators/InfoTranslator.d.ts.map +1 -1
- package/dist/src/translators/InfoTranslator.js +263 -164
- package/dist/src/translators/InfoTranslator.js.map +1 -1
- package/dist/src/translators/ObjectsTranslator.d.ts +23 -7
- package/dist/src/translators/ObjectsTranslator.d.ts.map +1 -1
- package/dist/src/translators/ObjectsTranslator.js +193 -162
- package/dist/src/translators/ObjectsTranslator.js.map +1 -1
- package/dist/src/translators/RegionsTranslator.d.ts +5 -4
- package/dist/src/translators/RegionsTranslator.d.ts.map +1 -1
- package/dist/src/translators/RegionsTranslator.js +18 -35
- package/dist/src/translators/RegionsTranslator.js.map +1 -1
- package/dist/src/translators/SoundsTranslator.d.ts +46 -6
- package/dist/src/translators/SoundsTranslator.d.ts.map +1 -1
- package/dist/src/translators/SoundsTranslator.js +127 -108
- package/dist/src/translators/SoundsTranslator.js.map +1 -1
- package/dist/src/translators/StringsTranslator.d.ts +10 -4
- package/dist/src/translators/StringsTranslator.d.ts.map +1 -1
- package/dist/src/translators/StringsTranslator.js +19 -20
- package/dist/src/translators/StringsTranslator.js.map +1 -1
- package/dist/src/translators/TerrainTranslator.d.ts +24 -2
- package/dist/src/translators/TerrainTranslator.d.ts.map +1 -1
- package/dist/src/translators/TerrainTranslator.js +74 -99
- package/dist/src/translators/TerrainTranslator.js.map +1 -1
- package/dist/src/translators/UnitsTranslator.d.ts +76 -14
- package/dist/src/translators/UnitsTranslator.d.ts.map +1 -1
- package/dist/src/translators/UnitsTranslator.js +235 -139
- package/dist/src/translators/UnitsTranslator.js.map +1 -1
- package/package.json +28 -25
- package/dist/src/translators/index.d.ts +0 -11
- package/dist/src/translators/index.d.ts.map +0 -1
- package/dist/src/translators/index.js +0 -23
- package/dist/src/translators/index.js.map +0 -1
|
@@ -1,14 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InfoTranslator = void 0;
|
|
4
3
|
const HexBuffer_1 = require("../HexBuffer");
|
|
5
4
|
const W3Buffer_1 = require("../W3Buffer");
|
|
5
|
+
const CommonInterfaces_1 = require("../CommonInterfaces");
|
|
6
|
+
const PlayerBitfield_1 = require("../PlayerBitfield");
|
|
7
|
+
var UpgradeAvailability;
|
|
8
|
+
(function (UpgradeAvailability) {
|
|
9
|
+
UpgradeAvailability[UpgradeAvailability["Unavailable"] = 0] = "Unavailable";
|
|
10
|
+
UpgradeAvailability[UpgradeAvailability["Available"] = 1] = "Available";
|
|
11
|
+
UpgradeAvailability[UpgradeAvailability["Researched"] = 2] = "Researched";
|
|
12
|
+
})(UpgradeAvailability || (UpgradeAvailability = {}));
|
|
13
|
+
var PlayerType;
|
|
14
|
+
(function (PlayerType) {
|
|
15
|
+
PlayerType[PlayerType["Human"] = 1] = "Human";
|
|
16
|
+
PlayerType[PlayerType["Computer"] = 2] = "Computer";
|
|
17
|
+
PlayerType[PlayerType["Neutral"] = 3] = "Neutral";
|
|
18
|
+
PlayerType[PlayerType["Rescuable"] = 4] = "Rescuable";
|
|
19
|
+
})(PlayerType || (PlayerType = {}));
|
|
20
|
+
var PlayerRace;
|
|
21
|
+
(function (PlayerRace) {
|
|
22
|
+
PlayerRace[PlayerRace["Human"] = 1] = "Human";
|
|
23
|
+
PlayerRace[PlayerRace["Orc"] = 2] = "Orc";
|
|
24
|
+
PlayerRace[PlayerRace["Undead"] = 3] = "Undead";
|
|
25
|
+
PlayerRace[PlayerRace["NightElf"] = 4] = "NightElf";
|
|
26
|
+
})(PlayerRace || (PlayerRace = {}));
|
|
6
27
|
var FogType;
|
|
7
28
|
(function (FogType) {
|
|
8
29
|
FogType[FogType["Linear"] = 0] = "Linear";
|
|
9
30
|
FogType[FogType["Exponential1"] = 1] = "Exponential1";
|
|
10
31
|
FogType[FogType["Exponential2"] = 2] = "Exponential2";
|
|
11
32
|
})(FogType || (FogType = {}));
|
|
33
|
+
var GameDataSet;
|
|
34
|
+
(function (GameDataSet) {
|
|
35
|
+
GameDataSet[GameDataSet["Default"] = 0] = "Default";
|
|
36
|
+
GameDataSet[GameDataSet["Custom101"] = 1] = "Custom101";
|
|
37
|
+
GameDataSet[GameDataSet["MeleeLatestPath"] = 2] = "MeleeLatestPath";
|
|
38
|
+
})(GameDataSet || (GameDataSet = {}));
|
|
39
|
+
var GameDataVersion;
|
|
40
|
+
(function (GameDataVersion) {
|
|
41
|
+
GameDataVersion[GameDataVersion["ROC"] = 0] = "ROC";
|
|
42
|
+
GameDataVersion[GameDataVersion["TFT"] = 1] = "TFT";
|
|
43
|
+
})(GameDataVersion || (GameDataVersion = {}));
|
|
12
44
|
var ScriptLanguage;
|
|
13
45
|
(function (ScriptLanguage) {
|
|
14
46
|
ScriptLanguage[ScriptLanguage["JASS"] = 0] = "JASS";
|
|
@@ -20,63 +52,60 @@ var SupportedModes;
|
|
|
20
52
|
SupportedModes[SupportedModes["HD"] = 2] = "HD";
|
|
21
53
|
SupportedModes[SupportedModes["Both"] = 3] = "Both";
|
|
22
54
|
})(SupportedModes || (SupportedModes = {}));
|
|
23
|
-
|
|
55
|
+
var RandomGroupType;
|
|
56
|
+
(function (RandomGroupType) {
|
|
57
|
+
RandomGroupType[RandomGroupType["Unit"] = 0] = "Unit";
|
|
58
|
+
RandomGroupType[RandomGroupType["Building"] = 1] = "Building";
|
|
59
|
+
RandomGroupType[RandomGroupType["Item"] = 2] = "Item";
|
|
60
|
+
})(RandomGroupType || (RandomGroupType = {}));
|
|
61
|
+
class InfoTranslator extends CommonInterfaces_1.ITranslator {
|
|
24
62
|
static jsonToWar(infoJson) {
|
|
25
63
|
const outBufferToWar = new HexBuffer_1.HexBuffer();
|
|
26
|
-
outBufferToWar.addInt(
|
|
64
|
+
outBufferToWar.addInt(33);
|
|
27
65
|
outBufferToWar.addInt(infoJson.saves || 0);
|
|
28
66
|
outBufferToWar.addInt(infoJson.editorVersion || 0);
|
|
29
67
|
outBufferToWar.addInt(infoJson.gameVersion.major);
|
|
30
68
|
outBufferToWar.addInt(infoJson.gameVersion.minor);
|
|
31
69
|
outBufferToWar.addInt(infoJson.gameVersion.patch);
|
|
32
70
|
outBufferToWar.addInt(infoJson.gameVersion.build);
|
|
33
|
-
// Map information
|
|
34
71
|
outBufferToWar.addString(infoJson.map.name);
|
|
35
72
|
outBufferToWar.addString(infoJson.map.author);
|
|
36
73
|
outBufferToWar.addString(infoJson.map.description);
|
|
37
74
|
outBufferToWar.addString(infoJson.map.recommendedPlayers);
|
|
38
|
-
// Camera bounds (8 floats total)
|
|
39
75
|
for (let cbIndex = 0; cbIndex < 8; cbIndex++) {
|
|
40
76
|
outBufferToWar.addFloat(infoJson.camera.bounds[cbIndex]);
|
|
41
77
|
}
|
|
42
|
-
// Camera complements (4 floats total)
|
|
43
78
|
for (let ccIndex = 0; ccIndex < 4; ccIndex++) {
|
|
44
79
|
outBufferToWar.addInt(infoJson.camera.complements[ccIndex]);
|
|
45
80
|
}
|
|
46
|
-
// Playable area
|
|
47
81
|
outBufferToWar.addInt(infoJson.map.playableArea.width);
|
|
48
82
|
outBufferToWar.addInt(infoJson.map.playableArea.height);
|
|
49
|
-
/*
|
|
50
|
-
* Flags
|
|
51
|
-
*/
|
|
52
83
|
let flags = 0;
|
|
53
|
-
if (infoJson.map.flags) {
|
|
84
|
+
if (infoJson.map.flags) {
|
|
54
85
|
if (infoJson.map.flags.hideMinimapInPreview)
|
|
55
|
-
flags |=
|
|
86
|
+
flags |= 0x1;
|
|
56
87
|
if (infoJson.map.flags.modifyAllyPriorities)
|
|
57
|
-
flags |=
|
|
88
|
+
flags |= 0x2;
|
|
58
89
|
if (infoJson.map.flags.isMeleeMap)
|
|
59
|
-
flags |=
|
|
60
|
-
// 0x0008 - unknown; // playable map size was large and never reduced to medium (?)
|
|
90
|
+
flags |= 0x4;
|
|
61
91
|
if (infoJson.map.flags.maskedPartiallyVisible)
|
|
62
|
-
flags |=
|
|
92
|
+
flags |= 0x10;
|
|
63
93
|
if (infoJson.map.flags.fixedPlayerSetting)
|
|
64
|
-
flags |=
|
|
94
|
+
flags |= 0x20;
|
|
65
95
|
if (infoJson.map.flags.useCustomForces)
|
|
66
|
-
flags |=
|
|
96
|
+
flags |= 0x40;
|
|
67
97
|
if (infoJson.map.flags.useCustomTechtree)
|
|
68
|
-
flags |=
|
|
98
|
+
flags |= 0x80;
|
|
69
99
|
if (infoJson.map.flags.useCustomAbilities)
|
|
70
|
-
flags |=
|
|
100
|
+
flags |= 0x100;
|
|
71
101
|
if (infoJson.map.flags.useCustomUpgrades)
|
|
72
|
-
flags |=
|
|
73
|
-
// 0x0400 - unknown; // map properties menu opened at least once since map creation (?)
|
|
102
|
+
flags |= 0x200;
|
|
74
103
|
if (infoJson.map.flags.waterWavesOnCliffShores)
|
|
75
|
-
flags |=
|
|
104
|
+
flags |= 0x800;
|
|
76
105
|
if (infoJson.map.flags.waterWavesOnRollingShores)
|
|
77
|
-
flags |= 0x1000;
|
|
78
|
-
|
|
79
|
-
|
|
106
|
+
flags |= 0x1000;
|
|
107
|
+
if (infoJson.map.flags.useTerrainFog)
|
|
108
|
+
flags |= 0x2000;
|
|
80
109
|
if (infoJson.map.flags.useItemClassificationSystem)
|
|
81
110
|
flags |= 0x8000;
|
|
82
111
|
if (infoJson.map.flags.enableWaterTinting)
|
|
@@ -85,28 +114,30 @@ class InfoTranslator {
|
|
|
85
114
|
flags |= 0x20000;
|
|
86
115
|
if (infoJson.map.flags.useCustomAbilitySkins)
|
|
87
116
|
flags |= 0x40000;
|
|
117
|
+
if (infoJson.map.flags.disableDenyIcon)
|
|
118
|
+
flags |= 0x80000;
|
|
119
|
+
if (infoJson.map.flags.forceDefaultCameraZoom)
|
|
120
|
+
flags |= 0x100000;
|
|
121
|
+
if (infoJson.map.flags.forceMaxCameraZoom)
|
|
122
|
+
flags |= 0x200000;
|
|
123
|
+
if (infoJson.map.flags.forceMinCameraZoom)
|
|
124
|
+
flags |= 0x400000;
|
|
88
125
|
}
|
|
89
|
-
// Unknown, but these seem to always be on, at least for default maps
|
|
90
126
|
flags |= 0x8000;
|
|
91
127
|
flags |= 0x4000;
|
|
92
|
-
flags |=
|
|
93
|
-
outBufferToWar.addInt(flags);
|
|
94
|
-
// Map main ground type
|
|
128
|
+
flags |= 0x400;
|
|
129
|
+
outBufferToWar.addInt(flags);
|
|
95
130
|
outBufferToWar.addChar(infoJson.map.mainTileType);
|
|
96
|
-
// Loading screen
|
|
97
131
|
outBufferToWar.addInt(infoJson.loadingScreen.background);
|
|
98
132
|
outBufferToWar.addString(infoJson.loadingScreen.path);
|
|
99
133
|
outBufferToWar.addString(infoJson.loadingScreen.text);
|
|
100
134
|
outBufferToWar.addString(infoJson.loadingScreen.title);
|
|
101
135
|
outBufferToWar.addString(infoJson.loadingScreen.subtitle);
|
|
102
|
-
|
|
103
|
-
outBufferToWar.addInt(0);
|
|
104
|
-
// Prologue
|
|
136
|
+
outBufferToWar.addInt(infoJson.gameDataSet);
|
|
105
137
|
outBufferToWar.addString(infoJson.prologue.path);
|
|
106
138
|
outBufferToWar.addString(infoJson.prologue.text);
|
|
107
139
|
outBufferToWar.addString(infoJson.prologue.title);
|
|
108
140
|
outBufferToWar.addString(infoJson.prologue.subtitle);
|
|
109
|
-
// Fog
|
|
110
141
|
outBufferToWar.addInt(infoJson.fog.type);
|
|
111
142
|
outBufferToWar.addFloat(infoJson.fog.startHeight);
|
|
112
143
|
outBufferToWar.addFloat(infoJson.fog.endHeight);
|
|
@@ -114,28 +145,28 @@ class InfoTranslator {
|
|
|
114
145
|
outBufferToWar.addByte(infoJson.fog.color[0]);
|
|
115
146
|
outBufferToWar.addByte(infoJson.fog.color[1]);
|
|
116
147
|
outBufferToWar.addByte(infoJson.fog.color[2]);
|
|
117
|
-
outBufferToWar.addByte(255);
|
|
118
|
-
// Misc.
|
|
119
|
-
// If globalWeather is not defined or is set to 'none', use 0 sentinel value, else add char[4]
|
|
148
|
+
outBufferToWar.addByte(255);
|
|
120
149
|
if (!infoJson.globalWeather || infoJson.globalWeather.toLowerCase() === 'none') {
|
|
121
150
|
outBufferToWar.addInt(0);
|
|
122
151
|
}
|
|
123
152
|
else {
|
|
124
|
-
outBufferToWar.addChars(infoJson.globalWeather);
|
|
153
|
+
outBufferToWar.addChars(infoJson.globalWeather);
|
|
125
154
|
}
|
|
126
155
|
outBufferToWar.addString(infoJson.customSoundEnvironment || '');
|
|
127
156
|
outBufferToWar.addChar(infoJson.customLightEnv || 'L');
|
|
128
|
-
// Custom water tinting
|
|
129
157
|
outBufferToWar.addByte(infoJson.water[0]);
|
|
130
158
|
outBufferToWar.addByte(infoJson.water[1]);
|
|
131
159
|
outBufferToWar.addByte(infoJson.water[2]);
|
|
132
|
-
outBufferToWar.addByte(255);
|
|
160
|
+
outBufferToWar.addByte(255);
|
|
133
161
|
outBufferToWar.addInt(infoJson.scriptLanguage);
|
|
134
162
|
outBufferToWar.addInt(infoJson.supportedModes);
|
|
135
|
-
outBufferToWar.addInt(
|
|
136
|
-
|
|
163
|
+
outBufferToWar.addInt(infoJson.gameDataVersion);
|
|
164
|
+
outBufferToWar.addInt(infoJson.forceDefaultCameraZoom);
|
|
165
|
+
outBufferToWar.addInt(infoJson.forceMaxCameraZoom);
|
|
166
|
+
outBufferToWar.addInt(infoJson.forceMinCameraZoom);
|
|
167
|
+
const availablePlayerNums = infoJson.players.map((player) => player.playerNum);
|
|
137
168
|
outBufferToWar.addInt(infoJson.players.length);
|
|
138
|
-
infoJson.players
|
|
169
|
+
for (const player of infoJson.players) {
|
|
139
170
|
outBufferToWar.addInt(player.playerNum);
|
|
140
171
|
outBufferToWar.addInt(player.type);
|
|
141
172
|
outBufferToWar.addInt(player.race);
|
|
@@ -143,41 +174,79 @@ class InfoTranslator {
|
|
|
143
174
|
outBufferToWar.addString(player.name);
|
|
144
175
|
outBufferToWar.addFloat(player.startingPos.x);
|
|
145
176
|
outBufferToWar.addFloat(player.startingPos.y);
|
|
146
|
-
outBufferToWar.addInt(0)
|
|
147
|
-
outBufferToWar.addInt(0)
|
|
148
|
-
outBufferToWar.addInt(0)
|
|
149
|
-
outBufferToWar.addInt(0)
|
|
150
|
-
}
|
|
151
|
-
// Forces
|
|
177
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(player.allyLowPriorityFlags || [], availablePlayerNums));
|
|
178
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(player.allyHighPriorityFlags || [], availablePlayerNums));
|
|
179
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(player.enemyLowPriorityFlags || [], availablePlayerNums));
|
|
180
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(player.enemyHighPriorityFlags || [], availablePlayerNums));
|
|
181
|
+
}
|
|
152
182
|
outBufferToWar.addInt(infoJson.forces.length);
|
|
153
|
-
infoJson.forces.
|
|
154
|
-
|
|
183
|
+
for (let i = 0; i < infoJson.forces.length; i++) {
|
|
184
|
+
const force = infoJson.forces[i];
|
|
155
185
|
let forceFlags = 0;
|
|
156
186
|
if (force.flags.allied)
|
|
157
|
-
forceFlags |=
|
|
187
|
+
forceFlags |= 0x1;
|
|
158
188
|
if (force.flags.alliedVictory)
|
|
159
|
-
forceFlags |=
|
|
160
|
-
// Skip 0x0004
|
|
189
|
+
forceFlags |= 0x2;
|
|
161
190
|
if (force.flags.shareVision)
|
|
162
|
-
forceFlags |=
|
|
191
|
+
forceFlags |= 0x8;
|
|
163
192
|
if (force.flags.shareUnitControl)
|
|
164
|
-
forceFlags |=
|
|
193
|
+
forceFlags |= 0x10;
|
|
165
194
|
if (force.flags.shareAdvUnitControl)
|
|
166
|
-
forceFlags |=
|
|
195
|
+
forceFlags |= 0x20;
|
|
167
196
|
outBufferToWar.addInt(forceFlags);
|
|
168
|
-
|
|
197
|
+
let forcePlayerBitfield = (0, PlayerBitfield_1.toPlayerBitfield)(force.players, availablePlayerNums);
|
|
198
|
+
if (i === 0) {
|
|
199
|
+
const nonExistentPlayerNums = new Set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
|
|
200
|
+
.filter((playerNum) => !availablePlayerNums.includes(playerNum)));
|
|
201
|
+
for (const nonExistentPlayerNum of nonExistentPlayerNums) {
|
|
202
|
+
forcePlayerBitfield |= (0b1 << nonExistentPlayerNum);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
outBufferToWar.addInt(forcePlayerBitfield);
|
|
169
206
|
outBufferToWar.addString(force.name);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
outBufferToWar.addInt(
|
|
207
|
+
}
|
|
208
|
+
outBufferToWar.addInt(infoJson.upgrades.length);
|
|
209
|
+
for (const upgrade of infoJson.upgrades) {
|
|
210
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(upgrade.players, availablePlayerNums));
|
|
211
|
+
outBufferToWar.addChars(upgrade.id);
|
|
212
|
+
outBufferToWar.addInt(upgrade.level);
|
|
213
|
+
outBufferToWar.addInt(upgrade.availability);
|
|
214
|
+
}
|
|
215
|
+
outBufferToWar.addInt(infoJson.techtree.length);
|
|
216
|
+
for (const techtree of infoJson.techtree) {
|
|
217
|
+
outBufferToWar.addInt((0, PlayerBitfield_1.toPlayerBitfield)(techtree.players, availablePlayerNums));
|
|
218
|
+
outBufferToWar.addChars(techtree.id);
|
|
219
|
+
}
|
|
220
|
+
outBufferToWar.addInt(infoJson.randomGroupTable.length);
|
|
221
|
+
for (const groupTable of infoJson.randomGroupTable) {
|
|
222
|
+
outBufferToWar.addInt(groupTable.number);
|
|
223
|
+
outBufferToWar.addString(groupTable.name);
|
|
224
|
+
outBufferToWar.addInt(groupTable.positions.length);
|
|
225
|
+
for (const position of groupTable.positions) {
|
|
226
|
+
outBufferToWar.addInt(position);
|
|
227
|
+
}
|
|
228
|
+
outBufferToWar.addInt(groupTable.rows.length);
|
|
229
|
+
for (const row of groupTable.rows) {
|
|
230
|
+
outBufferToWar.addInt(row.chance);
|
|
231
|
+
for (const entry of row.entries) {
|
|
232
|
+
outBufferToWar.addChars(entry);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
outBufferToWar.addInt(infoJson.randomItemTable.length);
|
|
237
|
+
for (const itemTable of infoJson.randomItemTable) {
|
|
238
|
+
outBufferToWar.addInt(itemTable.number);
|
|
239
|
+
outBufferToWar.addString(itemTable.name);
|
|
240
|
+
outBufferToWar.addInt(itemTable.sets.length);
|
|
241
|
+
for (const itemSet of itemTable.sets) {
|
|
242
|
+
outBufferToWar.addInt(itemSet.length);
|
|
243
|
+
for (const item of itemSet) {
|
|
244
|
+
outBufferToWar.addInt(item.chance);
|
|
245
|
+
outBufferToWar.addChars(item.id);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
179
249
|
return {
|
|
180
|
-
errors: [],
|
|
181
250
|
buffer: outBufferToWar.getBuffer()
|
|
182
251
|
};
|
|
183
252
|
}
|
|
@@ -197,20 +266,23 @@ class InfoTranslator {
|
|
|
197
266
|
hideMinimapInPreview: false,
|
|
198
267
|
modifyAllyPriorities: true,
|
|
199
268
|
isMeleeMap: false,
|
|
200
|
-
// 0x0008: 1=playable map size was large and has never been reduced to medium (?)
|
|
201
269
|
maskedPartiallyVisible: false,
|
|
202
270
|
fixedPlayerSetting: false,
|
|
203
271
|
useCustomForces: false,
|
|
204
272
|
useCustomTechtree: false,
|
|
205
273
|
useCustomAbilities: false,
|
|
206
274
|
useCustomUpgrades: false,
|
|
207
|
-
// 0x0400: 1=map properties menu opened at least once since map creation (?)
|
|
208
275
|
waterWavesOnCliffShores: false,
|
|
209
276
|
waterWavesOnRollingShores: false,
|
|
277
|
+
useTerrainFog: false,
|
|
210
278
|
useItemClassificationSystem: false,
|
|
211
279
|
enableWaterTinting: false,
|
|
212
280
|
useAccurateProbabilityForCalculations: false,
|
|
213
|
-
useCustomAbilitySkins: false
|
|
281
|
+
useCustomAbilitySkins: false,
|
|
282
|
+
disableDenyIcon: false,
|
|
283
|
+
forceDefaultCameraZoom: false,
|
|
284
|
+
forceMaxCameraZoom: false,
|
|
285
|
+
forceMinCameraZoom: false
|
|
214
286
|
}
|
|
215
287
|
},
|
|
216
288
|
loadingScreen: {
|
|
@@ -219,23 +291,34 @@ class InfoTranslator {
|
|
|
219
291
|
text: '',
|
|
220
292
|
title: '',
|
|
221
293
|
subtitle: ''
|
|
222
|
-
},
|
|
294
|
+
},
|
|
295
|
+
prologue: {
|
|
223
296
|
path: '',
|
|
224
297
|
text: '',
|
|
225
298
|
title: '',
|
|
226
299
|
subtitle: ''
|
|
227
|
-
},
|
|
300
|
+
},
|
|
301
|
+
fog: {
|
|
228
302
|
type: FogType.Linear,
|
|
229
303
|
startHeight: 0,
|
|
230
304
|
endHeight: 0,
|
|
231
305
|
density: 0,
|
|
232
|
-
color: [0, 0, 0
|
|
233
|
-
},
|
|
306
|
+
color: [0, 0, 0]
|
|
307
|
+
},
|
|
308
|
+
camera: {
|
|
234
309
|
bounds: [],
|
|
235
310
|
complements: []
|
|
236
|
-
},
|
|
311
|
+
},
|
|
312
|
+
players: [],
|
|
313
|
+
forces: [],
|
|
314
|
+
upgrades: [],
|
|
315
|
+
techtree: [],
|
|
316
|
+
randomGroupTable: [],
|
|
317
|
+
randomItemTable: [],
|
|
237
318
|
saves: 0,
|
|
238
319
|
editorVersion: 0,
|
|
320
|
+
gameDataVersion: GameDataVersion.TFT,
|
|
321
|
+
gameDataSet: GameDataSet.Default,
|
|
239
322
|
scriptLanguage: ScriptLanguage.JASS,
|
|
240
323
|
supportedModes: SupportedModes.Both,
|
|
241
324
|
gameVersion: {
|
|
@@ -247,12 +330,15 @@ class InfoTranslator {
|
|
|
247
330
|
globalWeather: '',
|
|
248
331
|
customSoundEnvironment: '',
|
|
249
332
|
customLightEnv: '',
|
|
250
|
-
water: []
|
|
333
|
+
water: [],
|
|
334
|
+
forceDefaultCameraZoom: 0,
|
|
335
|
+
forceMaxCameraZoom: 0,
|
|
336
|
+
forceMinCameraZoom: 0
|
|
251
337
|
};
|
|
252
338
|
const outBufferToJSON = new W3Buffer_1.W3Buffer(buffer);
|
|
253
|
-
|
|
254
|
-
result.saves = outBufferToJSON.readInt()
|
|
255
|
-
|
|
339
|
+
(0, CommonInterfaces_1.expectVersion)(33, outBufferToJSON.readInt());
|
|
340
|
+
result.saves = outBufferToJSON.readInt();
|
|
341
|
+
result.editorVersion = outBufferToJSON.readInt();
|
|
256
342
|
result.gameVersion = {
|
|
257
343
|
major: outBufferToJSON.readInt(),
|
|
258
344
|
minor: outBufferToJSON.readInt(),
|
|
@@ -276,24 +362,26 @@ class InfoTranslator {
|
|
|
276
362
|
};
|
|
277
363
|
const flags = outBufferToJSON.readInt();
|
|
278
364
|
result.map.flags = {
|
|
279
|
-
hideMinimapInPreview: !!(flags &
|
|
280
|
-
modifyAllyPriorities: !!(flags &
|
|
281
|
-
isMeleeMap: !!(flags &
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
waterWavesOnCliffShores: !!(flags & 0x0800),
|
|
365
|
+
hideMinimapInPreview: !!(flags & 0x1),
|
|
366
|
+
modifyAllyPriorities: !!(flags & 0x2),
|
|
367
|
+
isMeleeMap: !!(flags & 0x4),
|
|
368
|
+
maskedPartiallyVisible: !!(flags & 0x10),
|
|
369
|
+
fixedPlayerSetting: !!(flags & 0x20),
|
|
370
|
+
useCustomForces: !!(flags & 0x40),
|
|
371
|
+
useCustomTechtree: !!(flags & 0x80),
|
|
372
|
+
useCustomAbilities: !!(flags & 0x100),
|
|
373
|
+
useCustomUpgrades: !!(flags & 0x200),
|
|
374
|
+
waterWavesOnCliffShores: !!(flags & 0x800),
|
|
290
375
|
waterWavesOnRollingShores: !!(flags & 0x1000),
|
|
291
|
-
|
|
292
|
-
// skip 0x4000
|
|
376
|
+
useTerrainFog: !!(flags & 0x2000),
|
|
293
377
|
useItemClassificationSystem: !!(flags & 0x8000),
|
|
294
378
|
enableWaterTinting: !!(flags & 0x10000),
|
|
295
379
|
useAccurateProbabilityForCalculations: !!(flags & 0x20000),
|
|
296
|
-
useCustomAbilitySkins: !!(flags & 0x40000)
|
|
380
|
+
useCustomAbilitySkins: !!(flags & 0x40000),
|
|
381
|
+
disableDenyIcon: !!(flags & 0x80000),
|
|
382
|
+
forceDefaultCameraZoom: !!(flags & 0x100000),
|
|
383
|
+
forceMaxCameraZoom: !!(flags & 0x200000),
|
|
384
|
+
forceMinCameraZoom: !!(flags & 0x400000)
|
|
297
385
|
};
|
|
298
386
|
result.map.mainTileType = outBufferToJSON.readChars();
|
|
299
387
|
result.loadingScreen.background = outBufferToJSON.readInt();
|
|
@@ -301,7 +389,7 @@ class InfoTranslator {
|
|
|
301
389
|
result.loadingScreen.text = outBufferToJSON.readString();
|
|
302
390
|
result.loadingScreen.title = outBufferToJSON.readString();
|
|
303
391
|
result.loadingScreen.subtitle = outBufferToJSON.readString();
|
|
304
|
-
|
|
392
|
+
result.gameDataSet = outBufferToJSON.readInt();
|
|
305
393
|
result.prologue = {
|
|
306
394
|
path: outBufferToJSON.readString(),
|
|
307
395
|
text: outBufferToJSON.readString(),
|
|
@@ -313,110 +401,121 @@ class InfoTranslator {
|
|
|
313
401
|
startHeight: outBufferToJSON.readFloat(),
|
|
314
402
|
endHeight: outBufferToJSON.readFloat(),
|
|
315
403
|
density: outBufferToJSON.readFloat(),
|
|
316
|
-
color: [outBufferToJSON.readByte(), outBufferToJSON.readByte(), outBufferToJSON.readByte()
|
|
404
|
+
color: [outBufferToJSON.readByte(), outBufferToJSON.readByte(), outBufferToJSON.readByte()]
|
|
317
405
|
};
|
|
406
|
+
outBufferToJSON.readByte();
|
|
318
407
|
result.globalWeather = outBufferToJSON.readChars(4);
|
|
319
408
|
result.customSoundEnvironment = outBufferToJSON.readString();
|
|
320
409
|
result.customLightEnv = outBufferToJSON.readChars();
|
|
321
|
-
result.water = [outBufferToJSON.readByte(), outBufferToJSON.readByte(), outBufferToJSON.readByte()
|
|
410
|
+
result.water = [outBufferToJSON.readByte(), outBufferToJSON.readByte(), outBufferToJSON.readByte()];
|
|
411
|
+
outBufferToJSON.readByte();
|
|
322
412
|
result.scriptLanguage = outBufferToJSON.readInt();
|
|
323
413
|
result.supportedModes = outBufferToJSON.readInt();
|
|
324
|
-
outBufferToJSON.readInt();
|
|
325
|
-
|
|
414
|
+
result.gameDataVersion = outBufferToJSON.readInt();
|
|
415
|
+
result.forceDefaultCameraZoom = outBufferToJSON.readInt();
|
|
416
|
+
result.forceMaxCameraZoom = outBufferToJSON.readInt();
|
|
417
|
+
result.forceMinCameraZoom = outBufferToJSON.readInt();
|
|
326
418
|
const numPlayers = outBufferToJSON.readInt();
|
|
327
419
|
for (let i = 0; i < numPlayers; i++) {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
};
|
|
335
|
-
player.playerNum = outBufferToJSON.readInt();
|
|
336
|
-
player.type = outBufferToJSON.readInt(); // 1=Human, 2=Computer, 3=Neutral, 4=Rescuable
|
|
337
|
-
player.race = outBufferToJSON.readInt(); // 1=Human, 2=Orc, 3=Undead, 4=Night Elf
|
|
338
|
-
const isPlayerStartPositionFixed = outBufferToJSON.readInt() === 1; // 00000001 = fixed start position
|
|
339
|
-
player.name = outBufferToJSON.readString();
|
|
340
|
-
player.startingPos = {
|
|
420
|
+
const playerNum = outBufferToJSON.readInt();
|
|
421
|
+
const type = outBufferToJSON.readInt();
|
|
422
|
+
const race = outBufferToJSON.readInt();
|
|
423
|
+
const isFixedStartPosition = outBufferToJSON.readInt() === 1;
|
|
424
|
+
const name = outBufferToJSON.readString();
|
|
425
|
+
const startingPos = {
|
|
341
426
|
x: outBufferToJSON.readFloat(),
|
|
342
427
|
y: outBufferToJSON.readFloat(),
|
|
343
|
-
fixed:
|
|
428
|
+
fixed: isFixedStartPosition
|
|
344
429
|
};
|
|
345
|
-
outBufferToJSON.readInt()
|
|
346
|
-
outBufferToJSON.readInt()
|
|
347
|
-
outBufferToJSON.readInt();
|
|
348
|
-
outBufferToJSON.readInt();
|
|
349
|
-
result.players.push(
|
|
430
|
+
const allyLowPriorityFlags = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), undefined);
|
|
431
|
+
const allyHighPriorityFlags = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), undefined);
|
|
432
|
+
const enemyLowPriorityFlags = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), undefined);
|
|
433
|
+
const enemyHighPriorityFlags = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), undefined);
|
|
434
|
+
result.players.push({ name, startingPos, playerNum, type, race, allyLowPriorityFlags, allyHighPriorityFlags, enemyLowPriorityFlags, enemyHighPriorityFlags });
|
|
350
435
|
}
|
|
351
|
-
|
|
436
|
+
const availablePlayerNums = result.players.map((player) => player.playerNum);
|
|
352
437
|
const numForces = outBufferToJSON.readInt();
|
|
353
438
|
for (let i = 0; i < numForces; i++) {
|
|
354
|
-
const force = {
|
|
355
|
-
flags: { allied: false, alliedVictory: true, shareVision: true, shareUnitControl: false, shareAdvUnitControl: false },
|
|
356
|
-
players: 0,
|
|
357
|
-
name: ''
|
|
358
|
-
};
|
|
359
439
|
const forceFlag = outBufferToJSON.readInt();
|
|
360
|
-
|
|
361
|
-
allied: !!(forceFlag &
|
|
362
|
-
alliedVictory: !!(forceFlag &
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
shareAdvUnitControl: !!(forceFlag & 0b100000) // 0x00000020: share advanced unit control
|
|
440
|
+
const flags = {
|
|
441
|
+
allied: !!(forceFlag & 0x1),
|
|
442
|
+
alliedVictory: !!(forceFlag & 0x2),
|
|
443
|
+
shareVision: !!(forceFlag & 0x8),
|
|
444
|
+
shareUnitControl: !!(forceFlag & 0x10),
|
|
445
|
+
shareAdvUnitControl: !!(forceFlag & 0x20)
|
|
367
446
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
result.forces.push(
|
|
447
|
+
const players = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), availablePlayerNums);
|
|
448
|
+
const name = outBufferToJSON.readString();
|
|
449
|
+
result.forces.push({ name, flags, players });
|
|
371
450
|
}
|
|
372
|
-
// UNSUPPORTED: Struct: upgrade avail.
|
|
373
451
|
const numUpgrades = outBufferToJSON.readInt();
|
|
374
452
|
for (let i = 0; i < numUpgrades; i++) {
|
|
375
|
-
outBufferToJSON.readInt()
|
|
376
|
-
outBufferToJSON.readChars(4);
|
|
377
|
-
outBufferToJSON.readInt();
|
|
378
|
-
outBufferToJSON.readInt();
|
|
453
|
+
const players = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), availablePlayerNums);
|
|
454
|
+
const id = outBufferToJSON.readChars(4);
|
|
455
|
+
const level = outBufferToJSON.readInt();
|
|
456
|
+
const availability = outBufferToJSON.readInt();
|
|
457
|
+
result.upgrades.push({ id, players, level, availability });
|
|
379
458
|
}
|
|
380
|
-
// UNSUPPORTED: Struct: tech avail.
|
|
381
459
|
const numTech = outBufferToJSON.readInt();
|
|
382
460
|
for (let i = 0; i < numTech; i++) {
|
|
383
|
-
outBufferToJSON.readInt()
|
|
384
|
-
outBufferToJSON.readChars(4);
|
|
461
|
+
const players = (0, PlayerBitfield_1.fromPlayerBitfield)(outBufferToJSON.readInt(), availablePlayerNums);
|
|
462
|
+
const id = outBufferToJSON.readChars(4);
|
|
463
|
+
result.techtree.push({ players, id });
|
|
385
464
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
465
|
+
const numGroupTables = outBufferToJSON.readInt();
|
|
466
|
+
for (let i = 0; i < numGroupTables; i++) {
|
|
467
|
+
const group = {
|
|
468
|
+
number: outBufferToJSON.readInt(),
|
|
469
|
+
name: outBufferToJSON.readString(),
|
|
470
|
+
positions: [],
|
|
471
|
+
rows: []
|
|
472
|
+
};
|
|
473
|
+
const numPositions = outBufferToJSON.readInt();
|
|
474
|
+
for (let i = 0; i < numPositions; i++) {
|
|
475
|
+
const positionType = outBufferToJSON.readInt();
|
|
476
|
+
group.positions.push(positionType);
|
|
477
|
+
}
|
|
478
|
+
const numRows = outBufferToJSON.readInt();
|
|
479
|
+
for (let j = 0; j < numRows; j++) {
|
|
480
|
+
const chance = outBufferToJSON.readInt();
|
|
481
|
+
const entries = [];
|
|
482
|
+
for (let i = 0; i < numPositions; i++) {
|
|
483
|
+
entries.push(outBufferToJSON.readChars(4));
|
|
398
484
|
}
|
|
485
|
+
group.rows.push({ chance, entries });
|
|
399
486
|
}
|
|
487
|
+
result.randomGroupTable.push(group);
|
|
400
488
|
}
|
|
401
|
-
// UNSUPPORTED: Struct: random item table
|
|
402
489
|
const numItemTable = outBufferToJSON.readInt();
|
|
403
490
|
for (let i = 0; i < numItemTable; i++) {
|
|
404
|
-
outBufferToJSON.readInt();
|
|
405
|
-
outBufferToJSON.readString();
|
|
406
|
-
const
|
|
491
|
+
const number = outBufferToJSON.readInt();
|
|
492
|
+
const name = outBufferToJSON.readString();
|
|
493
|
+
const sets = [];
|
|
494
|
+
const itemSetsCurrentTable = outBufferToJSON.readInt();
|
|
407
495
|
for (let j = 0; j < itemSetsCurrentTable; j++) {
|
|
408
|
-
const
|
|
496
|
+
const itemSet = [];
|
|
497
|
+
const itemsInItemSet = outBufferToJSON.readInt();
|
|
409
498
|
for (let k = 0; k < itemsInItemSet; k++) {
|
|
410
|
-
outBufferToJSON.readInt();
|
|
411
|
-
outBufferToJSON.readChars(4);
|
|
499
|
+
const chance = outBufferToJSON.readInt();
|
|
500
|
+
const itemId = outBufferToJSON.readChars(4);
|
|
501
|
+
itemSet.push({ chance, id: itemId });
|
|
412
502
|
}
|
|
503
|
+
sets.push(itemSet);
|
|
413
504
|
}
|
|
505
|
+
result.randomItemTable.push({ name, number, sets });
|
|
414
506
|
}
|
|
415
507
|
return {
|
|
416
|
-
errors: [],
|
|
417
508
|
json: result
|
|
418
509
|
};
|
|
419
510
|
}
|
|
420
511
|
}
|
|
421
|
-
exports.
|
|
512
|
+
exports.default = InfoTranslator;
|
|
513
|
+
InfoTranslator.PlayerType = PlayerType;
|
|
514
|
+
InfoTranslator.PlayerRace = PlayerRace;
|
|
515
|
+
InfoTranslator.FogType = FogType;
|
|
516
|
+
InfoTranslator.GameDataSet = GameDataSet;
|
|
517
|
+
InfoTranslator.GameDataVersion = GameDataVersion;
|
|
518
|
+
InfoTranslator.ScriptLanguage = ScriptLanguage;
|
|
519
|
+
InfoTranslator.SupportedModes = SupportedModes;
|
|
520
|
+
InfoTranslator.UpgradeAvailability = UpgradeAvailability;
|
|
422
521
|
//# sourceMappingURL=InfoTranslator.js.map
|