kotiq / wt-tools

War Thunder resource extraction tools
29 stars 3 forks source link

How to pack files into vromfs.bin? #8

Open tommyZZM opened 2 years ago

tommyZZM commented 2 years ago

https://github.com/Keksilton/WtTools/issues/2

kotiq commented 2 years ago

What is the purpose of using repackaged archives? Can you bypass resource validation?

For me there is a problem with the file format of the shared names and strings. I don't know what algorithm calculates the short hash at its very beginning. Thus, I cannot create a correct nm file.

The second problem is that I don't know how the 256-byte remainder is generated for the archive.

You can see a draft of the image and archive packaging tool here vromfs.bin.BinFile.pack vromfs.vromfs.VromfsFile.pack

tommyZZM commented 2 years ago

What is the purpose of using repackaged archives? Can you bypass resource validation?

https://enlisted-sandbox.gaijin.net/feed/gamemod/

20220612091920

Since Enlisted allows players to upload maps in vromfs.bin format, these custom maps can be played with other players.

But yet we don't know how to package this format, in some of the easiest ways

kotiq commented 2 years ago

Fine. What files are to be packaged? If the blk files are self-contained (which have no shared strings or names), I think it is possible. Can you send me a link to an archive with sample files for packaging? I will try to write a simple CLI for standalone files.

kotiq commented 2 years ago

I added a branch with a packer to the vromfs project.

# ... cd vromfs; git pull
$ git checkout packer
$ pip install .

The directory /tmp/files containing the files to be packed. The directory itself is not packaged and is only for listing files.

$ tree -s --metafirst /tmp/files
[         80]  /tmp/files
[         60]  ├── inner
[       1061]  │   └── fstab
[        106]  └── lsb-release

Creating the archive /tmp/out.vromfs.bin with version 1.2.3.4 from the aforementioned directory

$ vromfs_bin_packer.py -v 1.2.3.4 -o /tmp/out.vromfs.bin /tmp/files
1655019014.6393943 DEBUG /tmp/files => temp vromfs
1655019014.6394637 DEBUG Размер временного образа: 1296
1655019014.640162 DEBUG temp vromfs => /tmp/out.vromfs.bin
1655019014.640218 INFO /tmp/files => /tmp/out.vromfs.bin

The resulting file.

$ ls -l /tmp/out.vromfs.bin 
-rw-r--r-- 1 kotiq kotiq 776 Jun 12 13:30 /tmp/out.vromfs.bin

Summary of contents.

$ vromfs_bin_unpacker.py --metadata /tmp/out.vromfs.bin | python -m json.tool
{
    "version": "1.1",
    "filelist": {
        "inner/fstab": "a0940cb3f3298ae0cb9ba0a30e05e678e7f8c6f2",
        "lsb-release": "792f608be04167807db067707a31a656aa687d0f"
    }
}
tommyZZM commented 2 years ago

What files are to be packaged

Thanks a lot, I will try packing.

There is only one scene.blk file known so far, which is a plain text with no encoding and can be executed by the game.

The directory structure of other files is not yet clear, perhaps some other plain text blk files and svg icons. Not sure if vromfs.bin can be loaded by the current game version.

Since the development team has not provided a clear example of this, everything is still being explored.

https://forum.enlisted.net/t/answering-your-questions-about-the-mission-editor-1/55849

image

kotiq commented 2 years ago

I hope you don't have to translate the control text blk files into binary blk.

tommyZZM commented 2 years ago

I hope you don't have to translate the control text blk files into binary blk.

I'm guessing that it probably doesn't need to become binary, since the current blk works in plain text

tommyZZM commented 2 years ago

Recently Enlisted opened up the ability for gamers to upload vromfs.

After my actual use, the MOD scene of vromfs generated by this packer tool can indeed be correctly recognized by the game program, and can also run in the server-side multiplayer game.

Many thanks❤️

kotiq commented 1 year ago

Glad to hear that the archive is working in a real environment.

Avarik commented 1 year ago

By any chance, is there a possibility for this to work in War Thunder if you host the vromfs file as a target link for a custom mission lobby? 🤔 I'm thinking, if the validation for a .vromfs file requires the file to match the folder construction of the game, that it might be possible to use it as a target for a mission link, so long that it contains a mission.blk file and whatever other user assets that were included, each in their respective and correct location. (E.G, a model resource file will go to content/pkg_local/res/pkg_local_, and a tank unit file to content/pkg_local/gameData/units/tankModels)