wc3maptranslator 3.0.3 → 4.0.1

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 (100) hide show
  1. package/.codeclimate.yml +0 -1
  2. package/.eslintignore +0 -1
  3. package/.github/workflows/codeql-analysis.yml +54 -0
  4. package/.nycrc +1 -2
  5. package/.travis.yml +1 -2
  6. package/CHANGELOG.md +78 -0
  7. package/LICENSE.md +23 -0
  8. package/README.md +68 -75
  9. package/index.js +11 -15
  10. package/index.ts +12 -30
  11. package/lib/CommonInterfaces.ts +22 -0
  12. package/lib/HexBuffer.ts +11 -14
  13. package/lib/W3Buffer.ts +7 -3
  14. package/lib/translators/CamerasTranslator.ts +36 -41
  15. package/lib/translators/DoodadsTranslator.ts +57 -55
  16. package/lib/translators/ImportsTranslator.ts +29 -31
  17. package/lib/translators/InfoTranslator.ts +252 -204
  18. package/lib/translators/{object/ObjectsTranslator.ts → ObjectsTranslator.ts} +84 -82
  19. package/lib/translators/RegionsTranslator.ts +40 -58
  20. package/lib/translators/SoundsTranslator.ts +112 -96
  21. package/lib/translators/StringsTranslator.ts +23 -49
  22. package/lib/translators/TerrainTranslator.ts +166 -97
  23. package/lib/translators/UnitsTranslator.ts +98 -97
  24. package/lib/translators/index.ts +0 -1
  25. package/package.json +23 -16
  26. package/test/.mocharc.json +4 -0
  27. package/test/HexBufferTest.ts +11 -15
  28. package/test/TranslatorReversion.ts +104 -115
  29. package/test/W3BufferTest.ts +19 -13
  30. package/test/data/cameras.json +16 -0
  31. package/test/data/doodads.json +2730 -0
  32. package/test/data/imports.json +386 -0
  33. package/test/data/info.json +250 -0
  34. package/test/data/obj-abilities.json +4892 -0
  35. package/test/data/obj-buffs.json +38 -0
  36. package/test/data/obj-destructables.json +31 -0
  37. package/test/data/obj-doodads.json +38 -0
  38. package/test/data/obj-items.json +31 -0
  39. package/test/data/obj-units.json +40 -0
  40. package/test/data/obj-upgrades.json +38 -0
  41. package/test/data/regions.json +206 -0
  42. package/test/data/sounds.json +50 -0
  43. package/test/data/strings.json +115 -0
  44. package/test/data/terrain.json +1 -0
  45. package/test/data/units.json +452 -0
  46. package/test/data/war3map.doo +0 -0
  47. package/test/data/war3map.imp +0 -0
  48. package/test/data/war3map.j +3442 -0
  49. package/test/data/war3map.shd +0 -0
  50. package/test/data/war3map.w3a +0 -0
  51. package/test/data/war3map.w3b +0 -0
  52. package/test/data/war3map.w3c +0 -0
  53. package/test/data/war3map.w3d +0 -0
  54. package/test/data/war3map.w3e +0 -0
  55. package/test/data/war3map.w3h +0 -0
  56. package/test/data/war3map.w3i +0 -0
  57. package/test/data/war3map.w3q +0 -0
  58. package/test/data/war3map.w3r +0 -0
  59. package/test/data/war3map.w3s +0 -0
  60. package/test/data/war3map.w3t +0 -0
  61. package/test/data/war3map.w3u +0 -0
  62. package/test/data/war3map.wts +631 -0
  63. package/test/data/war3mapUnits.doo +0 -0
  64. package/examples/index.js +0 -123
  65. package/examples/index.ts +0 -134
  66. package/examples/json/cameras.json +0 -16
  67. package/examples/json/doodads.json +0 -28499
  68. package/examples/json/imports.json +0 -10
  69. package/examples/json/info.json +0 -111
  70. package/examples/json/object-abilities.json +0 -31
  71. package/examples/json/object-buffs.json +0 -24
  72. package/examples/json/object-destructables.json +0 -31
  73. package/examples/json/object-doodads.json +0 -24
  74. package/examples/json/object-items.json +0 -45
  75. package/examples/json/object-units.json +0 -45
  76. package/examples/json/object-upgrades.json +0 -31
  77. package/examples/json/regions.json +0 -36
  78. package/examples/json/sounds.json +0 -46
  79. package/examples/json/strings.json +0 -83
  80. package/examples/json/terrain.json +0 -46633
  81. package/examples/json/units.json +0 -332
  82. package/examples/package.json +0 -17
  83. package/examples/tsconfig.json +0 -27
  84. package/examples/war/war3map.doo +0 -0
  85. package/examples/war/war3map.imp +0 -0
  86. package/examples/war/war3map.w3a +0 -0
  87. package/examples/war/war3map.w3b +0 -0
  88. package/examples/war/war3map.w3c +0 -0
  89. package/examples/war/war3map.w3d +0 -0
  90. package/examples/war/war3map.w3e +0 -0
  91. package/examples/war/war3map.w3h +0 -0
  92. package/examples/war/war3map.w3i +0 -0
  93. package/examples/war/war3map.w3q +0 -0
  94. package/examples/war/war3map.w3r +0 -0
  95. package/examples/war/war3map.w3s +0 -0
  96. package/examples/war/war3map.w3t +0 -0
  97. package/examples/war/war3map.w3u +0 -0
  98. package/examples/war/war3map.wts +0 -99
  99. package/lib/translators/index.js +0 -16
  100. package/test/mocha.opts +0 -4
@@ -1,5 +1,6 @@
1
- import { HexBuffer } from '../../HexBuffer';
2
- import { W3Buffer } from '../../W3Buffer';
1
+ import { HexBuffer } from '../HexBuffer';
2
+ import { W3Buffer } from '../W3Buffer';
3
+ import { WarResult, JsonResult } from '../CommonInterfaces'
3
4
 
4
5
  enum TableType {
5
6
  original = 'original',
@@ -13,6 +14,26 @@ enum ModificationType {
13
14
  string = 'string'
14
15
  }
15
16
 
17
+ enum FileTypeExtension { // (*) - uses the two optional ints after variable type
18
+ units = 'w3u',
19
+ items = 'w3t',
20
+ destructables = 'w3b',
21
+ doodads = 'w3d', // (*)
22
+ abilities = 'w3a', // (*)
23
+ buffs = 'w3h',
24
+ upgrades = 'w3q' // (*)
25
+ };
26
+
27
+ enum ObjectType {
28
+ Units = 'units',
29
+ Items = 'items',
30
+ Destructables = 'destructables',
31
+ Doodads = 'doodads',
32
+ Abilities = 'abilities',
33
+ Buffs = 'buffs',
34
+ Upgrades = 'upgrades'
35
+ };
36
+
16
37
  interface Modification {
17
38
  id: string;
18
39
  type: ModificationType; // 'int' | 'real' | 'unreal' | 'string',
@@ -26,54 +47,36 @@ interface Modification {
26
47
  variation?: number;
27
48
  }
28
49
 
29
- export class ObjectsTranslator {
50
+ interface ObjectModificationTable {
51
+ original: object,
52
+ custom: object
53
+ }
30
54
 
31
- public ObjectType = {
32
- Units: 'units',
33
- Items: 'items',
34
- Destructables: 'destructables',
35
- Doodads: 'doodads',
36
- Abilities: 'abilities',
37
- Buffs: 'buffs',
38
- Upgrades: 'upgrades'
55
+ export abstract class ObjectsTranslator {
56
+
57
+ // Expose the ObjectType enum as part of this abstract class
58
+ // The enum could be "export"ed , but it wouldn't be accessible
59
+ // via `ObjectsTranslator.ObjectType`, which is preferable.
60
+ public static readonly ObjectType = ObjectType;
61
+
62
+ private static varTypes = {
63
+ int: 0,
64
+ real: 1,
65
+ unreal: 2,
66
+ string: 3,
67
+ 0: 'int',
68
+ 1: 'real',
69
+ 2: 'unreal',
70
+ 3: 'string'
39
71
  };
40
72
 
41
- public varTypes: any;
42
- public fileTypeExt: any;
43
-
44
- private _outBufferToWar: HexBuffer;
45
- private _outBufferToJSON: W3Buffer;
46
-
47
- constructor() {
48
- this.varTypes = {
49
- int: 0,
50
- real: 1,
51
- unreal: 2,
52
- string: 3,
53
- 0: 'int',
54
- 1: 'real',
55
- 2: 'unreal',
56
- 3: 'string'
57
- };
58
-
59
- this.fileTypeExt = { // (*) - uses the two optional ints after variable type
60
- units: 'w3u',
61
- items: 'w3t',
62
- destructables: 'w3b',
63
- doodads: 'w3d', // (*)
64
- abilities: 'w3a', // (*)
65
- buffs: 'w3h',
66
- upgrades: 'w3q' // (*)
67
- };
68
- }
69
-
70
- public jsonToWar(type: string, json) {
71
- this._outBufferToWar = new HexBuffer();
73
+ public static jsonToWar(type: string, json): WarResult {
74
+ const outBufferToWar = new HexBuffer();
72
75
 
73
76
  /*
74
77
  * Header
75
78
  */
76
- this._outBufferToWar.addInt(2); // file version
79
+ outBufferToWar.addInt(2); // file version
77
80
 
78
81
  const generateTableFromJson = (tableType: TableType, tableData) => { // create "original" or "custom" table
79
82
  Object.keys(tableData).forEach((defKey) => {
@@ -81,22 +84,22 @@ export class ObjectsTranslator {
81
84
 
82
85
  // Original and new object ids
83
86
  if (tableType === TableType.original) {
84
- this._outBufferToWar.addString(defKey);
85
- this._outBufferToWar.addByte(0); this._outBufferToWar.addByte(0); this._outBufferToWar.addByte(0); this._outBufferToWar.addByte(0); // no new Id is assigned
87
+ outBufferToWar.addChars(defKey);
88
+ outBufferToWar.addByte(0); outBufferToWar.addByte(0); outBufferToWar.addByte(0); outBufferToWar.addByte(0); // no new Id is assigned
86
89
  } else {
87
90
  // e.g. "h000:hfoo"
88
- this._outBufferToWar.addString(defKey.substring(5, 9)); // original id
89
- this._outBufferToWar.addString(defKey.substring(0, 4)); // custom id
91
+ outBufferToWar.addChars(defKey.substring(5, 9)); // original id
92
+ outBufferToWar.addChars(defKey.substring(0, 4)); // custom id
90
93
  }
91
94
 
92
95
  // Number of modifications made to this object
93
- this._outBufferToWar.addInt(obj.length);
96
+ outBufferToWar.addInt(obj.length);
94
97
 
95
98
  obj.forEach((mod: Modification) => {
96
99
  let modType;
97
100
 
98
101
  // Modification id (e.g. unam = name; reference MetaData lookups)
99
- this._outBufferToWar.addString(mod.id);
102
+ outBufferToWar.addChars(mod.id);
100
103
 
101
104
  // Determine what type of field the mod is (int, real, unreal, string)
102
105
  if (mod.type) { // if a type is specified, use it
@@ -111,43 +114,42 @@ export class ObjectsTranslator {
111
114
  }
112
115
  }
113
116
 
114
- this._outBufferToWar.addInt(modType);
117
+ outBufferToWar.addInt(modType);
115
118
 
116
119
  // Addl integers
117
120
  // Required for: doodads, abilities, upgrades
118
- if (type === this.ObjectType.Doodads || type === this.ObjectType.Abilities || type === this.ObjectType.Upgrades) {
121
+ if (type === ObjectType.Doodads || type === ObjectType.Abilities || type === ObjectType.Upgrades) {
119
122
 
120
123
  // Level or variation
121
124
  // We need to check if hasOwnProperty because these could be explititly
122
125
  // set to 0, but JavaScript's truthiness evaluates to false to it was defaulting
123
- this._outBufferToWar.addInt(mod.level || mod.variation || 0); // defaults to 0
126
+ outBufferToWar.addInt(mod.level || mod.variation || 0); // defaults to 0
124
127
 
125
- this._outBufferToWar.addInt(mod.column || 0); // E.g DataA1 is 1 because of col A; refer to the xyzData.slk files for Data fields
128
+ outBufferToWar.addInt(mod.column || 0); // E.g DataA1 is 1 because of col A; refer to the xyzData.slk files for Data fields
126
129
  }
127
130
 
128
131
  // Write mod value
129
132
  if (modType === this.varTypes.int) {
130
- this._outBufferToWar.addInt(mod.value);
133
+ outBufferToWar.addInt(mod.value);
131
134
  } else if (modType === this.varTypes.real || modType === this.varTypes.unreal) {
132
135
  // Follow-up: check if unreal values are same hex format as real
133
- this._outBufferToWar.addFloat(mod.value);
136
+ outBufferToWar.addFloat(mod.value);
134
137
  } else if (modType === this.varTypes.string) {
135
138
  // Note that World Editor normally creates a TRIGSTR_000 for these string
136
139
  // values - WC3MapTranslator just writes the string directly to file
137
- this._outBufferToWar.addString(mod.value);
138
- this._outBufferToWar.addNullTerminator();
140
+ outBufferToWar.addString(mod.value);
139
141
  }
140
142
 
141
143
  // End of struct
142
144
  if (tableType === TableType.original) {
143
145
  // Original objects are ended with their base id (e.g. hfoo)
144
- this._outBufferToWar.addString(defKey);
146
+ outBufferToWar.addChars(defKey);
145
147
  } else {
146
148
  // Custom objects are ended with 0000 bytes
147
- this._outBufferToWar.addByte(0);
148
- this._outBufferToWar.addByte(0);
149
- this._outBufferToWar.addByte(0);
150
- this._outBufferToWar.addByte(0);
149
+ outBufferToWar.addByte(0);
150
+ outBufferToWar.addByte(0);
151
+ outBufferToWar.addByte(0);
152
+ outBufferToWar.addByte(0);
151
153
  }
152
154
  });
153
155
  });
@@ -156,36 +158,36 @@ export class ObjectsTranslator {
156
158
  /*
157
159
  * Original table
158
160
  */
159
- this._outBufferToWar.addInt(Object.keys(json.original).length);
161
+ outBufferToWar.addInt(Object.keys(json.original).length);
160
162
  generateTableFromJson(TableType.original, json.original);
161
163
 
162
164
  /*
163
165
  * Custom table
164
166
  */
165
- this._outBufferToWar.addInt(Object.keys(json.custom).length); // # entry modifications
167
+ outBufferToWar.addInt(Object.keys(json.custom).length); // # entry modifications
166
168
  generateTableFromJson(TableType.custom, json.custom);
167
169
 
168
170
  return {
169
171
  errors: [],
170
- buffer: this._outBufferToWar.getBuffer()
172
+ buffer: outBufferToWar.getBuffer()
171
173
  };
172
174
  }
173
175
 
174
- public warToJson(type: string, buffer: Buffer) {
176
+ public static warToJson(type: string, buffer: Buffer): JsonResult<ObjectModificationTable> {
175
177
  const result = { original: {}, custom: {} };
176
- this._outBufferToJSON = new W3Buffer(buffer);
178
+ const outBufferToJSON = new W3Buffer(buffer);
177
179
 
178
- const fileVersion = this._outBufferToJSON.readInt();
180
+ const fileVersion = outBufferToJSON.readInt();
179
181
 
180
182
  const readModificationTable = (isOriginalTable: boolean) => {
181
- const numTableModifications = this._outBufferToJSON.readInt();
183
+ const numTableModifications = outBufferToJSON.readInt();
182
184
 
183
185
  for (let i = 0; i < numTableModifications; i++) {
184
186
  const objectDefinition = []; // object definition will store one or more modification objects
185
187
 
186
- const originalId = this._outBufferToJSON.readChars(4),
187
- customId = this._outBufferToJSON.readChars(4),
188
- modificationCount = this._outBufferToJSON.readInt();
188
+ const originalId = outBufferToJSON.readChars(4),
189
+ customId = outBufferToJSON.readChars(4),
190
+ modificationCount = outBufferToJSON.readInt();
189
191
 
190
192
  for (let j = 0; j < modificationCount; j++) {
191
193
  const modification: Modification = {
@@ -196,26 +198,26 @@ export class ObjectsTranslator {
196
198
  value: {}
197
199
  };
198
200
 
199
- modification.id = this._outBufferToJSON.readChars(4);
200
- modification.type = this.varTypes[this._outBufferToJSON.readInt()]; // 'int' | 'real' | 'unreal' | 'string',
201
+ modification.id = outBufferToJSON.readChars(4);
202
+ modification.type = this.varTypes[outBufferToJSON.readInt()]; // 'int' | 'real' | 'unreal' | 'string',
201
203
 
202
- if (type === this.ObjectType.Doodads || type === this.ObjectType.Abilities || type === this.ObjectType.Upgrades) {
203
- modification.level = this._outBufferToJSON.readInt();
204
- modification.column = this._outBufferToJSON.readInt();
204
+ if (type === ObjectType.Doodads || type === ObjectType.Abilities || type === ObjectType.Upgrades) {
205
+ modification.level = outBufferToJSON.readInt();
206
+ modification.column = outBufferToJSON.readInt();
205
207
  }
206
208
 
207
209
  if (modification.type === 'int') {
208
- modification.value = this._outBufferToJSON.readInt();
210
+ modification.value = outBufferToJSON.readInt();
209
211
  } else if (modification.type === 'real' || modification.type === 'unreal') {
210
- modification.value = this._outBufferToJSON.readFloat();
212
+ modification.value = outBufferToJSON.readFloat();
211
213
  } else { // modification.type === 'string'
212
- modification.value = this._outBufferToJSON.readString();
214
+ modification.value = outBufferToJSON.readString();
213
215
  }
214
216
 
215
217
  if (isOriginalTable) {
216
- this._outBufferToJSON.readInt(); // should be 0 for original objects
218
+ outBufferToJSON.readInt(); // should be 0 for original objects
217
219
  } else {
218
- this._outBufferToJSON.readChars(4); // should be object ID for custom objects
220
+ outBufferToJSON.readChars(4); // should be object ID for custom objects
219
221
  }
220
222
 
221
223
  objectDefinition.push(modification);
@@ -1,5 +1,6 @@
1
1
  import { HexBuffer } from '../HexBuffer';
2
2
  import { W3Buffer } from '../W3Buffer';
3
+ import { WarResult, JsonResult } from '../CommonInterfaces'
3
4
 
4
5
  interface Region {
5
6
  position: Rect;
@@ -17,21 +18,16 @@ interface Rect {
17
18
  top: number;
18
19
  }
19
20
 
20
- export class RegionsTranslator {
21
+ export abstract class RegionsTranslator {
21
22
 
22
- private _outBufferToWar: HexBuffer;
23
- private _outBufferToJSON: W3Buffer;
24
-
25
- constructor() { }
26
-
27
- public jsonToWar(regionsJson: Region[]) {
28
- this._outBufferToWar = new HexBuffer();
23
+ public static jsonToWar(regionsJson: Region[]): WarResult {
24
+ const outBufferToWar = new HexBuffer();
29
25
 
30
26
  /*
31
27
  * Header
32
28
  */
33
- this._outBufferToWar.addInt(5); // file version
34
- this._outBufferToWar.addInt(regionsJson.length); // number of regions
29
+ outBufferToWar.addInt(5); // file version
30
+ outBufferToWar.addInt(regionsJson.length); // number of regions
35
31
 
36
32
  /*
37
33
  * Body
@@ -39,59 +35,51 @@ export class RegionsTranslator {
39
35
  regionsJson.forEach((region) => {
40
36
  // Position
41
37
  // Note that the .w3x guide has these coords wrong - the guide swaps bottom and right, but this is incorrect; bottom should be written before right
42
- this._outBufferToWar.addFloat(region.position.left);
43
- this._outBufferToWar.addFloat(region.position.bottom);
44
- this._outBufferToWar.addFloat(region.position.right);
45
- this._outBufferToWar.addFloat(region.position.top);
38
+ outBufferToWar.addFloat(region.position.left);
39
+ outBufferToWar.addFloat(region.position.bottom);
40
+ outBufferToWar.addFloat(region.position.right);
41
+ outBufferToWar.addFloat(region.position.top);
46
42
 
47
- // Region name - must be null terminated
48
- this._outBufferToWar.addString(region.name);
49
- this._outBufferToWar.addNullTerminator();
50
-
51
- // Region id
52
- this._outBufferToWar.addInt(region.id);
43
+ outBufferToWar.addString(region.name);
44
+ outBufferToWar.addInt(region.id);
53
45
 
54
46
  // Weather effect name - lookup necessary: char[4]
55
47
  if (region.weatherEffect) {
56
- this._outBufferToWar.addString(region.weatherEffect);
48
+ outBufferToWar.addChars(region.weatherEffect); // Weather effect is optional - defaults to 0000 for "none"
57
49
  } else {
58
- // Weather effect is optional - defaults to 0000 for "none"
59
- this._outBufferToWar.addBytes([0, 0, 0, 0]);
50
+ // We can't put a string "0000", because ASCII 0's differ from 0x0 bytes
51
+ outBufferToWar.addByte(0);
52
+ outBufferToWar.addByte(0);
53
+ outBufferToWar.addByte(0);
54
+ outBufferToWar.addByte(0);
60
55
  }
61
56
 
62
57
  // Ambient sound - refer to names defined in .w3s file
63
- this._outBufferToWar.addString(region.ambientSound || ''); // May be empty string
64
- this._outBufferToWar.addNullTerminator();
58
+ outBufferToWar.addString(region.ambientSound || ''); // May be empty string
65
59
 
66
60
  // Color of region used by editor
67
61
  // Careful! The order in .w3r is BB GG RR, whereas the JSON spec order is [RR, GG, BB]
68
- if (!region.color || region.color.length !== 3) {
69
- this._outBufferToWar.addByte(0); // blue
70
- this._outBufferToWar.addByte(0); // green
71
- this._outBufferToWar.addByte(0); // red
72
- } else {
73
- this._outBufferToWar.addByte(region.color[2]); // blue
74
- this._outBufferToWar.addByte(region.color[1]); // green
75
- this._outBufferToWar.addByte(region.color[0]); // red
76
- }
62
+ outBufferToWar.addByte(region.color[2]); // blue
63
+ outBufferToWar.addByte(region.color[1]); // green
64
+ outBufferToWar.addByte(region.color[0]); // red
77
65
 
78
66
  // End of structure - for some reason the .w3r needs this here;
79
67
  // Value is set to 0xff based on observing the .w3r file, but not sure if it could be something else
80
- this._outBufferToWar.addByte(0xff);
68
+ outBufferToWar.addByte(0xff);
81
69
  });
82
70
 
83
71
  return {
84
72
  errors: [],
85
- buffer: this._outBufferToWar.getBuffer()
73
+ buffer: outBufferToWar.getBuffer()
86
74
  };
87
75
  }
88
76
 
89
- public warToJson(buffer: Buffer) {
77
+ public static warToJson(buffer: Buffer): JsonResult<Region[]> {
90
78
  const result = [];
91
- this._outBufferToJSON = new W3Buffer(buffer);
79
+ const outBufferToJSON = new W3Buffer(buffer);
92
80
 
93
- const fileVersion = this._outBufferToJSON.readInt(), // File version
94
- numRegions = this._outBufferToJSON.readInt(); // # of regions
81
+ const fileVersion = outBufferToJSON.readInt(), // File version
82
+ numRegions = outBufferToJSON.readInt(); // # of regions
95
83
 
96
84
  for (let i = 0; i < numRegions; i++) {
97
85
  const region: Region = {
@@ -108,27 +96,21 @@ export class RegionsTranslator {
108
96
  }
109
97
  };
110
98
 
111
- region.position.left = this._outBufferToJSON.readFloat();
112
- region.position.bottom = this._outBufferToJSON.readFloat();
113
- region.position.right = this._outBufferToJSON.readFloat();
114
- region.position.top = this._outBufferToJSON.readFloat();
115
- region.name = this._outBufferToJSON.readString();
116
- region.id = this._outBufferToJSON.readInt();
117
-
118
- // Weather effect is specified by 4 characters (e.g. MEds is Dalaran Shield)
119
- // war3map uses "0000" as literal characters to indicate no weather effect, but
120
- // for the JSON format we use an empty string for this purpose, hence the check
121
- region.weatherEffect = this._outBufferToJSON.readChars(4);
122
- if (region.weatherEffect === '0000') region.weatherEffect = '';
123
-
124
- region.ambientSound = this._outBufferToJSON.readString();
99
+ region.position.left = outBufferToJSON.readFloat();
100
+ region.position.bottom = outBufferToJSON.readFloat();
101
+ region.position.right = outBufferToJSON.readFloat();
102
+ region.position.top = outBufferToJSON.readFloat();
103
+ region.name = outBufferToJSON.readString();
104
+ region.id = outBufferToJSON.readInt();
105
+ region.weatherEffect = outBufferToJSON.readChars(4);
106
+ region.ambientSound = outBufferToJSON.readString();
125
107
  region.color = [
126
- this._outBufferToJSON.readByte(), // red
127
- this._outBufferToJSON.readByte(), // green
128
- this._outBufferToJSON.readByte() // blue
108
+ outBufferToJSON.readByte(), // red
109
+ outBufferToJSON.readByte(), // green
110
+ outBufferToJSON.readByte() // blue
129
111
  ];
130
112
  region.color.reverse(); // json wants it in RGB, but .w3r file stores it as BB GG RR
131
- this._outBufferToJSON.readByte(); // end of region structure
113
+ outBufferToJSON.readByte(); // end of region structure
132
114
 
133
115
  result.push(region);
134
116
  }