Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug menu can look across z levels and reset ignored messages #2025

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ static bool checkDebugLevelClass( DL lev, DC cl )
}
}

void debug_reset_ignored_messages()
{
ignored_messages.clear();
}

// Debug only {{{1
// ---------------------------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ void setDebugLogClasses( const enum_bitset<DC> &mask, bool silent = false );
*/
bool debug_has_error_been_observed();

/**
* Reset any ignored debug messages
*/
void debug_reset_ignored_messages();

/**
* Capturing debug messages during func execution,
* used to test debugmsg calls in the unit tests
Expand Down
21 changes: 13 additions & 8 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ enum debug_menu_index {
DEBUG_TEST_MAP_EXTRA_DISTRIBUTION,
DEBUG_VEHICLE_BATTERY_CHARGE,
DEBUG_HOUR_TIMER,
DEBUG_NESTED_MAPGEN
DEBUG_NESTED_MAPGEN,
DEBUG_RESET_IGNORED_MESSAGES,
};

class mission_debug
Expand Down Expand Up @@ -233,6 +234,7 @@ static int info_uilist( bool display_all_entries = true )
{ uilist_entry( DEBUG_PRINT_NPC_MAGIC, true, 'M', _( "Print NPC magic info to console" ) ) },
{ uilist_entry( DEBUG_TEST_WEATHER, true, 'W', _( "Test weather" ) ) },
{ uilist_entry( DEBUG_TEST_MAP_EXTRA_DISTRIBUTION, true, 'e', _( "Test map extra list" ) ) },
{ uilist_entry( DEBUG_RESET_IGNORED_MESSAGES, true, 'I', _( "Reset ignored debug messages" ) ) },
};
uilist_initializer.insert( uilist_initializer.begin(), debug_only_options.begin(),
debug_only_options.end() );
Expand Down Expand Up @@ -370,7 +372,7 @@ static int debug_menu_uilist( bool display_all_entries = true )

void teleport_short()
{
const cata::optional<tripoint> where = g->look_around();
const cata::optional<tripoint> where = g->look_around( true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is great, I wasted a ton of time "emulating" it by switching 3D fov on just for one teleport.

if( !where || *where == g->u.pos() ) {
return;
}
Expand Down Expand Up @@ -432,7 +434,7 @@ void spawn_nested_mapgen()
nest_menu.query();
const int nest_choice = nest_menu.ret;
if( nest_choice >= 0 && nest_choice < static_cast<int>( nest_str.size() ) ) {
const cata::optional<tripoint> where = g->look_around();
const cata::optional<tripoint> where = g->look_around( true );
if( !where ) {
return;
}
Expand Down Expand Up @@ -952,7 +954,7 @@ void character_edit_menu( Character &c )
mission_debug::edit( p );
break;
case edit_character::tele: {
if( const cata::optional<tripoint> newpos = g->look_around() ) {
if( const cata::optional<tripoint> newpos = g->look_around( true ) ) {
p.setpos( *newpos );
if( p.is_player() ) {
if( p.is_mounted() ) {
Expand Down Expand Up @@ -1432,15 +1434,15 @@ void debug()

tripoint initial_pos = g->u.pos();
const look_around_result first = g->look_around( false, initial_pos, initial_pos,
false, true, false );
false, true, false, false, tripoint_zero, true );

if( !first.position ) {
break;
}

popup.message( "%s", _( "Select second point." ) );
const look_around_result second = g->look_around( false, initial_pos, *first.position,
true, true, false );
true, true, false, false, tripoint_zero, true );

if( !second.position ) {
break;
Expand Down Expand Up @@ -1522,7 +1524,7 @@ void debug()
break;

case DEBUG_SPAWN_ARTIFACT:
if( const cata::optional<tripoint> center = g->look_around() ) {
if( const cata::optional<tripoint> center = g->look_around( true ) ) {
artifact_natural_property prop = static_cast<artifact_natural_property>( rng( ARTPROP_NULL + 1,
ARTPROP_MAX - 1 ) );
m.create_anomaly( *center, prop );
Expand Down Expand Up @@ -1605,7 +1607,7 @@ void debug()
break;

case DEBUG_GEN_SOUND: {
const cata::optional<tripoint> where = g->look_around();
const cata::optional<tripoint> where = g->look_around( true );
if( !where ) {
return;
}
Expand Down Expand Up @@ -2014,6 +2016,9 @@ void debug()
case DEBUG_TEST_MAP_EXTRA_DISTRIBUTION:
MapExtras::debug_spawn_test();
break;
case DEBUG_RESET_IGNORED_MESSAGES:
debug_reset_ignored_messages();
break;
}
m.invalidate_map_cache( g->get_levz() );
}
Expand Down
14 changes: 8 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6651,21 +6651,21 @@ void game::pre_print_all_tile_info( const tripoint &lp, const catacurses::window
print_all_tile_info( lp, w_info, area_name, 1, first_line, last_line, cache );
}

cata::optional<tripoint> game::look_around()
cata::optional<tripoint> game::look_around( bool force_3d )
{
tripoint center = u.pos() + u.view_offset;
look_around_result result = look_around( /*show_window=*/true, center, center, false, false,
false );
false, false, tripoint_zero, force_3d );
return result.position;
}

look_around_result game::look_around( bool show_window, tripoint &center,
const tripoint &start_point, bool has_first_point, bool select_zone, bool peeking,
bool is_moving_zone, const tripoint &end_point )
bool is_moving_zone, const tripoint &end_point, bool force_3d )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That signature got really ugly. 5 bool parameters mean it is trying to do many different things at once and isn't very general.
In the future, it will need a refactor.

{
bVMonsterLookFire = false;
// TODO: Make this `true`
const bool allow_zlev_move = m.has_zlevels() && get_option<bool>( "FOV_3D" );
const bool allow_zlev_move = m.has_zlevels() && ( get_option<bool>( "FOV_3D" ) || force_3d );

temp_exit_fullscreen();

Expand Down Expand Up @@ -6750,8 +6750,10 @@ look_around_result game::look_around( bool show_window, tripoint &center,
#endif // TILES

const int old_levz = get_levz();
const int min_levz = std::max( old_levz - fov_3d_z_range, -OVERMAP_DEPTH );
const int max_levz = std::min( old_levz + fov_3d_z_range, OVERMAP_HEIGHT );
const int min_levz = force_3d ? -OVERMAP_DEPTH : std::max( old_levz - fov_3d_z_range,
-OVERMAP_DEPTH );
const int max_levz = force_3d ? OVERMAP_HEIGHT : std::min( old_levz + fov_3d_z_range,
OVERMAP_HEIGHT );

m.update_visibility_cache( old_levz );
const visibility_variables &cache = m.get_visibility_variables_cache();
Expand Down
4 changes: 2 additions & 2 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ class game
void zones_manager();

// Look at nearby terrain ';', or select zone points
cata::optional<tripoint> look_around();
cata::optional<tripoint> look_around( bool force_3d = false );
/**
* @brief
*
Expand All @@ -590,7 +590,7 @@ class game
*/
look_around_result look_around( bool show_window, tripoint &center,
const tripoint &start_point, bool has_first_point, bool select_zone, bool peeking,
bool is_moving_zone = false, const tripoint &end_point = tripoint_zero );
bool is_moving_zone = false, const tripoint &end_point = tripoint_zero, bool force_3d = false );

// Shared method to print "look around" info
void pre_print_all_tile_info( const tripoint &lp, const catacurses::window &w_info,
Expand Down
2 changes: 1 addition & 1 deletion src/wish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ void debug_menu::wishmonster( const cata::optional<tripoint> &p )
wmenu.query();
if( wmenu.ret >= 0 ) {
const mtype_id &mon_type = mtypes[ wmenu.ret ]->id;
if( cata::optional<tripoint> spawn = p ? p : g->look_around() ) {
if( cata::optional<tripoint> spawn = p ? p : g->look_around( true ) ) {
int num_spawned = 0;
for( const tripoint &destination : closest_points_first( *spawn, cb.group ) ) {
monster *const mon = g->place_critter_at( mon_type, destination );
Expand Down