Skip to content

GID calculation for collections of images off by one? #9

@androlo

Description

@androlo

raytmx/raytmx.h

Line 784 in e4679f2

else if (tileset.tilesLength > 0) // If the tileset is a "collection of images" with explicit tiles.

I use a mix of terrain tilemaps from a single image, and several "collection of images" types.

Had problems with an object being in the object-array but not rendering, and also causing heap corruption when unloading.

Patched it to:

else if (tileset.tilesLength > 0)
{
    uint32_t greatestID = 0;

    for (uint32_t j = 0; j < tileset.tilesLength; j++)
    {
        if (greatestID < tileset.tiles[j].id)
            greatestID = tileset.tiles[j].id;
    }

    tileset.lastGid = tileset.firstGid + greatestID;
}

That seemingly fixed the problem. The object started rendering again and the crash on exit went away.

Tiled: Version 1.12.2
Raylib: 5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions