Skip to content

Commit 84fae24

Browse files
committed
Added selector 23 to GetPluginInfo (ID of calling plugin)
1 parent 324e64f commit 84fae24

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

OtherTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ class CPlugin :public CObject
926926
double m_dVersion; // plugin version
927927
double m_dRequiredVersion; // minimum MUSHclient version required
928928
CTime m_tDateInstalled; // date installed
929+
CString m_strCallingPluginID; // during a CallPlugin - the ID of the calling plugin
929930

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

scripting/lua_methods.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,18 @@ static int L_CallPlugin (lua_State *L)
11111111
unsigned short iOldStyle = pDoc->m_iNoteStyle;
11121112
pDoc->m_iNoteStyle = NORMAL; // back to default style
11131113

1114+
CString strOldCallingPluginID = pPlugin->m_strCallingPluginID;
1115+
1116+
pPlugin->m_strCallingPluginID.Empty ();
1117+
1118+
if (pDoc->m_CurrentPlugin)
1119+
pPlugin->m_strCallingPluginID = pDoc->m_CurrentPlugin->m_strID;
1120+
11141121
// do this so plugin can find its own state (eg. with GetPluginID)
11151122
CPlugin * pSavedPlugin = pDoc->m_CurrentPlugin;
1116-
pDoc->m_CurrentPlugin = pPlugin;
1123+
pDoc->m_CurrentPlugin = pPlugin;
1124+
1125+
11171126

11181127
// now call the routine in the plugin
11191128

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

1164+
pPlugin->m_strCallingPluginID = strOldCallingPluginID;
1165+
11551166
return 3; // ie. eErrorCallingPluginRoutine, explanation, Lua error message
11561167
}
11571168

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

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

scripting/methods.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5387,6 +5387,7 @@ VARIANT CMUSHclientDoc::GetPluginInfo(LPCTSTR PluginID, short InfoType)
53875387
break;
53885388

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

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

56285629
long nInvocationCount = 0;
56295630

5631+
CString strOldCallingPluginID = pPlugin->m_strCallingPluginID;
5632+
5633+
pPlugin->m_strCallingPluginID.Empty ();
5634+
5635+
if (m_CurrentPlugin)
5636+
pPlugin->m_strCallingPluginID = m_CurrentPlugin->m_strID;
5637+
56305638
// do this so plugin can find its own state (eg. with GetPluginID)
56315639
CPlugin * pSavedPlugin = m_CurrentPlugin;
56325640
m_CurrentPlugin = pPlugin;
@@ -5678,6 +5686,8 @@ long nInvocationCount = 0;
56785686

56795687
m_CurrentPlugin = pSavedPlugin;
56805688

5689+
pPlugin->m_strCallingPluginID = strOldCallingPluginID;
5690+
56815691
if (iDispid == DISPID_UNKNOWN)
56825692
return eErrorCallingPluginRoutine;
56835693

0 commit comments

Comments
 (0)