Trigger build for hl2sdk-l4d changes.
2 * vim: set ts=4 sw=4 tw=99 noet:
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_INTERCOM_H_
33 #define _INCLUDE_SOURCEMOD_INTERCOM_H_
35 #include <sp_vm_api.h>
36 #include <IHandleSys.h>
37 #include <IShareSys.h>
38 #include <IPluginSys.h>
39 #include <IDBDriver.h>
40 #include <sh_string.h>
41 #include <sp_vm_api.h>
42 #include <sh_vector.h>
43 #include <IExtensionSys.h>
44 #include <IForwardSys.h>
46 using namespace SourceMod;
47 using namespace SourcePawn;
48 using namespace SourceHook;
51 * Add 1 to the RHS of this expression to bump the intercom file
52 * This is to prevent mismatching core/logic binaries
54 #define SM_LOGIC_MAGIC (0x0F47C0DE - 27)
59 class IVEngineServer_Logic
63 virtual bool IsMapValid(const char *map) = 0;
64 virtual void ServerCommand(const char *cmd) = 0;
67 typedef void * FileHandle_t;
68 typedef int FileFindHandle_t;
73 class IFileSystem_Logic
77 virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0;
78 virtual const char *FindNext(FileFindHandle_t handle) = 0;
79 virtual void FindClose(FileFindHandle_t handle) = 0;
80 virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0;
81 virtual void Close(FileHandle_t file) = 0;
82 virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0;
83 virtual bool EndOfFile(FileHandle_t file) = 0;
84 virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0;
85 virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0;
96 class IForwardManager;
101 class IPhraseCollection;
106 class IVEngineServer;
114 class IChangeableForward;
119 const double *universalTime;
120 float *interval_per_tick;
126 SourceHook::String autocfg;
127 SourceHook::String folder;
133 LibraryAction_Removed,
139 class SMPlugin : public IPlugin
142 virtual size_t GetConfigCount() = 0;
143 virtual AutoConfig *GetConfig(size_t i) = 0;
144 virtual void AddLibrary(const char *name) = 0;
145 virtual void AddConfig(bool create, const char *cfg, const char *folder) = 0;
146 virtual void SetErrorState(PluginStatus status, const char *fmt, ...) = 0;
152 virtual void LoadAll(const char *config_path, const char *plugins_path) = 0;
153 virtual void RefreshAll() = 0;
154 virtual void Shutdown() = 0;
155 virtual IdentityToken_t *GetIdentity() = 0;
156 virtual void SyncMaxClients(int maxClients) = 0;
157 virtual void AddPluginsListener(IPluginsListener *listener) = 0;
158 virtual void RemovePluginsListener(IPluginsListener *listener) = 0;
159 virtual IPluginIterator *GetPluginIterator() = 0;
160 virtual void OnLibraryAction(const char *name, LibraryAction action) = 0;
161 virtual bool LibraryExists(const char *name) = 0;
162 virtual SMPlugin *FindPluginByOrder(unsigned num) = 0;
163 virtual SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) = 0;
164 virtual SMPlugin *FindPluginByContext(IPluginContext *ctx) = 0;
165 virtual SMPlugin *FindPluginByContext(sp_context_t *ctx) = 0;
166 virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
167 virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
168 virtual bool UnloadPlugin(IPlugin *plugin) = 0;
169 virtual const CVector<SMPlugin *> *ListPlugins() = 0;
170 virtual void FreePluginList(const CVector<SMPlugin *> *list) = 0;
171 virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
174 class IExtensionSys : public IExtensionManager
177 virtual IExtension *LoadAutoExtension(const char *name, bool bErrorOnMissing=true) = 0;
178 virtual void TryAutoload() = 0;
179 virtual void Shutdown() = 0;
180 virtual IExtension *FindExtensionByFile(const char *name) = 0;
181 virtual bool LibraryExists(const char *name) = 0;
182 virtual void CallOnCoreMapStart(edict_t *edictList, int edictCount, int maxClients) = 0;
183 virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
184 virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
185 virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
186 virtual const CVector<IExtension *> *ListExtensions() = 0;
187 virtual void FreeExtensionList(const CVector<IExtension *> *list) = 0;
193 AutoPluginList(IScriptManager *scripts)
194 : scripts_(scripts), list_(scripts->ListPlugins())
199 scripts_->FreePluginList(list_);
201 const CVector<SMPlugin *> *operator ->()
206 IScriptManager *scripts_;
207 const CVector<SMPlugin *> *list_;
210 class AutoExtensionList
213 AutoExtensionList(IExtensionSys *extensions)
214 : extensions_(extensions), list_(extensions_->ListExtensions())
219 extensions_->FreeExtensionList(list_);
221 const CVector<IExtension *> *operator ->()
226 IExtensionSys *extensions_;
227 const CVector<IExtension *> *list_;
237 IVEngineServer *engine;
238 IFileSystem *filesystem;
239 IRootConsole *rootmenu;
240 ITimerSystem *timersys;
241 IPlayerManager *playerhelpers;
242 IAdminSystem *adminsys;
243 IGameHelpers *gamehelpers;
244 ISourcePawnEngine **spe1;
245 ISourcePawnEngine2 **spe2;
247 ConVar * (*FindConVar)(const char*);
248 unsigned int (*strncopy)(char*, const char*, size_t);
249 char * (*TrimWhitespace)(char *, size_t &);
250 void (*LogError)(const char*, ...);
251 void (*LogFatal)(const char*, ...);
252 void (*Log)(const char*, ...);
253 void (*LogToFile)(FILE *fp, const char*, ...);
254 void (*LogToGame)(const char *message);
255 const char * (*GetCvarString)(ConVar*);
256 size_t (*Format)(char*, size_t, const char*, ...);
257 size_t (*FormatArgs)(char*, size_t, const char*,va_list ap);
258 bool (*gnprintf)(char *, size_t, const char *, IPhraseCollection *, void **,
259 unsigned int, unsigned int &, size_t *, const char **);
260 size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *);
261 bool (*GetGameName)(char *buffer, size_t maxlength);
262 const char * (*GetGameDescription)();
263 const char * (*GetSourceEngineName)();
264 bool (*SymbolsAreHidden)();
265 const char * (*GetCoreConfigValue)(const char*);
266 bool (*IsMapLoading)();
267 bool (*IsMapRunning)();
268 int (*Argc)(const CCommand &args);
269 const char * (*Arg)(const CCommand &args, int arg);
270 int (*LoadMMSPlugin)(const char *file, bool *ok, char *error, size_t maxlength);
271 void (*UnloadMMSPlugin)(int id);
272 void (*DoGlobalPluginLoads)();
273 bool (*AreConfigsExecuted)();
274 void (*ExecuteConfigs)(IPluginContext *ctx);
275 DatabaseInfo (*GetDBInfoFromKeyValues)(KeyValues *);
276 const char *gamesuffix;
278 ServerGlobals *serverGlobals;
279 void * serverFactory;
280 void * engineFactory;
281 void * matchmakingDSFactory;
282 SMGlobalClass * listeners;
290 ITranslator *translator;
291 const char *(*stristr)(const char *, const char *);
292 bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...);
293 void (*AddCorePhraseFile)(const char *filename);
294 unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool);
295 char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool);
296 size_t (*DecodeHexString)(unsigned char *, size_t, const char *);
297 IGameConfig * (*GetCoreGameConfig)();
298 bool (*OnLogPrint)(const char *msg); // true to supercede
299 IDebugListener *debugger;
300 void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
301 void (*AddNatives)(sp_nativeinfo_t *natives);
302 void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
303 IScriptManager *scripts;
305 IExtensionSys *extsys;
306 IHandleSys *handlesys;
307 IForwardManager *forwardsys;
308 IdentityToken_t *core_ident;
312 typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic);
313 typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
314 typedef ITextParsers *(*GetITextParsers)();
316 #endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */