-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllapi.cpp
204 lines (190 loc) · 6.3 KB
/
dllapi.cpp
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include <precompiled.h>
DLL_FUNCTIONS *g_pFunctionTable, *g_pFunctionTable_Post;
DLL_FUNCTIONS g_FunctionTable =
{
NULL, // pfnGameInit
&DispatchSpawn, // pfnSpawn
NULL, // pfnThink
NULL, // pfnUse
NULL, // pfnTouch
NULL, // pfnBlocked
&KeyValue, // pfnKeyValue
NULL, // pfnSave
NULL, // pfnRestore
NULL, // pfnSetAbsBox
NULL, // pfnSaveWriteFields
NULL, // pfnSaveReadFields
NULL, // pfnSaveGlobalState
NULL, // pfnRestoreGlobalState
&ResetGlobalState, // pfnResetGlobalState
NULL, // pfnClientConnect
&R_ClientDisconnect, // pfnClientDisconnect
NULL, // pfnClientKill
NULL, // pfnClientPutInServer
NULL, // pfnClientCommand
NULL, // pfnClientUserInfoChanged
NULL, // pfnServerActivate
NULL, // pfnServerDeactivate
NULL, // pfnPlayerPreThink
NULL, // pfnPlayerPostThink
NULL, // pfnStartFrame
NULL, // pfnParmsNewLevel
NULL, // pfnParmsChangeLevel
NULL, // pfnGetGameDescription
NULL, // pfnPlayerCustomization
NULL, // pfnSpectatorConnect
NULL, // pfnSpectatorDisconnect
NULL, // pfnSpectatorThink
NULL, // pfnSys_Error
NULL, // pfnPM_Move
NULL, // pfnPM_Init
NULL, // pfnPM_FindTextureType
NULL, // pfnSetupVisibility
NULL, // pfnUpdateClientData
NULL, // pfnAddToFullPack
NULL, // pfnCreateBaseline
NULL, // pfnRegisterEncoders
NULL, // pfnGetWeaponData
NULL, // pfnCmdStart
NULL, // pfnCmdEnd
NULL, // pfnConnectionlessPacket
NULL, // pfnGetHullBounds
NULL, // pfnCreateInstancedBaselines
NULL, // pfnInconsistentFile
NULL, // pfnAllowLagCompensation
};
DLL_FUNCTIONS g_FunctionTable_Post =
{
NULL, // pfnGameInit
NULL, // pfnSpawn
NULL, // pfnThink
NULL, // pfnUse
NULL, // pfnTouch
NULL, // pfnBlocked
NULL, // pfnKeyValue
NULL, // pfnSave
NULL, // pfnRestore
NULL, // pfnSetAbsBox
NULL, // pfnSaveWriteFields
NULL, // pfnSaveReadFields
NULL, // pfnSaveGlobalState
NULL, // pfnRestoreGlobalState
NULL, // pfnResetGlobalState
NULL, // pfnClientConnect
NULL, // pfnClientDisconnect
NULL, // pfnClientKill
&R_ClientPutInServer_Post, // pfnClientPutInServer
NULL, // pfnClientCommand
NULL, // pfnClientUserInfoChanged
&ServerActivate_Post, // pfnServerActivate
&ServerDeactivate_Post, // pfnServerDeactivate
NULL, // pfnPlayerPreThink
NULL, // pfnPlayerPostThink
&R_StartFrame_Post, // pfnStartFrame
NULL, // pfnParmsNewLevel
NULL, // pfnParmsChangeLevel
NULL, // pfnGetGameDescription
NULL, // pfnPlayerCustomization
NULL, // pfnSpectatorConnect
NULL, // pfnSpectatorDisconnect
NULL, // pfnSpectatorThink
NULL, // pfnSys_Error
NULL, // pfnPM_Move
NULL, // pfnPM_Init
NULL, // pfnPM_FindTextureType
NULL, // pfnSetupVisibility
NULL, // pfnUpdateClientData
NULL, // pfnAddToFullPack
NULL, // pfnCreateBaseline
NULL, // pfnRegisterEncoders
NULL, // pfnGetWeaponData
NULL, // pfnCmdStart
CmdEnd_Post, // pfnCmdEnd
NULL, // pfnConnectionlessPacket
NULL, // pfnGetHullBounds
NULL, // pfnCreateInstancedBaselines
NULL, // pfnInconsistentFile
NULL, // pfnAllowLagCompensation
};
NEW_DLL_FUNCTIONS g_NewDllFunctionTable =
{
&OnFreeEntPrivateData, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
NULL, //! pfnGameShutdown()
NULL, //! pfnShouldCollide()
NULL, //! pfnCvarValue()
NULL, //! pfnCvarValue2()
};
NEW_DLL_FUNCTIONS g_NewDllFunctionTable_Post =
{
NULL, //! pfnOnFreeEntPrivateData() Called right before the object's memory is freed. Calls its destructor.
NULL, //! pfnGameShutdown()
NULL, //! pfnShouldCollide()
NULL, //! pfnCvarValue()
NULL, //! pfnCvarValue2()
};
C_DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
{
if (!pFunctionTable)
{
ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__);
return false;
}
if (*interfaceVersion != INTERFACE_VERSION)
{
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION);
*interfaceVersion = INTERFACE_VERSION;
return false;
}
memcpy(pFunctionTable, &g_FunctionTable, sizeof(DLL_FUNCTIONS));
g_pFunctionTable = pFunctionTable;
return true;
}
C_DLLEXPORT int GetEntityAPI2_Post(DLL_FUNCTIONS *pFunctionTable, int *interfaceVersion)
{
if (!pFunctionTable)
{
ALERT(at_logged, "%s called with null pFunctionTable", __FUNCTION__);
return false;
}
if (*interfaceVersion != INTERFACE_VERSION)
{
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, INTERFACE_VERSION);
*interfaceVersion = INTERFACE_VERSION;
return false;
}
memcpy(pFunctionTable, &g_FunctionTable_Post, sizeof(DLL_FUNCTIONS));
g_pFunctionTable_Post = pFunctionTable;
return true;
}
C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
{
if (!pNewFunctionTable)
{
ALERT(at_logged, "%s called with null pNewFunctionTable", __FUNCTION__);
return false;
}
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION)
{
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
return false;
}
memcpy(pNewFunctionTable, &g_NewDllFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
return true;
}
C_DLLEXPORT int GetNewDLLFunctions_Post(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion)
{
if (!pNewFunctionTable)
{
ALERT(at_logged, "%s called with null pNewFunctionTable", __FUNCTION__);
return false;
}
if (*interfaceVersion != NEW_DLL_FUNCTIONS_VERSION)
{
ALERT(at_logged, "%s version mismatch; requested=%d ours=%d", __FUNCTION__, *interfaceVersion, NEW_DLL_FUNCTIONS_VERSION);
*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
return false;
}
memcpy(pNewFunctionTable, &g_NewDllFunctionTable_Post, sizeof(NEW_DLL_FUNCTIONS));
return true;
}