1616: Minor CFileScore improvements r=heinrich5991 a=def-

It's written using STL strings and files intead of using system. Didn't change any of that because of the risk of breaking something unintentionally.

Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2019-04-11 09:41:01 +00:00
commit cde3781184

View file

@ -70,7 +70,11 @@ void CFileScore::SaveScoreThread(void *pUser)
lock_wait(gs_ScoreLock);
std::fstream f;
f.open(SaveFile().c_str(), std::ios::out);
if (!f.fail())
if(f.fail())
{
dbg_msg("filescore", "opening '%s' for writing failed", SaveFile().c_str());
}
else
{
int t = 0;
for (sorted_array<CPlayerScore>::range r = pSelf->m_Top.all();
@ -109,6 +113,10 @@ void CFileScore::Init()
std::fstream f;
f.open(SaveFile().c_str(), std::ios::in);
if(f.fail())
{
dbg_msg("filescore", "opening '%s' for reading failed", SaveFile().c_str());
}
while (!f.eof() && !f.fail())
{
std::string TmpName, TmpScore, TmpCpLine;
@ -268,9 +276,6 @@ void CFileScore::ShowRank(int ClientID, const char* pName, bool Search)
if (pScore && Pos > -1)
{
float Time = pScore->m_Score;
char aClientName[128];
str_format(aClientName, sizeof(aClientName), " (%s)",
Server()->ClientName(ClientID));
if (g_Config.m_SvHideScore)
str_format(aBuf, sizeof(aBuf),
"Your time: %d minute(s) %5.2f second(s)", (int)Time / 60,
@ -279,7 +284,7 @@ void CFileScore::ShowRank(int ClientID, const char* pName, bool Search)
str_format(aBuf, sizeof(aBuf),
"%d. %s Time: %d minute(s) %5.2f second(s), requested by (%s)", Pos,
pScore->m_aName, (int)Time / 60,
Time - ((int)Time / 60 * 60), aClientName);
Time - ((int)Time / 60 * 60), Server()->ClientName(ClientID));
if (!Search)
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, ClientID);
else