Ambermoon icon indicating copy to clipboard operation
Ambermoon copied to clipboard

AmbermoonTextImport tool on Linux: scrambles AMB text file?

Open iancrossfield opened this issue 3 years ago • 1 comments

Following up on the thread in https://github.com/Pyrdacor/Ambermoon/pull/25 , but now this seems more like an 'issue' discussion:

On my Ubuntu 20.04 system, the Linux version of AmbermoonTextImport seems to produce a 'scrambled' version of the referenced text file (see details below). First, the incorrect text file rears its head as shown in the following example:

Example :

Successfully Export the original AMB file:

./AmbermoonTextImport -e /path/to/Amberfiles NPC_texts.amb ~/temp/nt2/

Reading texts from sub-file 1 ... done Writing texts to '.../temp/nt2/NPC_texts.amb/001' ... done Reading texts from sub-file 2 ... done Writing texts to '.../temp/nt2/NPC_texts.amb/002' ... done ... [usw.] ... Reading texts from sub-file 70 ... done Writing texts to '.../temp/nt2/NPC_texts.amb/070' ... done

Successfully re-import the exported files:

./AmbermoonTextImport -i path/to/Amberfiles NPC_texts.amb ~/temp/nt2/

Looking for text data in '.../temp/nt2/NPC_texts.amb' ... done Found 454 texts in 70 filled sub-directories. Collecting text data ... done Writing data to '/path/to/Amberfiles/NPC_texts.amb' ... done

But then the second export (to a new directory) fails:

./AmbermoonTextImport -e /path/to/Amberfiles NPC_texts.amb ~/temp/nt3/

Failed to load game data: Index was outside the bounds of the array.

Demonstration that resulting file is 'scrambled':

Opening my new version of NPC_texts.amb and comparing to the original reveals that they contain large bits of the same data , but with these chunks in a different order. Perhaps the two files even have identical contents, but in a different order? They do have the same size, which is curious...

Anyway, this screenshot shows the hex values of the two files side-by-side: portions that should be near the top of the file in the original file (at right) are ~75% of the way down my new version of the file: Screenshot from 2022-02-17 21-46-14

I've also attached the two NPC_texts.amb files (renamed so GitHub accepts the upload) in case that helps track this down. Unfortunately my C# skills are nonexistent and unlikely to improve - thanks to anyone who has any thoughts on this. NPC_texts.amb.mine.txt NPC_texts.amb.original.txt

iancrossfield avatar Feb 18 '22 03:02 iancrossfield

Interesting observation. I will have a closer look. I still wonder how this can be different on Linux in Windows.

Pyrdacor avatar Feb 18 '22 07:02 Pyrdacor