the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2class File;
3class StatsCounter;
4class User;
5class File;
6class Stat;
7using namespace std;
8
9class StatsSyncher
10{
11private:
12 static const int SAVE_INTERVAL = 20 * 5;
13 static const int SEND_INTERVAL = 20 * 60;
14
15 volatile bool busy;
16
17 volatile unordered_map<Stat *, int> *serverStats;
18 volatile unordered_map<Stat *, int> *failedSentStats;
19
20 StatsCounter *statsCounter;
21 File *unsentFile, *lastServerFile;
22 File *unsentFileTmp, *lastServerFileTmp;
23 File *unsentFileOld, *lastServerFileOld;
24 User *user;
25
26 int noSaveIn, noSendIn;
27
28public:
29 StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
30private:
31 void attemptRename(File *dir, const wstring& name, File *to);
32 unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
33 unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
34 void doSend(unordered_map<Stat *, int> *stats);
35 void doSave(unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
36protected:
37 unordered_map<Stat *, int> *doGetStats();
38public:
39 void getStatsFromServer();
40 void saveUnsent(unordered_map<Stat *, int> *stats);
41 void sendUnsent(unordered_map<Stat *, int> *stats, unordered_map<Stat *, int> *fullStats);
42 void forceSendUnsent(unordered_map<Stat *, int> *stats);
43 void forceSaveUnsent(unordered_map<Stat *, int> *stats);
44 bool maySave();
45 bool maySend();
46 void tick();
47};