From fbf71a0f66fc26fad25aa7a55f181a1a4ae42e12 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 7 Dec 2024 15:55:25 +0100 Subject: [PATCH] typified game.h and .cpp --- src/activity_handlers.cpp | 2 +- src/activity_item_handling.cpp | 2 +- src/avatar_action.cpp | 4 +- src/bionics.cpp | 10 +- src/cata_tiles.cpp | 4 +- src/character.cpp | 12 +- src/character.h | 2 +- src/character_body.cpp | 6 +- src/computer_session.cpp | 8 +- src/consumption.cpp | 2 +- src/creature.h | 2 +- src/debug_menu.cpp | 8 +- src/display.cpp | 4 +- src/game.cpp | 539 +++++++++++++++---------------- src/game.h | 96 +++--- src/handle_action.cpp | 33 +- src/iexamine.cpp | 6 +- src/item.cpp | 8 +- src/iuse.cpp | 12 +- src/iuse_actor.cpp | 4 +- src/magic_spell_effect.cpp | 6 +- src/map.cpp | 2 +- src/map.h | 8 +- src/mattack_actors.cpp | 2 +- src/medical_ui.cpp | 8 +- src/melee.cpp | 4 +- src/monattack.cpp | 45 +-- src/monmove.cpp | 26 +- src/monster.cpp | 14 +- src/monster.h | 4 +- src/mutation.cpp | 2 +- src/npc.cpp | 8 +- src/npc.h | 2 +- src/npcmove.cpp | 8 +- src/npctalk.cpp | 16 +- src/npctalk_funcs.cpp | 2 +- src/overmapbuffer.cpp | 2 +- src/pathfinding.cpp | 77 ++--- src/pickup.cpp | 2 +- src/player_display.cpp | 6 +- src/player_hardcoded_effects.cpp | 2 +- src/sounds.cpp | 2 +- src/suffer.cpp | 5 +- src/talker_avatar.cpp | 2 +- src/timed_event.cpp | 4 +- src/trapfunc.cpp | 24 +- src/weather.cpp | 8 +- tests/bionics_test.cpp | 2 +- tests/char_sight_test.cpp | 8 +- tests/char_suffer_test.cpp | 4 +- tests/effect_test.cpp | 2 +- tests/enchantments_test.cpp | 6 +- tests/eoc_test.cpp | 16 +- 53 files changed, 537 insertions(+), 556 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 3d2ecdd36a660..2924118de669c 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2920,7 +2920,7 @@ static void rod_fish( Character *you, const std::vector &fishables ) monster *chosen_fish = random_entry( fishables ); chosen_fish->fish_population -= 1; if( chosen_fish->fish_population <= 0 ) { - g->catch_a_monster( chosen_fish, you->pos(), you, 50_hours ); + g->catch_a_monster( chosen_fish, you->pos_bub(), you, 50_hours ); } else { here.add_item_or_charges( you->pos_bub(), item::make_corpse( chosen_fish->type->id, calendar::turn + rng( 0_turns, diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 710134401a5fe..3775a76811ca7 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -3092,7 +3092,7 @@ static bool generic_multi_activity_do( you.activity.targets.emplace_back( you, &best_rod ); // TODO: fix point types you.activity.coord_set = - g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc.raw() ); + g->get_fishable_locations( ACTIVITY_SEARCH_DISTANCE, src_loc ); return false; } else if( reason == do_activity_reason::NEEDS_MINING ) { // if have enough batteries to continue etc. diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 4e0b99894951f..5e67aefeabb48 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -458,7 +458,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint_rel_ms &d ) if( veh0 != nullptr && std::abs( veh0->velocity ) > 100 ) { if( veh1 == nullptr ) { if( query_yn( _( "Dive from moving vehicle?" ) ) ) { - g->moving_vehicle_dismount( dest_loc.raw() ); + g->moving_vehicle_dismount( dest_loc ); } return false; } else if( veh1 != veh0 ) { @@ -656,7 +656,7 @@ void avatar_action::swim( map &m, avatar &you, const tripoint_bub_ms &p ) you.setpos( p ); g->update_map( you ); - cata_event_dispatch::avatar_moves( old_abs_pos.raw(), you, m ); + cata_event_dispatch::avatar_moves( old_abs_pos, you, m ); if( m.veh_at( you.pos_bub() ).part_with_feature( VPFLAG_BOARDABLE, true ) ) { m.board_vehicle( you.pos_bub(), &you ); diff --git a/src/bionics.cpp b/src/bionics.cpp index 26c312a4c2ac9..30b574514c60d 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -873,7 +873,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics add_msg_activate(); const w_point weatherPoint = *get_weather().weather_precise; int humidity = get_local_humidity( weatherPoint.humidity, get_weather().weather_id, - g->is_sheltered( player_character.pos() ) ); + g->is_sheltered( player_character.pos_bub() ) ); // thirst units = 5 mL int water_available = std::lround( humidity * 3.0 / 100.0 ); if( water_available == 0 ) { @@ -1069,13 +1069,13 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics weather_manager &weather = get_weather(); const units::temperature player_local_temp = weather.get_temperature( player_character.pos() ); const int windpower = get_local_windpower( weather.windspeed + vehwindspeed, - cur_om_ter, get_location(), weather.winddirection, g->is_sheltered( pos() ) ); + 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 ) ); const w_point weatherPoint = *weather.weather_precise; add_msg_if_player( m_info, _( "Relative Humidity: %s." ), print_humidity( get_local_humidity( weatherPoint.humidity, get_weather().weather_id, - g->is_sheltered( player_character.pos() ) ) ) ); + g->is_sheltered( player_character.pos_bub() ) ) ) ); add_msg_if_player( m_info, _( "Pressure: %s." ), print_pressure( static_cast( weatherPoint.pressure ) ) ); add_msg_if_player( m_info, _( "Wind Speed: %.1f %s." ), @@ -1438,7 +1438,7 @@ void Character::burn_fuel( bionic &bio ) bool solar_powered = ( !bio.id->fuel_opts.empty() && bio.id->fuel_opts.front() == fuel_type_sun_light ) || !result.connected_solar.empty(); - if( energy_gain == 0_J && solar_powered && !g->is_sheltered( pos() ) ) { + if( energy_gain == 0_J && solar_powered && !g->is_sheltered( pos_bub() ) ) { // Some sort of solar source const weather_type_id &wtype = current_weather( get_location() ); @@ -1709,7 +1709,7 @@ void Character::process_bionic( bionic &bio ) if( calendar::once_every( 5_minutes ) ) { const w_point weatherPoint = *get_weather().weather_precise; int humidity = get_local_humidity( weatherPoint.humidity, get_weather().weather_id, - g->is_sheltered( pos() ) ); + g->is_sheltered( pos_bub() ) ); // in thirst units = 5 mL water int water_available = std::lround( humidity * 3.0 / 100.0 ); // At 50% relative humidity or more, the player will draw 10 mL diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index ae2dfa1d7739c..8d685d8f75d7a 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1945,10 +1945,10 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int false ); } if( you.controlling_vehicle ) { - std::optional indicator_offset = g->get_veh_dir_indicator_location( true ); + std::optional indicator_offset = g->get_veh_dir_indicator_location( true ); if( indicator_offset ) { draw_from_id_string( "cursor", TILE_CATEGORY::NONE, empty_string, - indicator_offset->xy() + + indicator_offset->raw().xy() + tripoint( you.posx(), you.posy(), center.z ), 0, 0, lit_level::LIT, false ); } diff --git a/src/character.cpp b/src/character.cpp index 64e59322931e7..fc07fc877fd60 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1911,7 +1911,7 @@ void Character::dismount() add_msg_debug( debugmode::DF_CHARACTER, "dismount called when not riding" ); return; } - if( const std::optional pnt = choose_adjacent( _( "Dismount where?" ) ) ) { + if( const std::optional pnt = choose_adjacent_bub( _( "Dismount where?" ) ) ) { if( !g->is_empty( *pnt ) ) { add_msg( m_warning, _( "You cannot dismount there!" ) ); return; @@ -8190,7 +8190,7 @@ dealt_damage_instance Character::deal_damage( Creature *source, bodypart_id bp, // And slimespawners too if( has_trait( trait_SLIMESPAWNER ) && ( dam >= 10 ) && one_in( 20 - dam ) ) { - if( monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ) ) { + if( monster *const slime = g->place_critter_around( mon_player_blob, pos_bub(), 1 ) ) { slime->friendly = -1; add_msg_if_player( m_warning, _( "A mass of slime is torn from you, and moves on its own!" ) ); } @@ -9983,11 +9983,11 @@ float Character::adjust_for_focus( float amount ) const return amount * ( effective_focus / 100.0f ); } -std::function Character::get_path_avoid() const +std::function Character::get_path_avoid() const { // TODO: Add known traps in a way that doesn't destroy performance - return [this]( const tripoint & p ) { + return [this]( const tripoint_bub_ms & p ) { Creature *critter = get_creature_tracker().creature_at( p, true ); return critter && critter->is_npc() && this->sees( *critter ); }; @@ -10954,7 +10954,7 @@ void Character::process_one_effect( effect &it, bool is_new ) void Character::process_effects() { //Special Removals - if( has_effect( effect_darkness ) && g->is_in_sunlight( pos() ) ) { + if( has_effect( effect_darkness ) && g->is_in_sunlight( pos_bub() ) ) { remove_effect( effect_darkness ); } if( has_trait( trait_M_IMMUNE ) && has_effect( effect_fungus ) ) { @@ -12225,7 +12225,7 @@ void Character::recalc_speed_bonus() // Ectothermic/COLDBLOOD4 is intended to buff folks in the Summer // Threshold-crossing has its charms ;-) if( g != nullptr ) { - if( has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( pos() ) ) { + if( has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( pos_bub() ) ) { //FIXME get trait name directly mod_speed_bonus( -( g->light_level( posz() ) >= 12 ? 5 : 10 ), _( "Sunlight Dependent" ) ); } diff --git a/src/character.h b/src/character.h index bca79ca5f3e90..0be6f0ae9beda 100644 --- a/src/character.h +++ b/src/character.h @@ -3281,7 +3281,7 @@ class Character : public Creature, public visitable int run_cost( int base_cost, bool diag = false ) const; const pathfinding_settings &get_pathfinding_settings() const override; - std::function get_path_avoid() const override; + std::function get_path_avoid() const override; /** * Get all hostile creatures currently visible to this player. */ diff --git a/src/character_body.cpp b/src/character_body.cpp index 7882ae0b3d349..654b832273920 100644 --- a/src/character_body.cpp +++ b/src/character_body.cpp @@ -503,10 +503,10 @@ void Character::update_bodytemp() // Sunlight const float scaled_sun_irradiance = incident_sun_irradiance( get_weather().weather_id, calendar::turn ) / max_sun_irradiance(); - const units::temperature_delta sunlight_warmth = !g->is_sheltered( pos() ) ? 3_C_delta * + const units::temperature_delta sunlight_warmth = !g->is_sheltered( pos_bub() ) ? 3_C_delta * scaled_sun_irradiance : 0_C_delta; - const int best_fire = get_best_fire( pos() ); + const int best_fire = get_best_fire( pos_bub() ); const units::temperature_delta lying_warmth = use_floor_warmth ? floor_warmth( pos() ) : 0_C_delta; const units::temperature water_temperature = @@ -519,7 +519,7 @@ void Character::update_bodytemp() // Difference between high and low is the "safe" heat - one we only apply if it's beneficial const units::temperature_delta mutation_heat_bonus = mutation_heat_high - mutation_heat_low; - const units::temperature_delta h_radiation = get_heat_radiation( pos() ); + const units::temperature_delta h_radiation = get_heat_radiation( pos_bub() ); // 111F (44C) is a temperature in which proteins break down: https://en.wikipedia.org/wiki/Burn // Blisters arbitrarily scale with the sqrt of the temperature difference in fahrenheit. diff --git a/src/computer_session.cpp b/src/computer_session.cpp index e6d743ab281fb..377a1966e940f 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -1623,8 +1623,8 @@ void computer_session::failure_alarm() void computer_session::failure_manhacks() { int num_robots = rng( 4, 8 ); - const tripoint_range range = - get_map().points_in_radius( get_player_character().pos(), 3 ); + const tripoint_range range = + get_map().points_in_radius( get_player_character().pos_bub(), 3 ); for( int i = 0; i < num_robots; i++ ) { if( g->place_critter_within( mon_manhack, range ) ) { add_msg( m_warning, _( "Manhacks drop from compartments in the ceiling." ) ); @@ -1634,8 +1634,8 @@ void computer_session::failure_manhacks() void computer_session::failure_secubots() { - const tripoint_range range = - get_map().points_in_radius( get_player_character().pos(), 3 ); + const tripoint_range range = + get_map().points_in_radius( get_player_character().pos_bub(), 3 ); if( g->place_critter_within( mon_secubot, range ) ) { add_msg( m_warning, _( "A secubot emerges from a compartment in the floor." ) ); } diff --git a/src/consumption.cpp b/src/consumption.cpp index 3bd4d698c16e7..ae8018fcda0da 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -1677,7 +1677,7 @@ bool Character::consume_effects( item &food ) mod_pain( 5 ); int numslime = 1; for( int i = 0; i < numslime; i++ ) { - if( monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ) ) { + if( monster *const slime = g->place_critter_around( mon_player_blob, pos_bub(), 1 ) ) { slime->friendly = -1; } } diff --git a/src/creature.h b/src/creature.h index 048100ccd6665..8635369f1d8be 100644 --- a/src/creature.h +++ b/src/creature.h @@ -950,7 +950,7 @@ class Creature : public viewer /** Returns settings for pathfinding. */ virtual const pathfinding_settings &get_pathfinding_settings() const = 0; /** Returns a set of points we do not want to path through. */ - virtual std::function get_path_avoid() const = 0; + virtual std::function get_path_avoid() const = 0; bool underwater; void draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const; diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 79fc663b51085..9dd497967a088 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -3597,10 +3597,10 @@ static void set_automove() return; } - // TODO: fix point types - auto rt = get_map().route( player_character.pos_bub(), tripoint_bub_ms( *dest ), - player_character.get_pathfinding_settings(), - player_character.get_path_avoid() ); + std::vector rt = get_map().route( player_character.pos_bub(), + tripoint_bub_ms( *dest ), + player_character.get_pathfinding_settings(), + player_character.get_path_avoid() ); if( !rt.empty() ) { player_character.set_destination( rt ); } else { diff --git a/src/display.cpp b/src/display.cpp index f3c3e1ecae2fc..c834e4c645881 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -249,7 +249,7 @@ std::string display::sundial_text_color( const Character &u, int width ) const int azm_pos = static_cast( std::round( azm / scale ) ) - 1; const int night_h = h >= h_dawn + 12 ? h - ( h_dawn + 12 ) : h + ( 12 - h_dawn ); std::string ret = "["; - if( g->is_sheltered( u.pos() ) ) { + if( g->is_sheltered( u.pos_bub() ) ) { ret += ( width > 0 ? std::string( width, '?' ) : "" ); } else { for( int i = 0; i < width; i++ ) { @@ -1507,7 +1507,7 @@ std::pair display::wind_text_color( const Character &u ) const oter_id &cur_om_ter = overmap_buffer.ter( u.global_omt_location() ); weather_manager &weather = get_weather(); double windpower = get_local_windpower( weather.windspeed, cur_om_ter, - u.get_location(), weather.winddirection, g->is_sheltered( u.pos() ) ); + u.get_location(), weather.winddirection, g->is_sheltered( u.pos_bub() ) ); // Wind descriptor followed by a directional arrow const std::string wind_text = get_wind_desc( windpower ) + " " + get_wind_arrow( diff --git a/src/game.cpp b/src/game.cpp index 6832e6e3a9b4b..6ec69c8a1c986 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1134,7 +1134,7 @@ bool game::start_game() update_map( u ); // Profession pets for( const mtype_id &elem : u.starting_pets ) { - if( monster *const mon = place_critter_around( elem, u.pos(), 5 ) ) { + if( monster *const mon = place_critter_around( elem, u.pos_bub(), 5 ) ) { mon->friendly = -1; mon->add_effect( effect_pet, 1_turns, true ); } else { @@ -1411,13 +1411,13 @@ void game::calc_driving_offset( vehicle *veh ) // The maximal offset will leave at least this many tiles // between the PC and the edge of the main window. static const int border_range = 2; - point max_offset( ( getmaxx( w_terrain ) + 1 ) / 2 - border_range - 1, - ( getmaxy( w_terrain ) + 1 ) / 2 - border_range - 1 ); + point_rel_ms max_offset( ( getmaxx( w_terrain ) + 1 ) / 2 - border_range - 1, + ( getmaxy( w_terrain ) + 1 ) / 2 - border_range - 1 ); // velocity at or below this results in no offset at all static const float min_offset_vel = 1 * vehicles::vmiph_per_tile; // velocity at or above this results in maximal offset - const float max_offset_vel = std::min( max_offset.y, max_offset.x ) * + const float max_offset_vel = std::min( max_offset.y(), max_offset.x() ) * vehicles::vmiph_per_tile; float velocity = veh->velocity; rl_vec2d offset = veh->move_vec(); @@ -1443,8 +1443,8 @@ void game::calc_driving_offset( vehicle *veh ) } offset.x *= rel_offset; offset.y *= rel_offset; - offset.x *= max_offset.x; - offset.y *= max_offset.y; + offset.x *= max_offset.x(); + offset.y *= max_offset.y(); // [ ----@---- ] sight=6 // [ --@------ ] offset=2 // [ -@------# ] offset=3 @@ -1458,35 +1458,35 @@ void game::calc_driving_offset( vehicle *veh ) // above leads to invisible area in front of the car. // It will display (getmax/2+offset) squares in one direction and // (getmax/2-offset) in the opposite direction (centered on the PC). - const point maxoff( ( sight * 2 + 1 - getmaxx( w_terrain ) ) / 2, - ( sight * 2 + 1 - getmaxy( w_terrain ) ) / 2 ); - if( maxoff.x <= 0 ) { + const point_rel_ms maxoff( ( sight * 2 + 1 - getmaxx( w_terrain ) ) / 2, + ( sight * 2 + 1 - getmaxy( w_terrain ) ) / 2 ); + if( maxoff.x() <= 0 ) { offset.x = 0; - } else if( offset.x > 0 && offset.x > maxoff.x ) { - offset.x = maxoff.x; - } else if( offset.x < 0 && -offset.x > maxoff.x ) { - offset.x = -maxoff.x; + } else if( offset.x > 0 && offset.x > maxoff.x() ) { + offset.x = maxoff.x(); + } else if( offset.x < 0 && -offset.x > maxoff.x() ) { + offset.x = -maxoff.x(); } - if( maxoff.y <= 0 ) { + if( maxoff.y() <= 0 ) { offset.y = 0; - } else if( offset.y > 0 && offset.y > maxoff.y ) { - offset.y = maxoff.y; - } else if( offset.y < 0 && -offset.y > maxoff.y ) { - offset.y = -maxoff.y; + } else if( offset.y > 0 && offset.y > maxoff.y() ) { + offset.y = maxoff.y(); + } else if( offset.y < 0 && -offset.y > maxoff.y() ) { + offset.y = -maxoff.y(); } // Turn the offset into a vector that increments the offset toward the desired position // instead of setting it there instantly, should smooth out jerkiness. const point_rel_ms offset_difference( -driving_view_offset + point( offset.x, offset.y ) ); - const point offset_sign( ( offset_difference.x() < 0 ) ? -1 : 1, - ( offset_difference.y() < 0 ) ? -1 : 1 ); + const point_rel_ms offset_sign( ( offset_difference.x() < 0 ) ? -1 : 1, + ( offset_difference.y() < 0 ) ? -1 : 1 ); // Shift the current offset in the direction of the calculated offset by one tile // per draw event, but snap to calculated offset if we're close enough to avoid jitter. offset.x = ( std::abs( offset_difference.x() ) > 1 ) ? - ( driving_view_offset.x() + offset_sign.x ) : offset.x; + ( driving_view_offset.x() + offset_sign.x() ) : offset.x; offset.y = ( std::abs( offset_difference.y() ) > 1 ) ? - ( driving_view_offset.y() + offset_sign.y ) : offset.y; + ( driving_view_offset.y() + offset_sign.y() ) : offset.y; set_driving_view_offset( { offset.x, offset.y } ); } @@ -1502,7 +1502,7 @@ void game::set_driving_view_offset( const point_rel_ms &p ) driving_view_offset.raw(); // TODO: Implement -= etc. for relative coordinates. } -void game::catch_a_monster( monster *fish, const tripoint &pos, Character *p, +void game::catch_a_monster( monster *fish, const tripoint_bub_ms &pos, Character *p, const time_duration &catch_duration ) // catching function { //spawn the corpse, rotten by a part of the duration @@ -1689,14 +1689,14 @@ static int maptile_field_intensity( maptile &mt, field_type_id fld ) return field_ptr == nullptr ? 0 : field_ptr->get_field_intensity(); } -units::temperature_delta get_heat_radiation( const tripoint &location ) +units::temperature_delta get_heat_radiation( const tripoint_bub_ms &location ) { units::temperature_delta temp_mod = units::from_kelvin_delta( 0 ); Character &player_character = get_player_character(); map &here = get_map(); // Convert it to an int id once, instead of 139 times per turn const field_type_id fd_fire_int = fd_fire.id(); - for( const tripoint_bub_ms &dest : here.points_in_radius( tripoint_bub_ms( location ), 6 ) ) { + for( const tripoint_bub_ms &dest : here.points_in_radius( location, 6 ) ) { int heat_intensity = 0; maptile mt = here.maptile_at( dest ); @@ -1711,28 +1711,28 @@ units::temperature_delta get_heat_radiation( const tripoint &location ) // No heat source here continue; } - if( player_character.pos_bub().raw() == location ) { - if( !here.clear_path( dest.raw(), location, -1, 1, 100 ) ) { + if( player_character.pos_bub() == location ) { + if( !here.clear_path( dest, location, -1, 1, 100 ) ) { continue; } - } else if( !here.sees( location, dest.raw(), -1 ) ) { + } else if( !here.sees( location, dest, -1 ) ) { continue; } // Ensure fire_dist >= 1 to avoid divide-by-zero errors. - const int fire_dist = std::max( 1, square_dist( dest.raw(), location ) ); + const int fire_dist = std::max( 1, square_dist( dest, location ) ); temp_mod += units::from_fahrenheit_delta( 6.f * heat_intensity * heat_intensity / fire_dist ); } return temp_mod; } -int get_best_fire( const tripoint &location ) +int get_best_fire( const tripoint_bub_ms &location ) { int best_fire = 0; Character &player_character = get_player_character(); map &here = get_map(); // Convert it to an int id once, instead of 139 times per turn const field_type_id fd_fire_int = fd_fire.id(); - for( const tripoint_bub_ms &dest : here.points_in_radius( tripoint_bub_ms( location ), 6 ) ) { + for( const tripoint_bub_ms &dest : here.points_in_radius( location, 6 ) ) { int heat_intensity = 0; maptile mt = here.maptile_at( dest ); @@ -1747,14 +1747,14 @@ int get_best_fire( const tripoint &location ) // No heat source here continue; } - if( player_character.pos_bub().raw() == location ) { - if( !here.clear_path( dest.raw(), location, -1, 1, 100 ) ) { + if( player_character.pos_bub() == location ) { + if( !here.clear_path( dest, location, -1, 1, 100 ) ) { continue; } - } else if( !here.sees( location, dest.raw(), -1 ) ) { + } else if( !here.sees( location, dest, -1 ) ) { continue; } - if( square_dist( dest.raw(), location ) <= 1 ) { + if( square_dist( dest, location ) <= 1 ) { // Extend limbs/lean over a single adjacent fire to warm up best_fire = std::max( best_fire, heat_intensity ); } @@ -1762,7 +1762,7 @@ int get_best_fire( const tripoint &location ) return best_fire; } -units::temperature_delta get_convection_temperature( const tripoint &location ) +units::temperature_delta get_convection_temperature( const tripoint_bub_ms &location ) { units::temperature_delta temp_mod = units::from_kelvin_delta( 0 ); map &here = get_map(); @@ -2523,24 +2523,24 @@ std::pair game::mouse_edge_scrolling( input_co } const input_event event = ctxt.get_raw_input(); if( event.type == input_event_t::mouse ) { - const point threshold( projected_window_width() / 100, projected_window_height() / 100 ); - if( event.mouse_pos.x <= threshold.x ) { + const point_rel_ms threshold( projected_window_width() / 100, projected_window_height() / 100 ); + if( event.mouse_pos.x <= threshold.x() ) { ret.first.x() -= speed; if( iso ) { ret.first.y() -= speed; } - } else if( event.mouse_pos.x >= projected_window_width() - threshold.x ) { + } else if( event.mouse_pos.x >= projected_window_width() - threshold.x() ) { ret.first.x() += speed; if( iso ) { ret.first.y() += speed; } } - if( event.mouse_pos.y <= threshold.y ) { + if( event.mouse_pos.y <= threshold.y() ) { ret.first.y() -= speed; if( iso ) { ret.first.x() += speed; } - } else if( event.mouse_pos.y >= projected_window_height() - threshold.y ) { + } else if( event.mouse_pos.y >= projected_window_height() - threshold.y() ) { ret.first.y() += speed; if( iso ) { ret.first.x() -= speed; @@ -3771,7 +3771,7 @@ struct npc_dist_to_player { void game::disp_NPCs() { const tripoint_abs_omt ppos = u.global_omt_location(); - const tripoint lpos = u.pos(); + const tripoint_bub_ms lpos = u.pos_bub(); const int scan_range = 120; std::vector> npcs = overmap_buffer.get_npcs_near_player( scan_range ); std::sort( npcs.begin(), npcs.end(), npc_dist_to_player() ); @@ -3830,16 +3830,16 @@ void game::disp_NPCs() } // A little helper to draw footstep glyphs. -static void draw_footsteps( const catacurses::window &window, const tripoint &offset ) +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() ) { 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.xy(), glyph ); + mvwaddch( window, footstep.xy() + offset.raw().xy(), glyph ); } wattroff( window, c_yellow ); } @@ -3956,7 +3956,7 @@ void game::add_draw_callback( const shared_ptr_fast &cb ) invalidate_main_ui_adaptor(); } -static void draw_trail( const tripoint &start, const tripoint &end, bool bDrawX ); +static void draw_trail( const tripoint_bub_ms &start, const tripoint_bub_ms &end, bool bDrawX ); static shared_ptr_fast create_zone_callback( const std::optional &zone_start, @@ -3981,9 +3981,9 @@ static shared_ptr_fast create_zone_callback( } if( zone_blink && zone_start && zone_end ) { avatar &player_character = get_avatar(); - const point offset2( player_character.view_offset.xy().raw() + - point( player_character.posx() - getmaxx( g->w_terrain ) / 2, - player_character.posy() - getmaxy( g->w_terrain ) / 2 ) ); + const point_rel_ms offset2( player_character.view_offset.xy() + + point( player_character.posx() - getmaxx( g->w_terrain ) / 2, + player_character.posy() - getmaxy( g->w_terrain ) / 2 ) ); tripoint_rel_ms offset; #if defined(TILES) @@ -3991,7 +3991,7 @@ static shared_ptr_fast create_zone_callback( offset = tripoint_rel_ms::zero; //TILES } else { #endif - offset = tripoint_rel_ms( offset2.x, offset2.y, 0 ); //CURSES + offset = { offset2, 0}; //CURSES #if defined(TILES) } #endif @@ -4008,8 +4008,8 @@ static shared_ptr_fast create_zone_callback( } static shared_ptr_fast create_trail_callback( - const std::optional &trail_start, - const std::optional &trail_end, + const std::optional &trail_start, + const std::optional &trail_end, const bool &trail_end_x ) { @@ -4047,7 +4047,7 @@ void game::void_async_anim_curses() async_anim_layer_curses.clear(); } -void game::init_draw_blink_curses( const tripoint &p, const std::string &ncstr, +void game::init_draw_blink_curses( const tripoint_bub_ms &p, const std::string &ncstr, const nc_color &nccol ) { std::pair anim( ncstr, nccol ); @@ -4059,12 +4059,12 @@ void game::draw_blink_curses() // game::draw_blink_curses can be called multiple times, storing each animation to be played in blink_layer_curses // Iterate through every animation in async_anim_layer for( const auto &anim : blink_layer_curses ) { - const tripoint p = anim.first - u.view_offset.raw() + tripoint( POSX - u.posx(), POSY - u.posy(), - -u.posz() ); + const tripoint_bub_ms p = anim.first - u.view_offset + tripoint( POSX - u.posx(), POSY - u.posy(), + -u.posz() ); const std::string ncstr = anim.second.first; const nc_color nccol = anim.second.second; - mvwprintz( w_terrain, p.xy(), nccol, ncstr ); + mvwprintz( w_terrain, p.raw().xy(), nccol, ncstr ); } } @@ -4212,13 +4212,13 @@ void game::draw_critter( const Creature &critter, const tripoint_bub_ms ¢er // Monster is below // TODO: Make this show something more informative than just green 'v' // TODO: Allow looking at this mon with look command - init_draw_blink_curses( tripoint( critter.pos().xy(), center.z() ), "v", c_green_cyan ); + init_draw_blink_curses( { critter.pos_bub().xy(), center.z() }, "v", c_green_cyan ); } if( critter.posz() == center.z() + 1 && ( debug_mode || u.sees( critter ) ) && m.valid_move( critter.pos_bub(), critter.pos_bub() + tripoint::below, false, true ) ) { // Monster is above - init_draw_blink_curses( tripoint( critter.pos().xy(), center.z() ), "^", c_green_cyan ); + init_draw_blink_curses( { critter.pos_bub().xy(), center.z() }, "^", c_green_cyan ); } return; } @@ -4256,7 +4256,8 @@ void game::draw_ter( const tripoint_bub_ms ¢er, const bool looking, const bo m.draw( w_terrain, tripoint_bub_ms( center ) ); if( draw_sounds ) { - draw_footsteps( w_terrain, tripoint( -center.x(), -center.y(), center.z() ) + point( POSX, POSY ) ); + draw_footsteps( w_terrain, tripoint_rel_ms( -center.x(), -center.y(), center.z() ) + point( POSX, + POSY ) ); } for( Creature &critter : all_creatures() ) { @@ -4280,7 +4281,7 @@ void game::draw_ter( const tripoint_bub_ms ¢er, const bool looking, const bo } } -std::optional game::get_veh_dir_indicator_location( bool next ) const +std::optional game::get_veh_dir_indicator_location( bool next ) const { if( !get_option( "VEHICLE_DIR_INDICATOR" ) ) { return std::nullopt; @@ -4292,14 +4293,16 @@ std::optional game::get_veh_dir_indicator_location( bool next ) const vehicle *const veh = &vp->vehicle(); rl_vec2d face = next ? veh->dir_vec() : veh->face_vec(); float r = 10.0f; - return tripoint( static_cast( r * face.x ), static_cast( r * face.y ), u.pos().z ); + return tripoint_rel_ms( static_cast( r * face.x ), static_cast( r * face.y ), u.pos().z ); } void game::draw_veh_dir_indicator( bool next ) { - if( const std::optional indicator_offset = get_veh_dir_indicator_location( next ) ) { + if( const std::optional indicator_offset = get_veh_dir_indicator_location( + next ) ) { nc_color col = next ? c_white : c_dark_gray; - mvwputch( w_terrain, indicator_offset->xy() - u.view_offset.xy().raw() + point( POSX, POSY ), col, + mvwputch( w_terrain, indicator_offset->raw().xy() - u.view_offset.xy().raw() + point( POSX, POSY ), + col, 'X' ); } } @@ -4437,7 +4440,21 @@ field_entry *game::is_in_dangerous_field() return nullptr; } -std::unordered_set game::get_fishable_locations( int distance, const tripoint &fish_pos ) +std::unordered_set game::get_fishable_locations( int distance, + const tripoint_bub_ms &fish_pos ) +{ + const std::unordered_set temp = game::get_fishable_locations_bub( distance, + fish_pos ); + std::unordered_set result; + + for( const tripoint_bub_ms pos : temp ) { + result.insert( pos.raw() ); + } + + return result; +} +std::unordered_set game::get_fishable_locations_bub( int distance, + const tripoint_bub_ms &fish_pos ) { // We're going to get the contiguous fishable terrain starting at // the provided fishing location (e.g. where a line was cast or a fish @@ -4446,20 +4463,20 @@ std::unordered_set game::get_fishable_locations( int distance, const t // getting our fish from the location that we're ACTUALLY fishing, // rather than just somewhere in the vicinity. - std::unordered_set visited; + std::unordered_set visited; - const tripoint fishing_boundary_min( fish_pos + point( -distance, -distance ) ); - const tripoint fishing_boundary_max( fish_pos + point( distance, distance ) ); + const tripoint_bub_ms fishing_boundary_min( fish_pos + point( -distance, -distance ) ); + const tripoint_bub_ms fishing_boundary_max( fish_pos + point( distance, distance ) ); - const inclusive_cuboid fishing_boundaries( + const inclusive_cuboid fishing_boundaries( fishing_boundary_min, fishing_boundary_max ); - const auto get_fishable_terrain = [&]( tripoint starting_point, - std::unordered_set &fishable_terrain ) { - std::queue to_check; + const auto get_fishable_terrain = [&]( tripoint_bub_ms starting_point, + std::unordered_set &fishable_terrain ) { + std::queue to_check; to_check.push( starting_point ); while( !to_check.empty() ) { - const tripoint current_point = to_check.front(); + const tripoint_bub_ms current_point = to_check.front(); to_check.pop(); // We've been here before, so bail. @@ -4488,7 +4505,7 @@ std::unordered_set game::get_fishable_locations( int distance, const t // Starting at the provided location, get our fishable terrain // and populate a set with those locations which we'll then use // to determine if any fishable monsters are in those locations. - std::unordered_set fishable_points; + std::unordered_set fishable_points; get_fishable_terrain( fish_pos, fishable_points ); return fishable_points; @@ -4496,12 +4513,24 @@ std::unordered_set game::get_fishable_locations( int distance, const t std::vector game::get_fishable_monsters( std::unordered_set &fishable_locations ) +{ + std::unordered_set temp; + + for( const tripoint pos : fishable_locations ) { + temp.insert( tripoint_bub_ms( pos ) ); + } + + return game::get_fishable_monsters( temp ); +} + +std::vector game::get_fishable_monsters( std::unordered_set + &fishable_locations ) { std::vector unique_fish; for( monster &critter : all_monsters() ) { // If it is fishable... if( critter.has_flag( mon_flag_FISHABLE ) ) { - const tripoint critter_pos = critter.pos(); + const tripoint_bub_ms critter_pos = critter.pos_bub(); // ...and it is in a fishable location. if( fishable_locations.find( critter_pos ) != fishable_locations.end() ) { unique_fish.push_back( &critter ); @@ -4537,7 +4566,7 @@ void game::mon_info_update( ) } std::fill( dangerous.begin(), dangerous.end(), false ); - const tripoint view = u.pos() + u.view_offset.raw(); + const tripoint_bub_ms view = u.pos_bub() + u.view_offset; new_seen_mon.clear(); static time_point previous_turn = calendar::turn_zero; @@ -4547,8 +4576,8 @@ void game::mon_info_update( ) for( Creature *c : u.get_visible_creatures( MAPSIZE_X ) ) { monster *m = dynamic_cast( c ); npc *p = dynamic_cast( c ); - const direction dir_to_mon = direction_from( view.xy(), point( c->posx(), c->posy() ) ); - const point_rel_ms m2( -view.xy() + point( POSX + c->posx(), POSY + c->posy() ) ); + const direction dir_to_mon = direction_from( view.raw().xy(), point( c->posx(), c->posy() ) ); + const point_rel_ms m2( -view.raw().xy() + point( POSX + c->posx(), POSY + c->posy() ) ); int index = 8; if( !is_valid_in_w_terrain( m2 ) ) { // for compatibility with old code, see diagram below, it explains the values for index, @@ -5089,7 +5118,7 @@ template Character *game::critter_by_id( const character_id & ); template npc *game::critter_by_id( const character_id & ); template Creature *game::critter_by_id( const character_id & ); -static bool can_place_monster( const monster &mon, const tripoint &p ) +static bool can_place_monster( const monster &mon, const tripoint_bub_ms &p ) { creature_tracker &creatures = get_creature_tracker(); if( const monster *const critter = creatures.creature_at( p ) ) { @@ -5103,10 +5132,10 @@ static bool can_place_monster( const monster &mon, const tripoint &p ) if( creatures.creature_at( p ) ) { return false; } - return mon.will_move_to( p ) && mon.know_danger_at( p ); + return mon.will_move_to( p.raw() ) && mon.know_danger_at( p.raw() ); } -static bool can_place_npc( const tripoint &p ) +static bool can_place_npc( const tripoint_bub_ms &p ) { creature_tracker &creatures = get_creature_tracker(); if( const monster *const critter = creatures.creature_at( p ) ) { @@ -5121,35 +5150,26 @@ static bool can_place_npc( const tripoint &p ) return !g->is_dangerous_tile( p ); } -static std::optional choose_where_to_place_monster( const monster &mon, - const tripoint_range &range ) +static std::optional choose_where_to_place_monster( const monster &mon, + const tripoint_range &range ) { - return random_point( range, [&]( const tripoint & p ) { + return random_point( range, [&]( const tripoint_bub_ms & p ) { return can_place_monster( mon, p ); } ); } -monster *game::place_critter_at( const mtype_id &id, const tripoint &p ) -{ - return place_critter_around( id, p, 0 ); -} - monster *game::place_critter_at( const mtype_id &id, const tripoint_bub_ms &p ) { - return place_critter_around( id, p.raw(), 0 ); -} - -monster *game::place_critter_at( const shared_ptr_fast &mon, const tripoint &p ) -{ - return place_critter_around( mon, p, 0 ); + return place_critter_around( id, p, 0 ); } monster *game::place_critter_at( const shared_ptr_fast &mon, const tripoint_bub_ms &p ) { - return place_critter_around( mon, p.raw(), 0 ); + return place_critter_around( mon, p, 0 ); } -monster *game::place_critter_around( const mtype_id &id, const tripoint ¢er, const int radius ) +monster *game::place_critter_around( const mtype_id &id, const tripoint_bub_ms ¢er, + const int radius ) { // TODO: change this into an assert, it must never happen. if( id.is_null() ) { @@ -5161,11 +5181,11 @@ monster *game::place_critter_around( const mtype_id &id, const tripoint ¢er, } monster *game::place_critter_around( const shared_ptr_fast &mon, - const tripoint ¢er, + const tripoint_bub_ms ¢er, const int radius, bool forced ) { - std::optional where; + std::optional where; if( forced || can_place_monster( *mon, center ) ) { where = center; } @@ -5179,11 +5199,12 @@ monster *game::place_critter_around( const shared_ptr_fast &mon, if( !where ) { return nullptr; } - mon->spawn( *where ); + mon->spawn( where->raw() ); return critter_tracker->add( mon ) ? mon.get() : nullptr; } -monster *game::place_critter_within( const mtype_id &id, const tripoint_range &range ) +monster *game::place_critter_within( const mtype_id &id, + const tripoint_range &range ) { // TODO: change this into an assert, it must never happen. if( id.is_null() ) { @@ -5195,13 +5216,13 @@ monster *game::place_critter_within( const mtype_id &id, const tripoint_range &mon, - const tripoint_range &range ) + const tripoint_range &range ) { - const std::optional where = choose_where_to_place_monster( *mon, range ); + const std::optional where = choose_where_to_place_monster( *mon, range ); if( !where ) { return nullptr; } - mon->spawn( *where ); + mon->spawn( where->raw() ); return critter_tracker->add( mon ) ? mon.get() : nullptr; } @@ -5227,10 +5248,11 @@ void game::clear_zombies() critter_tracker->clear(); } -bool game::find_nearby_spawn_point( const tripoint &target, const mtype_id &mt, int min_radius, - int max_radius, tripoint &point, bool outdoor_only, bool indoor_only, bool open_air_allowed ) +bool game::find_nearby_spawn_point( const tripoint_bub_ms &target, const mtype_id &mt, + int min_radius, + int max_radius, tripoint_bub_ms &point, bool outdoor_only, bool indoor_only, bool open_air_allowed ) { - tripoint target_point; + tripoint_bub_ms target_point; //find a legal outdoor place to spawn based on the specified radius, //we just try a bunch of random points and use the first one that works, it none do then no spawn for( int attempts = 0; attempts < 75; attempts++ ) { @@ -5248,10 +5270,10 @@ bool game::find_nearby_spawn_point( const tripoint &target, const mtype_id &mt, return false; } -bool game::find_nearby_spawn_point( const tripoint &target, int min_radius, - int max_radius, tripoint &point, bool outdoor_only, bool indoor_only, bool open_air_allowed ) +bool game::find_nearby_spawn_point( const tripoint_bub_ms &target, int min_radius, + int max_radius, tripoint_bub_ms &point, bool outdoor_only, bool indoor_only, bool open_air_allowed ) { - tripoint target_point; + tripoint_bub_ms target_point; //find a legal outdoor place to spawn based on the specified radius, //we just try a bunch of random points and use the first one that works, it none do then no spawn for( int attempts = 0; attempts < 75; attempts++ ) { @@ -5275,7 +5297,7 @@ bool game::find_nearby_spawn_point( const tripoint &target, int min_radius, * a monster already in the target square. * @return Whether or not a hallucination was successfully spawned. */ -bool game::spawn_hallucination( const tripoint &p ) +bool game::spawn_hallucination( const tripoint_bub_ms &p ) { //Don't spawn hallucinations on open air if( get_map().has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ) { @@ -5315,7 +5337,7 @@ bool game::spawn_hallucination( const tripoint &p ) * a monster already in the target square. * @return Whether or not a hallucination was successfully spawned. */ -bool game::spawn_hallucination( const tripoint &p, const mtype_id &mt, +bool game::spawn_hallucination( const tripoint_bub_ms &p, const mtype_id &mt, std::optional lifespan ) { //Don't spawn hallucinations on open air @@ -5325,7 +5347,7 @@ bool game::spawn_hallucination( const tripoint &p, const mtype_id &mt, const shared_ptr_fast phantasm = make_shared_fast( mt ); phantasm->hallucination = true; - phantasm->spawn( p ); + phantasm->spawn( p.raw() ); if( lifespan.has_value() ) { phantasm->set_summon_time( lifespan.value() ); } @@ -5337,7 +5359,7 @@ bool game::spawn_hallucination( const tripoint &p, const mtype_id &mt, } } -bool game::spawn_npc( const tripoint &p, const string_id &npc_class, +bool game::spawn_npc( const tripoint_bub_ms &p, const string_id &npc_class, std::string &unique_id, std::vector &traits, std::optional lifespan ) { @@ -5450,26 +5472,21 @@ bool game::swap_critters( Creature &a, Creature &b ) bool game::is_empty( const tripoint &p ) { - return ( m.passable( p ) || m.has_flag( ter_furn_flag::TFLAG_LIQUID, p ) ) && - get_creature_tracker().creature_at( p ) == nullptr; + return is_empty( tripoint_bub_ms( p ) ); } bool game::is_empty( const tripoint_bub_ms &p ) { - return is_empty( p.raw() ); + return ( m.passable( p ) || m.has_flag( ter_furn_flag::TFLAG_LIQUID, p ) ) && + get_creature_tracker().creature_at( p ) == nullptr; } -bool game::is_in_sunlight( const tripoint &p ) +bool game::is_in_sunlight( const tripoint_bub_ms &p ) { return !is_sheltered( p ) && incident_sun_irradiance( get_weather().weather_id, calendar::turn ) > irradiance::minimal; } -bool game::is_sheltered( const tripoint &p ) -{ - return game::is_sheltered( tripoint_bub_ms( p ) ); -} - bool game::is_sheltered( const tripoint_bub_ms &p ) { const optional_vpart_position vp = m.veh_at( p ); @@ -5480,12 +5497,12 @@ bool game::is_sheltered( const tripoint_bub_ms &p ) is_inside; } -bool game::revive_corpse( const tripoint &p, item &it ) +bool game::revive_corpse( const tripoint_bub_ms &p, item &it ) { return revive_corpse( p, it, 1 ); } -bool game::revive_corpse( const tripoint &p, item &it, int radius ) +bool game::revive_corpse( const tripoint_bub_ms &p, item &it, int radius ) { if( !it.is_corpse() ) { debugmsg( "Tried to revive a non-corpse." ); @@ -5524,10 +5541,10 @@ bool game::revive_corpse( const tripoint &p, item &it, int radius ) } } - return place_critter_around( newmon_ptr, p, radius ); + return place_critter_around( newmon_ptr, tripoint_bub_ms( p ), radius ); } -void game::save_cyborg( item *cyborg, const tripoint &couch_pos, Character &installer ) +void game::save_cyborg( item *cyborg, const tripoint_bub_ms &couch_pos, Character &installer ) { int damage = cyborg->damage(); int dmg_lvl = cyborg->damage_level(); @@ -5623,7 +5640,7 @@ void game::open_gate( const tripoint_bub_ms &p ) gates::open_gate( p, u ); } -void game::moving_vehicle_dismount( const tripoint &dest_loc ) +void game::moving_vehicle_dismount( const tripoint_bub_ms &dest_loc ) { const optional_vpart_position vp = m.veh_at( u.pos_bub() ); if( !vp ) { @@ -5631,11 +5648,11 @@ void game::moving_vehicle_dismount( const tripoint &dest_loc ) return; } vehicle *const veh = &vp->vehicle(); - if( u.pos() == dest_loc ) { + if( u.pos_bub() == dest_loc ) { debugmsg( "Need somewhere to dismount towards." ); return; } - tileray ray( dest_loc.xy() + point( -u.posx(), -u.posy() ) ); + tileray ray( dest_loc.raw().xy() + point( -u.posx(), -u.posy() ) ); // TODO:: make dir() const correct! const units::angle d = ray.dir(); add_msg( _( "You dive from the %s." ), veh->name ); @@ -5742,11 +5759,11 @@ void game::control_vehicle() add_msg( _( "No vehicle controls found." ) ); return; } else if( num_valid_controls > 1 ) { - const std::optional temp = choose_adjacent( _( "Control vehicle where?" ) ); + const std::optional temp = choose_adjacent_bub( _( "Control vehicle where?" ) ); if( !vehicle_position ) { return; } else { - vehicle_position.value() = tripoint_bub_ms( temp.value() ); + vehicle_position.value() = temp.value(); } const optional_vpart_position vp = m.veh_at( *vehicle_position ); if( vp ) { @@ -5826,7 +5843,7 @@ bool game::npc_menu( npc &who ) if( choice == talk ) { u.talk_to( get_talker_for( who ) ); } else if( choice == swap_pos ) { - if( !prompt_dangerous_tile( who.pos() ) ) { + if( !prompt_dangerous_tile( who.pos_bub() ) ) { return true; } if( u.get_grab_type() == object_type::NONE ) { @@ -5851,10 +5868,10 @@ bool game::npc_menu( npc &who ) } // TODO: Make NPCs protest when displaced onto dangerous crap - tripoint oldpos = who.pos(); + tripoint_bub_ms oldpos = who.pos_bub(); who.move_away_from( u.pos_bub(), true ); u.mod_moves( -20 ); - if( oldpos != who.pos() ) { + if( oldpos != who.pos_bub() ) { add_msg( _( "%s moves out of the way." ), who.get_name() ); } else { add_msg( m_warning, _( "%s has nowhere to go!" ), who.get_name() ); @@ -6109,7 +6126,7 @@ void game::examine( const tripoint_bub_ms &examp, bool with_pickup ) const furn_t &xfurn_t = m.furn( examp ).obj(); const ter_t &xter_t = m.ter( examp ).obj(); - const tripoint player_pos = u.pos(); + const tripoint_bub_ms player_pos = u.pos_bub(); if( m.has_furn( examp ) ) { if( !u.cant_do_mounted() ) { @@ -6129,7 +6146,7 @@ void game::examine( const tripoint_bub_ms &examp, bool with_pickup ) // Did the player get moved? Bail out if so; our examp probably // isn't valid anymore. - if( player_pos != u.pos() ) { + if( player_pos != u.pos_bub() ) { return; } @@ -6139,7 +6156,7 @@ void game::examine( const tripoint_bub_ms &examp, bool with_pickup ) } // In case of teleport trap or somesuch - if( player_pos != u.pos() ) { + if( player_pos != u.pos_bub() ) { return; } @@ -6220,9 +6237,10 @@ 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( _( "Pick up items where?" ), - _( "There is nothing to pick up nearby." ), - ACTION_PICKUP, false ); + const std::optional where_ = choose_adjacent_highlight_bub_ms( + _( "Pick up items where?" ), + _( "There is nothing to pick up nearby." ), + ACTION_PICKUP, false ); if( !where_ ) { return; } @@ -6236,11 +6254,6 @@ void game::pickup_all() u.pick_up( game_menus::inv::pickup() ); } -void game::pickup( const tripoint &p ) -{ - game::pickup( tripoint_bub_ms( p ) ); -} - void game::pickup( const tripoint_bub_ms &p ) { // Highlight target @@ -6257,15 +6270,15 @@ void game::pickup( const tripoint_bub_ms &p ) //represents carefully peeking around a corner, hence the large move cost. void game::peek() { - const std::optional p = choose_direction( _( "Peek where?" ), true ); + const std::optional p = choose_direction_rel_ms( _( "Peek where?" ), true ); if( !p ) { return; } tripoint_bub_ms new_pos = u.pos_bub() + *p; - if( p->z != 0 ) { + if( p->z() != 0 ) { // Character might peek to a different submap; ensures return location is accurate. const tripoint_abs_ms old_loc = u.get_location(); - vertical_move( p->z, false, true ); + vertical_move( p->z(), false, true ); if( old_loc != u.get_location() ) { new_pos = u.pos_bub(); @@ -6286,9 +6299,9 @@ void game::peek() void game::peek( const tripoint_bub_ms &p ) { u.mod_moves( -u.get_speed() * 2 ); - tripoint prev = u.pos(); + tripoint_bub_ms prev = u.pos_bub(); u.setpos( p ); - const bool is_same_pos = u.pos() == prev; + const bool is_same_pos = u.pos_bub() == prev; const bool is_standup_peek = is_same_pos && u.is_crouching(); tripoint_bub_ms center = p; m.build_map_cache( p.z() ); @@ -6768,12 +6781,12 @@ void game::print_graffiti_info( const tripoint_bub_ms &lp, const catacurses::win } } -bool game::check_zone( const zone_type_id &type, const tripoint &where ) const +bool game::check_zone( const zone_type_id &type, const tripoint_bub_ms &where ) const { return zone_manager::get_manager().has( type, m.getglobal( where ) ); } -bool game::check_near_zone( const zone_type_id &type, const tripoint &where ) const +bool game::check_near_zone( const zone_type_id &type, const tripoint_bub_ms &where ) const { return zone_manager::get_manager().has_near( type, m.getglobal( where ) ); } @@ -7510,7 +7523,6 @@ void game::pre_print_all_tile_info( const tripoint_bub_ms &lp, const catacurses: const visibility_variables &cache ) { // get global area info according to look_around caret position - // TODO: fix point types tripoint_abs_omt omp( coords::project_to( m.getglobal( lp ) ) ); const oter_id &cur_ter_m = overmap_buffer.ter( omp ); om_vision_level vision = overmap_buffer.seen( omp ); @@ -7548,11 +7560,11 @@ std::optional> game::safe_route_to( Character &who, }; route_t shortest_route; for( const tripoint_bub_ms &p : here.points_in_radius( target, threshold, 0 ) ) { - if( is_dangerous_tile( p.raw() ) ) { + if( is_dangerous_tile( p ) ) { continue; } const route_t route = here.route( who.pos_bub(), p, - who.get_pathfinding_settings(), [this]( const tripoint & p ) { + who.get_pathfinding_settings(), [this]( const tripoint_bub_ms & p ) { return is_dangerous_tile( p ); } ); if( route.empty() ) { @@ -7575,8 +7587,6 @@ std::optional game::look_around() return result.position; } -//look_around_result game::look_around( const bool show_window, tripoint ¢er, -// const tripoint &start_point, bool has_first_point, bool select_zone, bool peeking ) look_around_result game::look_around( const bool show_window, tripoint_bub_ms ¢er, const tripoint_bub_ms &start_point, bool has_first_point, @@ -7892,28 +7902,24 @@ look_around_result game::look_around( ly = mouse_pos->y(); } } - } else if( std::optional vec = ctxt.get_direction( action ) ) { + } else if( std::optional vec = ctxt.get_direction_rel_ms( action ) ) { if( fast_scroll ) { - vec->x *= soffset; - vec->y *= soffset; + vec->x() *= soffset; + vec->y() *= soffset; } - lx = lx + vec->x; - ly = ly + vec->y; - center.x() = center.x() + vec->x; - center.y() = center.y() + vec->y; + lx = lx + vec->x(); + ly = ly + vec->y(); + center.x() = center.x() + vec->x(); + center.y() = center.y() + vec->y(); } else if( action == "throw_blind" ) { result.peek_action = PA_BLIND_THROW; } else if( action == "zoom_in" ) { - // TODO: fix point types - center.x() = lp.x(); - center.y() = lp.y(); + center.xy() = lp.xy(); zoom_in(); mark_main_ui_adaptor_resize(); } else if( action == "zoom_out" ) { - // TODO: fix point types - center.x() = lp.x(); - center.y() = lp.y(); + center.xy() = lp.xy(); zoom_out(); mark_main_ui_adaptor_resize(); } @@ -7959,15 +7965,16 @@ look_around_result game::look_around( look_around_params looka_params ) } static void add_item_recursive( std::vector &item_order, - std::map &temp_items, const item *it, const tripoint &relative_pos ) + std::map &temp_items, const item *it, + const tripoint_rel_ms &relative_pos ) { const std::string name = it->tname(); if( std::find( item_order.begin(), item_order.end(), name ) == item_order.end() ) { item_order.push_back( name ); - temp_items[name] = map_item_stack( it, relative_pos ); + temp_items[name] = map_item_stack( it, relative_pos.raw() ); } else { - temp_items[name].add_at_pos( it, relative_pos ); + temp_items[name].add_at_pos( it, relative_pos.raw() ); } for( const item *content : it->all_known_contents() ) { @@ -7993,7 +8000,7 @@ std::vector game::find_nearby_items( int iRadius ) for( item &elem : m.i_at( points_p_it ) ) { const tripoint_rel_ms relative_pos = points_p_it - u.pos_bub(); - add_item_recursive( item_order, temp_items, &elem, relative_pos.raw() ); + add_item_recursive( item_order, temp_items, &elem, relative_pos ); } } } @@ -8006,25 +8013,25 @@ std::vector game::find_nearby_items( int iRadius ) return ret; } -void draw_trail( const tripoint &start, const tripoint &end, const bool bDrawX ) +void draw_trail( const tripoint_bub_ms &start, const tripoint_bub_ms &end, const bool bDrawX ) { std::vector pts; avatar &player_character = get_avatar(); tripoint_bub_ms center = player_character.pos_bub() + player_character.view_offset; if( start != end ) { //Draw trail - pts = line_to( tripoint_bub_ms( start ), tripoint_bub_ms( end ), 0, 0 ); + pts = line_to( start, end, 0, 0 ); } else { //Draw point pts.emplace_back( start ); } - g->draw_line( tripoint_bub_ms( end ), center, pts ); + g->draw_line( end, center, pts ); if( bDrawX ) { char sym = 'X'; - if( end.z > center.z() ) { + if( end.z() > center.z() ) { sym = '^'; - } else if( end.z < center.z() ) { + } else if( end.z() < center.z() ) { sym = 'v'; } if( pts.empty() ) { @@ -8039,7 +8046,7 @@ void draw_trail( const tripoint &start, const tripoint &end, const bool bDrawX ) void game::draw_trail_to_square( const tripoint_rel_ms &t, bool bDrawX ) { - ::draw_trail( u.pos_bub().raw(), u.pos_bub().raw() + t.raw(), bDrawX ); + ::draw_trail( u.pos_bub(), u.pos_bub() + t, bDrawX ); } static void centerlistview( const tripoint &active_item_position, int ui_width ) @@ -8622,8 +8629,8 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) wnoutrefresh( w_item_info ); } ); - std::optional trail_start; - std::optional trail_end; + std::optional trail_start; + std::optional trail_end; bool trail_end_x = false; shared_ptr_fast trail_cb = create_trail_callback( trail_start, trail_end, trail_end_x ); @@ -8862,8 +8869,8 @@ game::vmenu_ret game::list_items( const std::vector &item_list ) if( activeItem ) { centerlistview( active_pos, width ); - trail_start = u.pos(); - trail_end = u.pos() + active_pos; + trail_start = u.pos_bub(); + trail_end = u.pos_bub() + active_pos; // Actually accessed from the terrain overlay callback `trail_cb` in the // call to `ui_manager::redraw`. //NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) @@ -9153,8 +9160,8 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list } } ); - std::optional trail_start; - std::optional trail_end; + std::optional trail_start; + std::optional trail_end; bool trail_end_x = false; shared_ptr_fast trail_cb = create_trail_callback( trail_start, trail_end, trail_end_x ); @@ -9207,8 +9214,8 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list cCurMon = monster_list[iActive]; iActivePos = cCurMon->pos() - u.pos(); centerlistview( iActivePos, width ); - trail_start = u.pos(); - trail_end = cCurMon->pos(); + trail_start = u.pos_bub(); + trail_end = cCurMon->pos_bub(); // Actually accessed from the terrain overlay callback `trail_cb` in the // call to `ui_manager::redraw`. //NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) @@ -9269,8 +9276,8 @@ void game::insert_item() void game::unload_container() { - if( const std::optional pnt = choose_adjacent( _( "Unload where?" ) ) ) { - u.drop( game_menus::inv::unload_container(), *pnt ); + if( const std::optional pnt = choose_adjacent_bub( _( "Unload where?" ) ) ) { + u.drop( game_menus::inv::unload_container(), pnt->raw() ); } } @@ -10393,11 +10400,6 @@ void game::set_safe_mode( safe_mode_type mode ) safe_mode_warning_logged = false; } -bool game::disable_robot( const tripoint &p ) -{ - return game::disable_robot( tripoint_bub_ms( p ) ); -} - bool game::disable_robot( const tripoint_bub_ms &p ) { monster *const mon_ptr = get_creature_tracker().creature_at( p ); @@ -10434,12 +10436,12 @@ bool game::disable_robot( const tripoint_bub_ms &p ) return false; } -bool game::is_dangerous_tile( const tripoint &dest_loc ) const +bool game::is_dangerous_tile( const tripoint_bub_ms &dest_loc ) const { return !get_dangerous_tile( dest_loc, 1 ).empty(); } -bool game::prompt_dangerous_tile( const tripoint &dest_loc, +bool game::prompt_dangerous_tile( const tripoint_bub_ms &dest_loc, std::vector *harmful_stuff ) const { if( u.has_effect( effect_stunned ) || u.has_effect( effect_psi_stunned ) ) { @@ -10463,12 +10465,6 @@ bool game::prompt_dangerous_tile( const tripoint &dest_loc, return true; } -std::vector game::get_dangerous_tile( const tripoint &dest_loc, - const size_t max ) const -{ - return game::get_dangerous_tile( tripoint_bub_ms( dest_loc ), max ); -} - std::vector game::get_dangerous_tile( const tripoint_bub_ms &dest_loc, const size_t max ) const { @@ -10717,16 +10713,16 @@ bool game::walk_move( const tripoint_bub_ms &dest_loc, const bool via_ramp, iexamine::ledge( u, tripoint_bub_ms( dest_loc ) ); return true; } else if( get_option( "DANGEROUS_TERRAIN_WARNING_PROMPT" ) == "ALWAYS" && - !prompt_dangerous_tile( dest_loc.raw(), &harmful_stuff ) ) { + !prompt_dangerous_tile( dest_loc, &harmful_stuff ) ) { return true; } else if( get_option( "DANGEROUS_TERRAIN_WARNING_PROMPT" ) == "RUNNING" && - ( !u.is_running() || !prompt_dangerous_tile( dest_loc.raw(), &harmful_stuff ) ) ) { + ( !u.is_running() || !prompt_dangerous_tile( dest_loc, &harmful_stuff ) ) ) { add_msg( m_warning, _( "Stepping into that %1$s looks risky. Run into it if you wish to enter anyway." ), enumerate_as_string( harmful_stuff ) ); return true; } else if( get_option( "DANGEROUS_TERRAIN_WARNING_PROMPT" ) == "CROUCHING" && - ( !u.is_crouching() || !prompt_dangerous_tile( dest_loc.raw(), &harmful_stuff ) ) ) { + ( !u.is_crouching() || !prompt_dangerous_tile( dest_loc, &harmful_stuff ) ) ) { add_msg( m_warning, _( "Stepping into that %1$s looks risky. Crouch and move into it if you wish to enter anyway." ), enumerate_as_string( harmful_stuff ) ); @@ -10872,7 +10868,7 @@ bool game::walk_move( const tripoint_bub_ms &dest_loc, const bool via_ramp, oldpos = oldpos - ms_shift.raw(); if( moving ) { - cata_event_dispatch::avatar_moves( old_abs_pos.raw(), u, m ); + cata_event_dispatch::avatar_moves( old_abs_pos, u, m ); // Add trail animation when sprinting if( get_option( "ANIMATIONS" ) && u.is_running() ) { @@ -10923,7 +10919,7 @@ bool game::walk_move( const tripoint_bub_ms &dest_loc, const bool via_ramp, } if( u.is_hauling() ) { - start_hauling( oldpos.raw() ); + start_hauling( oldpos ); } if( u.will_be_cramped_in_vehicle_tile( dest_loc_abs ) ) { @@ -11103,7 +11099,7 @@ point_rel_sm game::place_player( const tripoint_bub_ms &dest_loc, bool quick ) mon->process_triggers(); m.creature_in_field( *mon ); } - point_rel_sm submap_shift = point_rel_sm( update_map( u, z_level_changed ) ); + point_rel_sm submap_shift = update_map( u, z_level_changed ); // Important: don't use dest_loc after this line. `update_map` may have shifted the map // and dest_loc was not adjusted and therefore is still in the un-shifted system and probably wrong. // If you must use it you can calculate the position in the new, shifted system with @@ -11235,7 +11231,7 @@ point_rel_sm game::place_player( const tripoint_bub_ms &dest_loc, bool quick ) // List items here if( !quick && !m.has_flag( ter_furn_flag::TFLAG_SEALED, u.pos_bub() ) ) { if( get_option( "NO_AUTO_PICKUP_ZONES_LIST_ITEMS" ) || - !check_zone( zone_type_NO_AUTO_PICKUP, u.pos() ) ) { + !check_zone( zone_type_NO_AUTO_PICKUP, u.pos_bub() ) ) { const map_stack &ms = m.i_at( u.pos_bub() ); if( u.is_blind() && !ms.empty() ) { add_msg( _( "There's something here, but you can't see what it is." ) ); @@ -11444,8 +11440,8 @@ bool game::phasing_move_enchant( const tripoint_bub_ms &dest_loc, const int phas int tunneldist = 0; tripoint_bub_ms dest = dest_loc; - const tripoint d( sgn( dest.x() - u.posx() ), sgn( dest.y() - u.posy() ), - sgn( dest.z() - u.posz() ) ); + const tripoint_rel_ms d( sgn( dest.x() - u.posx() ), sgn( dest.y() - u.posy() ), + sgn( dest.z() - u.posz() ) ); creature_tracker &creatures = get_creature_tracker(); while( m.impassable( dest ) || @@ -11462,7 +11458,7 @@ bool game::phasing_move_enchant( const tripoint_bub_ms &dest_loc, const int phas } // vertical handling for adjacent tiles - if( d.z != 0 && !m.impassable( dest_loc ) && tunneldist == 0 ) { + if( d.z() != 0 && !m.impassable( dest_loc ) && tunneldist == 0 ) { tunneldist += 1; } @@ -11941,7 +11937,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo tileray tdir( dir ); int range = flvel / 10; - tripoint pt = c->pos(); + tripoint_bub_ms pt = c->pos_bub(); creature_tracker &creatures = get_creature_tracker(); while( range > 0 ) { c->underwater = false; @@ -11949,8 +11945,8 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo // or maybe even just redraw the changed tiles bool seen = is_u || u.sees( *c ); // To avoid redrawing when not seen tdir.advance(); - pt.x = c->posx() + tdir.dx(); - pt.y = c->posy() + tdir.dy(); + pt.x() = c->posx() + tdir.dx(); + pt.y() = c->posy() + tdir.dy(); float force = 0.0f; if( monster *const mon_ptr = creatures.creature_at( pt ) ) { @@ -11958,7 +11954,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo // Approximate critter's "stopping power" with its max hp force = std::min( 1.5f * critter.type->hp, flvel ); const int damage = rng( force, force * 2.0f ) / 6; - c->impact( damage, pt ); + c->impact( damage, pt.raw() ); // Multiply zed damage by 6 because no body parts const int zed_damage = std::max( 0, ( damage - critter.get_armor_type( damage_bash, bodypart_id( "torso" ) ) ) * 6 ); @@ -11978,7 +11974,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo force = flvel - 1; } const int damage = rng( force, force * 2.0f ) / 9; - c->impact( damage, pt ); + c->impact( damage, pt.raw() ); if( m.is_bashable( pt ) ) { // Only go through if we successfully make the tile passable m.bash( pt, flvel ); @@ -12001,7 +11997,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo } // If we're flinging the player around, make sure the map stays centered on them. if( is_u ) { - update_map( pt.x, pt.y ); + update_map( pt.x(), pt.y() ); } else { you->setpos( pt ); } @@ -12098,11 +12094,11 @@ std::optional game::point_selection_menu( const std::vector find_empty_spot_nearby( const tripoint &pos ) +static std::optional find_empty_spot_nearby( const tripoint_bub_ms &pos ) { map &here = get_map(); creature_tracker &creatures = get_creature_tracker(); - for( const tripoint &p : here.points_in_radius( pos, 1 ) ) { + for( const tripoint_bub_ms &p : here.points_in_radius( pos, 1 ) ) { if( p == pos ) { continue; } @@ -12387,12 +12383,12 @@ void game::vertical_move( int movez, bool force, bool peeking ) bool rope_ladder = false; // TODO: Remove the stairfinding, make the mapgen gen aligned maps if( !force && !climbing && !swimming ) { - const std::optional pnt = find_or_make_stairs( m, z_after, rope_ladder, peeking, - u.pos() ); + const std::optional pnt = find_or_make_stairs( m, z_after, rope_ladder, peeking, + u.pos_bub() ); if( !pnt ) { return; } - stairs = tripoint_bub_ms( *pnt ); + stairs = *pnt; } std::vector monsters_following; @@ -12430,7 +12426,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) const tripoint_bub_ms old_pos = u.pos_bub(); const tripoint_abs_ms old_abs_pos = here.getglobal( old_pos ); - point submap_shift; + point_rel_sm submap_shift; const bool z_level_changed = vertical_shift( z_after ); if( !force ) { submap_shift = update_map( stairs.x(), stairs.y(), z_level_changed ); @@ -12443,10 +12439,10 @@ void game::vertical_move( int movez, bool force, bool peeking ) creatures.creature_at( u.pos_bub(), true ) ) { std::string crit_name; bool player_displace = false; - std::optional displace = find_empty_spot_nearby( u.pos() ); + std::optional displace = find_empty_spot_nearby( u.pos_bub() ); if( !displace.has_value() ) { // They can always move to the previous location of the player. - displace = old_pos.raw(); + displace = old_pos; } npc *guy = creatures.creature_at( u.pos_bub(), true ); if( guy ) { @@ -12513,7 +12509,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) if( u.is_hauling() ) { const tripoint_bub_ms adjusted_pos = old_pos - coords::project_to( point_rel_sm( submap_shift ) ).raw(); - start_hauling( adjusted_pos.raw() ); + start_hauling( adjusted_pos ); } here.invalidate_map_cache( here.get_abs_sub().z() ); @@ -12525,10 +12521,10 @@ void game::vertical_move( int movez, bool force, bool peeking ) u.recoil = MAX_RECOIL; - cata_event_dispatch::avatar_moves( old_abs_pos.raw(), u, m ); + cata_event_dispatch::avatar_moves( old_abs_pos, u, m ); } -void game::start_hauling( const tripoint &pos ) +void game::start_hauling( const tripoint_bub_ms &pos ) { std::vector candidate_items = m.get_haulable_items( pos ); // Find target items and quantities thereof for the new activity @@ -12575,9 +12571,10 @@ void game::start_hauling( const tripoint &pos ) u.assign_activity( actor ); } -std::optional game::find_stairs( const map &mp, int z_after, const tripoint &pos ) +std::optional game::find_stairs( const map &mp, int z_after, + const tripoint_bub_ms &pos ) { - const int movez = z_after - pos.z; + const int movez = z_after - pos.z(); const bool going_down_1 = movez == -1; const bool going_up_1 = movez == 1; @@ -12591,7 +12588,7 @@ std::optional game::find_stairs( const map &mp, int z_after, const tri // We did not find stairs directly above or below, so search the map for them // If there's empty space right below us, we can just go down that way. int best = INT_MAX; - std::optional stairs; + std::optional stairs; const int omtilesz = SEEX * 2 - 1; const tripoint_abs_ms abs_omt_base( project_to( project_to( mp.getglobal( pos ) ) ) ); @@ -12608,7 +12605,7 @@ std::optional game::find_stairs( const map &mp, int z_after, const tri ( going_up_1 && ( mp.has_flag( ter_furn_flag::TFLAG_GOES_DOWN, dest ) || mp.ter( dest ) == ter_t_manhole_cover ) ) || ( ( movez == 2 || movez == -2 ) && mp.ter( dest ) == ter_t_elevator ) ) ) { - stairs.emplace( dest.raw() ); + stairs.emplace( dest ); best = rl_dist( u.pos_bub(), dest ); } } @@ -12617,14 +12614,15 @@ std::optional game::find_stairs( const map &mp, int z_after, const tri return stairs; } -std::optional game::find_or_make_stairs( map &mp, const int z_after, bool &rope_ladder, - bool peeking, const tripoint &pos ) +std::optional game::find_or_make_stairs( map &mp, const int z_after, + bool &rope_ladder, + bool peeking, const tripoint_bub_ms &pos ) { - const bool is_avatar = u.pos() == pos; - const int movez = z_after - pos.z; + const bool is_avatar = u.pos_bub() == pos; + const int movez = z_after - pos.z(); // Try to find the stairs. - std::optional stairs = find_stairs( mp, z_after, pos ); + std::optional stairs = find_stairs( mp, z_after, pos ); creature_tracker &creatures = get_creature_tracker(); if( stairs.has_value() ) { @@ -12662,7 +12660,7 @@ std::optional game::find_or_make_stairs( map &mp, const int z_after, b // No stairs found! Try to make some rope_ladder = false; stairs.emplace( pos ); - stairs->z = z_after; + stairs->z() = z_after; // Check the destination area for lava. if( mp.ter( *stairs ) == ter_t_lava ) { if( movez < 0 && @@ -12818,34 +12816,34 @@ void game::vertical_notes( int z_before, int z_after ) } } -point game::update_map( Character &p, bool z_level_changed ) +point_rel_sm game::update_map( Character &p, bool z_level_changed ) { - point p2( p.posx(), p.posy() ); - return update_map( p2.x, p2.y, z_level_changed ); + point_bub_ms p2( p.pos_bub().xy() ); + return update_map( p2.x(), p2.y(), z_level_changed ); } -point game::update_map( int &x, int &y, bool z_level_changed ) +point_rel_sm game::update_map( int &x, int &y, bool z_level_changed ) { - point shift; + point_rel_sm shift; while( x < HALF_MAPSIZE_X ) { x += SEEX; - shift.x--; + shift.x()--; } while( x >= HALF_MAPSIZE_X + SEEX ) { x -= SEEX; - shift.x++; + shift.x()++; } while( y < HALF_MAPSIZE_Y ) { y += SEEY; - shift.y--; + shift.y()--; } while( y >= HALF_MAPSIZE_Y + SEEY ) { y -= SEEY; - shift.y++; + shift.y()++; } - if( shift == point::zero ) { + if( shift == point_rel_sm::zero ) { // adjust player position u.setpos( tripoint( x, y, m.get_abs_sub().z() ) ); if( z_level_changed ) { @@ -12854,27 +12852,27 @@ point game::update_map( int &x, int &y, bool z_level_changed ) update_overmap_seen(); } // Not actually shifting the submaps, all the stuff below would do nothing - return point::zero; + return point_rel_sm::zero; } // this handles loading/unloading submaps that have scrolled on or off the viewport // NOLINTNEXTLINE(cata-use-named-point-constants) - inclusive_rectangle size_1( point( -1, -1 ), point( 1, 1 ) ); - point remaining_shift = shift; - while( remaining_shift != point::zero ) { - point this_shift = clamp( remaining_shift, size_1 ); + inclusive_rectangle size_1( {-1, -1}, { 1, 1 } ); + point_rel_sm remaining_shift = shift; + while( remaining_shift != point_rel_sm::zero ) { + point_rel_sm this_shift = clamp( remaining_shift, size_1 ); m.shift( point_rel_sm( this_shift ) ); remaining_shift -= this_shift; } // Shift monsters - shift_monsters( tripoint( shift, 0 ) ); - const point shift_ms = coords::project_to( point_rel_sm( shift ) ).raw(); - u.shift_destination( -shift_ms ); + shift_monsters( { shift, 0 } ); + const point_rel_ms shift_ms = coords::project_to( shift ); + u.shift_destination( -shift_ms.raw() ); // Shift NPCs for( auto it = critter_tracker->active_npc.begin(); it != critter_tracker->active_npc.end(); ) { - ( *it )->shift( shift ); + ( *it )->shift( shift.raw() ); if( ( *it )->posx() < 0 || ( *it )->posx() >= MAPSIZE_X || ( *it )->posy() < 0 || ( *it )->posy() >= MAPSIZE_Y ) { //Remove the npc from the active list. It remains in the overmap list. @@ -12885,7 +12883,7 @@ point game::update_map( int &x, int &y, bool z_level_changed ) } } - scent.shift( shift_ms ); + scent.shift( shift_ms.raw() ); // Also ensure the player is on current z-level // m.get_abs_sub().z should later be removed, when there is no longer such a thing @@ -12992,14 +12990,14 @@ void game::despawn_nonlocal_monsters() } } -void game::shift_monsters( const tripoint &shift ) +void game::shift_monsters( const tripoint_rel_sm &shift ) { - if( shift == tripoint::zero ) { + if( shift == tripoint_rel_sm::zero ) { return; } for( monster &critter : all_monsters() ) { - if( shift.xy() != point::zero ) { - critter.shift( shift.xy() ); + if( shift.xy() != point_rel_sm::zero ) { + critter.shift( shift.raw().xy() ); } if( m.inbounds( critter.pos_bub() ) ) { @@ -13982,7 +13980,7 @@ void game::climb_down_using( const tripoint_bub_ms &examp, climbing_aid_id aid_i namespace cata_event_dispatch { -void avatar_moves( const tripoint &old_abs_pos, const avatar &u, const map &m ) +void avatar_moves( const tripoint_abs_ms &old_abs_pos, const avatar &u, const map &m ) { const tripoint_bub_ms new_pos = u.pos_bub(); const tripoint_abs_ms new_abs_pos = m.getglobal( new_pos ); @@ -13993,11 +13991,10 @@ void avatar_moves( const tripoint &old_abs_pos, const avatar &u, const map &m ) get_event_bus().send( mount_type, m.ter( new_pos ).id(), u.current_movement_mode(), u.is_underwater(), new_pos.z() ); - // TODO: fix point types - const tripoint_abs_omt old_abs_omt( coords::project_to( tripoint_abs_ms( - old_abs_pos ) ) ); - const tripoint_abs_omt new_abs_omt( coords::project_to( tripoint_abs_ms( - new_abs_pos ) ) ); + const tripoint_abs_omt old_abs_omt( coords::project_to( + old_abs_pos ) ); + const tripoint_abs_omt new_abs_omt( coords::project_to( + new_abs_pos ) ); if( old_abs_omt != new_abs_omt ) { const oter_id &cur_ter = overmap_buffer.ter( new_abs_omt ); const oter_id &past_ter = overmap_buffer.ter( old_abs_omt ); diff --git a/src/game.h b/src/game.h index a2b0c5be802f0..eae4212640af6 100644 --- a/src/game.h +++ b/src/game.h @@ -261,14 +261,14 @@ class game async_anim_layer_curses; // NOLINT(cata-serialize) public: - void init_draw_blink_curses( const tripoint &p, const std::string &ncstr, + void init_draw_blink_curses( const tripoint_bub_ms &p, const std::string &ncstr, const nc_color &nccol ); void draw_blink_curses(); void void_blink_curses(); bool has_blink_curses(); bool blink_active_phase = true; // NOLINT(cata-serialize) protected: - std::map> + std::map> blink_layer_curses; // NOLINT(cata-serialize) public: @@ -282,7 +282,7 @@ class game * @param next If true, bases it on the vehicle the vehicle will turn to next turn, * instead of the one it is currently facing. */ - std::optional get_veh_dir_indicator_location( bool next ) const; + std::optional get_veh_dir_indicator_location( bool next ) const; void draw_veh_dir_indicator( bool next ); /** @@ -291,13 +291,14 @@ class game * If peeking == true, forbids some exotic movement options */ void vertical_move( int z, bool force, bool peeking = false ); - void start_hauling( const tripoint &pos ); + void start_hauling( const tripoint_bub_ms &pos ); /** Returns the other end of the stairs (if any). May query, affect u etc. * @param pos Disable queries and msgs if not the same position as player. */ - std::optional find_stairs( const map &mp, int z_after, const tripoint &pos ); - std::optional find_or_make_stairs( map &mp, int z_after, bool &rope_ladder, - bool peeking, const tripoint &pos ); + std::optional find_stairs( const map &mp, int z_after, + const tripoint_bub_ms &pos ); + std::optional find_or_make_stairs( map &mp, int z_after, bool &rope_ladder, + bool peeking, const tripoint_bub_ms &pos ); /* * Prompt player on direction they want to climb up or down. */ @@ -351,17 +352,14 @@ class game * the one contained in @p mon). */ /** @{ */ - // TODO: Get rid of untyped overload. - monster *place_critter_at( const mtype_id &id, const tripoint &p ); monster *place_critter_at( const mtype_id &id, const tripoint_bub_ms &p ); - monster *place_critter_at( const shared_ptr_fast &mon, const tripoint &p ); monster *place_critter_at( const shared_ptr_fast &mon, const tripoint_bub_ms &p ); - monster *place_critter_around( const mtype_id &id, const tripoint ¢er, int radius ); - monster *place_critter_around( const shared_ptr_fast &mon, const tripoint ¢er, + monster *place_critter_around( const mtype_id &id, const tripoint_bub_ms ¢er, int radius ); + monster *place_critter_around( const shared_ptr_fast &mon, const tripoint_bub_ms ¢er, int radius, bool forced = false ); - monster *place_critter_within( const mtype_id &id, const tripoint_range &range ); + monster *place_critter_within( const mtype_id &id, const tripoint_range &range ); monster *place_critter_within( const shared_ptr_fast &mon, - const tripoint_range &range ); + const tripoint_range &range ); /** @} */ /** * Returns the approximate number of creatures in the reality bubble. @@ -376,19 +374,20 @@ class game /** Redirects to the creature_tracker clear() function. */ void clear_zombies(); /** Spawns a hallucination at a determined position. */ - bool spawn_hallucination( const tripoint &p ); + bool spawn_hallucination( const tripoint_bub_ms &p ); /** Spawns a hallucination at a determined position of a given monster. */ - bool spawn_hallucination( const tripoint &p, const mtype_id &mt, + bool spawn_hallucination( const tripoint_bub_ms &p, const mtype_id &mt, std::optional lifespan ); /** Spawns a npc at a determined position. */ - bool spawn_npc( const tripoint &p, const string_id &npc_class, std::string &unique_id, + bool spawn_npc( const tripoint_bub_ms &p, const string_id &npc_class, + std::string &unique_id, std::vector &traits, std::optional lifespan ); /** Finds somewhere to spawn a monster or npc. */ - bool find_nearby_spawn_point( const tripoint &target, const mtype_id &mt, int min_radius, - int max_radius, tripoint &point, bool outdoor_only, bool indoor_only, + bool find_nearby_spawn_point( const tripoint_bub_ms &target, const mtype_id &mt, int min_radius, + int max_radius, tripoint_bub_ms &point, bool outdoor_only, bool indoor_only, bool open_air_allowed = false ); - bool find_nearby_spawn_point( const tripoint &target, int min_radius, - int max_radius, tripoint &point, bool outdoor_only, bool indoor_only, + bool find_nearby_spawn_point( const tripoint_bub_ms &target, int min_radius, + int max_radius, tripoint_bub_ms &point, bool outdoor_only, bool indoor_only, bool open_air_allowed = false ); /** Swaps positions of two creatures */ bool swap_critters( Creature &, Creature & ); @@ -502,10 +501,8 @@ class game bool is_empty( const tripoint &p ); bool is_empty( const tripoint_bub_ms &p ); /** Returns true if p is outdoors and it is sunny. */ - bool is_in_sunlight( const tripoint &p ); + bool is_in_sunlight( const tripoint_bub_ms &p ); /** Returns true if p is indoors, underground, or in a car. */ - // TODO: Get rid of untyped overload. - bool is_sheltered( const tripoint &p ); bool is_sheltered( const tripoint_bub_ms &p ); /** * Revives a corpse at given location. The monster type and some of its properties are @@ -518,11 +515,11 @@ class game * If the monster was revived, the caller should remove the corpse item. * If reviving failed, the item is unchanged, as is the environment (no new monsters). */ - bool revive_corpse( const tripoint &p, item &it ); + bool revive_corpse( const tripoint_bub_ms &p, item &it ); // same as above, but with relaxed placement radius. - bool revive_corpse( const tripoint &p, item &it, int radius ); + bool revive_corpse( const tripoint_bub_ms &p, item &it, int radius ); /**Turns Broken Cyborg monster into Cyborg NPC via surgery*/ - void save_cyborg( item *cyborg, const tripoint &couch_pos, Character &installer ); + void save_cyborg( item *cyborg, const tripoint_bub_ms &couch_pos, Character &installer ); /** Asks if the player wants to cancel their activity, and if so cancels it. */ bool cancel_activity_query( const std::string &text ); /** Asks if the player wants to cancel their activity and if so cancels it. Additionally checks @@ -530,7 +527,7 @@ class game bool cancel_activity_or_ignore_query( distraction_type type, const std::string &text ); bool portal_storm_query( distraction_type type, const std::string &text ); /** Handles players exiting from moving vehicles. */ - void moving_vehicle_dismount( const tripoint &dest_loc ); + void moving_vehicle_dismount( const tripoint_bub_ms &dest_loc ); /** Returns the current remotely controlled vehicle. */ vehicle *remoteveh(); @@ -579,7 +576,7 @@ class game /** validate camps to ensure they are on the overmap list */ void validate_camps(); /** Picks and spawns a random fish from the remaining fish list when a fish is caught. */ - void catch_a_monster( monster *fish, const tripoint &pos, Character *p, + void catch_a_monster( monster *fish, const tripoint_bub_ms &pos, Character *p, const time_duration &catch_duration ); /** * Get the contiguous fishable locations starting at fish_pos, out to the specified distance. @@ -587,14 +584,21 @@ class game * @param fish_pos The location being fished. * @return A set of locations representing the valid contiguous fishable locations. */ - std::unordered_set get_fishable_locations( int distance, const tripoint &fish_pos ); + // TODO: Get rid of untyped overload. + std::unordered_set get_fishable_locations( int distance, + const tripoint_bub_ms &fish_pos ); + std::unordered_set get_fishable_locations_bub( int distance, + const tripoint_bub_ms &fish_pos ); /** * Get the fishable monsters within the provided fishable locations. * @param fishable_locations A set of locations which are valid fishable terrain. Any fishable monsters * are filtered by this collection to determine those which can actually be caught. * @return Fishable monsters within the specified fishable terrain. */ + // TODO: Get rid of untyped overload. std::vector get_fishable_monsters( std::unordered_set &fishable_locations ); + std::vector get_fishable_monsters( std::unordered_set + &fishable_locations ); /** Destroy / dissolve character items when in water. */ void water_affect_items( Character &ch ) const; @@ -616,17 +620,17 @@ class game field_entry *is_in_dangerous_field(); // Handles shifting coordinates transparently when moving between submaps. // Helper to make calling with a player pointer less verbose. - point update_map( Character &p, bool z_level_changed = false ); - point update_map( int &x, int &y, bool z_level_changed = false ); + point_rel_sm update_map( Character &p, bool z_level_changed = false ); + point_rel_sm update_map( int &x, int &y, bool z_level_changed = false ); void update_overmap_seen(); // Update which overmap tiles we can see void peek(); void peek( const tripoint_bub_ms &p ); std::optional look_debug(); - bool check_zone( const zone_type_id &type, const tripoint &where ) const; + bool check_zone( const zone_type_id &type, const tripoint_bub_ms &where ) const; /** Checks whether or not there is a zone of particular type nearby */ - bool check_near_zone( const zone_type_id &type, const tripoint &where ) const; + bool check_near_zone( const zone_type_id &type, const tripoint_bub_ms &where ) const; bool is_zones_manager_open() const; void zones_manager(); @@ -934,16 +938,12 @@ class game void set_critter_died(); void mon_info_update( ); //Update seen monsters information void cleanup_dead(); // Delete any dead NPCs/monsters - bool is_dangerous_tile( const tripoint &dest_loc ) const; - // TODO: Get rid of untyped overload. - std::vector get_dangerous_tile( const tripoint &dest_loc, size_t max = 0 ) const; + bool is_dangerous_tile( const tripoint_bub_ms &dest_loc ) const; std::vector get_dangerous_tile( const tripoint_bub_ms &dest_loc, size_t max = 0 ) const; - bool prompt_dangerous_tile( const tripoint &dest_loc, + bool prompt_dangerous_tile( const tripoint_bub_ms &dest_loc, std::vector *harmful_stuff = nullptr ) const; // Pick up items from the given point - // TODO: Get rid of untyped overloads. - void pickup( const tripoint &p ); void pickup( const tripoint_bub_ms &p ); private: void wield(); @@ -978,13 +978,13 @@ class game input_context get_player_input( std::string &action ); /** - * Shift all active monsters, the shift vector is the number of + * Shift all active monsters, the shift coordinate is the number of * shifted submaps. Monsters that are outside of the reality bubble after * shifting are despawned. * Note on z-levels: this works with vertical shifts, but currently all * monsters are despawned upon a vertical shift. */ - void shift_monsters( const tripoint &shift ); + void shift_monsters( const tripoint_rel_sm &shift ); public: /** * Despawn a specific monster, it's stored on the overmap. Also removes @@ -998,7 +998,7 @@ class game // Routine loop functions, approximately in order of execution void open_consume_item_menu(); // Custom menu for consuming specific group of items bool do_regular_action( action_id &act, avatar &player_character, - const std::optional &mouse_target ); + const std::optional &mouse_target ); bool handle_action(); bool try_get_right_click_action( action_id &act, const tripoint_bub_ms &mouse_target ); bool try_get_left_click_action( action_id &act, const tripoint_bub_ms &mouse_target ); @@ -1018,8 +1018,6 @@ class game * been done. false if the player did not choose any action and the function * has effectively done nothing. */ - // TODO: Get rid of untyped overload. - bool disable_robot( const tripoint &p ); bool disable_robot( const tripoint_bub_ms &p ); // Draws the pixel minimap based on the player's current location void draw_pixel_minimap( const catacurses::window &w ); @@ -1307,12 +1305,12 @@ class game // Returns temperature modifier from direct heat radiation of nearby sources // @param location Location affected by heat sources -units::temperature_delta get_heat_radiation( const tripoint &location ); +units::temperature_delta get_heat_radiation( const tripoint_bub_ms &location ); // Returns heat intensity of adjecent fires -int get_best_fire( const tripoint &location ); +int get_best_fire( const tripoint_bub_ms &location ); // Returns temperature modifier from hot air fields of given location -units::temperature_delta get_convection_temperature( const tripoint &location ); +units::temperature_delta get_convection_temperature( const tripoint_bub_ms &location ); namespace cata_event_dispatch { @@ -1320,7 +1318,7 @@ namespace cata_event_dispatch // @param p The point the avatar moved from in absolute coordinates // @param u The avatar (should have already moved to the new pos) // @param m The map the avatar is moving on -void avatar_moves( const tripoint &old_abs_pos, const avatar &u, const map &m ); +void avatar_moves( const tripoint_abs_ms &old_abs_pos, const avatar &u, const map &m ); } // namespace cata_event_dispatch bool are_we_quitting(); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 56b82c4c5f9c0..76d74a0aa7bc1 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -1497,30 +1497,30 @@ static void loot() mgr.cache_vzones(); flags |= g->check_near_zone( zone_type_LOOT_UNSORTED, - player_character.pos() ) ? SortLoot : 0; - flags |= g->check_near_zone( zone_type_UNLOAD_ALL, player_character.pos() ) || - g->check_near_zone( zone_type_STRIP_CORPSES, player_character.pos() ) ? UnloadLoot : 0; - if( g->check_near_zone( zone_type_FARM_PLOT, player_character.pos() ) ) { + player_character.pos_bub() ) ? SortLoot : 0; + flags |= g->check_near_zone( zone_type_UNLOAD_ALL, player_character.pos_bub() ) || + g->check_near_zone( zone_type_STRIP_CORPSES, player_character.pos_bub() ) ? UnloadLoot : 0; + if( g->check_near_zone( zone_type_FARM_PLOT, player_character.pos_bub() ) ) { flags |= FertilizePlots; flags |= MultiFarmPlots; } flags |= g->check_near_zone( zone_type_CONSTRUCTION_BLUEPRINT, - player_character.pos() ) ? ConstructPlots : 0; + player_character.pos_bub() ) ? ConstructPlots : 0; flags |= g->check_near_zone( zone_type_CHOP_TREES, - player_character.pos() ) ? Multichoptrees : 0; + player_character.pos_bub() ) ? Multichoptrees : 0; flags |= g->check_near_zone( zone_type_LOOT_WOOD, - player_character.pos() ) ? Multichopplanks : 0; + player_character.pos_bub() ) ? Multichopplanks : 0; flags |= g->check_near_zone( zone_type_VEHICLE_DECONSTRUCT, - player_character.pos() ) ? Multideconvehicle : 0; + player_character.pos_bub() ) ? Multideconvehicle : 0; flags |= g->check_near_zone( zone_type_VEHICLE_REPAIR, - player_character.pos() ) ? Multirepairvehicle : 0; + player_character.pos_bub() ) ? Multirepairvehicle : 0; flags |= g->check_near_zone( zone_type_LOOT_CORPSE, - player_character.pos() ) ? MultiButchery : 0; - flags |= g->check_near_zone( zone_type_MINING, player_character.pos() ) ? MultiMining : 0; + player_character.pos_bub() ) ? MultiButchery : 0; + flags |= g->check_near_zone( zone_type_MINING, player_character.pos_bub() ) ? MultiMining : 0; flags |= g->check_near_zone( zone_type_DISASSEMBLE, - player_character.pos() ) ? MultiDis : 0; - flags |= g->check_near_zone( zone_type_MOPPING, player_character.pos() ) ? MultiMopping : 0; + player_character.pos_bub() ) ? MultiDis : 0; + flags |= g->check_near_zone( zone_type_MOPPING, player_character.pos_bub() ) ? MultiMopping : 0; if( flags == 0 ) { add_msg( m_info, _( "There is no compatible zone nearby." ) ); add_msg( m_info, _( "Compatible zones are %s and %s" ), @@ -2239,7 +2239,7 @@ static std::map get_actions_disabled_mounted() } bool game::do_regular_action( action_id &act, avatar &player_character, - const std::optional &mouse_target ) + const std::optional &mouse_target ) { item_location weapon = player_character.get_wielded_item(); const bool in_shell = player_character.has_active_mutation( trait_SHELL2 ) @@ -2489,7 +2489,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, case ACTION_PICKUP: case ACTION_PICKUP_ALL: if( mouse_target ) { - pickup( *mouse_target ); + pickup( tripoint_bub_ms( *mouse_target ) ); } else { if( act == ACTION_PICKUP_ALL ) { pickup_all(); @@ -3276,8 +3276,7 @@ bool game::handle_action() // actions allowed only while alive if( !player_character.is_dead_state() ) { - if( !do_regular_action( act, player_character, - mouse_target ? std::make_optional( mouse_target->raw() ) : std::nullopt ) ) { + if( !do_regular_action( act, player_character, mouse_target ) ) { return false; } } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 35da4af1990f0..36f688bd7d88c 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1379,7 +1379,7 @@ void iexamine::elevator( Character &you, const tripoint_bub_ms &examp ) if( you.is_avatar() ) { g->vertical_shift( movez ); g->update_map( you, true ); - cata_event_dispatch::avatar_moves( old_abs_pos.raw(), *you.as_avatar(), get_map() ); + cata_event_dispatch::avatar_moves( old_abs_pos, *you.as_avatar(), get_map() ); } } @@ -2073,7 +2073,7 @@ void iexamine::pedestal_wyrm( Character &you, const tripoint_bub_ms &examp ) get_event_bus().send(); for( const tripoint_bub_ms &p : here.points_on_zlevel() ) { if( here.ter( p ) == ter_t_orifice ) { - g->place_critter_around( mon_dark_wyrm, p.raw(), 1 ); + g->place_critter_around( mon_dark_wyrm, p, 1 ); } } @@ -5789,7 +5789,7 @@ void iexamine::autodoc( Character &you, const tripoint_bub_ms &examp ) } int choice_index = uilist( _( "Choose bionic to uninstall" ), choice_names ); if( choice_index == 0 ) { - g->save_cyborg( &cyborg, couch_pos.raw(), you ); + g->save_cyborg( &cyborg, couch_pos, you ); } else { popup( _( "UNKNOWN COMMAND. Autodoc Mk. XI. Crashed." ) ); return; diff --git a/src/item.cpp b/src/item.cpp index 607694cc5cb22..d21c6e562e86c 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -12967,8 +12967,8 @@ bool item::process_temperature_rot( float insulation, const tripoint_bub_ms &pos units::temperature_delta temp_mod; // Toilets and vending machines will try to get the heat radiation and convection during mapgen and segfault. if( !g->new_game ) { - temp_mod = get_heat_radiation( pos.raw() ); - temp_mod += get_convection_temperature( pos.raw() ); + temp_mod = get_heat_radiation( pos ); + temp_mod += get_convection_temperature( pos ); temp_mod += here.get_temperature_mod( pos ); } else { temp_mod = units::from_kelvin_delta( 0 ); @@ -13361,7 +13361,7 @@ bool item::process_corpse( map &here, Character *carrier, const tripoint_bub_ms here.trap_set( pos, trap_id( "tr_dormant_corpse" ) ); } else if( trap_here->loadid != trap_id( "tr_dormant_corpse" ) ) { // if there is a trap, but it isn't the right one, we need to revive the zombie manually. - return g->revive_corpse( pos.raw(), *this, 3 ); + return g->revive_corpse( pos, *this, 3 ); } return false; } @@ -13377,7 +13377,7 @@ bool item::process_corpse( map &here, Character *carrier, const tripoint_bub_ms return false; } if( rng( 0, volume() / units::legacy_volume_factor ) > burnt && - g->revive_corpse( pos.raw(), *this ) ) { + g->revive_corpse( pos, *this ) ) { if( carrier == nullptr ) { if( corpse->in_species( species_ROBOT ) ) { add_msg_if_player_sees( pos, m_warning, _( "A nearby robot has repaired itself and stands up!" ) ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 5de739c47da5b..3c59888fe25ca 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1742,7 +1742,7 @@ std::optional iuse::remove_all_mods( Character *p, item *, const tripoint_b static bool good_fishing_spot( const tripoint_bub_ms &pos, Character *p ) { - std::unordered_set fishable_locations = g->get_fishable_locations( 60, pos.raw() ); + std::unordered_set fishable_locations = g->get_fishable_locations_bub( 60, pos ); std::vector fishables = g->get_fishable_monsters( fishable_locations ); map &here = get_map(); // isolated little body of water with no definite fish population @@ -1785,7 +1785,7 @@ std::optional iuse::fishing_rod( Character *p, item *it, const tripoint_bub p->add_msg_if_player( _( "You cast your line and wait to hook something…" ) ); p->assign_activity( ACT_FISH, to_moves( 5_hours ), 0, 0, it->tname() ); p->activity.targets.emplace_back( *p, it ); - p->activity.coord_set = g->get_fishable_locations( 60, found->raw() ); + p->activity.coord_set = g->get_fishable_locations( 60, *found ); return 0; } @@ -1884,7 +1884,7 @@ std::optional iuse::fish_trap_tick( Character *p, item *it, const tripoint_ } //get the fishables around the trap's spot - std::unordered_set fishable_locations = g->get_fishable_locations( 60, pos.raw() ); + std::unordered_set fishable_locations = g->get_fishable_locations_bub( 60, pos ); std::vector fishables = g->get_fishable_monsters( fishable_locations ); for( int i = 0; i < fishes; i++ ) { player.practice( skill_survival, rng( 3, 10 ) ); @@ -1893,7 +1893,7 @@ std::optional iuse::fish_trap_tick( Character *p, item *it, const tripoint_ // reduce the abstract fish_population marker of that fish chosen_fish->fish_population -= 1; if( chosen_fish->fish_population <= 0 ) { - g->catch_a_monster( chosen_fish, pos.raw(), p, 300_hours ); //catch the fish! + g->catch_a_monster( chosen_fish, pos, p, 300_hours ); //catch the fish! } else { here.add_item_or_charges( pos, item::make_corpse( chosen_fish->type->id, calendar::turn + rng( 0_turns, @@ -7518,7 +7518,7 @@ static bool multicooker_hallu( Character &p ) case 6: if( !one_in( 5 ) ) { add_msg( m_warning, _( "The multi-cooker runs away!" ) ); - if( monster *const m = g->place_critter_around( mon_hallu_multicooker, p.pos(), 1 ) ) { + if( monster *const m = g->place_critter_around( mon_hallu_multicooker, p.pos_bub(), 1 ) ) { m->hallucination = true; m->add_effect( effect_run, 1_turns, true ); } @@ -8077,7 +8077,7 @@ bool item::release_monster( const tripoint_bub_ms &target, const int radius ) debugmsg( _( "Error restoring monster: %s" ), e.what() ); return false; } - if( !g->place_critter_around( new_monster, target.raw(), radius ) ) { + if( !g->place_critter_around( new_monster, target, radius ) ) { return false; } erase_var( "contained_name" ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 67b64fa01336c..6211c41996ab8 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -944,14 +944,14 @@ std::optional place_monster_iuse::use( Character *p, item &it, const tripoi newmon.init_from_item( it ); if( place_randomly ) { // place_critter_around returns the same pointer as its parameter (or null) - if( !g->place_critter_around( newmon_ptr, p->pos(), 1 ) ) { + if( !g->place_critter_around( newmon_ptr, p->pos_bub(), 1 ) ) { p->add_msg_if_player( m_info, _( "There is no adjacent square to release the %s in!" ), newmon.name() ); return std::nullopt; } } else { const std::string query = string_format( _( "Place the %s where?" ), newmon.name() ); - const std::optional pnt_ = choose_adjacent( query ); + const std::optional pnt_ = choose_adjacent_bub( query ); if( !pnt_ ) { return std::nullopt; } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 60194d6d18e15..57d3543dc4a17 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -1544,7 +1544,7 @@ void spell_effect::revive( const spell &sp, Creature &caster, const tripoint_bub !mt->has_flag( mon_flag_NO_NECRO ) ) ) { continue; } - if( g->revive_corpse( aoe.raw(), corpse ) ) { + if( g->revive_corpse( aoe, corpse ) ) { here.i_rem( aoe, &corpse ); break; } @@ -1567,7 +1567,7 @@ void spell_effect::revive_dormant( const spell &sp, Creature &caster, continue; } // relaxed revive with radius. - if( g->revive_corpse( aoe.raw(), corpse, 3 ) ) { + if( g->revive_corpse( aoe, corpse, 3 ) ) { here.i_rem( aoe, &corpse ); break; } @@ -1942,7 +1942,7 @@ void spell_effect::slime_split_on_death( const spell &sp, Creature &caster, shared_ptr_fast mon = make_shared_fast( slime_id ); mon->ammo = mon->type->starting_ammo; if( mon->will_move_to( dest.raw() ) && mon->know_danger_at( dest.raw() ) ) { - if( monster *const blob = g->place_critter_around( mon, dest.raw(), 0 ) ) { + if( monster *const blob = g->place_critter_around( mon, dest, 0 ) ) { sp.make_sound( dest, caster ); if( !permanent ) { blob->set_summon_time( sp.duration_turns( caster ) ); diff --git a/src/map.cpp b/src/map.cpp index 97a20b51092ab..5757b92dbdcf1 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4926,7 +4926,7 @@ bool map::open_door( Creature const &u, const tripoint_bub_ms &p, const bool ins if( u.has_trait( trait_SCHIZOPHRENIC ) && u.is_avatar() && one_in( 50 ) && !ter.has_flag( ter_furn_flag::TFLAG_TRANSPARENT ) ) { tripoint_bub_ms mp = p + point_rel_ms( -2 * u.pos_bub().xy().raw() ) + tripoint_rel_ms{ 2 * p.x(), 2 * p.y(), p.z() }; - g->spawn_hallucination( mp.raw() ); + g->spawn_hallucination( mp ); } } diff --git a/src/map.h b/src/map.h index 24de5e19ecf88..5d99f67e39dc0 100644 --- a/src/map.h +++ b/src/map.h @@ -773,15 +773,9 @@ class map * @param settings Structure describing pathfinding parameters. * @param pre_closed Never path through those points. They can still be the source or the destination. */ - // TODO: fix point types (remove the first overload) - std::vector route( const tripoint &f, const tripoint &t, - const pathfinding_settings &settings, - const std::function &avoid = []( const tripoint & ) { - return false; - } ) const; std::vector route( const tripoint_bub_ms &f, const tripoint_bub_ms &t, const pathfinding_settings &settings, - const std::function &avoid = []( const tripoint & ) { + const std::function &avoid = []( const tripoint_bub_ms & ) { return false; } ) const; diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 7e6421c1294e4..56f1434d20381 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -1177,7 +1177,7 @@ bool gun_actor::call( monster &z ) const bool gun_actor::try_target( monster &z, Creature &target ) const { - if( require_sunlight && !g->is_in_sunlight( z.pos() ) ) { + if( require_sunlight && !g->is_in_sunlight( z.pos_bub() ) ) { add_msg_debug( debugmode::DF_MATTACK, "Requires sunlight" ); if( one_in( 3 ) ) { add_msg_if_player_sees( z, failure_msg.translated(), z.name() ); diff --git a/src/medical_ui.cpp b/src/medical_ui.cpp index dbb1312d05626..76fdc7d8b3985 100644 --- a/src/medical_ui.cpp +++ b/src/medical_ui.cpp @@ -537,15 +537,15 @@ static medical_column draw_effects_summary( const int column_count, Character &y effects_column.add_column_line( selection_line( starvation_name, starvation_text, max_width ) ); } - if( you.has_trait( trait_TROGLO3 ) && g->is_in_sunlight( you.pos() ) ) { + if( you.has_trait( trait_TROGLO3 ) && g->is_in_sunlight( you.pos_bub() ) ) { effects_column.add_column_line( selection_line( "In Sunlight", "The sunlight irritates you terribly.\n", max_width ) ); - } else if( you.has_trait( trait_TROGLO2 ) && g->is_in_sunlight( you.pos() ) && + } else if( you.has_trait( trait_TROGLO2 ) && g->is_in_sunlight( you.pos_bub() ) && incident_sun_irradiance( get_weather().weather_id, calendar::turn ) > irradiance::low ) { effects_column.add_column_line( selection_line( "In Sunlight", "The sunlight irritates you badly.\n", max_width ) ); } else if( ( you.has_trait( trait_TROGLO ) || you.has_trait( trait_TROGLO2 ) ) && - g->is_in_sunlight( you.pos() ) && + g->is_in_sunlight( you.pos_bub() ) && incident_sun_irradiance( get_weather().weather_id, calendar::turn ) > irradiance::moderate ) { effects_column.add_column_line( selection_line( "In Sunlight", "The sunlight irritates you.\n", max_width ) ); @@ -626,7 +626,7 @@ static medical_column draw_stats_summary( const int column_count, Character &you "Starving" : "Underfed" ); speed_detail_str += colorize( string_format( _( "%s -%2d%%\n" ), pge_str, pen ), c_red ); } - if( you.has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( you.pos() ) ) { + if( you.has_trait( trait_SUNLIGHT_DEPENDENT ) && !g->is_in_sunlight( you.pos_bub() ) ) { pen = ( g->light_level( you.posz() ) >= 12 ? 5 : 10 ); pge_str = pgettext( "speed penalty", "Out of Sunlight " ); speed_detail_str += colorize( string_format( _( "%s -%2d%%\n" ), pge_str, pen ), c_red ); diff --git a/src/melee.cpp b/src/melee.cpp index c777e8f3acde5..bbc7d22bfcf02 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1808,7 +1808,7 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, new_.y = b.y; } - const tripoint &dest = tripoint( new_, b.z ); + const tripoint_bub_ms &dest{ new_.x, new_.y, b.z }; if( g->is_empty( dest ) ) { t.setpos( dest ); } @@ -1838,7 +1838,7 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, // Check if it's possible to move to the new tile bool move_issue = - g->is_dangerous_tile( prev_pos.raw() ) || // Tile contains fire, etc + g->is_dangerous_tile( prev_pos ) || // Tile contains fire, etc ( to_swimmable && to_deepwater ) || // Dive into deep water is_mounted() || ( veh0 != nullptr && std::abs( veh0->velocity ) > 100 ) || // Diving from moving vehicle diff --git a/src/monattack.cpp b/src/monattack.cpp index df5994af5323c..9f2a69d005aad 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -365,7 +365,7 @@ bool mattack::split( monster *z ) { bool split_performed = false; while( z->get_hp() / 2 > z->type->hp ) { - monster *const spawn = g->place_critter_around( z->type->id, z->pos(), 1 ); + monster *const spawn = g->place_critter_around( z->type->id, z->pos_bub(), 1 ); if( !spawn ) { break; } @@ -1088,7 +1088,7 @@ bool mattack::resurrect( monster *z ) Character &player_character = get_player_character(); bool sees_necromancer = player_character.sees( *z ); - std::vector> corpses; + std::vector> corpses; // Find all corpses that we can see within 10 tiles. int range = 10; bool found_eligible_corpse = false; @@ -1178,7 +1178,7 @@ bool mattack::resurrect( monster *z ) return false; } - std::pair raised = random_entry( corpses ); + std::pair raised = random_entry( corpses ); // To appease static analysis cata_assert( raised.second ); // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) @@ -1460,7 +1460,7 @@ bool mattack::grow_vine( monster *z ) z->mod_moves( -to_moves( 1_seconds ) ); // Attempt to fill up to 8 surrounding tiles. for( int i = 0; i < rng( 1, 8 ); ++i ) { - if( monster *const vine = g->place_critter_around( mon_creeper_vine, z->pos(), 1 ) ) { + if( monster *const vine = g->place_critter_around( mon_creeper_vine, z->pos_bub(), 1 ) ) { vine->make_ally( *z ); // Store position of parent hub in vine goal point. vine->set_dest( z->get_location() ); @@ -1525,7 +1525,7 @@ bool mattack::vine( monster *z ) !one_in( dist_from_hub ) ) { return true; } - if( monster *const vine = g->place_critter_around( mon_creeper_vine, z->pos(), 1 ) ) { + if( monster *const vine = g->place_critter_around( mon_creeper_vine, z->pos_bub(), 1 ) ) { vine->make_ally( *z ); vine->reset_special( "VINE" ); // Store position of parent hub in vine goal point. @@ -1593,12 +1593,12 @@ bool mattack::triffid_heartbeat( monster *z ) int tries = 0; while( here.route( player_character.pos_bub(), z->pos_bub(), root_pathfind ).empty() && tries < 20 ) { - point p( rng( player_character.posx(), z->posx() - 3 ), - rng( player_character.posy(), z->posy() - 3 ) ); - tripoint dest( p, z->posz() ); + point_bub_ms p( rng( player_character.posx(), z->posx() - 3 ), + rng( player_character.posy(), z->posy() - 3 ) ); + tripoint_bub_ms dest( p, z->posz() ); tries++; here.ter_set( dest, ter_t_dirt ); - if( rl_dist( dest, player_character.pos() ) > 3 && g->num_creatures() < 30 && + if( rl_dist( dest, player_character.pos_bub() ) > 3 && g->num_creatures() < 30 && !creatures.creature_at( dest ) && one_in( 20 ) ) { // Spawn an extra monster mtype_id montype = mon_triffid; if( one_in( 4 ) ) { @@ -1616,7 +1616,7 @@ bool mattack::triffid_heartbeat( monster *z ) // Spawn a monster in (about) every second surrounding tile. for( int i = 0; i < 4; ++i ) { - if( monster *const triffid = g->place_critter_around( mon_triffid, z->pos(), 1 ) ) { + if( monster *const triffid = g->place_critter_around( mon_triffid, z->pos_bub(), 1 ) ) { triffid->make_ally( *z ); } } @@ -1986,8 +1986,8 @@ bool mattack::fungus_fortify( monster *z ) // Oops, can't reach. ): // How's about we spawn more tendrils? :) // Aimed at the player, too? Sure! - const tripoint hit_pos = target->pos() + point( rng( -1, 1 ), rng( -1, 1 ) ); - if( hit_pos == target->pos() && !target->uncanny_dodge() ) { + const tripoint_bub_ms hit_pos = target->pos_bub() + point( rng( -1, 1 ), rng( -1, 1 ) ); + if( hit_pos == target->pos_bub() && !target->uncanny_dodge() ) { const bodypart_id &hit = body_part_hit_by_plant(); //~ %s is bodypart name in accusative. add_msg( m_bad, _( "A fungal tendril bursts forth from the earth and pierces your %s!" ), @@ -2141,18 +2141,18 @@ bool mattack::formblob( monster *z ) } bool didit = false; - std::vector pts = closest_points_first( z->pos(), 1 ); + std::vector pts = closest_points_first( z->pos_bub(), 1 ); // Don't check own tile pts.erase( pts.begin() ); creature_tracker &creatures = get_creature_tracker(); - for( const tripoint &dest : pts ) { + for( const tripoint_bub_ms &dest : pts ) { Creature *critter = creatures.creature_at( dest ); if( critter == nullptr ) { if( z->get_speed_base() > mon_blob_small->speed + 35 && rng( 0, 250 ) < z->get_speed_base() ) { // If we're big enough, spawn a baby blob. shared_ptr_fast mon = make_shared_fast( mon_blob_small ); mon->ammo = mon->type->starting_ammo; - if( mon->will_move_to( dest ) && mon->know_danger_at( dest ) ) { + if( mon->will_move_to( dest.raw() ) && mon->know_danger_at( dest.raw() ) ) { didit = true; z->set_speed_base( z->get_speed_base() - mon_blob_small->speed ); if( monster *const blob = g->place_critter_around( mon, dest, 0 ) ) { @@ -3213,7 +3213,7 @@ bool mattack::breathe( monster *z ) return true; } - if( monster *const spawned = g->place_critter_around( breather_type, z->pos(), 1 ) ) { + if( monster *const spawned = g->place_critter_around( breather_type, z->pos_bub(), 1 ) ) { spawned->reset_special( "BREATHE" ); spawned->make_ally( *z ); } @@ -3505,7 +3505,7 @@ bool mattack::darkman( monster *z ) if( rl_dist( z->pos(), player_character.pos() ) > 40 ) { return false; } - if( monster *const shadow = g->place_critter_around( mon_shadow, z->pos(), 1 ) ) { + if( monster *const shadow = g->place_critter_around( mon_shadow, z->pos_bub(), 1 ) ) { z->mod_moves( -to_moves( 1_seconds ) * 0.1 ); shadow->make_ally( *z ); add_msg_if_player_sees( *z, m_warning, _( "A shadow splits from the %s!" ), z->name() ); @@ -3826,7 +3826,7 @@ bool mattack::evolve_kill_strike( monster *z ) z->name() ); return true; } - tripoint const target_pos = target->pos(); + tripoint_bub_ms const target_pos = target->pos_bub(); const std::string target_name = target->disp_name(); int damage_dealt = target->deal_damage( z, bodypart_id( "torso" ), damage ).total_damage(); @@ -3882,7 +3882,7 @@ bool mattack::leech_spawner( monster *z ) const int monsters_spawned = rng( 1, 4 ); const mtype_id monster_type = one_in( 3 ) ? mon_leech_root_runner : mon_leech_root_drone; for( int i = 0; i < monsters_spawned; i++ ) { - if( monster *const new_mon = g->place_critter_around( monster_type, z->pos(), 1 ) ) { + if( monster *const new_mon = g->place_critter_around( monster_type, z->pos_bub(), 1 ) ) { if( u_see ) { add_msg( m_warning, _( "An egg pod ruptures and a %s crawls out from the remains!" ), new_mon->name() ); @@ -3926,7 +3926,8 @@ bool mattack::tindalos_teleport( monster *z ) return false; } if( one_in( 7 ) ) { - if( monster *const afterimage = g->place_critter_around( mon_hound_tindalos_afterimage, z->pos(), + if( monster *const afterimage = g->place_critter_around( mon_hound_tindalos_afterimage, + z->pos_bub(), 1 ) ) { z->mod_moves( -to_moves( 1_seconds ) * 1.4 ); afterimage->make_ally( *z ); @@ -3983,7 +3984,7 @@ bool mattack::flesh_tendril( monster *z ) if( one_in( 2 ) ) { spawned = mon_zombie_gasbag_impaler; } - if( monster *const summoned = g->place_critter_around( spawned, z->pos(), 1 ) ) { + if( monster *const summoned = g->place_critter_around( spawned, z->pos_bub(), 1 ) ) { z->mod_moves( -to_moves( 1_seconds ) ); summoned->make_ally( *z ); get_map().propagate_field( z->pos_bub(), fd_gibs_flesh, 75, 1 ); @@ -4535,7 +4536,7 @@ static int grenade_helper( monster *const z, Creature *const target, const int d return -1; } - const tripoint where = empty_neighbors.first[get_random_index( empty_neighbor_count )]; + const tripoint_bub_ms where{ empty_neighbors.first[get_random_index( empty_neighbor_count )] }; if( monster *const hack = g->place_critter_at( actor->mtypeid, where ) ) { hack->make_ally( *z ); diff --git a/src/monmove.cpp b/src/monmove.cpp index f8c50e90a1cdc..b5f58a05b36ec 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -168,7 +168,7 @@ bool monster::will_move_to( const tripoint &p ) const return false; } - if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( p ) ) { + if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( tripoint_bub_ms( p ) ) ) { return false; } @@ -1019,21 +1019,21 @@ void monster::move() } if( !is_wandering() || move_without_target ) { - while( !path.empty() && path.front() == pos() ) { + while( !path.empty() && path.front() == pos_bub() ) { path.erase( path.begin() ); } const pathfinding_settings &pf_settings = get_pathfinding_settings(); if( pf_settings.max_dist >= rl_dist( get_location(), get_dest() ) && - ( path.empty() || rl_dist( pos(), path.front() ) >= 2 || path.back() != local_dest.raw() ) ) { + ( path.empty() || rl_dist( pos_bub(), path.front() ) >= 2 || path.back() != local_dest ) ) { // We need a new path if( can_pathfind() ) { - path = here.route( pos(), local_dest.raw(), pf_settings, get_path_avoid() ); + path = here.route( pos_bub(), local_dest, pf_settings, get_path_avoid() ); if( path.empty() ) { increment_pathfinding_cd(); } } else { - path = here.straight_route( pos(), local_dest.raw() ); + path = here.straight_route( pos_bub(), local_dest ); if( !path.empty() ) { if( std::any_of( path.begin(), path.end(), get_path_avoid() ) ) { path.clear(); @@ -1046,8 +1046,8 @@ void monster::move() } // Try to respect old paths, even if we can't pathfind at the moment - if( !path.empty() && path.back() == local_dest.raw() ) { - destination = tripoint_bub_ms( path.front() ); + if( !path.empty() && path.back() == local_dest ) { + destination = path.front(); moved = true; pathed = true; } else { @@ -2326,7 +2326,8 @@ bool monster::will_reach( const point &p ) return false; } - auto path = get_map().route( pos(), tripoint( p, posz() ), get_pathfinding_settings() ); + const std::vector path = get_map().route( pos_bub(), tripoint_bub_ms( p.x, p.y, + posz() ), get_pathfinding_settings() ); if( path.empty() ) { return false; } @@ -2352,22 +2353,23 @@ int monster::turns_to_reach( const point &p ) { map &here = get_map(); // HACK: This function is a(n old) temporary hack that should soon be removed - auto path = here.route( pos(), tripoint( p, posz() ), get_pathfinding_settings() ); + const std::vector path = here.route( pos_bub(), tripoint_bub_ms( p.x, p.y, + posz() ), get_pathfinding_settings() ); if( path.empty() ) { return 999; } double turns = 0.; for( size_t i = 0; i < path.size(); i++ ) { - const tripoint &next = path[i]; + const tripoint_bub_ms &next = path[i]; if( here.impassable( next ) ) { // No bashing through, it looks stupid when you go back and find // the doors intact. return 999; } else if( i == 0 ) { - turns += static_cast( calc_movecost( pos(), next ) ) / get_speed(); + turns += static_cast( calc_movecost( pos(), next.raw() ) ) / get_speed(); } else { - turns += static_cast( calc_movecost( path[i - 1], next ) ) / get_speed(); + turns += static_cast( calc_movecost( path[i - 1].raw(), next.raw() ) ) / get_speed(); } } diff --git a/src/monster.cpp b/src/monster.cpp index cdc9bb9d8ad92..39b0a90f04ca5 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -513,8 +513,8 @@ void monster::try_upgrade( bool pin_time ) continue; } for( int i = 0; i < mgr.pack_size; i++ ) { - tripoint spawn_pos; - if( g->find_nearby_spawn_point( pos(), mgr.name, 1, *type->upgrade_multi_range, + tripoint_bub_ms spawn_pos; + if( g->find_nearby_spawn_point( pos_bub(), mgr.name, 1, *type->upgrade_multi_range, spawn_pos, false, false ) ) { monster *spawned = g->place_critter_at( mgr.name, spawn_pos ); if( spawned ) { @@ -3412,7 +3412,7 @@ void monster::process_effects() add_msg_if_player_sees( *this, m_warning, healing_format_string, name() ); } - if( type->regenerates_in_dark && !g->is_in_sunlight( pos() ) ) { + if( type->regenerates_in_dark && !g->is_in_sunlight( pos_bub() ) ) { const float light = get_map().ambient_light_at( pos_bub() ); // Magic number 10000 was chosen so that a floodlight prevents regeneration in a range of 20 tiles const float dHP = 50.0 * std::exp( - light * light / 10000 ); @@ -3490,7 +3490,7 @@ void monster::process_effects() } // If this critter dies in sunlight, check & assess damage. - if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( pos() ) ) { + if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( pos_bub() ) ) { add_msg_if_player_sees( *this, m_good, _( "The %s burns horribly in the sunlight!" ), name() ); apply_damage( nullptr, bodypart_id( "torso" ), 100 ); if( hp < 0 ) { @@ -4071,9 +4071,9 @@ const pathfinding_settings &monster::get_pathfinding_settings() const return type->path_settings; } -std::function monster::get_path_avoid() const +std::function monster::get_path_avoid() const { - return [this]( const tripoint & p ) { + return [this]( const tripoint_bub_ms & p ) { map &here = get_map(); // If we can't move there and can't bash it, don't path through it. if( !can_move_to( p ) && ( bash_skill() <= 0 || !here.is_bashable( p ) ) ) { @@ -4089,7 +4089,7 @@ std::function monster::get_path_avoid() const } else { return false; } - if( rl_dist( p, pos() ) <= radius && get_creature_tracker().creature_at( p ) ) { + if( rl_dist( p, pos_bub() ) <= radius && get_creature_tracker().creature_at( p ) ) { return true; } return false; diff --git a/src/monster.h b/src/monster.h index 29ec1e619e036..38e239baf959e 100644 --- a/src/monster.h +++ b/src/monster.h @@ -620,7 +620,7 @@ class monster : public Creature void on_load(); const pathfinding_settings &get_pathfinding_settings() const override; - std::function get_path_avoid() const override; + std::function get_path_avoid() const override; double calculate_by_enchantment( double modify, enchant_vals::mod value, bool round_output = false ) const; private: @@ -643,7 +643,7 @@ class monster : public Creature time_point stomach_timer; monster_horde_attraction horde_attraction = MHA_NULL; /** Found path. Note: Not used by monsters that don't pathfind! **/ - std::vector path; + std::vector path; // Exponential backoff for stuck monsters. Massively reduces pathfinding CPU. time_point pathfinding_cd = calendar::turn; diff --git a/src/mutation.cpp b/src/mutation.cpp index b666a83d95d8d..abf819a605d5b 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -869,7 +869,7 @@ void Character::activate_mutation( const trait_id &mut ) invoke_item( &burrowing_item ); return; // handled when the activity finishes } else if( mut == trait_SLIMESPAWNER ) { - monster *const slime = g->place_critter_around( mon_player_blob, pos(), 1 ); + monster *const slime = g->place_critter_around( mon_player_blob, pos_bub(), 1 ); if( !slime ) { // Oops, no room to divide! add_msg_if_player( m_bad, _( "You focus, but are too hemmed in to birth a new slime microbian!" ) ); diff --git a/src/npc.cpp b/src/npc.cpp index 74751a2c6df8b..e3b46f998e38e 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1170,11 +1170,11 @@ void npc::spawn_at_precise( const tripoint_abs_ms &p ) void npc::place_on_map() { - if( g->is_empty( pos() ) || is_mounted() ) { + if( g->is_empty( pos_bub() ) || is_mounted() ) { return; } - for( const tripoint &p : closest_points_first( pos(), SEEX + 1 ) ) { + for( const tripoint_bub_ms &p : closest_points_first( pos_bub(), SEEX + 1 ) ) { if( g->is_empty( p ) ) { setpos( p ); return; @@ -3470,9 +3470,9 @@ const pathfinding_settings &npc::get_pathfinding_settings( bool no_bashing ) con return *path_settings; } -std::function npc::get_path_avoid() const +std::function npc::get_path_avoid() const { - return [this]( const tripoint & p ) { + return [this]( const tripoint_bub_ms & p ) { if( get_creature_tracker().creature_at( p ) ) { return true; } diff --git a/src/npc.h b/src/npc.h index ebd75381a8355..59466cfdc7f87 100644 --- a/src/npc.h +++ b/src/npc.h @@ -1198,7 +1198,7 @@ class npc : public Character const pathfinding_settings &get_pathfinding_settings() const override; const pathfinding_settings &get_pathfinding_settings( bool no_bashing ) const; - std::function get_path_avoid() const override; + std::function get_path_avoid() const override; // Item discovery and fetching diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 6f4975bae48cf..f36ed9f6354b4 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -2868,7 +2868,7 @@ bool npc::can_move_to( const tripoint_bub_ms &p, bool no_bashing ) const // Allow moving into any bashable spots, but penalize them during pathing // Doors are not passable for hallucinations return( rl_dist( pos_bub(), p ) <= 1 && here.has_floor_or_water( p ) && - !g->is_dangerous_tile( p.raw() ) && + !g->is_dangerous_tile( p ) && ( here.passable( p ) || ( can_open_door( p, !here.is_outside( pos_bub() ) ) && !is_hallucination() ) || ( !no_bashing && here.bash_rating( smash_ability(), p ) > 0 ) ) @@ -3347,7 +3347,7 @@ void npc::worker_downtime() tripoint_abs_ms( temp_camp->get_bb_pos() ) ), 10 ) ) { if( creatures.creature_at( elem ) || !could_move_onto( elem ) || here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, elem ) || - !here.has_floor_or_water( elem ) || g->is_dangerous_tile( elem.raw() ) ) { + !here.has_floor_or_water( elem ) || g->is_dangerous_tile( elem ) ) { continue; } pts.push_back( elem ); @@ -3551,7 +3551,7 @@ void npc::find_item() for( const tripoint_bub_ms &p : closest_points_first( pos_bub(), range ) ) { // TODO: Make this sight check not overdraw nearby tiles // TODO: Optimize that zone check - if( is_player_ally() && g->check_zone( zone_type_NO_NPC_PICKUP, p.raw() ) ) { + if( is_player_ally() && g->check_zone( zone_type_NO_NPC_PICKUP, p ) ) { add_msg_debug( debugmode::DF_NPC_ITEMAI, "%s didn't pick up an item because it's in a no-pickup zone.", name ); continue; @@ -3667,7 +3667,7 @@ void npc::pick_up_item() if( ( !here.has_items( wanted_item_pos ) && !has_cargo && !here.is_harvestable( wanted_item_pos ) && sees( wanted_item_pos ) ) || - ( is_player_ally() && g->check_zone( zone_type_NO_NPC_PICKUP, wanted_item_pos.raw() ) ) ) { + ( is_player_ally() && g->check_zone( zone_type_NO_NPC_PICKUP, wanted_item_pos ) ) ) { // Items we wanted no longer exist and we can see it // Or player who is leading us doesn't want us to pick it up fetching_item = false; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 996110d74e0c8..9d6a4111db121 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -6698,7 +6698,7 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view int visible_spawns = 0; int spawns = 0; for( int i = 0; i < hallucination_count; i++ ) { - tripoint spawn_point; + tripoint_bub_ms spawn_point; if( !use_target_monster ) { if( group ) { target_monster = monster( MonsterGroupManager::GetRandomMonsterFromGroup( target_mongroup ) ); @@ -6707,7 +6707,7 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view target_monster = *copy->as_monster(); } } - if( g->find_nearby_spawn_point( target_pos.raw(), target_monster.type->id, min_radius, + if( g->find_nearby_spawn_point( target_pos, target_monster.type->id, min_radius, max_radius, spawn_point, outdoor_only, indoor_only, open_air_allowed ) ) { lifespan = dov_lifespan.evaluate( d ); if( lifespan.value() == 0_seconds ) { @@ -6728,7 +6728,7 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view } } for( int i = 0; i < real_count; i++ ) { - tripoint spawn_point; + tripoint_bub_ms spawn_point; if( !use_target_monster ) { if( group ) { target_monster = monster( MonsterGroupManager::GetRandomMonsterFromGroup( target_mongroup ) ); @@ -6737,7 +6737,7 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view target_monster = *copy->as_monster(); } } - if( g->find_nearby_spawn_point( target_pos.raw(), target_monster.type->id, min_radius, + if( g->find_nearby_spawn_point( target_pos, target_monster.type->id, min_radius, max_radius, spawn_point, outdoor_only, indoor_only, open_air_allowed ) ) { monster *spawned = g->place_critter_at( target_monster.type->id, spawn_point ); if( spawned ) { @@ -6833,8 +6833,8 @@ talk_effect_fun_t::func f_spawn_npc( const JsonObject &jo, std::string_view memb int visible_spawns = 0; int spawns = 0; for( int i = 0; i < real_count; i++ ) { - tripoint spawn_point; - if( g->find_nearby_spawn_point( target_pos.raw(), min_radius, + tripoint_bub_ms spawn_point; + if( g->find_nearby_spawn_point( target_pos, min_radius, max_radius, spawn_point, outdoor_only, indoor_only, open_air_allowed ) ) { lifespan = dov_lifespan.evaluate( d ); if( lifespan.value() == 0_seconds ) { @@ -6853,8 +6853,8 @@ talk_effect_fun_t::func f_spawn_npc( const JsonObject &jo, std::string_view memb } cur_traits.emplace_back( trait_HALLUCINATION ); for( int i = 0; i < hallucination_count; i++ ) { - tripoint spawn_point; - if( g->find_nearby_spawn_point( target_pos.raw(), min_radius, + tripoint_bub_ms spawn_point; + if( g->find_nearby_spawn_point( target_pos, min_radius, max_radius, spawn_point, outdoor_only, indoor_only, open_air_allowed ) ) { lifespan = dov_lifespan.evaluate( d ); if( lifespan.value() == 0_seconds ) { diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index cba63c99aaff3..91c6c57e4d38e 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -231,7 +231,7 @@ void talk_function::buy_cow( npc &p ) void spawn_animal( npc &p, const mtype_id &mon ) { - if( monster *const mon_ptr = g->place_critter_around( mon, p.pos(), 1 ) ) { + if( monster *const mon_ptr = g->place_critter_around( mon, p.pos_bub(), 1 ) ) { mon_ptr->friendly = -1; mon_ptr->add_effect( effect_pet, 1_turns, true ); } else { diff --git a/src/overmapbuffer.cpp b/src/overmapbuffer.cpp index 5a086ba57bf6a..d2afdd5956743 100644 --- a/src/overmapbuffer.cpp +++ b/src/overmapbuffer.cpp @@ -1600,7 +1600,7 @@ void overmapbuffer::spawn_monster( const tripoint_abs_sm &p, bool spawn_nonlocal cata_assert( here.inbounds( local ) ); } monster *const placed = g->place_critter_around( make_shared_fast( this_monster ), - local.raw(), 0, true ); + local, 0, true ); if( placed ) { placed->on_load(); } diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index 207d7368a94a6..3590be598a915 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -390,27 +390,27 @@ int map::extra_cost( const tripoint_bub_ms &cur, const tripoint_bub_ms &p, return pass_cost + avoid_cost; } -std::vector map::route( const tripoint &f, const tripoint &t, - const pathfinding_settings &settings, - const std::function &avoid ) const +std::vector map::route( const tripoint_bub_ms &f, const tripoint_bub_ms &t, + const pathfinding_settings &settings, + const std::function &avoid ) const { /* TODO: If the origin or destination is out of bound, figure out the closest * in-bounds point and go to that, then to the real origin/destination. */ - std::vector ret; + std::vector ret; if( f == t || !inbounds( f ) ) { return ret; } if( !inbounds( t ) ) { - tripoint clipped = t; + tripoint_bub_ms clipped = t; clip_to_bounds( clipped ); return route( f, clipped, settings, avoid ); } // First, check for a simple straight line on flat ground // Except when the line contains a pre-closed tile - we need to do regular pathing then - if( f.z == t.z ) { + if( f.z() == t.z() ) { auto line_path = straight_route( f, t ); if( !line_path.empty() ) { if( std::none_of( line_path.begin(), line_path.end(), avoid ) ) { @@ -427,14 +427,16 @@ std::vector map::route( const tripoint &f, const tripoint &t, const int max_length = settings.max_length; const int pad = 16; // Should be much bigger - low value makes pathfinders dumb! - tripoint_bub_ms min( std::min( f.x, t.x ) - pad, std::min( f.y, t.y ) - pad, std::min( f.z, t.z ) ); - tripoint_bub_ms max( std::max( f.x, t.x ) + pad, std::max( f.y, t.y ) + pad, std::max( f.z, t.z ) ); + tripoint_bub_ms min( std::min( f.x(), t.x() ) - pad, std::min( f.y(), t.y() ) - pad, + std::min( f.z(), t.z() ) ); + tripoint_bub_ms max( std::max( f.x(), t.x() ) + pad, std::max( f.y(), t.y() ) + pad, + std::max( f.z(), t.z() ) ); clip_to_bounds( min.x(), min.y(), min.z() ); clip_to_bounds( max.x(), max.y(), max.z() ); pf.reset( min.z(), max.z() ); - pf.add_point( 0, 0, f, f ); + pf.add_point( 0, 0, f.raw(), f.raw() ); bool done = false; @@ -449,10 +451,10 @@ std::vector map::route( const tripoint &f, const tripoint &t, if( layer.gscore[parent_index] > max_length ) { // Shortest path would be too long, return empty vector - return std::vector(); + return std::vector(); } - if( cur.raw() == t ) { + if( cur == t ) { done = true; break; } @@ -465,8 +467,8 @@ std::vector map::route( const tripoint &f, const tripoint &t, // 7 3 5 // 1 . 2 // 6 4 8 - constexpr std::array x_offset{{ -1, 1, 0, 0, 1, -1, -1, 1 }}; - constexpr std::array y_offset{{ 0, 0, -1, 1, -1, 1, -1, 1 }}; + constexpr std::array x_offset{ { -1, 1, 0, 0, 1, -1, -1, 1 } }; + constexpr std::array y_offset{ { 0, 0, -1, 1, -1, 1, -1, 1 } }; for( size_t i = 0; i < 8; i++ ) { const tripoint_bub_ms p( cur.x() + x_offset[i], cur.y() + y_offset[i], cur.z() ); const int index = flat_index( p.xy().raw() ); @@ -476,7 +478,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, continue; } - if( p.raw() != t && avoid( p.raw() ) ) { + if( p != t && avoid( p ) ) { layer.closed[index] = true; continue; } @@ -515,7 +517,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, path_data_layer &layer = pf.get_layer( p.z() - 1 ); // From cur, not p, because we won't be walking on air pf.add_point( layer.gscore[parent_index] + 10, - layer.score[parent_index] + 10 + 2 * rl_dist( below.raw(), t ), + layer.score[parent_index] + 10 + 2 * rl_dist( below, t ), cur.raw(), below.raw() ); } @@ -526,7 +528,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, } } - pf.add_point( newg, newg + 2 * rl_dist( p.raw(), t ), cur.raw(), p.raw() ); + pf.add_point( newg, newg + 2 * rl_dist( p, t ), cur.raw(), p.raw() ); } // TODO: We should be able to go up ramps even if we can't climb stairs. @@ -541,8 +543,8 @@ std::vector map::route( const tripoint &f, const tripoint &t, const ter_t &parent_terrain = parent_tile.get_ter_t(); if( settings.allow_climb_stairs && cur.z() > min.z() && parent_terrain.has_flag( ter_furn_flag::TFLAG_GOES_DOWN ) ) { - std::optional opt_dest = g->find_or_make_stairs( get_map(), - cur.z() - 1, rope_ladder, false, cur.raw() ); + std::optional opt_dest = g->find_or_make_stairs( get_map(), + cur.z() - 1, rope_ladder, false, cur ); if( !opt_dest ) { continue; } @@ -553,14 +555,14 @@ std::vector map::route( const tripoint &f, const tripoint &t, } path_data_layer &layer = pf.get_layer( dest.z() ); pf.add_point( layer.gscore[parent_index] + 2, - layer.score[parent_index] + 2 * rl_dist( dest.raw(), t ), + layer.score[parent_index] + 2 * rl_dist( dest, t ), cur.raw(), dest.raw() ); } } if( settings.allow_climb_stairs && cur.z() < max.z() && parent_terrain.has_flag( ter_furn_flag::TFLAG_GOES_UP ) ) { - std::optional opt_dest = g->find_or_make_stairs( get_map(), - cur.z() + 1, rope_ladder, false, cur.raw() ); + std::optional opt_dest = g->find_or_make_stairs( get_map(), + cur.z() + 1, rope_ladder, false, cur ); if( !opt_dest ) { continue; } @@ -571,7 +573,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, } path_data_layer &layer = pf.get_layer( dest.z() ); pf.add_point( layer.gscore[parent_index] + 2, - layer.score[parent_index] + 2 * rl_dist( dest.raw(), t ), + layer.score[parent_index] + 2 * rl_dist( dest, t ), cur.raw(), dest.raw() ); } } @@ -584,7 +586,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, continue; } pf.add_point( layer.gscore[parent_index] + 4, - layer.score[parent_index] + 4 + 2 * rl_dist( above.raw(), t ), + layer.score[parent_index] + 4 + 2 * rl_dist( above, t ), cur.raw(), above.raw() ); } } @@ -597,7 +599,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, continue; } pf.add_point( layer.gscore[parent_index] + 4, - layer.score[parent_index] + 4 + 2 * rl_dist( above.raw(), t ), + layer.score[parent_index] + 4 + 2 * rl_dist( above, t ), cur.raw(), above.raw() ); } } @@ -610,7 +612,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, continue; } pf.add_point( layer.gscore[parent_index] + 4, - layer.score[parent_index] + 4 + 2 * rl_dist( below.raw(), t ), + layer.score[parent_index] + 4 + 2 * rl_dist( below, t ), cur.raw(), below.raw() ); } } @@ -619,12 +621,12 @@ std::vector map::route( const tripoint &f, const tripoint &t, if( done ) { ret.reserve( rl_dist( f, t ) * 2 ); - tripoint cur = t; + tripoint_bub_ms cur = t; // Just to limit max distance, in case something weird happens for( int fdist = max_length; fdist != 0; fdist-- ) { - const int cur_index = flat_index( cur.xy() ); - const path_data_layer &layer = pf.get_layer( cur.z ); - const tripoint &par = layer.parent[cur_index]; + const int cur_index = flat_index( cur.raw().xy() ); + const path_data_layer &layer = pf.get_layer( cur.z() ); + const tripoint_bub_ms &par = tripoint_bub_ms( layer.parent[cur_index] ); if( cur == f ) { break; } @@ -632,9 +634,9 @@ std::vector map::route( const tripoint &f, const tripoint &t, ret.push_back( cur ); // Jumps are acceptable on 1 z-level changes // This is because stairs teleport the player too - if( rl_dist( cur, par ) > 1 && std::abs( cur.z - par.z ) != 1 ) { + if( rl_dist( cur, par ) > 1 && std::abs( cur.z() - par.z() ) != 1 ) { debugmsg( "Jump in our route! %d:%d:%d->%d:%d:%d", - cur.x, cur.y, cur.z, par.x, par.y, par.z ); + cur.x(), cur.y(), cur.z(), par.x(), par.y(), par.z() ); return ret; } @@ -646,16 +648,3 @@ std::vector map::route( const tripoint &f, const tripoint &t, return ret; } - -std::vector map::route( const tripoint_bub_ms &f, const tripoint_bub_ms &t, - const pathfinding_settings &settings, - const std::function &avoid ) const -{ - std::vector raw_result = route( f.raw(), t.raw(), settings, avoid ); - std::vector result; - std::transform( raw_result.begin(), raw_result.end(), std::back_inserter( result ), - []( const tripoint & p ) { - return tripoint_bub_ms( p ); - } ); - return result; -} diff --git a/src/pickup.cpp b/src/pickup.cpp index b9d408110636c..ae3f579e970ab 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -422,7 +422,7 @@ void Pickup::autopickup( const tripoint &p ) } } // Bail out if this square cannot be auto-picked-up - if( g->check_zone( zone_type_NO_AUTO_PICKUP, p ) || + if( g->check_zone( zone_type_NO_AUTO_PICKUP, tripoint_bub_ms( p ) ) || local.has_flag( ter_furn_flag::TFLAG_SEALED, p ) ) { return; } diff --git a/src/player_display.cpp b/src/player_display.cpp index 9dd30454b559d..9e6dfd6e9b0c9 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -1585,12 +1585,12 @@ void Character::disp_info( bool customize_character ) effect_name_and_text.emplace_back( starvation_name, starvation_text ); } - if( has_trait( trait_TROGLO3 ) && g->is_in_sunlight( pos() ) ) { + if( has_trait( trait_TROGLO3 ) && g->is_in_sunlight( pos_bub() ) ) { effect_name_and_text.emplace_back( _( "In Sunlight" ), _( "The sunlight irritates you terribly.\n" "Strength - 4; Dexterity - 4; Intelligence - 4; Perception - 4" ) ); - } else if( has_trait( trait_TROGLO2 ) && g->is_in_sunlight( pos() ) ) { + } else if( has_trait( trait_TROGLO2 ) && g->is_in_sunlight( pos_bub() ) ) { if( incident_sun_irradiance( get_weather().weather_id, calendar::turn ) > irradiance::moderate ) { effect_name_and_text.emplace_back( _( "In Sunlight" ), _( "The sunlight irritates you badly.\n" @@ -1601,7 +1601,7 @@ void Character::disp_info( bool customize_character ) "Strength - 1; Dexterity - 1; Intelligence - 1; Perception - 1" ) ); } - } else if( has_trait( trait_TROGLO ) && g->is_in_sunlight( pos() ) && + } else if( has_trait( trait_TROGLO ) && g->is_in_sunlight( pos_bub() ) && incident_sun_irradiance( get_weather().weather_id, calendar::turn ) > irradiance::moderate ) { effect_name_and_text.emplace_back( _( "In Sunlight" ), _( "The sunlight irritates you.\n" diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index d8c3b240b63a4..a32e96e1703ba 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -452,7 +452,7 @@ static void eff_fun_hallu( Character &u, effect &it ) u.add_miss_reason( _( "Dancing fractals distract you." ), 2 ); u.mod_str_bonus( -1 ); if( u.is_avatar() && one_in( 50 ) ) { - g->spawn_hallucination( u.pos() + tripoint( rng( -10, 10 ), rng( -10, 10 ), 0 ) ); + g->spawn_hallucination( u.pos_bub() + tripoint( rng( -10, 10 ), rng( -10, 10 ), 0 ) ); } } else if( dur == comedownTime ) { if( one_in( 42 ) ) { diff --git a/src/sounds.cpp b/src/sounds.cpp index a7ad98780497c..6ed6ccd3478c0 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1153,7 +1153,7 @@ void sfx::do_ambient() const bool is_deaf = player_character.is_deaf(); const int heard_volume = get_heard_volume( player_character.pos() ); const bool is_underground = player_character.pos().z < 0; - const bool is_sheltered = g->is_sheltered( player_character.pos() ); + const bool is_sheltered = g->is_sheltered( player_character.pos_bub() ); const bool night = is_night( calendar::turn ); const bool weather_changed = get_weather().weather_id != previous_weather || diff --git a/src/suffer.cpp b/src/suffer.cpp index 30eeb61191be1..fee24ef96e6d8 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -684,7 +684,7 @@ void suffer::from_asthma( Character &you, const int current_stim ) void suffer::in_sunlight( Character &you ) { - const tripoint position = you.pos(); + const tripoint_bub_ms position = you.pos_bub(); if( !g->is_in_sunlight( position ) ) { return; @@ -701,7 +701,8 @@ void suffer::in_sunlight( Character &you ) const bool has_hat = you.wearing_something_on( bodypart_id( "head" ) ); 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 ) ); + const int player_local_temp = units::to_fahrenheit( get_weather().get_temperature( + position.raw() ) ); const int flux = ( player_local_temp - 65 ) / 2; if( !has_hat ) { sunlight_nutrition += ( 100 + flux ) * weather_factor; diff --git a/src/talker_avatar.cpp b/src/talker_avatar.cpp index 5ddcec5046821..4766f0769860d 100644 --- a/src/talker_avatar.cpp +++ b/src/talker_avatar.cpp @@ -77,7 +77,7 @@ bool talker_avatar::buy_monster( talker &seller, const mtype_id &mtype, int cost } for( int i = 0; i < count; i++ ) { - monster *const mon_ptr = g->place_critter_around( mtype, me_chr->pos(), 3 ); + monster *const mon_ptr = g->place_critter_around( mtype, me_chr->pos_bub(), 3 ); if( !mon_ptr ) { add_msg_debug( debugmode::DF_TALKER, "Cannot place u_buy_monster, no valid placement locations." ); break; diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 9aa8c6b3c5887..3f33ca50200e3 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -119,7 +119,7 @@ void timed_event::actualize() // 50% chance to spawn a dark wyrm near every orifice on the level. for( const tripoint_bub_ms &p : here.points_on_zlevel() ) { if( here.ter( p ) == ter_id( "t_orifice" ) ) { - g->place_critter_around( mon_dark_wyrm, p.raw(), 1 ); + g->place_critter_around( mon_dark_wyrm, p, 1 ); } } @@ -274,7 +274,7 @@ void timed_event::actualize() } }; const mtype_id &montype = random_entry( temple_monsters ); - g->place_critter_around( montype, player_character.pos(), 2 ); + g->place_critter_around( montype, player_character.pos_bub(), 2 ); } break; diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 6add116c5c118..7be1ecf0c62f2 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -1603,15 +1603,15 @@ bool trapfunc::shadow( const tripoint &p, Creature *c, item * ) map &here = get_map(); // Monsters and npcs are completely ignored here, should they? for( int tries = 0; tries < 10; tries++ ) { - tripoint monp = p; + 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, p, 10 ) ) { + if( !here.sees( monp, tripoint_bub_ms( p ), 10 ) ) { continue; } if( monster *const spawned = g->place_critter_at( mon_shadow, monp ) ) { @@ -1729,15 +1729,15 @@ bool trapfunc::snake( const tripoint &p, Creature *, item * ) } if( one_in( 3 ) ) { for( int tries = 0; tries < 10; tries++ ) { - tripoint monp = p; + 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, p, 10 ) ) { + if( !here.sees( monp, tripoint_bub_ms( p ), 10 ) ) { continue; } if( monster *const spawned = g->place_critter_at( mon_shadow_snake, monp ) ) { diff --git a/src/weather.cpp b/src/weather.cpp index 384ac6157d3d0..d67ca385c18c2 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -98,7 +98,7 @@ void glare( const weather_type_id &w ) { Character &player_character = get_player_character();//todo npcs, also //General prerequisites for glare - if( g->is_sheltered( player_character.pos() ) || + if( g->is_sheltered( player_character.pos_bub() ) || player_character.in_sleep_state() || player_character.worn_with_flag( json_flag_SUN_GLASSES ) || player_character.has_flag( json_flag_GLARE_RESIST ) || @@ -965,9 +965,9 @@ units::temperature weather_manager::get_temperature( const tripoint &location ) if( !g->new_game ) { units::temperature_delta temp_mod; - temp_mod = get_heat_radiation( location ); - temp_mod += get_convection_temperature( location ); - temp_mod += get_map().get_temperature_mod( location ); + 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 += temp_mod; } diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 06d7a8c73e4a5..7372b2a4e2fad 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -522,7 +522,7 @@ TEST_CASE( "fueled_bionics", "[bionics] [item]" ) g->reset_light_level(); scoped_weather_override weather_clear( WEATHER_CLEAR ); calendar::turn = calendar::turn_zero + 12_hours; - REQUIRE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); // Connect solar backpack dummy.worn.wear_item( dummy, item( "pants_cargo" ), false, false ); diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index 75ea99c443989..c777aaa74a2c0 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -63,7 +63,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision calendar::turn = calendar::turn_zero + 9_hours + 30_minutes; // Build map cache including lightmap here.build_map_cache( 0, false ); - REQUIRE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); // ambient_light_at is ~100.0 at this time of day (this fails if lightmap cache is not built) REQUIRE( here.ambient_light_at( dummy.pos_bub() ) == Approx( 100.0f ).margin( 1 ) ); @@ -90,7 +90,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision tripoint const z_shift = GENERATE( tripoint::above, tripoint::zero ); dummy.setpos( dummy.pos() + z_shift ); // This implicitly rebuilds the light map. CAPTURE( z_shift ); - REQUIRE_FALSE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE_FALSE( g->is_in_sunlight( dummy.pos_bub() ) ); REQUIRE( here.ambient_light_at( dummy.pos_bub() ) == Approx( LIGHT_AMBIENT_MINIMAL ) ); // 7.3 is LIGHT_AMBIENT_MINIMAL, a dark cloudy night, unlit indoors @@ -170,7 +170,7 @@ TEST_CASE( "character_sight_limits", "[character][sight][vision]" ) GIVEN( "it is midnight with a new moon" ) { calendar::turn = calendar::turn_zero; here.build_map_cache( 0, false ); - REQUIRE_FALSE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE_FALSE( g->is_in_sunlight( dummy.pos_bub() ) ); THEN( "sight limit is 60 tiles away" ) { dummy.recalc_sight_limits(); @@ -318,7 +318,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) calendar::turn = calendar::turn_zero + 9_hours + 30_minutes; here.build_map_cache( 0, false ); light_here = here.ambient_light_at( dummy.pos_bub() ); - REQUIRE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); REQUIRE( light_here == Approx( 100.0f ).margin( 1 ) ); THEN( "impaired sight, with 12 tiles of range" ) { diff --git a/tests/char_suffer_test.cpp b/tests/char_suffer_test.cpp index b0715991bd32b..489aa3a43586e 100644 --- a/tests/char_suffer_test.cpp +++ b/tests/char_suffer_test.cpp @@ -127,7 +127,7 @@ TEST_CASE( "suffering_from_albinism", "[char][suffer][albino]" ) item longshirt( "test_longshirt" ); GIVEN( "avatar is in sunlight with the albino trait" ) { - REQUIRE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); dummy.toggle_trait( trait_ALBINO ); REQUIRE( dummy.has_trait( trait_ALBINO ) ); @@ -225,7 +225,7 @@ TEST_CASE( "suffering_from_sunburn", "[char][suffer][sunburn]" ) item longshirt( "test_longshirt" ); GIVEN( "avatar is in sunlight with the solar sensitivity trait" ) { - REQUIRE( g->is_in_sunlight( dummy.pos() ) ); + REQUIRE( g->is_in_sunlight( dummy.pos_bub() ) ); dummy.toggle_trait( trait_SUNBURN ); REQUIRE( dummy.has_trait( trait_SUNBURN ) ); diff --git a/tests/effect_test.cpp b/tests/effect_test.cpp index 632f410dfa469..656fcc6b1ede2 100644 --- a/tests/effect_test.cpp +++ b/tests/effect_test.cpp @@ -742,7 +742,7 @@ static void test_deadliness( const effect &applied, const int expected_dead, con // Place a hundred debug monsters, our subjects for( int i = 0; i < 10; ++i ) { for( int j = 0; j < 10; ++j ) { - tripoint cursor( i + 20, j + 20, 0 ); + tripoint_bub_ms cursor( i + 20, j + 20, 0 ); mons.push_back( g->place_critter_at( pseudo_debug_mon, cursor ) ); // make sure they're there! diff --git a/tests/enchantments_test.cpp b/tests/enchantments_test.cpp index 4144f63df8e0b..2e74b1a2af9b9 100644 --- a/tests/enchantments_test.cpp +++ b/tests/enchantments_test.cpp @@ -233,7 +233,7 @@ TEST_CASE( "Enchantment_ATTACK_SPEED_test", "[magic][enchantments]" ) clear_map(); Character &guy = get_player_character(); clear_avatar(); - g->place_critter_at( pseudo_debug_mon, tripoint::south ); + g->place_critter_at( pseudo_debug_mon, tripoint_bub_ms( tripoint::south ) ); creature_tracker &creatures = get_creature_tracker(); Creature &mon = *creatures.creature_at( tripoint::south ); int moves_spent_on_attacks = 0; @@ -292,7 +292,7 @@ TEST_CASE( "Enchantment_MELEE_STAMINA_CONSUMPTION_test", "[magic][enchantments]" clear_map(); Character &guy = get_player_character(); clear_avatar(); - g->place_critter_at( pseudo_debug_mon, tripoint::south ); + g->place_critter_at( pseudo_debug_mon, tripoint_bub_ms( tripoint::south ) ); creature_tracker &creatures = get_creature_tracker(); Creature &mon = *creatures.creature_at( tripoint::south ); int stamina_init = 0; @@ -361,7 +361,7 @@ TEST_CASE( "Enchantment_MELEE_TO_HIT_test", "[magic][enchantments]" ) clear_map(); Character &guy = get_player_character(); clear_avatar(); - g->place_critter_at( pseudo_debug_mon, tripoint::south ); + g->place_critter_at( pseudo_debug_mon, tripoint_bub_ms( tripoint::south ) ); creature_tracker &creatures = get_creature_tracker(); Creature &mon = *creatures.creature_at( tripoint::south ); double hit_rate = 0; diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index 77897d49d912c..228f88a6f4fec 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -667,14 +667,14 @@ TEST_CASE( "EOC_monsters_nearby", "[eoc][math_parser]" ) global_variables &globvars = get_globals(); globvars.clear_global_values(); - g->place_critter_at( mon_zombie, a.pos() + tripoint::east ); - monster *friendo = g->place_critter_at( mon_zombie, a.pos() + tripoint{ 2, 0, 0 } ); - g->place_critter_at( mon_triffid, a.pos() + tripoint{ 3, 0, 0 } ); - g->place_critter_at( mon_zombie_tough, a.pos() + tripoint::north ); - g->place_critter_at( mon_zombie_tough, a.pos() + tripoint{ 0, 2, 0 } ); - g->place_critter_at( mon_zombie_tough, a.pos() + tripoint{ 0, 3, 0 } ); - g->place_critter_at( mon_zombie_smoker, a.pos() + tripoint{ 10, 0, 0 } ); - g->place_critter_at( mon_zombie_smoker, a.pos() + tripoint{ 11, 0, 0 } ); + g->place_critter_at( mon_zombie, a.pos_bub() + tripoint::east ); + monster *friendo = g->place_critter_at( mon_zombie, a.pos_bub() + tripoint{ 2, 0, 0 } ); + g->place_critter_at( mon_triffid, a.pos_bub() + tripoint{ 3, 0, 0 } ); + g->place_critter_at( mon_zombie_tough, a.pos_bub() + tripoint::north ); + g->place_critter_at( mon_zombie_tough, a.pos_bub() + tripoint{ 0, 2, 0 } ); + g->place_critter_at( mon_zombie_tough, a.pos_bub() + tripoint{ 0, 3, 0 } ); + g->place_critter_at( mon_zombie_smoker, a.pos_bub() + tripoint{ 10, 0, 0 } ); + g->place_critter_at( mon_zombie_smoker, a.pos_bub() + tripoint{ 11, 0, 0 } ); REQUIRE( globvars.get_global_value( "mons" ).empty() ); dialogue d( get_talker_for( get_avatar() ), std::make_unique() );