Closed Luashine closed 2 years ago
Hi @Luashine, thanks for the details and sorry that it's not working! I'll be able to take a look this upcoming weekend.
I am able to replicate this issue with the RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 735. Received 736
error.
It looks like from the .w3i
file you provided, you're using a Pre-Reforged data format (version 25 instead of the latest version 31). WC3MapTranslator will be trying to translate this file as if it version 31. Because there were a number of fields added, this will mess up the parsing of older files.
You have a few options:
.w3i
file from in World Editor, and then save the map. World Editor will handle the data format upgrade for you, so the .w3i
will be in the latest format. Then use that file.npm install --save wc3maptranslator@3.0.2
, which was the most recent version to translate Info 25 files.
V3 has different syntax for translators:
const wc3maptranslator = new wc3.Translator() const translatedJson = wc3maptranslator.Info.warToJson(w3infoData).json
I think the first option is better, because WC3MapTranslator v4 saw some nice improvements to the organization of the translators and the code you'd use to import them and use them. As you can see in the code snippet above, WC3MapTranslator@3.0.2 is a little uglier and more confusing to use.
However, I was able to translate the info file:
{
map: {
name: 'TRIGSTR_014',
author: 'TRIGSTR_017',
description: 'TRIGSTR_016',
recommendedPlayers: 'TRIGSTR_015',
playableArea: { width: 244, height: 244 },
mainTileType: 'V',
flags: {
hideMinimapInPreview: false,
modifyAllyPriorities: false,
isMeleeMap: false,
maskedPartiallyVisible: true,
fixedPlayerSetting: false,
useCustomForces: false,
useCustomTechtree: false,
useCustomAbilities: false,
useCustomUpgrades: false,
waterWavesOnCliffShores: true,
waterWavesOnRollingShores: true
}
},
loadingScreen: { background: -1, path: '', text: '', title: '', subtitle: '' },
prologue: { path: '', text: '', title: '', subtitle: '' },
fog: {
type: 0,
startHeight: 3000,
endHeight: 5000,
density: 0.5,
color: [ 0, 0, 0, 255 ]
},
camera: {
bounds: [
-15104, -15616,
15104, 15104,
-15104, 15104,
15104, -15616
],
complements: [ 6, 6, 4, 8 ]
},
players: [
{
name: 'TRIGSTR_001',
startingPos: [Object],
playerNum: 0,
type: 1,
race: 1
},
{
name: 'TRIGSTR_002',
startingPos: [Object],
playerNum: 1,
type: 1,
race: 1
},
{
name: 'TRIGSTR_003',
startingPos: [Object],
playerNum: 2,
type: 2,
race: 1
},
{
name: 'TRIGSTR_004',
startingPos: [Object],
playerNum: 3,
type: 2,
race: 1
},
{
name: 'TRIGSTR_005',
startingPos: [Object],
playerNum: 4,
type: 2,
race: 1
},
{
name: 'TRIGSTR_006',
startingPos: [Object],
playerNum: 5,
type: 2,
race: 1
},
{
name: 'TRIGSTR_007',
startingPos: [Object],
playerNum: 6,
type: 2,
race: 1
},
{
name: 'TRIGSTR_008',
startingPos: [Object],
playerNum: 7,
type: 2,
race: 1
},
{
name: 'TRIGSTR_009',
startingPos: [Object],
playerNum: 8,
type: 2,
race: 1
},
{
name: 'TRIGSTR_010',
startingPos: [Object],
playerNum: 9,
type: 2,
race: 1
},
{
name: 'TRIGSTR_011',
startingPos: [Object],
playerNum: 10,
type: 2,
race: 1
},
{
name: 'TRIGSTR_012',
startingPos: [Object],
playerNum: 11,
type: 2,
race: 1
}
],
forces: [ { flags: [Object], players: -1, name: 'TRIGSTR_013' } ],
saves: 10,
editorVersion: 6059,
globalWeather: '0000',
customSoundEnvironment: '',
customLightEnv: '0',
water: [ 255, 255, 255, 255 ]
}
Let me know how either of these options go and if you encounter any more issues.
Thanks for the explanation, I thought old versions to be supported. In this case I really want and need to tinker with the 1.26 file. I will find another way then or use the older version as you suggested. :+1:
Using an older version is the way to go for now.
There is #65 for adding older file versions to the translators, which I can reconsider supporting. I'll think about the level of effort to build that functionality.
I wanted to convert a war3map.w3i (made in v1.26) to JSON to experiment with it. I have no idea how to use the library, so I came up with this by following the included tests:
Looks like an off-by-one error? thats hopefully not related to my code:
I installed the library from npm: version 4.0.0. The .w3i file is attached within zip: war3info.zip