From 6c9674fd15b0c09908119635e9ae5469c99784d6 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 9 Feb 2011 15:14:23 +0200 Subject: [PATCH 1/1] =?utf8?q?=D0=94=D0=BE=D0=B4=D0=B0=D0=BD=D0=BE=20?= =?utf8?q?=D1=80=D0=BE=D0=B7=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?utf8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20=D0=BF=D0=BE=D0=BC=D1=96?= =?utf8?q?=D1=81=D1=8F=D1=87=D0=BD=D0=BE=D1=97=20=D1=81=D1=82=D0=B0=D1=82?= =?utf8?q?=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit У файли stat.. тепер пишеться повний зріз, включаючи freeMb, passiveTime і т.д. Класичний формат файлів залишено для сумісності. --- .../plugins/store/files/file_store.cpp | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/projects/stargazer/plugins/store/files/file_store.cpp b/projects/stargazer/plugins/store/files/file_store.cpp index c147935d..5969c640 100644 --- a/projects/stargazer/plugins/store/files/file_store.cpp +++ b/projects/stargazer/plugins/store/files/file_store.cpp @@ -1190,35 +1190,58 @@ return WriteLog2String(logStr.str(), login); //----------------------------------------------------------------------------- int FILES_STORE::SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const { -string str; -int e; - -strprintf(&str,"%s/%s/stat.%d.%02d", +// Classic stats +string stat1; +strprintf(&stat1,"%s/%s/stat.%d.%02d", storeSettings.GetUsersDir().c_str(), login.c_str(), year + 1900, month + 1); -CONFIGFILE s(str, true); -e = s.Error(); +CONFIGFILE s(stat1, true); -if (e) +if (s.Error()) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); - errorStr = "Cannot create file " + str; + errorStr = "Cannot create file '" + stat1 + "'"; printfd(__FILE__, "FILES_STORE::SaveMonthStat - month stat write failed for user '%s'\n", login.c_str()); return -1; } -char dirName[3]; +// New stats +string stat2; +strprintf(&stat2,"%s/%s/stat2.%d.%02d", + storeSettings.GetUsersDir().c_str(), login.c_str(), year + 1900, month + 1); -for (int i = 0; i < DIR_NUM; i++) +CONFIGFILE s2(stat2, true); + +if (s2.Error()) { + STG_LOCKER lock(&mutex, __FILE__, __LINE__); + errorStr = "Cannot create file '" + stat2 + "'"; + printfd(__FILE__, "FILES_STORE::SaveMonthStat - month stat write failed for user '%s'\n", login.c_str()); + return -1; + } + +for (size_t i = 0; i < DIR_NUM; i++) + { + char dirName[3]; snprintf(dirName, 3, "U%d", i); - s.WriteInt(dirName, stat.up[i]); + s.WriteInt(dirName, stat.up[i]); // Classic + s2.WriteInt(dirName, stat.up[i]); // New snprintf(dirName, 3, "D%d", i); - s.WriteInt(dirName, stat.down[i]); + s.WriteInt(dirName, stat.down[i]); // Classic + s2.WriteInt(dirName, stat.down[i]); // New } +// Classic s.WriteDouble("cash", stat.cash); +// New +s2.WriteDouble("Cash", stat.cash); +s2.WriteDouble("FreeMb", stat.freeMb); +s2.WriteDouble("LastCashAdd", stat.lastCashAdd); +s2.WriteInt("LastCashAddTime", stat.lastCashAddTime); +s2.WriteInt("PassiveTime", stat.passiveTime); +s2.WriteInt("LastActivityTime", stat.lastActivityTime); + return 0; } //-----------------------------------------------------------------------------*/ -- 2.44.2