From 5c02744ab08fbe732c15760bdbacd8a3d3c06c56 Mon Sep 17 00:00:00 2001 From: anothersimulacrum Date: Fri, 3 Jan 2020 23:29:32 -0800 Subject: [PATCH] Prevent high eye encumbrance from blinding players Due to the way range of vision was calculated, when the player had high eye encumbrance, it could become negative and prevent the player from seeing anything, including their own tile. The player should never be unable to tell where they are, even if they cannot see anything else, so prevent range from becoming less than 1. --- src/character.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/character.cpp b/src/character.cpp index 0568b33284ecd..03fad476c6c6b 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1254,6 +1254,9 @@ float Character::get_vision_threshold( float light_level ) const range++; } + // Clamp range to 1+, so that we can always see where we are + range = std::max( 1.0f, range ); + return std::min( static_cast( LIGHT_AMBIENT_LOW ), threshold_for_range( range ) * dimming_from_light ); }