Add sv_sql_validservernames (fixes #1123)

This commit is contained in:
def 2018-05-11 21:57:47 +02:00
parent 121c3b8076
commit a7b778977a
2 changed files with 23 additions and 3 deletions

View file

@ -230,6 +230,7 @@ MACRO_CONFIG_STR(SvScoreFolder, sv_score_folder, 32, "records", CFGFLAG_SERVER,
#if defined(CONF_SQL)
MACRO_CONFIG_INT(SvUseSQL, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables SQL DB instead of record file")
MACRO_CONFIG_STR(SvSqlServerName, sv_sql_servername, 5, "UNK", CFGFLAG_SERVER, "SQL Server name that is inserted into record table")
MACRO_CONFIG_STR(SvSqlValidServerNames, sv_sql_valid_servernames, 64, "UNK", CFGFLAG_SERVER, "Comma seperated list of valid server names for saving a game to ([A-Z][A-Z][A-Z].?")
MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables savegames (/save and /load)")
MACRO_CONFIG_INT(SvSaveGamesDelay, sv_savegames_delay, 60, 0, 10000, CFGFLAG_SERVER, "Delay in seconds for loading a savegame")

View file

@ -629,10 +629,29 @@ void CGameContext::ConSave(IConsole::IResult *pResult, void *pUserData)
str_copy(aCountry, g_Config.m_SvSqlServerName, sizeof(aCountry));
}
pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry);
char aValidServerNames[sizeof(g_Config.m_SvSqlValidServerNames)];
str_copy(aValidServerNames, g_Config.m_SvSqlValidServerNames, sizeof(aValidServerNames));
char *p = strtok(aValidServerNames, ",");;
while(p)
{
if(str_comp(p, aCountry) == 0)
{
pSelf->Score()->SaveTeam(Team, pCode, pResult->m_ClientID, aCountry);
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
return;
}
p = strtok(NULL, ",");
}
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "Unknown server name '%s'.", aCountry);
pSelf->SendChatTarget(pResult->m_ClientID, aBuf);
if(g_Config.m_SvUseSQL)
pPlayer->m_LastSQLQuery = pSelf->Server()->Tick();
#endif
}