christorrella / mhpf-tools

package tools for the Melbourne House Pack File file format (.PCK)
GNU General Public License v3.0
3 stars 1 forks source link

String hash function #2

Open CookiePLMonster opened 2 years ago

CookiePLMonster commented 2 years ago

The string hash function has now been reverse engineered and implemented in TDUModTools: https://github.com/CookiePLMonster/TDUModTools/blob/main/mhpf.py#L213

It's essentially the simplest string hashing algorithm where for each character hash = (hash * 31) + character is computed, with the addition of normalizing paths and making the string lowercase.

That "unknown 31 value" is in fact the prime used for this hash - but there is very little to no reason to ever change it.

christorrella commented 2 years ago

If I remember correctly, The game refuses to load if that hash doesn't match the file in the archive.

CookiePLMonster commented 2 years ago

Yes, because those hashes are used for binary search with the game looks up files. With this they can now be recalculated.

christorrella commented 2 years ago

Very nice! Assuming you've successfully got this working, congratulations and kudos.

CookiePLMonster commented 2 years ago

Yup, it works properly and generates archives 1:1 to the original, with the exception of the file order - they've been manually ordered to optimize load times, or at least that's what it looks like.

christorrella commented 2 years ago

Now we need to work out an understanding for the vehicle model/texture files .3DD, . 3DG and etc. file extensions so we can import new custom vehicles into the game. Not sure if you have experience in that area.

On Tue, Jun 14, 2022 at 6:27 AM Silent @.***> wrote:

Yup, it works properly and generates archives 1:1 to the original, with the exception of the file order - they've been manually ordered to optimize load times, or at least that's what it looks like.

— Reply to this email directly, view it on GitHub https://github.com/christorrella/mhpf-tools/issues/2#issuecomment-1155186352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACO755AJMK6XRI6BSXSZWQ3VPCCCTANCNFSM5YVON6CQ . You are receiving this because you commented.Message ID: @.***>

CookiePLMonster commented 2 years ago

Now we need to work out an understanding for the vehicle model/texture files .3DD, . 3DG and etc. file extensions so we can import new custom vehicles into the game. Not sure if you have experience in that area.

Seems like those are Eden's formats and they are known: https://github.com/djey47/tdumt/blob/e7b433db37df889f4ed99c5907370a75a66fffd1/tdumt-lib/labs/WorldEditor/DAE/DAE_Reader.cs

Whether Melbourne's data stored in those format is identical is another matter, but it should be a good starting point.

MeFisto94 commented 1 year ago

I just found this issue!

Actually, I have been developing a c# lib that is able to parse all asset file formats syntactically (semantically, adding a new material still is an issue for the game). The project is currently private for a variety of reasons, but if you're interested in helping out (it should've become a gltf <-> tdu toolchain), I can grant access to it :)

Do note that to import vehicles, there's zmod2 that supports doing so and has been the standard way for years, it just doesn't hold up against modern day blender and may not support everything.

Also, feel free to join turboduck.net for the TDU modding community as well as finding me on their discord as well as on https://discord.tduniverse.org