Skip to content

Commit

Permalink
Revert "Don't access out of lightmap bounds (CleverRaven#66431)"
Browse files Browse the repository at this point in the history
This reverts commit 54368d9.
  • Loading branch information
andrei8l committed Dec 3, 2023
1 parent 3fac1e9 commit a527693
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,6 @@ lit_level map::apparent_light_at( const tripoint &p, const visibility_variables
}
}

bool tinymap::pl_sees( const tripoint &, int ) const
{
return false;
}

bool map::pl_sees( const tripoint &t, const int max_range ) const
{
if( !inbounds( t ) ) {
Expand Down
10 changes: 5 additions & 5 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ bool map::furn_set( const tripoint &p, const furn_id &new_furniture, const bool
invalidate_max_populated_zlev( p.z );

memory_cache_dec_set_dirty( p, true );
if( pl_sees( p, player_character.sight_max ) ) {
if( player_character.sees( p ) ) {
player_character.memorize_clear_decoration( getglobal( p ), "f_" );
}

Expand Down Expand Up @@ -2233,7 +2233,7 @@ bool map::ter_set( const tripoint &p, const ter_id &new_terrain, bool avoid_crea

memory_cache_dec_set_dirty( p, true );
avatar &player_character = get_avatar();
if( pl_sees( p, player_character.sight_max ) ) {
if( player_character.sees( p ) ) {
player_character.memorize_clear_decoration( getglobal( p ), "t_" );
}

Expand Down Expand Up @@ -6089,7 +6089,7 @@ void map::partial_con_remove( const tripoint_bub_ms &p )
current_submap->partial_constructions.erase( tripoint_sm_ms( l, p.z() ) );
memory_cache_dec_set_dirty( p.raw(), true );
avatar &player_character = get_avatar();
if( pl_sees( p.raw(), player_character.sight_max ) ) {
if( player_character.sees( p ) ) {
player_character.memorize_clear_decoration( getglobal( p ), "tr_" );
}
}
Expand Down Expand Up @@ -6132,7 +6132,7 @@ void map::trap_set( const tripoint &p, const trap_id &type )

memory_cache_dec_set_dirty( p, true );
avatar &player_character = get_avatar();
if( pl_sees( p, player_character.sight_max ) ) {
if( player_character.sees( p ) ) {
player_character.memorize_clear_decoration( getglobal( p ), "tr_" );
}
// If there was already a trap here, remove it.
Expand Down Expand Up @@ -6169,7 +6169,7 @@ void map::remove_trap( const tripoint &p )
if( g != nullptr && this == &get_map() ) {
memory_cache_dec_set_dirty( p, true );
avatar &player_character = get_avatar();
if( pl_sees( p, player_character.sight_max ) ) {
if( player_character.sees( p ) ) {
player_character.memorize_clear_decoration( getglobal( p ), "tr_" );
}
player_character.add_known_trap( p, tr_null.obj() );
Expand Down
4 changes: 1 addition & 3 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ class map
* @param max_range All squares that are further away than this are invisible.
* Ignored if smaller than 0.
*/
virtual bool pl_sees( const tripoint &t, int max_range ) const;
bool pl_sees( const tripoint &t, int max_range ) const;
/**
* Uses the map cache to tell if the player could see the given square.
* pl_sees implies pl_line_of_sight
Expand Down Expand Up @@ -2323,8 +2323,6 @@ class tinymap : public map
public:
tinymap() : map( 2, false ) {}
bool inbounds( const tripoint &p ) const override;
// @returns false
bool pl_sees( const tripoint &t, int max_range ) const override;
};

class fake_map : public tinymap
Expand Down

0 comments on commit a527693

Please sign in to comment.