Potential CCommandHook change

Moderator: MacroQuest Developers

onetimehero
a ghoul
a ghoul
Posts: 105
Joined: Fri Sep 05, 2003 2:42 pm

Potential CCommandHook change

Post by onetimehero » Fri Apr 22, 2005 1:09 am

I like this better, it lets me use / commands like normal.

Code: Select all

class CCommandHook 
{ 
public: 
	VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) 
	{ 
		//DebugSpew("CCommandHook::Detour(%s)",szFullLine);
		bool bIsISXCommand=false;
		// apply one alias
		char FullCommand[8192];
		strcpy(FullCommand,szFullLine);
		szFullLine=FullCommand;

		char *pSpace=strchr(FullCommand,' ');
		if (pSpace)
			*pSpace=0;

		PISXEQALIAS pAlias=FindISXEQAlias(FullCommand);
		if (pAlias) StrReplaceSection(FullCommand,strlen(FullCommand),pAlias->Replacement);

		if (FullCommand[0]=='/' && strlen(&FullCommand[1]))
			bIsISXCommand=pISInterface->IsCommand(&FullCommand[1]);

		if (pSpace)
			*pSpace=' ';

		if (bIsISXCommand)
		{
			pISInterface->ExecuteCommand(&szFullLine[1]);
				strcpy(szLastCommand,szFullLine);
		}
		else
		{
			char FullCommand[8192]={0};
			strcpy(FullCommand,szFullLine);
			pISInterface->DataParse(FullCommand);
			Trampoline(pChar,FullCommand); 
			strcpy(szLastCommand,FullCommand);
		}
	} 

	VOID Trampoline(PSPAWNINFO pChar, PCHAR szFullLine); 

}; 
Hmm. That's odd.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Fri Apr 22, 2005 6:05 pm

Here's an untested proposal. This gets rid of ISXEQAlias, and switches command processing to using the good old / when using the chat window (note for random people: SCRIPTS do not use slashes)

Code: Select all

bool ExecuteISCommand(char *Command, char *Parameters=0)
{
	char Temp[4096]={0};
	if (!pISInterface->IsAlias(Command) && !pISInterface->ResolveCommand(Command,Temp,sizeof(Temp)))
	{
		return false;
	}

	if (Parameters)
	{
		sprintf(Temp,"%s %s",Command,Parameters);
		pISInterface->ExecuteCommand(Temp);
	}
	else
		pISInterface->ExecuteCommand(Command);

	return true;
}

class CCommandHook 
{ 
public: 
	VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) 
	{ 
		//DebugSpew("CCommandHook::Detour(%s)",szFullLine);

		// apply one alias
		char FullCommand[4096];
		strcpy(FullCommand,szFullLine);
		szFullLine=FullCommand;

		char CommandName[256]={0};

		char *pSpace=strchr(FullCommand,' ');
		if (pSpace)
			*pSpace=0;
		strcpy(CommandName,FullCommand);
		if (pSpace)
		{
			*pSpace=' ';
			pSpace++;
		}

		if (CommandName[0]!='/' || !ExecuteISCommand(&CommandName[1],pSpace))
		{
			char FullCommand[8192]={0};
			strcpy(FullCommand,szFullLine);
			pISInterface->DataParse(FullCommand);
			Trampoline(pChar,FullCommand); 
		}
		strcpy(szLastCommand,FullCommand);

	} 

	VOID Trampoline(PSPAWNINFO pChar, PCHAR szFullLine); 

}; 
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0