diff --git a/bridge/include/BridgeAPI.h b/bridge/include/BridgeAPI.h new file mode 100644 index 00000000..80cc0331 --- /dev/null +++ b/bridge/include/BridgeAPI.h @@ -0,0 +1,46 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_API_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_API_H_ + +#include +#include +#include + +namespace SourceMod { + +// Add 1 to the RHS of this expression to bump the intercom file +// This is to prevent mismatching core/logic binaries +static const uint32_t SM_LOGIC_MAGIC = 0x0F47C0DE - 50; + +} // namespace SourceMod + +typedef void (*LogicInitFunction)(SourceMod::CoreProvider *core, SourceMod::sm_logic_t *logic); +typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic); +typedef SourceMod::ITextParsers *(*GetITextParsers)(); + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_API_H_ diff --git a/bridge/include/CoreProvider.h b/bridge/include/CoreProvider.h new file mode 100644 index 00000000..887d80a0 --- /dev/null +++ b/bridge/include/CoreProvider.h @@ -0,0 +1,132 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_ +#define _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_ + +#include +#include +#include + +namespace SourcePawn { +class ISourcePawnEngine; +class ISourcePawnEngine2; +} // namespace SourcePawn + +// SDK types. +#if defined(SM_LOGIC) +class ConCommandBase {}; +class ConVar : public ConCommandBase {}; +#else +class ConCommandBase; +class ConVar; +#endif +class KeyValues; + +struct ServerGlobals +{ + const double *universalTime; + float *interval_per_tick; + float *frametime; +}; + +namespace SourceMod { + +class ISourceMod; +class IVEngineServerBridge; +class IFileSystemBridge; +class ITimerSystem; +class IPlayerManager; +class IGameHelpers; +class IMenuManager; +struct DatabaseInfo; +class IPlayerInfoBridge; + +class CoreProvider +{ +public: + /* Objects */ + ISourceMod *sm; + IVEngineServerBridge *engine; + IFileSystemBridge *filesystem; + IPlayerInfoBridge *playerInfo; + ITimerSystem *timersys; + IPlayerManager *playerhelpers; + IGameHelpers *gamehelpers; + IMenuManager *menus; + SourcePawn::ISourcePawnEngine **spe1; + SourcePawn::ISourcePawnEngine2 **spe2; + const char *gamesuffix; + /* Data */ + ServerGlobals *serverGlobals; + void * serverFactory; + void * engineFactory; + void * matchmakingDSFactory; + SMGlobalClass * listeners; + + // ConVar functions. + virtual ConVar *FindConVar(const char *name) = 0; + virtual const char *GetCvarString(ConVar *cvar) = 0; + virtual bool GetCvarBool(ConVar* cvar) = 0; + + // Game description functions. + virtual bool GetGameName(char *buffer, size_t maxlength) = 0; + virtual const char *GetGameDescription() = 0; + virtual const char *GetSourceEngineName() = 0; + virtual bool SymbolsAreHidden() = 0; + + // Game state and helper functions. + virtual bool IsMapLoading() = 0; + virtual bool IsMapRunning() = 0; + virtual int MaxClients() = 0; + virtual bool DescribePlayer(int index, const char **namep, const char **authp, int *useridp) = 0; + virtual void LogToGame(const char *message) = 0; + virtual void ConPrint(const char *message) = 0; + virtual void ConsolePrintVa(const char *fmt, va_list ap) = 0; + + // Game engine helper functions. + virtual bool IsClientConVarQueryingSupported() = 0; + virtual int QueryClientConVar(int client, const char *cvar) = 0; + + // Metamod:Source functions. + virtual int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) = 0; + virtual void UnloadMMSPlugin(int id) = 0; + + const char * (*GetCoreConfigValue)(const char*); + void (*DoGlobalPluginLoads)(); + bool (*AreConfigsExecuted)(); + void (*ExecuteConfigs)(IPluginContext *ctx); + void (*GetDBInfoFromKeyValues)(KeyValues *, DatabaseInfo *); + int (*GetActivityFlags)(); + int (*GetImmunityMode)(); + void (*UpdateAdminCmdFlags)(const char *cmd, OverrideType type, FlagBits bits, bool remove); + bool (*LookForCommandAdminFlags)(const char *cmd, FlagBits *pFlags); + int (*GetGlobalTarget)(); +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_ diff --git a/bridge/include/IExtensionBridge.h b/bridge/include/IExtensionBridge.h new file mode 100644 index 00000000..4b41795f --- /dev/null +++ b/bridge/include/IExtensionBridge.h @@ -0,0 +1,81 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_ + +#include +#include +#include + +struct edict_t; + +namespace SourceMod { + +using namespace SourceHook; +using namespace SourcePawn; +class SMPlugin; + +class IExtensionSys : public IExtensionManager +{ +public: + virtual IExtension *LoadAutoExtension(const char *name, bool bErrorOnMissing=true) = 0; + virtual void TryAutoload() = 0; + virtual void Shutdown() = 0; + virtual IExtension *FindExtensionByFile(const char *name) = 0; + virtual bool LibraryExists(const char *name) = 0; + virtual void CallOnCoreMapStart(edict_t *edictList, int edictCount, int maxClients) = 0; + virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0; + virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0; + virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0; + virtual const CVector *ListExtensions() = 0; + virtual void FreeExtensionList(const CVector *list) = 0; + virtual void CallOnCoreMapEnd() = 0; +}; + +class AutoExtensionList +{ +public: + AutoExtensionList(IExtensionSys *extensions) + : extensions_(extensions), list_(extensions_->ListExtensions()) + { + } + ~AutoExtensionList() + { + extensions_->FreeExtensionList(list_); + } + const CVector *operator ->() + { + return list_; + } +private: + IExtensionSys *extensions_; + const CVector *list_; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_ diff --git a/bridge/include/IFileSystemBridge.h b/bridge/include/IFileSystemBridge.h new file mode 100644 index 00000000..33fe306c --- /dev/null +++ b/bridge/include/IFileSystemBridge.h @@ -0,0 +1,63 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_ + +typedef void * FileHandle_t; +typedef int FileFindHandle_t; + +namespace SourceMod { + +class IFileSystemBridge +{ +public: + virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0; + virtual const char *FindNext(FileFindHandle_t handle) = 0; + virtual bool FindIsDirectory(FileFindHandle_t handle) = 0; + virtual void FindClose(FileFindHandle_t handle) = 0; + virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0; + virtual void Close(FileHandle_t file) = 0; + virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; + virtual bool EndOfFile(FileHandle_t file) = 0; + virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0; + virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0; + virtual int Read(void* pOutput, int size, FileHandle_t file) = 0; + virtual int Write(void const* pInput, int size, FileHandle_t file) = 0; + virtual void Seek(FileHandle_t file, int post, int seekType) = 0; + virtual unsigned int Tell(FileHandle_t file) = 0; + virtual int FPrint(FileHandle_t file, const char *pData) = 0; + virtual void Flush(FileHandle_t file) = 0; + virtual bool IsOk(FileHandle_t file) = 0; + virtual void RemoveFile(const char *pRelativePath, const char *pathID = 0) = 0; + virtual void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID = 0) = 0; + virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0; + virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_ diff --git a/bridge/include/ILogger.h b/bridge/include/ILogger.h new file mode 100644 index 00000000..32887689 --- /dev/null +++ b/bridge/include/ILogger.h @@ -0,0 +1,43 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_ + +namespace SourceMod { + +class ILogger +{ +public: + virtual void LogMessage(const char *msg, ...) = 0; + virtual void LogError(const char *msg, ...) = 0; + virtual void LogFatal(const char *msg, ...) = 0; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_ + diff --git a/bridge/include/IPlayerInfoBridge.h b/bridge/include/IPlayerInfoBridge.h new file mode 100644 index 00000000..82f1ed51 --- /dev/null +++ b/bridge/include/IPlayerInfoBridge.h @@ -0,0 +1,55 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_ + +class IPlayerInfo; + +namespace SourceMod { + +class IPlayerInfoBridge +{ +public: + virtual bool IsObserver(IPlayerInfo *pInfo) = 0; + virtual int GetTeamIndex(IPlayerInfo *pInfo) = 0; + virtual int GetFragCount(IPlayerInfo *pInfo) = 0; + virtual int GetDeathCount(IPlayerInfo *pInfo) = 0; + virtual int GetArmorValue(IPlayerInfo *pInfo) = 0; + virtual void GetAbsOrigin(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; + virtual void GetAbsAngles(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; + virtual void GetPlayerMins(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; + virtual void GetPlayerMaxs(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; + virtual const char *GetWeaponName(IPlayerInfo *pInfo) = 0; + virtual const char *GetModelName(IPlayerInfo *pInfo) = 0; + virtual int GetHealth(IPlayerInfo *pInfo) = 0; + virtual void ChangeTeam(IPlayerInfo *pInfo, int iTeamNum) = 0; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_ + diff --git a/bridge/include/IProviderCallbacks.h b/bridge/include/IProviderCallbacks.h new file mode 100644 index 00000000..1ddfd0ae --- /dev/null +++ b/bridge/include/IProviderCallbacks.h @@ -0,0 +1,42 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_ + +namespace SourceMod { + +// Global callbacks provided to Core. +class IProviderCallbacks +{ +public: + // Called when a log message is printed. Return true to supercede. + virtual bool OnLogPrint(const char *msg) = 0; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_ diff --git a/bridge/include/IScriptManager.h b/bridge/include/IScriptManager.h new file mode 100644 index 00000000..9df38cd0 --- /dev/null +++ b/bridge/include/IScriptManager.h @@ -0,0 +1,112 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_ + +#include +#include +#include +#include + +namespace SourceMod { + +using namespace SourceHook; +using namespace SourcePawn; + +class IChangeableForward; + +enum LibraryAction +{ + LibraryAction_Removed, + LibraryAction_Added +}; + +struct AutoConfig +{ + SourceHook::String autocfg; + SourceHook::String folder; + bool create; +}; + +class SMPlugin : public IPlugin +{ +public: + virtual size_t GetConfigCount() = 0; + virtual AutoConfig *GetConfig(size_t i) = 0; + virtual void AddLibrary(const char *name) = 0; + virtual void AddConfig(bool create, const char *cfg, const char *folder) = 0; + virtual void SetErrorState(PluginStatus status, const char *fmt, ...) = 0; +}; + +class IScriptManager +{ +public: + virtual void LoadAll(const char *config_path, const char *plugins_path) = 0; + virtual void RefreshAll() = 0; + virtual void Shutdown() = 0; + virtual IdentityToken_t *GetIdentity() = 0; + virtual void SyncMaxClients(int maxClients) = 0; + virtual void AddPluginsListener(IPluginsListener *listener) = 0; + virtual void RemovePluginsListener(IPluginsListener *listener) = 0; + virtual IPluginIterator *GetPluginIterator() = 0; + virtual void OnLibraryAction(const char *name, LibraryAction action) = 0; + virtual bool LibraryExists(const char *name) = 0; + virtual SMPlugin *FindPluginByOrder(unsigned num) = 0; + virtual SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) = 0; + virtual SMPlugin *FindPluginByContext(IPluginContext *ctx) = 0; + virtual SMPlugin *FindPluginByContext(sp_context_t *ctx) = 0; + virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0; + virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0; + virtual bool UnloadPlugin(IPlugin *plugin) = 0; + virtual const CVector *ListPlugins() = 0; + virtual void FreePluginList(const CVector *list) = 0; + virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0; +}; + +class AutoPluginList +{ +public: + AutoPluginList(IScriptManager *scripts) + : scripts_(scripts), list_(scripts->ListPlugins()) + { + } + ~AutoPluginList() + { + scripts_->FreePluginList(list_); + } + const CVector *operator ->() + { + return list_; + } +private: + IScriptManager *scripts_; + const CVector *list_; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_ diff --git a/bridge/include/IVEngineServerBridge.h b/bridge/include/IVEngineServerBridge.h new file mode 100644 index 00000000..cf17f7c2 --- /dev/null +++ b/bridge/include/IVEngineServerBridge.h @@ -0,0 +1,48 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_ +#define _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_ + +struct edict_t; + +namespace SourceMod { + +class IVEngineServerBridge +{ +public: + virtual bool IsDedicatedServer() = 0; + virtual void InsertServerCommand(const char *cmd) = 0; + virtual void ServerCommand(const char *cmd) = 0; + virtual void ServerExecute() = 0; + virtual const char *GetClientConVarValue(int clientIndex, const char *name) = 0; + virtual void ClientCommand(edict_t *pEdict, const char *szCommand) = 0; + virtual void FakeClientCommand(edict_t *pEdict, const char *szCommand) = 0; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_ diff --git a/bridge/include/LogicProvider.h b/bridge/include/LogicProvider.h new file mode 100644 index 00000000..4b3c33b5 --- /dev/null +++ b/bridge/include/LogicProvider.h @@ -0,0 +1,90 @@ +// vim: set ts=4 sw=4 tw=99 noet: +// ============================================================================= +// SourceMod +// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved. +// ============================================================================= +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License, version 3.0, as published by the +// Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program. If not, see . +// +// As a special exception, AlliedModders LLC gives you permission to link the +// code of this program (as well as its derivative works) to "Half-Life 2," the +// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software +// by the Valve Corporation. You must obey the GNU General Public License in +// all respects for all other code used. Additionally, AlliedModders LLC grants +// this exception to all derivative works. AlliedModders LLC defines further +// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), +// or . +#ifndef _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_ +#define _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_ + +#include + +class SMGlobalClass; + +namespace SourceMod { + +using namespace SourcePawn; + +class CoreProvider; +class IThreader; +class ITranslator; +class IGameConfig; +class IScriptManager; +class IShareSys; +class IHandleSys; +class ICommandArgs; +class IForwardManager; +class IAdminSystem; +class IRootConsole; +class IProviderCallbacks; +class IExtensionSys; +class ITextParsers; +class ILogger; + +struct sm_logic_t +{ + SMGlobalClass *head; + IThreader *threader; + ITranslator *translator; + const char *(*stristr)(const char *, const char *); + size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *); + bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...); + void (*AddCorePhraseFile)(const char *filename); + unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool); + char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool); + size_t (*DecodeHexString)(unsigned char *, size_t, const char *); + IGameConfig * (*GetCoreGameConfig)(); + IDebugListener *debugger; + void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); + void (*AddNatives)(sp_nativeinfo_t *natives); + void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...)); + bool (*DumpAdminCache)(const char *filename); + void (*RegisterProfiler)(IProfilingTool *tool); + void (*OnRootCommand)(const ICommandArgs *args); + IScriptManager *scripts; + IShareSys *sharesys; + IExtensionSys *extsys; + IHandleSys *handlesys; + IForwardManager *forwardsys; + IAdminSystem *adminsys; + IdentityToken_t *core_ident; + ILogger *logger; + IRootConsole *rootmenu; + IProviderCallbacks *callbacks; + float sentinel; +}; + +} // namespace SourceMod + +#endif // _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_ + diff --git a/core/AMBuilder b/core/AMBuilder index 6c9e6a1e..85181755 100644 --- a/core/AMBuilder +++ b/core/AMBuilder @@ -51,6 +51,10 @@ for sdk_name in SM.sdks: binary = SM.HL2Config(project, binary_name, sdk) compiler = binary.compiler + compiler.cxxincludes += [ + builder.sourcePath + ] + if sdk.name == 'csgo': compiler.cxxincludes += [ os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'), diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index 92e31ba2..386e2900 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -36,6 +36,7 @@ #include "ChatTriggers.h" #include "logic_bridge.h" #include "sourcemod.h" +#include using namespace ke; diff --git a/core/ConVarManager.cpp b/core/ConVarManager.cpp index 374db25b..11fcd00e 100644 --- a/core/ConVarManager.cpp +++ b/core/ConVarManager.cpp @@ -35,6 +35,7 @@ #include "logic_bridge.h" #include "sourcemod.h" #include "provider.h" +#include ConVarManager g_ConVarManager; diff --git a/core/ConsoleDetours.cpp b/core/ConsoleDetours.cpp index fba52721..9d797393 100644 --- a/core/ConsoleDetours.cpp +++ b/core/ConsoleDetours.cpp @@ -51,6 +51,7 @@ #include "ConCommandBaseIterator.h" #include "logic_bridge.h" #include +#include #if defined PLATFORM_POSIX # include diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index ed3c1f44..bc04ad92 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -42,6 +42,9 @@ #include #include #include +#include +#include +#include using namespace SourceHook; diff --git a/core/EventManager.cpp b/core/EventManager.cpp index 89d4da25..80e20a5d 100644 --- a/core/EventManager.cpp +++ b/core/EventManager.cpp @@ -32,6 +32,7 @@ #include "EventManager.h" #include "sm_stringutil.h" #include "logic_bridge.h" +#include EventManager g_EventManager; diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 722c8473..4a8d9822 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -41,6 +41,7 @@ #include #include "logic_bridge.h" #include +#include #if SOURCE_ENGINE == SE_DOTA #include diff --git a/core/Logger.cpp b/core/Logger.cpp index 0e57367e..2312e3b0 100644 --- a/core/Logger.cpp +++ b/core/Logger.cpp @@ -37,6 +37,7 @@ #include "TimerSys.h" #include "logic_bridge.h" #include +#include bool g_in_game_log_hook = false; diff --git a/core/NextMap.cpp b/core/NextMap.cpp index 3712f874..660f3f9b 100644 --- a/core/NextMap.cpp +++ b/core/NextMap.cpp @@ -37,6 +37,8 @@ #include "sourcehook.h" #include "logic_bridge.h" #include "compat_wrappers.h" +#include +#include NextMapManager g_NextMap; diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index c00d2364..58596dcd 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -47,6 +47,9 @@ #include "logic_bridge.h" #include #include "smn_keyvalues.h" +#include +#include +#include PlayerManager g_Players; bool g_OnMapStarted = false; diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder index a9bfd967..56955df5 100644 --- a/core/logic/AMBuilder +++ b/core/logic/AMBuilder @@ -3,6 +3,7 @@ import os binary = SM.Library(builder, 'sourcemod.logic') binary.compiler.cxxincludes += [ + builder.sourcePath, os.path.join(builder.sourcePath, 'core', 'logic'), os.path.join(builder.sourcePath, 'public'), os.path.join(builder.sourcePath, 'sourcepawn', 'include'), diff --git a/core/logic/AdminCache.cpp b/core/logic/AdminCache.cpp index fb227e83..b55b892a 100644 --- a/core/logic/AdminCache.cpp +++ b/core/logic/AdminCache.cpp @@ -40,6 +40,9 @@ #include "Translator.h" #include "common_logic.h" #include "stringutil.h" +#include +#include +#include #define LEVEL_STATE_NONE 0 #define LEVEL_STATE_LEVELS 1 diff --git a/core/logic/Database.cpp b/core/logic/Database.cpp index e203eb86..c7dd38d4 100644 --- a/core/logic/Database.cpp +++ b/core/logic/Database.cpp @@ -36,6 +36,7 @@ #include "PluginSys.h" #include #include +#include #define DBPARSE_LEVEL_NONE 0 #define DBPARSE_LEVEL_MAIN 1 diff --git a/core/logic/ExtensionSys.cpp b/core/logic/ExtensionSys.cpp index 66b7cec7..673eda3b 100644 --- a/core/logic/ExtensionSys.cpp +++ b/core/logic/ExtensionSys.cpp @@ -37,6 +37,8 @@ #include "PluginSys.h" #include #include +#include +#include CExtensionManager g_Extensions; IdentityType_t g_ExtType; diff --git a/core/logic/ExtensionSys.h b/core/logic/ExtensionSys.h index 04ec5a00..be310494 100644 --- a/core/logic/ExtensionSys.h +++ b/core/logic/ExtensionSys.h @@ -41,6 +41,7 @@ #include #include "NativeOwner.h" #include "ShareSys.h" +#include class CPlayer; diff --git a/core/logic/ForwardSys.cpp b/core/logic/ForwardSys.cpp index f74a2968..37c5188e 100644 --- a/core/logic/ForwardSys.cpp +++ b/core/logic/ForwardSys.cpp @@ -35,6 +35,7 @@ #include "ForwardSys.h" #include "DebugReporter.h" #include "common_logic.h" +#include CForwardManager g_Forwards; diff --git a/core/logic/GameConfigs.cpp b/core/logic/GameConfigs.cpp index b7fcda5d..792db8a2 100644 --- a/core/logic/GameConfigs.cpp +++ b/core/logic/GameConfigs.cpp @@ -43,6 +43,8 @@ #include "sm_crc32.h" #include "MemoryUtils.h" #include +#include +#include #if defined PLATFORM_POSIX #include diff --git a/core/logic/GameConfigs.h b/core/logic/GameConfigs.h index 6e970688..2ed1de50 100644 --- a/core/logic/GameConfigs.h +++ b/core/logic/GameConfigs.h @@ -40,7 +40,6 @@ #include using namespace SourceMod; -using namespace SourceHook; class SendProp; diff --git a/core/logic/HandleSys.cpp b/core/logic/HandleSys.cpp index 53385988..afa37850 100644 --- a/core/logic/HandleSys.cpp +++ b/core/logic/HandleSys.cpp @@ -37,6 +37,7 @@ #include "ExtensionSys.h" #include "PluginSys.h" #include +#include HandleSystem g_HandleSys; diff --git a/core/logic/Logger.cpp b/core/logic/Logger.cpp index 00b612a6..2671016d 100644 --- a/core/logic/Logger.cpp +++ b/core/logic/Logger.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include Logger g_Logger; diff --git a/core/logic/Logger.h b/core/logic/Logger.h index 8d8ebcee..f2d6b200 100644 --- a/core/logic/Logger.h +++ b/core/logic/Logger.h @@ -32,10 +32,10 @@ #ifndef _INCLUDE_SOURCEMOD_CLOGGER_H_ #define _INCLUDE_SOURCEMOD_CLOGGER_H_ +#include "common_logic.h" #include #include - -#include "common_logic.h" +#include using namespace SourceHook; diff --git a/core/logic/Native.h b/core/logic/Native.h index b11304ab..cd86f528 100644 --- a/core/logic/Native.h +++ b/core/logic/Native.h @@ -38,6 +38,8 @@ #include #include "common_logic.h" +class CNativeOwner; + struct FakeNative { FakeNative(const char *name, IPluginFunction *fun) diff --git a/core/logic/NativeOwner.h b/core/logic/NativeOwner.h index 43b79ee2..e8037827 100644 --- a/core/logic/NativeOwner.h +++ b/core/logic/NativeOwner.h @@ -37,6 +37,7 @@ #include #include "common_logic.h" #include "Native.h" +#include struct Native; class CPlugin; diff --git a/core/logic/PluginSys.cpp b/core/logic/PluginSys.cpp index 8f5bd3b7..3bd6ef73 100644 --- a/core/logic/PluginSys.cpp +++ b/core/logic/PluginSys.cpp @@ -44,6 +44,8 @@ #include "Translator.h" #include "Logger.h" #include +#include +#include CPluginManager g_PluginSys; HandleType_t g_PluginType = 0; diff --git a/core/logic/PluginSys.h b/core/logic/PluginSys.h index 6af3ae33..2073f0e3 100644 --- a/core/logic/PluginSys.h +++ b/core/logic/PluginSys.h @@ -50,6 +50,7 @@ #include "IGameConfigs.h" #include "NativeOwner.h" #include "ShareSys.h" +#include class CPlayer; diff --git a/core/logic/RootConsoleMenu.cpp b/core/logic/RootConsoleMenu.cpp index 5317d5fb..b6cacc7c 100644 --- a/core/logic/RootConsoleMenu.cpp +++ b/core/logic/RootConsoleMenu.cpp @@ -27,6 +27,7 @@ #include "RootConsoleMenu.h" #include #include +#include RootConsoleMenu g_RootMenu; diff --git a/core/logic/Translator.cpp b/core/logic/Translator.cpp index cbd0ac49..05e9684d 100644 --- a/core/logic/Translator.cpp +++ b/core/logic/Translator.cpp @@ -42,6 +42,8 @@ #include "stringutil.h" #include "sprintf.h" #include +#include +#include Translator g_Translator; IPhraseCollection *g_pCorePhrases = NULL; diff --git a/core/logic/Translator.h b/core/logic/Translator.h index 177a2a70..601e9b41 100644 --- a/core/logic/Translator.h +++ b/core/logic/Translator.h @@ -42,6 +42,7 @@ /* :TODO: write a templatized version of tries? */ +using namespace SourceMod; using namespace SourceHook; class Translator; diff --git a/core/logic/common_logic.cpp b/core/logic/common_logic.cpp index 44f9b71c..96ffc9ad 100644 --- a/core/logic/common_logic.cpp +++ b/core/logic/common_logic.cpp @@ -54,6 +54,8 @@ #include "sprintf.h" #include "LibrarySys.h" #include "RootConsoleMenu.h" +#include +#include SMGlobalClass *SMGlobalClass::head = NULL; diff --git a/core/logic/common_logic.h b/core/logic/common_logic.h index 05286b3e..f2510212 100644 --- a/core/logic/common_logic.h +++ b/core/logic/common_logic.h @@ -32,32 +32,53 @@ #ifndef _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ #define _INCLUDE_SOURCEMOD_COMMON_LOGIC_H_ -#include - #include "../sm_globals.h" -#include "intercom.h" -extern CoreProvider *bridge; -extern IHandleSys *handlesys; -extern ISourceMod *g_pSM; -extern ILibrarySys *libsys; -extern ITextParsers *textparser; -extern IShareSys *sharesys; -extern IRootConsole *rootmenu; -extern IPluginManager *pluginsys; -extern IForwardManager *forwardsys; -extern ITimerSystem *timersys; +namespace SourceMod { +class CoreProvider; +class IHandleSys; +class ISourceMod; +class ILibrarySys; +class ITextParsers; +class IShareSys; +class IRootConsole ; +class IPluginManager; +class IForwardManager; +class ITimerSystem; +class IPlayerManager; +class IAdminSystem; +class IGameHelpers; +class IScriptManager; +class IExtensionSys; +class ILogger; +class IMenuManager; +#if defined SM_LOGIC +class IVEngineServerBridge; +#endif +} // namespace SourceMod +struct ServerGlobals; + +extern SourceMod::CoreProvider *bridge; +extern SourceMod::IHandleSys *handlesys; +extern SourceMod::ISourceMod *g_pSM; +extern SourceMod::ILibrarySys *libsys; +extern SourceMod::ITextParsers *textparser; +extern SourceMod::IShareSys *sharesys; +extern SourceMod::IRootConsole *rootmenu; +extern SourceMod::IPluginManager *pluginsys; +extern SourceMod::IForwardManager *forwardsys; +extern SourceMod::ITimerSystem *timersys; extern ServerGlobals serverGlobals; -extern IPlayerManager *playerhelpers; -extern IAdminSystem *adminsys; -extern IGameHelpers *gamehelpers; -extern IScriptManager *scripts; -extern IExtensionSys *extsys; -extern ILogger *logger; -extern IMenuManager *menus; +extern SourceMod::IPlayerManager *playerhelpers; +extern SourceMod::IAdminSystem *adminsys; +extern SourceMod::IGameHelpers *gamehelpers; +extern SourceMod::IScriptManager *scripts; +extern SourceMod::IExtensionSys *extsys; +extern SourceMod::ILogger *logger; +extern SourceMod::IMenuManager *menus; #if defined SM_LOGIC -extern IVEngineServerBridge *engine; +extern SourceMod::IVEngineServerBridge *engine; #else extern IVEngineServer *engine; #endif diff --git a/core/logic/handle_helpers.h b/core/logic/handle_helpers.h index 4223088a..37530eec 100644 --- a/core/logic/handle_helpers.h +++ b/core/logic/handle_helpers.h @@ -32,6 +32,7 @@ #define _include_sourcemod_handle_helpers_h_ #include "common_logic.h" +#include // T must be a pointer type. template diff --git a/core/logic/intercom.h b/core/logic/intercom.h deleted file mode 100644 index b67323e1..00000000 --- a/core/logic/intercom.h +++ /dev/null @@ -1,374 +0,0 @@ -/** - * vim: set ts=4 sw=4 tw=99 noet: - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. - * ============================================================================= - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - * As a special exception, AlliedModders LLC gives you permission to link the - * code of this program (as well as its derivative works) to "Half-Life 2," the - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software - * by the Valve Corporation. You must obey the GNU General Public License in - * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), - * or . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_INTERCOM_H_ -#define _INCLUDE_SOURCEMOD_INTERCOM_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace SourceMod; -using namespace SourcePawn; -using namespace SourceHook; - -/** - * Add 1 to the RHS of this expression to bump the intercom file - * This is to prevent mismatching core/logic binaries - */ -#define SM_LOGIC_MAGIC (0x0F47C0DE - 48) - -class IVEngineServerBridge -{ -public: - virtual bool IsDedicatedServer() = 0; - virtual void InsertServerCommand(const char *cmd) = 0; - virtual void ServerCommand(const char *cmd) = 0; - virtual void ServerExecute() = 0; - virtual const char *GetClientConVarValue(int clientIndex, const char *name) = 0; - virtual void ClientCommand(edict_t *pEdict, const char *szCommand) = 0; - virtual void FakeClientCommand(edict_t *pEdict, const char *szCommand) = 0; -}; - -typedef void * FileHandle_t; -typedef int FileFindHandle_t; - -class IFileSystemBridge -{ -public: - virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0; - virtual const char *FindNext(FileFindHandle_t handle) = 0; - virtual bool FindIsDirectory(FileFindHandle_t handle) = 0; - virtual void FindClose(FileFindHandle_t handle) = 0; - virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0; - virtual void Close(FileHandle_t file) = 0; - virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0; - virtual bool EndOfFile(FileHandle_t file) = 0; - virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0; - virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0; - virtual int Read(void* pOutput, int size, FileHandle_t file) = 0; - virtual int Write(void const* pInput, int size, FileHandle_t file) = 0; - virtual void Seek(FileHandle_t file, int post, int seekType) = 0; - virtual unsigned int Tell(FileHandle_t file) = 0; - virtual int FPrint(FileHandle_t file, const char *pData) = 0; - virtual void Flush(FileHandle_t file) = 0; - virtual bool IsOk(FileHandle_t file) = 0; - virtual void RemoveFile(const char *pRelativePath, const char *pathID = 0) = 0; - virtual void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID = 0) = 0; - virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0; - virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0; -}; - -namespace SourceMod -{ - class ISourceMod; - class ILibrarySys; - class ITextParsers; - class IThreader; - class IRootConsole; - class IPluginManager; - class IForwardManager; - class ITimerSystem; - class IPlayerManager; - class IAdminSystem; - class IGameHelpers; - class IPhraseCollection; - class ITranslator; - class IGameConfig; - class IMenuManager; - class ICommandArgs; -} - -class ConVar; -class KeyValues; -class SMGlobalClass; -class IPlayerInfo; - -class IPlayerInfoBridge -{ -public: - virtual bool IsObserver(IPlayerInfo *pInfo) = 0; - virtual int GetTeamIndex(IPlayerInfo *pInfo) = 0; - virtual int GetFragCount(IPlayerInfo *pInfo) = 0; - virtual int GetDeathCount(IPlayerInfo *pInfo) = 0; - virtual int GetArmorValue(IPlayerInfo *pInfo) = 0; - virtual void GetAbsOrigin(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; - virtual void GetAbsAngles(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; - virtual void GetPlayerMins(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; - virtual void GetPlayerMaxs(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0; - virtual const char *GetWeaponName(IPlayerInfo *pInfo) = 0; - virtual const char *GetModelName(IPlayerInfo *pInfo) = 0; - virtual int GetHealth(IPlayerInfo *pInfo) = 0; - virtual void ChangeTeam(IPlayerInfo *pInfo, int iTeamNum) = 0; -}; - -namespace SourceMod -{ - class IChangeableForward; -} - -struct ServerGlobals -{ - const double *universalTime; - float *interval_per_tick; - float *frametime; -}; - -struct AutoConfig -{ - SourceHook::String autocfg; - SourceHook::String folder; - bool create; -}; - -enum LibraryAction -{ - LibraryAction_Removed, - LibraryAction_Added -}; - -class CNativeOwner; - -class SMPlugin : public IPlugin -{ -public: - virtual size_t GetConfigCount() = 0; - virtual AutoConfig *GetConfig(size_t i) = 0; - virtual void AddLibrary(const char *name) = 0; - virtual void AddConfig(bool create, const char *cfg, const char *folder) = 0; - virtual void SetErrorState(PluginStatus status, const char *fmt, ...) = 0; -}; - -class IScriptManager -{ -public: - virtual void LoadAll(const char *config_path, const char *plugins_path) = 0; - virtual void RefreshAll() = 0; - virtual void Shutdown() = 0; - virtual IdentityToken_t *GetIdentity() = 0; - virtual void SyncMaxClients(int maxClients) = 0; - virtual void AddPluginsListener(IPluginsListener *listener) = 0; - virtual void RemovePluginsListener(IPluginsListener *listener) = 0; - virtual IPluginIterator *GetPluginIterator() = 0; - virtual void OnLibraryAction(const char *name, LibraryAction action) = 0; - virtual bool LibraryExists(const char *name) = 0; - virtual SMPlugin *FindPluginByOrder(unsigned num) = 0; - virtual SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) = 0; - virtual SMPlugin *FindPluginByContext(IPluginContext *ctx) = 0; - virtual SMPlugin *FindPluginByContext(sp_context_t *ctx) = 0; - virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0; - virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0; - virtual bool UnloadPlugin(IPlugin *plugin) = 0; - virtual const CVector *ListPlugins() = 0; - virtual void FreePluginList(const CVector *list) = 0; - virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0; -}; - -class IExtensionSys : public IExtensionManager -{ -public: - virtual IExtension *LoadAutoExtension(const char *name, bool bErrorOnMissing=true) = 0; - virtual void TryAutoload() = 0; - virtual void Shutdown() = 0; - virtual IExtension *FindExtensionByFile(const char *name) = 0; - virtual bool LibraryExists(const char *name) = 0; - virtual void CallOnCoreMapStart(edict_t *edictList, int edictCount, int maxClients) = 0; - virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0; - virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0; - virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0; - virtual const CVector *ListExtensions() = 0; - virtual void FreeExtensionList(const CVector *list) = 0; - virtual void CallOnCoreMapEnd() = 0; -}; - -class ILogger -{ -public: - virtual void LogMessage(const char *msg, ...) = 0; - virtual void LogError(const char *msg, ...) = 0; - virtual void LogFatal(const char *msg, ...) = 0; -}; - -class AutoPluginList -{ -public: - AutoPluginList(IScriptManager *scripts) - : scripts_(scripts), list_(scripts->ListPlugins()) - { - } - ~AutoPluginList() - { - scripts_->FreePluginList(list_); - } - const CVector *operator ->() - { - return list_; - } -private: - IScriptManager *scripts_; - const CVector *list_; -}; - -class AutoExtensionList -{ -public: - AutoExtensionList(IExtensionSys *extensions) - : extensions_(extensions), list_(extensions_->ListExtensions()) - { - } - ~AutoExtensionList() - { - extensions_->FreeExtensionList(list_); - } - const CVector *operator ->() - { - return list_; - } -private: - IExtensionSys *extensions_; - const CVector *list_; -}; - -class CoreProvider -{ -public: - /* Objects */ - ISourceMod *sm; - IVEngineServerBridge *engine; - IFileSystemBridge *filesystem; - IPlayerInfoBridge *playerInfo; - ITimerSystem *timersys; - IPlayerManager *playerhelpers; - IGameHelpers *gamehelpers; - IMenuManager *menus; - ISourcePawnEngine **spe1; - ISourcePawnEngine2 **spe2; - const char *gamesuffix; - /* Data */ - ServerGlobals *serverGlobals; - void * serverFactory; - void * engineFactory; - void * matchmakingDSFactory; - SMGlobalClass * listeners; - - // ConVar functions. - virtual ConVar *FindConVar(const char *name) = 0; - virtual const char *GetCvarString(ConVar *cvar) = 0; - virtual bool GetCvarBool(ConVar* cvar) = 0; - - // Game description functions. - virtual bool GetGameName(char *buffer, size_t maxlength) = 0; - virtual const char *GetGameDescription() = 0; - virtual const char *GetSourceEngineName() = 0; - virtual bool SymbolsAreHidden() = 0; - - // Game state and helper functions. - virtual bool IsMapLoading() = 0; - virtual bool IsMapRunning() = 0; - virtual int MaxClients() = 0; - virtual bool DescribePlayer(int index, const char **namep, const char **authp, int *useridp) = 0; - virtual void LogToGame(const char *message) = 0; - virtual void ConPrint(const char *message) = 0; - virtual void ConsolePrintVa(const char *fmt, va_list ap) = 0; - - // Game engine helper functions. - virtual bool IsClientConVarQueryingSupported() = 0; - virtual int QueryClientConVar(int client, const char *cvar) = 0; - - // Metamod:Source functions. - virtual int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) = 0; - virtual void UnloadMMSPlugin(int id) = 0; - - const char * (*GetCoreConfigValue)(const char*); - void (*DoGlobalPluginLoads)(); - bool (*AreConfigsExecuted)(); - void (*ExecuteConfigs)(IPluginContext *ctx); - DatabaseInfo (*GetDBInfoFromKeyValues)(KeyValues *); - int (*GetActivityFlags)(); - int (*GetImmunityMode)(); - void (*UpdateAdminCmdFlags)(const char *cmd, OverrideType type, FlagBits bits, bool remove); - bool (*LookForCommandAdminFlags)(const char *cmd, FlagBits *pFlags); - int (*GetGlobalTarget)(); -}; - -class IProviderCallbacks -{ -public: - // Called when a log message is printed. Return true to supercede. - virtual bool OnLogPrint(const char *msg) = 0; -}; - -struct sm_logic_t -{ - SMGlobalClass *head; - IThreader *threader; - ITranslator *translator; - const char *(*stristr)(const char *, const char *); - size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *); - bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...); - void (*AddCorePhraseFile)(const char *filename); - unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool); - char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool); - size_t (*DecodeHexString)(unsigned char *, size_t, const char *); - IGameConfig * (*GetCoreGameConfig)(); - IDebugListener *debugger; - void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); - void (*AddNatives)(sp_nativeinfo_t *natives); - void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...)); - bool (*DumpAdminCache)(const char *filename); - void (*RegisterProfiler)(IProfilingTool *tool); - void (*OnRootCommand)(const ICommandArgs *args); - IScriptManager *scripts; - IShareSys *sharesys; - IExtensionSys *extsys; - IHandleSys *handlesys; - IForwardManager *forwardsys; - IAdminSystem *adminsys; - IdentityToken_t *core_ident; - ILogger *logger; - IRootConsole *rootmenu; - IProviderCallbacks *callbacks; - float sentinel; -}; - -typedef void (*LogicInitFunction)(CoreProvider *core, sm_logic_t *logic); -typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic); -typedef ITextParsers *(*GetITextParsers)(); - -#endif /* _INCLUDE_SOURCEMOD_INTERCOM_H_ */ diff --git a/core/logic/smn_adt_array.cpp b/core/logic/smn_adt_array.cpp index 2dfda1a8..3d3a74a8 100644 --- a/core/logic/smn_adt_array.cpp +++ b/core/logic/smn_adt_array.cpp @@ -33,6 +33,7 @@ #include "common_logic.h" #include "CellArray.h" #include "stringutil.h" +#include HandleType_t htCellArray; diff --git a/core/logic/smn_adt_stack.cpp b/core/logic/smn_adt_stack.cpp index d11c994d..0a7c8734 100644 --- a/core/logic/smn_adt_stack.cpp +++ b/core/logic/smn_adt_stack.cpp @@ -34,6 +34,7 @@ #include "CellArray.h" #include "handle_helpers.h" #include "stringutil.h" +#include HandleType_t htCellStack; diff --git a/core/logic/smn_adt_trie.cpp b/core/logic/smn_adt_trie.cpp index c4e5afc9..fbee7893 100644 --- a/core/logic/smn_adt_trie.cpp +++ b/core/logic/smn_adt_trie.cpp @@ -35,6 +35,7 @@ #include #include #include "sm_memtable.h" +#include HandleType_t htCellTrie; HandleType_t htSnapshot; diff --git a/core/logic/smn_banning.cpp b/core/logic/smn_banning.cpp index 96e80ea8..20dadad5 100644 --- a/core/logic/smn_banning.cpp +++ b/core/logic/smn_banning.cpp @@ -36,6 +36,8 @@ #include #include "stringutil.h" #include +#include +#include #define BANFLAG_AUTO (1<<0) /**< Auto-detects whether to ban by steamid or IP */ #define BANFLAG_IP (1<<1) /**< Always ban by IP address */ diff --git a/core/logic/smn_console.cpp b/core/logic/smn_console.cpp index b1c1b72d..3e70321c 100644 --- a/core/logic/smn_console.cpp +++ b/core/logic/smn_console.cpp @@ -36,6 +36,8 @@ #include #include #include "sprintf.h" +#include +#include static cell_t CheckCommandAccess(IPluginContext *pContext, const cell_t *params) { diff --git a/core/logic/smn_core.cpp b/core/logic/smn_core.cpp index ef201d7e..808ce405 100644 --- a/core/logic/smn_core.cpp +++ b/core/logic/smn_core.cpp @@ -48,6 +48,15 @@ #include #include #endif +#include +#include +#include +#include +#include + +using namespace SourceMod; +using namespace SourcePawn; + HandleType_t g_PlIter; diff --git a/core/logic/smn_database.cpp b/core/logic/smn_database.cpp index 0c49a2da..410cb5db 100644 --- a/core/logic/smn_database.cpp +++ b/core/logic/smn_database.cpp @@ -35,9 +35,12 @@ #include "stringutil.h" #include "ISourceMod.h" #include "AutoHandleRooter.h" -#include "am-string.h" -#include "am-vector.h" -#include "am-refcounting.h" +#include "common_logic.h" +#include +#include +#include +#include +#include HandleType_t hStmtType; HandleType_t hCombinedQueryType; @@ -1405,7 +1408,8 @@ static cell_t SQL_ConnectCustom(IPluginContext *pContext, const cell_t *params) err); } - DatabaseInfo info = bridge->GetDBInfoFromKeyValues(kv); + DatabaseInfo info; + bridge->GetDBInfoFromKeyValues(kv, &info); IDBDriver *driver; if (info.driver[0] == '\0' || strcmp(info.driver, "default") == 0) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 68122274..fdf599ba 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -43,6 +43,8 @@ #include "sprintf.h" #include #include "handle_helpers.h" +#include +#include #if defined PLATFORM_WINDOWS #include diff --git a/core/logic/smn_maplists.cpp b/core/logic/smn_maplists.cpp index d7a4cef9..1532f8d5 100644 --- a/core/logic/smn_maplists.cpp +++ b/core/logic/smn_maplists.cpp @@ -38,6 +38,9 @@ #include #include #include "stringutil.h" +#include +#include +#include using namespace SourceHook; diff --git a/core/logic/smn_menus.cpp b/core/logic/smn_menus.cpp index ae07bc09..96033f4e 100644 --- a/core/logic/smn_menus.cpp +++ b/core/logic/smn_menus.cpp @@ -39,6 +39,7 @@ #endif #include #include +#include #if defined CreateMenu #undef CreateMenu diff --git a/core/logic/smn_players.cpp b/core/logic/smn_players.cpp index e07577e4..32961ab0 100644 --- a/core/logic/smn_players.cpp +++ b/core/logic/smn_players.cpp @@ -41,6 +41,10 @@ #include "CellArray.h" #include "AutoHandleRooter.h" #include "stringutil.h" +#include +#include +#include +#include using namespace SourceHook; using namespace SourceMod; diff --git a/core/logic/smn_profiler.cpp b/core/logic/smn_profiler.cpp index 31cf646e..695147ce 100644 --- a/core/logic/smn_profiler.cpp +++ b/core/logic/smn_profiler.cpp @@ -37,6 +37,7 @@ #include #endif #include "ProfileTools.h" +#include struct Profiler { diff --git a/core/logic/smn_sorting.cpp b/core/logic/smn_sorting.cpp index 7d175ee1..c60d8bf5 100644 --- a/core/logic/smn_sorting.cpp +++ b/core/logic/smn_sorting.cpp @@ -34,6 +34,7 @@ #include #include "common_logic.h" #include "CellArray.h" +#include /*********************************** * About the double array hack * diff --git a/core/logic/smn_timers.cpp b/core/logic/smn_timers.cpp index 33d3d873..631d4d41 100644 --- a/core/logic/smn_timers.cpp +++ b/core/logic/smn_timers.cpp @@ -36,6 +36,7 @@ #include #include #include "DebugReporter.h" +#include using namespace SourceHook; diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index cd9fefa8..e00381f8 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -30,6 +30,9 @@ #include "sprintf.h" #include #include +#include +#include +#include using namespace SourceMod; diff --git a/core/logic/sprintf.h b/core/logic/sprintf.h index f8870b57..756c7db4 100644 --- a/core/logic/sprintf.h +++ b/core/logic/sprintf.h @@ -29,6 +29,10 @@ #include +namespace SourceMod { +class IPhraseCollection; +} + // "AMX Templated Cell Printf", originally. SourceMod doesn't have cell-strings // so this is a normal sprintf(), except that its variadic arguments are // derived from scripted arguments. @@ -46,7 +50,7 @@ size_t atcprintf(char *buffer, bool gnprintf(char *buffer, size_t maxlen, const char *format, - IPhraseCollection *pPhrases, + SourceMod::IPhraseCollection *pPhrases, void **params, unsigned int numparams, unsigned int &curparam, diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index f5a46c7f..64acc40c 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -34,7 +34,6 @@ #include "sourcemm_api.h" #include "sm_globals.h" #include "sm_autonatives.h" -#include "logic/intercom.h" #include "sm_stringutil.h" #include "Logger.h" #include "TimerSys.h" @@ -59,6 +58,9 @@ #endif #include #include +#include +#include +#include #if defined _WIN32 # define MATCHMAKINGDS_SUFFIX "" @@ -297,17 +299,15 @@ static const char* get_core_config_value(const char* key) return g_CoreConfig.GetCoreConfigValue(key); } -static DatabaseInfo keyvalues_to_dbinfo(KeyValues *kv) +static void keyvalues_to_dbinfo(KeyValues *kv, DatabaseInfo *out) { - DatabaseInfo info; - info.database = kv->GetString("database", ""); - info.driver = kv->GetString("driver", "default"); - info.host = kv->GetString("host", ""); - info.maxTimeout = kv->GetInt("timeout", 0); - info.pass = kv->GetString("pass", ""); - info.port = kv->GetInt("port", 0); - info.user = kv->GetString("user", ""); - return info; + out->database = kv->GetString("database", ""); + out->driver = kv->GetString("driver", "default"); + out->host = kv->GetString("host", ""); + out->maxTimeout = kv->GetInt("timeout", 0); + out->pass = kv->GetString("pass", ""); + out->port = kv->GetInt("port", 0); + out->user = kv->GetString("user", ""); } static int get_activity_flags() diff --git a/core/logic_bridge.h b/core/logic_bridge.h index 2838be42..1c4bb9fa 100644 --- a/core/logic_bridge.h +++ b/core/logic_bridge.h @@ -31,20 +31,18 @@ #ifndef _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ #define _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ -#include "logic/intercom.h" +#include -struct sm_logic_t; - -extern sm_logic_t logicore; -extern ITranslator *translator; -extern IGameConfig *g_pGameConf; -extern IScriptManager *scripts; -extern IShareSys *sharesys; -extern IExtensionSys *extsys; -extern IHandleSys *handlesys; -extern IForwardManager *forwardsys; -extern IAdminSystem *adminsys; -extern ILogger *logger; -extern IRootConsole *rootmenu; +extern SourceMod::sm_logic_t logicore; +extern SourceMod::ITranslator *translator; +extern SourceMod::IGameConfig *g_pGameConf; +extern SourceMod::IScriptManager *scripts; +extern SourceMod::IShareSys *sharesys; +extern SourceMod::IExtensionSys *extsys; +extern SourceMod::IHandleSys *handlesys; +extern SourceMod::IForwardManager *forwardsys; +extern SourceMod::IAdminSystem *adminsys; +extern SourceMod::ILogger *logger; +extern SourceMod::IRootConsole *rootmenu; #endif /* _INCLUDE_SOURCEMOD_LOGIC_BRIDGE_H_ */ diff --git a/core/provider.h b/core/provider.h index 6f469fbb..7ac3b35d 100644 --- a/core/provider.h +++ b/core/provider.h @@ -27,9 +27,9 @@ #ifndef _INCLUDE_SOURCEMOD_CORE_PROVIDER_IMPL_H_ #define _INCLUDE_SOURCEMOD_CORE_PROVIDER_IMPL_H_ -#include "logic/intercom.h" -#include "GameHooks.h" #include +#include +#include "GameHooks.h" class CoreProviderImpl : public CoreProvider { diff --git a/core/smn_console.cpp b/core/smn_console.cpp index f5467e57..7286b0d8 100644 --- a/core/smn_console.cpp +++ b/core/smn_console.cpp @@ -47,6 +47,8 @@ #include "logic_bridge.h" #include #include "smn_keyvalues.h" +#include +#include #if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA #include diff --git a/core/smn_protobuf.cpp b/core/smn_protobuf.cpp index 5552e16f..919eb653 100644 --- a/core/smn_protobuf.cpp +++ b/core/smn_protobuf.cpp @@ -33,6 +33,7 @@ #include "UserMessages.h" #include "UserMessagePBHelpers.h" #include "smn_usermsgs.h" +#include // Assumes pbuf message handle is param 1, gets message as msg #define GET_MSG_FROM_HANDLE_OR_ERR() \ diff --git a/core/smn_usermsgs.cpp b/core/smn_usermsgs.cpp index dae1fb3c..f91f0d5f 100644 --- a/core/smn_usermsgs.cpp +++ b/core/smn_usermsgs.cpp @@ -33,8 +33,9 @@ #include "smn_usermsgs.h" #include "logic_bridge.h" #ifdef USE_PROTOBUF_USERMESSAGES -#include "UserMessagePBHelpers.h" +# include "UserMessagePBHelpers.h" #endif +#include HandleType_t g_ProtobufType = NO_HANDLE_TYPE; HandleType_t g_WrBitBufType = NO_HANDLE_TYPE; diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index e395539f..e3e5c4e2 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -37,6 +37,8 @@ #include "logic_bridge.h" #include #include "provider.h" +#include +#include SourceMod_Core g_SourceMod_Core; IVEngineServer *engine = NULL; diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index f484abeb..afc5394a 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -44,6 +44,9 @@ #include "provider.h" #include #include +#include +#include +#include SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool); SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);