sourcemm/concommands.cpp
changeset 76 39266faeec97
parent 71 8c6c2684f216
child 89 79be0cd8f6c9
     1.1 --- a/sourcemm/concommands.cpp	Fri May 27 21:39:30 2005 +0000
     1.2 +++ b/sourcemm/concommands.cpp	Fri Jun 24 22:26:19 2005 +0000
     1.3 @@ -9,6 +9,7 @@
     1.4  */
     1.5  
     1.6  #include <ctype.h>
     1.7 +#include "CSmmAPI.h"
     1.8  #include "concommands.h"
     1.9  #include "CPlugin.h"
    1.10  #include <string>
    1.11 @@ -95,26 +96,26 @@
    1.12  		const char *command = e->Cmd_Argv(1);
    1.13  		if (strcmp(command, "credits") == 0)
    1.14  		{
    1.15 -			Msg("Metamod:Source was developed by:\n");
    1.16 -			Msg("  SourceHook: Pavol \"PM OnoTo\" Marko\n");
    1.17 -			Msg("  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
    1.18 -			Msg("  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
    1.19 -			Msg("For more information, see the official website\n");
    1.20 -			Msg("http://www.sourcemm.net/\n");
    1.21 +			CONMSG("Metamod:Source was developed by:\n");
    1.22 +			CONMSG("  SourceHook: Pavol \"PM OnoTo\" Marko\n");
    1.23 +			CONMSG("  GameDLL/Plugins: David \"BAILOPAN\" Anderson\n");
    1.24 +			CONMSG("  GameDLL: Scott \"Damaged Soul\" Ehlert\n");
    1.25 +			CONMSG("For more information, see the official website\n");
    1.26 +			CONMSG("http://www.sourcemm.net/\n");
    1.27  			
    1.28  			return;
    1.29  		} else if (strcmp(command, "version") == 0) {
    1.30 -			Msg("Metamod:Source version %s\n", SOURCEMM_VERSION);
    1.31 -			Msg("Compiled on: %s\n", SOURCEMM_DATE);
    1.32 -			Msg("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
    1.33 -			Msg("SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
    1.34 -			Msg("http://www.sourcemm.net/\n");
    1.35 +			CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
    1.36 +			CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
    1.37 +			CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
    1.38 +			CONMSG("SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
    1.39 +			CONMSG("http://www.sourcemm.net/\n");
    1.40  
    1.41  			return;
    1.42  		} else if (strcmp(command, "game") == 0) {
    1.43 -			Msg("GameDLL Information\n");
    1.44 -			Msg("  Mod path: %s\n", g_ModPath.c_str());
    1.45 -			Msg("  Dll path: %s\n", g_BinPath.c_str());
    1.46 +			CONMSG("GameDLL Information\n");
    1.47 +			CONMSG("  Mod path: %s\n", g_ModPath.c_str());
    1.48 +			CONMSG("  Dll path: %s\n", g_BinPath.c_str());
    1.49  
    1.50  			return;
    1.51  		} else if (strcmp(command, "refresh") == 0) {
    1.52 @@ -135,7 +136,7 @@
    1.53  			const char *name=NULL;
    1.54  			const char *author=NULL;
    1.55  
    1.56 -			Msg("-Id- %-16.15s  %-8.7s  %-12.11s %-8.7s\n", "Name", "Version", "Author", "Status");
    1.57 +			CONMSG("-Id- %-16.15s  %-8.7s  %-12.11s %-8.7s\n", "Name", "Version", "Author", "Status");
    1.58  			for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++)
    1.59  			{
    1.60  				pl = (*i);
    1.61 @@ -173,10 +174,10 @@
    1.62  					name = pl->m_File.c_str();
    1.63  
    1.64  
    1.65 -				Msg("[%02d] %-16.15s  %-8.7s  %-12.11s %-8.7s\n", pl->m_Id, name, version, author, status);
    1.66 +				CONMSG("[%02d] %-16.15s  %-8.7s  %-12.11s %-8.7s\n", pl->m_Id, name, version, author, status);
    1.67  			}
    1.68  
    1.69 -			//Msg("\n");
    1.70 +			//CONMSG("\n");
    1.71  
    1.72  			return;
    1.73  		} else if (strcmp(command, "cmds") == 0) {
    1.74 @@ -187,26 +188,26 @@
    1.75  
    1.76  				if (!pl)
    1.77  				{
    1.78 -					Msg("Plugin %d not found.\n", id);
    1.79 +					CONMSG("Plugin %d not found.\n", id);
    1.80  					return;
    1.81  				}
    1.82  
    1.83  				if (!pl->m_API)
    1.84  				{
    1.85 -					Msg("Plugin %d is not loaded.\n", id);
    1.86 +					CONMSG("Plugin %d is not loaded.\n", id);
    1.87  				} else {
    1.88 -					Msg("Console commands for %s:\n", pl->m_API->GetName());
    1.89 +					CONMSG("Console commands for %s:\n", pl->m_API->GetName());
    1.90  					std::list<ConCommandBase *>::iterator ci;
    1.91  					size_t count = 0;
    1.92  
    1.93  					for (ci=pl->m_Cmds.begin(); ci!=pl->m_Cmds.end(); ci++)
    1.94  					{
    1.95  						count++;
    1.96 -						Msg(" [%5d] %-s\n", count, (*ci)->GetName());
    1.97 +						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
    1.98  					}
    1.99  				}
   1.100  			} else {
   1.101 -				Msg("Usage: meta cmds <id>\n");
   1.102 +				CONMSG("Usage: meta cmds <id>\n");
   1.103  			}
   1.104  
   1.105  			return;
   1.106 @@ -218,26 +219,26 @@
   1.107  
   1.108  				if (!pl)
   1.109  				{
   1.110 -					Msg("Plugin %d not found.\n", id);
   1.111 +					CONMSG("Plugin %d not found.\n", id);
   1.112  					return;
   1.113  				}
   1.114  
   1.115  				if (!pl->m_API)
   1.116  				{
   1.117 -					Msg("Plugin %d is not loaded.\n", id);
   1.118 +					CONMSG("Plugin %d is not loaded.\n", id);
   1.119  				} else {
   1.120 -					Msg("Registered cvars for %s:\n", pl->m_API->GetName());
   1.121 +					CONMSG("Registered cvars for %s:\n", pl->m_API->GetName());
   1.122  					std::list<ConCommandBase *>::iterator ci;
   1.123  					size_t count = 0;
   1.124  
   1.125  					for (ci=pl->m_Cvars.begin(); ci!=pl->m_Cvars.end(); ci++)
   1.126  					{
   1.127  						count++;
   1.128 -						Msg(" [%5d] %-s\n", count, (*ci)->GetName());
   1.129 +						CONMSG(" [%5d] %-s\n", count, (*ci)->GetName());
   1.130  					}
   1.131  				}
   1.132  			} else {
   1.133 -				Msg("Usage: meta cvars <id>\n");
   1.134 +				CONMSG("Usage: meta cvars <id>\n");
   1.135  			}
   1.136  
   1.137  			return;
   1.138 @@ -248,32 +249,32 @@
   1.139  				SourceMM::CPluginManager::CPlugin *pl = g_PluginMngr.FindById(id);
   1.140  				if (!pl)
   1.141  				{
   1.142 -					Msg("Plugin %d not found.\n", id);
   1.143 +					CONMSG("Plugin %d not found.\n", id);
   1.144  					return;
   1.145  				}
   1.146  
   1.147  				if (!pl->m_API)
   1.148  				{
   1.149 -					Msg("Plugin %d is not loaded.\n", id);
   1.150 +					CONMSG("Plugin %d is not loaded.\n", id);
   1.151  				} else {
   1.152  					if (pl->m_Status == Pl_Paused)
   1.153  					{
   1.154 -						Msg("Plugin %d is paused.\n", id);
   1.155 +						CONMSG("Plugin %d is paused.\n", id);
   1.156  					} else if (pl->m_Status == Pl_Running) {
   1.157 -						Msg("Plugin %d is running.\n", id);
   1.158 +						CONMSG("Plugin %d is running.\n", id);
   1.159  					}
   1.160 -					Msg("  Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
   1.161 -					Msg("  Version: %s\n", pl->m_API->GetVersion());
   1.162 -					Msg("  Description: %s\n", pl->m_API->GetDescription());
   1.163 -					Msg("  License: %s\n", pl->m_API->GetLicense());
   1.164 -					Msg("  URL: %s\n", pl->m_API->GetURL());
   1.165 -					Msg("  Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
   1.166 +					CONMSG("  Name: \"%s\" by %s\n", pl->m_API->GetName(), pl->m_API->GetAuthor());
   1.167 +					CONMSG("  Version: %s\n", pl->m_API->GetVersion());
   1.168 +					CONMSG("  Description: %s\n", pl->m_API->GetDescription());
   1.169 +					CONMSG("  License: %s\n", pl->m_API->GetLicense());
   1.170 +					CONMSG("  URL: %s\n", pl->m_API->GetURL());
   1.171 +					CONMSG("  Details: API %03d, Date: %s\n", pl->m_API->GetApiVersion(), pl->m_API->GetDate());
   1.172  				}
   1.173 -				Msg("File: %s\n\n", pl->m_File.c_str());
   1.174 +				CONMSG("File: %s\n\n", pl->m_File.c_str());
   1.175  
   1.176  				return;
   1.177  			} else {
   1.178 -				Msg("Usage: meta info <id>\n");
   1.179 +				CONMSG("Usage: meta info <id>\n");
   1.180  
   1.181  				return;
   1.182  			}
   1.183 @@ -286,15 +287,15 @@
   1.184  
   1.185  				if (!g_PluginMngr.Pause(id, error, sizeof(error)-1))
   1.186  				{
   1.187 -					Msg("Pause failed: %s\n", error);
   1.188 +					CONMSG("Pause failed: %s\n", error);
   1.189  					return;
   1.190  				}
   1.191  				
   1.192 -				Msg("Plugin %d has been paused.\n", id);
   1.193 +				CONMSG("Plugin %d has been paused.\n", id);
   1.194  
   1.195  				return;
   1.196  			} else {
   1.197 -				Msg("Usage: meta pause <id>\n");
   1.198 +				CONMSG("Usage: meta pause <id>\n");
   1.199  
   1.200  				return;
   1.201  			}
   1.202 @@ -306,15 +307,15 @@
   1.203  
   1.204  				if (!g_PluginMngr.Unpause(id, error, sizeof(error)-1))
   1.205  				{
   1.206 -					Msg("Unpause failed: %s\n", error);
   1.207 +					CONMSG("Unpause failed: %s\n", error);
   1.208  					return;
   1.209  				}
   1.210  
   1.211 -				Msg("Plugin %d has been unpaused.\n", id);
   1.212 +				CONMSG("Plugin %d has been unpaused.\n", id);
   1.213  
   1.214  				return;
   1.215  			} else {
   1.216 -				Msg("Usage: meta unpause <id>\n");
   1.217 +				CONMSG("Usage: meta unpause <id>\n");
   1.218  
   1.219  				return;
   1.220  			}
   1.221 @@ -346,20 +347,20 @@
   1.222  				pl = g_PluginMngr.FindById(id);
   1.223  				if (!pl || id < Pl_MinId || (pl->m_Status < Pl_Paused))
   1.224  				{
   1.225 -					Msg("Failed to load plugin %s (%s).\n", file, error);
   1.226 +					CONMSG("Failed to load plugin %s (%s).\n", file, error);
   1.227  					return;
   1.228  				}
   1.229  
   1.230  				if (!already)
   1.231  				{
   1.232 -					Msg("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.233 +					CONMSG("Plugin \"%s\" loaded with id %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.234  				} else {
   1.235 -					Msg("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.236 +					CONMSG("Plugin \"%s\" is already loaded as %d.\n", pl->m_API->GetName(), pl->m_Id);
   1.237  				}
   1.238  				
   1.239  				return;
   1.240  			} else {
   1.241 -				Msg("Usage: meta load <path>\n");
   1.242 +				CONMSG("Usage: meta load <path>\n");
   1.243  
   1.244  				return;
   1.245  			}
   1.246 @@ -371,15 +372,15 @@
   1.247  
   1.248  				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)-1))
   1.249  				{
   1.250 -					Msg("Unload failed: %s\n", error);
   1.251 +					CONMSG("Unload failed: %s\n", error);
   1.252  					return;
   1.253  				}
   1.254  
   1.255 -				Msg("Plugin %d unloaded.\n", id);
   1.256 +				CONMSG("Plugin %d unloaded.\n", id);
   1.257  
   1.258  				return;
   1.259  			} else {
   1.260 -				Msg("Usage: meta unload <id>\n");
   1.261 +				CONMSG("Usage: meta unload <id>\n");
   1.262  
   1.263  				return;
   1.264  			}
   1.265 @@ -391,26 +392,26 @@
   1.266  
   1.267  				if (!g_PluginMngr.Unload(id, false, error, sizeof(error)-1))
   1.268  				{
   1.269 -					Msg("Force unload failed: %s\n", error);
   1.270 +					CONMSG("Force unload failed: %s\n", error);
   1.271  					return;
   1.272  				}
   1.273  
   1.274 -				Msg("Plugin %d force unloaded.\n", id);
   1.275 +				CONMSG("Plugin %d force unloaded.\n", id);
   1.276  
   1.277  				return;
   1.278  			} else {
   1.279 -				Msg("Usage: meta force_unload <id>\n");
   1.280 +				CONMSG("Usage: meta force_unload <id>\n");
   1.281  
   1.282  				return;
   1.283  			}
   1.284  		} else if (strcmp(command, "clear") == 0) {
   1.285  			if (!g_PluginMngr.UnloadAll())
   1.286  			{
   1.287 -				Msg("One or more plugins resisted removal (cleaned anyway).\n");
   1.288 +				CONMSG("One or more plugins resisted removal (cleaned anyway).\n");
   1.289  				return;
   1.290  			} 
   1.291  
   1.292 -			Msg("All plugins unloaded.\n");
   1.293 +			CONMSG("All plugins unloaded.\n");
   1.294  
   1.295  			return;
   1.296  		} else if (strcmp(command, "retry") == 0) {
   1.297 @@ -421,38 +422,38 @@
   1.298  
   1.299  				if (!g_PluginMngr.Retry(id, error, sizeof(error)-1))
   1.300  				{
   1.301 -					Msg("Error reloading plugin: %s\n", error);
   1.302 +					CONMSG("Error reloading plugin: %s\n", error);
   1.303  					return;
   1.304  				}
   1.305  
   1.306 -				Msg("Plugin %d successfully reloaded.\n", id);
   1.307 +				CONMSG("Plugin %d successfully reloaded.\n", id);
   1.308  
   1.309  				return;
   1.310  			} else {
   1.311 -				Msg("Usage: meta retry <id>\n");
   1.312 +				CONMSG("Usage: meta retry <id>\n");
   1.313  
   1.314  				return;
   1.315  			}
   1.316  		}
   1.317  	}
   1.318  
   1.319 -	Msg("Metamod:Source Menu\n");
   1.320 -	Msg("usage: meta <command> [arguments]\n");
   1.321 -	Msg("  clear        - Unload all plugins forcefully\n");
   1.322 -	Msg("  cmds         - Show plugin commands\n");
   1.323 -	Msg("  cvars        - Show plugin cvars\n");
   1.324 -	Msg("  credits      - About Metamod:Source\n");
   1.325 -	Msg("  force_unload - Forcefully unload a plugin\n");
   1.326 -	Msg("  game         - Information about GameDLL\n");
   1.327 -	Msg("  info         - Information about a plugin\n");
   1.328 -	Msg("  list         - List plugins\n");
   1.329 -	Msg("  load         - Load a plugin\n");
   1.330 -	Msg("  pause        - Pause a running plugin\n");
   1.331 -	Msg("  refresh      - Reparse plugins file\n");
   1.332 -	Msg("  retry        - Attempt to reload a plugin\n");
   1.333 -	Msg("  unload       - Unload a loaded plugin\n");
   1.334 -	Msg("  unpause      - Unpause a paused plugin\n");
   1.335 -	Msg("  version      - Version information\n");
   1.336 +	CONMSG("Metamod:Source Menu\n");
   1.337 +	CONMSG("usage: meta <command> [arguments]\n");
   1.338 +	CONMSG("  clear        - Unload all plugins forcefully\n");
   1.339 +	CONMSG("  cmds         - Show plugin commands\n");
   1.340 +	CONMSG("  cvars        - Show plugin cvars\n");
   1.341 +	CONMSG("  credits      - About Metamod:Source\n");
   1.342 +	CONMSG("  force_unload - Forcefully unload a plugin\n");
   1.343 +	CONMSG("  game         - Information about GameDLL\n");
   1.344 +	CONMSG("  info         - Information about a plugin\n");
   1.345 +	CONMSG("  list         - List plugins\n");
   1.346 +	CONMSG("  load         - Load a plugin\n");
   1.347 +	CONMSG("  pause        - Pause a running plugin\n");
   1.348 +	CONMSG("  refresh      - Reparse plugins file\n");
   1.349 +	CONMSG("  retry        - Attempt to reload a plugin\n");
   1.350 +	CONMSG("  unload       - Unload a loaded plugin\n");
   1.351 +	CONMSG("  unpause      - Unpause a paused plugin\n");
   1.352 +	CONMSG("  version      - Version information\n");
   1.353  }
   1.354  
   1.355  int UTIL_CmpNocase(const std::string &s1, const std::string &s2)