ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Mon Sep 16, 2019 10:34 pm

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jul 26, 2019 10:14 pm 

Joined: Thu Feb 21, 2019 4:22 pm
Posts: 5
Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?


Attachments:
AllTextEng64.bin [161.91 KiB]
Downloaded 16 times
AllTextEng.bin [137.13 KiB]
Downloaded 13 times
Top
   
PostPosted: Sun Jul 28, 2019 1:58 pm 

Joined: Fri Aug 26, 2016 3:11 pm
Posts: 61
monako wrote:
Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?


Looking at the 32-bit one quickly the format is pretty simple. The layout is
Long (Value is always 1)
Long (File Length)
Long (Record Count)
Long (Size of Entry?)
-- Start Entry Blocks
-- String Data null terminated

For the Entry block
Long ID
Long Offset

This is an example to do the extract with C#, there are around 3.2k entries however only 2.7k unique entries. You'll need to decide how you want to manage all of the text and work with it.

Code:
        private void extractBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog OD = new OpenFileDialog();
            if(OD.ShowDialog() == DialogResult.OK)
            {
                byte[] fileIn = File.ReadAllBytes(OD.FileName);
                MemoryStream ms = new MemoryStream(fileIn);
                BinaryReader br = new BinaryReader(ms);
                List<Entry> entries = new List<Entry>();
                List<string> output = new List<string>();

                br.ReadInt32(); // Version 1?
                br.ReadInt32(); //File length
                int count = br.ReadInt32();
                int blockSize = br.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    entries.Add(new Entry(br.ReadUInt32(), br.ReadInt32()));
                }

                foreach(Entry en in entries)
                {
                    br.BaseStream.Position = en.offset + 8;
                    output.Add(String.Format("{0}\t{1}",en.id, getString(br)));
                }

                File.WriteAllLines(OD.FileName + ".txt", output);
                MessageBox.Show("Done.");
            }
        }

        private string getString(BinaryReader br)
        {
            MemoryStream ms = new MemoryStream();

            byte b = 0xFF;
            while (b != 0)
            {
                b = br.ReadByte();

                if (b != 0)
                    ms.WriteByte(b);
            }

            return Encoding.UTF8.GetString(ms.ToArray());
        }

        class Entry
        {
            public uint id;
            public int offset;

            public Entry(uint id, int offset)
            {
                this.id = id;
                this.offset = offset;
            }
        }


Top
   
PostPosted: Tue Aug 27, 2019 12:46 am 

Joined: Thu Feb 21, 2019 4:22 pm
Posts: 5
LokiReborn wrote:
monako wrote:
Hi guys.
I'd like to decompress the language file and change it to my native language.
So I looked in DataPC\Language folder, I found these files.
AllTextEng.bin and AllTextEng64.bin file.

How do I decompress these files?
and How can I compress it?


Looking at the 32-bit one quickly the format is pretty simple. The layout is
Long (Value is always 1)
Long (File Length)
Long (Record Count)
Long (Size of Entry?)
-- Start Entry Blocks
-- String Data null terminated

For the Entry block
Long ID
Long Offset

This is an example to do the extract with C#, there are around 3.2k entries however only 2.7k unique entries. You'll need to decide how you want to manage all of the text and work with it.

Code:
        private void extractBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog OD = new OpenFileDialog();
            if(OD.ShowDialog() == DialogResult.OK)
            {
                byte[] fileIn = File.ReadAllBytes(OD.FileName);
                MemoryStream ms = new MemoryStream(fileIn);
                BinaryReader br = new BinaryReader(ms);
                List<Entry> entries = new List<Entry>();
                List<string> output = new List<string>();

                br.ReadInt32(); // Version 1?
                br.ReadInt32(); //File length
                int count = br.ReadInt32();
                int blockSize = br.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    entries.Add(new Entry(br.ReadUInt32(), br.ReadInt32()));
                }

                foreach(Entry en in entries)
                {
                    br.BaseStream.Position = en.offset + 8;
                    output.Add(String.Format("{0}\t{1}",en.id, getString(br)));
                }

                File.WriteAllLines(OD.FileName + ".txt", output);
                MessageBox.Show("Done.");
            }
        }

        private string getString(BinaryReader br)
        {
            MemoryStream ms = new MemoryStream();

            byte b = 0xFF;
            while (b != 0)
            {
                b = br.ReadByte();

                if (b != 0)
                    ms.WriteByte(b);
            }

            return Encoding.UTF8.GetString(ms.ToArray());
        }

        class Entry
        {
            public uint id;
            public int offset;

            public Entry(uint id, int offset)
            {
                this.id = id;
                this.offset = offset;
            }
        }

Thank you for your reply. But I'm not a programmer.
so I can't use c# programming.
Can you make me an extractor and input tool? :o


Top
   
PostPosted: Mon Sep 16, 2019 4:05 pm 

Joined: Mon Sep 16, 2019 4:02 pm
Posts: 1
Please can download the .exe application with the file. :(


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited