fixed amb1475 - inconsistent root console menu usage
authorDavid Anderson <dvander@alliedmods.net>
Sat Mar 01 05:42:25 2008 +0000 (2008-03-01)
changeset 1902ce912ad912a5
parent 1901 e9116270cf6a
child 1903 23a9aae8ded6
fixed amb1475 - inconsistent root console menu usage
core/ConCmdManager.cpp
core/ConVarManager.cpp
core/sm_srvcmds.cpp
core/systems/PluginSys.cpp
core/systems/PluginSys.h
     1.1 --- a/core/ConCmdManager.cpp	Sat Mar 01 05:18:26 2008 +0000
     1.2 +++ b/core/ConCmdManager.cpp	Sat Mar 01 05:42:25 2008 +0000
     1.3 @@ -914,12 +914,11 @@
     1.4  	{
     1.5  		const char *text = command.Arg(2);
     1.6  
     1.7 -		int id = atoi(text);
     1.8 -		CPlugin *pPlugin = g_PluginSys.GetPluginByOrder(id);
     1.9 +		CPlugin *pPlugin = g_PluginSys.FindPluginByConsoleArg(text);
    1.10  
    1.11  		if (!pPlugin)
    1.12  		{
    1.13 -			g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
    1.14 +			g_RootMenu.ConsolePrint("[SM] Plugin \"%s\" was not found.", text);
    1.15  			return;
    1.16  		}
    1.17  
    1.18 @@ -946,7 +945,7 @@
    1.19  		g_RootMenu.ConsolePrint("  %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
    1.20  		for (iter=pList->begin();
    1.21  			 iter!=pList->end();
    1.22 -			 iter++, id++)
    1.23 +			 iter++)
    1.24  		{
    1.25  			PlCmdInfo &cmd = (*iter);
    1.26  			if (cmd.type == Cmd_Server)
    1.27 @@ -978,140 +977,3 @@
    1.28  
    1.29  	g_RootMenu.ConsolePrint("[SM] Usage: sm cmds <plugin #>");
    1.30  }
    1.31 -
    1.32 -static int g_yam_state = 0;
    1.33 -void _YamState(int state)
    1.34 -{
    1.35 -	if (state == 0)
    1.36 -	{
    1.37 -		g_RootMenu.ConsolePrint("Welcome to the SourceMod Text Adventure.");
    1.38 -		g_RootMenu.ConsolePrint("Type sm_text to see the last message.");
    1.39 -		g_RootMenu.ConsolePrint("Type sm_text <word> to follow a capital word.");
    1.40 -		g_RootMenu.ConsolePrint("-------------------------------");
    1.41 -		g_RootMenu.ConsolePrint("You are at VALVE HEADQUARTERS.");
    1.42 -		g_RootMenu.ConsolePrint("To your LEFT is BAILOPAN, rearranging the letters to spell");
    1.43 -		g_RootMenu.ConsolePrint("\"A HARD VEAL QUEST\".  FORWARD is the entrance to the building.");
    1.44 -		g_RootMenu.ConsolePrint("To your RIGHT is your last chance to flee in terror.");
    1.45 -	} else if (state == 1) {
    1.46 -		g_RootMenu.ConsolePrint("BAILOPAN tells you that his name his pronounced");
    1.47 -		g_RootMenu.ConsolePrint("\"bye low pahn,\" not \"bay low pan.\"  Do you ");
    1.48 -		g_RootMenu.ConsolePrint("MOCK him, or NOD quietly?");
    1.49 -	} else if (state == 2) {
    1.50 -		g_RootMenu.ConsolePrint("You enter the Valve building.  You hear screams coming from within.");
    1.51 -		g_RootMenu.ConsolePrint("A grotesque figure lumbers up to greet you; it is Gabe Newell.");
    1.52 -		g_RootMenu.ConsolePrint("\"Welcome,\" he belches, \"to my lair.\"");
    1.53 -		g_RootMenu.ConsolePrint("Do you SHAKE Gaben's hand, WALK past him, or OFFER a donut?");
    1.54 -	} else if (state == 3) {
    1.55 -		g_RootMenu.ConsolePrint("You walk into the break room.  Alfred \"Alf is from Melmac\" Reynolds and");
    1.56 -		g_RootMenu.ConsolePrint("Yahn \"Yeti\" Bernier are discussing something (you overhear ");
    1.57 -		g_RootMenu.ConsolePrint("the phrase \"and next Steam update, here's what we should break\").");
    1.58 -		g_RootMenu.ConsolePrint("Should you DIE in a fire, REPORT a bug, REQUEST a feature, or ");
    1.59 -		g_RootMenu.ConsolePrint("SPRAY them with butter?");
    1.60 -	}
    1.61 -	g_yam_state = state;
    1.62 -}
    1.63 -
    1.64 -#if defined ORANGEBOX_BUILD
    1.65 -void _IntExt_CallYams(const CCommand &cmd)
    1.66 -{
    1.67 -#else
    1.68 -void _IntExt_CallYams()
    1.69 -{
    1.70 -	CCommand cmd;
    1.71 -#endif
    1.72 -	const char *arg = cmd.Arg(1);
    1.73 -
    1.74 -	/* should be impossible */
    1.75 -	if (!arg || arg[0] == '\0')
    1.76 -	{
    1.77 -		_YamState(g_yam_state);
    1.78 -	}
    1.79 -
    1.80 -	if (g_yam_state == 1)
    1.81 -	{
    1.82 -		if (strcasecmp(arg, "mock") == 0)
    1.83 -		{
    1.84 -			g_RootMenu.ConsolePrint("You mock BAILOPAN's pronunciation.  In a fit of rage, ");
    1.85 -			g_RootMenu.ConsolePrint("he sticks an INT 3 call into your chest, rendering you broken.");
    1.86 -			g_RootMenu.ConsolePrint("YOU HAVE DIED.  GAME OVER.");
    1.87 -			g_yam_state = 0;
    1.88 -		} else if (strcasecmp(arg, "nod") == 0) {
    1.89 -			g_RootMenu.ConsolePrint("You nod quietly, and then slowly back away into the Valve headquarters.");
    1.90 -			_YamState(2);
    1.91 -		} else {
    1.92 -			g_RootMenu.ConsolePrint("Commands are MOCK and NOD.");
    1.93 -		}
    1.94 -	} else if (g_yam_state == 3) {
    1.95 -		if (strcasecmp(arg, "report") == 0)
    1.96 -		{
    1.97 -			g_RootMenu.ConsolePrint("You report a bug to Alfred and Yeti.  Immediately, both fall asleep.");
    1.98 -			g_RootMenu.ConsolePrint("You decay in the break room for two years while they sleep.");
    1.99 -			g_RootMenu.ConsolePrint("YOU HAVE DIED.  GAME OVER.");
   1.100 -			g_yam_state = 0;
   1.101 -		} else if (strcasecmp(arg, "request") == 0) {
   1.102 -			g_RootMenu.ConsolePrint("You request a feature to Alfred and Yeti.  They both mutter something");
   1.103 -			g_RootMenu.ConsolePrint("about it being implemented \"soon.\"  Then, by accident, someone sends");
   1.104 -			g_RootMenu.ConsolePrint("a message over \"Friends.\"  The entire building catches fire.");
   1.105 -			g_RootMenu.ConsolePrint("YOU HAVE DIED.  GAME OVER.");
   1.106 -			g_yam_state = 0;
   1.107 -		} else if (strcasecmp(arg, "die") == 0) {
   1.108 -			g_RootMenu.ConsolePrint("For no reason, you suddenly catch fire.  Alfred and Yeti find this");
   1.109 -			g_RootMenu.ConsolePrint("deeply disturbing, and cover your flaming corpse with Episode 2");
   1.110 -			g_RootMenu.ConsolePrint("advertisements.  Coming soon, with Team Fortress 2, and Portal!");
   1.111 -			g_RootMenu.ConsolePrint("YOU HAVE DIED.  GAME OVER.");
   1.112 -			g_yam_state = 0;
   1.113 -		} else if (strcasecmp(arg, "spray") == 0) {
   1.114 -			g_RootMenu.ConsolePrint("You spray Alfred and Yeti with butter.  Like Jack Thompson to an");
   1.115 -			g_RootMenu.ConsolePrint("ambulance, Gabe Newell instantly appears and devours them both.");
   1.116 -			g_RootMenu.ConsolePrint("You run away, just in time, as Gabe Newell explodes, registering ");
   1.117 -			g_RootMenu.ConsolePrint("a 5.6 earthquake.  Outside, world peace is achieved.");
   1.118 -			g_RootMenu.ConsolePrint("YOU HAVE WON.");
   1.119 -			g_yam_state = 0;
   1.120 -		}
   1.121 -	} else if (g_yam_state == 2) {
   1.122 -		if (strcasecmp(arg, "shake") == 0)
   1.123 -		{
   1.124 -			g_RootMenu.ConsolePrint("You shake Gaben's hand.  It is a terrifying and disgusting experience.");
   1.125 -			g_RootMenu.ConsolePrint("However, you survive, and continue on.");
   1.126 -			_YamState(3);
   1.127 -		} else if (strcasecmp(arg, "offer") == 0) {
   1.128 -			g_RootMenu.ConsolePrint("You offer Gabe Newell one (1) donut.  With a gleam in his eyes, ");
   1.129 -			g_RootMenu.ConsolePrint("he picks you up and devours you whole.");
   1.130 -			g_RootMenu.ConsolePrint("YOU HAVE DIED.  GAME OVER.");
   1.131 -			g_yam_state = 0;
   1.132 -		} else if (strcasecmp(arg, "walk") == 0) {
   1.133 -			g_RootMenu.ConsolePrint("You walk past Gabe Newell.  He can't keep up with your pace!");
   1.134 -			_YamState(3);
   1.135 -		} else {
   1.136 -			g_RootMenu.ConsolePrint("Commands are SHAKE, OFFER, and WALK.");
   1.137 -		}
   1.138 -	} else if (g_yam_state == 0) {
   1.139 -		if (strcasecmp(arg, "left") == 0)
   1.140 -		{
   1.141 -			_YamState(1);
   1.142 -		} else if (strcasecmp(arg, "right") == 0) {
   1.143 -			g_RootMenu.ConsolePrint("You run away from the Valve headquarters in sheer terror.");
   1.144 -			g_RootMenu.ConsolePrint("While running, you smash into an unknown person, who turns out to be your soul mate.");
   1.145 -			g_RootMenu.ConsolePrint("You marry and raise a family of 3 kids.");
   1.146 -			g_RootMenu.ConsolePrint("Many years later, you look back, and realize this was your best choice.");
   1.147 -			g_RootMenu.ConsolePrint("YOU HAVE WON.");
   1.148 -			g_yam_state = 0;
   1.149 -		} else if (strcasecmp(arg, "forward") == 0) {
   1.150 -			_YamState(2);
   1.151 -		} else if (arg[0] != '\0') {
   1.152 -			g_RootMenu.ConsolePrint("Commands are FORWARD, LEFT, and RIGHT.");
   1.153 -		}
   1.154 -	}
   1.155 -}
   1.156 -
   1.157 -void _IntExt_EnableYams()
   1.158 -{
   1.159 -	static ConCommand *pCmd = NULL;
   1.160 -	if (!pCmd)
   1.161 -	{
   1.162 -		pCmd = new ConCommand("sm_text", _IntExt_CallYams, "Fountain of Yams Adventure Game", FCVAR_GAMEDLL);
   1.163 -		g_RootMenu.ConsolePrint("Something is now enabled...");
   1.164 -	} else {
   1.165 -		g_RootMenu.ConsolePrint("Something is already enabled...");
   1.166 -	}
   1.167 -}
     2.1 --- a/core/ConVarManager.cpp	Sat Mar 01 05:18:26 2008 +0000
     2.2 +++ b/core/ConVarManager.cpp	Sat Mar 01 05:42:25 2008 +0000
     2.3 @@ -270,14 +270,14 @@
     2.4  	if (argcount >= 3)
     2.5  	{
     2.6  		/* Get plugin index that was passed */
     2.7 -		int id = atoi(command.Arg(2));
     2.8 +		const char *arg = command.Arg(2);
     2.9  		
    2.10  		/* Get plugin object */
    2.11 -		CPlugin *plugin = g_PluginSys.GetPluginByOrder(id);
    2.12 +		CPlugin *plugin = g_PluginSys.FindPluginByConsoleArg(arg);
    2.13  
    2.14  		if (!plugin)
    2.15  		{
    2.16 -			g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
    2.17 +			g_RootMenu.ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
    2.18  			return;
    2.19  		}
    2.20  
    2.21 @@ -705,159 +705,3 @@
    2.22  
    2.23  	return error;
    2.24  }
    2.25 -
    2.26 -static int s_YamagramState = 0;
    2.27 -
    2.28 -void _YamagramPrinterTwoPointOhOh(int yamagram)
    2.29 -{
    2.30 -	switch (yamagram)
    2.31 -	{
    2.32 -	case 0:
    2.33 -		g_RootMenu.ConsolePrint("Answer the following questions correctly and Gaben may not eat you after all.");
    2.34 -		g_RootMenu.ConsolePrint("You will be given one hint in the form of my patented yamagrams.");
    2.35 -		g_RootMenu.ConsolePrint("Type sm_nana to see the last question.");
    2.36 -		g_RootMenu.ConsolePrint("Type sm_nana <answer> to attempt an answer of the question.");
    2.37 -		g_RootMenu.ConsolePrint("-------------------------------");
    2.38 -		_YamagramPrinterTwoPointOhOh(1);
    2.39 -		return;
    2.40 -	case 1:
    2.41 -		g_RootMenu.ConsolePrint("Question Ichi (1)");
    2.42 -		g_RootMenu.ConsolePrint("One can turn into a cow by doing what action?");
    2.43 -		g_RootMenu.ConsolePrint("Hint: AGE SANS GRIT");
    2.44 -		break;
    2.45 -	case 2:
    2.46 -		g_RootMenu.ConsolePrint("Question Ni (2)");
    2.47 -		g_RootMenu.ConsolePrint("What kind of hat should you wear when using the Internet?");
    2.48 -		g_RootMenu.ConsolePrint("Hint: BRR MOOSE");
    2.49 -		break;
    2.50 -	case 3:
    2.51 -		g_RootMenu.ConsolePrint("Question San (3)");
    2.52 -		g_RootMenu.ConsolePrint("Who is the lead developer of SourceMod?");
    2.53 -		g_RootMenu.ConsolePrint("Hint: VEAL BANDANA DID RIP SOON");
    2.54 -		break;
    2.55 -	case 4:
    2.56 -		g_RootMenu.ConsolePrint("Question Yon (4)");
    2.57 -		g_RootMenu.ConsolePrint("A terrible translation of 'SVN Revision' to Japanese romaji might be ...");
    2.58 -		g_RootMenu.ConsolePrint("Hint: I TAKE IN AN AIR OK");
    2.59 -		break;
    2.60 -	case 5:
    2.61 -		g_RootMenu.ConsolePrint("Question Go (5)");
    2.62 -		g_RootMenu.ConsolePrint("What is a fundamental concept in the game of Go?");
    2.63 -		g_RootMenu.ConsolePrint("Hint: AD LADEN THIEF");
    2.64 -		break;
    2.65 -	case 6:
    2.66 -		g_RootMenu.ConsolePrint("Question Roku (6)");
    2.67 -		g_RootMenu.ConsolePrint("Why am I asking all these strange questions?");
    2.68 -		g_RootMenu.ConsolePrint("Hint: CHUBBY TITAN EATS EWE WAGE DATA");
    2.69 -		break;
    2.70 -	case 7:
    2.71 -		g_RootMenu.ConsolePrint("Question Nana (7)");
    2.72 -		g_RootMenu.ConsolePrint("What is my name?");
    2.73 -		g_RootMenu.ConsolePrint("Hint: AD MODE LAG US");
    2.74 -		break;
    2.75 -	default:
    2.76 -		break;
    2.77 -	}
    2.78 -
    2.79 -	s_YamagramState = yamagram;
    2.80 -}
    2.81 -
    2.82 -#if defined ORANGEBOX_BUILD
    2.83 -void _IntExt_CallYamagrams(const CCommand &cmd)
    2.84 -{
    2.85 -#else
    2.86 -void _IntExt_CallYamagrams()
    2.87 -{
    2.88 -	CCommand cmd;
    2.89 -#endif
    2.90 -	bool correct = false;
    2.91 -	const char *arg = cmd.ArgS();
    2.92 -
    2.93 -	if (!arg || arg[0] == '\0')
    2.94 -	{
    2.95 -		_YamagramPrinterTwoPointOhOh(s_YamagramState);
    2.96 -		return;
    2.97 -	}
    2.98 -
    2.99 -	switch (s_YamagramState)
   2.100 -	{
   2.101 -	case 1:
   2.102 -		correct = !strcasecmp(arg, "eating grass");
   2.103 -		break;
   2.104 -	case 2:
   2.105 -		correct = !strcasecmp(arg, "sombrero");
   2.106 -		break;
   2.107 -	case 3:
   2.108 -		correct = !strcasecmp(arg, "david bailopan anderson");
   2.109 -		break;
   2.110 -	case 4:
   2.111 -		correct = !strcasecmp(arg, "kaitei no kairan");
   2.112 -		break;
   2.113 -	case 5:
   2.114 -		correct = !strcasecmp(arg, "life and death");
   2.115 -		break;
   2.116 -	case 6:
   2.117 -		correct = !strcasecmp(arg, "because gabe wanted it that way");
   2.118 -		if (correct)
   2.119 -		{
   2.120 -			g_RootMenu.ConsolePrint("Congratulations, you have answered 6 of my questions.");
   2.121 -			g_RootMenu.ConsolePrint("However, I have one final question for you. It wouldn't be nana without it.");
   2.122 -			g_RootMenu.ConsolePrint("-------------------------------");
   2.123 -			_YamagramPrinterTwoPointOhOh(7);
   2.124 -			return;
   2.125 -		}
   2.126 -		break;
   2.127 -	case 7:
   2.128 -		correct = !strcasecmp(arg, "damaged soul");
   2.129 -		if (correct)
   2.130 -		{
   2.131 -			g_RootMenu.ConsolePrint("You don't know how lucky you are to still be alive!");
   2.132 -			g_RootMenu.ConsolePrint("Congratulations. You have answered all 7 questions correctly.");
   2.133 -			g_RootMenu.ConsolePrint("The SourceMod Dev Team will be at your door with anti-Gaben grenades");
   2.134 -			g_RootMenu.ConsolePrint("within seconds. You will also be provided with a rocket launcher,");
   2.135 -			g_RootMenu.ConsolePrint("just in case Alfred decides to strike you with a blitzkrieg in retaliation.");
   2.136 -
   2.137 -			s_YamagramState = 0;
   2.138 -			return;
   2.139 -		}
   2.140 -		break;
   2.141 -	default:
   2.142 -		break;
   2.143 -	}
   2.144 -
   2.145 -	if (s_YamagramState > 0)
   2.146 -	{
   2.147 -		if (correct)
   2.148 -		{
   2.149 -			g_RootMenu.ConsolePrint("Correct! You are one step closer to avoiding the deadly jaws of Gaben.");
   2.150 -			g_RootMenu.ConsolePrint("-------------------------------");
   2.151 -			s_YamagramState++;
   2.152 -		} else {
   2.153 -			g_RootMenu.ConsolePrint("Wrong! You better be more careful. Gaben may be at your door at any minute.");
   2.154 -			return;
   2.155 -		}
   2.156 -	}
   2.157 -
   2.158 -	_YamagramPrinterTwoPointOhOh(s_YamagramState);
   2.159 -}
   2.160 -
   2.161 -void _IntExt_EnableYamagrams()
   2.162 -{
   2.163 -	static ConCommand *pCmd = NULL;
   2.164 -	if (!pCmd)
   2.165 -	{
   2.166 -		pCmd = new ConCommand("sm_nana", _IntExt_CallYamagrams, "Try these yamagrams!", FCVAR_GAMEDLL);
   2.167 -		g_RootMenu.ConsolePrint("[SM] Warning: Gaben has been alerted of your actions. You may be eaten.");
   2.168 -	} else {
   2.169 -		g_RootMenu.ConsolePrint("[SM] Gaben has already been alerted of your actions...");
   2.170 -	}
   2.171 -}
   2.172 -
   2.173 -void _IntExt_OnHostnameChanged(ConVar *pConVar, const char *oldValue, float flOldValue)
   2.174 -{
   2.175 -	if (strcmp(oldValue, "Good morning, DS-san.") == 0
   2.176 -		&& strcmp(pConVar->GetString(), "Good night, talking desk lamp.") == 0)
   2.177 -	{
   2.178 -		_IntExt_EnableYamagrams();
   2.179 -	}
   2.180 -}
     3.1 --- a/core/sm_srvcmds.cpp	Sat Mar 01 05:18:26 2008 +0000
     3.2 +++ b/core/sm_srvcmds.cpp	Sat Mar 01 05:42:25 2008 +0000
     3.3 @@ -59,17 +59,6 @@
     3.4  	m_Menu.clear();
     3.5  }
     3.6  
     3.7 -extern void _IntExt_OnHostnameChanged(ConVar *var, const char *pOldValue, float flOldValue);
     3.8 -
     3.9 -class DetectHostNameChanges : public IConVarChangeListener
    3.10 -{
    3.11 -public:
    3.12 -	void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue)
    3.13 -	{
    3.14 -		_IntExt_OnHostnameChanged(pConVar, oldValue, flOldValue);
    3.15 -	}
    3.16 -} s_HostnameChangeDetector;
    3.17 -
    3.18  void RootConsoleMenu::OnSourceModStartup(bool late)
    3.19  {
    3.20  #if defined ORANGEBOX_BUILD
    3.21 @@ -82,13 +71,11 @@
    3.22  
    3.23  void RootConsoleMenu::OnSourceModAllInitialized()
    3.24  {
    3.25 -	g_ConVarManager.AddConVarChangeListener("hostname", &s_HostnameChangeDetector);
    3.26  	g_ShareSys.AddInterface(NULL, this);
    3.27  }
    3.28  
    3.29  void RootConsoleMenu::OnSourceModShutdown()
    3.30  {
    3.31 -	g_ConVarManager.RemoveConVarChangeListener("hostname", &s_HostnameChangeDetector);
    3.32  	RemoveRootConsoleCommand("credits", this);
    3.33  	RemoveRootConsoleCommand("version", this);
    3.34  }
    3.35 @@ -227,8 +214,6 @@
    3.36  	return SMINTERFACE_ROOTCONSOLE_VERSION;
    3.37  }
    3.38  
    3.39 -extern void _IntExt_EnableYams();
    3.40 -
    3.41  void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
    3.42  {
    3.43  	unsigned int argnum = cmd.ArgC();
    3.44 @@ -236,12 +221,7 @@
    3.45  	if (argnum >= 2)
    3.46  	{
    3.47  		const char *cmdname = cmd.Arg(1);
    3.48 -		if (strcmp(cmdname, "text") == 0)
    3.49 -		{
    3.50 -			_IntExt_EnableYams();
    3.51 -			return;
    3.52 -		}
    3.53 -		else if (strcmp(cmdname, "internal") == 0)
    3.54 +		if (strcmp(cmdname, "internal") == 0)
    3.55  		{
    3.56  			if (argnum >= 3)
    3.57  			{
     4.1 --- a/core/systems/PluginSys.cpp	Sat Mar 01 05:18:26 2008 +0000
     4.2 +++ b/core/systems/PluginSys.cpp	Sat Mar 01 05:42:25 2008 +0000
     4.3 @@ -2305,14 +2305,33 @@
     4.4  				return;
     4.5  			}
     4.6  
     4.7 -			int num = atoi(command.Arg(3));
     4.8 -			if (num < 1 || num > (int)GetPluginCount())
     4.9 +			CPlugin *pl;
    4.10 +			char *end;
    4.11 +			const char *arg = command.Arg(3);
    4.12 +			int id = strtol(arg, &end, 10);
    4.13 +
    4.14 +			if (*end == '\0')
    4.15  			{
    4.16 -				g_RootMenu.ConsolePrint("[SM] Plugin index not found.");
    4.17 -				return;
    4.18 +				pl = GetPluginByOrder(id);
    4.19 +				if (!pl)
    4.20 +				{
    4.21 +					g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
    4.22 +					return;
    4.23 +				}
    4.24 +			}
    4.25 +			else
    4.26 +			{
    4.27 +				char pluginfile[256];
    4.28 +				const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
    4.29 +				UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
    4.30 +
    4.31 +				if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
    4.32 +				{
    4.33 +					g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
    4.34 +					return;
    4.35 +				}
    4.36  			}
    4.37  
    4.38 -			CPlugin *pl = GetPluginByOrder(num);
    4.39  			const sm_plugininfo_t *info = pl->GetPublicInfo();
    4.40  
    4.41  			g_RootMenu.ConsolePrint("  Filename: %s", pl->GetFilename());
    4.42 @@ -2388,11 +2407,31 @@
    4.43  				return;
    4.44  			}
    4.45  
    4.46 -			int num = atoi(command.Arg(3));
    4.47 -			if (num < 1 || num > (int)GetPluginCount())
    4.48 +			CPlugin *pl;
    4.49 +			char *end;
    4.50 +			const char *arg = command.Arg(3);
    4.51 +			int id = strtol(arg, &end, 10);
    4.52 +
    4.53 +			if (*end == '\0')
    4.54  			{
    4.55 -				g_RootMenu.ConsolePrint("[SM] Plugin index not found.");
    4.56 -				return;
    4.57 +				pl = GetPluginByOrder(id);
    4.58 +				if (!pl)
    4.59 +				{
    4.60 +					g_RootMenu.ConsolePrint("[SM] Plugin index %d not found.", id);
    4.61 +					return;
    4.62 +				}
    4.63 +			}
    4.64 +			else
    4.65 +			{
    4.66 +				char pluginfile[256];
    4.67 +				const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
    4.68 +				UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
    4.69 +
    4.70 +				if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
    4.71 +				{
    4.72 +					g_RootMenu.ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
    4.73 +					return;
    4.74 +				}
    4.75  			}
    4.76  
    4.77  			int res;
    4.78 @@ -2413,7 +2452,6 @@
    4.79  				debug = false;
    4.80  			}
    4.81  
    4.82 -			CPlugin *pl = GetPluginByOrder(num);
    4.83  			if (debug && pl->IsDebugging())
    4.84  			{
    4.85  				g_RootMenu.ConsolePrint("[SM] This plugin is already in debug mode.");
    4.86 @@ -2807,3 +2845,33 @@
    4.87  	return -1;
    4.88  }
    4.89  
    4.90 +CPlugin *CPluginManager::FindPluginByConsoleArg(const char *arg)
    4.91 +{
    4.92 +	int id;
    4.93 +	char *end;
    4.94 +	CPlugin *pl;
    4.95 +	
    4.96 +	id = strtol(arg, &end, 10);
    4.97 +
    4.98 +	if (*end == '\0')
    4.99 +	{
   4.100 +		pl = GetPluginByOrder(id);
   4.101 +		if (!pl)
   4.102 +		{
   4.103 +			return NULL;
   4.104 +		}
   4.105 +	}
   4.106 +	else
   4.107 +	{
   4.108 +		char pluginfile[256];
   4.109 +		const char *ext = g_LibSys.GetFileExtension(arg) ? "" : ".smx";
   4.110 +		UTIL_Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
   4.111 +
   4.112 +		if (!sm_trie_retrieve(m_LoadLookup, pluginfile, (void **)&pl))
   4.113 +		{
   4.114 +			return NULL;
   4.115 +		}
   4.116 +	}
   4.117 +
   4.118 +	return pl;
   4.119 +}
     5.1 --- a/core/systems/PluginSys.h	Sat Mar 01 05:18:26 2008 +0000
     5.2 +++ b/core/systems/PluginSys.h	Sat Mar 01 05:42:25 2008 +0000
     5.3 @@ -443,6 +443,8 @@
     5.4  	bool ReloadPlugin(CPlugin *pl);
     5.5  
     5.6  	void UnloadAll();
     5.7 +
     5.8 +	CPlugin *FindPluginByConsoleArg(const char *arg);
     5.9  private:
    5.10  	LoadRes _LoadPlugin(CPlugin **pPlugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength);
    5.11