-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeta_api.cpp
More file actions
163 lines (140 loc) · 3.6 KB
/
meta_api.cpp
File metadata and controls
163 lines (140 loc) · 3.6 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "extdll.h"
#include "meta_api.h"
#include "main.h"
#undef C_DLLEXPORT
#ifdef _WIN32
#define C_DLLEXPORT extern "C" __declspec(dllexport)
#else
#include <sys/mman.h>
#define C_DLLEXPORT extern "C" __attribute__((visibility("default")))
#endif
plugin_info_t Plugin_info = {
META_INTERFACE_VERSION,
"SemiclipHL",
"2.2.1",
"18/06/23",
"s1lent & rtxa",
"https://github.com/rtxa/SemiclipHL",
"SemiclipHL",
PT_ANYTIME,
PT_ANYTIME,
};
meta_globals_t *gpMetaGlobals;
gamedll_funcs_t *gpGamedllFuncs;
mutil_funcs_t *gpMetaUtilFuncs;
enginefuncs_t g_engfuncs;
enginefuncs_t gpEnginefuncs_Post;
enginefuncs_t *g_pEnginefuncsTable_Post;
enginefuncs_t *gpEnginefuncInterface;
globalvars_t *gpGlobals;
DLL_FUNCTIONS gpFunctionTable;
DLL_FUNCTIONS gpFunctionTable_Post;
DLL_FUNCTIONS *g_pFunctionTable;
META_FUNCTIONS gMetaFunctionTable;
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable,int *)
{
memset(&gpFunctionTable,0,sizeof(DLL_FUNCTIONS));
gpFunctionTable.pfnPM_Move = PM_Move;
memcpy(pFunctionTable,&gpFunctionTable,sizeof(DLL_FUNCTIONS));
g_pFunctionTable = pFunctionTable;
return 1;
}
C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable,int *)
{
memset(&gpFunctionTable_Post,0,sizeof(DLL_FUNCTIONS));
gpFunctionTable_Post.pfnServerActivate = ServerActivate_Post;
gpFunctionTable_Post.pfnClientPutInServer = ClientPutInServer_Post;
memcpy(pFunctionTable,&gpFunctionTable_Post,sizeof(DLL_FUNCTIONS));
return 1;
}
C_DLLEXPORT int Meta_Query(char *,plugin_info_t **pPlugInfo,mutil_funcs_t *pMetaUtilFuncs)
{
*pPlugInfo = &(Plugin_info);
gpMetaUtilFuncs = pMetaUtilFuncs;
return 1;
}
C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pEnginefuncsTable,int *interfaceVersion)
{
memset(&gpEnginefuncs_Post,0,sizeof(enginefuncs_t));
if(semiclipData.time)
{
gpEnginefuncs_Post.pfnAlertMessage = AlertMessage;
}
memcpy(pEnginefuncsTable,&gpEnginefuncs_Post,sizeof(enginefuncs_t));
g_pEnginefuncsTable_Post = pEnginefuncsTable;
return 1;
}
C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME now,META_FUNCTIONS *pFunctionTable,meta_globals_t *pMGlobals,gamedll_funcs_t *pGamedllFuncs)
{
gpMetaGlobals = pMGlobals;
gpGamedllFuncs = pGamedllFuncs;
if(!OnMetaAttach())
{
return 0;
}
GET_HOOK_TABLES(PLID,&gpEnginefuncInterface,NULL,NULL);
gMetaFunctionTable.pfnGetEntityAPI2 = GetEntityAPI2;
gMetaFunctionTable.pfnGetEntityAPI2_Post = GetEntityAPI2_Post;
gMetaFunctionTable.pfnGetEngineFunctions_Post = GetEngineFunctions_Post;
memcpy(pFunctionTable,&gMetaFunctionTable,sizeof(META_FUNCTIONS));
return 1;
}
C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now,PL_UNLOAD_REASON reason)
{
OnMetaDetach();
return 1;
}
#ifndef _WIN32
C_DLLEXPORT void GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable,globalvars_t *pGlobals)
{
#else
#ifdef _MSC_VER
C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable,globalvars_t *pGlobals)
{
__asm
{
push ebp
mov ebp,esp
sub esp,__LOCAL_SIZE
push ebx
push esi
push edi
}
#else // _MSC_VER
#ifdef __GNUC__
C_DLLEXPORT void __stdcall GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable,globalvars_t *pGlobals)
{
#else
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers.
#endif
#endif // _MSC_VER
#endif // _WIN32
memcpy(&g_engfuncs,pEnginefuncsTable,sizeof(enginefuncs_t));
gpGlobals = pGlobals;
#ifdef _MSC_VER
if(sizeof(int *) == 8)
{
__asm
{
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
}
}
else
{
__asm
{
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 8
}
}
#endif // #ifdef _MSC_VER
}