Uncomment things in file_score. Add config variables

This commit is contained in:
btd 2010-08-25 18:33:21 +04:00
parent 41afca6db2
commit 091a1125a3
2 changed files with 28 additions and 14 deletions

View file

@ -41,8 +41,7 @@ MACRO_CONFIG_STR(SvRconPasswordHelper, sv_rcon_password_helper, 32, "", CFGFLAG_
MACRO_CONFIG_INT(SvNetmsgLimit, sv_netmsg_limit, 0, 0, 100, CFGFLAG_SERVER, "How Many unauthed Command Tries Before ban")
MACRO_CONFIG_INT(SvNetmsgBanTime, sv_netmsg_bantime, 300, 0, 9999, CFGFLAG_SERVER, "How Much time will the unauthed rcon command spammer will be banned")
MACRO_CONFIG_INT(SvExternalRecords, sv_external_records, 0, 0, 1, CFGFLAG_SERVER, "All records will be holded in the same dir as maps")
MACRO_CONFIG_INT(SvTimer, sv_timer, 0, 0, 1, CFGFLAG_SERVER, "Turns command timer On/Off")
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 30, CFGFLAG_SERVER, "Number of seconds to do warpup before round starts")
@ -64,6 +63,21 @@ MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 2, 1, MAX_CLIENTS, CF
MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only")
MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing")
MACRO_CONFIG_INT(SvScoreIP, sv_score_ip, 1, 0, 1, CFGFLAG_SERVER, "Check score for ip, too")
MACRO_CONFIG_INT(SvCheckpointSave, sv_checkpoint_save, 1, 0, 1, CFGFLAG_SERVER, "Save checkpoint times to score file")
MACRO_CONFIG_STR(SvScoreFolder, sv_score_folder, 32, "records", CFGFLAG_SERVER, "Folder to save score files to")
MACRO_CONFIG_INT(SvUseSQL, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables SQL DB instead of record file")
/* SQL */
MACRO_CONFIG_STR(SvSqlUser, sv_sql_user, 32, "nameless", CFGFLAG_SERVER, "SQL User")
MACRO_CONFIG_STR(SvSqlPw, sv_sql_pw, 32, "tee", CFGFLAG_SERVER, "SQL Password")
MACRO_CONFIG_STR(SvSqlIp, sv_sql_ip, 32, "127.0.0.1", CFGFLAG_SERVER, "SQL Database IP")
MACRO_CONFIG_INT(SvSqlPort, sv_sql_port, 3306, 0, 65535, CFGFLAG_SERVER, "SQL Database port")
MACRO_CONFIG_STR(SvSqlDatabase, sv_sql_database, 16, "teeworlds", CFGFLAG_SERVER, "SQL Database name")
MACRO_CONFIG_STR(SvSqlPrefix, sv_sql_prefix, 16, "record", CFGFLAG_SERVER, "SQL Database table prefix")
//=============================== */
MACRO_CONFIG_STR(PlayerName, player_name, 24, "nameless tee", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Name of the player")

View file

@ -39,9 +39,9 @@ CFileScore::~CFileScore()
std::string SaveFile()
{
std::ostringstream oss;
//if(g_Config.m_SvScoreFolder[0])
// oss << g_Config.m_SvScoreFolder << "/" << g_Config.m_SvMap << "_record.dtb";
//else
if(g_Config.m_SvScoreFolder[0])
oss << g_Config.m_SvScoreFolder << "/" << g_Config.m_SvMap << "_record.dtb";
else
oss << g_Config.m_SvMap << "_record.dtb";
return oss.str();
}
@ -58,12 +58,12 @@ void CFileScore::SaveScoreThread(void *pUser)
for(sorted_array<CPlayerScore>::range r = pSelf->m_Top.all(); !r.empty(); r.pop_front())
{
f << r.front().m_aName << std::endl << r.front().m_Score << std::endl << r.front().m_aIP << std::endl;
//if(g_Config.m_SvCheckpointSave)
//{
if(g_Config.m_SvCheckpointSave)
{
for(int c = 0; c < NUM_TELEPORT; c++)
f << r.front().m_aCpTime[c] << " ";
f << std::endl;
//}
}
t++;
if(t%50 == 0)
thread_sleep(1);
@ -86,8 +86,8 @@ void CFileScore::Init()
lock_wait(gs_ScoreLock);
// create folder if not exist
//if(g_Config.m_SvScoreFolder[0])
// fs_makedir(g_Config.m_SvScoreFolder);
if(g_Config.m_SvScoreFolder[0])
fs_makedir(g_Config.m_SvScoreFolder);
std::fstream f;
f.open(SaveFile().c_str(), std::ios::in);
@ -101,8 +101,8 @@ void CFileScore::Init()
std::getline(f, TmpScore);
std::getline(f, TmpIP);
float aTmpCpTime[NUM_TELEPORT] = {0};
//if(g_Config.m_SvCheckpointSave)
//{
if(g_Config.m_SvCheckpointSave)
{
std::getline(f, TmpCpLine);
char *pTime = strtok((char*)TmpCpLine.c_str(), " ");
int i = 0;
@ -112,7 +112,7 @@ void CFileScore::Init()
pTime = strtok(NULL, " ");
i++;
}
//}
}
m_Top.add(*new CPlayerScore(TmpName.c_str(), atof(TmpScore.c_str()), TmpIP.c_str(), aTmpCpTime));
}
}
@ -132,7 +132,7 @@ CFileScore::CPlayerScore *CFileScore::SearchScore(int ID, bool ScoreIP, int *pPo
int Pos = 1;
for(sorted_array<CPlayerScore>::range r = m_Top.all(); !r.empty(); r.pop_front())
{
if(!strcmp(r.front().m_aIP, aIP) /*&& g_Config.m_SvScoreIP*/ && ScoreIP)
if(!strcmp(r.front().m_aIP, aIP) && g_Config.m_SvScoreIP && ScoreIP)
{
if(pPosition)
*pPosition = Pos;