diff --git a/src/action.cpp b/src/action.cpp index e4abae23bd975..e7b81ebb4aa9c 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -770,7 +770,7 @@ action_id handle_action_menu() Character &player_character = get_player_character(); // Check if we're in a potential combat situation, if so, sort a few actions to the top. - if( !player_character.get_hostile_creatures( 60 ).empty() ) { + if( !player_character.get_hostile_creatures( MAX_VIEW_DISTANCE ).empty() ) { // Only prioritize movement options if we're not driving. if( !player_character.controlling_vehicle ) { action_weightings[ACTION_CYCLE_MOVE] = 400; diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 284f1d1ac9a01..1942e033e08b8 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -818,8 +818,8 @@ void hacking_activity_actor::finish( player_activity &act, Character &who ) // currently all things that can be hacked have equivalent alarm failure states. // this may not always be the case with new hackable things. get_event_bus().send( who.getID() ); - sounds::sound( who.pos(), 60, sounds::sound_t::music, _( "an alarm sound!" ), true, "environment", - "alarm" ); + sounds::sound( who.pos(), MAX_VIEW_DISTANCE, sounds::sound_t::music, _( "an alarm sound!" ), true, + "environment", "alarm" ); break; case hack_result::NOTHING: who.add_msg_if_player( _( "You fail the hack, but no alarms are triggered." ) ); diff --git a/src/basecamp.cpp b/src/basecamp.cpp index 46f9e55169b58..3baf72c0d6949 100644 --- a/src/basecamp.cpp +++ b/src/basecamp.cpp @@ -671,9 +671,9 @@ void basecamp::form_storage_zones( map &here, const tripoint_abs_ms &abspos ) } tripoint src_loc = here.getlocal( bb_pos ) + point_north; std::vector possible_liquid_dumps; - if( mgr.has_near( zone_type_CAMP_STORAGE, abspos, 60 ) ) { + if( mgr.has_near( zone_type_CAMP_STORAGE, abspos, MAX_VIEW_DISTANCE ) ) { const std::vector zones = mgr.get_near_zones( zone_type_CAMP_STORAGE, abspos, - 60 ); + MAX_VIEW_DISTANCE ); // Find the nearest unsorted zone to dump objects at if( !zones.empty() ) { if( zones != storage_zones ) { diff --git a/src/character.cpp b/src/character.cpp index f13d1dc5b5f6a..4bf7f3bec416b 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1261,7 +1261,7 @@ int Character::sight_range( float light_level ) const int Character::unimpaired_range() const { - return std::min( sight_max, 60 ); + return std::min( sight_max, MAX_VIEW_DISTANCE ); } bool Character::overmap_los( const tripoint_abs_omt &omt, int sight_points ) const diff --git a/src/clzones.cpp b/src/clzones.cpp index 41c0d446ee011..6fe6716756f5d 100644 --- a/src/clzones.cpp +++ b/src/clzones.cpp @@ -308,7 +308,7 @@ plot_options::query_seed_result plot_options::query_seed() zone_manager &mgr = zone_manager::get_manager(); map &here = get_map(); const std::unordered_set zone_src_set = - mgr.get_near( zone_type_LOOT_SEEDS, here.getglobal( player_character.pos() ), 60 ); + mgr.get_near( zone_type_LOOT_SEEDS, here.getglobal( player_character.pos() ), MAX_VIEW_DISTANCE ); for( const tripoint_abs_ms &elem : zone_src_set ) { tripoint elem_loc = here.getlocal( elem ); for( item &it : here.i_at( elem_loc ) ) { diff --git a/src/clzones.h b/src/clzones.h index 12c9ae05a4505..5a1b80a1a3203 100644 --- a/src/clzones.h +++ b/src/clzones.h @@ -35,7 +35,7 @@ inline const faction_id your_fac( "your_followers" ); const std::string type_fac_hash_str = "__FAC__"; //Generic activity: maximum search distance for zones, constructions, etc. -constexpr int ACTIVITY_SEARCH_DISTANCE = 60; +constexpr int ACTIVITY_SEARCH_DISTANCE = MAX_VIEW_DISTANCE; extern const std::vector ignorable_zone_types; diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index 7ba4af54041c3..7f593ac0e26bc 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -5290,8 +5290,8 @@ bool basecamp::validate_sort_points() zone_manager &mgr = zone_manager::get_manager(); map *here = &get_map(); const tripoint_abs_ms abspos = get_player_character().get_location(); - if( !mgr.has_near( zone_type_CAMP_STORAGE, abspos, 60 ) || - !mgr.has_near( zone_type_CAMP_FOOD, abspos, 60 ) ) { + if( !mgr.has_near( zone_type_CAMP_STORAGE, abspos, MAX_VIEW_DISTANCE ) || + !mgr.has_near( zone_type_CAMP_FOOD, abspos, MAX_VIEW_DISTANCE ) ) { if( query_yn( _( "You do not have sufficient sort zones. Do you want to add them?" ) ) ) { return set_sort_points(); } else { @@ -5687,7 +5687,7 @@ bool basecamp::distribute_food() } const tripoint_abs_ms &abspos = get_dumping_spot(); const std::unordered_set &z_food = - mgr.get_near( zone_type_CAMP_FOOD, abspos, 60 ); + mgr.get_near( zone_type_CAMP_FOOD, abspos, MAX_VIEW_DISTANCE ); double quick_rot = 0.6 + ( has_provides( "pantry" ) ? 0.1 : 0 ); double slow_rot = 0.8 + ( has_provides( "pantry" ) ? 0.05 : 0 ); diff --git a/src/game.cpp b/src/game.cpp index f9e6b47c1be1e..c60b097d3ab78 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -7023,7 +7023,7 @@ void game::zones_manager() } // get zones with distance between player and - // zone center point <= 60 or all zones, if show_all_zones is true + // zone center point <= ACTIVITY_SEARCH_DISTANCE or all zones, if show_all_zones is true auto get_zones = [&]() { std::vector zones; if( show_all_zones ) { @@ -7612,7 +7612,7 @@ std::optional> game::safe_route_to( Character &who, }; route_t shortest_route; std::unordered_set path_avoid; - for( const tripoint_bub_ms &p : points_in_radius( who.pos_bub(), 60 ) ) { + for( const tripoint_bub_ms &p : points_in_radius( who.pos_bub(), MAX_VIEW_DISTANCE ) ) { if( is_dangerous_tile( p.raw() ) ) { path_avoid.insert( p.raw() ); } @@ -8345,8 +8345,8 @@ void game::list_items_monsters() { // Search whole reality bubble because each function internally verifies // the visibility of the items / monsters in question. - std::vector mons = u.get_visible_creatures( 60 ); - const std::vector items = find_nearby_items( 60 ); + std::vector mons = u.get_visible_creatures( MAX_VIEW_DISTANCE ); + const std::vector items = find_nearby_items( MAX_VIEW_DISTANCE ); if( mons.empty() && items.empty() ) { add_msg( m_info, _( "You don't see any items or monsters around you!" ) ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 7cbbc591731b4..08c9ac3234d19 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -7052,7 +7052,7 @@ std::optional iuse::radiocaron( Character *p, item *it, const tripoint & ) static void sendRadioSignal( Character &p, const flag_id &signal ) { map &here = get_map(); - for( const tripoint &loc : here.points_in_radius( p.pos(), 60 ) ) { + for( const tripoint &loc : here.points_in_radius( p.pos(), MAX_VIEW_DISTANCE ) ) { for( item &it : here.i_at( loc ) ) { if( it.has_flag( flag_RADIO_ACTIVATION ) && it.has_flag( signal ) ) { sounds::sound( p.pos(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" ); diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 256ce42bb104a..2dff2a92ecedd 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -841,7 +841,7 @@ void castLight( cata::mdarray &output_cache, { constexpr quadrant quad = quadrant_from_x_y( -xx - xy, -yx - yy ); float newStart = 0.0f; - float radius = 60.0f - offsetDistance; + float radius = static_cast( MAX_VIEW_DISTANCE ) - offsetDistance; if( start < end ) { return; } @@ -1071,7 +1071,7 @@ void map::build_seen_cache( const tripoint &origin, const int target_z, int exte if( !is_camera ) { offsetDistance = penalty + rl_dist( origin, mirror_pos ); } else { - offsetDistance = 60 - vpi_mirror.bonus * vp_mirror.hp() / vpi_mirror.durability; + offsetDistance = MAX_VIEW_DISTANCE - vpi_mirror.bonus * vp_mirror.hp() / vpi_mirror.durability; mocache = &camera_cache; ( *mocache )[mirror_pos.x][mirror_pos.y] = LIGHT_TRANSPARENCY_OPEN_AIR; } diff --git a/src/lightmap.h b/src/lightmap.h index 94f5439af7e38..43c09d9bb8434 100644 --- a/src/lightmap.h +++ b/src/lightmap.h @@ -4,6 +4,7 @@ #include // IWYU pragma: keep #include +#include "map_scale_constants.h" constexpr float LIGHT_SOURCE_LOCAL = 0.1f; constexpr float LIGHT_SOURCE_BRIGHT = 10.0f; @@ -30,10 +31,12 @@ constexpr float LIGHT_AMBIENT_LIT = 10.0f; * Note: LIGHT_TRANSPARENCY_SOLID=0 is a special case (it indicates completely opaque tile) * */ constexpr float LIGHT_TRANSPARENCY_SOLID = 0.0f; -// Calculated to run out at 60 squares. -// Cumulative transparency should drop to 0.1 or lower over 60 squares, -// Bright sunlight should drop to LIGHT_AMBIENT_LOW over 60 squares. -constexpr float LIGHT_TRANSPARENCY_OPEN_AIR = 0.038376418216f; + +// Expected to run out at the maximum view distance as per MAX_VIEW_DISTANCE +// in map_scale_constants.h. +// Cumulative transparency should drop to 0.1 or lower, and bright sunlight should drop to +// LIGHT_AMBIENT_LOW over the same distance. +constexpr float LIGHT_TRANSPARENCY_OPEN_AIR = 2.3f / MAX_VIEW_DISTANCE; // indicates starting (full) visibility (for seen_cache) constexpr float VISIBILITY_FULL = 1.0f; diff --git a/src/map.cpp b/src/map.cpp index 2a70967c05a01..554d843b224e3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -9601,7 +9601,7 @@ void map::build_map_cache( const int zlev, bool skip_lightmap ) if( inbounds( mon.second ) ) { int const range = mon.first->type->vision_day; build_seen_cache( getlocal( mon.second ), mon.second.z(), range, cumulative, - true, std::max( 60 - range, 0 ) ); + true, std::max( MAX_VIEW_DISTANCE - range, 0 ) ); cumulative = true; } } diff --git a/src/map.h b/src/map.h index e72bf4317550c..459e0549d0d5d 100644 --- a/src/map.h +++ b/src/map.h @@ -2023,7 +2023,8 @@ class map protected: void generate_lightmap( int zlev ); - void build_seen_cache( const tripoint &origin, int target_z, int extension_range = 60, + void build_seen_cache( const tripoint &origin, int target_z, + int extension_range = MAX_VIEW_DISTANCE, bool cumulative = false, bool camera = false, int penalty = 0 ); void apply_character_light( Character &p ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 57c539ba8919d..351969fcc8894 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -4760,8 +4760,8 @@ bool mattack::flesh_tendril( monster *z ) if( one_in( 70 ) ) { add_msg( _( "The floor trembles underneath your feet." ) ); z->mod_moves( -to_moves( 2_seconds ) ); - sounds::sound( z->pos(), 60, sounds::sound_t::alert, _( "a deafening roar!" ), false, "shout", - "roar" ); + sounds::sound( z->pos(), MAX_VIEW_DISTANCE, sounds::sound_t::alert, _( "a deafening roar!" ), false, + "shout", "roar" ); } return false; } @@ -4788,8 +4788,8 @@ bool mattack::flesh_tendril( monster *z ) //it pulls you towards itself and then knocks you away bool pulled = z->type->special_attacks.at( "ranged_pull" )->call( *z ); if( pulled && one_in( 4 ) ) { - sounds::sound( z->pos(), 60, sounds::sound_t::alarm, _( "a deafening roar!" ), false, "shout", - "roar" ); + sounds::sound( z->pos(), MAX_VIEW_DISTANCE, sounds::sound_t::alarm, _( "a deafening roar!" ), false, + "shout", "roar" ); } return pulled; } @@ -5537,7 +5537,7 @@ bool mattack::doot( monster *z ) bool mattack::speaker( monster *z ) { - sounds::sound( z->pos(), 60, sounds::sound_t::order, + sounds::sound( z->pos(), MAX_VIEW_DISTANCE, sounds::sound_t::order, SNIPPET.random_from_category( "speaker_warning" ).value_or( translation() ) ); return true; } diff --git a/src/npcmove.cpp b/src/npcmove.cpp index aa69e6da49d2c..e898f154c6d1f 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -288,8 +288,8 @@ tripoint npc::good_escape_direction( bool include_pos ) zone_type_id retreat_zone = zone_type_NPC_RETREAT; const tripoint_abs_ms abs_pos = get_location(); const zone_manager &mgr = zone_manager::get_manager(); - std::optional retreat_target = mgr.get_nearest( retreat_zone, abs_pos, 60, - fac_id ); + std::optional retreat_target = mgr.get_nearest( retreat_zone, abs_pos, + MAX_VIEW_DISTANCE, fac_id ); // if there is a retreat zone in range, go there diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index 37e9a0b0ef238..3c877e1d913b8 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -2643,7 +2643,7 @@ static void CheckMessages() Character &player_character = get_player_character(); // Check if we're in a potential combat situation, if so, sort a few actions to the top. - if( !player_character.get_hostile_creatures( 60 ).empty() ) { + if( !player_character.get_hostile_creatures( MAX_VIEW_DISTANCE ).empty() ) { // Only prioritize movement options if we're not driving. if( !player_character.controlling_vehicle ) { actions.insert( ACTION_CYCLE_MOVE ); diff --git a/src/shadowcasting.cpp b/src/shadowcasting.cpp index 437aa74709e5d..7cc1f1ddf9a3b 100644 --- a/src/shadowcasting.cpp +++ b/src/shadowcasting.cpp @@ -10,6 +10,9 @@ #include "list.h" #include "point.h" +// historically 8 bits is enough for rise and run, as a shadowcasting radius of 60 +// readily fits within that space. larger shadowcasting volumes may require larger +// storage units; a radius of 120 definitely will not fit. struct slope { slope( int_least8_t rise, int_least8_t run ) { // Ensure run is always positive for the inequality operators @@ -21,8 +24,7 @@ struct slope { } } - // We don't need more that 8 bits since the shadowcasting area is not that large, - // currently the radius is 60. + // see above for commentary on types. int_least8_t rise; int_least8_t run; }; @@ -166,7 +168,7 @@ void cast_horizontal_zlight_segment( const tripoint &offset, const int offset_distance, const T numerator ) { - const int radius = 60 - offset_distance; + const int radius = MAX_VIEW_DISTANCE - offset_distance; constexpr int min_z = -OVERMAP_DEPTH; constexpr int max_z = OVERMAP_HEIGHT; @@ -362,7 +364,7 @@ void cast_vertical_zlight_segment( const tripoint &offset, const int offset_distance, const T numerator ) { - const int radius = 60 - offset_distance; + const int radius = MAX_VIEW_DISTANCE - offset_distance; constexpr int min_z = -OVERMAP_DEPTH; constexpr int max_z = OVERMAP_HEIGHT; diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 1b3ae9c68a842..5d0bc5226e739 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -125,7 +125,8 @@ void timed_event::actualize() // You could drop the flag, you know. if( player_character.has_amount( itype_petrified_eye, 1 ) ) { - sounds::sound( player_character.pos(), 60, sounds::sound_t::alert, _( "a tortured scream!" ), false, + sounds::sound( player_character.pos(), MAX_VIEW_DISTANCE, sounds::sound_t::alert, + _( "a tortured scream!" ), false, "shout", "scream_tortured" ); if( !player_character.is_deaf() ) { diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 791010d0a2937..d970b5766bb38 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -496,7 +496,7 @@ bool trapfunc::crossbow( const tripoint &p, Creature *c, item * ) bool trapfunc::shotgun( const tripoint &p, Creature *c, item * ) { map &here = get_map(); - sounds::sound( p, 60, sounds::sound_t::combat, _( "Kerblam!" ), false, "fire_gun", + sounds::sound( p, MAX_VIEW_DISTANCE, sounds::sound_t::combat, _( "Kerblam!" ), false, "fire_gun", here.tr_at( p ) == tr_shotgun_1 ? "shotgun_s" : "shotgun_d" ); int shots = 1; if( c != nullptr ) { diff --git a/src/vehicle.cpp b/src/vehicle.cpp index cf473f34f219c..2e3f333b84298 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -638,7 +638,7 @@ void vehicle::autopilot_patrol() } zone_manager &mgr = zone_manager::get_manager(); const auto &zone_src_set = - mgr.get_near( zone_type_VEHICLE_PATROL, global_square_location(), 60 ); + mgr.get_near( zone_type_VEHICLE_PATROL, global_square_location(), MAX_VIEW_DISTANCE ); if( zone_src_set.empty() ) { is_patrolling = false; return; diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 4be65521317e5..1ffd0013d2506 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -485,7 +485,7 @@ void vehicle::smash_security_system() void vehicle::autopilot_patrol_check() { zone_manager &mgr = zone_manager::get_manager(); - if( mgr.has_near( zone_type_VEHICLE_PATROL, global_square_location(), 60 ) ) { + if( mgr.has_near( zone_type_VEHICLE_PATROL, global_square_location(), MAX_VIEW_DISTANCE ) ) { enable_patrol(); } else { g->zones_manager(); diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index e3a16f69e9673..ef753e91c3709 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -172,9 +172,9 @@ TEST_CASE( "character_sight_limits", "[character][sight][vision]" ) here.build_map_cache( 0, false ); REQUIRE_FALSE( g->is_in_sunlight( dummy.pos() ) ); - THEN( "sight limit is 60 tiles away" ) { + THEN( "sight limit is" << MAX_VIEW_DISTANCE << "tiles away" ) { dummy.recalc_sight_limits(); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); } } @@ -219,10 +219,10 @@ TEST_CASE( "character_sight_limits", "[character][sight][vision]" ) dummy.wear_item( item( "glasses_eye" ) ); REQUIRE( dummy.worn_with_flag( flag_FIX_NEARSIGHT ) ); - THEN( "unimpaired sight, with 60 tiles of range" ) { + THEN( "unimpaired sight, with " << MAX_VIEW_DISTANCE << " tiles of range" ) { dummy.recalc_sight_limits(); CHECK_FALSE( dummy.sight_impaired() ); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); } } } @@ -281,7 +281,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) THEN( "unimpaired sight, with 7 tiles of range" ) { dummy.recalc_sight_limits(); CHECK_FALSE( dummy.sight_impaired() ); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); CHECK( dummy.sight_range( light_here ) == 7 ); } } @@ -295,7 +295,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) THEN( "unimpaired sight, with 8 tiles of range" ) { dummy.recalc_sight_limits(); CHECK_FALSE( dummy.sight_impaired() ); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); CHECK( dummy.sight_range( light_here ) == 8 ); } } @@ -309,7 +309,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) THEN( "unimpaired sight, with 27 tiles of range" ) { dummy.recalc_sight_limits(); CHECK_FALSE( dummy.sight_impaired() ); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); CHECK( dummy.sight_range( light_here ) == 18 ); } } @@ -336,7 +336,7 @@ TEST_CASE( "ursine_vision", "[character][ursine][vision]" ) THEN( "unimpaired sight, with 87 tiles of range" ) { dummy.recalc_sight_limits(); CHECK_FALSE( dummy.sight_impaired() ); - CHECK( dummy.unimpaired_range() == 60 ); + CHECK( dummy.unimpaired_range() == MAX_VIEW_DISTANCE ); CHECK( dummy.sight_range( light_here ) == 87 ); } }