From 7467c42c7c85ad59e349ac3409109805ace64d84 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Wed, 15 May 2024 01:28:46 +0200 Subject: [PATCH] Typified editmap (#73713) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * typified editmap * removed generated junk file * this doesn't work * Update src/line.cpp Co-authored-by: Jianxiang Wang (王健翔) * sorted out line_to * unnaming dummy parameter * Update src/coordinates.h Co-authored-by: Jianxiang Wang (王健翔) * Update src/coordinates.h Co-authored-by: Jianxiang Wang (王健翔) * Update src/line.cpp Co-authored-by: Jianxiang Wang (王健翔) * Update src/line.h Co-authored-by: Jianxiang Wang (王健翔) * Update src/coordinates.h Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Nicer parameter name --------- Co-authored-by: Jianxiang Wang (王健翔) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/animation.cpp | 4 +- src/cata_tiles.cpp | 13 --- src/cata_tiles.h | 4 - src/coordinates.h | 27 ++++- src/creature.cpp | 4 +- src/creature.h | 2 +- src/debug_menu.h | 5 + src/editmap.cpp | 253 +++++++++++++++++++++++---------------------- src/editmap.h | 16 +-- src/game.cpp | 8 +- src/game.h | 2 +- src/line.cpp | 1 + src/map.cpp | 67 ++++++++++-- src/map.h | 52 +++++++++- src/ranged.cpp | 14 +-- src/scent_map.cpp | 5 + src/scent_map.h | 3 + src/wish.cpp | 5 + 18 files changed, 301 insertions(+), 184 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index 34880d1708507..69b50748ab2e0 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -491,7 +491,7 @@ void draw_bullet_curses( map &m, const tripoint_bub_ms &t, const char bullet, shared_ptr_fast bullet_cb = make_shared_fast( [&]() { if( p != nullptr && p->z() == vp.z() ) { - m.drawsq( g->w_terrain, *p, drawsq_params().center( vp.raw() ) ); + m.drawsq( g->w_terrain, *p, drawsq_params().center( vp ) ); } mvwputch( g->w_terrain, t.xy().raw() - vp.xy().raw() + point( POSX, POSY ), c_red, bullet ); } ); @@ -693,7 +693,7 @@ void draw_line_curses( game &g, const tripoint_bub_ms ¢er, avatar &player_character = get_avatar(); map &here = get_map(); - drawsq_params params = drawsq_params().highlight( true ).center( center.raw() ); + drawsq_params params = drawsq_params().highlight( true ).center( center ); creature_tracker &creatures = get_creature_tracker(); for( const tripoint_bub_ms &p : ret ) { const Creature *critter = creatures.creature_at( p, true ); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index d8ba5bd8777cf..2862417af8dbb 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -4414,15 +4414,6 @@ void cata_tiles::init_explosion( const tripoint_bub_ms &p, int radius ) exp_pos = p; exp_rad = radius; } -void cata_tiles::init_custom_explosion_layer( const std::map &layer ) -{ - do_draw_custom_explosion = true; - std::map temp; - for( const auto &it : layer ) { - temp.insert( std::pair( tripoint_bub_ms( it.first ), it.second ) ); - } - custom_explosion_layer = temp; -} void cata_tiles::init_custom_explosion_layer( const std::map &layer ) { @@ -4455,10 +4446,6 @@ void cata_tiles::init_draw_cursor( const tripoint_bub_ms &p ) do_draw_cursor = true; cursors.emplace_back( p ); } -void cata_tiles::init_draw_highlight( const tripoint &p ) -{ - cata_tiles::init_draw_highlight( tripoint_bub_ms( p ) ); -} void cata_tiles::init_draw_highlight( const tripoint_bub_ms &p ) { do_draw_highlight = true; diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 45a794b937e2f..329429a50471c 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -587,8 +587,6 @@ class cata_tiles void draw_explosion_frame(); void void_explosion(); - // TODO: Get rid of untyped overload - void init_custom_explosion_layer( const std::map &layer ); void init_custom_explosion_layer( const std::map &layer ); void draw_custom_explosion_frame(); void void_custom_explosion(); @@ -613,8 +611,6 @@ class cata_tiles void draw_cursor(); void void_cursor(); - // TODO: Get rid of untyped overload - void init_draw_highlight( const tripoint &p ); void init_draw_highlight( const tripoint_bub_ms &p ); void draw_highlight(); void void_highlight(); diff --git a/src/coordinates.h b/src/coordinates.h index 886f65ec29ddd..f4038591027f2 100644 --- a/src/coordinates.h +++ b/src/coordinates.h @@ -793,12 +793,14 @@ direction direction_from( const coords::coord_point -std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds >> +template, int> = 0> +std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds && RhsInBounds >> line_to( const coords::coord_point &loc1, - const coords::coord_point &loc2 ) + const coords::coord_point &loc2, + const int t = 0 ) { - std::vector raw_result = line_to( loc1.raw(), loc2.raw() ); + std::vector raw_result = line_to( loc1.raw(), loc2.raw(), t ); std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds >> result; std::transform( raw_result.begin(), raw_result.end(), std::back_inserter( result ), []( const Point & p ) { @@ -808,6 +810,23 @@ std::vector < coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBou return result; } +template, int> = 0> +std::vector < coords::coord_point < Tripoint, Origin, Scale, LhsInBounds && RhsInBounds >> + line_to( const coords::coord_point &loc1, + const coords::coord_point &loc2, + const int t = 0, const int t2 = 0 ) +{ + std::vector raw_result = line_to( loc1.raw(), loc2.raw(), t, t2 ); + std::vector < coords::coord_point < Tripoint, Origin, Scale, LhsInBounds &&RhsInBounds >> result; + std::transform( raw_result.begin(), raw_result.end(), std::back_inserter( result ), + []( const Tripoint & p ) { + return coords::coord_point < Tripoint, Origin, Scale, LhsInBounds && + RhsInBounds >::make_unchecked( p ); + } ); + return result; +} + template coords::coord_point < Point, Origin, Scale, LhsInBounds &&RhsInBounds > midpoint( const coords::coord_point &loc1, diff --git a/src/creature.cpp b/src/creature.cpp index 5b861137857c7..e23fd24dacce4 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -2983,9 +2983,9 @@ units::mass Creature::weight_capacity() const /* * Drawing-related functions */ -void Creature::draw( const catacurses::window &w, const point &origin, bool inverted ) const +void Creature::draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const { - draw( w, tripoint( origin, posz() ), inverted ); + draw( w, tripoint_bub_ms( origin, posz() ), inverted ); } void Creature::draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const diff --git a/src/creature.h b/src/creature.h index e347eb56e15cd..bc7b0ee7247cd 100644 --- a/src/creature.h +++ b/src/creature.h @@ -939,7 +939,7 @@ class Creature : public viewer virtual std::unordered_set get_path_avoid() const = 0; bool underwater; - void draw( const catacurses::window &w, const point &origin, bool inverted ) const; + void draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const; // TODO: Get rid of the untyped overload void draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const; void draw( const catacurses::window &w, const tripoint_bub_ms &origin, bool inverted ) const; diff --git a/src/debug_menu.h b/src/debug_menu.h index 21c724359a22a..be80560b6168c 100644 --- a/src/debug_menu.h +++ b/src/debug_menu.h @@ -8,9 +8,12 @@ #include #include +#include "coordinates.h" + class Character; class Creature; struct tripoint; + template struct enum_traits; namespace debug_menu @@ -113,7 +116,9 @@ enum class debug_menu_index : int { void wisheffect( Creature &p ); void wishitem( Character *you = nullptr ); +// TODO: Get rid of untyped overload void wishitem( Character *you, const tripoint & ); +void wishitem( Character *you, const tripoint_bub_ms & ); void wishmonster( const std::optional &p ); void wishmutate( Character *you ); void wishbionics( Character *you ); diff --git a/src/editmap.cpp b/src/editmap.cpp index f0e8f057fa84c..790f1276ccbe7 100644 --- a/src/editmap.cpp +++ b/src/editmap.cpp @@ -223,7 +223,7 @@ void editmap_hilight::draw( editmap &em, bool update ) if( blink_interval[ cur_blink ] || update ) { map &here = get_map(); for( auto &elem : points ) { - const tripoint &p = elem.first; + const tripoint_bub_ms &p = elem.first; // but only if there's no vehicles/mobs/npcs on a point if( !here.veh_at( p ) && !creatures.creature_at( p ) ) { const ter_t &terrain = here.ter( p ).obj(); @@ -256,35 +256,35 @@ void editmap_hilight::draw( editmap &em, bool update ) /* * map position to screen position */ -tripoint editmap::pos2screen( const tripoint &p ) +tripoint editmap::pos2screen( const tripoint_bub_ms &p ) { - return p + tmax / 2 - target.xy(); + return p.raw() + tmax / 2 - target.xy().raw(); } /* * get_direction with extended moving via HJKL keys */ -bool editmap::eget_direction( tripoint &p, const std::string &action ) const +bool editmap::eget_direction( tripoint_rel_ms &p, const std::string &action ) const { - p = tripoint_zero; + p = tripoint_rel_ms( tripoint_zero ); if( action == "CENTER" ) { - p = get_player_character().pos() - target; + p = get_player_character().pos_bub() - target; } else if( action == "LEFT_WIDE" ) { - p.x = -tmax.x / 2; + p.x() = -tmax.x / 2; } else if( action == "DOWN_WIDE" ) { - p.y = tmax.y / 2; + p.y() = tmax.y / 2; } else if( action == "UP_WIDE" ) { - p.y = -tmax.y / 2; + p.y() = -tmax.y / 2; } else if( action == "RIGHT_WIDE" ) { - p.x = tmax.x / 2; + p.x() = tmax.x / 2; } else if( action == "LEVEL_DOWN" ) { - p.z = -1; + p.z() = -1; } else if( action == "LEVEL_UP" ) { - p.z = 1; + p.z() = 1; } else { input_context ctxt( "EGET_DIRECTION" ); ctxt.set_iso( true ); - const std::optional vec = ctxt.get_direction( action ); + const std::optional vec = ctxt.get_direction_rel_ms( action ); if( !vec ) { return false; } @@ -343,11 +343,11 @@ shared_ptr_fast editmap::create_or_get_ui_adaptor() return current_ui; } -std::optional editmap::edit() +std::optional editmap::edit() { avatar &player_character = get_avatar(); restore_on_out_of_scope view_offset_prev( player_character.view_offset ); - target = player_character.pos() + player_character.view_offset; + target = player_character.pos_bub() + player_character.view_offset; input_context ctxt( "EDITMAP" ); ctxt.set_iso( true ); ctxt.register_directions(); @@ -454,9 +454,9 @@ std::optional editmap::edit() void editmap::uber_draw_ter( const catacurses::window &w, map *m ) { - tripoint center = target; - tripoint start = center.xy() + tripoint( -getmaxx( w ) / 2, -getmaxy( w ) / 2, target.z ); - tripoint end = center.xy() + tripoint( getmaxx( w ) / 2, getmaxy( w ) / 2, target.z ); + tripoint_bub_ms center = target; + tripoint_bub_ms start = center.xy() + tripoint( -getmaxx( w ) / 2, -getmaxy( w ) / 2, target.z() ); + tripoint_bub_ms end = center.xy() + tripoint( getmaxx( w ) / 2, getmaxy( w ) / 2, target.z() ); /* // pending filter options bool draw_furn=true; @@ -473,9 +473,9 @@ void editmap::uber_draw_ter( const catacurses::window &w, map *m ) } creature_tracker &creatures = get_creature_tracker(); drawsq_params params = drawsq_params().center( center ); - for( const tripoint &p : tripoint_range( start, end ) ) { + for( const tripoint_bub_ms &p : tripoint_range( start, end ) ) { uint8_t sym = game_map ? '%' : ' '; - if( p.x >= 0 && p.x < msize && p.y >= 0 && p.y < msize ) { + if( p.x() >= 0 && p.x() < msize && p.y() >= 0 && p.y() < msize ) { if( game_map ) { Creature *critter = creatures.creature_at( p ); if( critter != nullptr ) { @@ -487,7 +487,7 @@ void editmap::uber_draw_ter( const catacurses::window &w, map *m ) monster *mon = dynamic_cast( critter ); if( mon != nullptr && mon->has_dest() ) { for( auto &location : line_to( mon->get_location(), mon->get_dest() ) ) { - hilights["mplan"].points[m->getlocal( location )] = 1; + hilights["mplan"].points[m->bub_from_abs( location )] = 1; } } } @@ -495,7 +495,7 @@ void editmap::uber_draw_ter( const catacurses::window &w, map *m ) m->drawsq( w, p, params ); } } else { - mvwputch( w, p.xy() - start.xy(), c_dark_gray, sym ); + mvwputch( w, ( p.xy() - start.xy() ).raw(), c_dark_gray, sym ); } } if( refresh_mplans ) { @@ -506,7 +506,7 @@ void editmap::uber_draw_ter( const catacurses::window &w, map *m ) void editmap::do_ui_invalidation() { avatar &player_character = get_avatar(); - player_character.view_offset = target - player_character.pos(); + player_character.view_offset = ( target - player_character.pos_bub() ).raw(); g->invalidate_main_ui_adaptor(); create_or_get_ui_adaptor()->invalidate_ui(); } @@ -530,21 +530,21 @@ void editmap::draw_main_ui_overlay() #ifdef TILES // give some visual indication of different cursor moving modes if( use_tiles && altblink ) { - std::array p = { origin.xy(), target.xy() }; + std::array p = { origin.xy(), target.xy() }; if( editshape == editmap_rect || editshape == editmap_rect_filled || p[0] == p[1] ) { if( p[0] == p[1] ) { // ensure more than one cursor is drawn to differ from resizing mode p[0] += point_north_west; p[1] += point_south_east; } - for( const point &pi : p ) { - for( const point &pj : p ) { - g->draw_cursor( tripoint( pi.x, pj.y, target.z ) ); + for( const point_bub_ms &pi : p ) { + for( const point_bub_ms &pj : p ) { + g->draw_cursor( tripoint_bub_ms( pi.x(), pj.y(), target.z() ) ); } } } else if( editshape == editmap_circle ) { g->draw_cursor( target ); - g->draw_cursor( origin * 2 - target ); + g->draw_cursor( tripoint_bub_ms( origin.raw() * 2 - target.raw() ) ); } else if( editshape == editmap_line ) { g->draw_cursor( origin ); g->draw_cursor( target ); @@ -559,7 +559,7 @@ void editmap::draw_main_ui_overlay() creature_tracker &creatures = get_creature_tracker(); // hilight target_list points if blink=true if( blink ) { - for( const tripoint &p : target_list ) { + for( const tripoint_bub_ms &p : target_list ) { #ifdef TILES if( use_tiles ) { if( draw_target_override ) { @@ -620,12 +620,12 @@ void editmap::draw_main_ui_overlay() tinymap &tmpmap = *tmpmap_ptr; #ifdef TILES if( use_tiles ) { - const tripoint player_location = get_player_character().pos(); - const point origin_p = target.xy() + point( 1 - SEEX, 1 - SEEY ); + const tripoint_bub_ms player_location = get_player_character().pos_bub(); + const point_bub_ms origin_p = target.xy() + point( 1 - SEEX, 1 - SEEY ); for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - const tripoint tmp_p( x, y, target.z ); - const tripoint map_p = origin_p + tmp_p; + const tripoint_omt_ms tmp_p( x, y, target.z() ); + const tripoint_bub_ms map_p = origin_p + tmp_p.raw(); g->draw_radiation_override( tripoint_bub_ms( map_p ), tmpmap.get_radiation( tmp_p ) ); // scent is managed in `game` instead of `map`, so there's no override for it // temperature is managed in `game` instead of `map`, so there's no override for it @@ -637,7 +637,7 @@ void editmap::draw_main_ui_overlay() g->draw_trap_override( map_p, tmpmap.tr_at( tmp_p ).loadid ); g->draw_field_override( map_p, tmpmap.field_at( tmp_p ).displayed_field_type() ); const maptile &tile = tmpmap.maptile_at( tmp_p ); - if( tmpmap.sees_some_items( tmp_p, player_location - origin_p ) ) { + if( tmpmap.sees_some_items( tmp_p, tripoint_omt_ms( ( player_location - origin_p ).raw() ) ) ) { const item &itm = tile.get_uppermost_item(); const mtype *const mon = itm.get_mtype(); g->draw_item_override( map_p, itm.typeId(), mon ? mon->id : mtype_id::NULL_ID(), @@ -664,14 +664,14 @@ void editmap::draw_main_ui_overlay() } } // int: count, bool: more than 1 spawn data - std::map> spawns; + std::map> spawns; for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *sm = tmpmap.get_submap_at_grid( { x, y, target.z } ); + submap *sm = tmpmap.get_submap_at_grid( { x, y, target.z()} ); if( sm ) { - const tripoint sm_origin = origin_p + tripoint( x * SEEX, y * SEEY, target.z ); + const tripoint_bub_ms sm_origin = origin_p + tripoint( x * SEEX, y * SEEY, target.z() ); for( const spawn_point &sp : sm->spawns ) { - const tripoint spawn_p = sm_origin + sp.pos; + const tripoint_bub_ms spawn_p = sm_origin + sp.pos; const auto spawn_it = spawns.find( spawn_p ); if( spawn_it == spawns.end() ) { const Creature::Attitude att = sp.friendly ? Creature::Attitude::FRIENDLY : Creature::Attitude::ANY; @@ -691,7 +691,7 @@ void editmap::draw_main_ui_overlay() } else { #endif hilights["mapgentgt"].draw( *this, true ); - drawsq_params params = drawsq_params().center( tripoint( SEEX - 1, SEEY - 1, target.z ) ); + drawsq_params params = drawsq_params().center( tripoint_bub_ms( SEEX - 1, SEEY - 1, target.z() ) ); for( const tripoint &p : tmpmap.points_on_zlevel() ) { tmpmap.drawsq( g->w_terrain, p, params ); } @@ -724,7 +724,8 @@ void editmap::update_view_with_help( const std::string &txt, const std::string & int off = 1; draw_border( w_info ); - mvwprintz( w_info, point( 2, 0 ), c_light_gray, "< %d,%d,%d >", target.x, target.y, target.z ); + mvwprintz( w_info, point( 2, 0 ), c_light_gray, "< %d,%d,%d >", target.x(), target.y(), + target.z() ); mvwputch( w_info, point( 2, off ), terrain_type.color(), terrain_type.symbol() ); mvwprintw( w_info, point( 4, off ), _( "%d: %s; move cost %d" ), here.ter( target ).to_i(), @@ -742,19 +743,19 @@ void editmap::update_view_with_help( const std::string &txt, const std::string & ); off++; // 3 } - const level_cache &map_cache = here.get_cache( target.z ); + const level_cache &map_cache = here.get_cache( target.z() ); Character &player_character = get_player_character(); const std::string u_see_msg = player_character.sees( target ) ? _( "yes" ) : _( "no" ); mvwprintw( w_info, point( 1, off++ ), _( "dist: %d u_see: %s veh: %s scent: %d" ), - rl_dist( player_character.pos(), target ), u_see_msg, veh_msg, get_scent().get( target ) ); + rl_dist( player_character.pos_bub(), target ), u_see_msg, veh_msg, get_scent().get( target ) ); mvwprintw( w_info, point( 1, off++ ), _( "sight_range: %d, noon_sight_range: %d," ), player_character.sight_range( g->light_level( player_character.posz() ) ), player_character.sight_range( sun_moon_light_at_noon_near( calendar::turn ) ) ); mvwprintw( w_info, point( 1, off++ ), _( "cache{transp:%.4f seen:%.4f cam:%.4f}" ), - map_cache.transparency_cache[target.x][target.y], - map_cache.seen_cache[target.x][target.y], - map_cache.camera_cache[target.x][target.y] + map_cache.transparency_cache[target.x()][target.y()], + map_cache.seen_cache[target.x()][target.y()], + map_cache.camera_cache[target.x()][target.y()] ); map::apparent_light_info al = map::apparent_light_helper( map_cache, tripoint_bub_ms( target ) ); int apparent_light = static_cast( @@ -765,7 +766,7 @@ void editmap::update_view_with_help( const std::string &txt, const std::string & static_cast( here.has_floor( target ) ) ); mvwprintw( w_info, point( 1, off++ ), _( "light_at: %s" ), - map_cache.lm[target.x][target.y].to_string() ); + map_cache.lm[target.x()][target.y()].to_string() ); mvwprintw( w_info, point( 1, off++ ), _( "apparent light: %.5f (%d)" ), al.apparent_light, apparent_light ); std::string extras; @@ -893,22 +894,22 @@ std::string info_title() } template -static T_id feature( const tripoint &p ); +static T_id feature( const tripoint_bub_ms &p ); template<> -ter_id feature( const tripoint &p ) +ter_id feature( const tripoint_bub_ms &p ) { return get_map().ter( p ); } template<> -furn_id feature( const tripoint &p ) +furn_id feature( const tripoint_bub_ms &p ) { return get_map().furn( p ); } template<> -trap_id feature( const tripoint &p ) +trap_id feature( const tripoint_bub_ms &p ) { return get_map().tr_at( p ).loadid; } @@ -981,33 +982,33 @@ std::string describe( const trap &type ) } template -static void draw_override( const tripoint &p, const T_id &id ); +static void draw_override( const tripoint_bub_ms &p, const T_id &id ); template<> -void draw_override( const tripoint &p, const ter_id &id ) +void draw_override( const tripoint_bub_ms &p, const ter_id &id ) { g->draw_terrain_override( p, id ); } template<> -void draw_override( const tripoint &p, const furn_id &id ) +void draw_override( const tripoint_bub_ms &p, const furn_id &id ) { g->draw_furniture_override( p, id ); } template<> -void draw_override( const tripoint &p, const trap_id &id ) +void draw_override( const tripoint_bub_ms &p, const trap_id &id ) { g->draw_trap_override( p, id ); } template -static void apply( const T_t &t, shapetype editshape, const tripoint &target, - const tripoint &origin, const std::vector &target_list ); +static void apply( const T_t &t, shapetype editshape, const tripoint_bub_ms &target, + const tripoint_bub_ms &origin, const std::vector &target_list ); template<> -void apply( const ter_t &t, const shapetype editshape, const tripoint &target, - const tripoint &origin, const std::vector &target_list ) +void apply( const ter_t &t, const shapetype editshape, const tripoint_bub_ms &target, + const tripoint_bub_ms &origin, const std::vector &target_list ) { bool isvert = false; bool doalt = false; @@ -1024,21 +1025,21 @@ void apply( const ter_t &t, const shapetype editshape, const tripoint &ta } if( teralt != undefined_ter_id ) { if( isvert ) { - alta = target.y; - altb = origin.y; + alta = target.y(); + altb = origin.y(); } else { - alta = target.x; - altb = origin.x; + alta = target.x(); + altb = origin.x(); } doalt = true; } } map &here = get_map(); - for( const tripoint &elem : target_list ) { + for( const tripoint_bub_ms &elem : target_list ) { ter_id wter = sel_ter; if( doalt ) { - int coord = isvert ? elem.y : elem.x; + int coord = isvert ? elem.y() : elem.x(); if( coord == alta || coord == altb ) { wter = teralt; } @@ -1048,22 +1049,22 @@ void apply( const ter_t &t, const shapetype editshape, const tripoint &ta } template<> -void apply( const furn_t &t, const shapetype, const tripoint &, - const tripoint &, const std::vector &target_list ) +void apply( const furn_t &t, const shapetype, const tripoint_bub_ms &, + const tripoint_bub_ms &, const std::vector &target_list ) { const furn_id sel_frn = t.id.id(); map &here = get_map(); - for( const tripoint &elem : target_list ) { + for( const tripoint_bub_ms &elem : target_list ) { here.furn_set( elem, sel_frn ); } } template<> -void apply( const trap &t, const shapetype, const tripoint &, - const tripoint &, const std::vector &target_list ) +void apply( const trap &t, const shapetype, const tripoint_bub_ms &, + const tripoint_bub_ms &, const std::vector &target_list ) { map &here = get_map(); - for( const tripoint &elem : target_list ) { + for( const tripoint_bub_ms &elem : target_list ) { here.trap_set( elem, t.loadid ); } } @@ -1132,7 +1133,7 @@ void editmap::edit_feature() do { const T_id override( emenu.selected ); if( override ) { - draw_target_override = [override]( const tripoint & p ) { + draw_target_override = [override]( const tripoint_bub_ms & p ) { draw_override( p, override ); }; } else { @@ -1250,7 +1251,7 @@ void editmap::edit_fld() do { const field_type_id override( fmenu.selected ); if( override ) { - draw_target_override = [override]( const tripoint & p ) { + draw_target_override = [override]( const tripoint_bub_ms & p ) { g->draw_field_override( p, override ); }; } else { @@ -1316,7 +1317,7 @@ void editmap::edit_fld() fsel_intensity--; } if( field_intensity != fsel_intensity || target_list.size() > 1 ) { - for( tripoint &elem : target_list ) { + for( tripoint_bub_ms &elem : target_list ) { const field_type_id fid = static_cast( idx ); field &t_field = here.get_field( elem ); field_entry *t_fld = t_field.find_field( fid ); @@ -1341,7 +1342,7 @@ void editmap::edit_fld() sel_field_intensity = fsel_intensity; } } else if( fmenu.ret == 0 ) { - for( tripoint &elem : target_list ) { + for( tripoint_bub_ms &elem : target_list ) { field &t_field = here.get_field( elem ); while( t_field.field_count() > 0 ) { const auto rmid = t_field.begin()->first; @@ -1582,13 +1583,13 @@ void editmap::edit_critter( Creature &critter ) */ void editmap::recalc_target( shapetype shape ) { - const int z = target.z; + const int z = target.z(); target_list.clear(); switch( shape ) { case editmap_circle: { int radius = rl_dist( origin, target ); map &here = get_map(); - for( const tripoint &p : here.points_in_radius( origin, radius ) ) { + for( const tripoint_bub_ms &p : here.points_in_radius( origin, radius ) ) { if( rl_dist( p, origin ) <= radius ) { if( here.inbounds( p ) ) { target_list.push_back( p ); @@ -1601,24 +1602,24 @@ void editmap::recalc_target( shapetype shape ) case editmap_rect: { point s; point e; - if( target.x < origin.x ) { - s.x = target.x; - e.x = origin.x; + if( target.x() < origin.x() ) { + s.x = target.x(); + e.x = origin.x(); } else { - s.x = origin.x; - e.x = target.x; + s.x = origin.x(); + e.x = target.x(); } - if( target.y < origin.y ) { - s.y = target.y; - e.y = origin.y; + if( target.y() < origin.y() ) { + s.y = target.y(); + e.y = origin.y(); } else { - s.y = origin.y; - e.y = target.y; + s.y = origin.y(); + e.y = target.y(); } for( int x = s.x; x <= e.x; x++ ) { for( int y = s.y; y <= e.y; y++ ) { if( shape == editmap_rect_filled || x == s.x || x == e.x || y == s.y || y == e.y ) { - const tripoint p( x, y, z ); + const tripoint_bub_ms p( x, y, z ); if( get_map().inbounds( p ) ) { target_list.push_back( p ); } @@ -1628,7 +1629,7 @@ void editmap::recalc_target( shapetype shape ) } break; case editmap_line: - target_list = line_to( origin, target, 0, 0 ); + target_list = line_to( origin, target ); break; } } @@ -1655,14 +1656,14 @@ static int limited_shift( int var, int &shift, int min, int max ) */ bool editmap::move_target( const std::string &action, int moveorigin ) { - tripoint mp; + tripoint_rel_ms mp; bool move_origin = moveorigin == 1 ? true : moveorigin == 0 ? false : moveall; if( eget_direction( mp, action ) ) { - target.x = limited_shift( target.x, mp.x, 0, MAPSIZE_X ); - target.y = limited_shift( target.y, mp.y, 0, MAPSIZE_Y ); + target.x() = limited_shift( target.x(), mp.x(), 0, MAPSIZE_X ); + target.y() = limited_shift( target.y(), mp.y(), 0, MAPSIZE_Y ); // OVERMAP_HEIGHT is the limit, not size of a 0 based vector, and limited_shift restricts to <, not <= - target.z = limited_shift( target.z, mp.z, -OVERMAP_DEPTH, OVERMAP_HEIGHT + 1 ); + target.z() = limited_shift( target.z(), mp.z(), -OVERMAP_DEPTH, OVERMAP_HEIGHT + 1 ); if( move_origin ) { origin += mp; } @@ -1676,8 +1677,8 @@ bool editmap::move_target( const std::string &action, int moveorigin ) */ int editmap::select_shape( shapetype shape, int mode ) { - tripoint orig = target; - tripoint origor = origin; + tripoint_bub_ms orig = target; + tripoint_bub_ms origor = origin; shapetype origshape = editshape; editshape = shape; input_context ctxt( "EDITMAP_SHAPE" ); @@ -1787,7 +1788,7 @@ int editmap::select_shape( shapetype shape, int mode ) target = origin; update = true; } else if( action == "SWAP" ) { - tripoint tmporigin = origin; + tripoint_bub_ms tmporigin = origin; origin = target; target = tmporigin; update = true; @@ -1838,7 +1839,7 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu ) // Coordinates of the overmap terrain that should be generated. const point_abs_omt omt_pos2 = tc.abs_omt(); - const tripoint_abs_omt omt_pos( omt_pos2, target.z ); + const tripoint_abs_omt omt_pos( omt_pos2, target.z() ); const oter_id &omt_ref = overmap_buffer.ter( omt_pos ); // Copy to store the original value, to restore it upon canceling const oter_id orig_oters = omt_ref; @@ -1919,22 +1920,22 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu ) } else if( gpmenu.ret == 1 ) { tmpmap.rotate( 1 ); } else if( gpmenu.ret == 2 ) { - const point target_sub( target.x / SEEX, target.y / SEEY ); + const point target_sub( target.x() / SEEX, target.y() / SEEY ); - here.set_transparency_cache_dirty( target.z ); - here.set_outside_cache_dirty( target.z ); - here.set_floor_cache_dirty( target.z ); - here.set_pathfinding_cache_dirty( target.z ); + here.set_transparency_cache_dirty( target.z() ); + here.set_outside_cache_dirty( target.z() ); + here.set_floor_cache_dirty( target.z() ); + here.set_pathfinding_cache_dirty( target.z() ); here.clear_vehicle_level_caches(); - here.clear_vehicle_list( target.z ); + here.clear_vehicle_list( target.z() ); for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { // Apply previewed mapgen to map. Since this is a function for testing, we try avoid triggering // functions that would alter the results - const tripoint dest_pos = target_sub + tripoint( x, y, target.z ); - const tripoint src_pos = tripoint{ x, y, target.z }; + const tripoint dest_pos = target_sub + tripoint( x, y, target.z() ); + const tripoint src_pos = tripoint{ x, y, target.z()}; submap *destsm = here.get_submap_at_grid( dest_pos ); submap *srcsm = tmpmap.get_submap_at_grid( src_pos ); @@ -1959,14 +1960,14 @@ void editmap::mapgen_preview( const real_coords &tc, uilist &gmenu ) // Since we cleared the vehicle cache of the whole z-level (not just the generate map), we add it back here for( int x = 0; x < here.getmapsize(); x++ ) { for( int y = 0; y < here.getmapsize(); y++ ) { - const tripoint dest_pos = tripoint( x, y, target.z ); + const tripoint dest_pos = tripoint( x, y, target.z() ); const submap *destsm = here.get_submap_at_grid( dest_pos ); if( destsm == nullptr ) { debugmsg( "Tried to update vehicle cache at (%d,%d,%d) but the submap is not loaded", dest_pos.x, dest_pos.y, dest_pos.z ); continue; } - here.update_vehicle_list( destsm, target.z ); // update real map's vcaches + here.update_vehicle_list( destsm, target.z() ); // update real map's vcaches } } @@ -2006,9 +2007,9 @@ vehicle *editmap::mapgen_veh_query( const tripoint_abs_omt &omt_tgt ) std::vector possible_vehicles; for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } ); + submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z()} ); if( destsm == nullptr ) { - debugmsg( "Tried to get vehicles at (%d,%d,%d) but the submap is not loaded", x, y, target.z ); + debugmsg( "Tried to get vehicles at (%d,%d,%d) but the submap is not loaded", x, y, target.z() ); continue; } for( const auto &vehicle : destsm->vehicles ) { @@ -2043,9 +2044,9 @@ bool editmap::mapgen_veh_destroy( const tripoint_abs_omt &omt_tgt, vehicle *car_ target_bay.load( omt_tgt, false ); for( int x = 0; x < 2; x++ ) { for( int y = 0; y < 2; y++ ) { - submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z } ); + submap *destsm = target_bay.get_submap_at_grid( { x, y, target.z()} ); if( destsm == nullptr ) { - debugmsg( "Tried to destroy vehicle at (%d,%d,%d) but the submap is not loaded", x, y, target.z ); + debugmsg( "Tried to destroy vehicle at (%d,%d,%d) but the submap is not loaded", x, y, target.z() ); continue; } for( auto &z : destsm->vehicles ) { @@ -2076,7 +2077,7 @@ void editmap::mapgen_retarget() // Needed for timeout to be useful ctxt.register_action( "ANY_INPUT" ); std::string action; - tripoint origm = target; + tripoint_bub_ms origm = target; shared_ptr_fast editmap_cb = draw_cb_container().create_or_get(); shared_ptr_fast current_ui = create_or_get_ui_adaptor(); @@ -2098,17 +2099,17 @@ void editmap::mapgen_retarget() action = ctxt.handle_input( get_option( "BLINK_SPEED" ) ); if( const std::optional vec = ctxt.get_direction( action ) ) { point vec_ms = omt_to_ms_copy( vec->xy() ); - tripoint ptarget = target + vec_ms; + tripoint_bub_ms ptarget = target + vec_ms; if( get_map().inbounds( ptarget ) && get_map().inbounds( ptarget + point( SEEX, SEEY ) ) ) { target = ptarget; target_list.clear(); - for( int x = target.x - SEEX + 1; x < target.x + SEEX + 1; x++ ) { - for( int y = target.y - SEEY + 1; y < target.y + SEEY + 1; y++ ) { - if( x == target.x - SEEX + 1 || x == target.x + SEEX || - y == target.y - SEEY + 1 || y == target.y + SEEY ) { - target_list.emplace_back( x, y, target.z ); + for( int x = target.x() - SEEX + 1; x < target.x() + SEEX + 1; x++ ) { + for( int y = target.y() - SEEY + 1; y < target.y() + SEEY + 1; y++ ) { + if( x == target.x() - SEEX + 1 || x == target.x() + SEEX || + y == target.y() - SEEY + 1 || y == target.y() + SEEY ) { + target_list.emplace_back( x, y, target.z() ); } } } @@ -2162,19 +2163,19 @@ void editmap::edit_mapgen() do { tc.fromabs( here.getabs( target.xy() ) ); - point omt_lpos = here.getlocal( tc.begin_om_pos() ); - tripoint om_ltarget = omt_lpos + tripoint( -1 + SEEX, -1 + SEEY, target.z ); + point_bub_ms omt_lpos = here.bub_from_abs( point_abs_ms( tc.begin_om_pos() ) ); + tripoint_bub_ms om_ltarget = omt_lpos + tripoint( -1 + SEEX, -1 + SEEY, target.z() ); - if( target.x != om_ltarget.x || target.y != om_ltarget.y ) { + if( target.x() != om_ltarget.x() || target.y() != om_ltarget.y() ) { target = om_ltarget; tc.fromabs( here.getabs( target.xy() ) ); } target_list.clear(); - for( int x = target.x - SEEX + 1; x < target.x + SEEX + 1; x++ ) { - for( int y = target.y - SEEY + 1; y < target.y + SEEY + 1; y++ ) { - if( x == target.x - SEEX + 1 || x == target.x + SEEX || - y == target.y - SEEY + 1 || y == target.y + SEEY ) { - target_list.emplace_back( x, y, target.z ); + for( int x = target.x() - SEEX + 1; x < target.x() + SEEX + 1; x++ ) { + for( int y = target.y() - SEEY + 1; y < target.y() + SEEY + 1; y++ ) { + if( x == target.x() - SEEX + 1 || x == target.x() + SEEX || + y == target.y() - SEEY + 1 || y == target.y() + SEEY ) { + target_list.emplace_back( x, y, target.z() ); } } } @@ -2215,7 +2216,7 @@ void editmap::cleartmpmap( tinymap &tmpmap ) const smap = nullptr; } - level_cache &ch = tmpmap.get_cache( target.z ); + level_cache &ch = tmpmap.get_cache( target.z() ); ch.clear_vehicle_cache(); ch.vehicle_list.clear(); ch.zone_vehicles.clear(); diff --git a/src/editmap.h b/src/editmap.h index 6f65bd86962df..281e005580ca3 100644 --- a/src/editmap.h +++ b/src/editmap.h @@ -33,7 +33,7 @@ struct editmap_hilight { std::vector blink_interval; int cur_blink = 0; nc_color color; - std::map points; + std::map points; nc_color( *getbg )( const nc_color & ); void setup() { getbg = color == c_red ? &red_background : @@ -47,9 +47,9 @@ struct editmap_hilight { class editmap { public: - tripoint pos2screen( const tripoint &p ); - bool eget_direction( tripoint &p, const std::string &action ) const; - std::optional edit(); + tripoint pos2screen( const tripoint_bub_ms &p ); + bool eget_direction( tripoint_rel_ms &p, const std::string &action ) const; + std::optional edit(); void uber_draw_ter( const catacurses::window &w, map *m ); void update_view_with_help( const std::string &txt, const std::string &title ); @@ -77,14 +77,14 @@ class editmap int sel_field; int sel_field_intensity; - tripoint target; - tripoint origin; + tripoint_bub_ms target; + tripoint_bub_ms origin; bool moveall; bool refresh_mplans; shapetype editshape; - std::vector target_list; - std::function draw_target_override; + std::vector target_list; + std::function draw_target_override; std::map hilights; bool blink; bool altblink; diff --git a/src/game.cpp b/src/game.cpp index 9595e3c56b6bd..34b9be63b7d98 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4110,7 +4110,7 @@ void game::draw_critter( const Creature &critter, const tripoint ¢er ) return; } if( u.sees( critter ) || &critter == &u ) { - critter.draw( w_terrain, center.xy(), false ); + critter.draw( w_terrain, point_bub_ms( center.xy() ), false ); return; } @@ -6408,7 +6408,7 @@ void game::peek( const tripoint &p ) } //////////////////////////////////////////////////////////////////////////////////////////// -std::optional game::look_debug() +std::optional game::look_debug() { editmap edit; return edit.edit(); @@ -6424,7 +6424,7 @@ void game::draw_look_around_cursor( const tripoint &lp, const visibility_variabl return; } #endif - const tripoint view_center = u.pos() + u.view_offset; + const tripoint_bub_ms view_center = u.pos_bub() + u.view_offset; visibility_type visibility = visibility_type::HIDDEN; const bool inbounds = m.inbounds( lp ); if( inbounds ) { @@ -6463,7 +6463,7 @@ void game::draw_look_around_cursor( const tripoint &lp, const visibility_variabl break; } - const tripoint screen_pos = point( POSX, POSY ) + lp - view_center; + const tripoint screen_pos = point( POSX, POSY ) + lp - view_center.raw(); mvwputch( w_terrain, screen_pos.xy(), visibility_indicator_color, visibility_indicator ); } } diff --git a/src/game.h b/src/game.h index c09ddc4e87692..84d060e7c9f14 100644 --- a/src/game.h +++ b/src/game.h @@ -607,7 +607,7 @@ class game void peek(); void peek( const tripoint &p ); - std::optional look_debug(); + std::optional look_debug(); bool check_zone( const zone_type_id &type, const tripoint &where ) const; /** Checks whether or not there is a zone of particular type nearby */ diff --git a/src/line.cpp b/src/line.cpp index d9c8c4697bfcd..79f76874c77a7 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -8,6 +8,7 @@ #include "cata_assert.h" #include "enums.h" +//####include "line_coordinates.h" #include "math_defines.h" #include "output.h" #include "string_formatter.h" diff --git a/src/map.cpp b/src/map.cpp index e3f2f81af3626..85908686adeef 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2374,6 +2374,11 @@ std::string map::features( const tripoint &p ) const return result; } +std::string map::features( const tripoint_bub_ms &p ) const +{ + return map::features( p.raw() ); +} + int map::move_cost_internal( const furn_t &furniture, const ter_t &terrain, const field &field, const vehicle *veh, const int vpart ) const @@ -2700,6 +2705,11 @@ bool map::has_floor( const tripoint &p ) const !has_flag( ter_furn_flag::TFLAG_NO_FLOOR_WATER, p ); } +bool map::has_floor( const tripoint_bub_ms &p ) const +{ + return map::has_floor( p.raw() ); +} + bool map::has_floor_or_water( const tripoint &p ) const { if( !zlevels || p.z < -OVERMAP_DEPTH + 1 || p.z > OVERMAP_HEIGHT ) { @@ -3402,6 +3412,11 @@ bool map::is_outside( const tripoint &p ) const return outside_cache[p.x][p.y]; } +bool map::is_outside( const tripoint_bub_ms &p ) const +{ + return map::is_outside( p.raw() ); +} + bool map::is_last_ter_wall( const bool no_furn, const point &p, const point &max, const direction dir ) const { @@ -4912,6 +4927,11 @@ int map::get_radiation( const tripoint &p ) const return current_submap->get_radiation( l ); } +int map::get_radiation( const tripoint_bub_ms &p ) const +{ + return map::get_radiation( p.raw() ); +} + void map::set_radiation( const tripoint &p, const int value ) { if( !inbounds( p ) ) { @@ -5858,7 +5878,7 @@ bool map::sees_some_items( const tripoint &p, const Creature &who ) const return has_items( p ) && could_see_items( p, who.pos() ); } -bool map::sees_some_items( const tripoint &p, const tripoint &from ) const +bool map::sees_some_items( const tripoint_bub_ms &p, const tripoint_bub_ms &from ) const { return has_items( p ) && could_see_items( p, from ); } @@ -5887,6 +5907,11 @@ bool map::could_see_items( const tripoint &p, const tripoint &from ) const return true; } +bool map::could_see_items( const tripoint_bub_ms &p, const tripoint_bub_ms &from ) const +{ + return map::could_see_items( p.raw(), from.raw() ); +} + bool map::has_items( const tripoint &p ) const { if( !inbounds( p ) ) { @@ -6467,6 +6492,13 @@ int map::set_field_intensity( const tripoint &p, const field_type_id &type, return 0; } +int map::set_field_intensity( const tripoint_bub_ms &p, const field_type_id &type, + const int new_intensity, + bool isoffset ) +{ + return map::set_field_intensity( p.raw(), type, new_intensity, isoffset ); +} + time_duration map::get_field_age( const tripoint &p, const field_type_id &type ) const { const field_entry *field_ptr = field_at( p ).find_field( type ); @@ -7076,9 +7108,9 @@ void map::drawsq( const catacurses::window &w, const tripoint &p, return; } - const tripoint view_center = params.center(); - const int k = p.x + getmaxx( w ) / 2 - view_center.x; - const int j = p.y + getmaxy( w ) / 2 - view_center.y; + const tripoint_bub_ms view_center = params.center(); + const int k = p.x + getmaxx( w ) / 2 - view_center.x(); + const int j = p.y + getmaxy( w ) / 2 - view_center.y(); if( k < 0 || k >= getmaxx( w ) || j < 0 || j >= getmaxy( w ) ) { return; } @@ -9140,6 +9172,12 @@ tripoint_range tinymap::points_in_radius( tripoint_omt_ms( preliminary_result.max() ) ); } +maptile tinymap::maptile_at( const tripoint_omt_ms &p ) +{ + return map::maptile_at( rebase_bub( p ) ); +} + + // set up a map just long enough scribble on it // this tinymap should never, ever get saved fake_map::fake_map( const ter_id &ter_type ) @@ -9231,6 +9269,11 @@ const std::string &map::graffiti_at( const tripoint &p ) const return current_submap->get_graffiti( l ); } +const std::string &map::graffiti_at( const tripoint_bub_ms &p ) const +{ + return map::graffiti_at( p.raw() ); +} + bool map::has_graffiti_at( const tripoint &p ) const { if( !inbounds( p ) ) { @@ -9245,6 +9288,11 @@ bool map::has_graffiti_at( const tripoint &p ) const return current_submap->has_graffiti( l ); } +bool map::has_graffiti_at( const tripoint_bub_ms &p ) const +{ + return map::has_graffiti_at( p.raw() ); +} + int map::determine_wall_corner( const tripoint &p ) const { const std::bitset &test_connect_group = ter( p ).obj().connect_to_groups; @@ -9921,6 +9969,11 @@ field &map::get_field( const tripoint &p ) return field_at( p ); } +field &map::get_field( const tripoint_bub_ms &p ) +{ + return field_at( p ); +} + void map::creature_on_trap( Creature &c, const bool may_avoid ) const { // gliding or boarded in a vehicle means the player is above the trap @@ -10595,11 +10648,11 @@ std::vector map::get_haulable_items( const tripoint &pos ) return target_items; } -tripoint drawsq_params::center() const +tripoint_bub_ms drawsq_params::center() const { - if( view_center == tripoint_min ) { + if( view_center.raw() == tripoint_min ) { avatar &player_character = get_avatar(); - return player_character.pos() + player_character.view_offset; + return player_character.pos_bub() + player_character.view_offset; } else { return view_center; } diff --git a/src/map.h b/src/map.h index 976964f8c745e..c383892c28174 100644 --- a/src/map.h +++ b/src/map.h @@ -167,7 +167,7 @@ struct bash_params { /** Draw parameters used by map::drawsq() and similar methods. */ struct drawsq_params { private: - tripoint view_center = tripoint_min; + tripoint_bub_ms view_center = tripoint_bub_ms( tripoint_min ); ter_str_id ter_override = ter_str_id::NULL_ID(); furn_str_id furn_override = furn_str_id::NULL_ID(); bool do_highlight = false; @@ -270,15 +270,15 @@ struct drawsq_params { * Default: uses avatar's current view center. */ //@{ - constexpr drawsq_params ¢er( const tripoint &p ) { + constexpr drawsq_params ¢er( const tripoint_bub_ms &p ) { view_center = p; return *this; } constexpr drawsq_params ¢er_at_avatar() { - view_center = tripoint_min; + view_center = tripoint_bub_ms( tripoint_min ); return *this; } - tripoint center() const; + tripoint_bub_ms center() const; //@} /** @@ -539,6 +539,7 @@ class map const_maptile maptile_at( const tripoint &p ) const; const_maptile maptile_at( const tripoint_bub_ms &p ) const; + // TODO: Get rid of untyped overload maptile maptile_at( const tripoint &p ); maptile maptile_at( const tripoint_bub_ms &p ); private: @@ -969,15 +970,18 @@ class map * - check for CONTAINER flag (makes items only visible when * the creature is at p or at an adjacent square). */ + // TODO: Get rid of untyped overload bool sees_some_items( const tripoint &p, const Creature &who ) const; - bool sees_some_items( const tripoint &p, const tripoint &from ) const; + bool sees_some_items( const tripoint_bub_ms &p, const tripoint_bub_ms &from ) const; /** * Check if the creature could see items at p if there were * any items. This is similar to @ref sees_some_items, but it * does not check that there are actually any items. */ bool could_see_items( const tripoint &p, const Creature &who ) const; + // TODO: Get rid of untyped overload bool could_see_items( const tripoint &p, const tripoint &from ) const; + bool could_see_items( const tripoint_bub_ms &p, const tripoint_bub_ms &from ) const; /** * Checks for existence of items. Faster than i_at(p).empty */ @@ -1001,7 +1005,9 @@ class map // Flags // Words relevant to terrain (sharp, etc) + // TODO: Get rid of untyped overload std::string features( const tripoint &p ) const; + std::string features( const tripoint_bub_ms &p ) const; std::string features( const point &p ) { return features( tripoint( p, abs_sub.z() ) ); } @@ -1126,7 +1132,9 @@ class map make_rubble( p, furn_str_id( "f_rubble" ), false, ter_str_id( "t_dirt" ).id(), false ); } + // TODO: Get rid of untyped overload bool is_outside( const tripoint &p ) const; + bool is_outside( const tripoint_bub_ms &p ) const; bool is_outside( const point &p ) const { return is_outside( tripoint( p, abs_sub.z() ) ); } @@ -1286,7 +1294,9 @@ class map void delete_signage( const tripoint_bub_ms &p ); // Radiation + // TODO: Get rid of untyped overload int get_radiation( const tripoint &p ) const; + int get_radiation( const tripoint_bub_ms &p ) const; void set_radiation( const tripoint &p, int value ); void set_radiation( const point &p, const int value ) { set_radiation( tripoint( p, abs_sub.z() ), value ); @@ -1657,8 +1667,11 @@ class map * if false, the existing intensity is ignored and overridden. * @return resulting intensity, or 0 for not present (either removed or not created at all). */ + // TODO: Get rid of untyped overload int set_field_intensity( const tripoint &p, const field_type_id &type, int new_intensity, bool isoffset = false ); + int set_field_intensity( const tripoint_bub_ms &p, const field_type_id &type, int new_intensity, + bool isoffset = false ); // returns true, if there **might** be a field at `p` // if false, there's no fields at `p` @@ -1762,8 +1775,12 @@ class map basecamp hoist_submap_camp( const tripoint &p ); bool point_within_camp( const tripoint &point_check ) const; // Graffiti + // TODO: Get rid of untyped overload bool has_graffiti_at( const tripoint &p ) const; + bool has_graffiti_at( const tripoint_bub_ms &p ) const; + // TODO: Get rid of untyped oveload const std::string &graffiti_at( const tripoint &p ) const; + const std::string &graffiti_at( const tripoint_bub_ms &p ) const; void set_graffiti( const tripoint &p, const std::string &contents ); void delete_graffiti( const tripoint &p ); @@ -1785,7 +1802,9 @@ class map // Returns true if terrain at p has NO flag ter_furn_flag::TFLAG_NO_FLOOR // and ter_furn_flag::TFLAG_NO_FLOOR_WATER, // if we're not in z-levels mode or if we're at lowest level + // TODO: Get rid of untyped overload bool has_floor( const tripoint &p ) const; + bool has_floor( const tripoint_bub_ms &p ) const; bool has_floor_or_water( const tripoint &p ) const; /** Does this tile support vehicles and furniture above it */ bool supports_above( const tripoint &p ) const; @@ -1905,12 +1924,17 @@ class map // TODO: fix point types (remove the first overload) tripoint_abs_ms getglobal( const tripoint &p ) const; tripoint_abs_ms getglobal( const tripoint_bub_ms &p ) const; + // TODO: Get rid of untyped overload point getabs( const point &p ) const { return getabs( tripoint( p, abs_sub.z() ) ).xy(); } + point getabs( const point_bub_ms &p ) const { + return getabs( tripoint_bub_ms( p, abs_sub.z() ) ).xy(); + } /** * Inverse of @ref getabs */ + // TODO: Get rid of these and use bub_from_abs instead tripoint getlocal( const tripoint &p ) const; tripoint getlocal( const tripoint_abs_ms &p ) const; point getlocal( const point &p ) const { @@ -1919,6 +1943,9 @@ class map // TODO: fix point types (remove the first overload) tripoint_bub_ms bub_from_abs( const tripoint &p ) const; tripoint_bub_ms bub_from_abs( const tripoint_abs_ms &p ) const; + point_bub_ms bub_from_abs( const point_abs_ms &p ) const { + return bub_from_abs( tripoint_abs_ms( p, abs_sub.z() ) ).xy(); + } bool inbounds( const tripoint &p ) const; bool inbounds( const tripoint_bub_ms &p ) const; bool inbounds( const tripoint_abs_ms &p ) const; @@ -2095,7 +2122,9 @@ class map void set_abs_sub( const tripoint_abs_sm &p ); private: + // TODO: Get rid of untyped overload field &get_field( const tripoint &p ); + field &get_field( const tripoint_bub_ms &p ); /** * Get the submap pointer with given index in @ref grid, the index must be valid! @@ -2710,6 +2739,19 @@ class tinymap : private map bool is_outside( const tripoint &p ) const { return map::is_outside( p ); // TODO: Make it typed } + int get_radiation( const tripoint_omt_ms &p ) const { + return map::get_radiation( rebase_bub( p ) ); + } + bool has_graffiti_at( const tripoint_omt_ms &p ) const { + return map::has_graffiti_at( rebase_bub( p ) ); + } + field &field_at( const tripoint_omt_ms &p ) { + return map::field_at( rebase_bub( p ) ); + } + maptile maptile_at( const tripoint_omt_ms &p ); + bool sees_some_items( const tripoint_omt_ms &p, const tripoint_omt_ms &from ) const { + return map::sees_some_items( rebase_bub( p ), rebase_bub( from ) ); + } using map::rotate; using map::mirror; diff --git a/src/ranged.cpp b/src/ranged.cpp index 4fc81dc3fe5f1..93d8bd8f5ddd1 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -3476,14 +3476,14 @@ bool target_ui::action_aim_and_shoot( const std::string &action ) void target_ui::draw_terrain_overlay() { - tripoint center = you->pos() + you->view_offset; + tripoint_bub_ms center = you->pos_bub() + you->view_offset; // Removes parts that don't belong to currently visible Z level const auto filter_this_z = [¢er]( const std::vector &traj ) { std::vector this_z = traj; this_z.erase( std::remove_if( this_z.begin(), this_z.end(), [¢er]( const tripoint & p ) { - return p.z != center.z; + return p.z != center.z(); } ), this_z.end() ); return this_z; }; @@ -3506,11 +3506,11 @@ void target_ui::draw_terrain_overlay() // we can draw it even if the player can't see some parts points.erase( dst ); // Workaround for fake cursor on TILES std::vector l( points.begin(), points.end() ); - if( dst.z == center.z ) { + if( dst.z == center.z() ) { // Workaround for fake cursor bug on TILES l.push_back( dst ); } - g->draw_line( src, center, l, true ); + g->draw_line( src, center.raw(), l, true ); } // Draw trajectory @@ -3520,12 +3520,12 @@ void target_ui::draw_terrain_overlay() // Draw a highlighted trajectory only if we can see the endpoint. // Provides feedback to the player, but avoids leaking information // about tiles they can't see. - g->draw_line( dst, center, this_z ); + g->draw_line( dst, center.raw(), this_z ); } // Since draw_line does nothing if destination is not visible, // cursor also disappears. Draw it explicitly. - if( dst.z == center.z ) { + if( dst.z == center.z() ) { g->draw_cursor( dst ); } @@ -3533,7 +3533,7 @@ void target_ui::draw_terrain_overlay() if( mode == TargetMode::Spell ) { drawsq_params params = drawsq_params().highlight( true ).center( center ); for( const tripoint &tile : spell_aoe ) { - if( tile.z != center.z ) { + if( tile.z != center.z() ) { continue; } #ifdef TILES diff --git a/src/scent_map.cpp b/src/scent_map.cpp index 464bdc53cbd70..5ad86379523af 100644 --- a/src/scent_map.cpp +++ b/src/scent_map.cpp @@ -100,6 +100,11 @@ int scent_map::get( const tripoint &p ) const return 0; } +int scent_map::get( const tripoint_bub_ms &p ) const +{ + return scent_map::get( p.raw() ); +} + void scent_map::set( const tripoint &p, int value, const scenttype_id &type ) { if( inbounds( p ) ) { diff --git a/src/scent_map.h b/src/scent_map.h index 7230599a6f871..e2fe0c57d8cb3 100644 --- a/src/scent_map.h +++ b/src/scent_map.h @@ -9,6 +9,7 @@ #include #include "calendar.h" +#include "coordinates.h" #include "enums.h" // IWYU pragma: keep #include "game_constants.h" #include "point.h" @@ -74,7 +75,9 @@ class scent_map */ /**@{*/ void set( const tripoint &p, int value, const scenttype_id &type = scenttype_id() ); + // TODO: Get rid of untyped override int get( const tripoint &p ) const; + int get( const tripoint_bub_ms &p ) const; /**@}*/ void set_unsafe( const tripoint &p, int value, const scenttype_id &type = scenttype_id() ); int get_unsafe( const tripoint &p ) const; diff --git a/src/wish.cpp b/src/wish.cpp index 20cfc62eaa532..bfc3abcda4bdf 100644 --- a/src/wish.cpp +++ b/src/wish.cpp @@ -1136,6 +1136,11 @@ void debug_menu::wishitem( Character *you, const tripoint &pos ) } while( wmenu.ret >= 0 ); } +void debug_menu::wishitem( Character *you, const tripoint_bub_ms &pos ) +{ + debug_menu::wishitem( you, pos.raw() ); +} + void debug_menu::wishskill( Character *you, bool change_theory ) { const int skoffset = 1;