mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-23 18:48:15 +00:00
Remove 200ms delay in gameloop processing when window is not visible
If we need this, it should, as the comment says, be implemented as part of the draw manager. But it also seems like any optimizations on this front are better left to the OS and its compositor.
This commit is contained in:
parent
8b14612fbe
commit
34c1c0f61c
@ -406,7 +406,7 @@ bool controller_base::handle_scroll(int mousex, int mousey, int mouse_flags)
|
||||
return true;
|
||||
}
|
||||
|
||||
void controller_base::play_slice(bool is_delay_enabled)
|
||||
void controller_base::play_slice()
|
||||
{
|
||||
CKey key;
|
||||
|
||||
@ -454,11 +454,6 @@ void controller_base::play_slice(bool is_delay_enabled)
|
||||
|
||||
map_location highlighted_hex = get_display().mouseover_hex();
|
||||
|
||||
// be nice when window is not visible // NOTE should be handled by display instead, to only disable drawing
|
||||
if(is_delay_enabled && !video::window_is_visible()) {
|
||||
SDL_Delay(200);
|
||||
}
|
||||
|
||||
// Scrolling ended, update the cursor and the brightened hex
|
||||
if(!scrolling_ && was_scrolling) {
|
||||
get_mouse_handler_base().mouse_update(is_browsing(), highlighted_hex);
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
controller_base();
|
||||
virtual ~controller_base();
|
||||
|
||||
virtual void play_slice(bool is_delay_enabled = true);
|
||||
virtual void play_slice();
|
||||
|
||||
void apply_keyboard_scroll(int x, int y);
|
||||
|
||||
|
@ -319,7 +319,7 @@ void playmp_controller::receive_actions()
|
||||
}
|
||||
|
||||
|
||||
void playmp_controller::play_slice(bool is_delay_enabled)
|
||||
void playmp_controller::play_slice()
|
||||
{
|
||||
if(!is_replay() && !network_processing_stopped_) {
|
||||
// receive chat during animations and delay
|
||||
@ -330,7 +330,7 @@ void playmp_controller::play_slice(bool is_delay_enabled)
|
||||
send_actions();
|
||||
}
|
||||
|
||||
playsingle_controller::play_slice(is_delay_enabled);
|
||||
playsingle_controller::play_slice();
|
||||
}
|
||||
|
||||
bool playmp_controller::is_networked_mp() const
|
||||
|
@ -38,8 +38,7 @@ public:
|
||||
void send_to_wesnothd(const config& cfg, const std::string& packet_type = "unknown") const override;
|
||||
bool receive_from_wesnothd(config& cfg) const override;
|
||||
|
||||
|
||||
void play_slice(bool is_delay_enabled = true) override;
|
||||
void play_slice() override;
|
||||
protected:
|
||||
virtual void handle_generic_event(const std::string& name) override;
|
||||
|
||||
|
@ -722,7 +722,7 @@ void playsingle_controller::play_network_turn()
|
||||
void playsingle_controller::handle_generic_event(const std::string& name)
|
||||
{
|
||||
if(name == "ai_user_interact") {
|
||||
play_slice(false);
|
||||
play_slice();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ void replay_controller::play_side_impl()
|
||||
stop_condition_->new_side_turn(controller_.current_side(), controller_.gamestate().tod_manager_.turn());
|
||||
}
|
||||
}
|
||||
controller_.play_slice(false);
|
||||
controller_.play_slice();
|
||||
|
||||
// Update the buttons once, on the transition from not-stopped to stopped.
|
||||
if(stop_condition_->should_stop()) {
|
||||
@ -189,7 +189,7 @@ void replay_controller::play_side_impl()
|
||||
// Don't move the update_enabled_buttons() call here. This play_slice() should block
|
||||
// until the next event occurs, but on X11/Linux update_enabled_buttons() seems to put
|
||||
// an event in the queue, turning this into a busy loop.
|
||||
controller_.play_slice(true);
|
||||
controller_.play_slice();
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -376,7 +376,7 @@ int game_lua_kernel::impl_run_animation(lua_State* L)
|
||||
}
|
||||
events::command_disabler command_disabler;
|
||||
unit_animator& anim = *static_cast<unit_animator*>(luaL_checkudata(L, 1, animatorKey));
|
||||
play_controller_.play_slice(false);
|
||||
play_controller_.play_slice();
|
||||
anim.start_animations();
|
||||
anim.wait_for_end();
|
||||
anim.set_all_standing();
|
||||
@ -4432,7 +4432,7 @@ int game_lua_kernel::intf_delay(lua_State *L)
|
||||
using namespace std::chrono_literals;
|
||||
std::chrono::milliseconds delay{luaL_checkinteger(L, 1)};
|
||||
if(delay == 0ms) {
|
||||
play_controller_.play_slice(false);
|
||||
play_controller_.play_slice();
|
||||
return 0;
|
||||
}
|
||||
if(luaW_toboolean(L, 2) && game_display_ && game_display_->turbo_speed() > 0) {
|
||||
@ -4440,7 +4440,7 @@ int game_lua_kernel::intf_delay(lua_State *L)
|
||||
}
|
||||
const auto end_time = std::chrono::steady_clock::now() + delay;
|
||||
do {
|
||||
play_controller_.play_slice(false);
|
||||
play_controller_.play_slice();
|
||||
std::this_thread::sleep_for(10ms);
|
||||
} while (std::chrono::steady_clock::now() < end_time);
|
||||
return 0;
|
||||
|
@ -1414,7 +1414,7 @@ void unit_animator::wait_until(const std::chrono::milliseconds& animation_time)
|
||||
display* disp = display::get_singleton();
|
||||
double speed = disp->turbo_speed();
|
||||
|
||||
resources::controller->play_slice(false);
|
||||
resources::controller->play_slice();
|
||||
|
||||
using std::chrono::steady_clock;
|
||||
auto end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
|
||||
@ -1424,7 +1424,7 @@ void unit_animator::wait_until(const std::chrono::milliseconds& animation_time)
|
||||
auto rest = std::chrono::floor<std::chrono::milliseconds>((animation_time - get_animation_time()) * speed);
|
||||
std::this_thread::sleep_for(std::clamp(rest, 0ms, 10ms));
|
||||
}
|
||||
resources::controller->play_slice(false);
|
||||
resources::controller->play_slice();
|
||||
end_tick = animated_units_[0].my_unit->anim_comp().get_animation()->time_to_tick(animation_time);
|
||||
}
|
||||
|
||||
@ -1443,7 +1443,7 @@ void unit_animator::wait_for_end() const
|
||||
|
||||
bool finished = false;
|
||||
while(!finished) {
|
||||
resources::controller->play_slice(false);
|
||||
resources::controller->play_slice();
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user