-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlot.cpp
More file actions
65 lines (51 loc) · 1.97 KB
/
Plot.cpp
File metadata and controls
65 lines (51 loc) · 1.97 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
#include "Plot.h"
#include <set>
#include "Runtime.h"
namespace Plot {
std::set<short*> lockedAppeals;
ProxyTypes::PushMethods base_PushMethods;
ProxyTypes::PushMethods orig_PushMethods;
Types::SetAppeal base_SetAppeal;
Types::SetAppeal orig_SetAppeal;
Types::GetInstance GetInstance;
void __cdecl SetAppeal(Instance* plot, int appeal) {
std::cout << "Hooked SetAppeal!\n";
if (lockedAppeals.find((short*)((uintptr_t)plot + 0x4a)) == lockedAppeals.end()) {
base_SetAppeal(plot, appeal);
}
}
int lSetAppeal(hks::lua_State* L) {
Instance* plot = GetInstance(L, 1, true);
int appeal = hks::checkinteger(L, 2);
std::cout << plot << ' ' << appeal << '\n';
SetAppeal(plot, appeal);
return 0;
}
int lLockAppeal(hks::lua_State* L) {
Instance* plot = GetInstance(L, 1, true);
bool setToLock = hks::toboolean(L, 2);
short* appealAddress = (short*)((uintptr_t)plot + 0x4a);
if (setToLock) {
lockedAppeals.insert(appealAddress);
}
else {
lockedAppeals.erase(appealAddress);
}
return 0;
}
void __cdecl PushMethods(hks::lua_State* L, int stackOffset) {
std::cout << "Hooked Plot::PushMethods!\n";
PushLuaMethod(L, lSetAppeal, "lSetAppeal", stackOffset, "SetAppeal");
PushLuaMethod(L, lLockAppeal, "lLockAppeal", stackOffset, "LockAppeal");
base_PushMethods(L, stackOffset);
}
void Create() {
using namespace Runtime;
GetInstance = GetGameCoreGlobalAt<Types::GetInstance>(GET_INSTANCE_OFFSET);
lockedAppeals = {};
orig_SetAppeal = GetGameCoreGlobalAt<Types::SetAppeal>(SET_APPEAL_OFFSET);
CreateHook(orig_SetAppeal, &SetAppeal, &base_SetAppeal);
orig_PushMethods = GetGameCoreGlobalAt<ProxyTypes::PushMethods>(PUSH_METHODS_OFFSET);
CreateHook(orig_PushMethods, &PushMethods, &base_PushMethods);
}
}