diff --git a/src/action.cpp b/src/action.cpp index d974b90c7c6e1..d69fca3804e46 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -1192,7 +1192,13 @@ std::optional choose_direction_rel_ms( const std::string &messa std::optional choose_adjacent( const std::string &message, const bool allow_vertical ) { - return choose_adjacent( get_player_character().pos(), message, allow_vertical ); + const std::optional temp = choose_adjacent( get_player_character().pos_bub(), + message, allow_vertical ); + std::optional result; + if( temp.has_value() ) { + result = temp.value().raw(); + } + return result; } std::optional choose_adjacent_bub( const std::string &message, @@ -1250,17 +1256,7 @@ std::optional choose_adjacent( const tripoint_bub_ms &pos, } } -std::optional choose_adjacent_highlight( const std::string &message, - const std::string &failure_message, const action_id action, - const bool allow_vertical, const bool allow_autoselect ) -{ - const std::function f = [&action]( const tripoint & p ) { - return can_interact_at( action, tripoint_bub_ms( p ) ); - }; - return choose_adjacent_highlight( message, failure_message, f, allow_vertical, allow_autoselect ); -} - -std::optional choose_adjacent_highlight_bub_ms( const std::string &message, +std::optional choose_adjacent_highlight( const std::string &message, const std::string &failure_message, const action_id action, const bool allow_vertical, const bool allow_autoselect ) { @@ -1270,14 +1266,6 @@ std::optional choose_adjacent_highlight_bub_ms( const std::stri return choose_adjacent_highlight( message, failure_message, f, allow_vertical, allow_autoselect ); } -std::optional choose_adjacent_highlight( const std::string &message, - const std::string &failure_message, const std::function &allowed, - const bool allow_vertical, const bool allow_autoselect ) -{ - return choose_adjacent_highlight( get_avatar().pos(), message, failure_message, allowed, - allow_vertical, allow_autoselect ); -} - std::optional choose_adjacent_highlight( const std::string &message, const std::string &failure_message, const std::function &allowed, const bool allow_vertical, const bool allow_autoselect ) @@ -1286,47 +1274,6 @@ std::optional choose_adjacent_highlight( const std::string &mes allow_vertical, allow_autoselect ); } -std::optional choose_adjacent_highlight( const tripoint &pos, const std::string &message, - const std::string &failure_message, const std::function &allowed, - bool allow_vertical, bool allow_autoselect ) -{ - std::vector valid; - map &here = get_map(); - if( allowed ) { - for( const tripoint_bub_ms &pos : here.points_in_radius( tripoint_bub_ms( pos ), 1 ) ) { - if( allowed( pos.raw() ) ) { - valid.emplace_back( pos ); - } - } - } - - const bool auto_select = allow_autoselect && get_option( "AUTOSELECT_SINGLE_VALID_TARGET" ); - if( valid.empty() && auto_select ) { - add_msg( failure_message ); - return std::nullopt; - } else if( valid.size() == 1 && auto_select ) { - return valid.back().raw(); - } - - shared_ptr_fast hilite_cb; - if( !valid.empty() ) { - hilite_cb = make_shared_fast( [&]() { - for( const tripoint_bub_ms &pos : valid ) { - here.drawsq( g->w_terrain, pos, drawsq_params().highlight( true ) ); - } - } ); - g->add_draw_callback( hilite_cb ); - } - - const std::optional chosen = choose_adjacent( tripoint_bub_ms( pos ), message, - allow_vertical ); - if( std::find( valid.begin(), valid.end(), chosen ) != valid.end() ) { - return std::optional( chosen.value().raw() ); - } - - return std::nullopt; -} - std::optional choose_adjacent_highlight( const tripoint_bub_ms &pos, const std::string &message, const std::string &failure_message, const std::function &allowed, diff --git a/src/action.h b/src/action.h index c7c0afe125e91..9ac3efdc173e3 100644 --- a/src/action.h +++ b/src/action.h @@ -531,11 +531,7 @@ std::optional choose_direction_rel_ms( const std::string &messa * @param[in] allow_vertical Allows direction vector to have vertical component if true * @param[in] allow_autoselect Automatically select location if there's only one valid option and the appropriate setting is enabled */ -// TODO: Get rid of untyped version and change name of typed one. -std::optional choose_adjacent_highlight( const std::string &message, - const std::string &failure_message, action_id action, - bool allow_vertical = false, bool allow_autoselect = true ); -std::optional choose_adjacent_highlight_bub_ms( const std::string &message, +std::optional choose_adjacent_highlight( const std::string &message, const std::string &failure_message, action_id action, bool allow_vertical = false, bool allow_autoselect = true ); @@ -556,17 +552,9 @@ std::optional choose_adjacent_highlight_bub_ms( const std::stri * @param[in] allow_vertical Allows direction vector to have vertical component if true * @param[in] allow_autoselect Automatically select location if there's only one valid option and the appropriate setting is enabled */ -// TODO: Get rid of untyped overload. -std::optional choose_adjacent_highlight( const std::string &message, - const std::string &failure_message, const std::function &allowed, - bool allow_vertical = false, bool allow_autoselect = true ); std::optional choose_adjacent_highlight( const std::string &message, const std::string &failure_message, const std::function &allowed, bool allow_vertical = false, bool allow_autoselect = true ); -// TODO: Get rid of untyped overload. -std::optional choose_adjacent_highlight( const tripoint &pos, const std::string &message, - const std::string &failure_message, const std::function &allowed, - bool allow_vertical = false, bool allow_autoselect = true ); std::optional choose_adjacent_highlight( const tripoint_bub_ms &pos, const std::string &message, const std::string &failure_message, const std::function &allowed, diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 0ac4de7cbdc8f..5fcd1b8e36cf9 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1652,7 +1652,7 @@ void activity_handlers::fill_liquid_do_turn( player_activity *act, Character *yo liquid.charges = std::min( charges_per_second, liquid.charges ); const int original_charges = liquid.charges; if( liquid.has_temperature() && units::to_joule_per_gram( liquid.specific_energy ) < 0 ) { - liquid.set_item_temperature( std::max( get_weather().get_temperature( you->pos() ), + liquid.set_item_temperature( std::max( get_weather().get_temperature( you->pos_bub() ), temperatures::cold ) ); } diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 7ce0cc8db010d..cdac5da624277 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -173,7 +173,7 @@ static void drop_or_embed_projectile( const dealt_projectile_attack &attack ) const trap &tr = here.tr_at( pt ); if( tr.triggered_by_item( dropped_item ) ) { - tr.trigger( pt.raw(), dropped_item ); + tr.trigger( pt, dropped_item ); } } } @@ -314,7 +314,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, if( first ) { sfx::play_variant_sound( "bullet_hit", "hit_wall", sfx::get_heard_volume( target ), - sfx::get_heard_angle( target.raw() ) ); + sfx::get_heard_angle( target ) ); } // TODO: Z dispersion } @@ -554,7 +554,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, z.add_effect( effect_bounced, 1_turns ); projectile_attack( proj, tp, z.pos_bub(), dispersion, origin, in_veh ); sfx::play_variant_sound( "fire_gun", "bio_lightning_tail", - sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos_bub() ) ); } } diff --git a/src/bionics.cpp b/src/bionics.cpp index b69491e2d4087..35ffb41b560a4 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -710,7 +710,7 @@ void npc::check_or_use_weapon_cbm( const bionic_id &cbm_id ) if( is_armed() ) { stow_item( *weapon ); } - add_msg_if_player_sees( pos(), m_info, _( "%s activates their %s." ), + add_msg_if_player_sees( pos_bub(), m_info, _( "%s activates their %s." ), disp_name(), bio.info().name ); set_wielded_item( cbm_weapon ); @@ -1068,7 +1068,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics const oter_id &cur_om_ter = overmap_buffer.ter( global_omt_location() ); /* cache g->get_temperature( player location ) since it is used twice. No reason to recalc */ weather_manager &weather = get_weather(); - const units::temperature player_local_temp = weather.get_temperature( player_character.pos() ); + const units::temperature player_local_temp = weather.get_temperature( player_character.pos_bub() ); const int windpower = get_local_windpower( weather.windspeed + vehwindspeed, cur_om_ter, get_location(), weather.winddirection, g->is_sheltered( pos_bub() ) ); add_msg_if_player( m_info, _( "Temperature: %s." ), print_temperature( player_local_temp ) ); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index ddcc7cf23dac4..59c7e9c1fd36f 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1305,7 +1305,7 @@ static std::map display_npc_attack_potential() return effectiveness_map; } -void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int height, +void cata_tiles::draw( const point &dest, const tripoint_bub_ms ¢er, int width, int height, std::multimap &overlay_strings, color_block_overlay_container &color_blocks ) { @@ -1337,7 +1337,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int map &here = get_map(); const visibility_variables &cache = here.get_visibility_variables_cache(); - o = is_isometric() ? center.xy() : center.xy() - point( POSX, POSY ); + o = is_isometric() ? center.xy().raw() : center.xy().raw() - point( POSX, POSY ); op = dest; screentile_width = s.x; @@ -1368,7 +1368,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int ( you.posy() % SEEY ) + ( MAPSIZE - 1 ) * SEEY ); const int draw_min_z = std::max( you.posz() - max_draw_depth, -OVERMAP_DEPTH ); - const level_cache &ch = here.access_cache( center.z ); + const level_cache &ch = here.access_cache( center.z() ); // Map memory should be at least the size of the view range // so that new tiles can be memorized, and at least the size of the display @@ -1421,8 +1421,8 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int here.prev_o = o; you.prepare_map_memory_region( - here.getglobal( tripoint_bub_ms( min_mm_reg.x, min_mm_reg.y, center.z ) ), - here.getglobal( tripoint_bub_ms( max_mm_reg.x, max_mm_reg.y, center.z ) ) + here.getglobal( tripoint_bub_ms( min_mm_reg.x, min_mm_reg.y, center.z() ) ), + here.getglobal( tripoint_bub_ms( max_mm_reg.x, max_mm_reg.y, center.z() ) ) ); //set up a default tile for the edges outside the render area @@ -1489,7 +1489,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int creature_tracker &creatures = get_creature_tracker(); for( int row = min_row; row < max_row; row ++ ) { // Reserve columns on each row - for( int zlevel = center.z; zlevel >= draw_min_z; zlevel -- ) { + for( int zlevel = center.z(); zlevel >= draw_min_z; zlevel -- ) { here.draw_points_cache[zlevel][row].reserve( std::max( 0, max_col - min_col ) ); } for( int col = min_col; col < max_col; col ++ ) { @@ -1497,13 +1497,13 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( !temp.has_value() ) { continue; } - for( int zlevel = center.z; zlevel >= draw_min_z; zlevel -- ) { + for( int zlevel = center.z(); zlevel >= draw_min_z; zlevel -- ) { // todo: conversion slightly simplified, a couple of calls already use pos as tripoint_bub_ms const tripoint_bub_ms pos( point_bub_ms( temp.value() ), zlevel ); const tripoint_abs_ms pos_global = here.getglobal( pos ); const int &x = pos.x(); const int &y = pos.y(); - const bool is_center_z = zlevel == center.z; + const bool is_center_z = zlevel == center.z(); const level_cache &ch2 = here.access_cache( zlevel ); // light level is used for choosing between grayscale filter and normal lit tiles. @@ -1516,7 +1516,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( has_memory_at( pos_global ) ) { ll = lit_level::MEMORIZED; invisible[0] = true; - } else if( has_draw_override( pos.raw() ) ) { + } else if( has_draw_override( pos ) ) { ll = lit_level::DARK; invisible[0] = true; } else { @@ -1554,7 +1554,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } if( g->display_overlay_state( ACTION_DISPLAY_RADIATION ) ) { - const auto rad_override = radiation_override.find( tripoint_bub_ms( pos ) ); + const auto rad_override = radiation_override.find( pos ); const bool rad_overridden = rad_override != radiation_override.end(); if( rad_overridden || !invisible[0] ) { const int rad_value = rad_overridden ? rad_override->second : @@ -1572,8 +1572,8 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } if( g->display_overlay_state( ACTION_DISPLAY_NPC_ATTACK_POTENTIAL ) ) { - if( npc_attack_rating_map.count( tripoint_bub_ms( pos ) ) ) { - const int val = npc_attack_rating_map.at( tripoint_bub_ms( pos ) ); + if( npc_attack_rating_map.count( pos ) ) { + const int val = npc_attack_rating_map.at( pos ); short color; if( val <= 0 ) { color = catacurses::red; @@ -1591,7 +1591,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int // Add temperature value to the overlay_strings list for every visible tile when // displaying temperature if( g->display_overlay_state( ACTION_DISPLAY_TEMPERATURE ) && !invisible[0] ) { - const units::temperature temp_value = get_weather().get_temperature( pos.raw() ); + const units::temperature temp_value = get_weather().get_temperature( pos ); const float celsius_temp_value = units::to_celsius( temp_value ); short color; const short bold = 8; @@ -1664,7 +1664,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( g->display_overlay_state( ACTION_DISPLAY_LIGHTING ) ) { if( g->displaying_lighting_condition == 0 ) { - const float light = here.ambient_light_at( {x, y, center.z} ); + const float light = here.ambient_light_at( {x, y, center.z()} ); // note: lighting will be constrained in the [1.0, 11.0] range. int intensity = static_cast( std::max( 1.0, LIGHT_AMBIENT_LIT - light + 1.0 ) ) - 1; @@ -1673,7 +1673,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } if( g->display_overlay_state( ACTION_DISPLAY_TRANSPARENCY ) ) { - const float tr = here.light_transparency( tripoint_bub_ms{x, y, center.z} ); + const float tr = here.light_transparency( tripoint_bub_ms{x, y, center.z()} ); int intensity = tr <= LIGHT_TRANSPARENCY_SOLID ? 10 : static_cast ( ( tr - LIGHT_TRANSPARENCY_OPEN_AIR ) * 8 ); draw_debug_tile( intensity, string_format( "%.2f", tr ) ); @@ -1684,7 +1684,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int const visibility_type vis_type = here.get_visibility( ll, cache ); if( would_apply_vision_effects( vis_type ) ) { const Creature *critter = creatures.creature_at( pos, true ); - if( has_draw_override( pos.raw() ) || has_memory_at( pos_global ) || + if( has_draw_override( pos ) || has_memory_at( pos_global ) || ( critter && ( critter->has_flag( mon_flag_ALWAYS_VISIBLE ) || you.sees_with_specials( *critter ) ) ) ) { @@ -1745,7 +1745,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int // Legacy draw mode for( int row = min_row; row < max_row; row ++ ) { for( auto f : drawing_layers_legacy ) { - for( tile_render_info &p : here.draw_points_cache[center.z][row] ) { + for( tile_render_info &p : here.draw_points_cache[center.z()][row] ) { if( const tile_render_info::vision_effect * const var = std::get_if( &p.var ) ) { if( f == &cata_tiles::draw_terrain ) { @@ -1763,14 +1763,14 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int // Start drawing from the lowest visible z-level (some off-screen tiles // are considered visible here to simplify the logic.) int cur_zlevel = draw_min_z; - while( cur_zlevel <= center.z ) { + while( cur_zlevel <= center.z() ) { const half_open_rectangle &cur_any_tile_range = is_isometric() - ? z_any_tile_range[center.z - cur_zlevel] : top_any_tile_range; + ? z_any_tile_range[center.z() - cur_zlevel] : top_any_tile_range; // For each row for( int row = cur_any_tile_range.p_min.y; row < cur_any_tile_range.p_max.y; row ++ ) { // Set base height for each tile for( tile_render_info &p : here.draw_points_cache[cur_zlevel][row] ) { - p.com.height_3d = ( cur_zlevel - center.z ) * zlevel_height; + p.com.height_3d = ( cur_zlevel - center.z() ) * zlevel_height; } // For each layer for( auto f : drawing_layers ) { @@ -1791,7 +1791,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( f == &cata_tiles::draw_vpart_no_roof || f == &cata_tiles::draw_vpart_roof ) { int temp_height_3d = p.com.height_3d; // Reset height_3d to base when drawing vehicles - p.com.height_3d = ( cur_zlevel - center.z ) * zlevel_height; + p.com.height_3d = ( cur_zlevel - center.z() ) * zlevel_height; // Draw if( !( this->*f )( p.com.pos, ll, p.com.height_3d, invisible, false ) ) { // If no vpart drawn, revert height_3d changes @@ -1800,7 +1800,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } else if( f == &cata_tiles::draw_critter_at ) { // Draw if( !( this->*f )( p.com.pos, ll, p.com.height_3d, invisible, false ) && do_draw_shadow && - here.dont_draw_lower_floor( tripoint_bub_ms( p.com.pos ) ) ) { + here.dont_draw_lower_floor( p.com.pos ) ) { // Draw shadow of flying critters on bottom-most tile if no other critter drawn draw_critter_above( p.com.pos, ll, p.com.height_3d, invisible ); } @@ -1818,13 +1818,13 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int // display number of monsters to spawn in mapgen preview for( int row = top_any_tile_range.p_min.y; row < top_any_tile_range.p_max.y; row ++ ) { - for( const tile_render_info &p : here.draw_points_cache[center.z][row] ) { + for( const tile_render_info &p : here.draw_points_cache[center.z()][row] ) { const tile_render_info::sprite *const var = std::get_if( &p.var ); if( !var ) { continue; } - const auto mon_override = monster_override.find( tripoint_bub_ms( p.com.pos ) ); + const auto mon_override = monster_override.find( p.com.pos ); if( mon_override != monster_override.end() ) { const int count = std::get<1>( mon_override->second ); const bool more = std::get<2>( mon_override->second ); @@ -1833,7 +1833,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( more ) { text += "+"; } - overlay_strings.emplace( player_to_screen( p.com.pos.xy() ) + half_tile, + overlay_strings.emplace( player_to_screen( p.com.pos.xy().raw() ) + half_tile, formatted_text( text, catacurses::red, direction::NORTH ) ); } @@ -1862,7 +1862,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( is_isometric() && top_any_tile_range.contains( colrow ) ) { continue; } - const tripoint_bub_ms p( mem_x, mem_y, center.z ); + const tripoint_bub_ms p( mem_x, mem_y, center.z() ); lit_level lighting = ch.visibility_cache[p.x()][p.y()]; // `apply_vision_effects` does not memorize anything so we only need // to call `would_apply_vision_effects` here. @@ -1878,14 +1878,14 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } //calling draw to memorize (and only memorize) everything. //bypass cache check in case we learn something new about the terrain's connections - draw_terrain( p.raw(), lighting, height_3d, invisible, true ); + draw_terrain( p, lighting, height_3d, invisible, true ); if( here.memory_cache_dec_is_dirty( p ) ) { you.memorize_clear_decoration( here.getglobal( p ), "" ); - draw_furniture( p.raw(), lighting, height_3d, invisible, true ); - draw_trap( p.raw(), lighting, height_3d, invisible, true ); - draw_part_con( p.raw(), lighting, height_3d, invisible, true ); - draw_vpart_no_roof( p.raw(), lighting, height_3d, invisible, true ); - draw_vpart_roof( p.raw(), lighting, height_3d, invisible, true ); + draw_furniture( p, lighting, height_3d, invisible, true ); + draw_trap( p, lighting, height_3d, invisible, true ); + draw_part_con( p, lighting, height_3d, invisible, true ); + draw_vpart_no_roof( p, lighting, height_3d, invisible, true ); + draw_vpart_roof( p, lighting, height_3d, invisible, true ); here.memory_cache_dec_set_dirty( p, false ); } } @@ -1941,7 +1941,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int } else if( you.view_offset != tripoint_rel_ms::zero && !you.in_vehicle ) { // check to see if player is located at ter draw_from_id_string( "cursor", TILE_CATEGORY::NONE, empty_string, - tripoint( g->ter_view_p.raw().xy(), center.z ), 0, 0, lit_level::LIT, + tripoint( g->ter_view_p.raw().xy(), center.z() ), 0, 0, lit_level::LIT, false ); } if( you.controlling_vehicle ) { @@ -1949,7 +1949,7 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( indicator_offset ) { draw_from_id_string( "cursor", TILE_CATEGORY::NONE, empty_string, indicator_offset->raw().xy() + - tripoint( you.posx(), you.posy(), center.z ), + tripoint( you.posx(), you.posy(), center.z() ), 0, 0, lit_level::LIT, false ); } } @@ -1963,7 +1963,8 @@ void cata_tiles::set_draw_cache_dirty() get_map().draw_points_cache_dirty = true; } -void cata_tiles::draw_minimap( const point &dest, const tripoint ¢er, int width, int height ) +void cata_tiles::draw_minimap( const point &dest, const tripoint_bub_ms ¢er, int width, + int height ) { minimap->set_type( is_isometric() ? pixel_minimap_type::iso : pixel_minimap_type::ortho ); minimap->draw( SDL_Rect{ dest.x, dest.y, width, height }, center ); @@ -2601,7 +2602,7 @@ bool cata_tiles::draw_from_id_string_internal( const std::string &id, TILE_CATEG if( !tt ) { // Use fog overlay as fallback for transparent terrain if( category == TILE_CATEGORY::TERRAIN && !here.dont_draw_lower_floor( tripoint_bub_ms( pos ) ) ) { - draw_zlevel_overlay( pos, ll, height_3d ); + draw_zlevel_overlay( tripoint_bub_ms( pos ), ll, height_3d ); // t_open_air is plentiful at high z-levels // Skipping the rest of the fallback code will significantly improve performance @@ -3158,7 +3159,7 @@ bool cata_tiles::would_apply_vision_effects( const visibility_type visibility ) return visibility != visibility_type::CLEAR; } -bool cata_tiles::apply_vision_effects( const tripoint &pos, +bool cata_tiles::apply_vision_effects( const tripoint_bub_ms &pos, const visibility_type visibility, int &height_3d ) { @@ -3188,7 +3189,7 @@ bool cata_tiles::apply_vision_effects( const tripoint &pos, } // lighting is never rotated, though, could possibly add in random rotation? - draw_from_id_string( light_name, TILE_CATEGORY::LIGHTING, empty_string, pos, 0, 0, + draw_from_id_string( light_name, TILE_CATEGORY::LIGHTING, empty_string, pos.raw(), 0, 0, lit_level::LIT, false, height_3d ); return true; @@ -3273,7 +3274,7 @@ void cata_tiles::draw_square_below( const point &p, const nc_color &col, const i geometry->rect( renderer, sdlrect, sdlcol ); } -bool cata_tiles::draw_terrain_below( const tripoint &p, const lit_level, int &, +bool cata_tiles::draw_terrain_below( const tripoint_bub_ms &p, const lit_level, int &, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -3281,14 +3282,14 @@ bool cata_tiles::draw_terrain_below( const tripoint &p, const lit_level, int &, } map &here = get_map(); - const auto low_override = draw_below_override.find( tripoint_bub_ms( p ) ); + const auto low_override = draw_below_override.find( p ); const bool low_overridden = low_override != draw_below_override.end(); if( low_overridden ? !low_override->second : - ( invisible[0] || here.dont_draw_lower_floor( tripoint_bub_ms( p ) ) ) ) { + ( invisible[0] || here.dont_draw_lower_floor( p ) ) ) { return false; } - tripoint_bub_ms pbelow = tripoint_bub_ms( p + tripoint::below ); + tripoint_bub_ms pbelow = p + tripoint::below; nc_color col = c_dark_gray; const ter_t &curr_ter = here.ter( pbelow ).obj(); @@ -3317,16 +3318,16 @@ bool cata_tiles::draw_terrain_below( const tripoint &p, const lit_level, int &, return true; } -bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_terrain( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { map &here = get_map(); - const auto override = terrain_override.find( tripoint_bub_ms( p ) ); + const auto override = terrain_override.find( p ); const bool overridden = override != terrain_override.end(); bool neighborhood_overridden = overridden; if( !neighborhood_overridden ) { for( const point &dir : neighborhood ) { - if( terrain_override.find( tripoint_bub_ms( p + dir ) ) != terrain_override.end() ) { + if( terrain_override.find( p + dir ) != terrain_override.end() ) { neighborhood_overridden = true; break; } @@ -3346,11 +3347,11 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh const std::bitset &rotate_group = t.obj().rotate_to_groups; if( connect_group.any() ) { - get_connect_values( tripoint_bub_ms( p ), subtile, rotation, connect_group, rotate_group, {} ); + get_connect_values( p, subtile, rotation, connect_group, rotate_group, {} ); // re-memorize previously seen terrain in case new connections have been seen here.memory_cache_ter_set_dirty( p, true ); } else { - get_terrain_orientation( tripoint_bub_ms( p ), rotation, subtile, {}, invisible, rotate_group ); + get_terrain_orientation( p, rotation, subtile, {}, invisible, rotate_group ); // do something to get other terrain orientation values } if( here.memory_cache_ter_is_dirty( p ) ) { @@ -3360,7 +3361,7 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh if( !neighborhood_overridden ) { return memorize_only ? false - : draw_from_id_string( tname, TILE_CATEGORY::TERRAIN, empty_string, p, subtile, + : draw_from_id_string( tname, TILE_CATEGORY::TERRAIN, empty_string, p.raw(), subtile, rotation, ll, nv_goggles_activated, height_3d ); } } @@ -3376,10 +3377,10 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh const std::bitset &rotate_group = t2.obj().rotate_to_groups; if( connect_group.any() ) { - get_connect_values( tripoint_bub_ms( p ), subtile, rotation, connect_group, rotate_group, + get_connect_values( p, subtile, rotation, connect_group, rotate_group, terrain_override ); } else { - get_terrain_orientation( tripoint_bub_ms( p ), rotation, subtile, terrain_override, invisible, + get_terrain_orientation( p, rotation, subtile, terrain_override, invisible, rotate_group ); } const std::string &tname = t2.id().str(); @@ -3389,7 +3390,7 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh const bool nv = overridden ? false : nv_goggles_activated; return memorize_only ? false - : draw_from_id_string( tname, TILE_CATEGORY::TERRAIN, empty_string, p, subtile, + : draw_from_id_string( tname, TILE_CATEGORY::TERRAIN, empty_string, p.raw(), subtile, rotation, lit, nv, height_3d ); } } else if( invisible[0] ) { @@ -3399,23 +3400,23 @@ bool cata_tiles::draw_terrain( const tripoint &p, const lit_level ll, int &heigh return memorize_only ? false : draw_from_id_string( - mt.get_ter_id(), TILE_CATEGORY::TERRAIN, empty_string, p, mt.get_ter_subtile(), + mt.get_ter_id(), TILE_CATEGORY::TERRAIN, empty_string, p.raw(), mt.get_ter_subtile(), mt.get_ter_rotation(), lit_level::MEMORIZED, nv_goggles_activated, height_3d ); } } return false; } -bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_furniture( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { avatar &you = get_avatar(); - const auto override = furniture_override.find( tripoint_bub_ms( p ) ); + const auto override = furniture_override.find( p ); const bool overridden = override != furniture_override.end(); bool neighborhood_overridden = overridden; if( !neighborhood_overridden ) { for( const point &dir : neighborhood ) { - if( furniture_override.find( tripoint_bub_ms( p + dir ) ) != furniture_override.end() ) { + if( furniture_override.find( p + dir ) != furniture_override.end() ) { neighborhood_overridden = true; break; } @@ -3437,13 +3438,13 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei const std::bitset &rotate_group = f.obj().rotate_to_groups; if( connect_group.any() ) { - get_furn_connect_values( p, subtile, rotation, connect_group, rotate_group, {} ); + get_furn_connect_values( p.raw(), subtile, rotation, connect_group, rotate_group, {} ); } else { - get_tile_values_with_ter( p, f.to_i(), neighborhood, subtile, rotation, rotate_group ); + get_tile_values_with_ter( p.raw(), f.to_i(), neighborhood, subtile, rotation, rotate_group ); } const std::string &fname = f.id().str(); if( !( you.get_grab_type() == object_type::FURNITURE - && tripoint_bub_ms( p ) == you.pos_bub() + you.grab_point ) + && p == you.pos_bub() + you.grab_point ) && here.memory_cache_dec_is_dirty( p ) ) { you.memorize_decoration( here.getglobal( p ), fname, subtile, rotation ); } @@ -3451,7 +3452,7 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei if( !neighborhood_overridden ) { return memorize_only ? false - : draw_from_id_string( fname, TILE_CATEGORY::FURNITURE, empty_string, p, subtile, + : draw_from_id_string( fname, TILE_CATEGORY::FURNITURE, empty_string, p.raw(), subtile, rotation, ll, nv_goggles_activated, height_3d ); } } @@ -3461,8 +3462,8 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei if( f2 ) { // both the current and neighboring overrides may change the appearance // of the tile, so always re-calculate it. - const auto furn = [&]( const tripoint & q, const bool invis ) -> furn_id { - const auto it = furniture_override.find( tripoint_bub_ms( q ) ); + const auto furn = [&]( const tripoint_bub_ms & q, const bool invis ) -> furn_id { + const auto it = furniture_override.find( q ); return it != furniture_override.end() ? it->second : ( !overridden || !invis ) ? here.furn( q ) : furn_str_id::NULL_ID().id(); }; @@ -3478,11 +3479,11 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei const std::bitset &rotate_group = f.obj().rotate_to_groups; if( connect_group.any() ) { - get_furn_connect_values( p, subtile, rotation, connect_group, rotate_group, {} ); + get_furn_connect_values( p.raw(), subtile, rotation, connect_group, rotate_group, {} ); } else { - get_tile_values_with_ter( p, f.to_i(), neighborhood, subtile, rotation, rotate_group ); + get_tile_values_with_ter( p.raw(), f.to_i(), neighborhood, subtile, rotation, rotate_group ); } - get_tile_values_with_ter( p, f2.to_i(), neighborhood, subtile, rotation, 0 ); + get_tile_values_with_ter( p.raw(), f2.to_i(), neighborhood, subtile, rotation, 0 ); const std::string &fname = f2.id().str(); // tile overrides are never memorized // tile overrides are always shown with full visibility @@ -3490,7 +3491,7 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei const bool nv = overridden ? false : nv_goggles_activated; return memorize_only ? false - : draw_from_id_string( fname, TILE_CATEGORY::FURNITURE, empty_string, p, subtile, + : draw_from_id_string( fname, TILE_CATEGORY::FURNITURE, empty_string, p.raw(), subtile, rotation, lit, nv, height_3d ); } } else if( invisible[0] ) { @@ -3500,22 +3501,22 @@ bool cata_tiles::draw_furniture( const tripoint &p, const lit_level ll, int &hei return memorize_only ? false : draw_from_id_string( - mt.get_dec_id(), TILE_CATEGORY::FURNITURE, empty_string, p, mt.get_dec_subtile(), + mt.get_dec_id(), TILE_CATEGORY::FURNITURE, empty_string, p.raw(), mt.get_dec_subtile(), mt.get_dec_rotation(), lit_level::MEMORIZED, nv_goggles_activated, height_3d ); } } return false; } -bool cata_tiles::draw_trap( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_trap( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { - const auto override = trap_override.find( tripoint_bub_ms( p ) ); + const auto override = trap_override.find( p ); const bool overridden = override != trap_override.end(); bool neighborhood_overridden = overridden; if( !neighborhood_overridden ) { for( const point &dir : neighborhood ) { - if( trap_override.find( tripoint_bub_ms( p + dir ) ) != trap_override.end() ) { + if( trap_override.find( p + dir ) != trap_override.end() ) { neighborhood_overridden = true; break; } @@ -3544,7 +3545,7 @@ bool cata_tiles::draw_trap( const tripoint &p, const lit_level ll, int &height_3 if( !neighborhood_overridden ) { return memorize_only ? false - : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p, subtile, + : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p.raw(), subtile, rotation, ll, nv_goggles_activated, height_3d ); } } @@ -3555,8 +3556,8 @@ bool cata_tiles::draw_trap( const tripoint &p, const lit_level ll, int &height_3 if( tr2 ) { // both the current and neighboring overrides may change the appearance // of the tile, so always re-calculate it. - const auto tr_at = [&]( const tripoint & q, const bool invis ) -> trap_id { - const auto it = trap_override.find( tripoint_bub_ms( q ) ); + const auto tr_at = [&]( const tripoint_bub_ms & q, const bool invis ) -> trap_id { + const auto it = trap_override.find( q ); return it != trap_override.end() ? it->second : ( !overridden || !invis ) ? here.tr_at( q ).loadid : tr_null; }; @@ -3576,7 +3577,7 @@ bool cata_tiles::draw_trap( const tripoint &p, const lit_level ll, int &height_3 const bool nv = overridden ? false : nv_goggles_activated; return memorize_only ? false - : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p, subtile, + : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p.raw(), subtile, rotation, lit, nv, height_3d ); } } else if( invisible[0] ) { @@ -3586,19 +3587,20 @@ bool cata_tiles::draw_trap( const tripoint &p, const lit_level ll, int &height_3 return memorize_only ? false : draw_from_id_string( - mt.get_dec_id(), TILE_CATEGORY::TRAP, empty_string, p, mt.get_dec_subtile(), mt.get_dec_rotation(), + mt.get_dec_id(), TILE_CATEGORY::TRAP, empty_string, p.raw(), mt.get_dec_subtile(), + mt.get_dec_rotation(), lit_level::MEMORIZED, nv_goggles_activated, height_3d ); } } return false; } -bool cata_tiles::draw_part_con( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_part_con( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { map &here = get_map(); // FIXME: fix tripoint type - if( here.partial_con_at( tripoint_bub_ms( p ) ) != nullptr && !invisible[0] ) { + if( here.partial_con_at( p ) != nullptr && !invisible[0] ) { avatar &you = get_avatar(); std::string const &trname = tr_unfinished_construction.str(); if( here.memory_cache_dec_is_dirty( p ) ) { @@ -3606,13 +3608,13 @@ bool cata_tiles::draw_part_con( const tripoint &p, const lit_level ll, int &heig } return memorize_only ? false - : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p, 0, + : draw_from_id_string( trname, TILE_CATEGORY::TRAP, empty_string, p.raw(), 0, 0, ll, nv_goggles_activated, height_3d ); } return false; } -bool cata_tiles::draw_graffiti( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_graffiti( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -3620,7 +3622,7 @@ bool cata_tiles::draw_graffiti( const tripoint &p, const lit_level ll, int &heig } map &here = get_map(); - const auto override = graffiti_override.find( tripoint_bub_ms( p ) ); + const auto override = graffiti_override.find( p ); const bool overridden = override != graffiti_override.end(); if( overridden ? !override->second : ( invisible[0] || !here.has_graffiti_at( p ) ) ) { return false; @@ -3631,17 +3633,17 @@ bool cata_tiles::draw_graffiti( const tripoint &p, const lit_level ll, int &heig to_upper_case( string_replace( remove_punctuations( here.graffiti_at( p ) ), " ", "_" ) ).substr( 0, 32 ); return draw_from_id_string( tileset_ptr->find_tile_type( tile ) ? tile : "graffiti", - TILE_CATEGORY::NONE, empty_string, p, 0, rotation, lit, false, height_3d ); + TILE_CATEGORY::NONE, empty_string, p.raw(), 0, rotation, lit, false, height_3d ); } -bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int &height_3d, +bool cata_tiles::draw_field_or_item( const tripoint_bub_ms &p, const lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { return false; } - const auto fld_override = field_override.find( tripoint_bub_ms( p ) ); + const auto fld_override = field_override.find( p ); const bool fld_overridden = fld_override != field_override.end(); map &here = get_map(); const field &f = here.field_at( p ); @@ -3665,7 +3667,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int // get the sprite to draw // roll is based on the maptile seed to keep visuals consistent - int roll = simple_point_hash( p.xy() ) % layer_var.total_weight; + int roll = simple_point_hash( p.xy().raw() ) % layer_var.total_weight; std::string sprite_to_draw; for( const auto &sprite_list : layer_var.sprite ) { roll = roll - sprite_list.second; @@ -3676,7 +3678,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int } // if we have found info on the item go through and draw its stuff - ret_draw_field = draw_from_id_string( sprite_to_draw, TILE_CATEGORY::FIELD, empty_string, p, + ret_draw_field = draw_from_id_string( sprite_to_draw, TILE_CATEGORY::FIELD, empty_string, p.raw(), subtile, rotation, ll, nv, height_3d, fe.get_field_intensity(), "", layer_var.offset ); break; } @@ -3719,7 +3721,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int variant += layer_var.append_suffix; } // if we have found info on the item go through and draw its stuff - draw_from_id_string( sprite_to_draw, TILE_CATEGORY::ITEM, layer_it_category, p, 0, + draw_from_id_string( sprite_to_draw, TILE_CATEGORY::ITEM, layer_it_category, p.raw(), 0, 0, layer_lit, layer_nv, height_3d, 0, variant, layer_var.offset ); // if the top item is already being layered don't draw it later @@ -3745,7 +3747,8 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int if( !invisible[0] && fld.obj().display_field ) { const lit_level lit = ll; - auto has_field = [&]( field_type_id fld, const tripoint & q, const bool invis ) -> field_type_id { + auto has_field = [&]( field_type_id fld, const tripoint_bub_ms & q, + const bool invis ) -> field_type_id { // go through the fields and see if they are equal field_type_id found = fd_null; for( std::pair &this_fld : here.field_at( q ) ) @@ -3754,7 +3757,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int found = fld; } } - const auto it = field_override.find( tripoint_bub_ms( q ) ); + const auto it = field_override.find( q ); return it != field_override.end() ? it->second : ( !fld_overridden || !invis ) ? found : fd_null; }; @@ -3783,7 +3786,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int } if( !has_drawn_field ) { draw_from_id_string( fld.id().str(), TILE_CATEGORY::FIELD, empty_string, - p, subtile, rotation, ll, nv_goggles_activated, height_3d, intensity ); + p.raw(), subtile, rotation, ll, nv_goggles_activated, height_3d, intensity ); } } } @@ -3793,8 +3796,8 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int if( fld.obj().display_field ) { const lit_level lit = lit_level::LIT; - auto field_at = [&]( const tripoint & q, const bool invis ) -> field_type_id { - const auto it = field_override.find( tripoint_bub_ms( q ) ); + auto field_at = [&]( const tripoint_bub_ms & q, const bool invis ) -> field_type_id { + const auto it = field_override.find( q ); return it != field_override.end() ? it->second : ( !fld_overridden || !invis ) ? here.field_at( q ).displayed_field_type() : fd_null; }; @@ -3813,12 +3816,12 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int //get field intensity int intensity = fld_overridden ? 0 : here.field_at( p ).displayed_intensity(); ret_draw_field = draw_from_id_string( fld.id().str(), TILE_CATEGORY::FIELD, empty_string, - p, subtile, rotation, lit, false, height_3d, intensity ); + p.raw(), subtile, rotation, lit, false, height_3d, intensity ); } } if( fld.obj().display_items ) { - const auto it_override = item_override.find( tripoint_bub_ms( p ) ); + const auto it_override = item_override.find( p ); const bool it_overridden = it_override != item_override.end(); itype_id it_id; @@ -3876,7 +3879,7 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int const lit_level lit = it_overridden ? lit_level::LIT : ll; const bool nv = it_overridden ? false : nv_goggles_activated; - ret_draw_items = draw_from_id_string( disp_id, TILE_CATEGORY::ITEM, it_category, p, 0, + ret_draw_items = draw_from_id_string( disp_id, TILE_CATEGORY::ITEM, it_category, p.raw(), 0, 0, lit, nv, height_3d, 0, variant ); if( ret_draw_items && hilite ) { draw_item_highlight( p, height_3d ); @@ -3891,20 +3894,21 @@ bool cata_tiles::draw_field_or_item( const tripoint &p, const lit_level ll, int return ret_draw_field && ret_draw_items; } -bool cata_tiles::draw_vpart_below( const tripoint &p, const lit_level /*ll*/, int &/*height_3d*/, +bool cata_tiles::draw_vpart_below( const tripoint_bub_ms &p, const lit_level /*ll*/, + int &/*height_3d*/, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { return false; } - const auto low_override = draw_below_override.find( tripoint_bub_ms( p ) ); + const auto low_override = draw_below_override.find( p ); const bool low_overridden = low_override != draw_below_override.end(); if( low_overridden ? !low_override->second : ( invisible[0] || - get_map().dont_draw_lower_floor( tripoint_bub_ms( p ) ) ) ) { + get_map().dont_draw_lower_floor( p ) ) ) { return false; } - tripoint pbelow( p.xy(), p.z - 1 ); + tripoint_bub_ms pbelow( p + tripoint::below ); int height_3d_below = 0; std::array below_invisible; std::fill( below_invisible.begin(), below_invisible.end(), false ); @@ -3912,22 +3916,22 @@ bool cata_tiles::draw_vpart_below( const tripoint &p, const lit_level /*ll*/, in memorize_only ); } -bool cata_tiles::draw_vpart_no_roof( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_vpart_no_roof( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { return draw_vpart( p, ll, height_3d, invisible, false, memorize_only ); } -bool cata_tiles::draw_vpart_roof( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_vpart_roof( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { return draw_vpart( p, ll, height_3d, invisible, true, memorize_only ); } -bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_vpart( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool roof, const bool memorize_only ) { - const auto override = vpart_override.find( tripoint_bub_ms( p ) ); + const auto override = vpart_override.find( p ); const bool overridden = override != vpart_override.end(); map &here = get_map(); // first memorize the actual vpart @@ -3950,7 +3954,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, const bool ret = memorize_only ? false : draw_from_id_string( "vp_" + vd.id.str(), TILE_CATEGORY::VEHICLE_PART, - empty_string, p, subtile, rotation, ll, + empty_string, p.raw(), subtile, rotation, ll, nv_goggles_activated, height_3d_temp, 0, vd.variant.id ); if( ret && vd.has_cargo ) { draw_item_highlight( p, height_3d_temp ); @@ -3977,7 +3981,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, int height_3d_temp = height_3d; const bool ret = memorize_only ? false - : draw_from_id_string( vpname, TILE_CATEGORY::VEHICLE_PART, empty_string, p, subtile, + : draw_from_id_string( vpname, TILE_CATEGORY::VEHICLE_PART, empty_string, p.raw(), subtile, rotation, lit_level::LIT, false, height_3d_temp ); if( ret && draw_highlight ) { draw_item_highlight( p, height_3d_temp ); @@ -4002,7 +4006,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, return memorize_only ? false : draw_from_id_string( - std::string( tid ), TILE_CATEGORY::VEHICLE_PART, empty_string, p, t.get_dec_subtile(), + std::string( tid ), TILE_CATEGORY::VEHICLE_PART, empty_string, p.raw(), t.get_dec_subtile(), t.get_dec_rotation(), lit_level::MEMORIZED, nv_goggles_activated, height_3d_temp, 0, std::string( tvar ) ); } @@ -4010,7 +4014,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, return false; } -bool cata_tiles::draw_critter_at_below( const tripoint &p, const lit_level, int &, +bool cata_tiles::draw_critter_at_below( const tripoint_bub_ms &p, const lit_level, int &, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -4018,14 +4022,14 @@ bool cata_tiles::draw_critter_at_below( const tripoint &p, const lit_level, int } // Check if we even need to draw below. If not, bail. - const auto low_override = draw_below_override.find( tripoint_bub_ms( p ) ); + const auto low_override = draw_below_override.find( p ); const bool low_overridden = low_override != draw_below_override.end(); if( low_overridden ? !low_override->second : ( invisible[0] || - get_map().dont_draw_lower_floor( tripoint_bub_ms( p ) ) ) ) { + get_map().dont_draw_lower_floor( p ) ) ) { return false; } - tripoint pbelow( p.xy(), p.z - 1 ); + tripoint_bub_ms pbelow( p + tripoint::below ); // Get the critter at the location below. If there isn't one, // we can bail. @@ -4042,12 +4046,12 @@ bool cata_tiles::draw_critter_at_below( const tripoint &p, const lit_level, int return false; } - draw_square_below( pbelow.xy(), c_red, 2 ); + draw_square_below( pbelow.xy().raw(), c_red, 2 ); return true; } -bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_critter_at( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -4061,7 +4065,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 Character &you = get_player_character(); const Creature *pcritter = get_creature_tracker().creature_at( p, true ); const bool always_visible = pcritter && pcritter->has_flag( mon_flag_ALWAYS_VISIBLE ); - const auto override = monster_override.find( tripoint_bub_ms( p ) ); + const auto override = monster_override.find( p ); if( override != monster_override.end() ) { const mtype_id id = std::get<0>( override->second ); if( !id ) { @@ -4073,7 +4077,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 const std::string &chosen_id = id.str(); const std::string &ent_subcategory = id.obj().species.empty() ? empty_string : id.obj().species.begin()->str(); - result = draw_from_id_string( chosen_id, TILE_CATEGORY::MONSTER, ent_subcategory, p, + result = draw_from_id_string( chosen_id, TILE_CATEGORY::MONSTER, ent_subcategory, p.raw(), corner, 0, lit_level::LIT, false, height_3d ); } else if( !invisible[0] || always_visible ) { if( pcritter == nullptr ) { @@ -4087,7 +4091,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 if( !sees_with_special.is_empty() ) { const enchant_cache::special_vision_descriptions special_vis_desc = you.enchantment_cache->get_vision_description_struct( sees_with_special, d ); - return draw_from_id_string( special_vis_desc.id, TILE_CATEGORY::NONE, empty_string, p, 0, 0, + return draw_from_id_string( special_vis_desc.id, TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, lit_level::LIT, false, height_3d ); } return false; @@ -4127,7 +4131,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 chosen_id = ridden_id; } } - result = draw_from_id_string( chosen_id, ent_category, ent_subcategory, p, + result = draw_from_id_string( chosen_id, ent_category, ent_subcategory, p.raw(), subtile, rot_facing, ll, false, height_3d ); sees_player = m->sees( you ); attitude = m->attitude_to( you ); @@ -4158,7 +4162,7 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 if( !scope_is_blocking ) { const enchant_cache::special_vision_descriptions special_vis_desc = you.enchantment_cache->get_vision_description_struct( sees_with_special, d ); - return draw_from_id_string( special_vis_desc.id, TILE_CATEGORY::NONE, empty_string, p, + return draw_from_id_string( special_vis_desc.id, TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, lit_level::LIT, false, height_3d ); } else { return false; @@ -4174,14 +4178,14 @@ bool cata_tiles::draw_critter_at( const tripoint &p, lit_level ll, int &height_3 draw_id += "_sees_player"; } if( tileset_ptr->find_tile_type( draw_id ) ) { - draw_from_id_string( draw_id, TILE_CATEGORY::NONE, empty_string, p, 0, 0, + draw_from_id_string( draw_id, TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, lit_level::LIT, false, height_3d ); } } return result; } -bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_critter_above( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible ) { if( invisible[0] ) { @@ -4207,7 +4211,7 @@ bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &heigh const Creature &critter = *pcritter; // Draw shadow - if( draw_from_id_string( "shadow", TILE_CATEGORY::NONE, empty_string, p, + if( draw_from_id_string( "shadow", TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, ll, false, height_3d ) && scan_p.z() - 1 > you.posz() && you.sees( critter ) ) { bool is_player = false; @@ -4239,7 +4243,7 @@ bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &heigh draw_id += "_sees_player"; } if( tileset_ptr->find_tile_type( draw_id ) ) { - draw_from_id_string( draw_id, TILE_CATEGORY::NONE, empty_string, p, 0, 0, + draw_from_id_string( draw_id, TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, lit_level::LIT, false, height_3d ); } } @@ -4249,7 +4253,7 @@ bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &heigh } } -bool cata_tiles::draw_zone_mark( const tripoint &p, lit_level ll, int &height_3d, +bool cata_tiles::draw_zone_mark( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -4272,7 +4276,7 @@ bool cata_tiles::draw_zone_mark( const tripoint &p, lit_level ll, int &height_3d const mark_option *option = dynamic_cast( &zone->get_options() ); if( option && !option->get_mark().empty() ) { - return draw_from_id_string( option->get_mark(), TILE_CATEGORY::NONE, empty_string, p, + return draw_from_id_string( option->get_mark(), TILE_CATEGORY::NONE, empty_string, p.raw(), 0, 0, ll, nv_goggles_activated, height_3d ); } } @@ -4280,7 +4284,7 @@ bool cata_tiles::draw_zone_mark( const tripoint &p, lit_level ll, int &height_3d return false; } -bool cata_tiles::draw_zombie_revival_indicators( const tripoint &pos, const lit_level /*ll*/, +bool cata_tiles::draw_zombie_revival_indicators( const tripoint_bub_ms &pos, const lit_level /*ll*/, int &height_3d, const std::array &invisible, const bool memorize_only ) { if( memorize_only ) { @@ -4289,23 +4293,23 @@ bool cata_tiles::draw_zombie_revival_indicators( const tripoint &pos, const lit_ map &here = get_map(); if( tileset_ptr->find_tile_type( ZOMBIE_REVIVAL_INDICATOR ) && !invisible[0] && - item_override.find( tripoint_bub_ms( pos ) ) == item_override.end() && + item_override.find( pos ) == item_override.end() && here.could_see_items( pos, get_player_character() ) ) { for( item &i : here.i_at( pos ) ) { if( i.can_revive() ) { return draw_from_id_string( ZOMBIE_REVIVAL_INDICATOR, TILE_CATEGORY::NONE, - empty_string, pos, 0, 0, lit_level::LIT, false, height_3d ); + empty_string, pos.raw(), 0, 0, lit_level::LIT, false, height_3d ); } } } return false; } -void cata_tiles::draw_zlevel_overlay( const tripoint &p, const lit_level ll, int &height_3d ) +void cata_tiles::draw_zlevel_overlay( const tripoint_bub_ms &p, const lit_level ll, int &height_3d ) { // Draws zlevel fog using geometry renderer // Slower than sprites so only use as fallback when sprite missing - const point screen = player_to_screen( p.xy() ); + const point screen = player_to_screen( p.xy().raw() ); SDL_Rect draw_rect; if( is_isometric() ) { // See comments in get_window_base_tile_counts for an explanation of tile width @@ -4349,7 +4353,8 @@ void cata_tiles::draw_zlevel_overlay( const tripoint &p, const lit_level ll, int SetRenderDrawBlendMode( renderer, SDL_BLENDMODE_NONE ); } -void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint &p, lit_level ll, +void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint_bub_ms &p, + lit_level ll, int &height_3d ) { std::vector override_look_muts = ch.get_functioning_mutations( true, @@ -4369,10 +4374,10 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint } // depending on the toggle flip sprite left or right if( ch.facing == FacingDirection::RIGHT ) { - draw_from_id_string( ent_name, TILE_CATEGORY::NONE, "", p, corner, 0, ll, false, + draw_from_id_string( ent_name, TILE_CATEGORY::NONE, "", p.raw(), corner, 0, ll, false, height_3d ); } else if( ch.facing == FacingDirection::LEFT ) { - draw_from_id_string( ent_name, TILE_CATEGORY::NONE, "", p, corner, -1, ll, false, + draw_from_id_string( ent_name, TILE_CATEGORY::NONE, "", p.raw(), corner, -1, ll, false, height_3d ); } } else { @@ -4386,10 +4391,10 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint category = TILE_CATEGORY::NONE; } if( ch.facing == FacingDirection::RIGHT ) { - draw_from_id_string( override_look.id, category, "", p, corner, 0, ll, false, + draw_from_id_string( override_look.id, category, "", p.raw(), corner, 0, ll, false, height_3d ); } else if( ch.facing == FacingDirection::LEFT ) { - draw_from_id_string( override_look.id, category, "", p, corner, -1, ll, false, + draw_from_id_string( override_look.id, category, "", p.raw(), corner, -1, ll, false, height_3d ); } } @@ -4402,10 +4407,10 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint if( find_overlay_looks_like( ch.male, overlay.first, overlay.second, draw_id ) ) { int overlay_height_3d = prev_height_3d; if( ch.facing == FacingDirection::RIGHT ) { - draw_from_id_string( draw_id, TILE_CATEGORY::NONE, "", p, corner, /*rota:*/ 0, ll, + draw_from_id_string( draw_id, TILE_CATEGORY::NONE, "", p.raw(), corner, /*rota:*/ 0, ll, false, overlay_height_3d ); } else if( ch.facing == FacingDirection::LEFT ) { - draw_from_id_string( draw_id, TILE_CATEGORY::NONE, "", p, corner, /*rota:*/ -1, ll, + draw_from_id_string( draw_id, TILE_CATEGORY::NONE, "", p.raw(), corner, /*rota:*/ -1, ll, false, overlay_height_3d ); } // the tallest height-having overlay is the one that counts @@ -4414,9 +4419,9 @@ void cata_tiles::draw_entity_with_overlays( const Character &ch, const tripoint } } -bool cata_tiles::draw_item_highlight( const tripoint &pos, int &height_3d ) +bool cata_tiles::draw_item_highlight( const tripoint_bub_ms &pos, int &height_3d ) { - return draw_from_id_string( ITEM_HIGHLIGHT, TILE_CATEGORY::NONE, empty_string, pos, 0, 0, + return draw_from_id_string( ITEM_HIGHLIGHT, TILE_CATEGORY::NONE, empty_string, pos.raw(), 0, 0, lit_level::LIT, false, height_3d ); } @@ -4678,18 +4683,18 @@ void cata_tiles::void_monster_override() monster_override.clear(); } -bool cata_tiles::has_draw_override( const tripoint &p ) const +bool cata_tiles::has_draw_override( const tripoint_bub_ms &p ) const { - return radiation_override.find( tripoint_bub_ms( p ) ) != radiation_override.end() || - terrain_override.find( tripoint_bub_ms( p ) ) != terrain_override.end() || - furniture_override.find( tripoint_bub_ms( p ) ) != furniture_override.end() || - graffiti_override.find( tripoint_bub_ms( p ) ) != graffiti_override.end() || - trap_override.find( tripoint_bub_ms( p ) ) != trap_override.end() || - field_override.find( tripoint_bub_ms( p ) ) != field_override.end() || - item_override.find( tripoint_bub_ms( p ) ) != item_override.end() || - vpart_override.find( tripoint_bub_ms( p ) ) != vpart_override.end() || - draw_below_override.find( tripoint_bub_ms( p ) ) != draw_below_override.end() || - monster_override.find( tripoint_bub_ms( p ) ) != monster_override.end(); + return radiation_override.find( p ) != radiation_override.end() || + terrain_override.find( p ) != terrain_override.end() || + furniture_override.find( p ) != furniture_override.end() || + graffiti_override.find( p ) != graffiti_override.end() || + trap_override.find( p ) != trap_override.end() || + field_override.find( p ) != field_override.end() || + item_override.find( p ) != item_override.end() || + vpart_override.find( p ) != vpart_override.end() || + draw_below_override.find( p ) != draw_below_override.end() || + monster_override.find( p ) != monster_override.end(); } /* -- Animation Renders */ @@ -4872,7 +4877,7 @@ void cata_tiles::draw_weather_frame() void cata_tiles::draw_sct_frame( std::multimap &overlay_strings ) { const bool use_font = get_option( "ANIMATION_SCT_USE_FONT" ); - tripoint player_pos = get_player_character().pos(); + tripoint_bub_ms player_pos = get_player_character().pos_bub(); for( const scrollingcombattext::cSCT &sct : SCT.vSCT ) { const point iD( sct.getPosX(), sct.getPosY() ); @@ -4901,7 +4906,7 @@ void cata_tiles::draw_sct_frame( std::multimap &overlay_s if( tileset_ptr->find_tile_type( generic_id ) ) { draw_from_id_string( generic_id, TILE_CATEGORY::NONE, empty_string, - iD + tripoint( iOffset, player_pos.z ), + iD + tripoint( iOffset, player_pos.z() ), 0, 0, lit_level::LIT, false ); } @@ -4917,11 +4922,11 @@ void cata_tiles::draw_sct_frame( std::multimap &overlay_s void cata_tiles::draw_zones_frame() { - tripoint player_pos = get_player_character().pos(); + tripoint_bub_ms player_pos = get_player_character().pos_bub(); for( int iY = zone_start.y(); iY <= zone_end.y(); ++ iY ) { for( int iX = zone_start.x(); iX <= zone_end.x(); ++iX ) { draw_from_id_string( "highlight", TILE_CATEGORY::NONE, empty_string, - zone_offset.xy() + tripoint( iX, iY, player_pos.z ), + zone_offset.xy() + tripoint( iX, iY, player_pos.z() ), 0, 0, lit_level::LIT, false ); } } @@ -4942,7 +4947,7 @@ void cata_tiles::draw_async_anim() } } -void cata_tiles::draw_footsteps_frame( const tripoint ¢er ) +void cata_tiles::draw_footsteps_frame( const tripoint_bub_ms ¢er ) { static const std::string id_footstep = "footstep"; static const std::string id_footstep_above = "footstep_above"; @@ -4951,13 +4956,13 @@ void cata_tiles::draw_footsteps_frame( const tripoint ¢er ) const tile_type *tl_above = tileset_ptr->find_tile_type( id_footstep_above ); const tile_type *tl_below = tileset_ptr->find_tile_type( id_footstep_below ); - for( const tripoint &pos : sounds::get_footstep_markers() ) { - if( pos.z > center.z && tl_above ) { - draw_from_id_string( id_footstep_above, pos, 0, 0, lit_level::LIT, false ); - } else if( pos.z < center.z && tl_below ) { - draw_from_id_string( id_footstep_below, pos, 0, 0, lit_level::LIT, false ); + for( const tripoint_bub_ms &pos : sounds::get_footstep_markers() ) { + if( pos.z() > center.z() && tl_above ) { + draw_from_id_string( id_footstep_above, pos.raw(), 0, 0, lit_level::LIT, false ); + } else if( pos.z() < center.z() && tl_below ) { + draw_from_id_string( id_footstep_below, pos.raw(), 0, 0, lit_level::LIT, false ); } else { - draw_from_id_string( id_footstep, pos, 0, 0, lit_level::LIT, false ); + draw_from_id_string( id_footstep, pos.raw(), 0, 0, lit_level::LIT, false ); } } } diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 47b6d7083ac61..741d7ad5b451f 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -440,13 +440,13 @@ class cata_tiles } /** Draw to screen */ - void draw( const point &dest, const tripoint ¢er, int width, int height, + void draw( const point &dest, const tripoint_bub_ms ¢er, int width, int height, std::multimap &overlay_strings, color_block_overlay_container &color_blocks ); void draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_omt, bool blink ); /** Minimap functionality */ - void draw_minimap( const point &dest, const tripoint ¢er, int width, int height ); + void draw_minimap( const point &dest, const tripoint_bub_ms ¢er, int width, int height ); protected: /** How many rows and columns of tiles fit into given dimensions, fully @@ -555,45 +555,45 @@ class cata_tiles /** Drawing Layers */ bool would_apply_vision_effects( visibility_type visibility ) const; - bool apply_vision_effects( const tripoint &pos, visibility_type visibility, int &height_3d ); + bool apply_vision_effects( const tripoint_bub_ms &pos, visibility_type visibility, int &height_3d ); void draw_square_below( const point &p, const nc_color &col, int sizefactor ); - bool draw_terrain( const tripoint &p, lit_level ll, int &height_3d, + bool draw_terrain( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_terrain_below( const tripoint &p, lit_level ll, int &height_3d, + bool draw_terrain_below( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_furniture( const tripoint &p, lit_level ll, int &height_3d, + bool draw_furniture( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_graffiti( const tripoint &p, lit_level ll, int &height_3d, + bool draw_graffiti( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_trap( const tripoint &p, lit_level ll, int &height_3d, + bool draw_trap( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_part_con( const tripoint &p, lit_level ll, int &height_3d, + bool draw_part_con( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_field_or_item( const tripoint &p, lit_level ll, int &height_3d, + bool draw_field_or_item( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_vpart( const tripoint &p, lit_level ll, int &height_3d, + bool draw_vpart( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool roof, bool memorize_only ); - bool draw_vpart_no_roof( const tripoint &p, lit_level ll, int &height_3d, + bool draw_vpart_no_roof( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_vpart_roof( const tripoint &p, lit_level ll, int &height_3d, + bool draw_vpart_roof( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_vpart_below( const tripoint &p, lit_level ll, int &height_3d, + bool draw_vpart_below( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_critter_at( const tripoint &p, lit_level ll, int &height_3d, + bool draw_critter_at( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_critter_at_below( const tripoint &p, lit_level ll, int &height_3d, + bool draw_critter_at_below( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_critter_above( const tripoint &p, lit_level ll, int &height_3d, + bool draw_critter_above( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible ); - bool draw_zone_mark( const tripoint &p, lit_level ll, int &height_3d, + bool draw_zone_mark( const tripoint_bub_ms &p, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - bool draw_zombie_revival_indicators( const tripoint &pos, lit_level ll, int &height_3d, + bool draw_zombie_revival_indicators( const tripoint_bub_ms &pos, lit_level ll, int &height_3d, const std::array &invisible, bool memorize_only ); - void draw_zlevel_overlay( const tripoint &p, lit_level ll, int &height_3d ); - void draw_entity_with_overlays( const Character &ch, const tripoint &p, lit_level ll, + void draw_zlevel_overlay( const tripoint_bub_ms &p, lit_level ll, int &height_3d ); + void draw_entity_with_overlays( const Character &ch, const tripoint_bub_ms &p, lit_level ll, int &height_3d ); - bool draw_item_highlight( const tripoint &pos, int &height_3d ); + bool draw_item_highlight( const tripoint_bub_ms &pos, int &height_3d ); public: // Animation layers @@ -613,7 +613,7 @@ class cata_tiles void draw_hit_frame(); void void_hit(); - void draw_footsteps_frame( const tripoint ¢er ); + void draw_footsteps_frame( const tripoint_bub_ms ¢er ); // pseudo-animated layer, not really though. void init_draw_line( const tripoint_bub_ms &p, std::vector trajectory, @@ -679,7 +679,7 @@ class cata_tiles bool more, Creature::Attitude att ); void void_monster_override(); - bool has_draw_override( const tripoint &p ) const; + bool has_draw_override( const tripoint_bub_ms &p ) const; void set_disable_occlusion( bool val ); diff --git a/src/character.cpp b/src/character.cpp index 13e31be53afdc..3fac45867c50d 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -5261,7 +5261,7 @@ needs_rates Character::calc_needs_rates() const if( has_trait( trait_TRANSPIRATION ) ) { // Transpiration, the act of moving nutrients with evaporating water, can take a very heavy toll on your thirst when it's really hot. rates.thirst *= ( ( units::to_fahrenheit( get_weather().get_temperature( - pos() ) ) - 32.5f ) / 40.0f ); + pos_bub() ) ) - 32.5f ) / 40.0f ); } rates.hunger = enchantment_cache->modify_value( enchant_vals::mod::HUNGER, rates.hunger ); @@ -12910,7 +12910,7 @@ void Character::search_surroundings() continue; } // Chance to detect traps we haven't yet seen. - if( tr.detect_trap( tp.raw(), *this ) ) { + if( tr.detect_trap( tp, *this ) ) { if( !tr.is_trivial_to_spot() ) { // Only bug player about traps that aren't trivial to spot. const std::string direction = direction_name( diff --git a/src/character_body.cpp b/src/character_body.cpp index 478294da563b5..56bf0c9c4ad4c 100644 --- a/src/character_body.cpp +++ b/src/character_body.cpp @@ -426,7 +426,7 @@ void Character::update_bodytemp() } weather_manager &weather_man = get_weather(); /* Cache calls to g->get_temperature( player position ), used in several places in function */ - const units::temperature player_local_temp = weather_man.get_temperature( pos() ); + const units::temperature player_local_temp = weather_man.get_temperature( pos_bub() ); const w_point weather = *weather_man.weather_precise; int vehwindspeed = 0; map &here = get_map(); @@ -849,7 +849,7 @@ void Character::update_frostbite( const bodypart_id &bp, const int FBwindPower, Less than -35F, more than 10 mp **/ - const float player_local_temp = units::to_fahrenheit( get_weather().get_temperature( pos() ) ); + const float player_local_temp = units::to_fahrenheit( get_weather().get_temperature( pos_bub() ) ); const units::temperature temp_after = get_part_temp_cur( bp ); if( bp == body_part_mouth || bp == body_part_foot_r || @@ -1368,7 +1368,7 @@ void Character::update_heartrate_index() // The following code was adapted from the heartrate function, which will now probably need to be rewritten to be based on the heartrate index. //COLDBLOOD dependencies, works almost same way as temperature effect for speed. - const float player_local_temp = units::to_fahrenheit( get_weather().get_temperature( pos() ) ); + const float player_local_temp = units::to_fahrenheit( get_weather().get_temperature( pos_bub() ) ); float temperature_modifier = 0.0f; if( has_flag( json_flag_COLDBLOOD ) ) { temperature_modifier = 0.002f; diff --git a/src/construction.cpp b/src/construction.cpp index 59d51ff14bbc4..07d4b22bcf355 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -2121,11 +2121,11 @@ void construct::do_turn_deconstruct( const tripoint_bub_ms &p, Character &who ) void construct::do_turn_shovel( const tripoint_bub_ms &p, Character &who ) { // TODO: fix point types - sfx::play_activity_sound( "tool", "shovel", sfx::get_heard_volume( p.raw() ) ); + sfx::play_activity_sound( "tool", "shovel", sfx::get_heard_volume( p ) ); if( calendar::once_every( 1_minutes ) ) { // TODO: fix point types //~ Sound of a shovel digging a pit at work! - sounds::sound( p.raw(), 10, sounds::sound_t::activity, _( "hsh!" ) ); + sounds::sound( p, 10, sounds::sound_t::activity, _( "hsh!" ) ); } if( !who.knows_trap( p ) ) { get_map().maybe_trigger_trap( p, who, true ); diff --git a/src/craft_command.cpp b/src/craft_command.cpp index dcc0ba44698b3..45c43d9c153f2 100644 --- a/src/craft_command.cpp +++ b/src/craft_command.cpp @@ -143,7 +143,7 @@ void craft_command::execute( bool only_cache_comps ) bool need_selections = true; inventory map_inv; - map_inv.form_from_map( crafter->pos(), PICKUP_RANGE, crafter ); + map_inv.form_from_map( crafter->pos_bub(), PICKUP_RANGE, crafter ); if( has_cached_selections() ) { std::vector> missing_items = check_item_components_missing( map_inv ); @@ -455,7 +455,7 @@ item craft_command::create_in_progress_craft() } inventory map_inv; - map_inv.form_from_map( crafter->pos(), PICKUP_RANGE, crafter ); + map_inv.form_from_map( crafter->pos_bub(), PICKUP_RANGE, crafter ); if( !check_item_components_missing( map_inv ).empty() ) { debugmsg( "Aborting crafting: couldn't find cached components" ); diff --git a/src/crafting.cpp b/src/crafting.cpp index d22abf3b0d758..b8df78bf5efd2 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -133,7 +133,7 @@ static bool crafting_allowed( const Character &p, const recipe &rec ) if( p.is_avatar() ) { add_msg( m_info, _( "Your morale is too low to craft such a difficult thing…" ) ); } else { - add_msg_if_player_sees( p.pos(), m_info, + add_msg_if_player_sees( p.pos_bub(), m_info, _( "%s's morale is too low to craft such a difficult thing…" ), p.get_name() ); } @@ -144,7 +144,7 @@ static bool crafting_allowed( const Character &p, const recipe &rec ) if( p.is_avatar() ) { add_msg( m_info, _( "You can't see to craft!" ) ); } else { - add_msg_if_player_sees( p.pos(), m_info, _( "%s can't see to craft!" ), + add_msg_if_player_sees( p.pos_bub(), m_info, _( "%s can't see to craft!" ), p.get_name() ); } return false; @@ -653,7 +653,7 @@ const inventory &Character::crafting_inventory( const tripoint_bub_ms &src_pos, } crafting_cache.crafting_inventory->clear(); if( radius >= 0 ) { - crafting_cache.crafting_inventory->form_from_map( inv_pos.raw(), radius, this, false, clear_path ); + crafting_cache.crafting_inventory->form_from_map( inv_pos, radius, this, false, clear_path ); } std::map tmp_liq_list; @@ -997,14 +997,14 @@ bool Character::craft_skill_gain( const item &craft, const int &num_practice_tic if( is_avatar() ) { add_msg( m_info, _( "%s assists with crafting…" ), helper->get_name() ); } else { - add_msg_if_player_sees( pos(), m_info, _( "%s assists with crafting…" ), helper->get_name() ); + add_msg_if_player_sees( pos_bub(), m_info, _( "%s assists with crafting…" ), helper->get_name() ); } } if( batch_size == 1 && one_in( 300 ) ) { if( is_avatar() ) { add_msg( m_info, _( "%s could assist you with a batch…" ), helper->get_name() ); } else { - add_msg_if_player_sees( pos(), m_info, _( "%1s could assist %2s with a batch…" ), + add_msg_if_player_sees( pos_bub(), m_info, _( "%1s could assist %2s with a batch…" ), helper->get_name(), get_name() ); } } @@ -1015,7 +1015,7 @@ bool Character::craft_skill_gain( const item &craft, const int &num_practice_tic if( is_avatar() ) { add_msg( m_info, _( "%s watches you craft…" ), helper->get_name() ); } else { - add_msg_if_player_sees( pos(), m_info, _( "%1s watches %2s crafts…" ), helper->get_name(), + add_msg_if_player_sees( pos_bub(), m_info, _( "%1s watches %2s crafts…" ), helper->get_name(), get_name() ); } } @@ -1544,7 +1544,7 @@ void Character::complete_craft( item &craft, const std::optionalis_avatar() ) { add_msg( _( "You stop crafting." ) ); } else { - add_msg_if_player_sees( pos(), _( "%s stops crafting." ), get_name() ); + add_msg_if_player_sees( pos_bub(), _( "%s stops crafting." ), get_name() ); } return false; } @@ -1709,7 +1709,7 @@ bool Character::can_continue_craft( item &craft, const requirement_data &continu } inventory map_inv; - map_inv.form_from_map( pos(), PICKUP_RANGE, this ); + map_inv.form_from_map( pos_bub(), PICKUP_RANGE, this ); std::vector> new_tool_selections; for( const std::vector &alternatives : tool_reqs ) { @@ -2171,7 +2171,7 @@ std::list Character::consume_items( const std::vector &componen const std::function &select_ind ) { inventory map_inv; - map_inv.form_from_map( pos(), PICKUP_RANGE, this ); + map_inv.form_from_map( pos_bub(), PICKUP_RANGE, this ); comp_selection sel = select_item_component( components, batch, map_inv, false, filter ); return consume_items( sel, batch, filter, select_ind( sel.comp.type ) ); } @@ -2361,7 +2361,7 @@ bool Character::craft_consume_tools( item &craft, int multiplier, bool start_cra craft.get_cached_tool_selections(); inventory map_inv; - map_inv.form_from_map( pos(), PICKUP_RANGE, this ); + map_inv.form_from_map( pos_bub(), PICKUP_RANGE, this ); for( const comp_selection &tool_sel : cached_tool_selections ) { itype_id type = tool_sel.comp.type; @@ -2482,7 +2482,7 @@ to consume_tools */ void Character::consume_tools( const std::vector &tools, int batch ) { inventory map_inv; - map_inv.form_from_map( pos(), PICKUP_RANGE, this ); + map_inv.form_from_map( pos_bub(), PICKUP_RANGE, this ); consume_tools( select_tool_component( tools, batch, map_inv ), batch ); } @@ -2931,7 +2931,7 @@ void Character::complete_disassemble( item_location &target, const recipe &dis ) if( act_item.has_temperature() ) { // TODO: fix point types - act_item.set_item_temperature( get_weather().get_temperature( loc.raw() ) ); + act_item.set_item_temperature( get_weather().get_temperature( loc ) ); } // Refitted clothing disassembles into refitted components (when applicable) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 9c67132912bef..c7dede874fa87 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -3572,13 +3572,13 @@ static void show_sound() player_character.view_offset.xy().raw() + point( POSX - player_character.posx(), POSY - player_character.posy() ) }; wattron( g->w_terrain, c_yellow ); - for( const tripoint &sound : sounds_to_draw.first ) { - mvwaddch( g->w_terrain, offset + sound.xy(), '?' ); + for( const tripoint_bub_ms &sound : sounds_to_draw.first ) { + mvwaddch( g->w_terrain, sound.xy().raw() + offset, '?' ); } wattroff( g->w_terrain, c_yellow ); wattron( g->w_terrain, c_red ); - for( const tripoint &sound : sounds_to_draw.second ) { - mvwaddch( g->w_terrain, offset + sound.xy(), '?' ); + for( const tripoint_bub_ms &sound : sounds_to_draw.second ) { + mvwaddch( g->w_terrain, sound.xy().raw() + offset, '?' ); } wattroff( g->w_terrain, c_red ); } ); diff --git a/src/display.cpp b/src/display.cpp index 1b313403a6398..09c6b455ab9ea 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -140,7 +140,7 @@ std::string display::get_temp( const Character &u ) std::string temp; if( u.cache_has_item_with( json_flag_THERMOMETER ) || u.has_flag( STATIC( json_character_flag( "THERMOMETER" ) ) ) ) { - temp = print_temperature( get_weather().get_temperature( u.pos() ) ); + temp = print_temperature( get_weather().get_temperature( u.pos_bub() ) ); } if( temp.empty() ) { return "-"; diff --git a/src/game.cpp b/src/game.cpp index 812686fb2e66e..b8653f4e88af0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3836,13 +3836,13 @@ void game::disp_NPCs() static void draw_footsteps( const catacurses::window &window, const tripoint_rel_ms &offset ) { wattron( window, c_yellow ); - for( const tripoint &footstep : sounds::get_footstep_markers() ) { + for( const tripoint_bub_ms &footstep : sounds::get_footstep_markers() ) { char glyph = '?'; - if( footstep.z != offset.z() ) { // Here z isn't an offset, but a coordinate - glyph = footstep.z > offset.z() ? '^' : 'v'; + if( footstep.z() != offset.z() ) { // Here z isn't an offset, but a coordinate + glyph = footstep.z() > offset.z() ? '^' : 'v'; } - mvwaddch( window, footstep.xy() + offset.raw().xy(), glyph ); + mvwaddch( window, footstep.raw().xy() + offset.raw().xy(), glyph ); } wattroff( window, c_yellow ); } @@ -5984,14 +5984,14 @@ void game::examine( bool with_pickup ) std::optional examp; if( with_pickup ) { // Examine and/or pick up items - examp = choose_adjacent_highlight_bub_ms( _( "Examine terrain, furniture, or items where?" ), - _( "There is nothing that can be examined nearby." ), - ACTION_EXAMINE_AND_PICKUP, false ); + examp = choose_adjacent_highlight( _( "Examine terrain, furniture, or items where?" ), + _( "There is nothing that can be examined nearby." ), + ACTION_EXAMINE_AND_PICKUP, false ); } else { // Examine but do not pick up items - examp = choose_adjacent_highlight_bub_ms( _( "Examine terrain or furniture where?" ), - _( "There is nothing that can be examined nearby." ), - ACTION_EXAMINE, false ); + examp = choose_adjacent_highlight( _( "Examine terrain or furniture where?" ), + _( "There is nothing that can be examined nearby." ), + ACTION_EXAMINE, false ); } if( !examp ) { @@ -6250,7 +6250,7 @@ bool game::warn_player_maybe_anger_local_faction( bool really_bad_offense, void game::pickup() { // Prompt for which adjacent/current tile to pick up items from - const std::optional where_ = choose_adjacent_highlight_bub_ms( + const std::optional where_ = choose_adjacent_highlight( _( "Pick up items where?" ), _( "There is nothing to pick up nearby." ), ACTION_PICKUP, false ); @@ -6464,7 +6464,7 @@ void game::print_all_tile_info( const tripoint_bub_ms &lp, const catacurses::win } const int max_width = getmaxx( w_look ) - column - 1; - std::string this_sound = sounds::sound_at( lp.raw() ); + std::string this_sound = sounds::sound_at( lp ); if( !this_sound.empty() ) { const int lines = fold_and_print( w_look, point( 1, ++line ), max_width, c_light_gray, _( "From here you heard %s" ), @@ -6478,7 +6478,7 @@ void game::print_all_tile_info( const tripoint_bub_ms &lp, const catacurses::win continue; } - std::string zlev_sound = sounds::sound_at( tmp.raw() ); + std::string zlev_sound = sounds::sound_at( tmp ); if( !zlev_sound.empty() ) { const int lines = fold_and_print( w_look, point( 1, ++line ), max_width, c_light_gray, tmp.z() > lp.z() ? @@ -9268,7 +9268,7 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list if( iActive >= 0 && static_cast( iActive ) < monster_list.size() ) { cCurMon = monster_list[iActive]; - iActivePos = cCurMon->pos() - u.pos(); + iActivePos = ( cCurMon->pos_bub() - u.pos_bub() ).raw(); centerlistview( iActivePos, width ); trail_start = u.pos_bub(); trail_end = cCurMon->pos_bub(); @@ -11907,13 +11907,13 @@ void game::water_affect_items( Character &ch ) const } // check flag first because its cheaper if( loc->has_flag( flag_WATER_DISSOLVE ) && !loc.protected_from_liquids() ) { - add_msg_if_player_sees( ch.pos(), m_bad, _( "%1$s %2$s dissolved in the water!" ), + add_msg_if_player_sees( ch.pos_bub(), m_bad, _( "%1$s %2$s dissolved in the water!" ), ch.disp_name( true, true ), loc->display_name() ); loc.remove_item(); } else if( loc->has_flag( flag_WATER_BREAK ) && !loc->is_broken() && !loc.protected_from_liquids() ) { - add_msg_if_player_sees( ch.pos(), m_bad, _( "The water destroyed %1$s %2$s!" ), + add_msg_if_player_sees( ch.pos_bub(), m_bad, _( "The water destroyed %1$s %2$s!" ), ch.disp_name( true ), loc->display_name() ); loc->deactivate(); // TODO: Maybe different types of wet faults? But I can't think of any. diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 34e395225f3fa..651af4629641f 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -580,14 +580,14 @@ static void pldrive( point d ) static void open() { avatar &player_character = get_avatar(); - const std::optional openp_ = choose_adjacent_highlight( _( "Open where?" ), - pgettext( "no door, gate, curtain, etc.", "There is nothing that can be opened nearby." ), - ACTION_OPEN, false ); + const std::optional openp_ = choose_adjacent_highlight( _( "Open where?" ), + pgettext( "no door, gate, curtain, etc.", "There is nothing that can be opened nearby." ), + ACTION_OPEN, false ); if( !openp_ ) { return; } - const tripoint_bub_ms openp = tripoint_bub_ms( *openp_ ); + const tripoint_bub_ms openp = *openp_; map &here = get_map(); player_character.mod_moves( -to_moves( 1_seconds ) ); @@ -665,7 +665,7 @@ static void open() static void close() { - if( const std::optional pnt = choose_adjacent_highlight_bub_ms( + if( const std::optional pnt = choose_adjacent_highlight( _( "Close where?" ), pgettext( "no door, gate, etc.", "There is nothing that can be closed nearby." ), ACTION_CLOSE, false ) ) { diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 1682aa2a9fcb4..708752de1e34c 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -154,7 +154,7 @@ static bool get_liquid_target( item &liquid, const item *const source, const int if( test_mode ) { switch( test_mode_spilling_action ) { case test_mode_spilling_action_t::spill_all: - target.pos = player_character.pos(); + target.pos = player_character.pos_bub().raw(); target.dest_opt = LD_GROUND; return true; case test_mode_spilling_action_t::cancel_spill: diff --git a/src/iexamine.cpp b/src/iexamine.cpp index f7a084d4425db..fd6f4c32c9441 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -2265,7 +2265,7 @@ void iexamine_helper::handle_harvest( Character &you, const std::string &itemid, { item harvest = item( itemid ); if( harvest.has_temperature() ) { - harvest.set_item_temperature( get_weather().get_temperature( you.pos() ) ); + harvest.set_item_temperature( get_weather().get_temperature( you.pos_bub() ) ); } if( !force_drop && you.can_pickVolume( harvest, true ) && you.can_pickWeight( harvest, !get_option( "DANGEROUS_PICKUPS" ) ) ) { @@ -4598,7 +4598,7 @@ void iexamine::shrub_wildveggies( Character &you, const tripoint_bub_ms &examp ) you.activity.auto_resume = true; } -void trap::examine( const tripoint &examp ) const +void trap::examine( const tripoint_bub_ms &examp ) const { avatar &player_character = get_avatar(); map &here = get_map(); @@ -4691,11 +4691,6 @@ void trap::examine( const tripoint &examp ) const } } -void trap::examine( const tripoint_bub_ms &examp ) const -{ - trap::examine( examp.raw() ); -} - void iexamine::part_con( Character &you, tripoint_bub_ms const &examp ) { map &here = get_map(); @@ -6763,7 +6758,7 @@ static void mill_load_food( Character &you, const tripoint_bub_ms &examp, Character &player_character = get_player_character(); // select from where to get the items from and place them - inv.form_from_map( player_character.pos(), PICKUP_RANGE, &player_character ); + inv.form_from_map( player_character.pos_bub(), PICKUP_RANGE, &player_character ); inv.remove_items_with( []( const item & it ) { return it.rotten(); } ); diff --git a/src/inventory.cpp b/src/inventory.cpp index ff2997d0c7606..42baa1a377d51 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -482,7 +482,7 @@ static int count_charges_in_list( const ammotype *ammotype, const map_stack &ite return 0; } -void inventory::form_from_map( const tripoint &origin, int range, const Character *pl, +void inventory::form_from_map( const tripoint_bub_ms &origin, int range, const Character *pl, bool assign_invlet, bool clear_path ) { @@ -492,40 +492,41 @@ void inventory::form_from_map( const tripoint &origin, int range, const Characte void inventory::form_from_zone( map &m, std::unordered_set &zone_pts, const Character *pl, bool assign_invlet ) { - std::vector pts; + std::vector pts; pts.reserve( zone_pts.size() ); for( const tripoint_abs_ms &elem : zone_pts ) { - pts.push_back( m.bub_from_abs( elem ).raw() ); + pts.push_back( m.bub_from_abs( elem ) ); } form_from_map( m, pts, pl, assign_invlet ); } -void inventory::form_from_map( map &m, const tripoint &origin, int range, const Character *pl, +void inventory::form_from_map( map &m, const tripoint_bub_ms &origin, int range, + const Character *pl, bool assign_invlet, bool clear_path ) { // populate a grid of spots that can be reached - std::vector reachable_pts = {}; + std::vector reachable_pts = {}; // If we need a clear path we care about the reachability of points if( clear_path ) { m.reachable_flood_steps( reachable_pts, origin, range, 1, 100 ); } else { // Fill reachable points with points_in_radius - tripoint_range in_radius = m.points_in_radius( origin, range ); - for( const tripoint &p : in_radius ) { + tripoint_range in_radius = m.points_in_radius( origin, range ); + for( const tripoint_bub_ms &p : in_radius ) { reachable_pts.emplace_back( p ); } } form_from_map( m, reachable_pts, pl, assign_invlet ); } -void inventory::form_from_map( map &m, std::vector pts, const Character *pl, +void inventory::form_from_map( map &m, std::vector pts, const Character *pl, bool assign_invlet ) { items.clear(); provisioned_pseudo_tools.clear(); - for( const tripoint &p : pts ) { + for( const tripoint_bub_ms &p : pts ) { const ter_id &t = m.ter( p ); // a temporary hack while trees are terrain if( t->has_flag( ter_furn_flag::TFLAG_TREE ) ) { diff --git a/src/inventory.h b/src/inventory.h index aaaf57689d65f..6f2a4474847f0 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -162,13 +162,13 @@ class inventory : public visitable void restack( Character &p ); void form_from_zone( map &m, std::unordered_set &zone_pts, const Character *pl = nullptr, bool assign_invlet = true ); - void form_from_map( const tripoint &origin, int range, const Character *pl = nullptr, + void form_from_map( const tripoint_bub_ms &origin, int range, const Character *pl = nullptr, bool assign_invlet = true, bool clear_path = true ); - void form_from_map( map &m, const tripoint &origin, int range, const Character *pl = nullptr, + void form_from_map( map &m, const tripoint_bub_ms &origin, int range, const Character *pl = nullptr, bool assign_invlet = true, bool clear_path = true ); - void form_from_map( map &m, std::vector pts, const Character *pl, + void form_from_map( map &m, std::vector pts, const Character *pl, bool assign_invlet = true ); /** * Remove a specific item from the inventory. The item is compared diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 4cc044ada0691..54c525d77b45b 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -1883,10 +1883,10 @@ const item_category *inventory_selector::naturalize_category( const item_categor return iter != categories.end() ? &*iter : nullptr; }; - const int dist = rl_dist( u.pos(), pos ); + const int dist = rl_dist( u.pos_bub().raw(), pos ); if( dist != 0 ) { - const std::string suffix = direction_suffix( u.pos(), pos ); + const std::string suffix = direction_suffix( u.pos_bub().raw(), pos ); const item_category_id id = item_category_id( string_format( "%s_%s", category.get_id().c_str(), suffix.c_str() ) ); diff --git a/src/item.cpp b/src/item.cpp index 089ae45242f54..d97521755db83 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -13092,7 +13092,7 @@ bool item::process_temperature_rot( float insulation, const tripoint_bub_ms &pos return false; } - units::temperature temp = get_weather().get_temperature( pos.raw() ); + units::temperature temp = get_weather().get_temperature( pos ); switch( flag ) { case temperature_flag::NORMAL: @@ -13159,7 +13159,7 @@ bool item::process_temperature_rot( float insulation, const tripoint_bub_ms &pos // Use weather if above ground, use map temp if below units::temperature env_temperature; if( pos.z() >= 0 && flag != temperature_flag::ROOT_CELLAR ) { - env_temperature = wgen.get_weather_temperature( pos.raw(), time, seed ); + env_temperature = wgen.get_weather_temperature( get_map().getglobal( pos ), time, seed ); } else { env_temperature = AVERAGE_ANNUAL_TEMPERATURE; } @@ -14032,7 +14032,7 @@ bool item::process_link( map &here, Character *carrier, const tripoint_bub_ms &p // Handle links to items in the inventory. if( link().source == link_state::solarpack ) { if( carrier == nullptr || !carrier->worn_with_flag( flag_SOLARPACK_ON ) ) { - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %s has come loose from the solar pack." ), + add_msg_if_player_sees( pos, m_bad, _( "The %s has come loose from the solar pack." ), link_name() ); reset_link( true, carrier ); return false; @@ -14043,7 +14043,7 @@ bool item::process_link( map &here, Character *carrier, const tripoint_bub_ms &p }; if( link().source == link_state::ups ) { if( carrier == nullptr || !carrier->cache_has_item_with( flag_IS_UPS, used_ups ) ) { - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %s has come loose from the UPS." ), link_name() ); + add_msg_if_player_sees( pos, m_bad, _( "The %s has come loose from the UPS." ), link_name() ); reset_link( true, carrier ); return false; } @@ -14073,7 +14073,7 @@ bool item::process_link( map &here, Character *carrier, const tripoint_bub_ms &p if( carrier != nullptr ) { carrier->add_msg_if_player( m_bad, _( "Your %s breaks loose!" ), cable_name ); } else { - add_msg_if_player_sees( pos.raw(), m_bad, _( "Your %s breaks loose!" ), cable_name ); + add_msg_if_player_sees( pos, m_bad, _( "Your %s breaks loose!" ), cable_name ); } return true; } else if( link().length + M_SQRT2 >= link().max_length + 1 && carrier != nullptr ) { @@ -14153,7 +14153,7 @@ bool item::process_link( map &here, Character *carrier, const tripoint_bub_ms &p } if( link().last_processed <= t_veh->part( link_vp_index ).last_disconnected ) { - add_msg_if_player_sees( pos.raw(), m_warning, string_format( _( "You detached the %s." ), + add_msg_if_player_sees( pos, m_warning, string_format( _( "You detached the %s." ), type_name() ) ); return reset_link( true, carrier, -2 ); } @@ -14302,7 +14302,7 @@ bool item::reset_link( bool unspool_if_too_long, Character *p, int vpart_index, if( p != nullptr ) { p->add_msg_if_player( m_warning, _( "Your %s has come loose." ), link_name() ); } else { - add_msg_if_player_sees( cable_position.raw(), m_warning, _( "The %s has come loose." ), + add_msg_if_player_sees( cable_position, m_warning, _( "The %s has come loose." ), link_name() ); } } diff --git a/src/item_pocket.cpp b/src/item_pocket.cpp index b98f70d123724..646187ff322df 100644 --- a/src/item_pocket.cpp +++ b/src/item_pocket.cpp @@ -1774,7 +1774,8 @@ static void move_to_parent_pocket_recursive( const tripoint &pos, item &it, carrier->add_msg_player_or_npc( m_bad, _( "Your %s falls to the ground." ), _( "'s %s falls to the ground." ), it.display_name() ); } else { - add_msg_if_player_sees( pos, m_bad, _( "The %s falls to the ground." ), it.display_name() ); + add_msg_if_player_sees( tripoint_bub_ms( pos ), m_bad, _( "The %s falls to the ground." ), + it.display_name() ); } here.add_item_or_charges( pos, it ); } diff --git a/src/iuse.cpp b/src/iuse.cpp index 684c704ff22ad..3b35e6193ea0a 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -729,7 +729,7 @@ std::optional iuse::fungicide( Character *p, item *, const tripoint_bub_ms if( monster *const mon_ptr = creatures.creature_at( dest ) ) { monster &critter = *mon_ptr; if( !critter.type->in_species( species_FUNGUS ) ) { - add_msg_if_player_sees( dest.raw(), m_warning, _( "The %s is covered in tiny spores!" ), + add_msg_if_player_sees( dest, m_warning, _( "The %s is covered in tiny spores!" ), critter.name() ); } if( !critter.make_fungus() ) { @@ -3342,7 +3342,7 @@ std::optional iuse::can_goo( Character *p, item *it, const tripoint_bub_ms found = here.passable( goop ) && here.tr_at( goop ).is_null(); } while( !found && tries < 10 ); if( found ) { - add_msg_if_player_sees( goop.raw(), m_warning, + add_msg_if_player_sees( goop, m_warning, _( "A nearby splatter of goo forms into a goo pit." ) ); here.trap_set( goop, tr_goo ); } else { @@ -7864,7 +7864,7 @@ std::optional iuse::multicooker_tick( Character *p, item *it, const tripoin meal.heat_up(); } else { meal.set_item_temperature( std::max( temperatures::cold, - get_weather().get_temperature( pos.raw() ) ) ); + get_weather().get_temperature( pos ) ) ); } it->active = false; @@ -7896,7 +7896,7 @@ std::optional iuse::weather_tool( Character *p, item *it, const tripoint_bu const w_point weatherPoint = *weather.weather_precise; /* Possibly used twice. Worth spending the time to precalculate. */ - const units::temperature player_local_temp = weather.get_temperature( p->pos_bub().raw() ); + const units::temperature player_local_temp = weather.get_temperature( p->pos_bub() ); if( it->typeId() == itype_weather_reader ) { p->add_msg_if_player( m_neutral, _( "The %s's monitor slowly outputs the data…" ), @@ -8218,8 +8218,8 @@ heating_requirements heating_requirements_for_weight( const units::mass &frozen, static std::optional> appliance_heater_selector( Character *p ) { - const std::optional pt = choose_adjacent_highlight( _( "Select an appliance." ), - _( "There is no appliance nearby." ), ACTION_EXAMINE, false ); + const std::optional pt = choose_adjacent_highlight( _( "Select an appliance." ), + _( "There is no appliance nearby." ), ACTION_EXAMINE, false ); if( !pt ) { p->add_msg_if_player( m_info, _( "You haven't selected any appliance." ) ); return std::nullopt; @@ -8251,7 +8251,7 @@ static std::optional> appliance_heater_selector( C p->add_msg_if_player( m_info, _( "You haven't selected any heater." ) ); return std::nullopt; } else { - return std::make_pair( pt.value(), pseudo_tools[app_menu.ret] ); + return std::make_pair( pt.value().raw(), pseudo_tools[app_menu.ret] ); } } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 2a49fce3ccdb2..47949fa62a211 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -406,7 +406,7 @@ ret_val iuse_transform::can_use( const Character &p, const item &it, std::map unmet_reqs; inventory inv; - inv.form_from_map( p.pos(), 1, &p, true, true ); + inv.form_from_map( p.pos_bub(), 1, &p, true, true ); for( const auto &quality : qualities_needed ) { if( !p.has_quality( quality.first, quality.second ) && !inv.has_quality( quality.first, quality.second ) ) { @@ -3957,7 +3957,7 @@ bool place_trap_actor::is_allowed( Character &p, const tripoint_bub_ms &pos, name ); } else { p.add_msg_if_player( m_bad, _( "You trigger a %s!" ), existing_trap.name() ); - existing_trap.trigger( pos.raw(), p ); + existing_trap.trigger( pos, p ); } return false; } diff --git a/src/magic.cpp b/src/magic.cpp index b2a5dc051c33b..69a6601af14e6 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -1221,7 +1221,7 @@ void spell::use_components( Character &guy ) const const requirement_data &spell_components = type->spell_components.obj(); // if we're here, we're assuming the Character has the correct components (using can_cast()) inventory map_inv; - map_inv.form_from_map( guy.pos(), 0, &guy, true, false ); + map_inv.form_from_map( guy.pos_bub(), 0, &guy, true, false ); for( const std::vector &comp_vec : spell_components.get_components() ) { guy.consume_items( guy.select_item_component( comp_vec, 1, map_inv ), 1 ); } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index a2e5e72926433..1a20bf806596d 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -617,7 +617,7 @@ static void damage_targets( const spell &sp, Creature &caster, } } else if( sp.damage( caster ) < 0 ) { sp.heal( target, caster ); - add_msg_if_player_sees( cr->pos(), m_good, _( "%s wounds are closing up!" ), + add_msg_if_player_sees( cr->pos_bub(), m_good, _( "%s wounds are closing up!" ), cr->disp_name( true ) ); } diff --git a/src/map.cpp b/src/map.cpp index 71928034624d0..10c2d03665428 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3125,7 +3125,7 @@ void map::drop_items( const tripoint_bub_ms &p ) } else if( creature_hit_chance < 100 ) { hit_part = creature_below->get_random_body_part_of_type( body_part_type::type::leg ); } else { - add_msg_if_player_sees( creature_below->pos(), _( "Falling %1$s misses %2$s!" ), i.tname(), + add_msg_if_player_sees( creature_below->pos_bub(), _( "Falling %1$s misses %2$s!" ), i.tname(), creature_below->disp_name() ); } // Did we hit at all? Then run the message. @@ -3133,10 +3133,10 @@ void map::drop_items( const tripoint_bub_ms &p ) if( hit_part.is_valid() && !creature_below->is_monster() ) { //~First positional argument: Item name. Second: Name of a person (e.g. "Jane") or player (e.g. "you"). Third: Body part name, accusative. const std::string msg = _( "Falling %1$s hits %2$s on the %3$s for %4$i damage!" ); - add_msg_if_player_sees( creature_below->pos(), msg, + add_msg_if_player_sees( creature_below->pos_bub(), msg, i.tname(), creature_below->disp_name(), hit_part->accusative, static_cast( damage ) ); } else { - add_msg_if_player_sees( creature_below->pos(), _( "Falling %1$s hits %2$s for %3$i damage!" ), + add_msg_if_player_sees( creature_below->pos_bub(), _( "Falling %1$s hits %2$s for %3$i damage!" ), i.tname(), creature_below->disp_name(), static_cast( damage ) ); } // FIXME: Hardcoded damage type! @@ -4147,16 +4147,16 @@ void map::smash_items( const tripoint_bub_ms &p, const int power, const std::str // Let the player know that the item was damaged if they can see it. if( items_destroyed > 1 ) { - add_msg_if_player_sees( p.raw(), m_bad, _( "The %s destroys several items!" ), cause_message ); + add_msg_if_player_sees( p, m_bad, _( "The %s destroys several items!" ), cause_message ); } else if( items_destroyed == 1 && items_damaged == 1 ) { //~ %1$s: the cause of destruction, %2$s: destroyed item name - add_msg_if_player_sees( p.raw(), m_bad, _( "The %1$s destroys the %2$s!" ), cause_message, + add_msg_if_player_sees( p, m_bad, _( "The %1$s destroys the %2$s!" ), cause_message, damaged_item_name ); } else if( items_damaged > 1 ) { - add_msg_if_player_sees( p.raw(), m_bad, _( "The %s damages several items." ), cause_message ); + add_msg_if_player_sees( p, m_bad, _( "The %s damages several items." ), cause_message ); } else if( items_damaged == 1 ) { //~ %1$s: the cause of damage, %2$s: damaged item name - add_msg_if_player_sees( p.raw(), m_bad, _( "The %1$s damages the %2$s." ), cause_message, + add_msg_if_player_sees( p, m_bad, _( "The %1$s damages the %2$s." ), cause_message, damaged_item_name ); } @@ -4882,7 +4882,7 @@ bool map::hit_with_acid( const tripoint_bub_ms &p ) t == ter_t_bars || t == ter_t_reb_cage ) { ter_set( p, ter_t_floor ); - add_msg_if_player_sees( p.raw(), m_warning, _( "The metal bars melt!" ) ); + add_msg_if_player_sees( p, m_warning, _( "The metal bars melt!" ) ); } else if( t == ter_t_door_b ) { if( one_in( 4 ) ) { ter_set( p, ter_t_door_frame ); @@ -5671,7 +5671,7 @@ item map::liquid_from( const tripoint_bub_ms &p ) const source_terrain.liquid_source_count == std::make_pair( 0, 0 ) ) { item ret( source_terrain.liquid_source_item_id, calendar::turn, item::INFINITE_CHARGES ); - ret.set_item_temperature( std::max( weather.get_temperature( p.raw() ), + ret.set_item_temperature( std::max( weather.get_temperature( p ), units::from_celsius( source_terrain.liquid_source_min_temp ) ) ); return ret; } @@ -7184,7 +7184,7 @@ void map::update_visibility_cache( const int zlev ) { Character &player_character = get_player_character(); if( !visibility_variables_cache.visibility_cache_dirty && - player_character.pos_bub().raw() == visibility_variables_cache.last_pos ) { + player_character.pos_bub() == visibility_variables_cache.last_pos ) { return; } @@ -7239,7 +7239,7 @@ void map::update_visibility_cache( const int zlev ) } #endif - visibility_variables_cache.last_pos = player_character.pos(); + visibility_variables_cache.last_pos = player_character.pos_bub(); visibility_variables_cache.visibility_cache_dirty = false; } @@ -8995,7 +8995,7 @@ void map::produce_sap( const tripoint_bub_ms &p, const time_duration &time_since item sap( "maple_sap", calendar::turn ); - sap.set_item_temperature( get_weather().get_temperature( p.raw() ) ); + sap.set_item_temperature( get_weather().get_temperature( p ) ); sap.charges = new_charges; // Is there a proper container? @@ -10459,7 +10459,7 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, c.add_msg_player_or_npc( m_bad, tr.get_trigger_message_u(), tr.get_trigger_message_npc(), tr.name() ); } - tr.trigger( pos.raw(), c ); + tr.trigger( pos, c ); } // TODO: Should be moved to submap or Creature? @@ -10622,7 +10622,7 @@ void map::maybe_trigger_trap( const tripoint_bub_ms &pos, Creature &c, const boo c.add_msg_player_or_npc( m_bad, tr.get_trigger_message_u(), tr.get_trigger_message_npc(), tr.name() ); } - tr.trigger( c.pos(), c ); + tr.trigger( c.pos_bub(), c ); } template diff --git a/src/map.h b/src/map.h index f3ef70b53cc1c..1d7d4a2c8cc96 100644 --- a/src/map.h +++ b/src/map.h @@ -133,7 +133,7 @@ struct visibility_variables { int u_clairvoyance = 0; float vision_threshold = 0.0f; std::optional clairvoyance_field; - tripoint last_pos; + tripoint_bub_ms last_pos; }; struct bash_params { @@ -304,7 +304,7 @@ struct drawsq_params { struct tile_render_info { struct common { - const tripoint pos; + const tripoint_bub_ms pos; // accumulator for 3d tallness of sprites rendered here so far; int height_3d = 0; diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 7e9c444ee9b28..c09e574041c47 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -3137,7 +3137,7 @@ class jmapgen_terrain : public jmapgen_piece_with_has_vehicle_collision if( is_boring_wall || act_trap == apply_action::act_erase ) { dat.m.remove_trap( p ); } else if( act_trap == apply_action::act_dismantle ) { - dat.m.tr_at( p ).on_disarmed( dat.m, p.raw() ); + dat.m.tr_at( p ).on_disarmed( dat.m, p ); } if( is_boring_wall || act_item == apply_action::act_erase ) { diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 97f51ecacdf32..5e4c01591c817 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -302,7 +302,7 @@ bool mon_spellcasting_actor::call( monster &mon ) const target_name = target_monster->disp_name(); } - add_msg_if_player_sees( target.raw(), spell_instance.message(), mon.disp_name(), + add_msg_if_player_sees( target, spell_instance.message(), mon.disp_name(), spell_instance.name(), target_name ); avatar fake_player; @@ -723,7 +723,7 @@ bool melee_actor::call( monster &z ) const if( uncanny_dodgeable && target->uncanny_dodge() ) { game_message_type msg_type = target->is_avatar() ? m_warning : m_info; sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), - sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_angle( z.pos_bub() ) ); target->add_msg_player_or_npc( msg_type, miss_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : translation(), z.name(), body_part_name_accusative( bp_id ) ); @@ -733,7 +733,7 @@ bool melee_actor::call( monster &z ) const if( dodgeable ) { if( hitspread < 0 ) { sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), - sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_angle( z.pos_bub() ) ); target->add_msg_player_or_npc( msg_type, miss_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : translation(), mon_name, body_part_name_accusative( bp_id ) ); @@ -868,7 +868,7 @@ bool melee_actor::call( monster &z ) const on_damage( z, *target, dealt_damage ); } else { sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), - sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_angle( z.pos_bub() ) ); target->add_msg_player_or_npc( msg_type, no_dmg_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? no_dmg_msg_npc : translation(), mon_name, body_part_name_accusative( grabbed_bp_id.value_or( bp_id ) ) ); @@ -934,7 +934,7 @@ void melee_actor::on_damage( monster &z, Creature &target, dealt_damage_instance { if( target.is_avatar() ) { sfx::play_variant_sound( "mon_bite", "bite_hit", sfx::get_heard_volume( z.pos_bub() ), - sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_angle( z.pos_bub() ) ); sfx::do_player_death_hurt( dynamic_cast( target ), false ); } game_message_type msg_type = target.attitude_to( get_player_character() ) == diff --git a/src/melee.cpp b/src/melee.cpp index f951063e269f8..31ede91cbb169 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -661,7 +661,7 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special, Character &player_character = get_player_character(); if( !hits ) { int stumble_pen = stumble( *this, cur_weapon ); - sfx::generate_melee_sound( pos(), t.pos(), false, false ); + sfx::generate_melee_sound( pos_bub(), t.pos_bub(), false, false ); const ma_technique miss_recovery = martial_arts_data->get_miss_recovery( *this ); @@ -873,7 +873,7 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special, material = "steel"; } } - sfx::generate_melee_sound( pos(), t.pos(), true, t.is_monster(), material ); + sfx::generate_melee_sound( pos_bub(), t.pos_bub(), true, t.is_monster(), material ); int dam = dealt_dam.total_damage(); melee::melee_stats.damage_amount += dam; diff --git a/src/messages.cpp b/src/messages.cpp index 3fbbf8c623563..3df98f1bd0981 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -1001,11 +1001,6 @@ void add_msg( const game_message_params ¶ms, std::string msg ) Messages::add_msg( params, std::move( msg ) ); } -void add_msg_if_player_sees( const tripoint &target, std::string msg ) -{ - add_msg_if_player_sees( tripoint_bub_ms( target ), std::move( msg ) ); -} - void add_msg_if_player_sees( const tripoint_bub_ms &target, std::string msg ) { if( get_player_view().sees( target ) ) { @@ -1020,12 +1015,6 @@ void add_msg_if_player_sees( const Creature &target, std::string msg ) } } -void add_msg_if_player_sees( const tripoint &target, const game_message_params ¶ms, - std::string msg ) -{ - add_msg_if_player_sees( tripoint_bub_ms( target ), params, std::move( msg ) ); -} - void add_msg_if_player_sees( const tripoint_bub_ms &target, const game_message_params ¶ms, std::string msg ) { diff --git a/src/messages.h b/src/messages.h index 7d522173ace9f..ddaa551ee9b99 100644 --- a/src/messages.h +++ b/src/messages.h @@ -78,12 +78,10 @@ inline void add_msg( const game_message_params ¶ms, const char *const msg, A return add_msg( params, string_format( msg, std::forward( args )... ) ); } -// TODO: Get rid of untyped overload -void add_msg_if_player_sees( const tripoint &target, std::string msg ); void add_msg_if_player_sees( const tripoint_bub_ms &target, std::string msg ); void add_msg_if_player_sees( const Creature &target, std::string msg ); template -inline void add_msg_if_player_sees( const tripoint &target, const std::string &msg, +inline void add_msg_if_player_sees( const tripoint_bub_ms &target, const std::string &msg, Args &&... args ) { return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); @@ -95,11 +93,6 @@ inline void add_msg_if_player_sees( const Creature &target, const std::string &m return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); } template -inline void add_msg_if_player_sees( const tripoint &target, const char *const msg, Args &&... args ) -{ - return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); -} -template inline void add_msg_if_player_sees( const tripoint_bub_ms &target, const char *const msg, Args &&... args ) { @@ -111,7 +104,7 @@ inline void add_msg_if_player_sees( const Creature &target, const char *const ms return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); } template -inline void add_msg_if_player_sees( const tripoint &target, const translation &msg, +inline void add_msg_if_player_sees( const tripoint_bub_ms &target, const translation &msg, Args &&... args ) { return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); @@ -123,15 +116,13 @@ inline void add_msg_if_player_sees( const Creature &target, const translation &m return add_msg_if_player_sees( target, string_format( msg, std::forward( args )... ) ); } -// TODO: Get rid of untyped overload -void add_msg_if_player_sees( const tripoint &target, const game_message_params ¶ms, - std::string msg ); void add_msg_if_player_sees( const tripoint_bub_ms &target, const game_message_params ¶ms, std::string msg ); void add_msg_if_player_sees( const Creature &target, const game_message_params ¶ms, std::string msg ); template -inline void add_msg_if_player_sees( const tripoint &target, const game_message_params ¶ms, +inline void add_msg_if_player_sees( const tripoint_bub_ms &target, + const game_message_params ¶ms, const std::string &msg, Args &&... args ) { if( params.type == m_debug && !debug_mode ) { @@ -151,7 +142,8 @@ inline void add_msg_if_player_sees( const Creature &target, const game_message_p std::forward( args )... ) ); } template -inline void add_msg_if_player_sees( const tripoint &target, const game_message_params ¶ms, +inline void add_msg_if_player_sees( const tripoint_bub_ms &target, + const game_message_params ¶ms, const char *const msg, Args &&... args ) { if( params.type == m_debug && !debug_mode ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index febffc35aea21..accb7b260d50f 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -4460,7 +4460,7 @@ bool mattack::kamikaze( monster *z ) */ // END HORRIBLE HACK - add_msg_if_player_sees( z->pos(), m_bad, _( "The %s lights up menacingly." ), z->name() ); + add_msg_if_player_sees( z->pos_bub(), m_bad, _( "The %s lights up menacingly." ), z->name() ); return true; } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index e8a7cf1499eda..232dacf5e8140 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -212,7 +212,7 @@ item_location mdeath::splatter( monster &z ) void mdeath::disappear( monster &z ) { if( !z.type->has_flag( mon_flag_SILENT_DISAPPEAR ) ) { - add_msg_if_player_sees( z.pos(), m_good, _( "The %s disappears." ), z.name() ); + add_msg_if_player_sees( z.pos_bub(), m_good, _( "The %s disappears." ), z.name() ); } } @@ -274,9 +274,9 @@ void mdeath::broken( monster &z ) // TODO: make mdeath::splatter work for robots if( broken_mon.damage() >= broken_mon.max_damage() ) { - add_msg_if_player_sees( z.pos(), m_good, _( "The %s is destroyed!" ), z.name() ); + add_msg_if_player_sees( z.pos_bub(), m_good, _( "The %s is destroyed!" ), z.name() ); } else { - add_msg_if_player_sees( z.pos(), m_good, _( "The %s collapses!" ), z.name() ); + add_msg_if_player_sees( z.pos_bub(), m_good, _( "The %s collapses!" ), z.name() ); } } diff --git a/src/monmove.cpp b/src/monmove.cpp index 2dab24972529d..c52478b7ceb97 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1419,7 +1419,7 @@ void monster::footsteps( const tripoint_bub_ms &p ) return; } int dist = rl_dist( p, get_player_character().pos_bub() ); - sounds::add_footstep( p.raw(), volume, dist, this, type->get_footsteps() ); + sounds::add_footstep( p, volume, dist, this, type->get_footsteps() ); } tripoint_bub_ms monster::scent_move() @@ -2433,7 +2433,7 @@ void monster::shove_vehicle( const tripoint_bub_ms &remote_destination, } if( shove_velocity > 0 ) { //~ %1$s - monster name, %2$s - vehicle name - add_msg_if_player_sees( this->pos(), m_bad, _( "%1$s shoves %2$s out of their way!" ), + add_msg_if_player_sees( this->pos_bub(), m_bad, _( "%1$s shoves %2$s out of their way!" ), this->disp_name(), veh.disp_name() ); int shove_moves = shove_veh_mass_moves_factor * veh_mass / 10_kilogram; diff --git a/src/monster.cpp b/src/monster.cpp index 26098492e5c19..78ac5154edd31 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2868,10 +2868,10 @@ void monster::process_turn() if( t == ter_t_gas_pump || t == ter_t_gas_pump_a ) { if( one_in( 4 ) ) { explosion_handler::explosion( this, pos_bub(), 40, 0.8, true ); - add_msg_if_player_sees( zap.raw(), m_warning, _( "The %s explodes in a fiery inferno!" ), + add_msg_if_player_sees( zap, m_warning, _( "The %s explodes in a fiery inferno!" ), here.tername( zap ) ); } else { - add_msg_if_player_sees( zap.raw(), m_warning, _( "Lightning from %1$s engulfs the %2$s!" ), + add_msg_if_player_sees( zap, m_warning, _( "Lightning from %1$s engulfs the %2$s!" ), name(), here.tername( zap ) ); here.add_field( zap, fd_fire, 1, 2_turns ); } @@ -3531,7 +3531,7 @@ bool monster::make_fungus() const std::string old_name = name(); poly( type->fungalize_into ); - add_msg_if_player_sees( pos(), m_info, _( "The spores transform %1$s into a %2$s!" ), + add_msg_if_player_sees( pos_bub(), m_info, _( "The spores transform %1$s into a %2$s!" ), old_name, name() ); return true; diff --git a/src/npc.cpp b/src/npc.cpp index bd5c83598dc28..e60e9e5bf1070 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1396,7 +1396,7 @@ void npc::do_npc_read( bool ebook ) book = book.obtain( *npc_character ); if( can_read( *book, fail_reasons ) ) { - add_msg_if_player_sees( pos(), _( "%s starts reading." ), disp_name() ); + add_msg_if_player_sees( pos_bub(), _( "%s starts reading." ), disp_name() ); // NPCs can't read to other NPCs yet const time_duration time_taken = time_to_read( *book, *this ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index c8423cb231756..5a0fcf59f3ba2 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -4790,7 +4790,7 @@ void npc::reach_omt_destination() if( rl_dist( player_character.pos_bub(), pos_bub() ) > SEEX * 2 ) { if( player_character.cache_has_item_with_flag( flag_TWO_WAY_RADIO, true ) && cache_has_item_with_flag( flag_TWO_WAY_RADIO, true ) ) { - add_msg_if_player_sees( pos(), m_info, _( "From your two-way radio you hear %s reporting in, " + add_msg_if_player_sees( pos_bub(), m_info, _( "From your two-way radio you hear %s reporting in, " "'I've arrived, boss!'" ), disp_name() ); } } @@ -5367,7 +5367,7 @@ void npc::do_reload( const item_location &it ) if( get_player_view().sees( *this ) ) { add_msg( _( "%1$s reloads their %2$s." ), get_name(), it->tname() ); sfx::play_variant_sound( "reload", it->typeId().str(), sfx::get_heard_volume( pos_bub() ), - sfx::get_heard_angle( pos() ) ); + sfx::get_heard_angle( pos_bub() ) ); } // Otherwise the NPC may not equip the weapon until they see danger diff --git a/src/pixel_minimap.cpp b/src/pixel_minimap.cpp index 60c5f1f800a8d..7d64b3cfb5d11 100644 --- a/src/pixel_minimap.cpp +++ b/src/pixel_minimap.cpp @@ -548,7 +548,7 @@ void pixel_minimap::render_critters( const tripoint ¢er ) } //the main call for drawing the pixel minimap to the screen -void pixel_minimap::draw( const SDL_Rect &screen_rect, const tripoint ¢er ) +void pixel_minimap::draw( const SDL_Rect &screen_rect, const tripoint_bub_ms ¢er ) { if( !g ) { return; @@ -559,8 +559,8 @@ void pixel_minimap::draw( const SDL_Rect &screen_rect, const tripoint ¢er ) } set_screen_rect( screen_rect ); - process_cache( center ); - render( center ); + process_cache( center.raw() ); + render( center.raw() ); } void pixel_minimap::draw_beacon( const SDL_Rect &rect, const SDL_Color &color ) diff --git a/src/pixel_minimap.h b/src/pixel_minimap.h index 3eb597c66d708..a4333ed0fb8a3 100644 --- a/src/pixel_minimap.h +++ b/src/pixel_minimap.h @@ -5,6 +5,7 @@ #include #include +#include "coords_fwd.h" #include "point.h" #include "sdl_wrappers.h" #include "sdl_geometry.h" @@ -40,7 +41,7 @@ class pixel_minimap void set_type( pixel_minimap_type type ); void set_settings( const pixel_minimap_settings &settings ); - void draw( const SDL_Rect &screen_rect, const tripoint ¢er ); + void draw( const SDL_Rect &screen_rect, const tripoint_bub_ms ¢er ); private: struct submap_cache; diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 55d34979b5140..e80c7e80dcbc7 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -1283,7 +1283,7 @@ void Character::hardcoded_effects( effect &it ) body_part_name_accusative( bp ) ); } else { //~ 1$s is NPC name, 2$s is bodypart in accusative. - add_msg_if_player_sees( pos(), _( "%1$s starts scratching their %2$s!" ), get_name(), + add_msg_if_player_sees( pos_bub(), _( "%1$s starts scratching their %2$s!" ), get_name(), body_part_name_accusative( bp ) ); } mod_moves( -to_moves( 1_seconds ) * 1.5 ); diff --git a/src/ranged.cpp b/src/ranged.cpp index 01055ea7f72b1..3eb4b1ccb233f 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -2268,7 +2268,7 @@ static void cycle_action( item &weap, const itype_id &ammo, const tripoint &pos tiles.erase( std::remove_if( tiles.begin(), tiles.end(), [&]( const tripoint & e ) { return !here.passable( e ); } ), tiles.end() ); - tripoint eject = tiles.empty() ? pos : random_entry( tiles ); + tripoint_bub_ms eject{ tiles.empty() ? pos : random_entry( tiles ) }; // for turrets try and drop casings or linkages directly to any CARGO part on the same tile const std::optional ovp_cargo = weap.has_flag( flag_VEHICLE ) diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index cc9fa46776b41..7a81e956fb40f 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -993,12 +993,14 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt ¢er_abs_ const tripoint_abs_omt &guy_loc = guy->global_omt_location(); if( guy_loc.z() == center_pos.z() && ( has_debug_vision || overmap_buffer.seen_more_than( guy_loc, om_vision_level::details ) ) ) { - draw_entity_with_overlays( *guy, global_omt_to_draw_position( guy_loc ), lit_level::LIT, + draw_entity_with_overlays( *guy, tripoint_bub_ms( global_omt_to_draw_position( guy_loc ) ), + lit_level::LIT, height_3d ); } } - draw_entity_with_overlays( get_player_character(), global_omt_to_draw_position( avatar_pos ), + draw_entity_with_overlays( get_player_character(), + tripoint_bub_ms( global_omt_to_draw_position( avatar_pos ) ), lit_level::LIT, height_3d ); if( !fast_traveling ) { draw_from_id_string( "cursor", global_omt_to_draw_position( center_pos ), 0, 0, lit_level::LIT, @@ -1348,7 +1350,7 @@ void cata_cursesport::curses_drawwindow( const catacurses::window &w ) // skip the normal drawing code for it. tilecontext->draw( point( win->pos.x * fontwidth, win->pos.y * fontheight ), - g->ter_view_p.raw(), + g->ter_view_p, TERRAIN_WINDOW_TERM_WIDTH * font->width, TERRAIN_WINDOW_TERM_HEIGHT * font->height, overlay_strings, @@ -1459,8 +1461,8 @@ void cata_cursesport::curses_drawwindow( const catacurses::window &w ) clear_window_area( w ); tilecontext->draw_minimap( point( win->pos.x * fontwidth, win->pos.y * fontheight ), - tripoint( get_player_character().pos_bub().raw().xy(), g->ter_view_p.z() ), - win->width * font->width, win->height * font->height ); + { get_player_character().pos_bub().xy(), g->ter_view_p.z() }, + win->width * font->width, win->height * font->height ); update = true; } else { diff --git a/src/sounds.cpp b/src/sounds.cpp index d5392e0401ccb..1633b65c6af62 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -238,11 +238,11 @@ std::string enum_to_string( sounds::sound_t data ) // Static globals tracking sounds events of various kinds. // The sound events since the last monster turn. -static std::vector> recent_sounds; +static std::vector> recent_sounds; // The sound events since the last interactive player turn. (doesn't count sleep etc) -static std::vector> sounds_since_last_turn; +static std::vector> sounds_since_last_turn; // The sound events currently displayed to the player. -static std::unordered_map sound_markers; +static std::unordered_map sound_markers; // This is an attempt to handle attenuation of sound for underground areas. // The main issue it addresses is that you can hear activity @@ -250,10 +250,10 @@ static std::unordered_map sound_markers; // My research indicates that attenuation through soil-like materials is as // high as 100x the attenuation through air, plus vertical distances are // roughly five times as large as horizontal ones. -static int sound_distance( const tripoint &source, const tripoint &sink ) +static int sound_distance( const tripoint_bub_ms &source, const tripoint_bub_ms &sink ) { - const int lower_z = std::min( source.z, sink.z ); - const int upper_z = std::max( source.z, sink.z ); + const int lower_z = std::min( source.z(), sink.z() ); + const int upper_z = std::max( source.z(), sink.z() ); const int vertical_displacement = upper_z - lower_z; int vertical_attenuation = vertical_displacement; if( lower_z < 0 && vertical_displacement > 0 ) { @@ -308,19 +308,14 @@ static bool is_provocative( sounds::sound_t category ) cata_fatal( "Invalid sound_t category" ); } -void sounds::ambient_sound( const tripoint &p, int vol, sound_t category, - const std::string &description ) -{ - sound( p, vol, category, description, true ); -} - void sounds::ambient_sound( const tripoint_bub_ms &p, int vol, sound_t category, const std::string &description ) { - sounds::ambient_sound( p.raw(), vol, category, description ); + sound( p, vol, category, description, true ); } -void sounds::sound( const tripoint &p, int vol, sound_t category, const std::string &description, +void sounds::sound( const tripoint_bub_ms &p, int vol, sound_t category, + const std::string &description, bool ambient, const std::string &id, const std::string &variant ) { if( vol < 0 ) { @@ -330,37 +325,24 @@ void sounds::sound( const tripoint &p, int vol, sound_t category, const std::str } // Description is not an optional parameter if( description.empty() ) { - debugmsg( "Sound at %d:%d has no description!", p.x, p.y ); + debugmsg( "Sound at %d:%d has no description!", p.x(), p.y() ); } const season_type seas = season_of_year( calendar::turn ); const std::string seas_str = season_str( seas ); recent_sounds.emplace_back( p, monster_sound_event{ vol, is_provocative( category ) } ); sounds_since_last_turn.emplace_back( p, - sound_event { vol, category, description, ambient, + sound_event{ vol, category, description, ambient, false, id, variant, seas_str } ); } -void sounds::sound( const tripoint_bub_ms &p, int vol, sound_t category, - const std::string &description, - bool ambient, const std::string &id, const std::string &variant ) -{ - sounds::sound( p.raw(), vol, category, description, ambient, id, variant ); -} - -void sounds::sound( const tripoint &p, int vol, sound_t category, const translation &description, - bool ambient, const std::string &id, const std::string &variant ) -{ - sounds::sound( p, vol, category, description.translated(), ambient, id, variant ); -} - void sounds::sound( const tripoint_bub_ms &p, int vol, sound_t category, const translation &description, bool ambient, const std::string &id, const std::string &variant ) { - sounds::sound( p.raw(), vol, category, description, ambient, id, variant ); + sounds::sound( p, vol, category, description.translated(), ambient, id, variant ); } -void sounds::add_footstep( const tripoint &p, int volume, int, monster *, +void sounds::add_footstep( const tripoint_bub_ms &p, int volume, int, monster *, const std::string &footstep ) { const season_type seas = season_of_year( calendar::turn ); @@ -380,8 +362,9 @@ static void vector_quick_remove( std::vector &source, int index ) source.pop_back(); } -static std::vector cluster_sounds( std::vector> - input_sounds ) +static std::vector cluster_sounds( + std::vector> + input_sounds ) { // If there are too many monsters and too many noise sources (which can be monsters, go figure), // applying sound events to monsters can dominate processing time for the whole game, @@ -395,8 +378,8 @@ static std::vector cluster_sounds( std::vector( 10 ) ), static_cast( std::log( input_sounds.size() ) ) ); const size_t stopping_point = input_sounds.size() - num_seed_clusters; - const size_t max_map_distance = sound_distance( tripoint( point::zero, OVERMAP_DEPTH ), - tripoint( MAPSIZE_X, MAPSIZE_Y, OVERMAP_HEIGHT ) ); + const size_t max_map_distance = sound_distance( { point_bub_ms::zero, OVERMAP_DEPTH }, + { MAPSIZE_X, MAPSIZE_Y, OVERMAP_HEIGHT } ); // Randomly choose cluster seeds. for( size_t i = input_sounds.size(); i > stopping_point; i-- ) { size_t index = rng( 0, i - 1 ); @@ -404,8 +387,8 @@ static std::vector cluster_sounds( std::vectorfloat conversions are safe. { - static_cast( input_sounds[index].first.x ), static_cast( input_sounds[index].first.y ), - static_cast( input_sounds[index].first.z ), + static_cast( input_sounds[index].first.x() ), static_cast( input_sounds[index].first.y() ), + static_cast( input_sounds[index].first.z() ), static_cast( input_sounds[index].second.volume ), static_cast( input_sounds[index].second.volume ), input_sounds[index].second.provocative } ); @@ -418,8 +401,8 @@ static std::vector cluster_sounds( std::vector( centroid_iter->x ), static_cast( centroid_iter->y ), static_cast( centroid_iter->z ) }; - const int dist = sound_distance( sound_event_pair.first, centroid_pos ); + tripoint_bub_ms centroid_pos { static_cast( centroid_iter->x ), static_cast( centroid_iter->y ), static_cast( centroid_iter->z ) }; + const int dist = sound_distance( tripoint_bub_ms( sound_event_pair.first ), centroid_pos ); if( dist * dist < dist_factor ) { found_centroid = centroid_iter; dist_factor = dist * dist; @@ -428,13 +411,13 @@ static std::vector cluster_sounds( std::vector( sound_event_pair.second.volume ) + found_centroid->weight; // Set the centroid location to the average of the two locations, weighted by volume. - found_centroid->x = static_cast( ( sound_event_pair.first.x * + found_centroid->x = static_cast( ( sound_event_pair.first.x() * sound_event_pair.second.volume ) + ( found_centroid->x * found_centroid->weight ) ) / volume_sum; - found_centroid->y = static_cast( ( sound_event_pair.first.y * + found_centroid->y = static_cast( ( sound_event_pair.first.y() * sound_event_pair.second.volume ) + ( found_centroid->y * found_centroid->weight ) ) / volume_sum; - found_centroid->z = static_cast( ( sound_event_pair.first.z * + found_centroid->z = static_cast( ( sound_event_pair.first.z() * sound_event_pair.second.volume ) + ( found_centroid->z * found_centroid->weight ) ) / volume_sum; // Set the centroid volume to the larger of the volumes. @@ -497,7 +480,7 @@ void sounds::process_sounds() // Alert all monsters (that can hear) to the sound. for( monster &critter : g->all_monsters() ) { // TODO: Generalize this to Creature::hear_sound - const int dist = sound_distance( source.raw(), critter.pos() ); + const int dist = sound_distance( source, critter.pos_bub() ); if( vol * 2 > dist ) { // Exclude monsters that certainly won't hear the sound critter.hear_sound( source, vol, dist, this_centroid.provocative ); @@ -506,12 +489,12 @@ void sounds::process_sounds() // Trigger sound-triggered traps and ensure they are still valid for( const trap *trapType : trap::get_sound_triggered_traps() ) { for( const tripoint_bub_ms &tp : get_map().trap_locations( trapType->id ) ) { - const int dist = sound_distance( source.raw(), tp.raw() ); + const int dist = sound_distance( source, tp ); const trap &tr = get_map().tr_at( tp ); // Exclude traps that certainly won't hear the sound if( vol * 2 > dist ) { if( tr.triggered_by_sound( vol, dist ) ) { - tr.trigger( tp.raw() ); + tr.trigger( tp ); } } } @@ -582,7 +565,7 @@ void sounds::process_sound_markers( Character *you ) // so the references may become invalid after the vector enlarged its internal buffer const tripoint_bub_ms pos = tripoint_bub_ms( sounds_since_last_turn[i].first ); const sound_event sound = sounds_since_last_turn[i].second; - const int distance_to_sound = sound_distance( you->pos_bub().raw(), pos.raw() ); + const int distance_to_sound = sound_distance( you->pos_bub(), pos ); const int raw_volume = sound.volume; // The felt volume of a sound is not affected by negative multipliers, such as already @@ -769,10 +752,10 @@ void sounds::process_sound_markers( Character *you ) // Enumerate the valid points the player *cannot* see. // Unless the source is on a different z-level, then any point is fine // Also show sensory sounds like SONAR even if we can see the point. - std::vector unseen_points; + std::vector unseen_points; for( const tripoint_bub_ms &newp : get_map().points_in_radius( pos, err_offset ) ) { if( diff_z || sound.category == sound_t::sensory || !you->sees( newp ) ) { - unseen_points.emplace_back( newp.raw() ); + unseen_points.emplace_back( newp ); } } @@ -798,10 +781,10 @@ void sounds::reset_markers() sound_markers.clear(); } -std::vector sounds::get_footstep_markers() +std::vector sounds::get_footstep_markers() { // Optimization, make this static and clear it in reset_markers? - std::vector footsteps; + std::vector footsteps; footsteps.reserve( sound_markers.size() ); for( const auto &mark : sound_markers ) { footsteps.push_back( mark.first ); @@ -809,15 +792,15 @@ std::vector sounds::get_footstep_markers() return footsteps; } -std::pair, std::vector> sounds::get_monster_sounds() +std::pair, std::vector> sounds::get_monster_sounds() { auto sound_clusters = cluster_sounds( recent_sounds ); - std::vector sound_locations; + std::vector sound_locations; sound_locations.reserve( recent_sounds.size() ); for( const auto &sound : recent_sounds ) { sound_locations.push_back( sound.first ); } - std::vector cluster_centroids; + std::vector cluster_centroids; cluster_centroids.reserve( sound_clusters.size() ); for( const centroid &sound : sound_clusters ) { cluster_centroids.emplace_back( static_cast( sound.x ), static_cast( sound.y ), @@ -826,7 +809,7 @@ std::pair, std::vector> sounds::get_monster_soun return { sound_locations, cluster_centroids }; } -std::string sounds::sound_at( const tripoint &location ) +std::string sounds::sound_at( const tripoint_bub_ms &location ) { auto this_sound = sound_markers.find( location ); if( this_sound == sound_markers.end() ) { @@ -1025,7 +1008,7 @@ void sfx::do_vehicle_engine_sfx() add_msg_debug( debugmode::DF_SOUND, "STOP speed %d =/= %d", current_speed, previous_speed ); play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, - sfx::get_heard_volume( player_character.pos() ), ch, 1000, pitch ); + sfx::get_heard_volume( player_character.pos_bub() ), ch, 1000, pitch ); add_msg_debug( debugmode::DF_SOUND, "PITCH %f", pitch ); } previous_speed = current_speed; @@ -1063,10 +1046,10 @@ void sfx::do_vehicle_exterior_engine_sfx() for( wrapped_vehicle vehicle : vehs ) { if( vehicle.v->vehicle_noise > 0 && vehicle.v->vehicle_noise - - sound_distance( player_character.pos_bub().raw(), vehicle.v->pos_bub().raw() ) > noise_factor ) { + sound_distance( player_character.pos_bub(), vehicle.v->pos_bub() ) > noise_factor ) { - noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos_bub().raw(), - vehicle.v->pos_bub().raw() ); + noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos_bub(), + vehicle.v->pos_bub() ); veh = vehicle.v; } } @@ -1105,7 +1088,7 @@ void sfx::do_vehicle_exterior_engine_sfx() if( is_channel_playing( ch ) ) { if( engine_external_id_and_variant == id_and_variant ) { - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "PLAYING exterior_engine_sound, vol: ex:%d true:%d", vol, Mix_Volume( ch_int, -1 ) ); @@ -1115,7 +1098,7 @@ void sfx::do_vehicle_exterior_engine_sfx() add_msg_debug( debugmode::DF_SOUND, "STOP exterior_engine_sound, change id/var" ); play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound %s %s vol: %d", id_and_variant.first, @@ -1126,7 +1109,7 @@ void sfx::do_vehicle_exterior_engine_sfx() play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub() ) ), 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound NEW %s %s vol: ex:%d true:%d", @@ -1327,7 +1310,7 @@ void sfx::generate_gun_sound( const Character &source_arg, const item &firing ) if( std::chrono::duration_cast ( sfx_time ).count() < 80 ) { return; } - const tripoint source = source_arg.pos(); + const tripoint_bub_ms source = source_arg.pos_bub(); int heard_volume = get_heard_volume( source ); if( heard_volume <= 30 ) { heard_volume = 30; @@ -1343,7 +1326,7 @@ void sfx::generate_gun_sound( const Character &source_arg, const item &firing ) const bool indoors = !is_creature_outside( player_character ); const bool night = is_night( calendar::turn ); // this does not mean p == avatar (it could be a vehicle turret) - if( player_character.pos() == source ) { + if( player_character.pos_bub() == source ) { selected_sound = "fire_gun"; const auto mods = firing.gunmods(); @@ -1356,7 +1339,7 @@ void sfx::generate_gun_sound( const Character &source_arg, const item &firing ) } else { angle = get_heard_angle( source ); - distance = sound_distance( player_character.pos(), source ); + distance = sound_distance( player_character.pos_bub(), source ); if( distance <= 17 ) { selected_sound = "fire_gun"; } else { @@ -1372,7 +1355,7 @@ void sfx::generate_gun_sound( const Character &source_arg, const item &firing ) namespace sfx { struct sound_thread { - sound_thread( const tripoint &source, const tripoint &target, bool hit, bool targ_mon, + sound_thread( const tripoint_bub_ms &source, const tripoint_bub_ms &target, bool hit, bool targ_mon, const std::string &material ); bool hit; @@ -1392,7 +1375,8 @@ struct sound_thread { }; } // namespace sfx -void sfx::generate_melee_sound( const tripoint &source, const tripoint &target, bool hit, +void sfx::generate_melee_sound( const tripoint_bub_ms &source, const tripoint_bub_ms &target, + bool hit, bool targ_mon, const std::string &material ) { @@ -1417,7 +1401,8 @@ void sfx::generate_melee_sound( const tripoint &source, const tripoint &target, } } -sfx::sound_thread::sound_thread( const tripoint &source, const tripoint &target, const bool hit, +sfx::sound_thread::sound_thread( const tripoint_bub_ms &source, const tripoint_bub_ms &target, + const bool hit, const bool targ_mon, const std::string &material ) : hit( hit ) , targ_mon( targ_mon ) @@ -1509,7 +1494,7 @@ void sfx::do_projectile_hit( const Creature &target ) } const int heard_volume = sfx::get_heard_volume( target.pos_bub() ); - const units::angle angle = get_heard_angle( target.pos() ); + const units::angle angle = get_heard_angle( target.pos_bub() ); const season_type seas = season_of_year( calendar::turn ); const std::string seas_str = season_str( seas ); const bool indoors = !is_creature_outside( get_player_character() ); @@ -2008,7 +1993,7 @@ void sfx::play_ambient_variant_sound( const std::string &, const std::string &, void sfx::play_activity_sound( const std::string &, const std::string &, int ) { } void sfx::end_activity_sounds() { } void sfx::generate_gun_sound( const Character &, const item & ) { } -void sfx::generate_melee_sound( const tripoint &, const tripoint &, bool, bool, +void sfx::generate_melee_sound( const tripoint_bub_ms &, const tripoint_bub_ms &, bool, bool, const std::string & ) { } void sfx::do_hearing_loss( int ) { } void sfx::remove_hearing_loss() { } @@ -2046,9 +2031,9 @@ void sfx::play_variant_sound( const std::string &, const std::string &, const st /** Functions from sfx that do not use the SDL_mixer API at all. They can be used in builds * without sound support. */ /*@{*/ -int sfx::get_heard_volume( const tripoint &source ) +int sfx::get_heard_volume( const tripoint_bub_ms &source ) { - int distance = sound_distance( get_player_character().pos(), source ); + int distance = sound_distance( get_player_character().pos_bub(), source ); // fract = -100 / 24 const float fract = -4.166666f; int heard_volume = fract * distance - 1 + 100; @@ -2059,14 +2044,9 @@ int sfx::get_heard_volume( const tripoint &source ) return heard_volume; } -int sfx::get_heard_volume( const tripoint_bub_ms &source ) -{ - return sfx::get_heard_volume( source.raw() ); -} - -units::angle sfx::get_heard_angle( const tripoint &source ) +units::angle sfx::get_heard_angle( const tripoint_bub_ms &source ) { - units::angle angle = coord_to_angle( get_player_character().pos(), source ) + 90_degrees; + units::angle angle = coord_to_angle( get_player_character().pos_bub(), source ) + 90_degrees; //add_msg(m_warning, "angle: %i", angle); return angle; } diff --git a/src/sounds.h b/src/sounds.h index b34b6ea4a7c6c..45854632806e4 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -53,27 +53,17 @@ enum class sound_t : int { * @param variant Variant of sound effect given in id * @returns true if the player could hear the sound. */ -// TODO: Get rid of untyped overload. -void sound( const tripoint &p, int vol, sound_t category, const std::string &description, - bool ambient = false, const std::string &id = "", - const std::string &variant = "default" ); void sound( const tripoint_bub_ms &p, int vol, sound_t category, const std::string &description, bool ambient = false, const std::string &id = "", const std::string &variant = "default" ); -// TODO: Get rid of untyped overload. -void sound( const tripoint &p, int vol, sound_t category, const translation &description, - bool ambient = false, const std::string &id = "", - const std::string &variant = "default" ); void sound( const tripoint_bub_ms &p, int vol, sound_t category, const translation &description, bool ambient = false, const std::string &id = "", const std::string &variant = "default" ); /** Functions identical to sound(..., true). */ -// TODO: Get rid of untyped overload -void ambient_sound( const tripoint &p, int vol, sound_t category, const std::string &description ); void ambient_sound( const tripoint_bub_ms &p, int vol, sound_t category, const std::string &description ); /** Creates a list of coordinates at which to draw footsteps. */ -void add_footstep( const tripoint &p, int volume, int distance, monster *source, +void add_footstep( const tripoint_bub_ms &p, int volume, int distance, monster *source, const std::string &footstep ); /* Make sure the sounds are all reset when we start a new game. */ @@ -87,11 +77,11 @@ void process_sounds(); void process_sound_markers( Character *you ); // Return list of points that have sound events the player can hear. -std::vector get_footstep_markers(); +std::vector get_footstep_markers(); // Return list of all sounds and the list of sound cluster centroids. -std::pair, std::vector> get_monster_sounds(); +std::pair, std::vector> get_monster_sounds(); // retrieve the sound event(s?) at a location. -std::string sound_at( const tripoint &location ); +std::string sound_at( const tripoint_bub_ms &location ); /** Tells us if sound has been enabled in options */ extern bool sound_enabled; } // namespace sounds @@ -171,15 +161,13 @@ void play_activity_sound( const std::string &id, const std::string &variant, const std::string &season, int volume ); void end_activity_sounds(); void generate_gun_sound( const Character &source_arg, const item &firing ); -void generate_melee_sound( const tripoint &source, const tripoint &target, bool hit, +void generate_melee_sound( const tripoint_bub_ms &source, const tripoint_bub_ms &target, bool hit, bool targ_mon = false, const std::string &material = "flesh" ); void do_hearing_loss( int turns = -1 ); void remove_hearing_loss(); void do_projectile_hit( const Creature &target ); -// TODO: Get rid of untyped overload -int get_heard_volume( const tripoint &source ); int get_heard_volume( const tripoint_bub_ms &source ); -units::angle get_heard_angle( const tripoint &source ); +units::angle get_heard_angle( const tripoint_bub_ms &source ); void do_footstep(); void do_danger_music(); void do_ambient(); diff --git a/src/suffer.cpp b/src/suffer.cpp index a2070295b40f1..ee67af8639230 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -600,7 +600,7 @@ void suffer::from_asthma( Character &you, const int current_stim ) map &here = get_map(); if( you.in_sleep_state() && !you.has_effect( effect_narcosis ) ) { inventory map_inv; - map_inv.form_from_map( you.pos(), 2, &you ); + map_inv.form_from_map( you.pos_bub(), 2, &you ); // check if an inhaler is somewhere near bool nearby_use = auto_use || oxygenator || map_inv.has_charges( itype_inhaler, 1 ) || map_inv.has_charges( itype_oxygen_tank, 1 ) || @@ -702,7 +702,7 @@ void suffer::in_sunlight( Character &you ) const float weather_factor = std::min( incident_sun_irradiance( get_weather().weather_id, calendar::turn ) / irradiance::moderate, 1.f ); const int player_local_temp = units::to_fahrenheit( get_weather().get_temperature( - position.raw() ) ); + position ) ); const int flux = ( player_local_temp - 65 ) / 2; if( !has_hat ) { sunlight_nutrition += ( 100 + flux ) * weather_factor; diff --git a/src/trap.cpp b/src/trap.cpp index 27c37c5366787..16a05939d16de 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -259,7 +259,7 @@ bool trap::detected_by_echolocation() const return has_flag( json_flag_ECHOLOCATION_DETECTABLE ); } -bool trap::detect_trap( const tripoint &pos, const Character &p ) const +bool trap::detect_trap( const tripoint_bub_ms &pos, const Character &p ) const { // * Buried landmines, the silent killer, have a visibility of 10. // Assuming no knowledge of traps or proficiencies, and average per/int (8 each), @@ -280,7 +280,7 @@ bool trap::detect_trap( const tripoint &pos, const Character &p ) const // The further away the trap is, the harder it is to spot. // Subtract 1 so that we don't get an unfair penalty when not quite on top of the trap. - const int distance_penalty = rl_dist( p.pos(), pos ) - 1; + const int distance_penalty = rl_dist( p.pos_bub(), pos ) - 1; int proficiency_effect = -1; // Without at least a basic traps proficiency, your skill level is effectively three levels lower. @@ -314,18 +314,6 @@ bool trap::detect_trap( const tripoint &pos, const Character &p ) const } // Whether or not, in the current state, the player can see the trap. -bool trap::can_see( const tripoint &pos, const Character &p ) const -{ - if( is_null() ) { - // There is no trap at all, so logically one can not see it. - return false; - } - if( is_always_invisible() ) { - return false; - } - return visibility < 0 || p.knows_trap( tripoint_bub_ms( pos ) ); -} - bool trap::can_see( const tripoint_bub_ms &pos, const Character &p ) const { if( is_null() ) { @@ -338,7 +326,7 @@ bool trap::can_see( const tripoint_bub_ms &pos, const Character &p ) const return visibility < 0 || p.knows_trap( pos ); } -void trap::trigger( const tripoint &pos ) const +void trap::trigger( const tripoint_bub_ms &pos ) const { if( is_null() ) { return; @@ -346,17 +334,17 @@ void trap::trigger( const tripoint &pos ) const act( pos, nullptr, nullptr ); } -void trap::trigger( const tripoint &pos, Creature &creature ) const +void trap::trigger( const tripoint_bub_ms &pos, Creature &creature ) const { return trigger( pos, &creature, nullptr ); } -void trap::trigger( const tripoint &pos, item &item ) const +void trap::trigger( const tripoint_bub_ms &pos, item &item ) const { return trigger( pos, nullptr, &item ); } -void trap::trigger( const tripoint &pos, Creature *creature, item *item ) const +void trap::trigger( const tripoint_bub_ms &pos, Creature *creature, item *item ) const { if( is_null() ) { return; @@ -412,7 +400,7 @@ bool trap::triggered_by_sound( int vol, int dist ) const return !is_null() && ( rng( 0, 100 ) <= sound_chance ); } -void trap::on_disarmed( map &m, const tripoint &p ) const +void trap::on_disarmed( map &m, const tripoint_bub_ms &p ) const { for( const auto &i : components ) { const itype_id &item_type = std::get<0>( i ); diff --git a/src/trap.h b/src/trap.h index 1d8528abee990..4fcdc5e057385 100644 --- a/src/trap.h +++ b/src/trap.h @@ -11,6 +11,7 @@ #include #include "color.h" +#include "coords_fwd.h" #include "effect_on_condition.h" #include "flat_set.h" #include "magic.h" @@ -31,41 +32,41 @@ namespace trapfunc // creature is the creature that triggered the trap, // item is the item that triggered the trap, // creature and item can be nullptr. -bool none( const tripoint &, Creature *, item * ); -bool bubble( const tripoint &p, Creature *c, item *i ); -bool glass( const tripoint &p, Creature *c, item *i ); -bool cot( const tripoint &p, Creature *c, item *i ); -bool beartrap( const tripoint &p, Creature *c, item *i ); -bool snare_light( const tripoint &p, Creature *c, item *i ); -bool snare_heavy( const tripoint &p, Creature *c, item *i ); -bool snare_species( const tripoint &p, Creature *critter, item *trap_item ); -bool board( const tripoint &p, Creature *c, item *i ); -bool caltrops( const tripoint &p, Creature *c, item *i ); -bool caltrops_glass( const tripoint &p, Creature *c, item *i ); -bool eocs( const tripoint &p, Creature *critter, item * ); -bool tripwire( const tripoint &p, Creature *c, item *i ); -bool crossbow( const tripoint &p, Creature *c, item *i ); -bool shotgun( const tripoint &p, Creature *c, item *i ); -bool blade( const tripoint &p, Creature *c, item *i ); -bool landmine( const tripoint &p, Creature *c, item *i ); -bool goo( const tripoint &p, Creature *c, item *i ); -bool dissector( const tripoint &p, Creature *c, item *i ); -bool sinkhole( const tripoint &p, Creature *c, item *i ); -bool pit( const tripoint &p, Creature *c, item *i ); -bool pit_spikes( const tripoint &p, Creature *c, item *i ); -bool pit_glass( const tripoint &p, Creature *c, item *i ); -bool lava( const tripoint &p, Creature *c, item *i ); -bool boobytrap( const tripoint &p, Creature *c, item *i ); -bool temple_flood( const tripoint &p, Creature *c, item *i ); -bool temple_toggle( const tripoint &p, Creature *c, item *i ); -bool glow( const tripoint &p, Creature *c, item *i ); -bool hum( const tripoint &p, Creature *c, item *i ); -bool shadow( const tripoint &p, Creature *c, item *i ); -bool map_regen( const tripoint &p, Creature *c, item *i ); -bool drain( const tripoint &p, Creature *c, item *i ); -bool snake( const tripoint &p, Creature *c, item *i ); -bool cast_spell( const tripoint &p, Creature *critter, item * ); -bool dummy_trap( const tripoint &p, Creature *critter, item * ); +bool none( const tripoint_bub_ms &, Creature *, item * ); +bool bubble( const tripoint_bub_ms &p, Creature *c, item *i ); +bool glass( const tripoint_bub_ms &p, Creature *c, item *i ); +bool cot( const tripoint_bub_ms &p, Creature *c, item *i ); +bool beartrap( const tripoint_bub_ms &p, Creature *c, item *i ); +bool snare_light( const tripoint_bub_ms &p, Creature *c, item *i ); +bool snare_heavy( const tripoint_bub_ms &p, Creature *c, item *i ); +bool snare_species( const tripoint_bub_ms &p, Creature *critter, item *trap_item ); +bool board( const tripoint_bub_ms &p, Creature *c, item *i ); +bool caltrops( const tripoint_bub_ms &p, Creature *c, item *i ); +bool caltrops_glass( const tripoint_bub_ms &p, Creature *c, item *i ); +bool eocs( const tripoint_bub_ms &p, Creature *critter, item * ); +bool tripwire( const tripoint_bub_ms &p, Creature *c, item *i ); +bool crossbow( const tripoint_bub_ms &p, Creature *c, item *i ); +bool shotgun( const tripoint_bub_ms &p, Creature *c, item *i ); +bool blade( const tripoint_bub_ms &p, Creature *c, item *i ); +bool landmine( const tripoint_bub_ms &p, Creature *c, item *i ); +bool goo( const tripoint_bub_ms &p, Creature *c, item *i ); +bool dissector( const tripoint_bub_ms &p, Creature *c, item *i ); +bool sinkhole( const tripoint_bub_ms &p, Creature *c, item *i ); +bool pit( const tripoint_bub_ms &p, Creature *c, item *i ); +bool pit_spikes( const tripoint_bub_ms &p, Creature *c, item *i ); +bool pit_glass( const tripoint_bub_ms &p, Creature *c, item *i ); +bool lava( const tripoint_bub_ms &p, Creature *c, item *i ); +bool boobytrap( const tripoint_bub_ms &p, Creature *c, item *i ); +bool temple_flood( const tripoint_bub_ms &p, Creature *c, item *i ); +bool temple_toggle( const tripoint_bub_ms &p, Creature *c, item *i ); +bool glow( const tripoint_bub_ms &p, Creature *c, item *i ); +bool hum( const tripoint_bub_ms &p, Creature *c, item *i ); +bool shadow( const tripoint_bub_ms &p, Creature *c, item *i ); +bool map_regen( const tripoint_bub_ms &p, Creature *c, item *i ); +bool drain( const tripoint_bub_ms &p, Creature *c, item *i ); +bool snake( const tripoint_bub_ms &p, Creature *c, item *i ); +bool cast_spell( const tripoint_bub_ms &p, Creature *critter, item * ); +bool dummy_trap( const tripoint_bub_ms &p, Creature *critter, item * ); } // namespace trapfunc struct vehicle_handle_trap_data { @@ -84,7 +85,7 @@ struct vehicle_handle_trap_data { trap_str_id set_trap = trap_str_id::NULL_ID(); }; -using trap_function = std::function; +using trap_function = std::function; /** * Some traps aren't actually traps in the usual sense of the word. We use traps to implement @@ -204,8 +205,6 @@ struct trap { * called on the null trap. */ // Implemented for historical reasons in iexamine.cpp - // TODO: Get rid of untyped overload. - void examine( const tripoint &examp ) const; void examine( const tripoint_bub_ms &examp ) const; update_mapgen_id map_regen_target() const; @@ -250,13 +249,11 @@ struct trap { bool detected_by_echolocation() const; /** Player has not yet seen the trap and returns the variable chance, at this moment, of whether the trap is seen or not. */ - bool detect_trap( const tripoint &pos, const Character &p ) const; + bool detect_trap( const tripoint_bub_ms &pos, const Character &p ) const; /** * Can player/npc p see this kind of trap, either by their memory (they known there is * the trap) or by the visibility of the trap (the trap is not hidden at all)? */ - // TODO: Get rid of untyped overload. - bool can_see( const tripoint &pos, const Character &p ) const; bool can_see( const tripoint_bub_ms &pos, const Character &p ) const; bool has_trigger_msg() const { @@ -285,7 +282,7 @@ struct trap { * @param item The item that triggered the trap */ // Don't call from outside this class. Add a wrapper like the ones below instead. - void trigger( const tripoint &pos, Creature *creature, item *item ) const; + void trigger( const tripoint_bub_ms &pos, Creature *creature, item *item ) const; public: /*@{*/ /** @@ -296,11 +293,11 @@ struct trap { * caller has already checked whether the trap should be activated * (e.g. the creature has had a chance to avoid the trap, but it failed). */ - void trigger( const tripoint &pos, Creature &creature ) const; - void trigger( const tripoint &pos, item &item ) const; + void trigger( const tripoint_bub_ms &pos, Creature &creature ) const; + void trigger( const tripoint_bub_ms &pos, item &item ) const; /*@}*/ - void trigger( const tripoint &pos ) const; + void trigger( const tripoint_bub_ms &pos ) const; /** * If the given item is throw onto the trap, does it trigger the trap? @@ -312,7 +309,7 @@ struct trap { * It should spawn trap items (if any) and remove the trap from the map via * @ref map::remove_trap. */ - void on_disarmed( map &m, const tripoint &p ) const; + void on_disarmed( map &m, const tripoint_bub_ms &p ) const; /** * This is used when defining area this trap occupies. A value of 0 means trap occupies exactly 1 tile. */ diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index cb9754726165e..6e851e08499e7 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -98,7 +98,7 @@ static const trap_str_id tr_shotgun_2( "tr_shotgun_2" ); static const trap_str_id tr_temple_flood( "tr_temple_flood" ); // A pit becomes less effective as it fills with corpses. -static float pit_effectiveness( const tripoint &p ) +static float pit_effectiveness( const tripoint_bub_ms &p ) { units::volume corpse_volume = 0_ml; for( item &pit_content : get_map().i_at( p ) ) { @@ -113,12 +113,12 @@ static float pit_effectiveness( const tripoint &p ) return std::max( 0.0f, 1.0f - corpse_volume / filled_volume ); } -bool trapfunc::none( const tripoint &, Creature *, item * ) +bool trapfunc::none( const tripoint_bub_ms &, Creature *, item * ) { return false; } -bool trapfunc::bubble( const tripoint &p, Creature *c, item * ) +bool trapfunc::bubble( const tripoint_bub_ms &p, Creature *c, item * ) { // tiny animals don't trigger bubble wrap if( c != nullptr && c->get_size() == creature_size::tiny ) { @@ -136,7 +136,7 @@ bool trapfunc::bubble( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::glass( const tripoint &p, Creature *c, item * ) +bool trapfunc::glass( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -160,7 +160,7 @@ bool trapfunc::glass( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::cot( const tripoint &, Creature *c, item * ) +bool trapfunc::cot( const tripoint_bub_ms &, Creature *c, item * ) { monster *z = dynamic_cast( c ); if( z != nullptr ) { @@ -172,7 +172,7 @@ bool trapfunc::cot( const tripoint &, Creature *c, item * ) return false; } -bool trapfunc::beartrap( const tripoint &p, Creature *c, item * ) +bool trapfunc::beartrap( const tripoint_bub_ms &p, Creature *c, item * ) { // tiny animals don't trigger bear traps if( c != nullptr && c->get_size() == creature_size::tiny ) { @@ -216,7 +216,7 @@ bool trapfunc::beartrap( const tripoint &p, Creature *c, item * ) return true; } -static void mount_step_on_trap_make_slow_give_msg( monster *z, const tripoint &p ) +static void mount_step_on_trap_make_slow_give_msg( monster *z, const tripoint_bub_ms &p ) { if( !z ) { // should never happen debugmsg( "non-monster creature passed to mount_step_on_trap_make_slow_give_msg" ); @@ -225,7 +225,7 @@ static void mount_step_on_trap_make_slow_give_msg( monster *z, const tripoint &p map &here = get_map(); Character *rider = nullptr; for( npc &guy : g->all_npcs() ) { - if( guy.pos() == p && guy.pos_bub() == z->pos_bub() ) { + if( guy.pos_bub() == p && guy.pos_bub() == z->pos_bub() ) { rider = &guy; break; } @@ -254,7 +254,7 @@ static void try_apply_tetanus( Character *you, int total_cut_dmg ) } } -bool trapfunc::board( const tripoint &p, Creature *c, item * ) +bool trapfunc::board( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -294,7 +294,7 @@ bool trapfunc::board( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::caltrops( const tripoint &p, Creature *c, item * ) +bool trapfunc::caltrops( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -336,7 +336,7 @@ bool trapfunc::caltrops( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::caltrops_glass( const tripoint &p, Creature *c, item * ) +bool trapfunc::caltrops_glass( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -365,7 +365,7 @@ bool trapfunc::caltrops_glass( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::eocs( const tripoint &p, Creature *critter, item * ) +bool trapfunc::eocs( const tripoint_bub_ms &p, Creature *critter, item * ) { if( !critter ) { //TODO: Pass the item as a talker somehow taking into account we don't have the item's tripoint in the case of ranged traps so something like get_talker_for( item_location( map_cursor( tripoint_bub_ms( p ) ), it ) ) isn't enough (and didn't work for non ranged traps on testing anyway) @@ -388,7 +388,7 @@ bool trapfunc::eocs( const tripoint &p, Creature *critter, item * ) } -bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) +bool trapfunc::tripwire( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -407,8 +407,8 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) if( z != nullptr ) { if( z->has_effect( effect_ridden ) ) { add_msg( m_bad, _( "Your %s trips over a tripwire!" ), z->get_name() ); - std::vector valid; - for( const tripoint &jk : here.points_in_radius( p, 1 ) ) { + std::vector valid; + for( const tripoint_bub_ms &jk : here.points_in_radius( p, 1 ) ) { if( g->is_empty( jk ) ) { valid.push_back( jk ); } @@ -427,8 +427,8 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) 4 ) ) ); } } else if( you != nullptr ) { - std::vector valid; - for( const tripoint &jk : here.points_in_radius( p, 1 ) ) { + std::vector valid; + for( const tripoint_bub_ms &jk : here.points_in_radius( p, 1 ) ) { if( g->is_empty( jk ) ) { valid.push_back( jk ); } @@ -451,7 +451,7 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::crossbow( const tripoint &p, Creature *c, item * ) +bool trapfunc::crossbow( const tripoint_bub_ms &p, Creature *c, item * ) { bool add_bolt = true; if( c != nullptr ) { @@ -549,7 +549,7 @@ bool trapfunc::crossbow( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::shotgun( const tripoint &p, Creature *c, item * ) +bool trapfunc::shotgun( const tripoint_bub_ms &p, Creature *c, item * ) { map &here = get_map(); sounds::sound( p, 60, sounds::sound_t::combat, _( "Kerblam!" ), false, "fire_gun", @@ -651,7 +651,7 @@ bool trapfunc::shotgun( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::blade( const tripoint &, Creature *c, item * ) +bool trapfunc::blade( const tripoint_bub_ms &, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -669,7 +669,7 @@ bool trapfunc::blade( const tripoint &, Creature *c, item * ) return true; } -bool trapfunc::snare_light( const tripoint &p, Creature *c, item * ) +bool trapfunc::snare_light( const tripoint_bub_ms &p, Creature *c, item * ) { sounds::sound( p, 4, sounds::sound_t::combat, _( "Snap!" ), false, "trap", "snare" ); map &here = get_map(); @@ -695,7 +695,7 @@ bool trapfunc::snare_light( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::snare_heavy( const tripoint &p, Creature *c, item * ) +bool trapfunc::snare_heavy( const tripoint_bub_ms &p, Creature *c, item * ) { sounds::sound( p, 4, sounds::sound_t::combat, _( "Snap!" ), false, "trap", "snare" ); get_map().remove_trap( p ); @@ -738,7 +738,7 @@ bool trapfunc::snare_heavy( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::snare_species( const tripoint &p, Creature *critter, item * ) +bool trapfunc::snare_species( const tripoint_bub_ms &p, Creature *critter, item * ) { map &here = get_map(); const trap &laid_trap = here.tr_at( p ); @@ -800,7 +800,7 @@ bool trapfunc::snare_species( const tripoint &p, Creature *critter, item * ) return true; } -bool trapfunc::landmine( const tripoint &p, Creature *c, item * ) +bool trapfunc::landmine( const tripoint_bub_ms &p, Creature *c, item * ) { // tiny animals are too light to trigger land mines if( c != nullptr && c->get_size() == creature_size::tiny ) { @@ -810,12 +810,12 @@ bool trapfunc::landmine( const tripoint &p, Creature *c, item * ) c->add_msg_player_or_npc( m_bad, _( "You trigger a land mine!" ), _( " triggers a land mine!" ) ); } - explosion_handler::explosion( c, tripoint_bub_ms( p ), 18, 0.5, false, 8 ); + explosion_handler::explosion( c, p, 18, 0.5, false, 8 ); get_map().remove_trap( p ); return true; } -bool trapfunc::boobytrap( const tripoint &p, Creature *c, item * ) +bool trapfunc::boobytrap( const tripoint_bub_ms &p, Creature *c, item * ) { if( c != nullptr ) { c->add_msg_player_or_npc( m_bad, _( "You trigger a booby trap!" ), @@ -830,7 +830,7 @@ bool trapfunc::boobytrap( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::goo( const tripoint &p, Creature *c, item * ) +bool trapfunc::goo( const tripoint_bub_ms &p, Creature *c, item * ) { get_map().remove_trap( p ); if( c == nullptr ) { @@ -878,7 +878,7 @@ bool trapfunc::goo( const tripoint &p, Creature *c, item * ) cata_fatal( "c must be either a monster or a Character" ); } -bool trapfunc::dissector( const tripoint &p, Creature *c, item * ) +bool trapfunc::dissector( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -936,7 +936,7 @@ bool trapfunc::dissector( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::pit( const tripoint &p, Creature *c, item * ) +bool trapfunc::pit( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -985,7 +985,7 @@ bool trapfunc::pit( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::pit_spikes( const tripoint &p, Creature *c, item * ) +bool trapfunc::pit_spikes( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1070,7 +1070,7 @@ bool trapfunc::pit_spikes( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::pit_glass( const tripoint &p, Creature *c, item * ) +bool trapfunc::pit_glass( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1160,7 +1160,7 @@ bool trapfunc::pit_glass( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::lava( const tripoint &p, Creature *c, item * ) +bool trapfunc::lava( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1209,10 +1209,10 @@ static bool query_for_item( const Character *pl, const itype_id &itemname, const return pl->has_amount( itemname, 1 ) && ( !pl->is_avatar() || query_yn( que ) ); } -static tripoint random_neighbor( tripoint center ) +static tripoint_bub_ms random_neighbor( tripoint_bub_ms center ) { - center.x += rng( -1, 1 ); - center.y += rng( -1, 1 ); + center.x() += rng( -1, 1 ); + center.y() += rng( -1, 1 ); return center; } @@ -1229,7 +1229,7 @@ static bool sinkhole_safety_roll( Character &you, const itype_id &itemname, cons if( roll < diff ) { you.add_msg_if_player( m_bad, _( "You fail to attach it…" ) ); you.use_amount( itemname, 1 ); - here.spawn_item( tripoint_bub_ms( random_neighbor( you.pos() ) ), itemname ); + here.spawn_item( random_neighbor( you.pos_bub() ), itemname ); return false; } @@ -1242,7 +1242,7 @@ static bool sinkhole_safety_roll( Character &you, const itype_id &itemname, cons if( safe.empty() ) { you.add_msg_if_player( m_bad, _( "There's nowhere to pull yourself to, and you sink!" ) ); you.use_amount( itemname, 1 ); - here.spawn_item( tripoint_bub_ms( random_neighbor( you.pos() ) ), itemname ); + here.spawn_item( random_neighbor( you.pos_bub() ), itemname ); return false; } else { you.add_msg_player_or_npc( m_good, _( "You pull yourself to safety!" ), @@ -1256,7 +1256,7 @@ static bool sinkhole_safety_roll( Character &you, const itype_id &itemname, cons } } -bool trapfunc::sinkhole( const tripoint &p, Creature *c, item *i ) +bool trapfunc::sinkhole( const tripoint_bub_ms &p, Creature *c, item *i ) { // tiny creatures don't trigger the sinkhole to collapse if( c == nullptr || c->get_size() == creature_size::tiny ) { @@ -1302,7 +1302,7 @@ bool trapfunc::sinkhole( const tripoint &p, Creature *c, item *i ) return true; } -bool trapfunc::temple_flood( const tripoint &p, Creature *c, item * ) +bool trapfunc::temple_flood( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1310,7 +1310,7 @@ bool trapfunc::temple_flood( const tripoint &p, Creature *c, item * ) // Monsters and npcs are completely ignored here, should they? if( c->is_avatar() ) { add_msg( m_warning, _( "You step on a loose tile, and water starts to flood the room!" ) ); - tripoint_bub_ms tmp = tripoint_bub_ms( p ); + tripoint_bub_ms tmp = p; int &i = tmp.x(); int &j = tmp.y(); map &here = get_map(); @@ -1327,7 +1327,7 @@ bool trapfunc::temple_flood( const tripoint &p, Creature *c, item * ) return false; } -bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) +bool trapfunc::temple_toggle( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1337,9 +1337,9 @@ bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) add_msg( _( "You hear the grinding of shifting rock." ) ); map &here = get_map(); const ter_id &type = here.ter( p ); - tripoint tmp = p; - int &i = tmp.x; - int &j = tmp.y; + tripoint_bub_ms tmp = p; + int &i = tmp.x(); + int &j = tmp.y(); for( i = 0; i < MAPSIZE_X; i++ ) { for( j = 0; j < MAPSIZE_Y; j++ ) { const ter_id &t = here.ter( tmp ); @@ -1366,8 +1366,8 @@ bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) } // In case we're completely encircled by walls, replace random wall around the player with floor tile - std::vector blocked_tiles; - for( const tripoint &pnt : here.points_in_radius( p, 1 ) ) { + std::vector blocked_tiles; + for( const tripoint_bub_ms &pnt : here.points_in_radius( p, 1 ) ) { if( here.impassable( pnt ) ) { blocked_tiles.push_back( pnt ); } @@ -1382,7 +1382,7 @@ bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) blocked_tiles.erase( blocked_tiles.begin() + i ); } } - const tripoint &pnt = random_entry( blocked_tiles ); + const tripoint_bub_ms &pnt = random_entry( blocked_tiles ); const ter_id &t = here.ter( pnt ); if( t == ter_t_rock_red ) { here.ter_set( pnt, ter_t_floor_red ); @@ -1398,7 +1398,7 @@ bool trapfunc::temple_toggle( const tripoint &p, Creature *c, item * ) return false; } -bool trapfunc::glow( const tripoint &p, Creature *c, item * ) +bool trapfunc::glow( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr ) { return false; @@ -1417,7 +1417,7 @@ bool trapfunc::glow( const tripoint &p, Creature *c, item * ) get_player_character().irradiate( rng( 10, 30 ) ); } else if( one_in( 4 ) ) { add_msg( m_bad, _( "A blinding flash strikes you!" ) ); - explosion_handler::flashbang( tripoint_bub_ms( p ) ); + explosion_handler::flashbang( p ); } else { add_msg( _( "Small flashes surround you." ) ); } @@ -1429,7 +1429,7 @@ bool trapfunc::glow( const tripoint &p, Creature *c, item * ) you->irradiate( rng( 10, 30 ) ); } else if( one_in( 4 ) ) { you->add_msg_if_player( m_bad, _( "A blinding flash strikes you!" ) ); - explosion_handler::flashbang( tripoint_bub_ms( p ) ); + explosion_handler::flashbang( p ); } else { c->add_msg_if_player( _( "Small flashes surround you." ) ); } @@ -1438,7 +1438,7 @@ bool trapfunc::glow( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::hum( const tripoint &p, Creature *, item * ) +bool trapfunc::hum( const tripoint_bub_ms &p, Creature *, item * ) { int volume = rng( 1, 200 ); std::string sfx; @@ -1459,7 +1459,7 @@ bool trapfunc::hum( const tripoint &p, Creature *, item * ) return true; } -bool trapfunc::shadow( const tripoint &p, Creature *c, item * ) +bool trapfunc::shadow( const tripoint_bub_ms &p, Creature *c, item * ) { if( c == nullptr || !c->is_avatar() ) { return false; @@ -1469,13 +1469,13 @@ bool trapfunc::shadow( const tripoint &p, Creature *c, item * ) for( int tries = 0; tries < 10; tries++ ) { tripoint_bub_ms monp{ p }; if( one_in( 2 ) ) { - monp.x() = p.x + rng( -5, +5 ); - monp.y() = p.y + ( one_in( 2 ) ? -5 : +5 ); + monp.x() = p.x() + rng( -5, +5 ); + monp.y() = p.y() + ( one_in( 2 ) ? -5 : +5 ); } else { - monp.x() = p.x + ( one_in( 2 ) ? -5 : +5 ); - monp.y() = p.y + rng( -5, +5 ); + monp.x() = p.x() + ( one_in( 2 ) ? -5 : +5 ); + monp.y() = p.y() + rng( -5, +5 ); } - if( !here.sees( monp, tripoint_bub_ms( p ), 10 ) ) { + if( !here.sees( monp, p, 10 ) ) { continue; } if( monster *const spawned = g->place_critter_at( mon_shadow, monp ) ) { @@ -1488,7 +1488,7 @@ bool trapfunc::shadow( const tripoint &p, Creature *c, item * ) return true; } -bool trapfunc::map_regen( const tripoint &p, Creature *c, item * ) +bool trapfunc::map_regen( const tripoint_bub_ms &p, Creature *c, item * ) { if( c ) { Character *you = dynamic_cast( c ); @@ -1507,15 +1507,15 @@ bool trapfunc::map_regen( const tripoint &p, Creature *c, item * ) return false; } set_queued_points(); - here.set_seen_cache_dirty( tripoint_bub_ms( p ) ); - here.set_transparency_cache_dirty( p.z ); + here.set_seen_cache_dirty( p ); + here.set_transparency_cache_dirty( p.z() ); return true; } } return false; } -bool trapfunc::drain( const tripoint &, Creature *c, item * ) +bool trapfunc::drain( const tripoint_bub_ms &, Creature *c, item * ) { if( c != nullptr ) { c->add_msg_if_player( m_bad, _( "You feel your life force sapping away." ) ); @@ -1532,7 +1532,7 @@ bool trapfunc::drain( const tripoint &, Creature *c, item * ) return false; } -bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * ) +bool trapfunc::cast_spell( const tripoint_bub_ms &p, Creature *critter, item * ) { if( critter == nullptr ) { map &here = get_map(); @@ -1544,9 +1544,9 @@ bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * ) } if( tr.has_flag( json_flag_PROXIMITY ) ) { // remove all traps in 3-3 area area - for( int x = p.x - 1; x <= p.x + 1; x++ ) { - for( int y = p.y - 1; y <= p.y + 1; y++ ) { - tripoint_bub_ms pt( x, y, p.z ); + for( int x = p.x() - 1; x <= p.x() + 1; x++ ) { + for( int y = p.y() - 1; y <= p.y() + 1; y++ ) { + tripoint_bub_ms pt( x, y, p.z() ); if( here.tr_at( pt ).loadid == tr.loadid ) { here.remove_trap( pt ); } @@ -1554,8 +1554,8 @@ bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * ) } } // we remove the trap before casting the spell because otherwise if we teleport we might be elsewhere at the end and p is no longer valid - trap_spell.cast_all_effects( dummy, tripoint_bub_ms( p ) ); - trap_spell.make_sound( tripoint_bub_ms( p ), get_player_character() ); + trap_spell.cast_all_effects( dummy, p ); + trap_spell.make_sound( p, get_player_character() ); return true; } else { map &here = get_map(); @@ -1567,9 +1567,9 @@ bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * ) } if( tr.has_flag( json_flag_PROXIMITY ) ) { // remove all traps in 3-3 area area - for( int x = p.x - 1; x <= p.x + 1; x++ ) { - for( int y = p.y - 1; y <= p.y + 1; y++ ) { - tripoint_bub_ms pt( x, y, p.z ); + for( int x = p.x() - 1; x <= p.x() + 1; x++ ) { + for( int y = p.y() - 1; y <= p.y() + 1; y++ ) { + tripoint_bub_ms pt( x, y, p.z() ); if( here.tr_at( pt ).loadid == tr.loadid ) { here.remove_trap( pt ); } @@ -1578,12 +1578,12 @@ bool trapfunc::cast_spell( const tripoint &p, Creature *critter, item * ) } // we remove the trap before casting the spell because otherwise if we teleport we might be elsewhere at the end and p is no longer valid trap_spell.cast_all_effects( dummy, critter->pos_bub() ); - trap_spell.make_sound( tripoint_bub_ms( p ), get_player_character() ); + trap_spell.make_sound( p, get_player_character() ); return true; } } -bool trapfunc::snake( const tripoint &p, Creature *, item * ) +bool trapfunc::snake( const tripoint_bub_ms &p, Creature *, item * ) { //~ the sound a snake makes sounds::sound( p, 10, sounds::sound_t::movement, _( "ssssssss" ), false, "misc", "snake_hiss" ); @@ -1595,13 +1595,13 @@ bool trapfunc::snake( const tripoint &p, Creature *, item * ) for( int tries = 0; tries < 10; tries++ ) { tripoint_bub_ms monp{ p }; if( one_in( 2 ) ) { - monp.x() = p.x + rng( -5, +5 ); - monp.y() = p.y + ( one_in( 2 ) ? -5 : +5 ); + monp.x() = p.x() + rng( -5, +5 ); + monp.y() = p.y() + ( one_in( 2 ) ? -5 : +5 ); } else { - monp.x() = p.x + ( one_in( 2 ) ? -5 : +5 ); - monp.y() = p.y + rng( -5, +5 ); + monp.x() = p.x() + ( one_in( 2 ) ? -5 : +5 ); + monp.y() = p.y() + rng( -5, +5 ); } - if( !here.sees( monp, tripoint_bub_ms( p ), 10 ) ) { + if( !here.sees( monp, p, 10 ) ) { continue; } if( monster *const spawned = g->place_critter_at( mon_shadow_snake, monp ) ) { @@ -1615,7 +1615,7 @@ bool trapfunc::snake( const tripoint &p, Creature *, item * ) return true; } -bool trapfunc::dummy_trap( const tripoint &, Creature *, item * ) +bool trapfunc::dummy_trap( const tripoint_bub_ms &, Creature *, item * ) { return true; } diff --git a/src/veh_utils.cpp b/src/veh_utils.cpp index 1b858460414ed..6b45b902bff8a 100644 --- a/src/veh_utils.cpp +++ b/src/veh_utils.cpp @@ -104,7 +104,7 @@ bool repair_part( vehicle &veh, vehicle_part &pt, Character &who ) // allow NPCs to use welding rigs they can't see ( on the other side of a vehicle ) // as they have the handicap of not being able to use the veh interaction menu // or able to drag a welding cart etc. - map_inv.form_from_map( who.pos(), PICKUP_RANGE, &who, false, !who.is_npc() ); + map_inv.form_from_map( who.pos_bub(), PICKUP_RANGE, &who, false, !who.is_npc() ); if( !reqs.can_make_with_inventory( inv, is_crafting_component ) ) { who.add_msg_if_player( m_info, _( "You don't meet the requirements to repair the %s." ), pt.name() ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 69e6b1179f6cf..4360f30c7773e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -6385,7 +6385,7 @@ bool vehicle::decrement_summon_timer() } vp.items.clear(); } - add_msg_if_player_sees( pos_bub().raw(), m_info, _( "Your %s winks out of existence." ), name ); + add_msg_if_player_sees( pos_bub(), m_info, _( "Your %s winks out of existence." ), name ); get_map().destroy_vehicle( this ); return true; } else { @@ -7264,7 +7264,7 @@ void vehicle::shed_loose_parts( const trinary shed_cables, const tripoint_bub_ms const int max_dist = vp_loose.get_base().max_link_length(); if( distance > max_dist || shed_cables == trinary::ALL ) { - add_msg_if_player_sees( bub_part_pos( vp_loose ).raw(), m_warning, + add_msg_if_player_sees( bub_part_pos( vp_loose ), m_warning, _( "The %s's %s was detached!" ), name, vp_loose.name( false ) ); remove_remote = true; } else { @@ -7615,23 +7615,23 @@ int vehicle::break_off( map &here, vehicle_part &vp, int dmg ) continue; // Ignore the frame being destroyed } else if( vpi_here.has_flag( "TOW_CABLE" ) ) { // Tow cables - remove it in one piece, remove remote part, and remove towing data - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is disconnected!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is disconnected!" ), name, vp_here.name() ); invalidate_towing( true ); } else if( vpi_here.has_flag( VPFLAG_POWER_TRANSFER ) ) { // Electrical cables - remove it in one piece and remove remote part - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is disconnected!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is disconnected!" ), name, vp_here.name() ); here.add_item_or_charges( pos, part_to_item( vp_here ) ); remove_remote_part( vp_here ); } else if( vp_here.is_broken() ) { // Tearing off a broken part - break it up - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %s's %s breaks into pieces!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %s's %s breaks into pieces!" ), name, vp_here.name() ); scatter_parts( vp_here ); } else { // Intact (but possibly damaged) part - remove it in one piece - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is torn off!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is torn off!" ), name, vp_here.name() ); if( !magic ) { here.add_item_or_charges( pos, part_to_item( vp_here ) ); @@ -7640,25 +7640,25 @@ int vehicle::break_off( map &here, vehicle_part &vp, int dmg ) remove_part( vp_here, *handler_ptr ); } // After clearing the frame, remove it. - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is destroyed!" ), name, vp.name() ); + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is destroyed!" ), name, vp.name() ); scatter_parts( vp ); remove_part( vp, *handler_ptr ); find_and_split_vehicles( here, { index_of_part( &vp, /* include_removed = */ true ) } ); } else { if( vpi.has_flag( "TOW_CABLE" ) ) { // Tow cables - remove it in one piece, remove remote part, and remove towing data - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is disconnected!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is disconnected!" ), name, vp.name() ); invalidate_towing( true ); } else if( vpi.has_flag( VPFLAG_POWER_TRANSFER ) ) { // Electrical cables - remove it in one piece and remove remote part - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is disconnected!" ), name, + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is disconnected!" ), name, vp.name() ); here.add_item_or_charges( pos, part_to_item( vp ) ); remove_remote_part( vp ); } else { //Just break it off - add_msg_if_player_sees( pos.raw(), m_bad, _( "The %1$s's %2$s is destroyed!" ), name, vp.name() ); + add_msg_if_player_sees( pos, m_bad, _( "The %1$s's %2$s is destroyed!" ), name, vp.name() ); scatter_parts( vp ); } const point_rel_ms position = vp.mount; @@ -7798,7 +7798,7 @@ int vehicle::damage_direct( map &here, vehicle_part &vp, int dmg, const damage_t invalidate_towing( true ); } else { item part_as_item = part_to_item( vp ); - add_msg_if_player_sees( vppos.raw(), m_bad, _( "The %1$s's %2$s is disconnected!" ), name, + add_msg_if_player_sees( vppos, m_bad, _( "The %1$s's %2$s is disconnected!" ), name, vp.name() ); if( vpi.has_flag( VPFLAG_POWER_TRANSFER ) ) { remove_remote_part( vp ); diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 7534ca8b2d567..9e0c00d5e8370 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -2288,7 +2288,7 @@ units::angle map::shake_vehicle( vehicle &veh, const int velocity_before, "the power of the impact!" ), veh.name ); unboard_vehicle( part_pos ); } else { - add_msg_if_player_sees( part_pos.raw(), m_bad, + add_msg_if_player_sees( part_pos, m_bad, _( "The %s is hurled from %s's by the power of the impact!" ), pet->disp_name(), veh.name ); } diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 2d768e8644a0b..00137aa0b9b4d 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -580,7 +580,7 @@ double vehicle::engine_cold_factor( const vehicle_part &vp ) const } const tripoint_bub_ms pos = bub_part_pos( vp ); - double eff_temp = units::to_fahrenheit( get_weather().get_temperature( pos.raw() ) ); + double eff_temp = units::to_fahrenheit( get_weather().get_temperature( pos ) ); if( !vp.has_fault_flag( "BAD_COLD_START" ) ) { eff_temp = std::min( eff_temp, 20.0 ); } @@ -1584,7 +1584,8 @@ void vehicle::use_harness( int part, const tripoint_bub_ms &pos ) return; } creature_tracker &creatures = get_creature_tracker(); - const std::function f = [&creatures]( const tripoint & pnt ) { + const std::function f = [&creatures]( + const tripoint_bub_ms & pnt ) { monster *mon_ptr = creatures.creature_at( pnt ); if( mon_ptr == nullptr ) { return false; @@ -1594,14 +1595,14 @@ void vehicle::use_harness( int part, const tripoint_bub_ms &pos ) f.has_flag( mon_flag_PET_HARNESSABLE ) ); }; - const std::optional pnt_ = choose_adjacent_highlight( - _( "Where is the creature to harness?" ), _( "There is no creature to harness nearby." ), f, - false ); + const std::optional pnt_ = choose_adjacent_highlight( + _( "Where is the creature to harness?" ), _( "There is no creature to harness nearby." ), f, + false ); if( !pnt_ ) { add_msg( m_info, _( "Never mind." ) ); return; } - const tripoint &target = *pnt_; + const tripoint_bub_ms &target = *pnt_; monster *mon_ptr = creatures.creature_at( target ); if( mon_ptr == nullptr ) { add_msg( m_info, _( "No creature there." ) ); diff --git a/src/weather.cpp b/src/weather.cpp index d67ca385c18c2..29fac6269dcb9 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -870,7 +870,7 @@ rl_vec2d convert_wind_to_coord( const int angle ) bool warm_enough_to_plant( const tripoint_bub_ms &pos ) { // semi-appropriate temperature for most plants - return get_weather().get_temperature( pos.raw() ) >= units::from_fahrenheit( 50 ); + return get_weather().get_temperature( pos ) >= units::from_fahrenheit( 50 ); } bool warm_enough_to_plant( const tripoint_abs_omt &pos ) @@ -949,7 +949,7 @@ void weather_manager::set_nextweather( time_point t ) update_weather(); } -units::temperature weather_manager::get_temperature( const tripoint &location ) +units::temperature weather_manager::get_temperature( const tripoint_bub_ms &location ) { if( forced_temperature ) { return *forced_temperature; @@ -961,13 +961,13 @@ units::temperature weather_manager::get_temperature( const tripoint &location ) } //underground temperature = average New England temperature = 43F/6C - units::temperature temp = location.z < 0 ? AVERAGE_ANNUAL_TEMPERATURE : temperature; + units::temperature temp = location.z() < 0 ? AVERAGE_ANNUAL_TEMPERATURE : temperature; if( !g->new_game ) { units::temperature_delta temp_mod; - temp_mod = get_heat_radiation( tripoint_bub_ms( location ) ); - temp_mod += get_convection_temperature( tripoint_bub_ms( location ) ); - temp_mod += get_map().get_temperature_mod( tripoint_bub_ms( location ) ); + temp_mod = get_heat_radiation( location ); + temp_mod += get_convection_temperature( location ); + temp_mod += get_map().get_temperature_mod( location ); temp += temp_mod; } diff --git a/src/weather.h b/src/weather.h index 9b8d28a968c23..398c4dca0b8da 100644 --- a/src/weather.h +++ b/src/weather.h @@ -222,9 +222,9 @@ class weather_manager // The time at which weather will shift next. time_point nextweather; /** temperature cache, cleared every turn, sparse map of map tripoints to temperatures */ - std::unordered_map< tripoint, units::temperature > temperature_cache; + std::unordered_map< tripoint_bub_ms, units::temperature > temperature_cache; // Returns outdoor or indoor temperature of given location - units::temperature get_temperature( const tripoint &location ); + units::temperature get_temperature( const tripoint_bub_ms &location ); // Returns outdoor or indoor temperature of given location units::temperature get_temperature( const tripoint_abs_omt &location ) const; void clear_temp_cache(); diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 866d353b06df2..54fb43e5407c3 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -48,15 +48,16 @@ struct weather_gen_common { season_type season = season_type::SPRING; }; -static weather_gen_common get_common_data( const tripoint &location, const time_point &real_t, +static weather_gen_common get_common_data( const tripoint_abs_ms &location, + const time_point &real_t, unsigned seed ) { season_effective_time t( real_t ); weather_gen_common result; // Integer x position / widening factor of the Perlin function. - result.x = location.x / 2000.0; + result.x = location.x() / 2000.0; // Integer y position / widening factor of the Perlin function. - result.y = location.y / 2000.0; + result.y = location.y() / 2000.0; // Integer turn / widening factor of the Perlin function. result.z = to_days( real_t - calendar::turn_zero ); // Limit the random seed during noise calculation, a large value flattens the noise generator to zero @@ -107,7 +108,7 @@ static units::temperature weather_temperature_from_common_data( const weather_ge } units::temperature weather_generator::get_weather_temperature( - const tripoint &location, const time_point &real_t, unsigned seed ) const + const tripoint_abs_ms &location, const time_point &real_t, unsigned seed ) const { return weather_temperature_from_common_data( *this, get_common_data( location, real_t, seed ), season_effective_time( real_t ) ); @@ -116,7 +117,7 @@ w_point weather_generator::get_weather( const tripoint_abs_ms &location, const t unsigned seed ) const { season_effective_time t( real_t ); - const weather_gen_common common = get_common_data( location.raw(), real_t, seed ); + const weather_gen_common common = get_common_data( location, real_t, seed ); const double x( common.x ); const double y( common.y ); diff --git a/src/weather_gen.h b/src/weather_gen.h index f1c2cce83e414..1ddba7f02447b 100644 --- a/src/weather_gen.h +++ b/src/weather_gen.h @@ -71,7 +71,8 @@ class weather_generator units::temperature get_water_temperature() const; void test_weather( unsigned seed ) const; void sort_weather(); - units::temperature get_weather_temperature( const tripoint &, const time_point &, unsigned ) const; + units::temperature get_weather_temperature( const tripoint_abs_ms &, const time_point &, + unsigned ) const; void load( const JsonObject &jo, bool was_loaded ); }; diff --git a/tests/behavior_test.cpp b/tests/behavior_test.cpp index f487ad3e2bae6..a1471f6eb6efa 100644 --- a/tests/behavior_test.cpp +++ b/tests/behavior_test.cpp @@ -168,7 +168,7 @@ TEST_CASE( "check_npc_behavior_tree", "[npc][behavior]" ) weather_manager &weather = get_weather(); weather.temperature = units::from_fahrenheit( 0 ); weather.clear_temp_cache(); - REQUIRE( units::to_fahrenheit( weather.get_temperature( test_npc.pos() ) ) == Approx( 0 ) ); + REQUIRE( units::to_fahrenheit( weather.get_temperature( test_npc.pos_bub() ) ) == Approx( 0 ) ); test_npc.update_bodytemp(); REQUIRE( oracle.needs_warmth_badly( "" ) == behavior::status_t::running ); CHECK( npc_needs.tick( &oracle ) == "idle" ); diff --git a/tests/fake_messages.cpp b/tests/fake_messages.cpp index b0e4e52e2fbaf..e6b4566108ae7 100644 --- a/tests/fake_messages.cpp +++ b/tests/fake_messages.cpp @@ -66,10 +66,6 @@ void add_msg( const game_message_params &, std::string m ) { Messages::add_msg( std::move( m ) ); } -void add_msg_if_player_sees( const tripoint &, std::string m ) -{ - Messages::add_msg( std::move( m ) ); -} void add_msg_if_player_sees( const tripoint_bub_ms &, std::string m ) { Messages::add_msg( std::move( m ) ); @@ -78,10 +74,6 @@ void add_msg_if_player_sees( const Creature &, std::string m ) { Messages::add_msg( std::move( m ) ); } -void add_msg_if_player_sees( const tripoint &, const game_message_params &, std::string m ) -{ - Messages::add_msg( std::move( m ) ); -} void add_msg_if_player_sees( const tripoint_bub_ms &, const game_message_params &, std::string m ) { Messages::add_msg( std::move( m ) ); diff --git a/tests/map_test.cpp b/tests/map_test.cpp index bac1666e2d24c..79ef5ed3cbf83 100644 --- a/tests/map_test.cpp +++ b/tests/map_test.cpp @@ -220,7 +220,7 @@ TEST_CASE( "milk_rotting", "[active_item][map]" ) restore_on_out_of_scope restore_temp( get_weather().forced_temperature ); get_weather().forced_temperature = units::from_celsius( 21 ); - REQUIRE( units::to_celsius( get_weather().get_temperature( test_loc.raw() ) ) == 21 ); + REQUIRE( units::to_celsius( get_weather().get_temperature( test_loc ) ) == 21 ); item almond_milk( "almond_milk" ); item *bp = nullptr;