What hash should I use to set a table's assets names?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
Red
Kobold
Posts: 9
Joined: Tue May 27, 2014 4:13 am

What hash should I use to set a table's assets names?

Post by Red »

Hi all,

For my campaign framework, I decided to build a table automatically, but users encounter problems after an autosave of the campaign.
I used md5 for creating the name of the images in a table:

Code: Select all

asset_name = md5(asset_id)
for instance:
asset_id == "1" => asset_name = md5(1)
but it appears the table could not find images after an autosave (all images are replaced by huge red question marks). I assume I'm not using the correct hashing method for giving assets their correct name. Is there a way to know the correct hashing method to use so that I can create a table containing images with accurate assets names?
I understand this might look very deep in the code, but this would help me automate the creation of a table containing roughly 1,000 images with a simple (?) script.

Table in its current "buggy" status is available here: https://github.com/stephanepjeannin/maptool-mod

Thank you for your answers!

~Red/Stéphane

EDIT: I just looked at my post and found it might not be explaining enough HOW I'm building the table:
- I create the table using the method I explained in one of my previous subjects (http://forums.rptools.net/viewtopic.php?f=3&t=25134)
- I add images and assets, then I give them names
- I add the XML details on the table in the correct file
- I zip the file and change the extention to a MapTool table.

So yeah, if you need any further explanation on my "framework" for building tables automatically, I'd be pleased to share such information here :)


Red
Kobold
Posts: 9
Joined: Tue May 27, 2014 4:13 am

Re: What hash should I use to set a table's assets names?

Post by Red »

Hi all, I've let the project aside for a couple months... Coming back to it, I think I've found a way. Here's what I did:
- I instantiated the MapTool code and browsed it for finding how the images were hashed:

Code: Select all

	public Asset(String name, byte[] image) {
		this.image = image;
		this.name = name;
		if (image != null) {
			this.id = new MD5Key(image);
			extension = null;
			getImageExtension();
		}
	}
Meaning the name of the assets are depending of the content of themselves (why not...)

- I created a script for having a md5 of the content of the assets (easy to do in Perl or Python) and modified the name of the assets.

- I created a SQL database for storing "OLD_NAME" and "NEW_NAME", like "Dragon"=>"a45b39..."

- I modified the assets's names and contents accordingly (therefore, I had then a set of files like "a45b39...653f" and "a45b39...653f.png" instead of having "Dragon" and "Dragon.png")

- I modified the table's contents.xml file so it make id's, that were names from the old names, correspond to the new names (like "replace <id>Dragon</id> with <id>a45b39...</a>")

- I zipped the contents.xml file, properties.xml file and assets/ folder and modified the extension to .mttable

And voila, a brand new table ready to use, with no error like "asset not found"! :)

I hope it will be of any help to any nerd wanting to create his own tables ;)

Post Reply

Return to “MapTool”