Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same name textures but for different .img's get resolved one-sided #119

Open
rokuniichi opened this issue Nov 3, 2024 · 6 comments
Open

Comments

@rokuniichi
Copy link

Found that problem while was trying to remove annoying labels from clothes.

Example:
There's a jacket named "coach" in player.img that has a corresponding texture "coach.txd"
Also, there's a vehicle "coach" in gta3.img that has an appropriately named "coach.txd" texture

If you were to use 2 mods, one of which changes the vehicle's texture and another that change's the jacket's texture in that example, you would only get only one of those textures actually loaded in the game and another one completely ignored.

@rokuniichi
Copy link
Author

After looking through code and debugging, here are my observations:

  • the solution for coach that is already in the project doesn't take into account other filetypes of "coach" files (e.g. .txd as mentioned above):
    image
  • that exact solution wouldn't work anyways, because we populate raw_models map here using a file's filename as a key and one of the files will be inevitably overwritten (which one would depend on the directory name since they're ordered alphabetically and therefore accessed in that order):
    image

This is 100% reproducible and the only easy (?) solution without breaking much here would be to use file.filepath or file.filedir as a key and adjust the code for accessing the raw_models map accordingly.

@thelink2012
Copy link
Owner

Hey @rokuniichi. There's already a solution for this within the project. If you put a clothing item inside a player.img subdirectory it won't be detected as a streaming asset. For example, modloader/my mod/player.img/coach.txd.

Internally, when such a directory pattern occurs, the item is added a is_fcloth_mask flag, which is checked in the snippet of code you've seen. There's other two heuristics in place too:

  • We have a map of the hashes of all streaming models and clothing models imported by the game when it processed its IMG files. We check if the model has appeared as a clothing (in player.img) and not as a streamable model (other imgs).
  • I don't remember why there's a specific check for coach.dff, maybe trying to be defensive in importing a clothing model as a vehicle (which would make the game inevitably crash when said vehicle is spawned). Something that wouldn't happen with a texture (vehicle would just be all white).

@rokuniichi
Copy link
Author

rokuniichi commented Nov 4, 2024

As I've said in my follow up comment, the problem is that mask solution comes after raw_modules map gets populated, and since the key for the map used is just the filename, when we actually get to process and mark the clothing items with the is_cloth_mask, there's no such file like that anymore in the map, because we've already overwritten it by another value using the same filename as a key.

As I've told, it's 100% reproducible with coach.txd clothing mod if you have another vehicle mod that also uses coach.txd and it doesn't matter if you put it in player.img or not in that case, because it would overwritten by the vehicle one by the time we try and determine if it's a clothing piece or not.

Repro steps:

  • Put a clothing texture coach.txd as a mod in modloader/A/player.img
  • Put a vehicle texture coach.txd as a mod in modloader/B
  • Launch the game
  • Observe that Green Windbreaker is original coach.txd texture from San Andreas player.img

@thelink2012
Copy link
Owner

@rokuniichi makes sense, I apologize for not reading your previous comment thoroughly. I'll take a look into reproducing and merging your PR once I have some time. Would you be able to provide me a clothing mod for testing purposes?

@rokuniichi
Copy link
Author

@thelink2012
No problem at all, I'm happy to help.

Some assets for testing:
coach_test.zip

@rokuniichi
Copy link
Author

rokuniichi commented Nov 4, 2024

As I've told, it's 100% reproducible with coach.txd clothing mod if you have another vehicle mod that also uses coach.txd and it doesn't matter if you put it in player.img or not in that case, because it would overwritten by the vehicle one by the time we try and determine if it's a clothing piece or not.

Not entirely accurate what I said here, since because we always read modloader folder alphabetically ordered top to bottom, you'd only have to rename your coach.txd vehicle texture mod folder to something lexicographically "smaller" than your clothing one for it to be overwritten by the clothing texture mod instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants