|
pred@1958
|
1 |
/** |
|
pred@1958
|
2 |
* vim: set ts=4 : |
|
pred@1958
|
3 |
* ============================================================================= |
|
pred@1958
|
4 |
* SourceMod SDKTools Extension |
|
ds@1990
|
5 |
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. |
|
pred@1958
|
6 |
* ============================================================================= |
|
pred@1958
|
7 |
* |
|
pred@1958
|
8 |
* This program is free software; you can redistribute it and/or modify it under |
|
pred@1958
|
9 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
pred@1958
|
10 |
* Free Software Foundation. |
|
pred@1958
|
11 |
* |
|
pred@1958
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
pred@1958
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
pred@1958
|
14 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
pred@1958
|
15 |
* details. |
|
pred@1958
|
16 |
* |
|
pred@1958
|
17 |
* You should have received a copy of the GNU General Public License along with |
|
pred@1958
|
18 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
pred@1958
|
19 |
* |
|
pred@1958
|
20 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
pred@1958
|
21 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
pred@1958
|
22 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
pred@1958
|
23 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
pred@1958
|
24 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
pred@1958
|
25 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
pred@1958
|
26 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
pred@1958
|
27 |
* or <http://www.sourcemod.net/license.php>. |
|
pred@1958
|
28 |
* |
|
ds@1987
|
29 |
* Version: $Id$ |
|
pred@1958
|
30 |
*/ |
|
pred@1958
|
31 |
|
|
pred@1958
|
32 |
#ifndef _INCLUDE_SOURCEMOD_OUTPUT_H_ |
|
pred@1958
|
33 |
#define _INCLUDE_SOURCEMOD_OUTPUT_H_ |
|
pred@1958
|
34 |
|
|
pred@1958
|
35 |
#include <jit/jit_helpers.h> |
|
pred@1958
|
36 |
#include <jit/x86/x86_macros.h> |
|
pred@1958
|
37 |
#include "sh_list.h" |
|
pred@1958
|
38 |
#include "sh_stack.h" |
|
pred@1958
|
39 |
#include "sm_trie_tpl.h" |
|
pred@1958
|
40 |
#include "detours.h" |
|
pred@1958
|
41 |
|
|
pred@1958
|
42 |
extern ISourcePawnEngine *spengine; |
|
pred@1958
|
43 |
|
|
pred@1958
|
44 |
struct OutputNameStruct; |
|
pred@1958
|
45 |
|
|
pred@1958
|
46 |
/** |
|
pred@1958
|
47 |
* This is a function specific hook that corresponds to an entity classname |
|
pred@1958
|
48 |
* and outputname. There can be many of these for each classname/output combo |
|
pred@1958
|
49 |
*/ |
|
pred@1958
|
50 |
struct omg_hooks |
|
pred@1958
|
51 |
{ |
|
pred@1958
|
52 |
int entity_filter; // if not -1 is an entity signature |
|
pred@1958
|
53 |
int entity_index; |
|
pred@1958
|
54 |
bool only_once; |
|
pred@1958
|
55 |
IPluginFunction *pf; |
|
pred@1958
|
56 |
OutputNameStruct *m_parent; |
|
pred@1958
|
57 |
bool in_use; |
|
pred@1958
|
58 |
bool delete_me; |
|
pred@1958
|
59 |
}; |
|
pred@1958
|
60 |
|
|
pred@1958
|
61 |
/** |
|
pred@1958
|
62 |
* This represents an output belonging to a specific classname |
|
pred@1958
|
63 |
*/ |
|
pred@1958
|
64 |
struct OutputNameStruct |
|
pred@1958
|
65 |
{ |
|
pred@1958
|
66 |
SourceHook::List<omg_hooks *> hooks; |
|
pred@1958
|
67 |
char Name[50]; |
|
pred@1958
|
68 |
}; |
|
pred@1958
|
69 |
|
|
pred@1958
|
70 |
/** |
|
pred@1958
|
71 |
* This represents an entity classname |
|
pred@1958
|
72 |
*/ |
|
pred@1958
|
73 |
struct ClassNameStruct |
|
pred@1958
|
74 |
{ |
|
pred@1958
|
75 |
//Trie mapping outputname to a OutputNameStruct |
|
pred@1958
|
76 |
//KTrie<OutputNameStruct *> OutputList; |
|
pred@1958
|
77 |
IBasicTrie *OutputList; |
|
pred@1958
|
78 |
|
|
pred@1958
|
79 |
ClassNameStruct() |
|
pred@1958
|
80 |
{ |
|
pred@1958
|
81 |
OutputList = adtfactory->CreateBasicTrie(); |
|
pred@1958
|
82 |
} |
|
pred@1958
|
83 |
|
|
pred@1958
|
84 |
~ClassNameStruct() |
|
pred@1958
|
85 |
{ |
|
pred@1958
|
86 |
OutputList->Destroy(); |
|
pred@1958
|
87 |
} |
|
pred@1958
|
88 |
}; |
|
pred@1958
|
89 |
|
|
pred@1958
|
90 |
class EntityOutputManager : public IPluginsListener |
|
pred@1958
|
91 |
{ |
|
pred@1958
|
92 |
public: |
|
dvander@1992
|
93 |
EntityOutputManager(); |
|
dvander@1992
|
94 |
~EntityOutputManager(); |
|
dvander@1992
|
95 |
public: |
|
dvander@1992
|
96 |
void Init(); |
|
pred@1958
|
97 |
|
|
dvander@1992
|
98 |
bool IsEnabled(); |
|
pred@1958
|
99 |
|
|
pred@1958
|
100 |
void FireEventDetour(void *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay); |
|
pred@1958
|
101 |
|
|
pred@1958
|
102 |
void OnPluginDestroyed(IPlugin *plugin); |
|
pred@1958
|
103 |
|
|
pred@1958
|
104 |
OutputNameStruct *FindOutputPointer(const char *classname, const char *outputname, bool create); |
|
pred@1958
|
105 |
|
|
pred@1958
|
106 |
void CleanUpHook(omg_hooks *hook); |
|
pred@1958
|
107 |
|
|
pred@1958
|
108 |
omg_hooks *NewHook(); |
|
pred@1958
|
109 |
|
|
pred@1958
|
110 |
void OnHookAdded(); |
|
pred@1958
|
111 |
void OnHookRemoved(); |
|
pred@1958
|
112 |
|
|
pred@1958
|
113 |
private: |
|
pred@1958
|
114 |
bool enabled; |
|
pred@1958
|
115 |
|
|
pred@1958
|
116 |
// Patch/unpatch the server dll |
|
pred@1958
|
117 |
void InitFireEventDetour(); |
|
pred@1958
|
118 |
void ShutdownFireEventDetour(); |
|
pred@1958
|
119 |
bool is_detoured; |
|
pred@1958
|
120 |
|
|
pred@1958
|
121 |
//These create/delete the allocated memory and write into it |
|
pred@1958
|
122 |
bool CreateFireEventDetour(); |
|
pred@1958
|
123 |
void DeleteFireEventDetour(); |
|
pred@1958
|
124 |
|
|
pred@1958
|
125 |
const char *FindOutputName(void *pOutput, CBaseEntity *pCaller); |
|
pred@1958
|
126 |
edict_t *BaseHandleToEdict(CBaseHandle &hndl); |
|
pred@1958
|
127 |
|
|
pred@1958
|
128 |
//Maps CEntityOutput * to a OutputNameStruct |
|
pred@1958
|
129 |
IBasicTrie *EntityOutputs; |
|
pred@1958
|
130 |
// Maps classname to a ClassNameStruct |
|
pred@1958
|
131 |
IBasicTrie *ClassNames; |
|
pred@1958
|
132 |
|
|
pred@1958
|
133 |
SourceHook::CStack<omg_hooks *> FreeHooks; //Stores hook pointers to avoid calls to new |
|
pred@1958
|
134 |
|
|
pred@1958
|
135 |
int HookCount; |
|
pred@1958
|
136 |
|
|
pred@1958
|
137 |
patch_t info_restore; |
|
pred@1958
|
138 |
void *info_address; |
|
pred@1958
|
139 |
void *info_callback; |
|
pred@1958
|
140 |
}; |
|
pred@1958
|
141 |
|
|
pred@1958
|
142 |
void TempDetour(void *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay); |
|
pred@1958
|
143 |
|
|
pred@1958
|
144 |
extern EntityOutputManager g_OutputManager; |
|
pred@1958
|
145 |
|
|
pred@1958
|
146 |
extern sp_nativeinfo_t g_EntOutputNatives[]; |
|
pred@1958
|
147 |
|
|
pred@1958
|
148 |
#endif //_INCLUDE_SOURCEMOD_OUTPUT_H_ |