Merge
authorNicholas Hastings <skamonkey@gmail.com>
Tue Nov 20 20:57:36 2012 -0500 (2012-11-20)
changeset 3689514c846f5573
parent 3688 7026a2961207
parent 3687 d0b1262dbc03
child 3690 4227fcc88dc9
Merge
     1.1 --- a/core/ConCmdManager.cpp	Tue Nov 20 20:55:28 2012 -0500
     1.2 +++ b/core/ConCmdManager.cpp	Tue Nov 20 20:57:36 2012 -0500
     1.3 @@ -559,44 +559,6 @@
     1.4  	return false;
     1.5  }
     1.6  
     1.7 -bool ConCmdManager::AddConsoleCommand(IPluginFunction *pFunction, 
     1.8 -									   const char *name, 
     1.9 -									   const char *description, 
    1.10 -									   int flags)
    1.11 -{
    1.12 -	ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
    1.13 -
    1.14 -	if (!pInfo)
    1.15 -	{
    1.16 -		return false;
    1.17 -	}
    1.18 -
    1.19 -	CmdHook *pHook = new CmdHook();
    1.20 -
    1.21 -	pHook->pf = pFunction;
    1.22 -	if (description && description[0])
    1.23 -	{
    1.24 -		pHook->helptext.assign(description);
    1.25 -	}
    1.26 -	pInfo->conhooks.push_back(pHook);
    1.27 -
    1.28 -	/* Add to the plugin */
    1.29 -	CmdList *pList;
    1.30 -	IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext());
    1.31 -	if (!pPlugin->GetProperty("CommandList", (void **)&pList))
    1.32 -	{
    1.33 -		pList = new CmdList();
    1.34 -		pPlugin->SetProperty("CommandList", pList);
    1.35 -	}
    1.36 -	PlCmdInfo info;
    1.37 -	info.pInfo = pInfo;
    1.38 -	info.type = Cmd_Console;
    1.39 -	info.pHook = pHook;
    1.40 -	AddToPlCmdList(pList, info);
    1.41 -
    1.42 -	return true;
    1.43 -}
    1.44 -
    1.45  bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction, 
    1.46  									 const char *name, 
    1.47  									 const char *group,
    1.48 @@ -658,7 +620,6 @@
    1.49  	/* Finally, add the hook */
    1.50  	pInfo->conhooks.push_back(pHook);
    1.51  	pInfo->admin = *(pHook->pAdmin);
    1.52 -	pInfo->is_admin_set = true;
    1.53  
    1.54  	/* Now add to the plugin */
    1.55  	CmdList *pList;
    1.56 @@ -803,7 +764,6 @@
    1.57  				pInfo->admin = *(pHook->pAdmin);
    1.58  			}
    1.59  		}
    1.60 -		pInfo->is_admin_set = true;
    1.61  	}
    1.62  	else if (type == Override_CommandGroup)
    1.63  	{
    1.64 @@ -837,7 +797,6 @@
    1.65  				}
    1.66  			}
    1.67  		}
    1.68 -		pInfo->is_admin_set = true;
    1.69  	}
    1.70  }
    1.71  
    1.72 @@ -905,7 +864,7 @@
    1.73  
    1.74  	*pFlags = pInfo->admin.eflags;
    1.75  
    1.76 -	return pInfo->is_admin_set;
    1.77 +	return true;
    1.78  }
    1.79  
    1.80  ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
    1.81 @@ -942,7 +901,6 @@
    1.82  		}
    1.83  
    1.84  		pInfo->pCmd = pCmd;
    1.85 -		pInfo->is_admin_set = false;
    1.86  
    1.87  		sm_trie_insert(m_pCmds, name, pInfo);
    1.88  		AddToCmdList(pInfo);
    1.89 @@ -995,13 +953,9 @@
    1.90  			{
    1.91  				type = "server";
    1.92  			}
    1.93 -			else if (cmd.type == Cmd_Console)
    1.94 -			{
    1.95 -				type = "console";
    1.96 -			}
    1.97  			else if (cmd.type == Cmd_Admin)
    1.98  			{
    1.99 -				type = "admin";
   1.100 +				type = (cmd.pInfo->admin.eflags == 0)?"console":"admin";
   1.101  			}
   1.102  			name = cmd.pInfo->pCmd->GetName();
   1.103  			if (cmd.pHook->helptext.size())
     2.1 --- a/core/ConCmdManager.h	Tue Nov 20 20:55:28 2012 -0500
     2.2 +++ b/core/ConCmdManager.h	Tue Nov 20 20:57:36 2012 -0500
     2.3 @@ -48,7 +48,6 @@
     2.4  enum CmdType
     2.5  {
     2.6  	Cmd_Server,
     2.7 -	Cmd_Console,
     2.8  	Cmd_Admin,
     2.9  };
    2.10  
    2.11 @@ -89,7 +88,6 @@
    2.12  	List<CmdHook *> srvhooks;		/**< Hooks as a server command */
    2.13  	List<CmdHook *> conhooks;		/**< Hooks as a console command */
    2.14  	AdminCmdInfo admin;				/**< Admin info, if any */
    2.15 -	bool is_admin_set;				/**< Whether or not admin info is set */
    2.16  };
    2.17  
    2.18  typedef List<ConCmdInfo *> ConCmdList;
    2.19 @@ -119,7 +117,6 @@
    2.20  	void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe);
    2.21  public:
    2.22  	bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
    2.23 -	bool AddConsoleCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
    2.24  	bool AddAdminCommand(IPluginFunction *pFunction, 
    2.25  						 const char *name, 
    2.26  						 const char *group,
     3.1 --- a/core/CoreConfig.cpp	Tue Nov 20 20:55:28 2012 -0500
     3.2 +++ b/core/CoreConfig.cpp	Tue Nov 20 20:57:36 2012 -0500
     3.3 @@ -193,17 +193,30 @@
     3.4  
     3.5  		if (res == ConfigResult_Reject)
     3.6  		{
     3.7 -			g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\" (%s)", option, value, error);
     3.8 +			g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
     3.9  		} else if (res == ConfigResult_Ignore) {
    3.10  			g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
    3.11  		} else {
    3.12 -			g_RootMenu.ConsolePrint("Config option \"%s\" successfully set to \"%s.\"", option, value);
    3.13 +			g_RootMenu.ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value);
    3.14  		}
    3.15  
    3.16  		return;
    3.17 +	} else if (argcount >= 3) {
    3.18 +		const char *option = command.Arg(2);
    3.19 +		
    3.20 +		const char *value = GetCoreConfigValue(option);
    3.21 +		
    3.22 +		if (value == NULL)
    3.23 +		{
    3.24 +			g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
    3.25 +		} else {
    3.26 +			g_RootMenu.ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
    3.27 +		}
    3.28 +		
    3.29 +		return;
    3.30  	}
    3.31  
    3.32 -	g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> <value>");
    3.33 +	g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> [value]");
    3.34  }
    3.35  
    3.36  void CoreConfig::Initialize()
     4.1 --- a/core/smn_console.cpp	Tue Nov 20 20:55:28 2012 -0500
     4.2 +++ b/core/smn_console.cpp	Tue Nov 20 20:57:36 2012 -0500
     4.3 @@ -722,7 +722,9 @@
     4.4  		return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
     4.5  	}
     4.6  
     4.7 -	if (!g_ConCmds.AddConsoleCommand(pFunction, name, help, params[4]))
     4.8 +	CPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pContext->GetContext());
     4.9 +	const char *group = pPlugin->GetFilename();
    4.10 +	if (!g_ConCmds.AddAdminCommand(pFunction, name, group, 0, help, params[4]))
    4.11  	{
    4.12  		return pContext->ThrowNativeError("Command \"%s\" could not be created. A convar with the same name already exists.", name);
    4.13  	}
     5.1 --- a/extensions/sdktools/vhelpers.cpp	Tue Nov 20 20:55:28 2012 -0500
     5.2 +++ b/extensions/sdktools/vhelpers.cpp	Tue Nov 20 20:57:36 2012 -0500
     5.3 @@ -329,24 +329,22 @@
     5.4  	fprintf(fp, "</serverclass>\n");
     5.5  }
     5.6  
     5.7 -void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level)
     5.8 +void UTIL_DrawSendTable(FILE *fp, SendTable *pTable, int level = 1)
     5.9  {
    5.10 -	char spaces[255];
    5.11 -	for (int i=0; i<level; i++)
    5.12 -		spaces[i] = ' ';
    5.13 -	spaces[level] = '\0';
    5.14 +	SendProp *pProp;
    5.15 +	const char *type;
    5.16  
    5.17 -	const char *name, *type;
    5.18 -	SendProp *pProp;
    5.19 -
    5.20 -	fprintf(fp, "%sSub-Class Table (%d Deep): %s\n", spaces, level, pTable->GetName());
    5.21 -
    5.22 -	for (int i=0; i<pTable->GetNumProps(); i++)
    5.23 +	for (int i = 0; i < pTable->GetNumProps(); i++)
    5.24  	{
    5.25  		pProp = pTable->GetProp(i);
    5.26 -		name = pProp->GetName();
    5.27  		if (pProp->GetDataTable())
    5.28  		{
    5.29 +			fprintf(fp, "%*sTable: %s (offset %d) (type %s)\n", 
    5.30 +				level, "", 
    5.31 +				pProp->GetName(), 
    5.32 +				pProp->GetOffset(), 
    5.33 +				pProp->GetDataTable()->GetName());
    5.34 +			
    5.35  			UTIL_DrawSendTable(fp, pProp->GetDataTable(), level + 1);
    5.36  		}
    5.37  		else
    5.38 @@ -356,8 +354,8 @@
    5.39  			if (type != NULL)
    5.40  			{
    5.41  				fprintf(fp,
    5.42 -					"%s-Member: %s (offset %d) (type %s) (bits %d)\n", 
    5.43 -					spaces, 
    5.44 +					"%*sMember: %s (offset %d) (type %s) (bits %d)\n", 
    5.45 +					level, "", 
    5.46  					pProp->GetName(),
    5.47  					pProp->GetOffset(),
    5.48  					type,
    5.49 @@ -366,8 +364,8 @@
    5.50  			else
    5.51  			{
    5.52  				fprintf(fp,
    5.53 -					"%s-Member: %s (offset %d) (type %d) (bits %d)\n", 
    5.54 -					spaces, 
    5.55 +					"%*sMember: %s (offset %d) (type %d) (bits %d)\n", 
    5.56 +					level, "", 
    5.57  					pProp->GetName(),
    5.58  					pProp->GetOffset(),
    5.59  					pProp->GetType(),
    5.60 @@ -453,8 +451,8 @@
    5.61  	ServerClass *pBase = gamedll->GetAllServerClasses();
    5.62  	while (pBase != NULL)
    5.63  	{
    5.64 -		fprintf(fp, "%s:\n", pBase->GetName());
    5.65 -		UTIL_DrawSendTable(fp, pBase->m_pTable, 1);
    5.66 +		fprintf(fp, "%s (type %s)\n", pBase->GetName(), pBase->m_pTable->GetName());
    5.67 +		UTIL_DrawSendTable(fp, pBase->m_pTable);
    5.68  		pBase = pBase->m_pNext;
    5.69  	}
    5.70