Replies: 9 (Who?), Viewed: 4563 times.
Lab Assistant
Original Poster
#1 Old 13th Jul 2009 at 5:40 AM Last edited by ChaosMageX : 13th Jul 2009 at 11:29 PM.
Default Simple FNV Encoder - Version 1.1 with 64, 32, & 24 bit encoding
Hello. I'm just putting this here for a bit of convenience, but I'm not sure if it directly relates to TS3 (or is just too insignificant).

New Version 1.1 out
This time, I just copied the entire ResourceUtils class out of the game's code, and made a button to make use of each of its functions.

This is just a simple C# .NET application I whipped up by transplanting the game's code for generating 64 bit hash numbers from strings into it.

This can be used to create unique Instance IDs for new resources you're putting in your mods folder. Just put a string in the specified text box and press one of the given buttons to output a hex format number in the other text box. These are the functions available:

Hash 64 - uses FNV encoding with the proper offset to create a 64 bit hash number

Hash 32 - uses FNV encoding with the proper offset to create a 32 bit hash number, useful for animation clip ids and other things like that;
each time this function is called, it also adds your string, both before and after strlower(), to a hash table in memory with its number.

Hash 24 - uses Xor Folding to create a 24 bit hash number, and I have no idea where this is used in the game code.

Xor 32 - uses Xor Folding to create a 32 bit hash number for a different thing than the FNV encoding;
this function does not add to the hash table in the Hash 32 function.

Create New GUID - uses the following algorithm that is also available in the game to create a 32 bit GUID number and output it in hex format:
Code:
DateTime time = new DateTime(0x7d5, 1, 1);
TimeSpan span = (TimeSpan)(DateTime.Now - time);
return (uint)((int)span.TotalSeconds);


UnHash 32 - Remember that hash table that was created with the function Hash 32? This function searches that hash table for a value matching the one you have given in the hex text box, and outputs the first string entry it finds into the string text box.
WARNING: Parsing errors may be thrown here in a message box if you don't enter a valid 32-bit hex format number into the text box.

Just about any modder can make their own version of this application in a heart beat, but I decided to put this up on Srikandi's suggestion over at Simlogical for users who don't know how or don't care to take the short time to make their own.

It requires the latest .NET, I think, since it was built in MS Visual C# Express 2008.

EDIT: Attachment is now showing up.
Download - please read all instructions before downloading any files!
File Type: rar Sims3FNVEncoder.rar (3.9 KB, 109 downloads) - View custom content
Description: Contains the old executable, with just the Hash 64 function
File Type: rar Sims3FNVEncoder1_1.rar (5.1 KB, 256 downloads) - View custom content
Description: Contains the new executable, with all the fun new exceptions
Advertisement
Eminence Grise
#2 Old 13th Jul 2009 at 5:58 AM
Thank you ChaosMage Needed this for the painting tutorial I'm writing. (It's a quick way of generating hopefully-unique instance IDs, which you need to add objects to the game.)
Warrior Gryphon
site owner
#3 Old 13th Jul 2009 at 12:46 PM
ChaosMageX: You should also add FNV32 generation too.

Most of us tool makers have written our own versions, but having one for the masses is nice.

Story books are full of fairy tales, of Kings and Queens, and the bluest skies.
Alchemist
#4 Old 13th Jul 2009 at 3:02 PM
I would use one with both FNV 32 and 64 in it.
There is a program called Visual Hash that does those (and a ton of other stuff), but it does not do a strlower() first, so to get the correct answer you have to edit the text.
Warrior Gryphon
site owner
#5 Old 13th Jul 2009 at 5:49 PM
Wes: VisualHash also gives wrong FNV64s too The offset it uses is wrong.

Story books are full of fairy tales, of Kings and Queens, and the bluest skies.
Lab Assistant
Original Poster
#6 Old 13th Jul 2009 at 8:12 PM
New version 1.1, in which I copied the ResourceUtils class out of the game code.
It includes the following new functions, detailed in the first post:
Hash 32, Hash 24, Xor 32, Create New GUID, and UnHash 32.
Enjoy!!

Also, I may decide to turn this into a plug-in for the major package editors out there, but since there are so many out there at the moment, I'm going to let natural selection take its course first until only one or two dominate the food chain.

If I make a newer version, I think I'll make it hash brown themed, since that's always what used to pop into my head before I actually learned what hash was in computer science. XD
Alchemist
#7 Old 14th Jul 2009 at 2:10 AM
Good work on the 24-bit hash... I think these are used in the object instances as the high-order dword, with a hash-32 as the lo order one.

<* Wes *>
Lab Assistant
#8 Old 14th Jul 2009 at 2:17 AM
Quote:
Originally Posted by wesHowe
Good work on the 24-bit hash... I think these are used in the object instances as the high-order dword, with a hash-32 as the lo order one.

<* Wes *>
What object instances are those?
Alchemist
#9 Old 14th Jul 2009 at 3:00 AM
My misrecollection of the hash-32/24 mix. The hash-24 I was thinking of is the instance for the .model files. Although I am not certain of what is being hashed, at the moment, they appear to always be 24-bit values.
Since we now have a handy-dandy hash tool (game specific routines) I plan on working at that, although my current diversion is working on the innards, or gubbins, of the files themselves.
<* Wes *>
Warrior Gryphon
site owner
#10 Old 14th Jul 2009 at 5:12 PM
Ah ha! 24bit hash fits perfectly with the custom groups for CAS package files. Until today I didn't even know that existed.

Story books are full of fairy tales, of Kings and Queens, and the bluest skies.
Back to top