core/systems/PluginSys.cpp
changeset 2226 d10b38524be3
parent 2219 5ddd93671335
child 2289 44045ead61cd
     1.1 --- a/core/systems/PluginSys.cpp	Sun Aug 10 05:39:25 2008 +0000
     1.2 +++ b/core/systems/PluginSys.cpp	Fri Aug 15 05:22:26 2008 +0000
     1.3 @@ -447,7 +447,7 @@
     1.4  		return false;
     1.5  	}
     1.6  
     1.7 -	return m_pRuntime->IsDebugging();
     1.8 +	return true;
     1.9  }
    1.10  
    1.11  void CPlugin::LibraryActions(bool dropping)
    1.12 @@ -507,61 +507,6 @@
    1.13  	return m_ident;
    1.14  }
    1.15  
    1.16 -bool CPlugin::ToggleDebugMode(bool debug, char *error, size_t maxlength)
    1.17 -{
    1.18 -	int err;
    1.19 -
    1.20 -	if (!IsRunnable())
    1.21 -	{
    1.22 -		if (error)
    1.23 -		{
    1.24 -			snprintf(error, maxlength, "Plugin is not runnable.");
    1.25 -		}
    1.26 -		return false;
    1.27 -	}
    1.28 -
    1.29 -	if (debug && IsDebugging())
    1.30 -	{
    1.31 -		if (error)
    1.32 -		{
    1.33 -			snprintf(error, maxlength, "Plugin is already in debug mode.");
    1.34 -		}
    1.35 -		return false;
    1.36 -	}
    1.37 -	else if (!debug && !IsDebugging())
    1.38 -	{
    1.39 -		if (error)
    1.40 -		{
    1.41 -			snprintf(error, maxlength, "Plugins is already in production mode.");
    1.42 -		}
    1.43 -		return false;
    1.44 -	}
    1.45 -
    1.46 -	ICompilation *co = g_pSourcePawn2->StartCompilation();
    1.47 -
    1.48 -	if (!co->SetOption("debug", (debug) ? "1" : "0"))
    1.49 -	{
    1.50 -		if (error)
    1.51 -		{
    1.52 -			snprintf(error, maxlength, "Failed to change plugin mode (JIT failure).");
    1.53 -		}
    1.54 -		return false;
    1.55 -	}
    1.56 -
    1.57 -	if ((err = m_pRuntime->ApplyCompilationOptions(co)) != SP_ERROR_NONE)
    1.58 -	{
    1.59 -		if (error)
    1.60 -		{
    1.61 -			snprintf(error, maxlength, "Failed to recompile plugin (JIT error %d).", err);
    1.62 -		}
    1.63 -		return false;
    1.64 -	}
    1.65 -
    1.66 -	UpdateInfo();
    1.67 -
    1.68 -	return true;
    1.69 -}
    1.70 -
    1.71  bool CPlugin::IsRunnable()
    1.72  {
    1.73  	return (m_status <= Plugin_Paused) ? true : false;
    1.74 @@ -1057,7 +1002,7 @@
    1.75  	LoadRes res;
    1.76  
    1.77  	*wasloaded = false;
    1.78 -	if ((res=_LoadPlugin(&pl, path, debug, type, error, maxlength)) == LoadRes_Failure)
    1.79 +	if ((res=_LoadPlugin(&pl, path, true, type, error, maxlength)) == LoadRes_Failure)
    1.80  	{
    1.81  		delete pl;
    1.82  		return NULL;
    1.83 @@ -2195,14 +2140,7 @@
    1.84  				{
    1.85  					if (pl->GetStatus() == Plugin_Running)
    1.86  					{
    1.87 -						if (pl->IsDebugging())
    1.88 -						{
    1.89 -							g_RootMenu.ConsolePrint("  Status: running, debugging");
    1.90 -						}
    1.91 -						else
    1.92 -						{
    1.93 -							g_RootMenu.ConsolePrint("  Status: running");
    1.94 -						}
    1.95 +						g_RootMenu.ConsolePrint("  Status: running");
    1.96  					}
    1.97  					else
    1.98  					{
    1.99 @@ -2245,83 +2183,6 @@
   1.100  
   1.101  			return;
   1.102  		}
   1.103 -		else if (strcmp(cmd, "debug") == 0)
   1.104 -		{
   1.105 -			if (argcount < 5)
   1.106 -			{
   1.107 -				g_RootMenu.ConsolePrint("[SM] Usage: sm plugins debug <#> [on|off]");
   1.108 -				return;
   1.109 -			}
   1.110 -
   1.111 -			CPlugin *pl;
   1.112 -			char *end;
   1.113 -			const char *arg = command.Arg(3);
   1.114 -			int id = strtol(arg, &end, 10);
   1.115 -
   1.116 -			if (*end == '\0')
   1.117 -			{
   1.118 -				pl = GetPluginByOrder(id);
   1.119 -				if (!pl)
   1.120 -				{
   1.121 -					g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
   1.122 -					return;
   1.123 -				}
   1.124 -			}
   1.125 -			else
   1.126 -			{
   1.127 -				char pluginfile[256];
   1.128 -				const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
   1.129 -				UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
   1.130 -
   1.131 -				if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
   1.132 -				{
   1.133 -					g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
   1.134 -					return;
   1.135 -				}
   1.136 -			}
   1.137 -
   1.138 -			int res;
   1.139 -			const char *mode = command.Arg(4);
   1.140 -			if ((res=strcmp("on", mode)) && strcmp("off", mode))
   1.141 -			{
   1.142 -				g_RootMenu.ConsolePrint("[SM] The only possible options are \"on\" and \"off.\"");
   1.143 -				return;
   1.144 -			}
   1.145 -
   1.146 -			bool debug;
   1.147 -			if (!res)
   1.148 -			{
   1.149 -				debug = true;
   1.150 -			}
   1.151 -			else
   1.152 -			{
   1.153 -				debug = false;
   1.154 -			}
   1.155 -
   1.156 -			if (debug && pl->IsDebugging())
   1.157 -			{
   1.158 -				g_RootMenu.ConsolePrint("[SM] This plugin is already in debug mode.");
   1.159 -				return;
   1.160 -			}
   1.161 -			else if (!debug && !pl->IsDebugging())
   1.162 -			{
   1.163 -				g_RootMenu.ConsolePrint("[SM] Debug mode is already disabled in this plugin.");
   1.164 -				return;
   1.165 -			}
   1.166 -
   1.167 -			char error[256];
   1.168 -			if (pl->ToggleDebugMode(debug, error, sizeof(error)))
   1.169 -			{
   1.170 -				g_RootMenu.ConsolePrint("[SM] Successfully toggled debug mode on plugin %s.", pl->GetFilename());
   1.171 -				return;
   1.172 -			}
   1.173 -			else
   1.174 -			{
   1.175 -				g_RootMenu.ConsolePrint("[SM] Could not toggle debug mode on plugin %s.", pl->GetFilename());
   1.176 -				g_RootMenu.ConsolePrint("[SM] Plugin returned error: %s", error);
   1.177 -				return;
   1.178 -			}
   1.179 -		}
   1.180  		else if (strcmp(cmd, "refresh") == 0)
   1.181  		{
   1.182  			g_SourceMod.DoGlobalPluginLoads();
   1.183 @@ -2382,7 +2243,6 @@
   1.184  
   1.185  	/* Draw the main menu */
   1.186  	g_RootMenu.ConsolePrint("SourceMod Plugins Menu:");
   1.187 -	g_RootMenu.DrawGenericOption("debug", "Toggle debug mode on a plugin");
   1.188  	g_RootMenu.DrawGenericOption("info", "Information about a plugin");
   1.189  	g_RootMenu.DrawGenericOption("list", "Show loaded plugins");
   1.190  	g_RootMenu.DrawGenericOption("load", "Load a plugin");
   1.191 @@ -2398,13 +2258,12 @@
   1.192  {
   1.193  	List<CPlugin *>::iterator iter;
   1.194  	char filename[PLATFORM_MAX_PATH];
   1.195 -	bool debug, wasloaded;
   1.196 +	bool wasloaded;
   1.197  	PluginType ptype;
   1.198  	IPlugin *newpl;
   1.199  	int id = 1;
   1.200  
   1.201  	strcpy(filename, pl->m_filename);
   1.202 -	debug = pl->IsDebugging();
   1.203  	ptype = pl->GetType();
   1.204  
   1.205  	for (iter=m_plugins.begin(); iter!=m_plugins.end(); iter++, id++)
   1.206 @@ -2419,7 +2278,7 @@
   1.207  	{
   1.208  		return false;
   1.209  	}
   1.210 -	if (!(newpl=LoadPlugin(filename, debug, ptype, NULL, 0, &wasloaded)))
   1.211 +	if (!(newpl=LoadPlugin(filename, true, ptype, NULL, 0, &wasloaded)))
   1.212  	{
   1.213  		return false;
   1.214  	}