-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMGS2.DelayedLoad.cpp
More file actions
50 lines (37 loc) · 1.25 KB
/
Copy pathMGS2.DelayedLoad.cpp
File metadata and controls
50 lines (37 loc) · 1.25 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
#include "MGS2.framework.h"
#include <thread>
#include <chrono>
namespace MGS2::DelayedLoad {
const char* Category = "DelayedLoad";
bool Active = false;
char* NewGameWarning = (char*)calloc(32, 1);
std::chrono::microseconds DelayUsecs;
tFUN_Void oFUN_00884ca0;
void __cdecl hkFUN_00884ca0() {
try_mgs2
if (Active) {
std::this_thread::sleep_for(DelayUsecs);
}
catch_mgs2(Category, "884CA0");
oFUN_00884ca0();
}
void ToggleAction(Actions::Action action) {
Active = !Active;
Log::DisplayToggleMessage("Delayed Load", Active);
}
bool NewGameInfoCallback() {
return Active;
}
void Run(CSimpleIniA& ini) {
if (ini.IsEmpty() || (!ini.GetBoolValue(Category, "Enabled", false))) {
return;
}
long long msecs = ConfigParser::ParseInteger(ini, Category, "Delay", 1000, 0, INT_MAX);
DelayUsecs = std::chrono::microseconds(msecs * 1000);
Active = ini.GetBoolValue(Category, "Active", true);
snprintf(NewGameWarning, 32, "Delayed Loads (%dms)", (int)msecs);
NewGameInfo::AddWarning(NewGameWarning, &NewGameInfoCallback);
Actions::RegisterAction(ini, "DelayedLoad.Toggle", &ToggleAction);
oFUN_00884ca0 = (tFUN_Void)mem::TrampHook32((BYTE*)0x884CA0, (BYTE*)hkFUN_00884ca0, 6);
}
}