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

Inconsistent path separators for assets cause unexpected behaviours #261

Closed
Joakker opened this issue Feb 9, 2025 · 3 comments
Closed
Labels
needs documentation For features or changes which still need changes in the book

Comments

@Joakker
Copy link
Contributor

Joakker commented Feb 9, 2025

I'm working on both windows and linux, and as you know, they have different path separators. Currently BMS uses the asset's path to determine which script must be loaded where. However, if I do the following on windows

ScriptComponent::new(vec!["foo/bar.baz"])

I can't actually load the script into the entity because the asset is loaded as "foo\bar.baz". I don't want to keep track of two copies of each path changing only the separator character. I think the path should be normalised to convert \ into /

@makspll
Copy link
Owner

makspll commented Feb 9, 2025

Hmm, so a few things to consider:

  • Why not use PathBuf/Path here to avoid any issues?
  • You can already do this by overriding ScriptAssetSettings, and specifically the AssetPathToScriptIdMapper, if you override there, you will be able to normalize all ScriptId's
  • I am not sure asset paths always correspond to file paths, so I am a bit wary of making many assumptions here

What do you think?

@Joakker
Copy link
Contributor Author

Joakker commented Feb 9, 2025

N°1 is how I ended up solving this issue, but I'll look into number 2. Thanks 😃

@Joakker Joakker closed this as completed Feb 9, 2025
@makspll
Copy link
Owner

makspll commented Feb 9, 2025

I should probably mention something in the docs about this, as it's a bit of a footgun!

@makspll makspll added the needs documentation For features or changes which still need changes in the book label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs documentation For features or changes which still need changes in the book
Projects
None yet
Development

No branches or pull requests

2 participants