mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Replace cl_cpu_throttle with cl_refresh_rate
This commit is contained in:
parent
4125941896
commit
8553ed727b
|
@ -2755,6 +2755,8 @@ void CClient::Run()
|
|||
bool LastE = false;
|
||||
bool LastG = false;
|
||||
|
||||
int64 LastTime = time_get();
|
||||
|
||||
while (1)
|
||||
{
|
||||
set_new_tick();
|
||||
|
@ -2908,15 +2910,20 @@ void CClient::Run()
|
|||
#endif
|
||||
|
||||
// beNice
|
||||
int64 Now = time_get();
|
||||
if(
|
||||
#ifdef CONF_DEBUG
|
||||
if(g_Config.m_DbgStress)
|
||||
thread_sleep(g_Config.m_ClCpuThrottleInactive);
|
||||
g_Config.m_DbgStress ||
|
||||
#endif
|
||||
if(g_Config.m_ClCpuThrottleInactive && !m_pGraphics->WindowActive())
|
||||
thread_sleep(g_Config.m_ClCpuThrottleInactive);
|
||||
else if(g_Config.m_ClCpuThrottle)
|
||||
net_socket_read_wait(m_NetClient[0].m_Socket, g_Config.m_ClCpuThrottle * 1000);
|
||||
//thread_sleep(g_Config.m_ClCpuThrottle);
|
||||
(g_Config.m_ClRefreshRateInactive && !m_pGraphics->WindowActive()))
|
||||
{
|
||||
thread_sleep(max(1000000 * (LastTime + time_freq() / g_Config.m_ClRefreshRateInactive - Now) / time_freq(), (int64)0));
|
||||
}
|
||||
else if(g_Config.m_ClRefreshRate)
|
||||
{
|
||||
net_socket_read_wait(m_NetClient[0].m_Socket, max(1000000 * (LastTime + time_freq() / g_Config.m_ClRefreshRate - Now) / time_freq(), (int64)0));
|
||||
}
|
||||
LastTime = Now;
|
||||
|
||||
if(g_Config.m_DbgHitch)
|
||||
{
|
||||
|
|
|
@ -15,8 +15,8 @@ MACRO_CONFIG_STR(Logfile, logfile, 128, "", CFGFLAG_SAVE|CFGFLAG_CLIENT|CFGFLAG_
|
|||
MACRO_CONFIG_INT(ConsoleOutputLevel, console_output_level, 0, 0, 2, CFGFLAG_CLIENT|CFGFLAG_SERVER, "Adjusts the amount of information in the console")
|
||||
|
||||
MACRO_CONFIG_INT(ClSaveSettings, cl_save_settings, 1, 0, 1, CFGFLAG_CLIENT, "Write the settings file on exit")
|
||||
MACRO_CONFIG_INT(ClCpuThrottle, cl_cpu_throttle, 0, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(ClCpuThrottleInactive, cl_cpu_throttle_inactive, 5, 0, 100, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(ClRefreshRate, cl_refresh_rate, 0, 0, 10000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Refresh rate for updating the game (in Hz)")
|
||||
MACRO_CONFIG_INT(ClRefreshRateInactive, cl_refresh_rate_inactive, 0, 0, 10000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Refresh rate for updating the game when the window is inactive (in Hz)")
|
||||
MACRO_CONFIG_INT(ClEditor, cl_editor, 0, 0, 1, CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(ClEditorUndo, cl_editorundo, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Undo function in editor")
|
||||
MACRO_CONFIG_INT(ClLoadCountryFlags, cl_load_country_flags, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Load and show country flags")
|
||||
|
|
|
@ -202,14 +202,14 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|||
Left.HSplitTop(20.0f, &Label, &Left);
|
||||
Button.VSplitRight(20.0f, &Button, 0);
|
||||
char aBuf[64];
|
||||
if(g_Config.m_ClCpuThrottle)
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("CPU Throttle"), g_Config.m_ClCpuThrottle);
|
||||
if(g_Config.m_ClRefreshRate)
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_ClRefreshRate);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("CPU Throttle"), Localize("none"));
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), Localize("no limit"));
|
||||
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
||||
Left.HSplitTop(20.0f, &Button, 0);
|
||||
Button.HMargin(2.0f, &Button);
|
||||
g_Config.m_ClCpuThrottle= static_cast<int>(DoScrollbarH(&g_Config.m_ClCpuThrottle, &Button, g_Config.m_ClCpuThrottle/100.0f)*100.0f+0.1f);
|
||||
g_Config.m_ClRefreshRate= static_cast<int>(DoScrollbarH(&g_Config.m_ClRefreshRate, &Button, g_Config.m_ClRefreshRate/10000.0f)*10000.0f+0.1f);
|
||||
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
Left.HSplitTop(20.0f, 0, &Left);
|
||||
|
@ -991,7 +991,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
|
||||
MainView.HSplitTop(20.0f, &Label, &MainView);
|
||||
Label.VSplitLeft(130.0f, &Label, &Button);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Refresh Rate"), g_Config.m_GfxRefreshRate);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_GfxRefreshRate);
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
||||
Button.HMargin(2.0f, &Button);
|
||||
g_Config.m_GfxRefreshRate = static_cast<int>(DoScrollbarH(&g_Config.m_GfxRefreshRate, &Button, g_Config.m_GfxRefreshRate/1000.0f)*1000.0f+0.1f);
|
||||
|
|
Loading…
Reference in a new issue