|
ds@1990
|
1 |
/** |
|
ds@1990
|
2 |
* vim: set ts=4 : |
|
ds@1990
|
3 |
* ============================================================================= |
|
ds@1990
|
4 |
* SourceMod Extension Code for Metamod:Source |
|
ds@1990
|
5 |
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. |
|
ds@1990
|
6 |
* ============================================================================= |
|
ds@1990
|
7 |
* |
|
ds@1990
|
8 |
* This program is free software; you can redistribute it and/or modify it under |
|
ds@1990
|
9 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
ds@1990
|
10 |
* Free Software Foundation. |
|
ds@1990
|
11 |
* |
|
ds@1990
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
ds@1990
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
ds@1990
|
14 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
ds@1990
|
15 |
* details. |
|
ds@1990
|
16 |
* |
|
ds@1990
|
17 |
* You should have received a copy of the GNU General Public License along with |
|
ds@1990
|
18 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
ds@1990
|
19 |
* |
|
ds@1990
|
20 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
ds@1990
|
21 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
ds@1990
|
22 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
ds@1990
|
23 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
ds@1990
|
24 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
ds@1990
|
25 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
ds@1990
|
26 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
ds@1990
|
27 |
* or <http://www.sourcemod.net/license.php>. |
|
ds@1990
|
28 |
* |
|
ds@1990
|
29 |
* Version: $Id$ |
|
ds@1990
|
30 |
*/ |
|
ds@1990
|
31 |
|
|
ds@1990
|
32 |
#include <stdio.h> |
|
ds@1990
|
33 |
#include "stub_mm.h" |
|
ds@1990
|
34 |
#include "stub_util.h" |
|
ds@1990
|
35 |
#include "sm_ext.h" |
|
ds@1990
|
36 |
|
|
ds@1990
|
37 |
MyExtension g_SMExt; |
|
ds@1990
|
38 |
|
|
ds@1990
|
39 |
bool SM_LoadExtension(char *error, size_t maxlength) |
|
ds@1990
|
40 |
{ |
|
ds@1990
|
41 |
if ((smexts = (IExtensionManager *)g_SMAPI->MetaFactory( |
|
ds@1990
|
42 |
SOURCEMOD_INTERFACE_EXTENSIONS, |
|
ds@1990
|
43 |
NULL, |
|
ds@1990
|
44 |
NULL)) |
|
ds@1990
|
45 |
== NULL) |
|
ds@1990
|
46 |
{ |
|
ds@1990
|
47 |
if (error && maxlength) |
|
ds@1990
|
48 |
{ |
|
ds@1990
|
49 |
UTIL_Format(error, maxlength, SOURCEMOD_INTERFACE_EXTENSIONS " interface not found"); |
|
ds@1990
|
50 |
} |
|
ds@1990
|
51 |
return false; |
|
ds@1990
|
52 |
} |
|
ds@1990
|
53 |
|
|
ds@1990
|
54 |
/* This could be more dynamic */ |
|
ds@1990
|
55 |
char path[256]; |
|
ds@1990
|
56 |
g_SMAPI->PathFormat(path, |
|
ds@1990
|
57 |
sizeof(path), |
|
ds@1990
|
58 |
"addons/myplugin/bin/myplugin%s", |
|
ds@1990
|
59 |
#if defined __linux__ |
|
ds@1990
|
60 |
"_i486.so" |
|
ds@1990
|
61 |
#else |
|
ds@1990
|
62 |
".dll" |
|
ds@1990
|
63 |
#endif |
|
ds@1990
|
64 |
); |
|
ds@1990
|
65 |
|
|
ds@1990
|
66 |
if ((myself = smexts->LoadExternal(&g_SMExt, |
|
ds@1990
|
67 |
path, |
|
ds@1990
|
68 |
"myplugin_mm.ext", |
|
ds@1990
|
69 |
error, |
|
ds@1990
|
70 |
maxlength)) |
|
ds@1990
|
71 |
== NULL) |
|
ds@1990
|
72 |
{ |
|
ds@1990
|
73 |
SM_UnsetInterfaces(); |
|
ds@1990
|
74 |
return false; |
|
ds@1990
|
75 |
} |
|
ds@1990
|
76 |
|
|
ds@1990
|
77 |
return true; |
|
ds@1990
|
78 |
} |
|
ds@1990
|
79 |
|
|
ds@1990
|
80 |
void SM_UnloadExtension() |
|
ds@1990
|
81 |
{ |
|
ds@1990
|
82 |
smexts->UnloadExtension(myself); |
|
ds@1990
|
83 |
} |
|
ds@1990
|
84 |
|
|
ds@1990
|
85 |
bool MyExtension::OnExtensionLoad(IExtension *me, |
|
ds@1990
|
86 |
IShareSys *sys, |
|
ds@1990
|
87 |
char *error, |
|
ds@1990
|
88 |
size_t maxlength, |
|
ds@1990
|
89 |
bool late) |
|
ds@1990
|
90 |
{ |
|
ds@1990
|
91 |
sharesys = sys; |
|
ds@1990
|
92 |
myself = me; |
|
ds@1990
|
93 |
|
|
ds@1990
|
94 |
/* Get the default interfaces from our configured SDK header */ |
|
ds@1990
|
95 |
if (!SM_AcquireInterfaces(error, maxlength)) |
|
ds@1990
|
96 |
{ |
|
ds@1990
|
97 |
return false; |
|
ds@1990
|
98 |
} |
|
ds@1990
|
99 |
|
|
ds@1990
|
100 |
return true; |
|
ds@1990
|
101 |
} |
|
ds@1990
|
102 |
|
|
ds@1990
|
103 |
void MyExtension::OnExtensionUnload() |
|
ds@1990
|
104 |
{ |
|
ds@1990
|
105 |
/* Clean up any resources here, and more importantly, make sure |
|
ds@1990
|
106 |
* any listeners/hooks into SourceMod are totally removed, as well |
|
ds@1990
|
107 |
* as data structures like handle types and forwards. |
|
ds@1990
|
108 |
*/ |
|
ds@1990
|
109 |
|
|
ds@1990
|
110 |
//... |
|
ds@1990
|
111 |
|
|
ds@1990
|
112 |
/* Make sure our pointers get NULL'd just in case */ |
|
ds@1990
|
113 |
SM_UnsetInterfaces(); |
|
ds@1990
|
114 |
} |
|
ds@1990
|
115 |
|
|
ds@1990
|
116 |
void MyExtension::OnExtensionsAllLoaded() |
|
ds@1990
|
117 |
{ |
|
ds@1990
|
118 |
/* Called once all extensions are marked as loaded. |
|
ds@1990
|
119 |
* This always called, and always called only once. |
|
ds@1990
|
120 |
*/ |
|
ds@1990
|
121 |
} |
|
ds@1990
|
122 |
|
|
ds@1990
|
123 |
void MyExtension::OnExtensionPauseChange(bool pause) |
|
ds@1990
|
124 |
{ |
|
ds@1990
|
125 |
} |
|
ds@1990
|
126 |
|
|
ds@1990
|
127 |
bool MyExtension::QueryRunning(char *error, size_t maxlength) |
|
ds@1990
|
128 |
{ |
|
ds@1990
|
129 |
/* if something is required that can't be determined during the initial |
|
ds@1990
|
130 |
* load process, print a message here will show a helpful message to |
|
ds@1990
|
131 |
* users when they view the extension's info. |
|
ds@1990
|
132 |
*/ |
|
ds@1990
|
133 |
return true; |
|
ds@1990
|
134 |
} |
|
ds@1990
|
135 |
|
|
ds@1990
|
136 |
bool MyExtension::IsMetamodExtension() |
|
ds@1990
|
137 |
{ |
|
ds@1990
|
138 |
/* Must return false! */ |
|
ds@1990
|
139 |
return false; |
|
ds@1990
|
140 |
} |
|
ds@1990
|
141 |
|
|
ds@1990
|
142 |
const char *MyExtension::GetExtensionName() |
|
ds@1990
|
143 |
{ |
|
ds@1990
|
144 |
return mmsplugin->GetName(); |
|
ds@1990
|
145 |
} |
|
ds@1990
|
146 |
|
|
ds@1990
|
147 |
const char *MyExtension::GetExtensionURL() |
|
ds@1990
|
148 |
{ |
|
ds@1990
|
149 |
return mmsplugin->GetURL(); |
|
ds@1990
|
150 |
} |
|
ds@1990
|
151 |
|
|
ds@1990
|
152 |
const char *MyExtension::GetExtensionTag() |
|
ds@1990
|
153 |
{ |
|
ds@1990
|
154 |
return mmsplugin->GetLogTag(); |
|
ds@1990
|
155 |
} |
|
ds@1990
|
156 |
|
|
ds@1990
|
157 |
const char *MyExtension::GetExtensionAuthor() |
|
ds@1990
|
158 |
{ |
|
ds@1990
|
159 |
return mmsplugin->GetAuthor(); |
|
ds@1990
|
160 |
} |
|
ds@1990
|
161 |
|
|
ds@1990
|
162 |
const char *MyExtension::GetExtensionVerString() |
|
ds@1990
|
163 |
{ |
|
ds@1990
|
164 |
return mmsplugin->GetVersion(); |
|
ds@1990
|
165 |
} |
|
ds@1990
|
166 |
|
|
ds@1990
|
167 |
const char *MyExtension::GetExtensionDescription() |
|
ds@1990
|
168 |
{ |
|
ds@1990
|
169 |
return mmsplugin->GetDescription(); |
|
ds@1990
|
170 |
} |
|
ds@1990
|
171 |
|
|
ds@1990
|
172 |
const char *MyExtension::GetExtensionDateString() |
|
ds@1990
|
173 |
{ |
|
ds@1990
|
174 |
return mmsplugin->GetDate(); |
|
ds@1990
|
175 |
} |
|
ds@1990
|
176 |
|