Fix for SDKTools TeamScore natives crash on CS:GO (
bug 5319, r=psychonic).
3 * =============================================================================
5 * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
33 #define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
35 #include "sm_globals.h"
36 #include <INativeInvoker.h>
40 int flags; /* Copy-back flags */
41 bool marked; /* Whether this is marked as being used */
42 cell_t local_addr; /* Local address to free */
43 cell_t *phys_addr; /* Physical address of our copy */
44 cell_t *orig_addr; /* Original address to copy back to */
45 ucell_t size; /* Size of array in bytes */
48 bool is_sz; /* is a string */
49 int sz_flags; /* has sz flags */
53 class NativeInvoker : public INativeInvoker
58 public: /* ICallable */
59 int PushCell(cell_t cell);
60 int PushCellByRef(cell_t *cell, int flags=SM_PARAM_COPYBACK);
61 int PushFloat(float number);
62 int PushFloatByRef(float *number, int flags=SM_PARAM_COPYBACK);
63 int PushArray(cell_t *inarray, unsigned int cells, int flags=0);
64 int PushString(const char *string);
65 int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
67 public: /* INativeInvoker */
68 bool Start(IPluginContext *pContext, const char *name);
69 int Invoke(cell_t *result);
71 int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
72 int SetError(int err);
74 IPluginContext *pContext;
75 SPVM_NATIVE_FUNC native;
76 cell_t m_params[SP_MAX_EXEC_PARAMS];
77 ParamInfo m_info[SP_MAX_EXEC_PARAMS];
78 unsigned int m_curparam;
82 class NativeInterface :
83 public INativeInterface,
86 public: /* SMGlobalClass */
87 void OnSourceModAllInitialized();
88 public: /* SMInterface */
89 unsigned int GetInterfaceVersion();
90 const char *GetInterfaceName();
91 public: /* INativeInvoker */
92 IPluginRuntime *CreateRuntime(const char *name, size_t bytes);
93 INativeInvoker *CreateInvoker();
96 extern NativeInterface g_NInvoke;
98 #endif /* _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_ */