-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpatches.h
60 lines (44 loc) · 851 Bytes
/
patches.h
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
#pragma once
#include <memory>
#include <windows.h>
#include "signature.h"
#include "spelunky.h"
#include "debug.h"
#include <iomanip>
#include <iostream>
class Patch {
private:
bool active;
bool is_locked;
virtual bool _undo() = 0;
virtual bool _perform() = 0;
public:
std::shared_ptr<Spelunky> spel;
Patch(std::shared_ptr<Spelunky> spel) : active(false), spel(spel), is_locked(false) {}
virtual void lock() { is_locked = true; }
virtual void unlock() { is_locked = false; }
bool locked() {
return is_locked;
}
void undo() {
if(is_locked) {
return;
}
if(this->valid() && _undo()) {
active = false;
}
}
virtual bool valid() = 0;
void perform() {
if(is_locked) {
return;
}
if(this->valid() && _perform()) {
active = true;
}
}
bool is_active() {
return active;
}
virtual ~Patch() {}
};