From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/StatsSyncher.h | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Minecraft.Client/StatsSyncher.h (limited to 'Minecraft.Client/StatsSyncher.h') 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 *serverStats; + volatile unordered_map *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 *loadStatsFromDisk(File *file, File *tmp, File *old); + unordered_map *loadStatsFromDisk(File *file); + void doSend(unordered_map *stats); + void doSave(unordered_map *stats, File *file, File *tmp, File *old); +protected: + unordered_map *doGetStats(); +public: + void getStatsFromServer(); + void saveUnsent(unordered_map *stats); + void sendUnsent(unordered_map *stats, unordered_map *fullStats); + void forceSendUnsent(unordered_map *stats); + void forceSaveUnsent(unordered_map *stats); + bool maySave(); + bool maySend(); + void tick(); +}; -- cgit v1.2.3