-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPredictGeneratorKey.h
More file actions
84 lines (76 loc) · 2.1 KB
/
PredictGeneratorKey.h
File metadata and controls
84 lines (76 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
Time : 2016/06/13
Author: Kay Yang (1025115216@qq.com)
*/
#ifndef _PREDICTGENERATORKEY_H
#define _PREDICTGENERATORKEY_H
#include "PredictTypeDefines.h"
#include "DS_HashTable.h"
#include "DS_OrderedList.h"
#include "HexTimeCounter.h"
class PredictConfig;
class PredictCheck;
struct ThreeKeyPair
{
ThreeKeyPair(){}
ThreeKeyPair(__u32 sessionId, __u64 keyId, __u64 timestamp) : mSessionId(sessionId), mKeyId(keyId), mTimestamp(timestamp){}
__u32 mSessionId;
__u64 mKeyId;
__u64 mTimestamp;
};
int CompareKeyTime(const __u64& time, const ThreeKeyPair& keiPair);
#ifdef ORDER_LIST
typedef DataStructures::OrderedList<__u64, ThreeKeyPair, CompareKeyTime> KEYPAIR_LISTS;
#else
typedef DataStructures::List<ThreeKeyPair> KEYPAIR_LISTS;
#endif
#ifndef HASHTABLE
typedef DataStructures::HashTable<__u32, KEYPAIR_LISTS> KEYTABLE;
typedef KEYTABLE::SimpleIterator SITR;
#else
typedef DataStructures::HashTable<__u32, KEYPAIR_LISTS> KEYTABLE;
typedef KEYTABLE::SimpleIterator SITR;
#endif
class PredictGeneratorKey
{
public:
PredictGeneratorKey(){}
PredictGeneratorKey(PredictConfig* mConfig);
~PredictGeneratorKey();
bool CheckKeysWrong(__u64& keyResult);
void LoadFromFile(const char* fileName);
void WriteToFile(const char* fileName, __u64 key = 0);
// should be safe in multiple threads
void AppendKeyPair(__u32 sessionId, __u64 keyId, __u64 timestamp, bool needCheck);
__u32 Size();
void Clear();
// __u32 GeneratorId();
// when change game,should save firstly and clear
void WriteAndClear(const char* fileName);
bool IsNeedRecalculate();
void IsNeedRecalculate(bool isNeed);
void InitializeCheckManual();
void InitializeCheck();
void ResetCheck();
void CheckTimer();
void IsNeedCalculate(bool check);
bool IsNeedCalculate();
bool NeedRecheckNow();
bool CanBeCalculate();
public:
DataStructures::HexString mGameName;
private:
KEYTABLE mKeySequence;
HexTimeCounter mRecheck;
float mLastDecreaseThreashold;
PredictCheck* mCheck;
PredictConfig* mConfig;
HexTimeCounter mRecalculateTimer;
bool mIsNeedCalculate;
bool mIsNeedRecalculate;
SimpleMutex mMutex;
int mCount;
private:
int mTotalSessionCount;
};
#endif