diff --git a/data/json/overmap/overmap_terrain/overmap_terrain_transportation.json b/data/json/overmap/overmap_terrain/overmap_terrain_transportation.json index 7b0c6a2a99ce2..d7ab43492188c 100644 --- a/data/json/overmap/overmap_terrain/overmap_terrain_transportation.json +++ b/data/json/overmap/overmap_terrain/overmap_terrain_transportation.json @@ -218,7 +218,6 @@ "type": "overmap_terrain", "id": "forest_trail", "name": "forest trail", - "sym": "T", "color": "green", "mapgen_straight": [ { "method": "builtin", "name": "forest_trail_straight" } ], "mapgen_curved": [ { "method": "builtin", "name": "forest_trail_curved" } ], diff --git a/gfx/RetroDaysTileset/tile_config.json b/gfx/RetroDaysTileset/tile_config.json index 96654f57a90d2..d0c9a4b21c1f8 100644 --- a/gfx/RetroDaysTileset/tile_config.json +++ b/gfx/RetroDaysTileset/tile_config.json @@ -5390,20 +5390,21 @@ { "id": "river_nw", "fg": 2301, "rotates": false }, { "id": "river_se", "fg": 2299, "rotates": false }, { "id": "river_sw", "fg": 2300, "rotates": false }, - { "id": "road_end", "fg": [ 2274, 2275, 2276, 2277 ], "rotates": true }, - { "id": "road_es", "fg": 2281, "rotates": false }, - { "id": "road_esw", "fg": 2288, "rotates": false }, - { "id": "road_ew", "fg": 2284, "rotates": false }, - { "id": "road_isolated", "fg": 2278, "rotates": false }, - { "id": "road_ne", "fg": 2279, "rotates": false }, - { "id": "road_nes", "fg": 2282, "rotates": false }, - { "id": "road_nesw", "fg": 2289, "rotates": false }, + { + "id": "road", + "fg": 2278, + "rotates": true, + "multitile": true, + "additional_tiles": [ + { "id": "center", "fg": 2289 }, + { "id": "corner", "fg": 2281 }, + { "id": "edge", "fg": 2280 }, + { "id": "end_piece", "fg": 2274 }, + { "id": "t_connection", "fg": 2288 }, + { "id": "unconnected", "fg": 2278 } + ] + }, { "id": "road_nesw_manhole", "fg": 2290, "rotates": false }, - { "id": "road_new", "fg": 2285, "rotates": false }, - { "id": "road_ns", "fg": 2280, "rotates": false }, - { "id": "road_nsw", "fg": 2287, "rotates": false }, - { "id": "road_sw", "fg": 2286, "rotates": false }, - { "id": "road_wn", "fg": 2283, "rotates": false }, { "id": [ "s_clothes", "s_clothes_1", "s_clothes_2", "s_clothes_3", "s_clothes_4", "s_clothes_5", "s_clothes_6" ], "fg": [ 2353, 2353, 2353, 2353 ], diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 2bf90a6a703e4..953a5135f1356 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1881,7 +1881,7 @@ bool cata_tiles::draw_from_id_string( const std::string &id, TILE_CATEGORY categ sym = tmp->get_uint32_symbol(); col = tmp->get_color(); } else if( type_tmp.is_valid() ) { - sym = type_tmp->get_symbol().front(); + sym = type_tmp->symbol; col = type_tmp->color; } } else if( category == C_OVERMAP_NOTE ) { diff --git a/src/cata_tiles.h b/src/cata_tiles.h index cc99a4d0dd562..0762f362e802b 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -45,18 +45,6 @@ struct tile_type { std::vector available_subtiles; }; -/* Enums */ -enum MULTITILE_TYPE { - center, - corner, - edge, - t_connection, - end_piece, - unconnected, - open_, - broken, - num_multitile_types -}; // Make sure to change TILE_CATEGORY_IDS if this changes! enum TILE_CATEGORY { C_NONE, @@ -539,7 +527,8 @@ class cata_tiles static std::vector build_renderer_list(); static std::vector build_display_list(); private: - int get_omt_rotation( std::string &id ); + std::string get_omt_id_rotation_and_subtile( + const tripoint_abs_omt &omp, int &rota, int &subtile ); protected: template void tile_loading_report( const maptype &tiletypemap, TILE_CATEGORY category, diff --git a/src/enums.h b/src/enums.h index a2976644100c9..74e0206bc80b4 100644 --- a/src/enums.h +++ b/src/enums.h @@ -378,6 +378,18 @@ struct social_modifiers { } }; +enum MULTITILE_TYPE { + center, + corner, + edge, + t_connection, + end_piece, + unconnected, + open_, + broken, + num_multitile_types +}; + enum class reachability_cache_quadrant : int { NE, SE, NW, SW }; diff --git a/src/omdata.h b/src/omdata.h index 342da3096ef87..5211e2cd9c58e 100644 --- a/src/omdata.h +++ b/src/omdata.h @@ -296,6 +296,7 @@ struct oter_t { size_t get_line() const { return line; } + void get_rotation_and_subtile( int &rotation, int &subtile ) const; unsigned char get_see_cost() const { return type->see_cost; diff --git a/src/overmap.cpp b/src/overmap.cpp index 5090fb35ab842..7b4a73cd60ae9 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -91,6 +91,8 @@ namespace om_lines struct type { uint32_t symbol; size_t mapgen; + MULTITILE_TYPE subtile; + int rotation; std::string suffix; }; @@ -100,22 +102,22 @@ const std::array mapgen_suffixes = {{ }; const std::array < type, 1 + om_direction::bits > all = {{ - { UTF8_getch( LINE_XXXX_S ), 4, "_isolated" }, // 0 ---- - { UTF8_getch( LINE_XOXO_S ), 2, "_end_south" }, // 1 ---n - { UTF8_getch( LINE_OXOX_S ), 2, "_end_west" }, // 2 --e- - { UTF8_getch( LINE_XXOO_S ), 1, "_ne" }, // 3 --en - { UTF8_getch( LINE_XOXO_S ), 2, "_end_north" }, // 4 -s-- - { UTF8_getch( LINE_XOXO_S ), 0, "_ns" }, // 5 -s-n - { UTF8_getch( LINE_OXXO_S ), 1, "_es" }, // 6 -se- - { UTF8_getch( LINE_XXXO_S ), 3, "_nes" }, // 7 -sen - { UTF8_getch( LINE_OXOX_S ), 2, "_end_east" }, // 8 w--- - { UTF8_getch( LINE_XOOX_S ), 1, "_wn" }, // 9 w--n - { UTF8_getch( LINE_OXOX_S ), 0, "_ew" }, // 10 w-e- - { UTF8_getch( LINE_XXOX_S ), 3, "_new" }, // 11 w-en - { UTF8_getch( LINE_OOXX_S ), 1, "_sw" }, // 12 ws-- - { UTF8_getch( LINE_XOXX_S ), 3, "_nsw" }, // 13 ws-n - { UTF8_getch( LINE_OXXX_S ), 3, "_esw" }, // 14 wse- - { UTF8_getch( LINE_XXXX_S ), 4, "_nesw" } // 15 wsen + { UTF8_getch( LINE_XXXX_S ), 4, unconnected, 0, "_isolated" }, // 0 ---- + { UTF8_getch( LINE_XOXO_S ), 2, end_piece, 2, "_end_south" }, // 1 ---n + { UTF8_getch( LINE_OXOX_S ), 2, end_piece, 1, "_end_west" }, // 2 --e- + { UTF8_getch( LINE_XXOO_S ), 1, corner, 1, "_ne" }, // 3 --en + { UTF8_getch( LINE_XOXO_S ), 2, end_piece, 0, "_end_north" }, // 4 -s-- + { UTF8_getch( LINE_XOXO_S ), 0, edge, 0, "_ns" }, // 5 -s-n + { UTF8_getch( LINE_OXXO_S ), 1, corner, 0, "_es" }, // 6 -se- + { UTF8_getch( LINE_XXXO_S ), 3, t_connection, 1, "_nes" }, // 7 -sen + { UTF8_getch( LINE_OXOX_S ), 2, end_piece, 3, "_end_east" }, // 8 w--- + { UTF8_getch( LINE_XOOX_S ), 1, corner, 2, "_wn" }, // 9 w--n + { UTF8_getch( LINE_OXOX_S ), 0, edge, 1, "_ew" }, // 10 w-e- + { UTF8_getch( LINE_XXOX_S ), 3, t_connection, 2, "_new" }, // 11 w-en + { UTF8_getch( LINE_OOXX_S ), 1, corner, 3, "_sw" }, // 12 ws-- + { UTF8_getch( LINE_XOXX_S ), 3, t_connection, 3, "_nsw" }, // 13 ws-n + { UTF8_getch( LINE_OXXX_S ), 3, t_connection, 0, "_esw" }, // 14 wse- + { UTF8_getch( LINE_XXXX_S ), 4, center, 0, "_nesw" } // 15 wsen } }; @@ -568,6 +570,14 @@ void oter_type_t::load( const JsonObject &jo, const std::string &src ) for( const auto &elem : om_lines::mapgen_suffixes ) { load_overmap_terrain_mapgens( jo, id.str(), elem ); } + + if( symbol == NULL_UNICODE ) { + // Default the sym for linear terrains to a specific value which + // has special behaviour when using fallback ASCII tiles so as to + // cause it to draw using the box drawing characters (see + // load_ascii_set). + symbol = LINE_XOXO_C; + } } else { if( symbol == NULL_UNICODE && !jo.has_string( "abstract" ) ) { DebugLog( D_ERROR, D_MAP_GEN ) << "sym is not defined for overmap_terrain: " @@ -688,6 +698,21 @@ oter_id oter_t::get_rotated( om_direction::type dir ) const : type->get_rotated( om_direction::add( this->dir, dir ) ); } +void oter_t::get_rotation_and_subtile( int &rotation, int &subtile ) const +{ + if( is_linear() ) { + const om_lines::type &t = om_lines::all[line]; + rotation = t.rotation; + subtile = t.subtile; + } else if( is_rotatable() ) { + rotation = static_cast( get_dir() ); + subtile = -1; + } else { + rotation = 0; + subtile = -1; + } +} + bool oter_t::type_is( const int_id &type_id ) const { return type->id.id() == type_id; diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 72fe41e46a538..7eea06f9ddbf4 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -755,38 +755,20 @@ static cata::optional> get_mission_arro return std::make_pair( tripoint_abs_omt( *prev ), mission_arrow_variant ); } -int cata_tiles::get_omt_rotation( std::string &id ) +std::string cata_tiles::get_omt_id_rotation_and_subtile( + const tripoint_abs_omt &omp, int &rota, int &subtile ) { - if( id.length() < 5 ) { - return 0; - } - // save the id for later just in case we don't have a tile - const std::string first_id = id; - int rotation = 0; - std::string suffix = id.substr( id.length() - 5, id.length() - 1 ); - if( suffix == "_east" ) { - id = id.substr( 0, id.length() - 5 ); - rotation = 1; - } else if( suffix == "_west" ) { - id = id.substr( 0, id.length() - 5 ); - rotation = 3; - } - if( id.length() < 6 ) { - return rotation; - } - suffix = id.substr( id.length() - 6, id.length() - 1 ); - if( suffix == "_north" ) { - id = id.substr( 0, id.length() - 6 ); - rotation = 0; - } else if( suffix == "_south" ) { - id = id.substr( 0, id.length() - 6 ); - rotation = 2; - } - if( !find_tile_looks_like( id, TILE_CATEGORY::C_OVERMAP_TERRAIN ) ) { - //fallback tiles - id = first_id; + oter_id ot_id = overmap_buffer.ter( omp ); + + if( !uistate.overmap_show_forest_trails && + is_ot_match( "forest_trail", ot_id, ot_match_type::type ) ) { + ot_id = oter_id( "forest" ); } - return rotation; + + const oter_t &ot = *ot_id; + oter_type_id ot_type_id = ot.get_type_id(); + ot.get_rotation_and_subtile( rota, subtile ); + return ot_type_id.id().str(); } void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_omt, bool blink ) @@ -861,9 +843,10 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ const bool see = overmap_buffer.seen( omp ); const bool los = see && you.overmap_los( omp, sight_points ); - const oter_id &cur_ter = overmap_buffer.ter( omp ); // the full string from the ter_id including _north etc. std::string id; + int rotation = 0; + int subtile = -1; if( viewing_weather ) { const tripoint_abs_omt omp_sky( omp.xy(), OVERMAP_HEIGHT ); @@ -873,21 +856,16 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ } else { id = "unexplored_terrain"; } + } else if( !see ) { + id = "unknown_terrain"; } else { - id = see ? cur_ter->id.c_str() : "unknown_terrain"; - - if( !uistate.overmap_show_forest_trails && - is_ot_match( "forest_trail", cur_ter, ot_match_type::type ) ) { - id = "forest"; - } + id = get_omt_id_rotation_and_subtile( omp, rotation, subtile ); } - const int rotation = get_omt_rotation( id ); - const lit_level ll = overmap_buffer.is_explored( omp ) ? lit_level::LOW : lit_level::LIT; // light level is now used for choosing between grayscale filter and normal lit tiles. - draw_from_id_string( id, TILE_CATEGORY::C_OVERMAP_TERRAIN, "overmap_terrain", pos, -1, rotation, - ll, false, height_3d ); + draw_from_id_string( id, TILE_CATEGORY::C_OVERMAP_TERRAIN, "overmap_terrain", pos, + subtile, rotation, ll, false, height_3d ); if( see ) { if( blink && uistate.overmap_debug_mongroup ) { @@ -954,10 +932,13 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ } if( uistate.place_terrain ) { - const oter_str_id &terrain = uistate.place_terrain->id; - std::string id = terrain.c_str(); - const int rotation = get_omt_rotation( id ); - draw_from_id_string( id, global_omt_to_draw_position( center_abs_omt ), 0, rotation, + const oter_str_id &terrain_id = uistate.place_terrain->id; + const oter_t &terrain = *terrain_id; + std::string id = terrain.get_type_id().str(); + int rotation; + int subtile; + terrain.get_rotation_and_subtile( rotation, subtile ); + draw_from_id_string( id, global_omt_to_draw_position( center_abs_omt ), subtile, rotation, lit_level::LOW, true ); } if( uistate.place_special ) { @@ -965,8 +946,12 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ if( s_ter.p.z == 0 ) { // TODO: fix point types const point_rel_omt rp( om_direction::rotate( s_ter.p.xy(), uistate.omedit_rotation ) ); - std::string id = s_ter.terrain->get_rotated( uistate.omedit_rotation ).id().c_str(); - const int rotation = get_omt_rotation( id ); + oter_id rotated_id = s_ter.terrain->get_rotated( uistate.omedit_rotation ); + const oter_t &terrain = *rotated_id; + std::string id = terrain.get_type_id().str(); + int rotation; + int subtile; + terrain.get_rotation_and_subtile( rotation, subtile ); draw_from_id_string( id, TILE_CATEGORY::C_OVERMAP_TERRAIN, "overmap_terrain", global_omt_to_draw_position( center_abs_omt + rp ), 0, rotation, lit_level::LOW, true );