From 9919ce2552e65db270c2cc50742ff5270da1f065 Mon Sep 17 00:00:00 2001 From: olanti-p Date: Mon, 17 May 2021 17:28:52 +0300 Subject: [PATCH] Overwrite tiles with same id --- src/cata_tiles.cpp | 6 +++++- src/cata_tiles.h | 8 +------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index ba814ce3d2d00..58652cacfe20f 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -256,7 +256,11 @@ tileset::find_tile_type_by_season( const std::string &id, season_type season ) c tile_type &tileset::create_tile_type( const std::string &id, tile_type &&new_tile_type ) { - auto inserted = tile_ids.insert( std::make_pair( id, new_tile_type ) ).first; + // Must overwrite existing tile + // TODO: c++17 - replace [] + find() with insert_or_assign() + tile_ids[id] = std::move( new_tile_type ); + auto inserted = tile_ids.find( id ); + const std::string &inserted_id = inserted->first; tile_type &inserted_tile = inserted->second; diff --git a/src/cata_tiles.h b/src/cata_tiles.h index c736c3c76a5fa..df57d96250ffd 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -221,13 +221,7 @@ class tileset_loader void add_ascii_subtile( tile_type &curr_tile, const std::string &t_id, int sprite_id, const std::string &s_id ); void load_ascii_set( const JsonObject &entry ); - /** - * Create a new tile_type, add it to tile_ids (using id). - * Set the fg and bg properties of it (loaded from the json object). - * Makes sure each is either -1, or in the interval [0,size). - * If it's in that interval, adds offset to it, if it's not in the - * interval (and not -1), throw an std::string error. - */ + tile_type &load_tile( const JsonObject &entry, const std::string &id ); void load_tile_spritelists( const JsonObject &entry, weighted_int_list> &vs,