diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/StatsSyncher.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/StatsSyncher.h')
| -rw-r--r-- | Minecraft.Client/StatsSyncher.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Minecraft.Client/StatsSyncher.h b/Minecraft.Client/StatsSyncher.h new file mode 100644 index 00000000..843505bf --- /dev/null +++ b/Minecraft.Client/StatsSyncher.h @@ -0,0 +1,47 @@ +#pragma once +class File; +class StatsCounter; +class User; +class File; +class Stat; +using namespace std; + +class StatsSyncher +{ +private: + static const int SAVE_INTERVAL = 20 * 5; + static const int SEND_INTERVAL = 20 * 60; + + volatile bool busy; + + volatile unordered_map<Stat *, int> *serverStats; + volatile unordered_map<Stat *, int> *failedSentStats; + + StatsCounter *statsCounter; + File *unsentFile, *lastServerFile; + File *unsentFileTmp, *lastServerFileTmp; + File *unsentFileOld, *lastServerFileOld; + User *user; + + int noSaveIn, noSendIn; + +public: + StatsSyncher(User *user, StatsCounter *statsCounter, File *dir); +private: + void attemptRename(File *dir, const wstring& name, File *to); + unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old); + unordered_map<Stat *, int> *loadStatsFromDisk(File *file); + void doSend(unordered_map<Stat *, int> *stats); + void doSave(unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old); +protected: + unordered_map<Stat *, int> *doGetStats(); +public: + void getStatsFromServer(); + void saveUnsent(unordered_map<Stat *, int> *stats); + void sendUnsent(unordered_map<Stat *, int> *stats, unordered_map<Stat *, int> *fullStats); + void forceSendUnsent(unordered_map<Stat *, int> *stats); + void forceSaveUnsent(unordered_map<Stat *, int> *stats); + bool maySave(); + bool maySend(); + void tick(); +}; |
