[SOLVED] Flash exporters skip duplicates

Status
Not open for further replies.

Joeh

Member
Jan 9, 2020
10
28
I've recently started a new project which requires unpacking and repacking habbo assets.
I've been battling a couple of bugs that I've managed to track down to very early on in the process during the initial extraction. Sometimes there are duplicates (in terms of being the same image) and they don't get extracted twice.

I'm using but I've tried several other extractors and they all seem to have this issue.

So, time to delve into it.

First, we take a look at the original shockwave asset as a point of reference.
You must be registered for see images attach


We can see that these 2 assets are identical.

Then we can take a look at the Flash manifest xml.
XML:
            <asset name='h_wlk_sh_4_1_0' mimeType='image/png' >
                <param key='offset' value='-24,8' />
            </asset>
            <asset name='h_wlk_sh_4_1_1' mimeType='image/png' >
                <param key='offset' value='-15,5' />
            </asset>
            <asset name='h_wlk_sh_4_1_2' mimeType='image/png' >
                <param key='offset' value='-23,8' />
            </asset>
            <asset name='h_wlk_sh_4_1_3' mimeType='image/png' >
                <param key='offset' value='-13,5' />
            </asset>
All 4 of the files are listed (including the 2 dupes).

If we look at the flash asset, we see that flash detected they are dupes, so both are listed but point to the same asset (note the U16).
You must be registered for see images attach


Finally, let's look at what was extracted
You must be registered for see images attach


We are missing 4_1_3.
This appears to happen with every exporter I have tried, presumably they don't handle this duplicate case correctly.

Fixing it up manually is not really an option because I need to bulk transform the assets.
Has anyone else noticed this? Found an exporter that works? etc
Post automatically merged:

I was actually able to resolve this.
It seems like most exporters only allow a 1:1 mapping between image and name even though flash allows multiple.

If you are using swf-extract with nodejs, you can do something like:

JavaScript:
    export const extractGenerateAssetMap = (swf: any) => {
        const assetMap: any = {};
        for (let _i = 0, _a = swf.tags; _i < _a.length; _i++) {
            const tag = _a[_i];
            if (tag.header.code == 76) {
                for (let _b = 0, _c = tag.symbols; _b < _c.length; _b++) {
                    const asset = _c[_b];
                    if(!assetMap[asset.id]) assetMap[asset.id] = [];
                    assetMap[asset.id].push(asset.name);
                }
            }
        }
        return assetMap;
    }

This way, you have a list of names for each id, and you can just write the image out multiple times for all the names in the list.
 
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top