Configurable rate limit for SQL queries

This commit is contained in:
def 2017-04-13 09:33:26 +02:00
parent 407943a0a0
commit d4ed1310d2
2 changed files with 12 additions and 11 deletions

View file

@ -231,6 +231,7 @@ MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables sa
MACRO_CONFIG_INT(SvSaveGamesDelay, sv_savegames_delay, 60, 0, 10000, CFGFLAG_SERVER, "Delay in seconds for loading a savegame")
MACRO_CONFIG_STR(SvSqlFailureFile, sv_sql_failure_file, 64, "failed_sql.sql", CFGFLAG_SERVER, "File to store failed Sql-Inserts (ranks)")
MACRO_CONFIG_INT(SvSqlQueriesDelay, sv_sql_queries_delay, 1, 0, 20, CFGFLAG_SERVER, "Delay in seconds between SQL queries of a single player")
#endif
MACRO_CONFIG_INT(SvDDRaceRules, sv_ddrace_rules, 1, 0, 1, CFGFLAG_SERVER, "Whether the default mod rules are displayed or not")

View file

@ -341,7 +341,7 @@ void CGameContext::ConTeamTop5(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -372,7 +372,7 @@ void CGameContext::ConTop5(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -403,7 +403,7 @@ void CGameContext::ConTimes(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -495,7 +495,7 @@ void CGameContext::ConMap(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -519,7 +519,7 @@ void CGameContext::ConMapInfo(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -581,7 +581,7 @@ void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData)
}
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
int Team = ((CGameControllerDDRace*) pSelf->m_pController)->m_Teams.m_Core.Team(pResult->m_ClientID);
@ -636,7 +636,7 @@ void CGameContext::ConLoad(IConsole::IResult *pResult, void *pUserData)
}
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -663,7 +663,7 @@ void CGameContext::ConTeamRank(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -698,7 +698,7 @@ void CGameContext::ConRank(IConsole::IResult *pResult, void *pUserData)
#if defined(CONF_SQL)
if(g_Config.m_SvUseSQL)
if(pPlayer->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pPlayer->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
#endif
@ -1402,7 +1402,7 @@ void CGameContext::ConPoints(IConsole::IResult *pResult, void *pUserData)
return;
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
@ -1435,7 +1435,7 @@ void CGameContext::ConTopPoints(IConsole::IResult *pResult, void *pUserData)
return;
if(pSelf->m_apPlayers[pResult->m_ClientID] && g_Config.m_SvUseSQL)
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
if(pSelf->m_apPlayers[pResult->m_ClientID]->m_LastSQLQuery + g_Config.m_SvSqlQueriesDelay * pSelf->Server()->TickSpeed() >= pSelf->Server()->Tick())
return;
if (g_Config.m_SvHideScore)