klensy / wt-tools

War Thunder resource extraction tools
128 stars 39 forks source link

[Feature request] Compressing back unpacked .blk files #50

Closed PwaDesu closed 4 years ago

PwaDesu commented 4 years ago

Hey there!

First, let me start by one thing: Thanks for these tools, I've been using them for months and it's made my life so much easier when working with WT's awful modding API.

Here I come with a rather counter-intuitive request (that I've tried to get done by myself but unfortunately python isn't my strong suit): Adding the possibility to repack .blk files that were previously unpacked.

The reason for that is rather simple: Compressed .blk files are much lighter, and I believe they would still work for multiplayer missions (which are currently limited to 512KB, hence why the compression would help oh so very much)

klensy commented 4 years ago

Hi. I don't really know how to conver it back, at least now.

Are you tried to solve 512kb limit other way: for example using import_record thing? ( it's \mis.vromfs.bin\gamedata\missions\cta\historical\bfd\moscow_bfd_norespawn.blkx file, you can find there few more files over 512kb, even over 1mb)

imports{

  import_record{
    file:t="gameData/missions/templates/base_logic_template.blk"
    importAreas:b=yes
    importUnits:b=yes
    importTriggers:b=yes
    importMissionObjectives:b=yes
    importWayPoints:b=yes
    showAreas:b=yes
    showUnits:b=yes
    showTriggers:b=yes
    showMissionObjectives:b=yes
    showWayPoints:b=yes

    excludes{
    }
  }
PwaDesu commented 4 years ago

Yeah, imports are very useful, but unfortunately, as far as custom missions go, they cannot be used in multiplayer (As when creating a new custom battle in-game, you can only provide a direct link to a single .blk file, so imported files won't work - despite gaijin using imports internally. I guess, us, mere players, don't deserve that kind of power)

Do you know of any trick that could help reduce the size maybe? (I'm pretty sure new-lines are mandatory for example, but there could be some patterns that are only for human-readability and can be dropped like blank-lines)

klensy commented 4 years ago

What mission i can try to launch locally?

PwaDesu commented 4 years ago

What do you mean?

klensy commented 4 years ago

I've written simple minimizer, i need to test it on mission locally, as i can't launch multiplayer missions. Test mission works.

PwaDesu commented 4 years ago

you can't launch multiplayer missions?

klensy commented 4 years ago

As i understand, multiplayer mission requires:

  1. The mission should have an initiator (creator of the session). The option of being an initiator will be automatically given to players that purchase any item from the game shop for more than $10. I don't really remember, if i purchased anything.
  2. Multiplayer mission need to be uploaded to LIVE, to play? I've tried to download https://live.warthunder.com/post/890395/en/ and start from user mission, but it wont work (something about user should be owner or smth, i didn't remember).
PwaDesu commented 4 years ago

No you don't need to pay anything, the process to start a custom multiplayer is the following:

The mission i just uploaded is very bare bones but works, so you can try to compress that

klensy commented 4 years ago

Nope, no "missions by url" for me https://wiki.warthunder.com/How_to_launch_a_custom_mission_in_the_game

PwaDesu commented 4 years ago

Oh so that's really a thing... i never noticed... Well, maybe you can run your script on the mission i just uploaded (https://cdn.discordapp.com/attachments/356224772184735756/699683602090295346/middle_east_ffa.blk) and send it back so i can test it

klensy commented 4 years ago

Hmm, can't see this mission when placed to UserMission folder, but ExploreSweden.blk shows in list. middle_east_ffa.min.blk.txt

klensy commented 4 years ago

https://github.com/klensy/wt-tools/suites/597656412/artifacts/4376619 ,will do proper release later.

PwaDesu commented 4 years ago

Alright, so I just tested the minified file you sent in custom multiplayer battles - and it works flawlessly. Pretty good compression ratio too, I cannot thank you enough for that

klensy commented 4 years ago

Yeah, imports are very useful, but unfortunately, as far as custom missions go, they cannot be used in multiplayer (As when creating a new custom battle in-game, you can only provide a direct link to a single .blk file, so imported files won't work - despite gaijin using imports internally. I guess, us, mere players, don't deserve that kind of power)

Do you know of any trick that could help reduce the size maybe? (I'm pretty sure new-lines are mandatory for example, but there could be some patterns that are only for human-readability and can be dropped like blank-lines)

Ah, yes.

  if ("imports" in misblk && "import_record" in misblk.imports)
    err("import_record in imports not supported in user missions")