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.
Files changed (77) hide show
  1. package/README.md +62 -43
  2. package/dist/src/AngleConverter.d.ts +3 -2
  3. package/dist/src/AngleConverter.d.ts.map +1 -1
  4. package/dist/src/AngleConverter.js.map +1 -1
  5. package/dist/src/CommonInterfaces.d.ts +12 -8
  6. package/dist/src/CommonInterfaces.d.ts.map +1 -1
  7. package/dist/src/CommonInterfaces.js +17 -0
  8. package/dist/src/CommonInterfaces.js.map +1 -1
  9. package/dist/src/HexBuffer.d.ts +5 -2
  10. package/dist/src/HexBuffer.d.ts.map +1 -1
  11. package/dist/src/HexBuffer.js +34 -34
  12. package/dist/src/HexBuffer.js.map +1 -1
  13. package/dist/src/PlayerBitfield.d.ts +30 -0
  14. package/dist/src/PlayerBitfield.d.ts.map +1 -0
  15. package/dist/src/PlayerBitfield.js +56 -0
  16. package/dist/src/PlayerBitfield.js.map +1 -0
  17. package/dist/src/TranslatorMappings.d.ts +12 -0
  18. package/dist/src/TranslatorMappings.d.ts.map +1 -0
  19. package/dist/src/TranslatorMappings.js +47 -0
  20. package/dist/src/TranslatorMappings.js.map +1 -0
  21. package/dist/src/W3Buffer.d.ts +4 -1
  22. package/dist/src/W3Buffer.d.ts.map +1 -1
  23. package/dist/src/W3Buffer.js +13 -9
  24. package/dist/src/W3Buffer.js.map +1 -1
  25. package/dist/src/cli.d.ts +3 -0
  26. package/dist/src/cli.d.ts.map +1 -0
  27. package/dist/src/cli.js +162 -0
  28. package/dist/src/cli.js.map +1 -0
  29. package/dist/src/index.d.ts +10 -1
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +23 -11
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/src/translators/CamerasTranslator.d.ts +9 -4
  34. package/dist/src/translators/CamerasTranslator.d.ts.map +1 -1
  35. package/dist/src/translators/CamerasTranslator.js +25 -24
  36. package/dist/src/translators/CamerasTranslator.js.map +1 -1
  37. package/dist/src/translators/DoodadsTranslator.d.ts +22 -9
  38. package/dist/src/translators/DoodadsTranslator.d.ts.map +1 -1
  39. package/dist/src/translators/DoodadsTranslator.js +101 -109
  40. package/dist/src/translators/DoodadsTranslator.js.map +1 -1
  41. package/dist/src/translators/ImportsTranslator.d.ts +5 -13
  42. package/dist/src/translators/ImportsTranslator.d.ts.map +1 -1
  43. package/dist/src/translators/ImportsTranslator.js +15 -41
  44. package/dist/src/translators/ImportsTranslator.js.map +1 -1
  45. package/dist/src/translators/InfoTranslator.d.ts +98 -10
  46. package/dist/src/translators/InfoTranslator.d.ts.map +1 -1
  47. package/dist/src/translators/InfoTranslator.js +263 -164
  48. package/dist/src/translators/InfoTranslator.js.map +1 -1
  49. package/dist/src/translators/ObjectsTranslator.d.ts +23 -7
  50. package/dist/src/translators/ObjectsTranslator.d.ts.map +1 -1
  51. package/dist/src/translators/ObjectsTranslator.js +193 -162
  52. package/dist/src/translators/ObjectsTranslator.js.map +1 -1
  53. package/dist/src/translators/RegionsTranslator.d.ts +5 -4
  54. package/dist/src/translators/RegionsTranslator.d.ts.map +1 -1
  55. package/dist/src/translators/RegionsTranslator.js +18 -35
  56. package/dist/src/translators/RegionsTranslator.js.map +1 -1
  57. package/dist/src/translators/SoundsTranslator.d.ts +46 -6
  58. package/dist/src/translators/SoundsTranslator.d.ts.map +1 -1
  59. package/dist/src/translators/SoundsTranslator.js +127 -108
  60. package/dist/src/translators/SoundsTranslator.js.map +1 -1
  61. package/dist/src/translators/StringsTranslator.d.ts +10 -4
  62. package/dist/src/translators/StringsTranslator.d.ts.map +1 -1
  63. package/dist/src/translators/StringsTranslator.js +19 -20
  64. package/dist/src/translators/StringsTranslator.js.map +1 -1
  65. package/dist/src/translators/TerrainTranslator.d.ts +24 -2
  66. package/dist/src/translators/TerrainTranslator.d.ts.map +1 -1
  67. package/dist/src/translators/TerrainTranslator.js +74 -99
  68. package/dist/src/translators/TerrainTranslator.js.map +1 -1
  69. package/dist/src/translators/UnitsTranslator.d.ts +76 -14
  70. package/dist/src/translators/UnitsTranslator.d.ts.map +1 -1
  71. package/dist/src/translators/UnitsTranslator.js +235 -139
  72. package/dist/src/translators/UnitsTranslator.js.map +1 -1
  73. package/package.json +28 -25
  74. package/dist/src/translators/index.d.ts +0 -11
  75. package/dist/src/translators/index.d.ts.map +0 -1
  76. package/dist/src/translators/index.js +0 -23
  77. 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
- class InfoTranslator {
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(31); // file version, 0x1F
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) { // can leave out the entire flags object, all flags will default to false
84
+ if (infoJson.map.flags) {
54
85
  if (infoJson.map.flags.hideMinimapInPreview)
55
- flags |= 0x0001; // hide minimap in preview screens
86
+ flags |= 0x1;
56
87
  if (infoJson.map.flags.modifyAllyPriorities)
57
- flags |= 0x0002; // modify ally priorities
88
+ flags |= 0x2;
58
89
  if (infoJson.map.flags.isMeleeMap)
59
- flags |= 0x0004; // melee map
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 |= 0x0010; // masked area are partially visible
92
+ flags |= 0x10;
63
93
  if (infoJson.map.flags.fixedPlayerSetting)
64
- flags |= 0x0020; // fixed player setting for custom forces
94
+ flags |= 0x20;
65
95
  if (infoJson.map.flags.useCustomForces)
66
- flags |= 0x0040; // use custom forces
96
+ flags |= 0x40;
67
97
  if (infoJson.map.flags.useCustomTechtree)
68
- flags |= 0x0080; // use custom techtree
98
+ flags |= 0x80;
69
99
  if (infoJson.map.flags.useCustomAbilities)
70
- flags |= 0x0100; // use custom abilities
100
+ flags |= 0x100;
71
101
  if (infoJson.map.flags.useCustomUpgrades)
72
- flags |= 0x0200; // use custom upgrades
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 |= 0x0800; // show water waves on cliff shores
104
+ flags |= 0x800;
76
105
  if (infoJson.map.flags.waterWavesOnRollingShores)
77
- flags |= 0x1000; // show water waves on rolling shores
78
- // 0x2000: 1=unknown
79
- // 0x4000: 1=unknown
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 |= 0x0400;
93
- outBufferToWar.addInt(flags); // Add 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
- // Use game data set (Unsupported)
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); // Fog alpha - unsupported
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); // char[4] - lookup table
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); // Water alpha - unsupported
160
+ outBufferToWar.addByte(255);
133
161
  outBufferToWar.addInt(infoJson.scriptLanguage);
134
162
  outBufferToWar.addInt(infoJson.supportedModes);
135
- outBufferToWar.addInt(0); // unknown
136
- // Players
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.forEach((player) => {
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); // ally low prio flags - unsupported
147
- outBufferToWar.addInt(0); // ally high prio flags - unsupported
148
- outBufferToWar.addInt(0); // enemy low prio flags - unsupported
149
- outBufferToWar.addInt(0); // enemy high prio flags - unsupported
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.forEach((force) => {
154
- // Calculate flags
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 |= 0x0001;
187
+ forceFlags |= 0x1;
158
188
  if (force.flags.alliedVictory)
159
- forceFlags |= 0x0002;
160
- // Skip 0x0004
189
+ forceFlags |= 0x2;
161
190
  if (force.flags.shareVision)
162
- forceFlags |= 0x0008;
191
+ forceFlags |= 0x8;
163
192
  if (force.flags.shareUnitControl)
164
- forceFlags |= 0x0010;
193
+ forceFlags |= 0x10;
165
194
  if (force.flags.shareAdvUnitControl)
166
- forceFlags |= 0x0020;
195
+ forceFlags |= 0x20;
167
196
  outBufferToWar.addInt(forceFlags);
168
- outBufferToWar.addInt(force.players);
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
- // Upgrades - unsupported
172
- outBufferToWar.addInt(0);
173
- // Tech availability - unsupported
174
- outBufferToWar.addInt(0);
175
- // Unit table (random) - unsupported
176
- outBufferToWar.addInt(0);
177
- // Item table (random) - unsupported
178
- outBufferToWar.addInt(0);
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 // 0x40000
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
- }, prologue: {
294
+ },
295
+ prologue: {
223
296
  path: '',
224
297
  text: '',
225
298
  title: '',
226
299
  subtitle: ''
227
- }, fog: {
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, 1]
233
- }, camera: {
306
+ color: [0, 0, 0]
307
+ },
308
+ camera: {
234
309
  bounds: [],
235
310
  complements: []
236
- }, players: [], forces: [],
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
- const fileVersion = outBufferToJSON.readInt();
254
- result.saves = outBufferToJSON.readInt(),
255
- result.editorVersion = outBufferToJSON.readInt();
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 & 0x0001),
280
- modifyAllyPriorities: !!(flags & 0x0002),
281
- isMeleeMap: !!(flags & 0x0004),
282
- // skip 0x008
283
- maskedPartiallyVisible: !!(flags & 0x0010),
284
- fixedPlayerSetting: !!(flags & 0x0020),
285
- useCustomForces: !!(flags & 0x0040),
286
- useCustomTechtree: !!(flags & 0x0080),
287
- useCustomAbilities: !!(flags & 0x0100),
288
- useCustomUpgrades: !!(flags & 0x0200),
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
- // skip 0x2000
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
- const gameDataSet = outBufferToJSON.readInt(); // 0 = standard
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(), outBufferToJSON.readByte()] // R G B A
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(), outBufferToJSON.readByte()]; // R G B A
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(); // unknown
325
- // Struct: players
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 player = {
329
- name: '',
330
- startingPos: { x: 0, y: 0, fixed: false },
331
- playerNum: 0,
332
- type: 0,
333
- race: 0
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: isPlayerStartPositionFixed
428
+ fixed: isFixedStartPosition
344
429
  };
345
- outBufferToJSON.readInt(); // ally low priorities flags (bit "x"=1 --> set for player "x")
346
- outBufferToJSON.readInt(); // ally high priorities flags (bit "x"=1 --> set for player "x")
347
- outBufferToJSON.readInt(); // enemy low priorities flags
348
- outBufferToJSON.readInt(); // enemy high priorities flags
349
- result.players.push(player);
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
- // Struct: forces
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
- force.flags = {
361
- allied: !!(forceFlag & 0b1),
362
- alliedVictory: !!(forceFlag & 0b10),
363
- // 0x00000004: share vision (the documentation has this incorrect)
364
- shareVision: !!(forceFlag & 0b1000),
365
- shareUnitControl: !!(forceFlag & 0b10000),
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
- force.players = outBufferToJSON.readInt(); // UNSUPPORTED: (bit "x"=1 --> player "x" is in this force; but carried over for accurate translation
369
- force.name = outBufferToJSON.readString();
370
- result.forces.push(force);
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(); // Player Flags (bit "x"=1 if this change applies for player "x")
376
- outBufferToJSON.readChars(4); // upgrade id (as in UpgradeData.slk)
377
- outBufferToJSON.readInt(); // Level of the upgrade for which the availability is changed (this is actually the level - 1, so 1 => 0)
378
- outBufferToJSON.readInt(); // Availability (0 = unavailable, 1 = available, 2 = researched)
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(); // Player Flags (bit "x"=1 if this change applies for player "x")
384
- outBufferToJSON.readChars(4); // tech id (this can be an item, unit or ability)
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
- // UNSUPPORTED: Struct: random unit table
387
- const numUnitTable = outBufferToJSON.readInt();
388
- for (let i = 0; i < numUnitTable; i++) {
389
- outBufferToJSON.readInt(); // Group number
390
- outBufferToJSON.readString(); // Group name
391
- const numPositions = outBufferToJSON.readInt(); // Number "m" of positions
392
- for (let j = 0; j < numPositions; j++) {
393
- outBufferToJSON.readInt(); // unit table (=0), a building table (=1) or an item table (=2)
394
- const numLinesInTable = outBufferToJSON.readInt();
395
- for (let k = 0; k < numLinesInTable; k++) {
396
- outBufferToJSON.readInt(); // Chance of the unit/item (percentage)
397
- outBufferToJSON.readChars(4); // unit/item id's for this line specified
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(); // Table number
405
- outBufferToJSON.readString(); // Table name
406
- const itemSetsCurrentTable = outBufferToJSON.readInt(); // Number "m" of item sets on the current item table
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 itemsInItemSet = outBufferToJSON.readInt(); // Number "i" of items on the current item set
496
+ const itemSet = [];
497
+ const itemsInItemSet = outBufferToJSON.readInt();
409
498
  for (let k = 0; k < itemsInItemSet; k++) {
410
- outBufferToJSON.readInt(); // Percentual chance
411
- outBufferToJSON.readChars(4); // Item id (as in ItemData.slk)
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.InfoTranslator = InfoTranslator;
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