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
package/README.md CHANGED
@@ -47,18 +47,42 @@
47
47
  <hr/>
48
48
 
49
49
  ## Overview
50
- WC3MapTranslator is a TypeScript module to convert between JSON and WarCraft III (.w3x) `war3map` formats. This makes the map data readable and easily modifiable, a perfect format for storing WC3 maps in Git repositories and inspecting diffs!
50
+ WC3MapTranslator is a TypeScript module and CLI to convert between JSON and WarCraft III (.w3x) `war3map` formats. This makes the map data readable and easily modifiable, a perfect format for storing WC3 maps in Git repositories and inspecting diffs!
51
51
 
52
52
  ![TranslationExample](https://user-images.githubusercontent.com/4079034/71315302-4947fb00-2427-11ea-8f50-edf05d6e5c6a.png)
53
53
 
54
54
  ## Install
55
- ```ts
56
- npm install wc3maptranslator
55
+ ```sh
56
+ # Global install recommended for CLI usage; for local install drop the -g flag
57
+ npm install -g wc3maptranslator
57
58
  ```
58
59
 
59
- **Requires Node ≥ 14**
60
+ **Requires Node ≥ 24**
61
+
62
+ ## Usage (CLI)
63
+ ```sh
64
+ # wc3maptranslator <input> [output]
65
+
66
+ # Usage (individual files, same directory)
67
+ wc3maptranslator terrain.json # outputs war3map.w3e in CWD
68
+ wc3maptranslator war3map.w3i # outputs info.json in CWD
69
+
70
+ # Usage (translate an entire folder)
71
+ wc3maptranslator ./path/to/war3mapFiles --toJson
72
+ wc3maptranslator ./path/to/jsonFiles --toWar
73
+
74
+ # See list of available translators and standard file names
75
+ wc3maptranslator --list
60
76
 
61
- ## Usage
77
+ # See help
78
+ wc3maptranslator --help
79
+
80
+ # Useful flags
81
+ --force / -f Overwrite existing files (by default, translation is skipped if it would overwrite an existing file)
82
+ --silent / -s Silence success output messages (errors will still be shown)
83
+ ```
84
+
85
+ ## Usage (programmatic)
62
86
  ```ts
63
87
  import {
64
88
  CamerasTranslator,
@@ -107,53 +131,44 @@ fs.writeFileSync('war3map.w3c', translatedResult.buffer);
107
131
 
108
132
  | Type | Json → War | War → Json | File |
109
133
  |-------------------------|:-----------:|:-----------:|---------------|
110
- | Terrain | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3e |
111
- | Units | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3mapUnits.doo |
112
- | Doodads | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.doo |
113
- | Regions | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3r |
114
- | Cameras | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3c |
115
- | Sounds (definitions) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3s |
134
+ | Terrain | | | war3map.w3e |
135
+ | Units | | | war3mapUnits.doo |
136
+ | Doodads | | | war3map.doo |
137
+ | Regions | | | war3map.w3r |
138
+ | Cameras | | | war3map.w3c |
116
139
 
117
140
  ### Object data files
118
141
 
119
142
  | Type | Json → War | War → Json | File |
120
143
  |-------------------------|:-----------:|:-----------:|---------------|
121
- | Units - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3u |
122
- | Items - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3t |
123
- | Abilities - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3a |
124
- | Destructables - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3b |
125
- | Doodads - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3d |
126
- | Upgrades - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3q |
127
- | Buffs - Objects | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3h |
128
-
129
- ### Trigger files
130
-
131
- | Type | Json → War | War → Json | File |
132
- |-------------------------|:-----------:|:-----------:|---------------|
133
- | LUA | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.lua |
134
- | JASS | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.j |
135
- | Strings | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.wts |
136
-
137
-
144
+ | Units - Objects | | | war3map.w3u |
145
+ | Items - Objects | | | war3map.w3t |
146
+ | Abilities - Objects | | | war3map.w3a |
147
+ | Destructables - Objects | | | war3map.w3b / war3mapSkin.w3b |
148
+ | Doodads - Objects | | | war3map.w3d |
149
+ | Upgrades - Objects | | | war3map.w3q |
150
+ | Buffs - Objects | | | war3map.w3h |
138
151
 
139
152
  ### Map files
140
153
 
141
154
  | Type | Json → War | War → Json | File |
142
155
  |-------------------------|:-----------:|:-----------:|---------------|
143
- | Info File | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.w3i |
144
- | Imported Files | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | ![check](https://cloud.githubusercontent.com/assets/4079034/25298706/7a881946-26c5-11e7-896b-402f60a0f059.png) | war3map.imp |
145
- | Pathing | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.wpm |
146
- | Shadow map | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | ![times](https://cloud.githubusercontent.com/assets/4079034/25298707/7a883642-26c5-11e7-841c-cd3eb1425461.png) | war3map.shd |
147
-
156
+ | Info File | | | war3map.w3i |
157
+ | Imported Files | | | war3map.imp |
158
+ | Sounds (definitions) | | | war3map.w3s |
159
+ | Strings (triggers) | | | war3map.wts |
160
+ | Pathing | ❌ | ❌ | war3map.wpm |
161
+ | Shadow map | ❌ | ❌ | war3map.shd |
148
162
 
149
163
  ### Not relevant
150
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Custom Text Trigger File (war3map.wct)
151
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Trigger Names File (war3map.wtg)
152
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Menu Minimap (war3map.mmp)
153
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Minimap Image (war3mapMap.blp)
154
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Minimap Image (war3mapMap.b00
155
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Minimap Image (war3mapMap.tga)
156
- ![minus-solid](https://user-images.githubusercontent.com/4079034/108644014-16f6bb00-747b-11eb-8c2b-9e7a1d7b6f9b.png) Map Preview Image (war3mapPreview.tga)
164
+ Triggers (war3map.j, war3map.lua)
165
+ Custom Text Trigger File (war3map.wct)
166
+ Trigger Names File (war3map.wtg)
167
+ Menu Minimap (war3map.mmp)
168
+ Minimap Image (war3mapMap.blp)
169
+ Minimap Image (war3mapMap.b00)
170
+ Minimap Image (war3mapMap.tga)
171
+ ➖ Map Preview Image (war3mapPreview.tga)
157
172
 
158
173
  ## Specification
159
174
  ### WC3MapTranslator format
@@ -168,15 +183,19 @@ The underlying WarCraft map files (e.g. war3map.doo) have been documented in a s
168
183
  We encourage contributions! Generally, the process of making a change is:
169
184
  1. Fork this repo
170
185
  2. Develop your changes on a new branch
171
- 3. Submit a pull request to `dev`
186
+ 3. Submit a pull request to `master`
172
187
 
173
188
  **Your code should**:
174
189
  * **run** (your code needs to work, of course)
175
- * **include tests** (write unit tests to demonstrate your code works under different conditions)
190
+ * **include tests** (run `npm run test` and include unit tests to demonstrate your code works under different conditions)
176
191
  * **be linted** (run `npm run lint` and follow the project's coding standards)
177
192
  * **pass CI** (we enforce: ESLint, unit tests pass, code coverage)
178
193
 
179
- A code review is required on your PR to be accepted into `dev`. A project member will get back to you within one week. If you haven't heard from someone regarding your PR, feel free to ping @chiefofgxbxl.
194
+ A code review is required on your PR to be accepted into `master`. A project member will get back to you within one week. If you haven't heard from someone regarding your PR, feel free to ping @chiefofgxbxl.
195
+
196
+ Your pull request may update `package.json` to include your username under the `contributors` field.
197
+
198
+ If you are updating the CLI, remember to run `npm link` during local development prior to testing out changes, so the `wc3maptranslator` command reflects your latest changes.
180
199
 
181
200
  ## Special Thanks
182
201
  We owe a lot of thanks to *Chocobo* on [TheHelper](http://www.thehelper.net/) for the detailed documentation of the files found in a .w3x archive. Two tutorials are [here (1)](http://www.thehelper.net/threads/guide-explanation-of-w3m-and-w3x-files.35292/) and [here (2)](http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=42787).
@@ -1,3 +1,4 @@
1
- export declare function deg2Rad(angleInDegrees: number): number;
2
- export declare function rad2Deg(angleInRadians: number): number;
1
+ import { angle } from './CommonInterfaces';
2
+ export declare function deg2Rad(angleInDegrees: angle): number;
3
+ export declare function rad2Deg(angleInRadians: number): angle;
3
4
  //# sourceMappingURL=AngleConverter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AngleConverter.d.ts","sourceRoot":"","sources":["../../src/AngleConverter.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAEtD"}
1
+ {"version":3,"file":"AngleConverter.d.ts","sourceRoot":"","sources":["../../src/AngleConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,wBAAgB,OAAO,CAAC,cAAc,EAAE,KAAK,GAAG,MAAM,CAErD;AAED,wBAAgB,OAAO,CAAC,cAAc,EAAE,MAAM,GAAG,KAAK,CAErD"}
@@ -1 +1 @@
1
- {"version":3,"file":"AngleConverter.js","sourceRoot":"","sources":["../../src/AngleConverter.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,cAAsB;IAC1C,OAAO,cAAc,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAC1C,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO,CAAC,cAAsB;IAC1C,OAAO,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1C,CAAC;AAFD,0BAEC"}
1
+ {"version":3,"file":"AngleConverter.js","sourceRoot":"","sources":["../../src/AngleConverter.ts"],"names":[],"mappings":";;;AAEA,SAAgB,OAAO,CAAC,cAAqB;IACzC,OAAO,cAAc,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;AAC1C,CAAC;AAFD,0BAEC;AAED,SAAgB,OAAO,CAAC,cAAsB;IAC1C,OAAO,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AAC1C,CAAC;AAFD,0BAEC"}
@@ -1,17 +1,21 @@
1
1
  /// <reference types="node" />
2
- /**
3
- * @type angle - An angle is measured in degrees, 0 <= angle < 360
4
- */
5
- export declare type angle = number;
6
- export interface TranslationError {
7
- message: string;
2
+ /// <reference types="node" />
3
+ export type angle = number;
4
+ export declare abstract class ITranslator {
5
+ abstract jsonToWar(...args: any[]): WarResult;
6
+ abstract warToJson(...args: any[]): JsonResult;
8
7
  }
9
8
  export interface WarResult {
10
9
  buffer: Buffer;
11
- errors?: TranslationError[];
10
+ bufferSkin?: Buffer;
12
11
  }
13
12
  export interface JsonResult<T = object> {
14
13
  json: T;
15
- errors?: TranslationError[];
16
14
  }
15
+ export declare class VersionError extends Error {
16
+ expectedVersion: number;
17
+ foundVersion: number;
18
+ constructor(expectedVersion: number, foundVersion: number);
19
+ }
20
+ export declare function expectVersion(expected: number, actual: number): void;
17
21
  //# sourceMappingURL=CommonInterfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonInterfaces.d.ts","sourceRoot":"","sources":["../../src/CommonInterfaces.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,oBAAY,KAAK,GAAG,MAAM,CAAC;AAM3B,MAAM,WAAW,gBAAgB;IAC7B,OAAO,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM;IAClC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC9B"}
1
+ {"version":3,"file":"CommonInterfaces.d.ts","sourceRoot":"","sources":["../../src/CommonInterfaces.ts"],"names":[],"mappings":";;AAGA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B,8BAAsB,WAAW;IAC7B,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,SAAS;IAC7C,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,UAAU;CAGjD;AAED,MAAM,WAAW,SAAS;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM;IAClC,IAAI,EAAE,CAAC,CAAC;CACX;AAED,qBAAa,YAAa,SAAQ,KAAK;IAChB,eAAe,EAAE,MAAM;IAAS,YAAY,EAAE,MAAM;gBAApD,eAAe,EAAE,MAAM,EAAS,YAAY,EAAE,MAAM;CAG1E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAE7D"}
@@ -1,3 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.expectVersion = exports.VersionError = exports.ITranslator = void 0;
4
+ class ITranslator {
5
+ }
6
+ exports.ITranslator = ITranslator;
7
+ class VersionError extends Error {
8
+ constructor(expectedVersion, foundVersion) {
9
+ super('WC3MapTranslator cannot currently parse this version of a war3map file');
10
+ this.expectedVersion = expectedVersion;
11
+ this.foundVersion = foundVersion;
12
+ }
13
+ }
14
+ exports.VersionError = VersionError;
15
+ function expectVersion(expected, actual) {
16
+ if (actual !== expected)
17
+ throw new VersionError(expected, actual);
18
+ }
19
+ exports.expectVersion = expectVersion;
3
20
  //# sourceMappingURL=CommonInterfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CommonInterfaces.js","sourceRoot":"","sources":["../../src/CommonInterfaces.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"CommonInterfaces.js","sourceRoot":"","sources":["../../src/CommonInterfaces.ts"],"names":[],"mappings":";;;AAKA,MAAsB,WAAW;CAKhC;AALD,kCAKC;AAWD,MAAa,YAAa,SAAQ,KAAK;IACnC,YAAmB,eAAuB,EAAS,YAAoB;QACnE,KAAK,CAAC,wEAAwE,CAAC,CAAC;QADjE,oBAAe,GAAf,eAAe,CAAQ;QAAS,iBAAY,GAAZ,YAAY,CAAQ;IAEvE,CAAC;CACJ;AAJD,oCAIC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,MAAc;IAC1D,IAAI,MAAM,KAAK,QAAQ;QAAE,MAAM,IAAI,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAFD,sCAEC"}
@@ -1,14 +1,17 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare class HexBuffer {
3
4
  private _buffer;
4
5
  addString(str: string): void;
5
6
  addNewLine(): void;
6
7
  addChar(char: string): void;
7
8
  addChars(chars: string): void;
8
- addInt(int: number, isShort?: boolean): void;
9
+ private addSizedInt;
10
+ addInt(int: number): void;
11
+ addInt24(int: number): void;
9
12
  addShort(short: number): void;
10
13
  addFloat(float: number): void;
11
- addByte(byte: any): void;
14
+ addByte(byte: number): void;
12
15
  addNullTerminator(): void;
13
16
  getBuffer(): Buffer;
14
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HexBuffer.d.ts","sourceRoot":"","sources":["../../src/HexBuffer.ts"],"names":[],"mappings":";AAkBA,qBAAa,SAAS;IAClB,OAAO,CAAC,OAAO,CAAM;IAEd,SAAS,CAAC,GAAG,EAAE,MAAM;IAYrB,UAAU;IAKV,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMtB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe;IAM5C,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAWtB,OAAO,CAAC,IAAI,KAAA;IAIZ,iBAAiB;IAIjB,SAAS,IAAI,MAAM;CAG7B"}
1
+ {"version":3,"file":"HexBuffer.d.ts","sourceRoot":"","sources":["../../src/HexBuffer.ts"],"names":[],"mappings":";;AAeA,qBAAa,SAAS;IAClB,OAAO,CAAC,OAAO,CAAgB;IAExB,SAAS,CAAC,GAAG,EAAE,MAAM;IAQrB,UAAU;IAKV,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAM7B,OAAO,CAAC,WAAW;IAMZ,MAAM,CAAC,GAAG,EAAE,MAAM;IAIlB,QAAQ,CAAC,GAAG,EAAE,MAAM;IAIpB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAWtB,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB,iBAAiB;IAIjB,SAAS,IAAI,MAAM;CAG7B"}
@@ -1,70 +1,70 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.HexBuffer = void 0;
4
- const ieee754 = require('ieee754'), IntN = require('intn'), intToHex = (intV, isShort) => {
5
- // Creates a new 32-bit integer from the given number
6
- const intSize = isShort ? 16 : 32;
7
- const intNSize = new IntN(intSize);
8
- const byteNum = intNSize.fromInt(intV).bytes;
9
- // Map decimal bytes to hex bytes
10
- // Bytes are already in correct little-endian form
11
- return byteNum.map((Byte) => {
12
- return '0x' + Byte.toString(16);
13
- });
14
- }, charToHex = (character) => {
15
- return '0x' + character.charCodeAt(0).toString(16);
7
+ const ieee754_1 = __importDefault(require("ieee754"));
8
+ const intn_1 = __importDefault(require("intn"));
9
+ const byteToHex = (byte) => ('0x' + byte.toString(16));
10
+ const charToHex = (character) => ('0x' + character.charCodeAt(0).toString(16));
11
+ const intToHex = (intV, size = 32) => {
12
+ const sizedInt = new intn_1.default(size);
13
+ const byteNum = sizedInt.fromInt(intV).bytes;
14
+ return byteNum.map(byteToHex);
16
15
  };
17
16
  class HexBuffer {
18
17
  constructor() {
19
18
  this._buffer = [];
20
19
  }
21
20
  addString(str) {
22
- // Write each char to the buffer
23
- // "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2"
24
- // | "ucs-2" | "base64" | "latin1" | "binary" | "hex"
25
21
  const buf = Buffer.from(str, 'utf-8');
26
- // tslint:disable-next-line: prefer-for-of
27
- for (let i = 0; i < buf.length; i++) {
28
- this._buffer.push('0x' + buf[i].toString(16));
22
+ for (const byte of buf) {
23
+ this._buffer.push(byteToHex(byte));
29
24
  }
30
25
  this.addNullTerminator();
31
26
  }
32
27
  addNewLine() {
33
- this._buffer.push('0x0d'); // carriage return
34
- this._buffer.push('0x0a'); // line feed
28
+ this._buffer.push('0x0d');
29
+ this._buffer.push('0x0a');
35
30
  }
36
31
  addChar(char) {
37
32
  this._buffer.push(charToHex(char));
38
33
  }
39
34
  addChars(chars) {
40
- chars.split('').forEach(char => {
35
+ for (const char of chars.split('')) {
41
36
  this.addChar(char);
42
- });
37
+ }
38
+ }
39
+ addSizedInt(int, size = 32) {
40
+ for (const byte of intToHex(int, size)) {
41
+ this._buffer.push(byte);
42
+ }
43
+ }
44
+ addInt(int) {
45
+ this.addSizedInt(int, 32);
43
46
  }
44
- addInt(int, isShort = false) {
45
- intToHex(int, isShort).forEach((Byte) => {
46
- this._buffer.push(Byte);
47
- });
47
+ addInt24(int) {
48
+ this.addSizedInt(int, 24);
48
49
  }
49
50
  addShort(short) {
50
- this.addInt(short, true);
51
+ this.addSizedInt(short, 16);
51
52
  }
52
53
  addFloat(float) {
53
54
  const buf = Buffer.alloc(4);
54
- // ieee754.write(buffer, value, buffer offset, little-endian, mantissa length, bytes);
55
- ieee754.write(buf, float, 0, true, 23, 4);
56
- buf.forEach((byte) => {
57
- this._buffer.push('0x' + byte.toString(16));
58
- });
55
+ ieee754_1.default.write(buf, float, 0, true, 23, 4);
56
+ for (const byte of buf) {
57
+ this._buffer.push(byteToHex(byte));
58
+ }
59
59
  }
60
60
  addByte(byte) {
61
- this._buffer.push('0x' + byte.toString(16));
61
+ this._buffer.push(byteToHex(byte));
62
62
  }
63
63
  addNullTerminator() {
64
64
  this._buffer.push('0x0');
65
65
  }
66
66
  getBuffer() {
67
- return Buffer.from(this._buffer);
67
+ return Buffer.from(this._buffer.map((s) => parseInt(s)));
68
68
  }
69
69
  }
70
70
  exports.HexBuffer = HexBuffer;
@@ -1 +1 @@
1
- {"version":3,"file":"HexBuffer.js","sourceRoot":"","sources":["../../src/HexBuffer.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,EAC9B,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,EACtB,QAAQ,GAAG,CAAC,IAAY,EAAE,OAAgB,EAAY,EAAE;IACpD,qDAAqD;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAClC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;IAE7C,iCAAiC;IACjC,kDAAkD;IAClD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,OAAO,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACP,CAAC,EACD,SAAS,GAAG,CAAC,SAAiB,EAAU,EAAE;IACtC,OAAO,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAEN,MAAa,SAAS;IAAtB;QACY,YAAO,GAAG,EAAE,CAAC;IA6DzB,CAAC;IA3DU,SAAS,CAAC,GAAW;Q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,QAAQ,CAAC,GAAW;QACvB,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;IAEM,QAAQ,CAAC,KAAa;QACzB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;IAEM,QAAQ,CAAC,KAAa;QACzB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAG5B,iBAAO,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAE1C,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;YACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SACtC;IACL,CAAC;IAEM,OAAO,CAAC,IAAY;QACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC;IAEM,iBAAiB;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAEM,SAAS;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;CACJ;AAlED,8BAkEC"}
@@ -0,0 +1,30 @@
1
+ export type PlayerArray = Player[];
2
+ export declare enum Player {
3
+ Red = "red",
4
+ Blue = "blue",
5
+ Teal = "teal",
6
+ Purple = "purple",
7
+ Yellow = "yellow",
8
+ Orange = "orange",
9
+ Green = "green",
10
+ Pink = "pink",
11
+ Gray = "gray",
12
+ LightBlue = "lightblue",
13
+ DarkGreen = "darkgreen",
14
+ Brown = "brown",
15
+ Maroon = "maroon",
16
+ Navy = "navy",
17
+ Turquoise = "turquoise",
18
+ Violet = "violet",
19
+ Wheat = "wheat",
20
+ Peach = "peach",
21
+ Mint = "mint",
22
+ Lavender = "lavender",
23
+ Coal = "coal",
24
+ Snow = "snow",
25
+ Emerald = "emerald",
26
+ Peanut = "peanut"
27
+ }
28
+ export declare function fromPlayerBitfield(num: number, availablePlayerNums?: number[]): PlayerArray;
29
+ export declare function toPlayerBitfield(playerArray: PlayerArray, availablePlayerNums?: number[]): number;
30
+ //# sourceMappingURL=PlayerBitfield.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlayerBitfield.d.ts","sourceRoot":"","sources":["../../src/PlayerBitfield.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC;AAEnC,oBAAY,MAAM;IACd,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;CACpB;AAID,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,WAAW,CAgB3F;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAajG"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toPlayerBitfield = exports.fromPlayerBitfield = exports.Player = void 0;
4
+ var Player;
5
+ (function (Player) {
6
+ Player["Red"] = "red";
7
+ Player["Blue"] = "blue";
8
+ Player["Teal"] = "teal";
9
+ Player["Purple"] = "purple";
10
+ Player["Yellow"] = "yellow";
11
+ Player["Orange"] = "orange";
12
+ Player["Green"] = "green";
13
+ Player["Pink"] = "pink";
14
+ Player["Gray"] = "gray";
15
+ Player["LightBlue"] = "lightblue";
16
+ Player["DarkGreen"] = "darkgreen";
17
+ Player["Brown"] = "brown";
18
+ Player["Maroon"] = "maroon";
19
+ Player["Navy"] = "navy";
20
+ Player["Turquoise"] = "turquoise";
21
+ Player["Violet"] = "violet";
22
+ Player["Wheat"] = "wheat";
23
+ Player["Peach"] = "peach";
24
+ Player["Mint"] = "mint";
25
+ Player["Lavender"] = "lavender";
26
+ Player["Coal"] = "coal";
27
+ Player["Snow"] = "snow";
28
+ Player["Emerald"] = "emerald";
29
+ Player["Peanut"] = "peanut";
30
+ })(Player = exports.Player || (exports.Player = {}));
31
+ const AllPlayerValues = Object.values(Player);
32
+ function fromPlayerBitfield(num, availablePlayerNums) {
33
+ const players = [];
34
+ if (num === 0)
35
+ return players;
36
+ for (const [idx, playerValue] of AllPlayerValues.entries()) {
37
+ if ((num & (0b1 << idx))
38
+ && (availablePlayerNums ? availablePlayerNums.includes(idx) : true)) {
39
+ players.push(playerValue);
40
+ }
41
+ }
42
+ return players;
43
+ }
44
+ exports.fromPlayerBitfield = fromPlayerBitfield;
45
+ function toPlayerBitfield(playerArray, availablePlayerNums) {
46
+ let num = 0;
47
+ for (const [idx, playerValue] of AllPlayerValues.entries()) {
48
+ if (playerArray.includes(playerValue)
49
+ && (availablePlayerNums ? (availablePlayerNums.includes(idx)) : true)) {
50
+ num |= (0b1 << idx);
51
+ }
52
+ }
53
+ return num;
54
+ }
55
+ exports.toPlayerBitfield = toPlayerBitfield;
56
+ //# sourceMappingURL=PlayerBitfield.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlayerBitfield.js","sourceRoot":"","sources":["../../src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AAG,GAAG,CAAC,CAAC;IAEZ,KAAK,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE;QACxD,IACI,WAAW,CAAC,QAAQ,CAAC,WAAqB,CAAC;eACxC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EACvE;YACE,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;SACvB;KACJ;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAbD,4CAaC"}
@@ -0,0 +1,12 @@
1
+ import { ITranslator } from './CommonInterfaces';
2
+ interface TranslatorMapping {
3
+ name: string;
4
+ displayName: string;
5
+ translator: ITranslator;
6
+ jsonFile: string;
7
+ warFile: string;
8
+ objectType?: string;
9
+ }
10
+ declare const translatorMappings: TranslatorMapping[];
11
+ export default translatorMappings;
12
+ //# sourceMappingURL=TranslatorMappings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TranslatorMappings.d.ts","sourceRoot":"","sources":["../../src/TranslatorMappings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,UAAU,iBAAiB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,QAAA,MAAM,kBAAkB,EAAE,iBAAiB,EAkB1C,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const Translator = __importStar(require("./index"));
27
+ const ObjectType = Translator.ObjectsTranslator.ObjectType;
28
+ const translatorMappings = [
29
+ { name: 'cameras', displayName: 'Cameras', translator: Translator.CamerasTranslator, jsonFile: 'cameras.json', warFile: 'war3map.w3c' },
30
+ { name: 'doodads', displayName: 'Doodads', translator: Translator.DoodadsTranslator, jsonFile: 'doodads.json', warFile: 'war3map.doo' },
31
+ { name: 'imports', displayName: 'Imports', translator: Translator.ImportsTranslator, jsonFile: 'imports.json', warFile: 'war3map.imp' },
32
+ { name: 'info', displayName: 'Info', translator: Translator.InfoTranslator, jsonFile: 'info.json', warFile: 'war3map.w3i' },
33
+ { name: 'regions', displayName: 'Regions', translator: Translator.RegionsTranslator, jsonFile: 'regions.json', warFile: 'war3map.w3r' },
34
+ { name: 'sounds', displayName: 'Sounds', translator: Translator.SoundsTranslator, jsonFile: 'sounds.json', warFile: 'war3map.w3s' },
35
+ { name: 'strings', displayName: 'Strings', translator: Translator.StringsTranslator, jsonFile: 'strings.json', warFile: 'war3map.wts' },
36
+ { name: 'terrain', displayName: 'Terrain', translator: Translator.TerrainTranslator, jsonFile: 'terrain.json', warFile: 'war3map.w3e' },
37
+ { name: 'units', displayName: 'Units', translator: Translator.UnitsTranslator, jsonFile: 'units.json', warFile: 'war3mapUnits.doo' },
38
+ { name: 'objects', displayName: 'Abilities (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-abilities.json', warFile: 'war3map.w3a', objectType: ObjectType.Abilities },
39
+ { name: 'objects', displayName: 'Buffs (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-buffs.json', warFile: 'war3map.w3h', objectType: ObjectType.Buffs },
40
+ { name: 'objects', displayName: 'Destructables (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-destructables.json', warFile: 'war3map.w3b', objectType: ObjectType.Destructables },
41
+ { name: 'objects', displayName: 'Doodads (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-doodads.json', warFile: 'war3map.w3d', objectType: ObjectType.Doodads },
42
+ { name: 'objects', displayName: 'Items (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-items.json', warFile: 'war3map.w3t', objectType: ObjectType.Items },
43
+ { name: 'objects', displayName: 'Units (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-units.json', warFile: 'war3map.w3u', objectType: ObjectType.Units },
44
+ { name: 'objects', displayName: 'Upgrades (Object)', translator: Translator.ObjectsTranslator, jsonFile: 'obj-upgrades.json', warFile: 'war3map.w3q', objectType: ObjectType.Upgrades }
45
+ ];
46
+ exports.default = translatorMappings;
47
+ //# sourceMappingURL=TranslatorMappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TranslatorMappings.js","sourceRoot":"","sources":["../../src/TranslatorMappings.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,oDAAsC;AAWtC,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC,UAAU,CAAC;AAC3D,MAAM,kBAAkB,GAAwB;IAC5C,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,E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,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,UAAU,CAAC,iBAAiB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;CAC1L,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
@@ -1,13 +1,16 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare class W3Buffer {
3
4
  private _offset;
4
5
  private _buffer;
5
6
  constructor(buffer: Buffer);
6
7
  readInt(): number;
8
+ readInt24(): number;
7
9
  readShort(): number;
8
10
  readFloat(): number;
9
11
  readString(): string;
10
- readChars(len?: number): string;
12
+ readChars(len?: number, allowNull?: boolean): string;
13
+ readFourCC(): string;
11
14
  readByte(): number;
12
15
  isExhausted(): boolean;
13
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"W3Buffer.d.ts","sourceRoot":"","sources":["../../src/W3Buffer.ts"],"names":[],"mappings":";AAEA,qBAAa,QAAQ;IAEjB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM;IAInB,OAAO,IAAI,MAAM;IAMjB,SAAS,IAAI,MAAM;IAMnB,SAAS,IAAI,MAAM;IAMnB,UAAU,IAAI,MAAM;IAcpB,SAAS,CAAC,GAAG,GAAE,MAAU,GAAG,MAAM;IAelC,QAAQ;IAOR,WAAW,IAAI,OAAO;CAGhC"}
1
+ {"version":3,"file":"W3Buffer.d.ts","sourceRoot":"","sources":["../../src/W3Buffer.ts"],"names":[],"mappings":";;AAEA,qBAAa,QAAQ;IACjB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM;IAInB,OAAO,IAAI,MAAM;IAMjB,SAAS,IAAI,MAAM;IAMnB,SAAS,IAAI,MAAM;IAMnB,SAAS,IAAI,MAAM;IAMnB,UAAU,IAAI,MAAM;IAcpB,SAAS,CAAC,GAAG,GAAE,MAAU,EAAE,SAAS,GAAE,OAAe,GAAG,MAAM;IAe9D,UAAU,IAAI,MAAM;IAIpB,QAAQ,IAAI,MAAM;IAMlB,WAAW,IAAI,OAAO;CAGhC"}