Oops, stop showing PNG reference art

Huh, weird. So I reversed the manifest, because you want to get the *last* movie. And I figured that semantic probably extended to PNGs and SVGs too?

But actually, PNGs sometimes have *other* PNGs in the manifest that aren't the relevant asset at all, and are just reference art.

Again, I'm really not sure what the underlying semantic is here? Does the Neopets customizer just display them all, and for the items with this problem, they happen to layer in a way that's not broken?? I would really like to not do that, and I would really like to know the real semantic, but I can't find it >.>

So um, I'm going ahead and using the best semantic that solves the problems I know about? Which is, use the last movie, and use the first PNG. Fingers crossed lol!

I also didn't test this change extensively, because I'm on a train lol

I'm just trusting that this push will be better than what we had before. I tested it on the Dandan MME, which has two JS files, and it took the latter; and the Pathway of Petals Background, which has two PNG files, and it took the former. Success? 😬🤞
This commit is contained in:
Emi Matchu 2021-06-27 15:34:36 -07:00
parent f5e5f16f87
commit b0672d589f

View file

@ -417,15 +417,12 @@ async function loadAndCacheAssetDataFromManifest(db, layer) {
(ad) => new URL(ad.path, "http://images.neopets.com")
);
// Now, we search the asset URLs for the *last* asset matching each filetype.
// (This is because sometimes there will be older and newer animations in the
// same file, and the newer one comes second, I guess!)
//
// NOTE: I'm not sure how reliable this actually is. I wonder if the more
// correct behavior is to like... play all of them? 😳
assetUrls.reverse();
const jsAssetUrl = assetUrls.find(
// In the case of JS assets, we want the *last* one in the list, because
// sometimes older broken movies are included in the manifest too. In
// practice, they generally seem to appear later, but I don't know how
// reliable that actually is. (For PNGs though, we *must* return the first,
// see the comments there.)
const jsAssetUrl = [...assetUrls].reverse().find(
// NOTE: Sometimes the path ends with a ?v= query string, so we need
// to use `extname` to find the real extension!
// TODO: There's a file_ext field in the full manifest, but it's not
@ -443,6 +440,10 @@ async function loadAndCacheAssetDataFromManifest(db, layer) {
(url) => path.extname(url.pathname) === ".svg"
);
// NOTE: Unlike movies, we *must* use the first PNG and not the last, because
// sometimes reference art is included in the manifest as later PNGs.
// I wish I understood the underlying logic here, I'm not sure how
// reliable this is!
const pngAssetUrl = assetUrls.find(
// NOTE: Sometimes the path ends with a ?v= query string, so we need
// to use `extname` to find the real extension!