Remove buggy and unneeded finish time in /rank and /rankteam

This commit is contained in:
def 2014-12-19 16:27:10 +01:00
parent 75bbf64bbd
commit da0750d26f

View file

@ -717,7 +717,7 @@ void CSqlScore::ShowTeamRankThread(void *pUser)
pData->m_pSqlData->m_pStatement->execute("SET @prev := NULL;");
pData->m_pSqlData->m_pStatement->execute("SET @rank := 1;");
pData->m_pSqlData->m_pStatement->execute("SET @pos := 0;");
str_format(aBuf, sizeof(aBuf), "SELECT Rank, Name, Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago, UNIX_TIMESTAMP(Timestamp) as stamp FROM (SELECT Rank, l2.ID FROM ((SELECT ID, (@pos := @pos+1) pos, (@rank := IF(@prev = Time,@rank,@pos)) rank, (@prev := Time) Time FROM (SELECT ID, Time FROM %s_teamrace WHERE Map = '%s' GROUP BY ID ORDER BY Time) as ll) as l2) LEFT JOIN %s_teamrace as r2 ON l2.ID = r2.ID WHERE Map = '%s' AND Name = '%s' ORDER BY Rank LIMIT 1) as l LEFT JOIN %s_teamrace as r ON l.ID = r.ID ORDER BY Name;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_pSqlData->m_pPrefix);
str_format(aBuf, sizeof(aBuf), "SELECT Rank, Name, Time FROM (SELECT Rank, l2.ID FROM ((SELECT ID, (@pos := @pos+1) pos, (@rank := IF(@prev = Time,@rank,@pos)) rank, (@prev := Time) Time FROM (SELECT ID, Time FROM %s_teamrace WHERE Map = '%s' GROUP BY ID ORDER BY Time) as ll) as l2) LEFT JOIN %s_teamrace as r2 ON l2.ID = r2.ID WHERE Map = '%s' AND Name = '%s' ORDER BY Rank LIMIT 1) as l LEFT JOIN %s_teamrace as r ON l.ID = r.ID ORDER BY Name;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_pSqlData->m_pPrefix);
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
@ -732,11 +732,6 @@ void CSqlScore::ShowTeamRankThread(void *pUser)
{
pData->m_pSqlData->m_pResults->first();
int since = (int)pData->m_pSqlData->m_pResults->getInt("Ago");
char agoString[40];
mem_zero(agoString, sizeof(agoString));
agoTimeToString(since,agoString);
float Time = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
int Rank = (int)pData->m_pSqlData->m_pResults->getInt("Rank");
@ -756,15 +751,9 @@ void CSqlScore::ShowTeamRankThread(void *pUser)
if(g_Config.m_SvHideScore)
str_format(aBuf, sizeof(aBuf), "Your team time: %02d:%05.02f", (int)(Time/60), Time-((int)Time/60*60));
else
str_format(aBuf, sizeof(aBuf), "%d. %s Team time: %02d:%05.02f, requested by %s", Rank, aNames, (int)(Time/60), Time-((int)Time/60*60), pData->m_aRequestingPlayer, agoString);
str_format(aBuf, sizeof(aBuf), "%d. %s Team time: %02d:%05.02f, requested by %s", Rank, aNames, (int)(Time/60), Time-((int)Time/60*60), pData->m_aRequestingPlayer);
if(pData->m_pSqlData->m_pResults->getInt("stamp") != 0)
{
pData->m_pSqlData->GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1);
str_format(aBuf, sizeof(aBuf), "Finished: %s ago", agoString);
}
pData->m_pSqlData->GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1);
}
dbg_msg("SQL", "Showing teamrank done");
@ -913,7 +902,7 @@ void CSqlScore::ShowRankThread(void *pUser)
pData->m_pSqlData->m_pStatement->execute("SET @prev := NULL;");
pData->m_pSqlData->m_pStatement->execute("SET @rank := 1;");
pData->m_pSqlData->m_pStatement->execute("SET @pos := 0;");
str_format(aBuf, sizeof(aBuf), "SELECT Rank, Name, Time, UNIX_TIMESTAMP(CURRENT_TIMESTAMP)-UNIX_TIMESTAMP(Timestamp) as Ago, UNIX_TIMESTAMP(Timestamp) as stamp FROM (SELECT Name, (@pos := @pos+1) pos, (@rank := IF(@prev = Time,@rank, @pos)) rank, (@prev := Time) Time, Timestamp FROM (SELECT Name, min(Time) as Time, Timestamp FROM %s_race WHERE Map = '%s' GROUP BY Name ORDER BY `Time` ASC) as a) as b WHERE Name = '%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName);
str_format(aBuf, sizeof(aBuf), "SELECT Rank, Name, Time FROM (SELECT Name, (@pos := @pos+1) pos, (@rank := IF(@prev = Time,@rank, @pos)) rank, (@prev := Time) Time FROM (SELECT Name, min(Time) as Time FROM %s_race WHERE Map = '%s' GROUP BY Name ORDER BY `Time` ASC) as a) as b WHERE Name = '%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName);
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
@ -925,25 +914,15 @@ void CSqlScore::ShowRankThread(void *pUser)
else
{
pData->m_pSqlData->m_pResults->next();
int since = (int)pData->m_pSqlData->m_pResults->getInt("Ago");
char agoString[40];
mem_zero(agoString, sizeof(agoString));
agoTimeToString(since,agoString);
float Time = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
int Rank = (int)pData->m_pSqlData->m_pResults->getInt("Rank");
if(g_Config.m_SvHideScore)
str_format(aBuf, sizeof(aBuf), "Your time: %02d:%05.2f", (int)(Time/60), Time-((int)Time/60*60));
else
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %02d:%05.2f, requested by %s", Rank, pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(Time/60), Time-((int)Time/60*60), pData->m_aRequestingPlayer, agoString);
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %02d:%05.2f, requested by %s", Rank, pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(Time/60), Time-((int)Time/60*60), pData->m_aRequestingPlayer);
if(pData->m_pSqlData->m_pResults->getInt("stamp") != 0)
{
pData->m_pSqlData->GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1);
str_format(aBuf, sizeof(aBuf), "Finished: %s ago", agoString);
}
pData->m_pSqlData->GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1);
}
dbg_msg("SQL", "Showing rank done");