Tiles mode - Multitile background defaults to 0

This is a fairly small problem with a fairly easy solution, unless there is something else there that I am not aware of.

Basically, the problem is that whenever multitile tiles are defined for a tileset, if their background is not set (the line is omitted), then the background tile defaults to the zeroth tile, instead of a nonexistent one. Which makes multitile blood spatters and smoke spontaneously spawn grass under them, or whichever tile is in the tileset’s tilepage first.

[quote=“Sean Mirrsen, post:89, topic:5029”]Okay, found it. It’s a bug in Cataclysm itself.

[code] JsonArray tiles = config.get_array(“tiles”);
while (tiles.has_more()) {
JsonObject entry = tiles.next_object();

    tile_type *curr_tile = new tile_type();
    std::string t_id = entry.get_string("id");
    int t_fg = entry.get_int("fg", -1);//<<<<<<<<<<<<<<<<<<<<<<<
    int t_bg = entry.get_int("bg", -1);
    bool t_multi = entry.get_bool("multitile", false);
    bool t_rota = entry.get_bool("rotates", t_multi);
    if (t_multi) {
        // fetch additional tiles
        JsonArray subentries = entry.get_array("additional_tiles");
        while (subentries.has_more()) {
            JsonObject subentry = subentries.next_object();

            tile_type *curr_subtile = new tile_type();
            std::string s_id = subentry.get_string("id");
            int s_fg = subentry.get_int("fg", 0);//<<<<<<<<<<<<<<<<<<<<<<<
            int s_bg = subentry.get_int("bg", 0);[/code]

Or, well, more like an oversight. When loading tile data, the foreground and background both default to -1, as needed. But when loading subsequent subtiles in a multitile, it defaults to 0, which means multitiles with no background defined will use the zeroth tile. I guess one way to bypass this, at the moment, is make sure the zeroth tile is transparent. For instance, by adding a “00” tile definition, and force-selecting a transparent image as its foreground, then clicking Sort so it’s in the top. In the meantime, we should probably file a bugreport.[/quote]Unless there is a reason the multitile backgrounds default to 0, the fix to this one should be pretty easy.

Thanks for finding out what the problem is. I agree this should be eventually fixed in game.

Not clear myself what the issue is. (As I don’t use tiles) but could you make an issue on the issue tracker describing the problem and the solution (or better, make a pull req with the fixed code).

Here.

Thanks for reporting nad working on the fix.