3 * =============================================================================
4 * SourceMod SDKTools Extension
5 * Copyright (C) 2004-2008 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_OUTPUT_H_
33 #define _INCLUDE_SOURCEMOD_OUTPUT_H_
35 #include <jit/jit_helpers.h>
36 #include <jit/x86/x86_macros.h>
39 #include "sm_trie_tpl.h"
42 extern ISourcePawnEngine *spengine;
44 struct OutputNameStruct;
47 * This is a function specific hook that corresponds to an entity classname
48 * and outputname. There can be many of these for each classname/output combo
52 int entity_filter; // if not -1 is an entity signature
56 OutputNameStruct *m_parent;
62 * This represents an output belonging to a specific classname
64 struct OutputNameStruct
66 SourceHook::List<omg_hooks *> hooks;
71 * This represents an entity classname
73 struct ClassNameStruct
75 //Trie mapping outputname to a OutputNameStruct
76 //KTrie<OutputNameStruct *> OutputList;
77 IBasicTrie *OutputList;
81 OutputList = adtfactory->CreateBasicTrie();
86 OutputList->Destroy();
90 class EntityOutputManager : public IPluginsListener
93 EntityOutputManager();
94 ~EntityOutputManager();
100 void FireEventDetour(void *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay);
102 void OnPluginDestroyed(IPlugin *plugin);
104 OutputNameStruct *FindOutputPointer(const char *classname, const char *outputname, bool create);
106 void CleanUpHook(omg_hooks *hook);
108 omg_hooks *NewHook();
111 void OnHookRemoved();
116 // Patch/unpatch the server dll
117 void InitFireEventDetour();
118 void ShutdownFireEventDetour();
121 //These create/delete the allocated memory and write into it
122 bool CreateFireEventDetour();
123 void DeleteFireEventDetour();
125 const char *FindOutputName(void *pOutput, CBaseEntity *pCaller);
126 edict_t *BaseHandleToEdict(CBaseHandle &hndl);
128 //Maps CEntityOutput * to a OutputNameStruct
129 IBasicTrie *EntityOutputs;
130 // Maps classname to a ClassNameStruct
131 IBasicTrie *ClassNames;
133 SourceHook::CStack<omg_hooks *> FreeHooks; //Stores hook pointers to avoid calls to new
137 patch_t info_restore;
142 void TempDetour(void *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay);
144 extern EntityOutputManager g_OutputManager;
146 extern sp_nativeinfo_t g_EntOutputNatives[];
148 #endif //_INCLUDE_SOURCEMOD_OUTPUT_H_