RandyGaul / cute_headers

Collection of cross-platform one-file C/C++ libraries with no dependencies, primarily used for games
4.24k stars 264 forks source link

cute_tiled: Problem with new default field "class" on Objects since Tiled 1.9 #323

Closed g-lujan closed 1 year ago

g-lujan commented 1 year ago

Apparently, since Tiled 1.9, the field "class" is exported by default in the Objects on an Object Layer.

An example of a simple object inside an object layer: image

It breaks the function cute_tiled_load_map_from_file, making it return null even on very simple cases.

Steps to reproduce

Proposed solution while "class" is not implemented

Add the following case on the switch inside the function cute_tiled_read_object:

case 1485919047363370797U: // class
    CUTE_TILED_WARNING("Class field of Tiled objects is not yet supported. Ignoring field.");   
        while (cute_tiled_peak(m) != ',' && cute_tiled_peak(m) != '}') cute_tiled_next(m);
    if (cute_tiled_peak(m) == '}')  continue;
    break;

This will ignore the field class when trying to read an object. The while is looking for both ',' and '}' to avoid breaking the parsing in case the user passes the field.

And add the following to the struct cute_tiled_object_t

/* class */                          // Not currently supported.
RandyGaul commented 1 year ago

This looks great! Please add a pull request for this. Do you know how? I can send instructions — you can do it from the browser with just copy + paste.

g-lujan commented 1 year ago

@RandyGaul just submitted a PR. Thanks!!