From 78eb5b77478aef76f626e20349ec9beccc8ac88f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 26 Feb 2007 08:32:20 +0000 Subject: [PATCH] removed Handle:myself from OnPluginStart added GetMyHandle to get handle now, but there's no use... --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40542 --- core/smn_handles.cpp | 7 +++++++ core/systems/PluginSys.cpp | 6 +++++- core/systems/PluginSys.h | 22 ++++++++++++---------- plugins/include/sourcemod.inc | 9 ++++++++- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/core/smn_handles.cpp b/core/smn_handles.cpp index 204c344f..4e818819 100644 --- a/core/smn_handles.cpp +++ b/core/smn_handles.cpp @@ -82,6 +82,13 @@ static cell_t sm_CloneHandle(IPluginContext *pContext, const cell_t *params) } } +static cell_t sm_GetMyHandle(IPluginContext *pContext, const cell_t *params) +{ + CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext()); + + return pPlugin->GetMyHandle(); +} + REGISTER_NATIVES(handles) { {"IsValidHandle", sm_IsValidHandle}, diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index 5881a06e..63f09009 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -92,6 +92,11 @@ void CPlugin::InitIdentity() } } +Handle_t CPlugin::GetMyHandle() +{ + return m_handle; +} + CPlugin *CPlugin::CreatePlugin(const char *file, char *error, size_t maxlength) { char fullpath[PLATFORM_MAX_PATH+1]; @@ -280,7 +285,6 @@ void CPlugin::Call_OnPluginStart() return; } - pFunction->PushCell(m_handle); pFunction->Execute(&result); } diff --git a/core/systems/PluginSys.h b/core/systems/PluginSys.h index 2b46fed0..05838db0 100644 --- a/core/systems/PluginSys.h +++ b/core/systems/PluginSys.h @@ -182,34 +182,36 @@ public: bool IsRunnable() const; /** - * Adds a language file index to the plugin's list. - */ + * Adds a language file index to the plugin's list. + */ void AddLangFile(unsigned int index); /** - * Get language file count for this plugin. - */ + * Get language file count for this plugin. + */ size_t GetLangFileCount() const; /** - * Get language file index based on the vector index. - */ + * Get language file index based on the vector index. + */ unsigned int GetLangFileByIndex(unsigned int index) const; public: /** - * Returns the modification time during last plugin load. - */ + * Returns the modification time during last plugin load. + */ time_t GetTimeStamp() const; /** - * Returns the current modification time of the plugin file. - */ + * Returns the current modification time of the plugin file. + */ time_t GetFileTimeStamp(); /** * Returns true if the plugin was running, but is now invalid. */ bool WasRunning(); + + Handle_t GetMyHandle(); protected: void UpdateInfo(); void SetTimeStamp(time_t t); diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 4410d151..cab69d2c 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -56,7 +56,7 @@ public Plugin:myinfo; * * @noreturn */ -forward OnPluginStart(Handle:myself); +forward OnPluginStart(); /** * Called before OnPluginStart, in case the plugin wants to check for load failure. @@ -156,6 +156,13 @@ forward OnClientAuthorized(client, const String:auth[]); */ forward OnGameFrame(); +/** + * Returns the calling plugin's Handle. + * + * @return Handle of the calling plugin. + */ +native Handle:GetMyHandle(); + /** * Returns the maximum number of clients allowed on the server. *