diff --git a/src/action.cpp b/src/action.cpp index 416ceb45c69d9..2de40c0bb08b9 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -956,8 +956,6 @@ action_id handle_action_menu() smenu.query(); const int selection = smenu.ret; - g->draw(); - if( selection < 0 || selection == NUM_ACTIONS ) { return ACTION_NULL; } else if( selection == 2 * NUM_ACTIONS ) { @@ -1006,8 +1004,6 @@ action_id handle_main_menu() smenu.query(); int selection = smenu.ret; - g->draw(); - if( selection < 0 || selection >= NUM_ACTIONS ) { return ACTION_NULL; } else { @@ -1076,31 +1072,33 @@ cata::optional choose_adjacent_highlight( const std::string &message, const std::string &failure_message, const std::function &allowed, const bool allow_vertical ) { - // Highlight nearby terrain according to the highlight function - if( allowed != nullptr ) { - cata::optional single; - bool highlighted = false; + std::vector valid; + if( allowed ) { for( const tripoint &pos : g->m.points_in_radius( g->u.pos(), 1 ) ) { if( allowed( pos ) ) { - if( !highlighted ) { - single = pos; - highlighted = true; - } else { - single = cata::nullopt; - } + valid.emplace_back( pos ); + } + } + } + + const bool auto_select = get_option( "AUTOSELECT_SINGLE_VALID_TARGET" ); + if( valid.empty() && auto_select ) { + add_msg( failure_message ); + return cata::nullopt; + } else if( valid.size() == 1 && auto_select ) { + return valid.back(); + } + + shared_ptr_fast hilite_cb; + if( !valid.empty() ) { + hilite_cb = make_shared_fast( [&]() { + for( const tripoint &pos : valid ) { g->m.drawsq( g->w_terrain, g->u, pos, true, true, g->u.pos() + g->u.view_offset ); } - } - if( highlighted ) { - wrefresh( g->w_terrain ); - } else if( get_option( "AUTOSELECT_SINGLE_VALID_TARGET" ) ) { - add_msg( failure_message ); - return cata::nullopt; - } - if( get_option( "AUTOSELECT_SINGLE_VALID_TARGET" ) && single ) { - return single; - } + } ); + g->add_draw_callback( hilite_cb ); } + return choose_adjacent( message, allow_vertical ); } diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index df1f5ec140cd5..fe13a5518272e 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -150,7 +150,6 @@ void aim_activity_actor::do_turn( player_activity &act, Character &who ) } g->temp_exit_fullscreen(); - g->m.draw( g->w_terrain, you.pos() ); target_handler::trajectory trajectory = target_handler::mode_fire( you, *this ); g->reenter_fullscreen(); @@ -180,11 +179,6 @@ void aim_activity_actor::finish( player_activity &act, Character &who ) return; } - // Recenter our view - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels(); - // Fire! item *weapon = get_weapon(); gun_mode gun = weapon->gun_current_mode(); @@ -264,7 +258,7 @@ void aim_activity_actor::restore_view() g->u.view_offset = initial_view_offset; if( changed_z ) { g->m.invalidate_map_cache( g->u.view_offset.z ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); } } @@ -310,7 +304,6 @@ bool aim_activity_actor::load_RAS_weapon() reload_time += ( sta_percent < 25 ) ? ( ( 25 - sta_percent ) * 2 ) : 0; you.moves -= reload_time; - g->refresh_all(); return true; } @@ -335,7 +328,6 @@ void aim_activity_actor::unload_RAS_weapon() if( first_turn ) { you.moves = moves_before_unload; } - g->refresh_all(); } } diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 7ac7a65e2b282..78858e75608e1 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2224,7 +2224,6 @@ void activity_handlers::vehicle_finish( player_activity *act, player *p ) } else { if( vp ) { g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); // TODO: Z (and also where the activity is queued) // Or not, because the vehicle coordinates are dropped anyway if( !resume_for_multi_activities( *p ) ) { @@ -2620,7 +2619,6 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p ) // target selection and validation. while( act->targets.size() < 2 ) { - g->draw(); item_location item_loc = game_menus::inv::repair( *p, actor, &main_tool ); if( item_loc == item_location::nowhere ) { @@ -2673,7 +2671,6 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p ) act->values.resize( 1 ); } do { - g->draw(); repeat = repeat_menu( title, repeat ); if( repeat == REPEAT_CANCEL ) { @@ -2950,7 +2947,6 @@ void activity_handlers::travel_do_turn( player_activity *act, player *p ) p->omt_path.pop_back(); if( p->omt_path.empty() ) { p->add_msg_if_player( m_info, _( "You have reached your destination." ) ); - g->draw(); act->set_to_null(); return; } @@ -2977,7 +2973,6 @@ void activity_handlers::travel_do_turn( player_activity *act, player *p ) } else { p->add_msg_if_player( m_info, _( "You have reached your destination." ) ); } - g->draw(); act->set_to_null(); } diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index cd3c2d69d7e4a..b54584888cab6 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -113,12 +113,6 @@ advanced_inventory::~advanced_inventory() } // Only refresh if we exited manually, otherwise we're going to be right back if( exit ) { - werase( head ); - werase( minimap ); - werase( mm_border ); - werase( panes[left].window ); - werase( panes[right].window ); - g->refresh_all(); g->u.check_item_encumbrance_flag(); } } @@ -1681,12 +1675,7 @@ bool advanced_inventory::query_destination( aim_location &def ) } // Selected keyed to uilist.entries, which starts at 0. menu.selected = save_state->last_popup_dest - AIM_SOUTHWEST; - // generate and show window. - menu.show(); - // query, but don't loop - while( menu.ret == UILIST_WAIT_INPUT ) { - menu.query( false ); - } + menu.query(); if( menu.ret >= AIM_SOUTHWEST && menu.ret <= AIM_NORTHEAST ) { assert( squares[menu.ret].canputitems() ); def = static_cast( menu.ret ); diff --git a/src/animation.cpp b/src/animation.cpp index 73cc6063577dc..414aaeda1d504 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -45,15 +45,13 @@ class basic_animation } void draw() const { - wrefresh( g->w_terrain ); - g->draw_panels(); - - query_popup() + static_popup popup; + popup .wait_message( "%s", _( "Hang on a bit…" ) ) - .on_top( true ) - .show(); + .on_top( true ); - catacurses::refresh(); + g->invalidate_main_ui_adaptor(); + ui_manager::redraw_invalidated(); refresh_display(); } @@ -119,7 +117,7 @@ tripoint relative_view_pos( const game &g, const tripoint &p ) noexcept return p - g.ter_view_p + point( POSX, POSY ); } -void draw_explosion_curses( const game &g, const tripoint ¢er, const int r, +void draw_explosion_curses( game &g, const tripoint ¢er, const int r, const nc_color &col ) { if( !is_radius_visible( center, r ) ) { @@ -128,33 +126,39 @@ void draw_explosion_curses( const game &g, const tripoint ¢er, const int r, // TODO: Make it look different from above/below const tripoint p = relative_view_pos( g.u, center ); - // TODO: why not always print '*'? - if( r == 0 ) { - mvwputch( g.w_terrain, point( p.y, p.x ), col, '*' ); - } - explosion_animation anim; - for( int i = 1; i <= r; ++i ) { - // corner: top left - mvwputch( g.w_terrain, p.xy() + point( -i, -i ), col, '/' ); - // corner: top right - mvwputch( g.w_terrain, p.xy() + point( i, -i ), col, '\\' ); - // corner: bottom left - mvwputch( g.w_terrain, p.xy() + point( -i, i ), col, '\\' ); - // corner: bottom right - mvwputch( g.w_terrain, p.xy() + point( i, i ), col, '/' ); - for( int j = 1 - i; j < 0 + i; j++ ) { - // edge: top - mvwputch( g.w_terrain, p.xy() + point( j, -i ), col, '-' ); - // edge: bottom - mvwputch( g.w_terrain, p.xy() + point( j, i ), col, '-' ); - // edge: left - mvwputch( g.w_terrain, p.xy() + point( -i, j ), col, '|' ); - // edge: right - mvwputch( g.w_terrain, p.xy() + point( i, j ), col, '|' ); + int frame = 0; + shared_ptr_fast explosion_cb = + make_shared_fast( [&]() { + if( r == 0 ) { + mvwputch( g.w_terrain, point( p.y, p.x ), col, '*' ); + } + + for( int i = 1; i <= frame; ++i ) { + // corner: top left + mvwputch( g.w_terrain, p.xy() + point( -i, -i ), col, '/' ); + // corner: top right + mvwputch( g.w_terrain, p.xy() + point( i, -i ), col, '\\' ); + // corner: bottom left + mvwputch( g.w_terrain, p.xy() + point( -i, i ), col, '\\' ); + // corner: bottom right + mvwputch( g.w_terrain, p.xy() + point( i, i ), col, '/' ); + for( int j = 1 - i; j < 0 + i; j++ ) { + // edge: top + mvwputch( g.w_terrain, p.xy() + point( j, -i ), col, '-' ); + // edge: bottom + mvwputch( g.w_terrain, p.xy() + point( j, i ), col, '-' ); + // edge: left + mvwputch( g.w_terrain, p.xy() + point( -i, j ), col, '|' ); + // edge: right + mvwputch( g.w_terrain, p.xy() + point( i, j ), col, '|' ); + } } + } ); + g.add_draw_callback( explosion_cb ); + for( frame = 1; frame <= r; ++frame ) { anim.progress(); } } @@ -169,7 +173,7 @@ constexpr explosion_neighbors operator ^ ( explosion_neighbors lhs, explosion_ne return static_cast( static_cast< int >( lhs ) ^ static_cast< int >( rhs ) ); } -void draw_custom_explosion_curses( const game &g, +void draw_custom_explosion_curses( game &g, const std::list< std::map > &layers ) { // calculate screen offset relative to player + view offset position @@ -179,57 +183,64 @@ void draw_custom_explosion_curses( const game &g, explosion_animation anim; - for( const auto &layer : layers ) { - for( const auto &pr : layer ) { - // update tripoint in relation to top left corner of curses window - // mvwputch already filters out of bounds coordinates - const tripoint p = pr.first - topleft; - const explosion_neighbors ngh = pr.second.neighborhood; - const nc_color col = pr.second.color; - - switch( ngh ) { - // '^', 'v', '<', '>' - case N_NORTH: - mvwputch( g.w_terrain, p.xy(), col, '^' ); - break; - case N_SOUTH: - mvwputch( g.w_terrain, p.xy(), col, 'v' ); - break; - case N_WEST: - mvwputch( g.w_terrain, p.xy(), col, '<' ); - break; - case N_EAST: - mvwputch( g.w_terrain, p.xy(), col, '>' ); - break; - // '|' and '-' - case N_NORTH | N_SOUTH: - case N_NORTH | N_SOUTH | N_WEST: - case N_NORTH | N_SOUTH | N_EAST: - mvwputch( g.w_terrain, p.xy(), col, '|' ); - break; - case N_WEST | N_EAST: - case N_WEST | N_EAST | N_NORTH: - case N_WEST | N_EAST | N_SOUTH: - mvwputch( g.w_terrain, p.xy(), col, '-' ); - break; - // '/' and '\' - case N_NORTH | N_WEST: - case N_SOUTH | N_EAST: - mvwputch( g.w_terrain, p.xy(), col, '/' ); - break; - case N_SOUTH | N_WEST: - case N_NORTH | N_EAST: - mvwputch( g.w_terrain, p.xy(), col, '\\' ); - break; - case N_NO_NEIGHBORS: - mvwputch( g.w_terrain, p.xy(), col, '*' ); - break; - case N_WEST | N_EAST | N_NORTH | N_SOUTH: - break; + auto last_layer_it = layers.begin(); + shared_ptr_fast explosion_cb = + make_shared_fast( [&]() { + for( auto it = layers.begin(); it != std::next( last_layer_it ); ++it ) { + for( const auto &pr : *it ) { + // update tripoint in relation to top left corner of curses window + // mvwputch already filters out of bounds coordinates + const tripoint p = pr.first - topleft; + const explosion_neighbors ngh = pr.second.neighborhood; + const nc_color col = pr.second.color; + + switch( ngh ) { + // '^', 'v', '<', '>' + case N_NORTH: + mvwputch( g.w_terrain, p.xy(), col, '^' ); + break; + case N_SOUTH: + mvwputch( g.w_terrain, p.xy(), col, 'v' ); + break; + case N_WEST: + mvwputch( g.w_terrain, p.xy(), col, '<' ); + break; + case N_EAST: + mvwputch( g.w_terrain, p.xy(), col, '>' ); + break; + // '|' and '-' + case N_NORTH | N_SOUTH: + case N_NORTH | N_SOUTH | N_WEST: + case N_NORTH | N_SOUTH | N_EAST: + mvwputch( g.w_terrain, p.xy(), col, '|' ); + break; + case N_WEST | N_EAST: + case N_WEST | N_EAST | N_NORTH: + case N_WEST | N_EAST | N_SOUTH: + mvwputch( g.w_terrain, p.xy(), col, '-' ); + break; + // '/' and '\' + case N_NORTH | N_WEST: + case N_SOUTH | N_EAST: + mvwputch( g.w_terrain, p.xy(), col, '/' ); + break; + case N_SOUTH | N_WEST: + case N_NORTH | N_EAST: + mvwputch( g.w_terrain, p.xy(), col, '\\' ); + break; + case N_NO_NEIGHBORS: + mvwputch( g.w_terrain, p.xy(), col, '*' ); + break; + case N_WEST | N_EAST | N_NORTH | N_SOUTH: + break; + } } } + } ); + g.add_draw_callback( explosion_cb ); - if( is_layer_visible( layer ) ) { + for( last_layer_it = layers.begin(); last_layer_it != layers.end(); ++last_layer_it ) { + if( is_layer_visible( *last_layer_it ) ) { anim.progress(); } } @@ -255,10 +266,16 @@ void explosion_handler::draw_explosion( const tripoint &p, const int r, const nc explosion_animation anim; - const bool visible = is_radius_visible( p, r ); - for( int i = 1; i <= r; i++ ) { + int i = 1; + shared_ptr_fast explosion_cb = + make_shared_fast( [&]() { // TODO: not xpos ypos? tilecontext->init_explosion( p, i ); + } ); + g->add_draw_callback( explosion_cb ); + + const bool visible = is_radius_visible( p, r ); + for( i = 1; i <= r; i++ ) { if( visible ) { anim.progress(); } @@ -398,9 +415,15 @@ void explosion_handler::draw_custom_explosion( const tripoint &, explosion_animation anim; // We need to draw all explosions up to now std::map combined_layer; + + shared_ptr_fast explosion_cb = + make_shared_fast( [&]() { + tilecontext->init_custom_explosion_layer( combined_layer ); + } ); + g->add_draw_callback( explosion_cb ); + for( const auto &layer : layers ) { combined_layer.insert( layer.begin(), layer.end() ); - tilecontext->init_custom_explosion_layer( combined_layer ); if( is_layer_visible( layer ) ) { anim.progress(); } @@ -423,15 +446,17 @@ void draw_bullet_curses( map &m, const tripoint &t, const char bullet, const tri const tripoint vp = g->u.pos() + g->u.view_offset; - if( p != nullptr && p->z == vp.z ) { - m.drawsq( g->w_terrain, g->u, *p, false, true, vp ); - } - if( vp.z != t.z ) { return; } - mvwputch( g->w_terrain, t.xy() - vp.xy() + point( POSX, POSY ), c_red, bullet ); + shared_ptr_fast bullet_cb = make_shared_fast( [&]() { + if( p != nullptr && p->z == vp.z ) { + m.drawsq( g->w_terrain, g->u, *p, false, true, vp ); + } + mvwputch( g->w_terrain, t.xy() - vp.xy() + point( POSX, POSY ), c_red, bullet ); + } ); + g->add_draw_callback( bullet_cb ); bullet_animation().progress(); } @@ -463,7 +488,11 @@ void game::draw_bullet( const tripoint &t, const int /*i*/, : bullet == '`' ? bullet_shrapnel : bullet_unknown; - tilecontext->init_draw_bullet( t, bullet_type ); + shared_ptr_fast bullet_cb = make_shared_fast( [&]() { + tilecontext->init_draw_bullet( t, bullet_type ); + } ); + add_draw_callback( bullet_cb ); + bullet_animation().progress(); tilecontext->void_bullet(); } @@ -523,7 +552,10 @@ void game::draw_hit_mon( const tripoint &p, const monster &m, const bool dead ) return; } - tilecontext->init_draw_hit( p, m.type->id.str() ); + shared_ptr_fast hit_cb = make_shared_fast( [&]() { + tilecontext->init_draw_hit( p, m.type->id.str() ); + } ); + add_draw_callback( hit_cb ); bullet_animation().progress(); } @@ -564,7 +596,12 @@ void game::draw_hit_player( const Character &p, const int dam ) const std::string &type = p.is_player() ? ( p.male ? player_male : player_female ) : p.male ? npc_male : npc_female; - tilecontext->init_draw_hit( p.pos(), type ); + + shared_ptr_fast hit_cb = make_shared_fast( [&]() { + tilecontext->init_draw_hit( p.pos(), type ); + } ); + add_draw_callback( hit_cb ); + bullet_animation().progress(); } #else diff --git a/src/avatar.cpp b/src/avatar.cpp index f1fbe873b3071..71f489f4239c0 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1616,8 +1616,6 @@ bool avatar::invoke_item( item *used, const tripoint &pt ) const std::string &method = std::next( use_methods.begin(), choice )->first; - g->refresh_all(); - return invoke_item( used, method, pt ); } diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 5b146c2e9785b..cea45207f2b73 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -857,15 +857,9 @@ void avatar_action::fire_turret_manual( avatar &you, map &m, turret_data &turret } g->temp_exit_fullscreen(); - g->m.draw( g->w_terrain, you.pos() ); target_handler::trajectory trajectory = target_handler::mode_turret_manual( you, turret ); if( !trajectory.empty() ) { - // Recenter our view - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels(); - turret.fire( you, trajectory.back() ); } g->reenter_fullscreen(); @@ -973,7 +967,6 @@ void avatar_action::plthrow( avatar &you, item_location loc, if( !loc ) { loc = game_menus::inv::titled_menu( you, _( "Throw item" ), _( "You don't have any items to throw." ) ); - g->refresh_all(); } if( !loc ) { @@ -1030,11 +1023,9 @@ void avatar_action::plthrow( avatar &you, item_location loc, const tripoint original_player_position = you.pos(); if( blind_throw_from_pos ) { you.setpos( *blind_throw_from_pos ); - g->draw_ter(); } g->temp_exit_fullscreen(); - g->m.draw( g->w_terrain, you.pos() ); target_handler::trajectory trajectory = target_handler::mode_throw( you, you.weapon, blind_throw_from_pos.has_value() ); @@ -1113,8 +1104,6 @@ void avatar_action::use_item( avatar &you, item_location &loc ) } } - g->refresh_all(); - if( use_in_place ) { update_lum( loc, false ); you.use( loc ); diff --git a/src/bionics.cpp b/src/bionics.cpp index b5c58f33b940c..ba479c4871028 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -586,7 +586,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) if( bio.info().has_flag( flag_BIO_GUN ) ) { add_msg_activate(); refund_power(); // Power usage calculated later, in avatar_action::fire - g->refresh_all(); if( close_bionics_ui ) { *close_bionics_ui = true; } @@ -613,7 +612,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) weapon.invlet = '#'; if( bio.ammo_count > 0 ) { weapon.ammo_set( bio.ammo_loaded, bio.ammo_count ); - g->refresh_all(); avatar_action::fire_wielded_weapon( g->u ); } } else if( bio.id == bio_ears && has_active_bionic( bio_earplugs ) ) { @@ -846,7 +844,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) add_msg_activate(); add_msg_if_player( m_info, _( "You can now run faster, assisted by joint servomotors." ) ); } else if( bio.id == bio_lighter ) { - g->refresh_all(); const cata::optional pnt = choose_adjacent( _( "Start a fire where?" ) ); if( pnt && g->m.is_flammable( *pnt ) ) { add_msg_activate(); @@ -878,7 +875,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) add_effect( effect_adrenaline, 20_minutes ); } } else if( bio.id == bio_emp ) { - g->refresh_all(); if( const cata::optional pnt = choose_adjacent( _( "Create an EMP where?" ) ) ) { add_msg_activate(); explosion_handler::emp_blast( *pnt ); @@ -947,7 +943,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) } } - g->refresh_all(); for( const std::pair &pr : affected ) { projectile proj; proj.speed = 50; @@ -966,7 +961,6 @@ bool Character::activate_bionic( int b, bool eff_only, bool *close_bionics_ui ) if( !is_avatar() ) { return false; } - g->refresh_all(); cata::optional target = lockpick_activity_actor::select_location( g->u ); if( target.has_value() ) { add_msg_activate(); @@ -2227,7 +2221,6 @@ void Character::perform_uninstall( const bionic_id &bid, int difficulty, int suc } g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer, player &patient, @@ -2299,7 +2292,6 @@ bool Character::uninstall_bionic( const bionic &target_cbm, monster &installer, } else { bionics_uninstall_failure( installer, patient, difficulty, success, adjusted_skill ); } - g->refresh_all(); return false; } @@ -2470,7 +2462,6 @@ void Character::perform_install( const bionic_id &bid, const bionic_id &upbid, i bionics_install_failure( bid, installer_name, difficulty, success, adjusted_skill, patient_pos ); } g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } void Character::bionics_install_failure( const bionic_id &bid, const std::string &installer, diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index c104c3b44ccb3..d823fdc44ab9c 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -437,8 +437,13 @@ void player::power_bionics() catacurses::window w_title; catacurses::window w_tabs; + bool hide = false; ui_adaptor ui; ui.on_screen_resize( [&]( ui_adaptor & ui ) { + if( hide ) { + ui.position( point_zero, point_zero ); + return; + } // Main window /** Total required height is: * top frame line: + 1 @@ -509,6 +514,10 @@ void player::power_bionics() ctxt.register_action( "TOGGLE_AUTO_START" ); ui.on_redraw( [&]( const ui_adaptor & ) { + if( hide ) { + return; + } + std::vector *current_bionic_list = ( tab_mode == TAB_ACTIVE ? &active : &passive ); werase( wBio ); @@ -647,7 +656,6 @@ void player::power_bionics() } const int newch = popup_getkey( _( "%s; enter new letter. Space to clear. Esc to cancel." ), tmp->id->name ); - wrefresh( wBio ); if( newch == ch || newch == KEY_ESCAPE ) { continue; } @@ -747,9 +755,8 @@ void player::power_bionics() if( menu_mode == ACTIVATING ) { if( bio_data.activated ) { int b = tmp - &( *my_bionics )[0]; - // Invalidate bionics menu so the remaining power gets redrawn - // if other UIs are opened when activating the bionic. - ui.invalidate_ui(); + hide = true; + ui.mark_resize(); if( tmp->powered ) { deactivate_bionic( b ); } else { @@ -760,6 +767,8 @@ void player::power_bionics() break; } } + hide = false; + ui.mark_resize(); g->invalidate_main_ui_adaptor(); if( moves < 0 ) { return; diff --git a/src/character.cpp b/src/character.cpp index fe849263df63d..c41a7ff034c08 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1280,7 +1280,6 @@ void Character::dismount() mounted_creature = nullptr; critter->mounted_player = nullptr; setpos( *pnt ); - g->refresh_all(); mod_moves( -100 ); set_movement_mode( move_mode_id( "walk" ) ); } diff --git a/src/computer_session.cpp b/src/computer_session.cpp index c6790eff56d27..df59a20526225 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -1488,9 +1488,6 @@ computer_session::ynq computer_session::query_ynq( const std::string &text, Args return ynq::quit; } } - if( action == "HELP_KEYBINDINGS" ) { - refresh(); - } } while( true ); } diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index df8a4fb70bd8f..7e546052c3215 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -75,6 +75,7 @@ #include "player.h" #include "pldata.h" #include "point.h" +#include "popup.h" #include "recipe_dictionary.h" #include "rng.h" #include "sounds.h" @@ -442,7 +443,6 @@ void spawn_nested_mapgen() target_map.save(); g->load_npcs(); g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } } @@ -1096,13 +1096,19 @@ void draw_benchmark( const int max_difference ) auto end_tick = std::chrono::steady_clock::now(); int64_t difference = 0; int draw_counter = 0; + + static_popup popup; + popup.on_top( true ).message( "%s", _( "Benchmark in progress…" ) ); + while( true ) { end_tick = std::chrono::steady_clock::now(); difference = std::chrono::duration_cast( end_tick - start_tick ).count(); if( difference >= max_difference ) { break; } - g->draw(); + g->invalidate_main_ui_adaptor(); + ui_manager::redraw_invalidated(); + refresh_display(); draw_counter++; } @@ -1146,7 +1152,6 @@ void debug() } } - g->refresh_all(); avatar &u = g->u; map &m = g->m; switch( action ) { @@ -1658,7 +1663,6 @@ void debug() MapExtras::apply_function( mx_str[mx_choice], mx_map, where_sm ); g->load_npcs(); g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } } break; @@ -1818,9 +1822,7 @@ void debug() MapExtras::debug_spawn_test(); break; } - catacurses::erase(); m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } } // namespace debug_menu diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index feee6b71558f1..61b69d4949e1f 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -1545,10 +1545,6 @@ bool basecamp::handle_mission( const std::string &miss_id, emergency_recall(); } - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels( true ); - return true; } @@ -1921,7 +1917,6 @@ void basecamp::start_cut_logs() chop_time, travel_time, dist, 2, time_to_food( work_time ) ) ) ) { return; } - g->draw_ter(); npc_ptr comp = start_mission( "_faction_camp_cut_log", work_time, true, _( "departs to cut logs…" ), false, {}, @@ -1967,7 +1962,6 @@ void basecamp::start_clearcut() chop_time, travel_time, dist, 2, time_to_food( work_time ) ) ) ) { return; } - g->draw_ter(); npc_ptr comp = start_mission( "_faction_camp_clearcut", work_time, true, _( "departs to clear a forest…" ), false, {}, @@ -3559,9 +3553,6 @@ std::vector basecamp::give_equipment( std::vector equipment, { std::vector equipment_lost; do { - g->draw_ter(); - wrefresh( g->w_terrain ); - std::vector names; names.reserve( equipment.size() ); for( auto &i : equipment ) { diff --git a/src/game.cpp b/src/game.cpp index 186edbd298e24..cb35adc4abc12 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -309,7 +309,7 @@ game::game() : tileset_zoom( DEFAULT_TILESET_ZOOM ), last_mouse_edge_scroll( std::chrono::steady_clock::now() ) { - player_was_sleeping = false; + first_redraw_since_waiting_started = true; reset_light_level(); events().subscribe( &*stats_tracker_ptr ); events().subscribe( &*kill_tracker_ptr ); @@ -535,7 +535,6 @@ void game::reload_tileset() popup( _( "Loading the tileset failed: %s" ), err.what() ); } g->reset_zoom(); - g->refresh_all(); #endif // TILES } @@ -1566,39 +1565,40 @@ bool game::do_turn() } const bool player_is_sleeping = u.has_effect( effect_sleep ); - + bool wait_redraw = false; + std::string wait_message; + time_duration wait_refresh_rate; if( player_is_sleeping ) { - if( calendar::once_every( 30_minutes ) || !player_was_sleeping ) { - ui_manager::redraw(); - //Putting this in here to save on checking - if( calendar::once_every( 1_hours ) ) { - add_artifact_dreams( ); + wait_redraw = true; + wait_message = _( "Wait till you wake up…" ); + wait_refresh_rate = 30_minutes; + if( calendar::once_every( 1_hours ) ) { + add_artifact_dreams(); + } + } else if( const cata::optional progress = u.activity.get_progress_message( u ) ) { + wait_redraw = true; + wait_message = *progress; + wait_refresh_rate = 5_minutes; + } + if( wait_redraw ) { + if( first_redraw_since_waiting_started || calendar::once_every( 1_minutes ) ) { + if( first_redraw_since_waiting_started || calendar::once_every( wait_refresh_rate ) ) { + ui_manager::redraw(); } - } - - if( calendar::once_every( 1_minutes ) ) { - query_popup() - .wait_message( "%s", _( "Wait till you wake up…" ) ) - .on_top( true ) - .show(); - catacurses::refresh(); - refresh_display(); - } - } else if( calendar::once_every( 1_minutes ) ) { - if( const cata::optional progress = u.activity.get_progress_message( u ) ) { - query_popup() - .wait_message( "%s", *progress ) - .on_top( true ) - .show(); - - catacurses::refresh(); + // Avoid redrawing the main UI every time due to invalidation + ui_adaptor dummy( ui_adaptor::disable_uis_below {} ); + static_popup popup; + popup.on_top( true ).wait_message( "%s", wait_message ); + ui_manager::redraw(); refresh_display(); + first_redraw_since_waiting_started = false; } + } else { + // Nothing to wait for now + first_redraw_since_waiting_started = true; } - player_was_sleeping = player_is_sleeping; - u.update_bodytemp(); u.update_body_wetness( *weather.weather_precise ); u.apply_wetness_morale( weather.temperature ); @@ -1643,13 +1643,6 @@ void game::process_activity() return; } - if( calendar::once_every( 5_minutes ) - && u.activity.moves_total > to_moves - ( 5_minutes ) ) {//This is a hack to prevent an issue with the consume menu popping up again when this fires, since eating is not at present ever 5 minutes long this works - ui_manager::redraw(); - refresh_display(); - } - while( u.moves > 0 && u.activity ) { u.activity.do_turn( u ); } @@ -3131,32 +3124,33 @@ void game::write_memorial_file( std::string sLastWords ) void game::disp_NPC_epilogues() { - catacurses::window w = catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, - point( std::max( 0, ( TERMX - FULL_SCREEN_WIDTH ) / 2 ), std::max( 0, - ( TERMY - FULL_SCREEN_HEIGHT ) / 2 ) ) ); // TODO: This search needs to be expanded to all NPCs for( auto elem : follower_ids ) { shared_ptr_fast guy = overmap_buffer.find_npc( elem ); if( !guy ) { continue; } - scrollable_text( w, guy->disp_name(), guy->get_epilogue() ); + const auto new_win = []() { + return catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, + point( std::max( 0, ( TERMX - FULL_SCREEN_WIDTH ) / 2 ), + std::max( 0, ( TERMY - FULL_SCREEN_HEIGHT ) / 2 ) ) ); + }; + scrollable_text( new_win, guy->disp_name(), guy->get_epilogue() ); } - - refresh_all(); } void game::display_faction_epilogues() { - catacurses::window w = catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, - point( std::max( 0, ( TERMX - FULL_SCREEN_WIDTH ) / 2 ), - std::max( 0, ( TERMY - FULL_SCREEN_HEIGHT ) / 2 ) ) ); - for( const auto &elem : faction_manager_ptr->all() ) { if( elem.second.known_by_u ) { const std::vector epilogue = elem.second.epilogue(); if( !epilogue.empty() ) { - scrollable_text( w, elem.second.name, + const auto new_win = []() { + return catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, + point( std::max( 0, ( TERMX - FULL_SCREEN_WIDTH ) / 2 ), + std::max( 0, ( TERMY - FULL_SCREEN_HEIGHT ) / 2 ) ) ); + }; + scrollable_text( new_win, elem.second.name, std::accumulate( epilogue.begin() + 1, epilogue.end(), epilogue.front(), []( const std::string & lhs, const std::string & rhs ) -> std::string { return lhs + "\n" + rhs; @@ -3164,8 +3158,6 @@ void game::display_faction_epilogues() } } } - - refresh_all(); } struct npc_dist_to_player { @@ -3609,18 +3601,6 @@ void game::draw_veh_dir_indicator( bool next ) } } -void game::refresh_all() -{ - const int minz = m.has_zlevels() ? -OVERMAP_DEPTH : get_levz(); - const int maxz = m.has_zlevels() ? OVERMAP_HEIGHT : get_levz(); - for( int z = minz; z <= maxz; z++ ) { - m.reset_vehicle_cache( z ); - } - - draw(); - catacurses::refresh(); -} - void game::draw_minimap() { @@ -5625,10 +5605,6 @@ void game::examine() return; } u.manual_examine = true; - // redraw terrain to erase 'examine' window - draw_ter(); - wrefresh( w_terrain ); - draw_panels( true ); examine( *examp_ ); u.manual_examine = false; } @@ -5780,9 +5756,6 @@ void game::examine( const tripoint &examp ) if( !m.tr_at( examp ).is_null() && !u.is_mounted() ) { iexamine::trap( u, examp ); - draw_ter(); - wrefresh( w_terrain ); - draw_panels(); } else if( !m.tr_at( examp ).is_null() && u.is_mounted() ) { add_msg( m_warning, _( "You cannot do that while mounted." ) ); } @@ -5832,17 +5805,16 @@ void game::pickup() if( !examp_ ) { return; } - // redraw terrain to erase 'pickup' window - draw_ter(); - // wrefresh is called in pickup( const tripoint & ) pickup( *examp_ ); } void game::pickup( const tripoint &p ) { // Highlight target - g->m.drawsq( w_terrain, u, p, true, true, u.pos() + u.view_offset ); - wrefresh( w_terrain ); + shared_ptr_fast hilite_cb = make_shared_fast( [&]() { + m.drawsq( w_terrain, u, p, true, true, u.pos() + u.view_offset ); + } ); + add_draw_callback( hilite_cb ); Pickup::pick_up( p, 0 ); } @@ -5858,7 +5830,6 @@ void game::peek() { const cata::optional p = choose_direction( _( "Peek where?" ), true ); if( !p ) { - refresh_all(); return; } @@ -5869,10 +5840,7 @@ void game::peek() if( old_pos != u.pos() ) { look_around(); vertical_move( p->z * -1, false ); - draw_ter(); } - wrefresh( w_terrain ); - draw_panels(); return; } @@ -5898,10 +5866,6 @@ void game::peek( const tripoint &p ) avatar_action::plthrow( u, loc, p ); } m.invalidate_map_cache( p.z ); - - draw_ter(); - wrefresh( w_terrain ); - draw_panels(); } //////////////////////////////////////////////////////////////////////////////////////////// cata::optional game::look_debug() @@ -5911,10 +5875,44 @@ cata::optional game::look_debug() } //////////////////////////////////////////////////////////////////////////////////////////// +void game::draw_terrain_indicator( const tripoint &lp, const visibility_variables &cache ) const +{ + visibility_type visibility = VIS_HIDDEN; + const bool inbounds = m.inbounds( lp ); + if( inbounds ) { + visibility = m.get_visibility( m.apparent_light_at( lp, cache ), cache ); + } + const Creature *creature = critter_at( lp, true ); + switch( visibility ) { + case VIS_CLEAR: +#if defined( TILES ) + if( !is_draw_tiles_mode() && !liveview.is_enabled() ) +#endif + { + if( creature != nullptr && u.sees( *creature ) ) { + creature->draw( w_terrain, lp, true ); + } else { + m.drawsq( w_terrain, u, lp, true, true, lp ); + } + } + break; + case VIS_HIDDEN: +#if defined( TILES ) + if( !is_draw_tiles_mode() && !liveview.is_enabled() ) +#endif + { + print_visibility_indicator( visibility ); + } + break; + default: + break; + } +} + void game::print_all_tile_info( const tripoint &lp, const catacurses::window &w_look, const std::string &area_name, int column, int &line, - const int last_line, bool draw_terrain_indicators, + const int last_line, const visibility_variables &cache ) { visibility_type visibility = VIS_HIDDEN; @@ -5934,14 +5932,6 @@ void game::print_all_tile_info( const tripoint &lp, const catacurses::window &w_ last_line ); print_items_info( lp, w_look, column, line, last_line ); print_graffiti_info( lp, w_look, column, line, last_line ); - - if( draw_terrain_indicators && !liveview.is_enabled() ) { - if( creature != nullptr && u.sees( *creature ) ) { - creature->draw( w_terrain, lp, true ); - } else { - m.drawsq( w_terrain, u, lp, true, true, lp ); - } - } } break; case VIS_BOOMER: @@ -5978,10 +5968,6 @@ void game::print_all_tile_info( const tripoint &lp, const catacurses::window &w_ mvwprintw( w_look, point( 1, ++line ), _( "You sense a creature here." ) ); } } - - if( draw_terrain_indicators && !liveview.is_enabled() ) { - print_visibility_indicator( visibility ); - } break; } if( !inbounds ) { @@ -6171,7 +6157,7 @@ void game::print_vehicle_info( const vehicle *veh, int veh_part, const catacurse } } -void game::print_visibility_indicator( visibility_type visibility ) +void game::print_visibility_indicator( visibility_type visibility ) const { std::string visibility_indicator; nc_color visibility_indicator_color = c_white; @@ -6768,8 +6754,7 @@ void game::pre_print_all_tile_info( const tripoint &lp, const catacurses::window const oter_id &cur_ter_m = overmap_buffer.ter( ms_to_omt_copy( g->m.getabs( lp ) ) ); // we only need the area name and then pass it to print_all_tile_info() function below const std::string area_name = cur_ter_m->get_name(); - print_all_tile_info( lp, w_info, area_name, 1, first_line, last_line, !is_draw_tiles_mode(), - cache ); + print_all_tile_info( lp, w_info, area_name, 1, first_line, last_line, cache ); } cata::optional game::look_around() @@ -6875,6 +6860,8 @@ look_around_result game::look_around( const bool show_window, tripoint ¢er, bool blink = true; look_around_result result; + shared_ptr_fast ter_indicator_cb; + if( show_window && ui ) { ui->on_redraw( [&]( const ui_adaptor & ) { werase( w_info ); @@ -6899,6 +6886,10 @@ look_around_result game::look_around( const bool show_window, tripoint ¢er, wrefresh( w_info ); } ); + ter_indicator_cb = make_shared_fast( [&]() { + draw_terrain_indicator( lp, cache ); + } ); + add_draw_callback( ter_indicator_cb ); } cata::optional zone_start; @@ -6925,13 +6916,6 @@ look_around_result game::look_around( const bool show_window, tripoint ¢er, // call to `ui_manager::redraw`. //NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) zone_blink = blink; - } else { - zone_start = lp; - zone_end = cata::nullopt; - // Actually accessed from the terrain overlay callback `zone_cb` in the - // call to `ui_manager::redraw`. - //NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) - zone_blink = false; } invalidate_main_ui_adaptor(); ui_manager::redraw(); @@ -8156,7 +8140,6 @@ void game::drop() void game::drop_in_direction() { if( const cata::optional pnt = choose_adjacent( _( "Drop where?" ) ) ) { - refresh_all(); u.drop( game_menus::inv::multidrop( u ), *pnt ); } } @@ -8641,9 +8624,6 @@ void game::butcher() break; case BUTCHER_CORPSE: { butcher_submenu( corpses, indexer_index ); - draw_ter(); - wrefresh( w_terrain ); - draw_panels( true ); u.activity.targets.emplace_back( map_cursor( u.pos() ), &*corpses[indexer_index] ); } break; @@ -8749,8 +8729,6 @@ void game::reload( item_location &loc, bool prompt, bool empty ) } u.activity.targets.push_back( std::move( opt.ammo ) ); } - - refresh_all(); } // Reload something. @@ -10258,7 +10236,9 @@ void game::fling_creature( Creature *c, const int &dir, float flvel, bool contro range--; steps++; if( animate && ( seen || u.sees( *c ) ) ) { - draw(); + invalidate_main_ui_adaptor(); + ui_manager::redraw_invalidated(); + refresh_display(); } } @@ -10721,7 +10701,6 @@ void game::vertical_move( int movez, bool force ) } m.invalidate_map_cache( g->get_levz() ); - refresh_all(); // Upon force movement, traps can not be avoided. m.creature_on_trap( u, !force ); diff --git a/src/game.h b/src/game.h index b55fc17555c37..ec3d8d3ef8969 100644 --- a/src/game.h +++ b/src/game.h @@ -547,7 +547,6 @@ class game character_id assign_npc_id(); Creature *is_hostile_nearby(); Creature *is_hostile_very_close(); - void refresh_all(); // Handles shifting coordinates transparently when moving between submaps. // Helper to make calling with a player pointer less verbose. point update_map( player &p ); @@ -580,7 +579,9 @@ class game // Shared method to print "look around" info void print_all_tile_info( const tripoint &lp, const catacurses::window &w_look, const std::string &area_name, int column, - int &line, int last_line, bool draw_terrain_indicators, const visibility_variables &cache ); + int &line, int last_line, const visibility_variables &cache ); + + void draw_terrain_indicator( const tripoint &lp, const visibility_variables &cache ) const; /** Long description of (visible) things at tile. */ void extended_description( const tripoint &p ); @@ -845,7 +846,7 @@ class game int column, int &line, int last_line ); void print_visibility_info( const catacurses::window &w_look, int column, int &line, visibility_type visibility ); - void print_visibility_indicator( visibility_type visibility ); + void print_visibility_indicator( visibility_type visibility ) const; void print_items_info( const tripoint &lp, const catacurses::window &w_look, int column, int &line, int last_line ); void print_graffiti_info( const tripoint &lp, const catacurses::window &w_look, int column, @@ -1049,8 +1050,8 @@ class game bool npcs_dirty = false; /** Has anything died in this turn and needs to be cleaned up? */ bool critter_died = false; - /** Was the player sleeping during this turn. */ - bool player_was_sleeping = false; + /** Is this the first redraw since waiting (sleeping or activity) started */ + bool first_redraw_since_waiting_started = true; /** Is Zone manager open or not - changes graphics of some zone tiles */ bool zones_manager_open = false; diff --git a/src/game_inventory.cpp b/src/game_inventory.cpp index cd7c0b8ef0136..6fd14fd68d518 100644 --- a/src/game_inventory.cpp +++ b/src/game_inventory.cpp @@ -228,10 +228,7 @@ void game_menus::inv::common( avatar &you ) } } - g->refresh_all(); res = g->inventory_item_menu( location ); - g->refresh_all(); - } while( loop_options.count( res ) != 0 ); } @@ -264,10 +261,7 @@ void game_menus::inv::common( item_location &loc, avatar &you ) } } - g->refresh_all(); res = g->inventory_item_menu( location ); - g->refresh_all(); - } while( loop_options.count( res ) != 0 ); } @@ -1602,7 +1596,6 @@ void game_menus::inv::swap_letters( player &p ) } reassign_letter( p, *loc ); - g->refresh_all(); } } diff --git a/src/gamemode_tutorial.cpp b/src/gamemode_tutorial.cpp index 1e15a38923087..bb88f2961064b 100644 --- a/src/gamemode_tutorial.cpp +++ b/src/gamemode_tutorial.cpp @@ -327,7 +327,7 @@ void tutorial_game::add_message( tut_lesson lesson ) return; } tutorials_seen[lesson] = true; + g->invalidate_main_ui_adaptor(); popup( SNIPPET.get_snippet_by_id( snippet_id( io::enum_to_string( lesson ) ) ).value_or( translation() ).translated(), PF_ON_TOP ); - g->refresh_all(); } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index e45859a95c101..8a0c6383e5ffb 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -69,6 +69,7 @@ #include "string_id.h" #include "translations.h" #include "ui.h" +#include "ui_manager.h" #include "units.h" #include "veh_type.h" #include "vehicle.h" @@ -247,7 +248,17 @@ input_context game::get_player_input( std::string &action ) wPrint.vdrops.clear(); ctxt.set_timeout( 125 ); - bool initial_draw = true; + + shared_ptr_fast animation_cb = + make_shared_fast( [&]() { + draw_weather( wPrint ); + + if( uquit != QUIT_WATCH ) { + draw_sct(); + } + } ); + add_draw_callback( animation_cb ); + do { if( bWeatherEffect && get_option( "ANIMATION_RAIN" ) ) { /* @@ -257,24 +268,8 @@ input_context game::get_player_input( std::string &action ) WEATHER_DRIZZLE | WEATHER_LIGHT_DRIZZLE | WEATHER_RAINY | WEATHER_THUNDER | WEATHER_LIGHTNING = "weather_rain_drop" WEATHER_FLURRIES | WEATHER_SNOW | WEATHER_SNOWSTORM = "weather_snowflake" */ + invalidate_main_ui_adaptor(); -#if defined(TILES) - if( !use_tiles ) { -#endif //TILES - //If not using tiles, erase previous drops from w_terrain - for( auto &elem : wPrint.vdrops ) { - const tripoint location( elem.first + offset_x, elem.second + offset_y, get_levz() ); - const lit_level lighting = visibility_cache[location.x][location.y]; - wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { - m.drawsq( w_terrain, u, location, false, true, - u.pos() + u.view_offset, - lighting == lit_level::LOW, lighting == lit_level::BRIGHT ); - } - } -#if defined(TILES) - } -#endif //TILES wPrint.vdrops.clear(); for( int i = 0; i < dropCount; i++ ) { @@ -296,28 +291,7 @@ input_context game::get_player_input( std::string &action ) } // don't bother calculating SCT if we won't show it if( uquit != QUIT_WATCH && get_option( "ANIMATION_SCT" ) ) { -#if defined(TILES) - if( !use_tiles ) { -#endif - for( auto &elem : SCT.vSCT ) { - //Erase previous text from w_terrain - if( elem.getStep() > 0 ) { - const int width = utf8_width( elem.getText() ); - for( int i = 0; i < width; ++i ) { - const tripoint location( elem.getPosX() + i, elem.getPosY(), get_levz() ); - const lit_level lighting = visibility_cache[location.x][location.y]; - wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { - m.drawsq( w_terrain, u, location, false, true, - u.pos() + u.view_offset, - lighting == lit_level::LOW, lighting == lit_level::BRIGHT ); - } - } - } - } -#if defined(TILES) - } -#endif + invalidate_main_ui_adaptor(); SCT.advanceAllSteps(); @@ -348,27 +322,15 @@ input_context game::get_player_input( std::string &action ) } } - if( initial_draw ) { - werase( w_terrain ); - - draw_ter(); - initial_draw = false; - } - draw_weather( wPrint ); - - if( uquit != QUIT_WATCH ) { - draw_sct(); - } - - wrefresh( w_terrain ); - g->draw_panels(); - + std::unique_ptr deathcam_msg_popup; if( uquit == QUIT_WATCH ) { - query_popup() - .wait_message( c_red, _( "Press %s to accept your fate…" ), ctxt.get_desc( "QUIT" ) ) - .on_top( true ) - .show(); + deathcam_msg_popup = std::make_unique(); + deathcam_msg_popup + ->wait_message( c_red, _( "Press %s to accept your fate…" ), ctxt.get_desc( "QUIT" ) ) + .on_top( true ); } + + ui_manager::redraw_invalidated(); } while( handle_mouseview( ctxt, action ) && uquit != QUIT_WATCH && ( action != "TIMEOUT" || !current_turn.has_timeout_elapsed() ) ); ctxt.reset_timeout(); @@ -1293,16 +1255,12 @@ static void read() static void reach_attack( avatar &you ) { g->temp_exit_fullscreen(); - g->m.draw( g->w_terrain, you.pos() ); target_handler::trajectory traj = target_handler::mode_reach( you, you.weapon ); if( !traj.empty() ) { you.reach_attack( traj.back() ); } - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels(); g->reenter_fullscreen(); } @@ -1551,7 +1509,6 @@ bool game::handle_action() if( act == ACTION_KEYBINDINGS ) { // already handled by input context - refresh_all(); return false; } @@ -2096,16 +2053,13 @@ bool game::handle_action() break; case ACTION_BIONICS: u.power_bionics(); - refresh_all(); break; case ACTION_MUTATIONS: u.power_mutations(); - refresh_all(); break; case ACTION_SORT_ARMOR: u.sort_armor(); - refresh_all(); break; case ACTION_WAIT: @@ -2149,7 +2103,6 @@ bool game::handle_action() add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); } else { u.disassemble(); - refresh_all(); } break; @@ -2255,7 +2208,6 @@ bool game::handle_action() uquit = QUIT_SUICIDE; } } - refresh_all(); break; case ACTION_SAVE: @@ -2265,7 +2217,6 @@ bool game::handle_action() uquit = QUIT_SAVED; } } - refresh_all(); break; case ACTION_QUICKSAVE: @@ -2281,13 +2232,11 @@ bool game::handle_action() break; case ACTION_MAP: - werase( w_terrain ); ui::omap::display(); break; case ACTION_SKY: if( m.is_outside( u.pos() ) ) { - werase( w_terrain ); ui::omap::display_visible_weather(); } else { add_msg( m_info, _( "You can't see the sky from here." ) ); @@ -2308,17 +2257,14 @@ bool game::handle_action() case ACTION_MORALE: u.disp_morale(); - refresh_all(); break; case ACTION_MESSAGES: Messages::display_messages(); - refresh_all(); break; case ACTION_HELP: get_help().display_help(); - refresh_all(); break; case ACTION_OPTIONS: @@ -2327,27 +2273,22 @@ bool game::handle_action() case ACTION_AUTOPICKUP: get_auto_pickup().show(); - refresh_all(); break; case ACTION_AUTONOTES: get_auto_notes_settings().show_gui(); - refresh_all(); break; case ACTION_SAFEMODE: get_safemode().show(); - refresh_all(); break; case ACTION_COLOR: all_colors.show_gui(); - refresh_all(); break; case ACTION_WORLD_MODS: world_generator->show_active_world_mods( world_generator->active_world->active_mod_order ); - refresh_all(); break; case ACTION_DEBUG: diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 0a83c2c895a14..2282364a9ae65 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -263,7 +263,6 @@ static bool get_liquid_target( item &liquid, item *const source, const int radiu const std::string liqstr = string_format( _( "Pour %s where?" ), liquid_name ); - g->refresh_all(); const cata::optional target_pos_ = choose_adjacent( liqstr ); if( !target_pos_ ) { return; @@ -291,7 +290,6 @@ static bool get_liquid_target( item &liquid, item *const source, const int radiu } menu.query(); - g->refresh_all(); if( menu.ret < 0 || static_cast( menu.ret ) >= actions.size() ) { add_msg( _( "Never mind." ) ); // Explicitly canceled all options (container, drink, pour). diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 0cf3317669e0d..3190c81a6878f 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -411,7 +411,6 @@ class atm_menu if( !u.activity.is_null() ) { break; } - g->draw(); } } private: diff --git a/src/init.cpp b/src/init.cpp index cb09ff8c097c4..20132236b1e48 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -725,6 +725,4 @@ void DynamicDataLoader::check_consistency( loading_ui &ui ) e.second(); ui.proceed(); } - catacurses::erase(); - catacurses::refresh(); } diff --git a/src/input.cpp b/src/input.cpp index 7e17cb6682190..5dc523b7d9633 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1282,8 +1282,6 @@ action_id input_context::display_menu( const bool permit_execute_action ) } else if( changed ) { inp_mngr.action_contexts.swap( old_action_contexts ); } - werase( w_help ); - wrefresh( w_help ); return action_to_execute; } diff --git a/src/item_action.cpp b/src/item_action.cpp index 732a85669747a..d9b773b4917c0 100644 --- a/src/item_action.cpp +++ b/src/item_action.cpp @@ -337,10 +337,6 @@ void game::item_action_menu() return; } - draw_ter(); - wrefresh( w_terrain ); - draw_panels( true ); - const item_action_id action = std::get<0>( menu_items[kmenu.ret] ); item *it = iactions[action]; diff --git a/src/iuse.cpp b/src/iuse.cpp index 3617beeb9d88e..d8e6199b61355 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1528,7 +1528,7 @@ int iuse::mycus( player *p, item *it, bool t, const tripoint &pos ) p->fall_asleep( 5_hours - p->int_cur * 1_minutes ); p->unset_mutation( trait_THRESH_MARLOSS ); p->set_mutation( trait_THRESH_MYCUS ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); //~ The Mycus does not use the term (or encourage the concept of) "you". The PC is a local/native organism, but is now the Mycus. //~ It still understands the concept, but uninitelligent fungaloids and mind-bent symbiotes should not need it. //~ We are the Mycus. @@ -1536,22 +1536,22 @@ int iuse::mycus( player *p, item *it, bool t, const tripoint &pos ) p->add_msg_if_player( " " ); p->add_msg_if_player( m_good, _( "A sea of white caps, waving gently. A haze of spores wafting silently over a forest." ) ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); popup( _( "The natives have a saying: \"E Pluribus Unum.\" Out of many, one." ) ); p->add_msg_if_player( " " ); p->add_msg_if_player( m_good, _( "The blazing pink redness of the berry. The juices spreading across your tongue, the warmth draping over us like a lover's embrace." ) ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); popup( _( "We welcome the union of our lines in our local guide. We will prosper, and unite this world. Even now, our fruits adapt to better serve local physiology." ) ); p->add_msg_if_player( " " ); p->add_msg_if_player( m_good, _( "The sky-blue of the seed. The nutty, creamy flavors intermingling with the berry, a memory that will never leave us." ) ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); popup( _( "As, in time, shall we adapt to better welcome those who have not received us." ) ); p->add_msg_if_player( " " ); p->add_msg_if_player( m_good, _( "The amber-yellow of the sap. Feel it flowing through our veins, taking the place of the strange, thin red gruel called \"blood.\"" ) ); - g->refresh_all(); + g->invalidate_main_ui_adaptor(); popup( _( "We are the Mycus." ) ); /*p->add_msg_if_player( m_good, _( "We welcome into us. We have endured long in this forbidding world." ) ); @@ -1997,7 +1997,6 @@ int iuse::extinguisher( player *p, item *it, bool, const tripoint & ) if( !it->ammo_sufficient() ) { return 0; } - g->draw(); // If anyone other than the player wants to use one of these, // they're going to need to figure out how to aim it. const cata::optional dest_ = choose_adjacent( _( "Spray where?" ) ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 2bb3e610b7769..67c93f0a84f91 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1251,7 +1251,6 @@ bool firestarter_actor::prep_firestarter_use( const player &p, tripoint &pos ) if( const cata::optional pnt_ = choose_adjacent( _( "Light where?" ) ) ) { pos = *pnt_; } else { - g->refresh_all(); return false; } } diff --git a/src/magic_teleporter_list.cpp b/src/magic_teleporter_list.cpp index 0298279beb683..d7235d3e177b0 100644 --- a/src/magic_teleporter_list.cpp +++ b/src/magic_teleporter_list.cpp @@ -183,7 +183,6 @@ class teleporter_callback : public uilist_callback cata::optional teleporter_list::choose_teleport_location() { cata::optional ret = cata::nullopt; - g->refresh_all(); uilist teleport_selector; teleport_selector.w_height_setup = 24; diff --git a/src/main.cpp b/src/main.cpp index 963b59ba27c1e..a2073d9126148 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -754,8 +754,6 @@ void exit_handler( int s ) const int old_timeout = inp_mngr.get_timeout(); inp_mngr.reset_timeout(); if( s != 2 || query_yn( _( "Really Quit? All unsaved changes will be lost." ) ) ) { - catacurses::erase(); // Clear screen - deinitDebug(); int exit_status = 0; diff --git a/src/main_menu.cpp b/src/main_menu.cpp index 4ff82a01530ac..c5fb95c8407d9 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -218,9 +218,7 @@ void main_menu::print_menu( const catacurses::window &w_open, int iSel, const po print_menu_items( w_open, vMenuItems, iSel, point( final_offset, offset.y ), spacing ); - catacurses::refresh(); wrefresh( w_open ); - catacurses::refresh(); } std::vector main_menu::load_file( const std::string &path, @@ -457,7 +455,6 @@ void main_menu::display_text( const std::string &text, const std::string &title, draw_scrollbar( w_border, selected, height, iLines, point_south, BORDER_COLOR, true ); wrefresh( w_border ); wrefresh( w_text ); - catacurses::refresh(); } void main_menu::load_char_templates() @@ -487,9 +484,7 @@ bool main_menu::opening_screen() world_generator->init(); get_help().load(); - init_windows(); init_strings(); - print_menu( w_open, 0, menu_offset ); if( !assure_dir_exist( PATH_INFO::config_dir() ) ) { popup( _( "Unable to make config directory. Check permissions." ) ); @@ -595,7 +590,7 @@ bool main_menu::opening_screen() init_windows(); ui.position_from_window( w_open ); } ); - ui.position_from_window( w_open ); + ui.mark_resize(); while( !start ) { ui_manager::redraw(); @@ -783,10 +778,6 @@ bool main_menu::opening_screen() } } } - if( start ) { - g->refresh_all(); - g->draw(); - } return start; } diff --git a/src/map.cpp b/src/map.cpp index 2446ec7097287..291082cf23e8d 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -84,6 +84,7 @@ #include "timed_event.h" #include "translations.h" #include "trap.h" +#include "ui_manager.h" #include "value_ptr.h" #include "veh_type.h" #include "vehicle.h" @@ -681,7 +682,8 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac // Redraw scene // But only if the vehicle was seen before or after the move if( seen || sees_veh( g->u, veh, true ) ) { - g->draw(); + g->invalidate_main_ui_adaptor(); + ui_manager::redraw_invalidated(); refresh_display(); } return new_vehicle; diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index 7353d3544b7f0..133717506e8a2 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -671,10 +671,6 @@ bool talk_function::handle_outpost_mission( const mission_entry &cur_key, npc &p forage_return( p ); } - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels( true ); - return true; } diff --git a/src/monattack.cpp b/src/monattack.cpp index dc4304980d5b8..925a5f75f3bf2 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -75,6 +75,7 @@ #include "translations.h" #include "type_id.h" #include "ui.h" +#include "ui_manager.h" #include "units.h" #include "value_ptr.h" #include "weighted_list.h" @@ -2672,7 +2673,9 @@ bool mattack::ranged_pull( monster *z ) target->setpos( pt ); range--; if( target->is_player() && seen ) { - g->draw(); + g->invalidate_main_ui_adaptor(); + ui_manager::redraw_invalidated(); + refresh_display(); } } // The monster might drag a target that's not on it's z level diff --git a/src/mutation.cpp b/src/mutation.cpp index 80d69f478e76d..62e1cafa97a2b 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -625,7 +625,6 @@ void Character::activate_mutation( const trait_id &mut ) return; } else if( !mdata.ranged_mutation.is_empty() ) { add_msg_if_player( mdata.ranged_mutation_message() ); - g->refresh_all(); avatar_action::fire_ranged_mutation( g->u, item( mdata.ranged_mutation ) ); tdata.powered = false; return; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index b331ed33886c7..f6dc8e82dbf34 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -279,7 +279,6 @@ static void npc_temp_orders_menu( const std::vector &npc_list ) output_string += std::string( "\n" ) + _( "Other followers might have different temporary orders." ); } - g->refresh_all(); nmenu.reset(); nmenu.text = _( "Issue what temporary order?" ); nmenu.desc_enabled = true; @@ -623,7 +622,6 @@ void game::chat() } u.moves -= 100; - refresh_all(); } void npc::handle_sound( const sounds::sound_t spriority, const std::string &description, @@ -879,7 +877,6 @@ void npc::talk_to_u( bool text_only, bool radio_contact ) d.add_topic( next ); } } while( !d.done ); - g->refresh_all(); if( g->u.activity.id() == ACT_AIM && !g->u.has_weapon() ) { g->u.cancel_activity(); diff --git a/src/npctrade.cpp b/src/npctrade.cpp index f196c0dff6dc3..c77e951feb9af 100644 --- a/src/npctrade.cpp +++ b/src/npctrade.cpp @@ -699,7 +699,6 @@ bool npc_trading::trade( npc &np, int cost, const std::string &deal ) g->u.practice( skill_barter, practice / 10000 ); } } - g->refresh_all(); return traded; } diff --git a/src/options.cpp b/src/options.cpp index 225c50245070b..1d05b17e0f4cd 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2501,9 +2501,6 @@ static void refresh_tiles( bool used_tiles_changed, bool pixel_minimap_height_ch tilecontext->load_tileset( get_option( "TILES" ) ); //g->init_ui is called when zoom is changed g->reset_zoom(); - if( ingame ) { - g->refresh_all(); - } tilecontext->do_tile_loading_report(); } catch( const std::exception &err ) { popup( _( "Loading the tileset failed: %s" ), err.what() ); diff --git a/src/output.cpp b/src/output.cpp index 012ca0df7af7c..f43d7178638f7 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -336,14 +336,6 @@ int fold_and_print_from( const catacurses::window &w, const point &begin, int wi return textformatted.size(); } -void scrollable_text( const catacurses::window &w, const std::string &title, - const std::string &text ) -{ - scrollable_text( [&w]() { - return w; - }, title, text ); -} - void scrollable_text( const std::function &init_window, const std::string &title, const std::string &text ) { diff --git a/src/output.h b/src/output.h index b3f378232d73a..1f0def0b404df 100644 --- a/src/output.h +++ b/src/output.h @@ -326,8 +326,6 @@ int right_print( const catacurses::window &w, int line, int right_indent, void insert_table( const catacurses::window &w, int pad, int line, int columns, const nc_color &FG, const std::string ÷r, bool r_align, const std::vector &data ); -void scrollable_text( const catacurses::window &w, const std::string &title, - const std::string &text ); void scrollable_text( const std::function &init_window, const std::string &title, const std::string &text ); std::string name_and_value( const std::string &name, int value, int field_width ); diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 22932bf09bc90..43f5ef4976437 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -1404,6 +1404,8 @@ static void place_ter_or_special( const ui_adaptor &om_ui, tripoint &curs, static tripoint display( const tripoint &orig, const draw_data_t &data = draw_data_t() ) { + background_pane bg_pane; + ui_adaptor ui; ui.on_screen_resize( []( ui_adaptor & ui ) { /** diff --git a/src/popup.cpp b/src/popup.cpp index 7c96ec58851b0..27668d3702aba 100644 --- a/src/popup.cpp +++ b/src/popup.cpp @@ -350,11 +350,6 @@ query_popup::result query_popup::query() do { res = query_once(); } while( res.wait_input ); - // Erase the window so there's feedback during consecutive popups - werase( win ); - wrefresh( win ); - catacurses::refresh(); - refresh_display(); return res; } diff --git a/src/ranged.cpp b/src/ranged.cpp index a9e5a51cb21d7..058b66414df60 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -1885,6 +1885,9 @@ target_handler::trajectory target_ui::run() draw_turret_lines = vturrets->size() == 1; } + on_out_of_scope cleanup( []() { + g->m.invalidate_map_cache( g->u.pos().z + g->u.view_offset.z ); + } ); restore_on_out_of_scope view_offset_prev( g->u.view_offset ); shared_ptr_fast target_ui_cb = make_shared_fast( @@ -2520,7 +2523,6 @@ void target_ui::set_view_offset( const tripoint &new_offset ) // We need to do a bunch of cache updates since we're // looking at a different z-level. g->m.invalidate_map_cache( new_z ); - g->refresh_all(); } } diff --git a/src/string_input_popup.cpp b/src/string_input_popup.cpp index 3c87c98dfa301..5c2351e0d24b5 100644 --- a/src/string_input_popup.cpp +++ b/src/string_input_popup.cpp @@ -146,8 +146,6 @@ void string_input_popup::show_history( utf8_wrapper &ret ) finished = true; } } while( !finished ); - werase( hmenu.window ); - wrefresh( hmenu.window ); } } diff --git a/src/translations.cpp b/src/translations.cpp index b48f2dd6af4a6..94b704d0f9a42 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -153,8 +153,6 @@ void select_language() return lang.first.empty() || lang.second.empty(); } ), languages.end() ); - wrefresh( catacurses::stdscr ); - uilist sm; sm.allow_cancel = false; sm.text = _( "Select your language" ); diff --git a/src/ui.cpp b/src/ui.cpp index fe0fdacb46ce5..a5eda05d0fe0b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -223,7 +223,7 @@ void uilist::filterlist() fentries.push_back( i ); if( i == selected && ( hilight_disabled || entries[i].enabled ) ) { fselected = f; - } else if( i > selected && fselected == -1 ) { + } else if( i > selected && fselected == -1 && ( hilight_disabled || entries[i].enabled ) ) { // Past the previously selected entry, which has been filtered out, // choose another nearby entry instead. fselected = f; diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 2672d28297b63..aa6cdcb36a616 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -1861,7 +1861,6 @@ void vehicle::use_bike_rack( int part ) } if( success ) { g->m.invalidate_map_cache( g->get_levz() ); - g->refresh_all(); } } diff --git a/src/wincurse.cpp b/src/wincurse.cpp index bb651d6e4a17c..13ca9ee9bc7fc 100644 --- a/src/wincurse.cpp +++ b/src/wincurse.cpp @@ -188,7 +188,6 @@ bool handle_resize( int, int ) if( SetDIBColorTable( backbuffer, 0, windowsPalette.size(), windowsPalette.data() ) == 0 ) { throw std::runtime_error( "SetDIBColorTable failed" ); } - catacurses::refresh(); ui_manager::screen_resized(); } diff --git a/src/wish.cpp b/src/wish.cpp index 334635fef117f..8ccbe89d9c1fe 100644 --- a/src/wish.cpp +++ b/src/wish.cpp @@ -674,9 +674,6 @@ void debug_menu::wishskill( player *p ) sksetmenu.addentry( i, true, i + 48, "%d%s", i, skcur == i ? _( " (current)" ) : "" ); } sksetmenu.query(); - g->draw_ter(); - wrefresh( g->w_terrain ); - g->draw_panels( true ); skset = sksetmenu.ret; } diff --git a/src/worldfactory.cpp b/src/worldfactory.cpp index d0218f931bc63..0598802fe18d7 100644 --- a/src/worldfactory.cpp +++ b/src/worldfactory.cpp @@ -1304,7 +1304,6 @@ void worldfactory::draw_modselection_borders( const catacurses::window &win, ctxtp.get_desc( "HELP_KEYBINDINGS" ) ); wrefresh( win ); - catacurses::refresh(); } void worldfactory::draw_worldgen_tabs( const catacurses::window &w, size_t current ) diff --git a/tests/vehicle_power_test.cpp b/tests/vehicle_power_test.cpp index 0729c45afa4a4..79a5d8d546da1 100644 --- a/tests/vehicle_power_test.cpp +++ b/tests/vehicle_power_test.cpp @@ -37,7 +37,6 @@ TEST_CASE( "vehicle power with reactor and solar panels", "[vehicle][power]" ) const tripoint reactor_origin = tripoint( 10, 10, 0 ); vehicle *veh_ptr = g->m.add_vehicle( vproto_id( "reactor_test" ), reactor_origin, 0, 0, 0 ); REQUIRE( veh_ptr != nullptr ); - g->refresh_all(); REQUIRE( !veh_ptr->reactors.empty() ); vehicle_part &reactor = veh_ptr->parts[ veh_ptr->reactors.front() ]; @@ -66,7 +65,6 @@ TEST_CASE( "vehicle power with reactor and solar panels", "[vehicle][power]" ) const tripoint solar_origin = tripoint( 5, 5, 0 ); vehicle *veh_ptr = g->m.add_vehicle( vproto_id( "solar_panel_test" ), solar_origin, 0, 0, 0 ); REQUIRE( veh_ptr != nullptr ); - g->refresh_all(); GIVEN( "it is 3 hours after sunrise, with sunny weather" ) { calendar::turn = calendar::turn_zero + calendar::season_length() + 1_days; @@ -131,7 +129,6 @@ TEST_CASE( "maximum reverse velocity", "[vehicle][power][reverse]" ) const tripoint origin = tripoint( 10, 0, 0 ); vehicle *veh_ptr = g->m.add_vehicle( vproto_id( "scooter_test" ), origin, 0, 0, 0 ); REQUIRE( veh_ptr != nullptr ); - g->refresh_all(); veh_ptr->charge_battery( 500 ); REQUIRE( veh_ptr->fuel_left( fuel_type_battery ) == 500 ); @@ -157,7 +154,6 @@ TEST_CASE( "maximum reverse velocity", "[vehicle][power][reverse]" ) const tripoint origin = tripoint( 15, 0, 0 ); vehicle *veh_ptr = g->m.add_vehicle( vproto_id( "scooter_electric_test" ), origin, 0, 0, 0 ); REQUIRE( veh_ptr != nullptr ); - g->refresh_all(); veh_ptr->charge_battery( 5000 ); REQUIRE( veh_ptr->fuel_left( fuel_type_battery ) == 5000 ); diff --git a/tests/vehicle_split_test.cpp b/tests/vehicle_split_test.cpp index 1f3a022d82b5c..100c5cbe047fa 100644 --- a/tests/vehicle_split_test.cpp +++ b/tests/vehicle_split_test.cpp @@ -23,7 +23,6 @@ TEST_CASE( "vehicle_split_section" ) veh_ptr = vehs_v.v; g->m.destroy_vehicle( veh_ptr ); } - g->refresh_all(); REQUIRE( g->m.get_vehicles().empty() ); veh_ptr = g->m.add_vehicle( vproto_id( "cross_split_test" ), vehicle_origin, dir, 0, 0 ); REQUIRE( veh_ptr != nullptr ); @@ -65,7 +64,6 @@ TEST_CASE( "vehicle_split_section" ) g->m.destroy_vehicle( vehs[ 1 ].v ); g->m.destroy_vehicle( vehs[ 0 ].v ); } - g->refresh_all(); REQUIRE( g->m.get_vehicles().empty() ); vehicle_origin = tripoint( 20, 20, 0 ); veh_ptr = g->m.add_vehicle( vproto_id( "circle_split_test" ), vehicle_origin, dir, 0, 0 );