Skip to content

Commit 9e6c993

Browse files
committed
Fix missing include
1 parent f9f177a commit 9e6c993

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

addons/sourcemod/scripting/l4d_consistent_escaperoute.sp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <sourcemod>
99
#include <dhooks>
1010
#include <sourcescramble>
11-
#include <@Forgetest/gamedatawrapper>
1211

1312
#if DEBUG
1413
#include <sdktools_functions>
@@ -23,6 +22,46 @@ public Plugin myinfo =
2322
url = "https://github.com/Target5150/MoYu_Server_Stupid_Plugins"
2423
};
2524

25+
methodmap GameDataWrapper < GameData {
26+
public GameDataWrapper(const char[] file) {
27+
GameData gd = new GameData(file);
28+
if (!gd) SetFailState("Missing gamedata \"%s\"", file);
29+
return view_as<GameDataWrapper>(gd);
30+
}
31+
property GameData Super {
32+
public get() { return view_as<GameData>(this); }
33+
}
34+
public int GetOffset(const char[] key) {
35+
int offset = this.Super.GetOffset(key);
36+
if (offset == -1) SetFailState("Missing offset \"%s\"", key);
37+
return offset;
38+
}
39+
public Address GetAddress(const char[] key) {
40+
Address ptr = this.Super.GetAddress(key);
41+
if (ptr == Address_Null) SetFailState("Missing address \"%s\"", key);
42+
return ptr;
43+
}
44+
public MemoryPatch CreatePatchOrFail(const char[] name, bool enable = false) {
45+
MemoryPatch hPatch = MemoryPatch.CreateFromConf(this, name);
46+
if (!(enable ? hPatch.Enable() : hPatch.Validate()))
47+
SetFailState("Failed to patch \"%s\"", name);
48+
return hPatch;
49+
}
50+
public DynamicDetour CreateDetourOrFail(
51+
const char[] name,
52+
DHookCallback preHook = INVALID_FUNCTION,
53+
DHookCallback postHook = INVALID_FUNCTION) {
54+
DynamicDetour hSetup = DynamicDetour.FromConf(this, name);
55+
if (!hSetup)
56+
SetFailState("Missing detour setup \"%s\"", name);
57+
if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook))
58+
SetFailState("Failed to pre-detour \"%s\"", name);
59+
if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook))
60+
SetFailState("Failed to post-detour \"%s\"", name);
61+
return hSetup;
62+
}
63+
}
64+
2665
methodmap Address {}
2766

2867
#if DEBUG

0 commit comments

Comments
 (0)