jdolan / quetoo

Quetoo ("Q2") is a free first person shooter based on id Tech2. GPL v2 license.
http://quetoo.org
202 stars 28 forks source link

Models with skins of the same basename cause media collisions #411

Closed jdolan closed 3 years ago

jdolan commented 7 years ago

This is a nasty one.. with a couple hundred (really bad) Q3 player models on my system, I'm seeing renderer media corruption that I don't fully understand yet. Screenshot of the stack trace and corruption:

screen shot 2017-02-11 at 8 37 34 am

You can see that the mod, which should be a mesh MD3, is identifying as MEDIA_IMAGE. Its mesh member is all NULLs, so it probably is an image that is, for some reason, keyed with the model name.

jdolan commented 7 years ago

CC @Paril

jdolan commented 7 years ago

Shit. I see what's going on here. The player model in question has an upper.md3 and an upper.tga. The skin file displaced the model in the media table. Hmm. How to handle...

Paril commented 7 years ago

Could just append _mod, _tex, etc to the key name, similar to how we append _mat for materials so they don't collide with the textures.

jdolan commented 7 years ago

Yea, it'd require a bunch of path mangling (lookup name versus underlying asset name), but it's doable. Another option would be to have separate hash tables in r_media_t for each media type.. but, meh.

Paril commented 7 years ago

Both options are attractive... the latter option means shorter lookup times and less collisions between types but slightly more complex pathing, the former is uglier code-wise and slams everything into one hash map but is easier to do for us.

Honestly, in the long run, path #2 seems best to me.

jdolan commented 3 years ago

Couldn't we also provide a better custom hash value function for media, instead of just relying on g_str_hash and g_str_equal? That seems like an easy, and correct, fix for this. In other words: just implement the hashcode and equals contracts correctly for r_media_t.

jdolan commented 3 years ago

Fixed. 'Bout fuckin' time :)