Fix a few divisions by zero, see #2727
This commit is contained in:
parent
5f4bef044b
commit
68fe1e58c2
@ -144,8 +144,8 @@ void RibbonWidget::add()
|
||||
//int biggest_y = 0;
|
||||
const int button_y = 10;
|
||||
|
||||
const int one_button_space =
|
||||
int(roundf((float)m_w / (float)subbuttons_amount));
|
||||
const int one_button_space = (subbuttons_amount == 0 ? m_w :
|
||||
int(roundf((float)m_w / (float)subbuttons_amount)));
|
||||
|
||||
int widget_x = -1;
|
||||
|
||||
|
@ -118,15 +118,19 @@ float MainLoop::getLimitedDt()
|
||||
// the noise the fan on a graphics card makes.
|
||||
// When in menus, reduce FPS much, it's not necessary to push to the maximum for plain menus
|
||||
const int max_fps = (StateManager::get()->throttleFPS() ? 30 : UserConfigParams::m_max_fps);
|
||||
const int current_fps = (int)(1000.0f/dt);
|
||||
if (m_throttle_fps && current_fps > max_fps && !ProfileWorld::isProfileMode())
|
||||
if (dt > 0)
|
||||
{
|
||||
int wait_time = 1000/max_fps - 1000/current_fps;
|
||||
if(wait_time < 1) wait_time = 1;
|
||||
const int current_fps = (int)(1000.0f / dt);
|
||||
if (m_throttle_fps && current_fps > max_fps && !ProfileWorld::isProfileMode())
|
||||
{
|
||||
int wait_time = 1000 / max_fps - 1000 / current_fps;
|
||||
if (wait_time < 1) wait_time = 1;
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Throttle framerate", 0, 0, 0);
|
||||
StkTime::sleep(wait_time);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_PUSH_CPU_MARKER("Throttle framerate", 0, 0, 0);
|
||||
StkTime::sleep(wait_time);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
else break;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user