Skip to content

Commit

Permalink
Overwrite tiles with same id
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p authored and Fris0uman committed Aug 31, 2021
1 parent 0447a46 commit 9919ce2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <B>id</B>).
* 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<std::vector<int>> &vs,
Expand Down

0 comments on commit 9919ce2

Please sign in to comment.