Skip to content

Commit bad3cb6

Browse files
committed
Add FeatureSettings
1 parent 8e99057 commit bad3cb6

6 files changed

Lines changed: 53 additions & 15 deletions

File tree

src/CleanCheat.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ClCompile Include="Runners\BasicRunner.cpp" />
2626
<ClCompile Include="SharedDataStruct.cpp" />
2727
<ClInclude Include="CleanCheat.h" />
28+
<ClInclude Include="CleanCheat\FeatureSettings.h" />
2829
<ClInclude Include="CleanCheat\Macros.h" />
2930
<ClInclude Include="CleanCheat\HookManager.h" />
3031
<ClInclude Include="CleanCheat\MemoryManager.h" />

src/CleanCheat/FeatureBase.h

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#pragma once
22
#include "Macros.h"
3+
#include "FeatureSettings.h"
34

4-
template <typename TType>
5+
template <typename TType, class TSettings = FeatureSettings>
56
ABSTRACT class FeatureBase
67
{
78
private:
89
bool _init = false;
910

11+
public:
12+
TSettings* Settings;
13+
1014
public:
1115
virtual ~FeatureBase() = default;
12-
virtual void Discard() { }
1316

1417
protected:
1518
virtual void OnExecute(TType* param) = 0;
@@ -20,6 +23,15 @@ ABSTRACT class FeatureBase
2023
}
2124

2225
public:
26+
/// <summary>
27+
/// Determinate initialization status
28+
/// </summary>
29+
/// <returns>`True` if initialized, otherwise `False`</returns>
30+
bool IsInitialized() const
31+
{
32+
return _init;
33+
}
34+
2335
/// <summary>
2436
/// Condition runner will use to determine will execute this feature or not
2537
/// </summary>
@@ -46,15 +58,6 @@ ABSTRACT class FeatureBase
4658
OnExecute(param);
4759
}
4860

49-
/// <summary>
50-
/// Determinate initialization status
51-
/// </summary>
52-
/// <returns>`True` if initialized, otherwise `False`</returns>
53-
bool IsInitialized() const
54-
{
55-
return _init;
56-
}
57-
5861
/// <summary>
5962
/// Initialize
6063
/// </summary>
@@ -64,6 +67,18 @@ ABSTRACT class FeatureBase
6467
return false;
6568
_init = true;
6669

70+
Settings = new TSettings();
71+
Settings->OnInit();
72+
6773
return OnInit(initData);
6874
}
75+
76+
/// <summary>
77+
/// Discard
78+
/// </summary>
79+
virtual void Discard()
80+
{
81+
delete Settings;
82+
Settings = nullptr;
83+
}
6984
};

src/CleanCheat/FeatureSettings.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
/// <summary>
4+
/// Features settings class
5+
/// </summary>
6+
class FeatureSettings
7+
{
8+
public:
9+
bool Enable = true;
10+
11+
public:
12+
virtual ~FeatureSettings() = default;
13+
14+
protected:
15+
virtual void OnInit() { }
16+
};

src/CleanCheat/RunnerBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ template <typename TType>
77
ABSTRACT class RunnerBase
88
{
99
protected:
10-
std::vector<FeatureBase<TType>*> _features;
10+
std::vector<FeatureBase<TType, int8_t>*> _features;
1111

1212
public:
1313
virtual ~RunnerBase() = default;
@@ -35,7 +35,7 @@ ABSTRACT class RunnerBase
3535
{
3636
for (FeatureBase<TType>* const& feature : _features)
3737
{
38-
if (feature->Condition(item))
38+
if (feature->Settings->Enable && feature->Condition(item))
3939
feature->Execute(item);
4040
}
4141
}

src/Features/BasicFeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ void BasicFeature::OnExecute(int* param)
99

1010
bool BasicFeature::Condition(int* param)
1111
{
12-
return true;
12+
return Settings->Enable;
1313
}

src/Features/BasicFeature.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#pragma once
22
#include "CleanCheat/FeatureBase.h"
33

4-
class BasicFeature final : public FeatureBase<int>
4+
class BasicSettings final : public FeatureSettings
5+
{
6+
public:
7+
bool Test = false;
8+
};
9+
10+
class BasicFeature final : public FeatureBase<int, BasicSettings>
511
{
612
protected:
713
void OnExecute(int* param) override;

0 commit comments

Comments
 (0)