StarArawn / bevy_tiled

A plugin for rendering tiled maps.
MIT License
151 stars 40 forks source link

Incomplete path passed to tiled::parse_with_path #51

Closed SarthakSingh31 closed 3 years ago

SarthakSingh31 commented 3 years ago
├── Cargo.toml
├── src/
│      └──  main.rs
├── assets/
│       ├── world.tmx
│       ├── tiles_world.tsx
│       └── tiles_world.png

For a project with the above file structure and where tiles_world.tsx is an external tileset used by world.tmx

when we try to run asset_server.load("working_map.tmx")

https://github.com/StarArawn/bevy_tiled/blob/2af6208d6ccd7c9b8da5aed27c46a2e24cf6cce2/src/loader.rs#L25-L32

load_context.path() returns the path relative to the assets folder (i.e. "world.tmx")

https://github.com/StarArawn/bevy_tiled/blob/2af6208d6ccd7c9b8da5aed27c46a2e24cf6cce2/src/map.rs#L53-L54

this asset_path is then used in tiled::parse_with_path to resolve external tilesets which panics with

Other("External tileset file not found: \"tiles_world.tsx\"")

because it will try to look for "<execution path>/tiles_world.tsx" instead of "<execution path>/assets/tiles_world.tsx"

frantisekhanzlikbl commented 3 years ago

shouldn't the path be relative to the world file and completely unrelated to the working directory?

while #52 fixes this when the project is run from its root, it is still broken when the project is e.g. a workspace member.

dmtaub commented 3 years ago

That’s a good point, I didn’t check that case when I tested it. #52 was a distinct improvement from what was there, so I merged, but I’d love to see a more complete solution if there is one.

On Apr 18, 2021, at 7:42 AM, František Hanzlík @.***> wrote:

 shouldn't the path be relative to the world file and completely unrelated to the working directory?

while #52 fixes this when the project is run from its root, it is still broken when the project is e.g. a workspace member.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

frantisekhanzlikbl commented 3 years ago

I am currently short on time so I can't submit a PR anytime soon, but if this is still broken when I have free time again I'll take a look at it