Added capability to toggle debug state in plugins at runtime
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40295
This commit is contained in:
@@ -485,11 +485,53 @@ bool CPlugin::SetPauseState(bool paused)
|
||||
return true;
|
||||
}
|
||||
|
||||
IdentityToken_t *CPlugin::GetIdentity()
|
||||
IdentityToken_t *CPlugin::GetIdentity() const
|
||||
{
|
||||
return m_ident;
|
||||
}
|
||||
|
||||
bool CPlugin::ToggleDebugMode(bool debug)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (!IsRunnable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((debug && IsDebugging()) || (!debug && !IsDebugging()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ICompilation *co = g_pVM->StartCompilation(m_ctx.ctx->plugin);
|
||||
if (!g_pVM->SetCompilationOption(co, "debug", (debug) ? "1" : "0"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sp_context_t *new_ctx = g_pVM->CompileToContext(co, &err);
|
||||
|
||||
memcpy(new_ctx->memory, m_ctx.ctx->memory, m_ctx.ctx->mem_size);
|
||||
new_ctx->hp = m_ctx.ctx->hp;
|
||||
new_ctx->sp = m_ctx.ctx->sp;
|
||||
new_ctx->frm = m_ctx.ctx->frm;
|
||||
new_ctx->dbreak = m_ctx.ctx->dbreak;
|
||||
new_ctx->context = m_ctx.ctx->context;
|
||||
memcpy(new_ctx->user, m_ctx.ctx->user, sizeof(m_ctx.ctx->user));
|
||||
|
||||
g_pVM->FreeContext(m_ctx.ctx);
|
||||
m_ctx.ctx = new_ctx;
|
||||
m_ctx.base->SetContext(new_ctx);
|
||||
|
||||
UpdateInfo();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPlugin::IsRunnable() const
|
||||
{
|
||||
return (m_status <= Plugin_Paused) ? true : false;
|
||||
}
|
||||
|
||||
/*******************
|
||||
* PLUGIN ITERATOR *
|
||||
*******************/
|
||||
@@ -1152,7 +1194,7 @@ bool CPluginManager::TestAliasMatch(const char *alias, const char *localpath)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPluginManager::IsLateLoadTime()
|
||||
bool CPluginManager::IsLateLoadTime() const
|
||||
{
|
||||
return (m_AllPluginsLoaded || g_SourceMod.IsLateLoadInMap());
|
||||
}
|
||||
@@ -1210,3 +1252,22 @@ IPlugin *CPluginManager::PluginFromHandle(Handle_t handle, HandleError *err)
|
||||
|
||||
return pPlugin;
|
||||
}
|
||||
|
||||
CPlugin *CPluginManager::GetPluginByOrder(int num)
|
||||
{
|
||||
if (num < 1 || num > (int)GetPluginCount())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CPlugin *pl;
|
||||
int id = 1;
|
||||
|
||||
IPluginIterator *iter = GetPluginIterator();
|
||||
for (; iter->MorePlugins() && id<num; iter->NextPlugin(), id++) {}
|
||||
|
||||
pl = (CPlugin *)(iter->GetPlugin());
|
||||
iter->Release();
|
||||
|
||||
return pl;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
virtual const sp_plugin_t *GetPluginStructure() const;
|
||||
virtual IPluginFunction *GetFunctionByName(const char *public_name);
|
||||
virtual IPluginFunction *GetFunctionById(funcid_t func_id);
|
||||
virtual IdentityToken_t *GetIdentity();
|
||||
virtual IdentityToken_t *GetIdentity() const;
|
||||
public:
|
||||
/**
|
||||
* Creates a plugin object with default values.
|
||||
@@ -146,6 +146,16 @@ public:
|
||||
* Calls the OnPluginUnload function.
|
||||
*/
|
||||
void Call_OnPluginUnload();
|
||||
|
||||
/**
|
||||
* Toggles debug mode in the plugin
|
||||
*/
|
||||
bool ToggleDebugMode(bool debug);
|
||||
|
||||
/**
|
||||
* Returns true if a plugin is usable.
|
||||
*/
|
||||
bool IsRunnable() const;
|
||||
public:
|
||||
time_t HasUpdatedFile();
|
||||
|
||||
@@ -242,7 +252,7 @@ public:
|
||||
/**
|
||||
* Returns whether anything loaded will be a late load.
|
||||
*/
|
||||
bool IsLateLoadTime();
|
||||
bool IsLateLoadTime() const;
|
||||
|
||||
/**
|
||||
* Adds natives from core into the native pool.
|
||||
@@ -253,6 +263,11 @@ public:
|
||||
* Converts a Handle to an IPlugin if possible.
|
||||
*/
|
||||
IPlugin *PluginFromHandle(Handle_t handle, HandleError *err);
|
||||
|
||||
/**
|
||||
* Finds a plugin based on its index. (starts on index 1)
|
||||
*/
|
||||
CPlugin *GetPluginByOrder(int num);
|
||||
private:
|
||||
/**
|
||||
* Recursively loads all plugins in the given directory.
|
||||
|
||||
Reference in New Issue
Block a user