Skip to content

Commit

Permalink
Added selector 23 to GetPluginInfo (ID of calling plugin)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Jul 28, 2010
1 parent 324e64f commit 84fae24
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions OtherTypes.h
Expand Up @@ -926,6 +926,7 @@ class CPlugin :public CObject
double m_dVersion; // plugin version
double m_dRequiredVersion; // minimum MUSHclient version required
CTime m_tDateInstalled; // date installed
CString m_strCallingPluginID; // during a CallPlugin - the ID of the calling plugin

CScriptEngine * m_ScriptEngine; // script engine for script, if any

Expand Down
14 changes: 13 additions & 1 deletion scripting/lua_methods.cpp
Expand Up @@ -1111,9 +1111,18 @@ static int L_CallPlugin (lua_State *L)
unsigned short iOldStyle = pDoc->m_iNoteStyle;
pDoc->m_iNoteStyle = NORMAL; // back to default style

CString strOldCallingPluginID = pPlugin->m_strCallingPluginID;

pPlugin->m_strCallingPluginID.Empty ();

if (pDoc->m_CurrentPlugin)
pPlugin->m_strCallingPluginID = pDoc->m_CurrentPlugin->m_strID;

// do this so plugin can find its own state (eg. with GetPluginID)
CPlugin * pSavedPlugin = pDoc->m_CurrentPlugin;
pDoc->m_CurrentPlugin = pPlugin;
pDoc->m_CurrentPlugin = pPlugin;



// now call the routine in the plugin

Expand Down Expand Up @@ -1152,12 +1161,15 @@ static int L_CallPlugin (lua_State *L)
// what the exact Lua error message was (result value 3)
lua_pushstring (L, strLuaError);

pPlugin->m_strCallingPluginID = strOldCallingPluginID;

return 3; // ie. eErrorCallingPluginRoutine, explanation, Lua error message
}

// back to who *we* are (if no error)
pDoc->m_CurrentPlugin = pSavedPlugin;
pDoc->m_iNoteStyle = iOldStyle;
pPlugin->m_strCallingPluginID = strOldCallingPluginID;

int ret_n = lua_gettop(pL); // number of returned values (might be zero)

Expand Down
10 changes: 10 additions & 0 deletions scripting/methods.cpp
Expand Up @@ -5387,6 +5387,7 @@ VARIANT CMUSHclientDoc::GetPluginInfo(LPCTSTR PluginID, short InfoType)
break;

case 22: SetUpVariantDate (vaResult, COleDateTime (pPlugin->m_tDateInstalled.GetTime ())); break;
case 23: SetUpVariantString (vaResult, pPlugin->m_strCallingPluginID); break;

default:
vaResult.vt = VT_NULL;
Expand Down Expand Up @@ -5627,6 +5628,13 @@ DISPID iDispid = pPlugin->m_ScriptEngine->GetDispid (Routine);

long nInvocationCount = 0;

CString strOldCallingPluginID = pPlugin->m_strCallingPluginID;

pPlugin->m_strCallingPluginID.Empty ();

if (m_CurrentPlugin)
pPlugin->m_strCallingPluginID = m_CurrentPlugin->m_strID;

// do this so plugin can find its own state (eg. with GetPluginID)
CPlugin * pSavedPlugin = m_CurrentPlugin;
m_CurrentPlugin = pPlugin;
Expand Down Expand Up @@ -5678,6 +5686,8 @@ long nInvocationCount = 0;

m_CurrentPlugin = pSavedPlugin;

pPlugin->m_strCallingPluginID = strOldCallingPluginID;

if (iDispid == DISPID_UNKNOWN)
return eErrorCallingPluginRoutine;

Expand Down

0 comments on commit 84fae24

Please sign in to comment.