baylej / tmx

C tmx map loader
http://libtmx.rtfd.io/
BSD 2-Clause "Simplified" License
241 stars 54 forks source link

Load Buffer Base Path for images #57

Closed RobLoach closed 9 months ago

RobLoach commented 3 years ago

When loading a map through a buffer, there is no base-path associated with where the file was loaded from. This means that if you load a map through a buffer, tmx will attempt to load images through tmx_img_load_func(path) without the basepath applied to where images actually exist.

tmx_map* tmx_load_buffer(const char *buffer, int len);

For example...

resources/map/map.tmx
resources/map/tileset.png

If you load the map through a buffer, it will attempt to load tileset.png rather than resources/map/tileset.png.

baylej commented 2 years ago

Hi, the buffer/fd/callback set of load functions only exist for very specific cases, eg to load from a zipped file system, or using custom IO. These are not the preferred way to load maps, why do you need to load from a buffer ?

RobLoach commented 2 years ago

Correct. This change will allow...

For my use case, I'm working on a libretro core named Lutro where games are distributed through a single .lutro file, which is similar to Love2D. A .lutro file is essentially a .zip file. Looking to add Tiled support directly into Lutro.