VOID Draw_Detour(VOID)
    {
        PCSIDLWND pThisLabel;
        __asm {mov [pThisLabel], ecx};
        //          (PCSIDLWND)this;
        Draw_Trampoline();
        CHAR Buffer[MAX_STRING] = {0};
        BOOL Found=FALSE;
        DWORD index;

        if ((DWORD)pThisLabel->SidlPiece==9999) {
            if (!pThisLabel->XMLToolTip) {
                strcpy(Buffer,"BadCustom");
                Found=TRUE;
            } else {
                //strcpy(Buffer,&pThisLabel->XMLToolTip->Text[0]);
                STMLToPlainText(&pThisLabel->XMLToolTip->Text[0],Buffer);
                ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                if (!strcmp(Buffer,"NULL"))
                    Buffer[0]=0;
                Found=TRUE;
            }
        } else if ((DWORD)pThisLabel->SidlPiece>=1000) {
            for (index=0;Id_PMP[index].ID>0 && !Found;index++) {
                if (Id_PMP[index].ID==(DWORD)pThisLabel->SidlPiece) {
                    strcpy(Buffer,Id_PMP[index].PMP);
                    ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                    if (!strcmp(Buffer,"NULL"))
                        Buffer[0]=0;
                    Found=TRUE;
                }
            }
        }
        if (Found) SetCXStr(&(pThisLabel->WindowText),Buffer);
    }
Esempio n. 2
0
    VOID Draw_Detour(VOID)
    {
		CLabel* pThisLabel = (CLabel*)this;
        CHAR Buffer[MAX_STRING] = {0};
        BOOL Found=FALSE;
        DWORD index;
		if (gAnonymize) {
			if (!bTrimnames) {
				EzDetourwName(CEverQuest__trimName, &CLabelHook::CEverQuest__trimName_Detour, &CLabelHook::CEverQuest__trimName_Trampoline,"CEverQuest__trimName");
				EzDetourwName(__GetGaugeValueFromEQ, GetGaugeValueFromEQ_Detour, GetGaugeValueFromEQ_Trampoline,"__GetGaugeValueFromEQ");
				EzDetourwName(__GetLabelFromEQ, GetLabelFromEQ_Detour, GetLabelFromEQ_Trampoline,"__GetLabelFromEQ");
				bTrimnames = 1;
			}
			if (pThisLabel && pThisLabel->WindowText) {
				GetCXStr(pThisLabel->WindowText, Buffer);
				Anonymize(Buffer);
			}
		} else {
			if (bTrimnames) {
				bTrimnames = 0;
				RemoveDetour(CEverQuest__trimName);
				RemoveDetour(__GetGaugeValueFromEQ);
				RemoveDetour(__GetLabelFromEQ);
			}
		}
		Draw_Trampoline();
       if ((DWORD)pThisLabel->EQType==9999) {
            if (!pThisLabel->XMLToolTip) {
                strcpy_s(Buffer,"BadCustom");
                Found=TRUE;
            } else {
                //strcpy_s(Buffer,&pThisLabel->XMLToolTip->Text[0]);
                STMLToPlainText(&pThisLabel->XMLToolTip->Text[0],Buffer);
                ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                if (!strcmp(Buffer,"NULL"))
                    Buffer[0]=0;
                Found=TRUE;
            }
        } else if (pThisLabel->EQType==1000) {
            for (index=0;Id_PMP[index].ID>0 && !Found;index++) {
                if (Id_PMP[index].ID==(DWORD)pThisLabel->EQType) {
                    strcpy_s(Buffer,Id_PMP[index].PMP);
                    ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                    if (!strcmp(Buffer,"NULL"))
                        Buffer[0]=0;
                    Found=TRUE;
                }
            }
        }
        if (Found)
			SetCXStr(&(pThisLabel->WindowText),Buffer);
    }
Esempio n. 3
0
BOOL DoNextCommand()
{
	if (!ppCharSpawn || !pCharSpawn) return FALSE;
	PSPAWNINFO pCharOrMount = NULL;
	PCHARINFO pCharInfo = GetCharInfo();
	PSPAWNINFO pChar = pCharOrMount = (PSPAWNINFO)pCharSpawn;
	if (pCharInfo && pCharInfo->pSpawn) pChar = pCharInfo->pSpawn;
	if ((!pChar) || (gZoning)/* || (gDelayZoning)*/) return FALSE;
	if (((gFaceAngle != 10000.0f) || (gLookAngle != 10000.0f)) && (TurnNotDone)) return FALSE;
	if (IsMouseWaiting()) return FALSE;
	if (gDelay && gDelayCondition[0])
	{
		CHAR szCond[MAX_STRING];
		strcpy(szCond, gDelayCondition);
		ParseMacroParameter(GetCharInfo()->pSpawn, szCond);
		DOUBLE Result;
		if (!Calculate(szCond, Result))
		{
			FatalError("Failed to parse /delay condition '%s', non-numeric encountered", szCond);
			return false;
		}
		if (Result != 0)
		{
			DebugSpewNoFile("/delay ending early, conditions met");
			gDelay = 0;
		}
	}
	if (!gDelay && !gMacroPause && (!gMQPauseOnChat || *EQADDR_NOTINCHATMODE) &&
		gMacroBlock && gMacroStack) {
		PMACROBLOCK tmpBlock = gMacroBlock;
		gMacroStack->Location = gMacroBlock;
#ifdef MQ2_PROFILING
		LARGE_INTEGER BeforeCommand;
		QueryPerformanceCounter(&BeforeCommand);
		PMACROBLOCK ThisMacroBlock = gMacroBlock;
#endif
		gMacroBlock->MacroCmd = 0;
		DoCommand(pChar, gMacroBlock->Line);
		if (gMacroBlock) {
#ifdef MQ2_PROFILING
			LARGE_INTEGER AfterCommand;
			QueryPerformanceCounter(&AfterCommand);
			ThisMacroBlock->ExecutionCount++;
			ThisMacroBlock->ExecutionTime += AfterCommand.QuadPart - BeforeCommand.QuadPart;
#endif
			if (!gMacroBlock->pNext) {
				FatalError("Reached end of macro.");
			}
			else {
				// if the macro block changed and there was a /macro 
				// command don't bump the line 
				//if (gMacroBlock == tmpBlock || !gMacroBlock->MacroCmd) {
				gMacroBlock = gMacroBlock->pNext;
				//}
			}
		}
		return TRUE;
	}
	return FALSE;
}
// ***************************************************************************
// Function:    Delay
// Description: Our '/delay' command
// Usage:       /delay <time> [condition to end early]
// ***************************************************************************
VOID Delay(PSPAWNINFO pChar, PCHAR szLine)
{
    CHAR szVal[MAX_STRING] = {0};
    LONG VarValue;

    if (szLine[0]==0) {
        SyntaxError("Usage: /delay <time> [condition to end early]");
        return;
    }
    GetArg(szVal,szLine,1);
    ParseMacroParameter(GetCharInfo()->pSpawn,szVal);
    strcpy(gDelayCondition,GetNextArg(szLine));
    VarValue = atol(szVal);
    switch (szVal[strlen(szVal)-1]) {
        case 'm':
        case 'M':
            VarValue *= 60;
        case 's':
        case 'S':
            VarValue *= 10;
    }
    gDelay = VarValue;
    bRunNextCommand=false;
    //    DebugSpewNoFile("Delay - %d",gDelay);
}
 VOID Draw_Detour(VOID)
 {
     PCSIDLWND pThisGauge;
     __asm {mov [pThisGauge], ecx};
     StealNextGauge=false;
     if ((DWORD)pThisGauge->SidlPiece==9999)
     {
         StealNextGauge=true;
         CHAR Buffer[MAX_STRING]={0};
         STMLToPlainText(&pThisGauge->XMLToolTip->Text[0],Buffer);
         ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
         NextGauge=atoi(Buffer);
     }
     Draw_Trampoline();
 }
// ***************************************************************************
// Function:    Next
// Description: Our '/next' command
// Usage:       /next v#
// ***************************************************************************
VOID Next(PSPAWNINFO pChar, PCHAR szLine)
{
    bRunNextCommand = TRUE;
    CHAR szComp[MAX_STRING] = {0};
    CHAR ForLine[MAX_STRING] = {0};
    CHAR szNext[MAX_STRING] = {0};
    PMACROBLOCK pMacroLine = gMacroBlock;
    LONG StepSize = 1;
    GetArg(szNext,szLine,1);

    PDATAVAR pVar = FindMQ2DataVariable(szNext);
    if (!pVar)
    {
        FatalError("/next using invalid variable");
        return;
    }
    if (pVar->Var.Type!=pIntType)
    {
        FatalError("/for loops must use an int variable");
        return;
    }

    if (!gMacroBlock) {
        MacroError("Can only use /next during a macro.");
        return;
    }
    sprintf(szComp,"/for %s ",pVar->szName);
    while (pMacroLine->pPrev) {
        strcpy(ForLine,pMacroLine->Line);
        if (!strnicmp(ForLine,"Sub ",4)) {
            FatalError("/next without matching /for");
            return;
        }
        if (strnicmp(ForLine,"/for ",5)) {
            pMacroLine = pMacroLine->pPrev;
            continue;
        }
        if (!strnicmp(ParseMacroParameter(pChar,ForLine),szComp,strlen(szComp))) {
            if (!gMacroBlock) {
                // PMP bailed on us, we need to exit...
                return;
            }
            CHAR szTemp[MAX_STRING] = {0};
            DWORD VarNum = atoi(szLine+1);
            LONG Loop;
            if (strstr(_strlwr(strcpy(szTemp,ForLine)),"step")) {
                PCHAR pTemp = strstr(szTemp,"step")+4;
                while ( (pTemp[0]!=0) && (pTemp[0]!=' ') && (pTemp[0]!='\t')) pTemp++;
                if (pTemp[0]!=0) StepSize = atoi(pTemp);
            }

            pVar = FindMQ2DataVariable(szNext);
            if (!pVar)
            {
                FatalError("/next without badly matching /for");
                return;
            }

            if (strstr(_strlwr(strcpy(szTemp,ForLine)),"downto")) 
            {
                Loop = atoi(strstr(szTemp,"downto")+7);
                DebugSpewNoFile("Next - End of loop %d downto %d", pVar->Var.Int, Loop);
                pVar->Var.Int-=StepSize;
                if (pVar->Var.Int >= Loop) 
                    gMacroBlock = pMacroLine;
            } 
            else 
            {
                Loop = atoi(strstr(szTemp,"to")+3);
                DebugSpewNoFile("Next - End of loop %d to %d", pVar->Var.Int, Loop);
                pVar->Var.Int+=StepSize;
                if (pVar->Var.Int <= Loop) 
                    gMacroBlock = pMacroLine;
            }
            return;
        }
        pMacroLine = pMacroLine->pPrev;
    }

    FatalError("/next without matching /for");
}
Esempio n. 7
0
    VOID Draw_Detour(VOID)
    {
		CLabel* pThisLabel = (CLabel*)this;
        CHAR Buffer[MAX_STRING] = {0};
        BOOL Found=FALSE;
        DWORD index;
		if (gAnonymize) {
			if (!bTrimnames) {
				#if !defined(ROF2EMU) && !defined(UFEMU)
				EzDetourwName(CAdvancedLootWnd__UpdateMasterLooter, &CLabelHook::CAdvancedLootWnd__UpdateMasterLooter_Detour, &CLabelHook::CAdvancedLootWnd__UpdateMasterLooter_Trampoline,"CAdvancedLootWnd__UpdateMasterLooter");
				EzDetourwName(CComboWnd__GetChoiceText, &CLabelHook::CComboWnd__GetChoiceText_Detour, &CLabelHook::CComboWnd__GetChoiceText_Trampoline,"CComboWnd__GetChoiceText");
				EzDetourwName(CComboWnd__InsertChoiceAtIndex, &CLabelHook::CComboWnd__InsertChoiceAtIndex_Detour, &CLabelHook::CComboWnd__InsertChoiceAtIndex_Trampoline,"CComboWnd__InsertChoiceAtIndex");
				EzDetourwName(CAdvancedLootWnd__AddPlayerToList, &CLabelHook::CAdvancedLootWnd__AddPlayerToList_Detour, &CLabelHook::CAdvancedLootWnd__AddPlayerToList_Trampoline,"CAdvancedLootWnd__AddPlayerToList");
				if (pAdvancedLootWnd && GetGameState() == GAMESTATE_INGAME)
				{
					CleanupLootCombo(true);
				}
				#endif
				EzDetourwName(CListWnd__AddString, &CLabelHook::CListWnd__AddString_Detour, &CLabelHook::CListWnd__AddString_Trampoline,"CListWnd__AddString");
				EzDetourwName(CEverQuest__trimName, &CLabelHook::CEverQuest__trimName_Detour, &CLabelHook::CEverQuest__trimName_Trampoline,"CEverQuest__trimName");
				EzDetourwName(__GetGaugeValueFromEQ, GetGaugeValueFromEQ_Detour, GetGaugeValueFromEQ_Trampoline,"__GetGaugeValueFromEQ");
				EzDetourwName(__GetLabelFromEQ, GetLabelFromEQ_Detour, GetLabelFromEQ_Trampoline,"__GetLabelFromEQ");
				bTrimnames = 1;
			}
			if (pThisLabel && pThisLabel->CGetWindowText()) {
				GetCXStr(pThisLabel->CGetWindowText(), Buffer);
				Anonymize(Buffer,MAX_STRING);
			}
		} else {
			if (bTrimnames) {
				bTrimnames = 0;
			#if !defined(ROF2EMU) && !defined(UFEMU)
				RemoveDetour(CComboWnd__GetChoiceText);
				RemoveDetour(CComboWnd__InsertChoiceAtIndex);
				RemoveDetour(CAdvancedLootWnd__AddPlayerToList);
			#endif
				RemoveDetour(CListWnd__AddString);
				RemoveDetour(CEverQuest__trimName);
				RemoveDetour(__GetGaugeValueFromEQ);
				RemoveDetour(__GetLabelFromEQ);
			#if !defined(ROF2EMU) && !defined(UFEMU)
				CleanupLootCombo(false);
				RemoveDetour(CAdvancedLootWnd__UpdateMasterLooter);
			#endif
			}
		}
		Draw_Trampoline();
       if ((DWORD)pThisLabel->EQType==9999) {
            if (!pThisLabel->GetXMLToolTip()) {
                strcpy_s(Buffer,"BadCustom");
                Found=TRUE;
            } else {
                //strcpy_s(Buffer,&pThisLabel->XMLToolTip->Text[0]);
                STMLToPlainText(&pThisLabel->GetXMLToolTip()->Text[0],Buffer);
                ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                if (!strcmp(Buffer,"NULL"))
                    Buffer[0]=0;
                Found=TRUE;
            }
        } else if (pThisLabel->EQType==1000) {
            for (index=0;Id_PMP[index].ID>0 && !Found;index++) {
                if (Id_PMP[index].ID==(DWORD)pThisLabel->EQType) {
                    strcpy_s(Buffer,Id_PMP[index].PMP);
                    ParseMacroParameter(((PCHARINFO)pCharData)->pSpawn,Buffer);
                    if (!strcmp(Buffer,"NULL"))
                        Buffer[0]=0;
                    Found=TRUE;
                }
            }
        }
		if (Found)
		{
			pThisLabel->CSetWindowText(Buffer);
			//SetCXStr(&(pThisLabel->WindowText), Buffer);
		}
    }
Esempio n. 8
0
// Called every frame that the "HUD" is drawn -- e.g. net status / packet loss bar
PLUGIN_API VOID OnDrawHUD(VOID)
{
    static int N=0;
    CHAR szBuffer[MAX_STRING]={0};

    if (++N>CheckINI)
    {
        N=0;
        struct _stat now;
        if (Stat(INIFileName,now) && now.st_mtime!=LastRead.st_mtime)
            HandleINI();

        // check for EQ in foreground
        HWND EQhWnd = *(HWND*)EQADDR_HWND;
        if (EQW_GetDisplayWindow) EQhWnd=EQW_GetDisplayWindow();
        if (!bBGUpdate && GetForegroundWindow()!=EQhWnd)
            bEQHasFocus = false;
        else
            bEQHasFocus = true;
    }
    if (!bEQHasFocus) return;

    DWORD SX=0;
    DWORD SY=0;
    if (pScreenX && pScreenY)
    {
        SX=ScreenX;
        SY=ScreenY;
    }   
    PHUDELEMENT pElement=pHud;

    DWORD X,Y;
    while(pElement)
    {
        if ((gGameState==GAMESTATE_CHARSELECT && pElement->Type&HUDTYPE_CHARSELECT) ||
            (gGameState==GAMESTATE_INGAME && (
            (pElement->Type&HUDTYPE_NORMAL && ScreenMode!=3) ||
            (pElement->Type&HUDTYPE_FULLSCREEN && ScreenMode==3))))
        {
            if (pElement->Type&HUDTYPE_CURSOR)
            {
                PMOUSEINFO pMouse = (PMOUSEINFO)EQADDR_MOUSE;
                X=pMouse->X+pElement->X;
                Y=pMouse->Y+pElement->Y;
            }
            else
            {
                X=SX+pElement->X;
                Y=SX+pElement->Y;
            }
            if (!(N%SkipParse)) {
                strcpy_s(pElement->PreParsed,pElement->Text);
                ParseMacroParameter(GetCharInfo()->pSpawn,pElement->PreParsed);
            }
            strcpy_s(szBuffer,pElement->PreParsed);
            if (szBuffer[0] && strcmp(szBuffer,"NULL"))
            {
                DrawHUDText(szBuffer,X,Y,pElement->Color,pElement->Size);
            }
        }
        pElement=pElement->pNext;
    }
}
Esempio n. 9
0
VOID HideDoCommand(PSPAWNINFO pChar, PCHAR szLine, BOOL delayed)
{
    if (delayed)
    {
        PCHATBUF pChat = (PCHATBUF)malloc(sizeof(CHATBUF));
        if (pChat) {
            strcpy(pChat->szText,szLine);
            pChat->pNext = NULL;
            if (!gDelayedCommands) {
                gDelayedCommands = pChat;
            } else {
                PCHATBUF pCurrent;
                for (pCurrent = gDelayedCommands;pCurrent->pNext;pCurrent=pCurrent->pNext);
                pCurrent->pNext = pChat;
            }
        }
        return;
    }

    CAutoLock DoCommandLock(&gCommandCS);
    CHAR szCmd[MAX_STRING] = {0};
    CHAR szParam[MAX_STRING] = {0};
    CHAR szOriginalLine[MAX_STRING] = {0};

    strcpy(szOriginalLine,szLine);
    GetArg(szCmd,szLine,1);
    PALIAS pLoop = pAliases;
    while (pLoop) {
        if (!stricmp(szCmd,pLoop->szName)) {
            sprintf(szLine,"%s%s",pLoop->szCommand,szOriginalLine+strlen(pLoop->szName));
            break;
        }
        pLoop = pLoop->pNext;
    }


    GetArg(szCmd,szLine,1);
    if (szCmd[0]==0)
		return;
    strcpy(szParam, GetNextArg(szLine));

    if ((szCmd[0]==':') || (szCmd[0]=='{')) {
        bRunNextCommand = TRUE;
        return;
    }
	if(gMacroBlock && gMacroBlock->LoopLine!=0) {
		//this is a command thats inside a while loop
		//so its time to loop back
		gMacroBlock = GetWhileBlock(gMacroBlock->LoopLine);
		if (szCmd[0]=='}') {
			bRunNextCommand = TRUE;
			return;
		}
	} else if (szCmd[0]=='}') {
		if (strstr(szLine,"{")) {
			GetArg(szCmd,szLine,2);
			if (stricmp(szCmd,"else")) {
				FatalError("} and { seen on the same line without an else present");
			}
			//          DebugSpew("DoCommand - handing {} off to FailIf");
			FailIf(pChar,"{",gMacroBlock,TRUE);
		} else {
			// handle this: 
			//            /if () {
			//            } else /echo stuff
			GetArg(szCmd,szLine,2);
			if (!stricmp(szCmd,"else")) {
				// check here to fail this:
				//            /if () {
				//            } else 
				//                /echo stuff
				GetArg(szCmd,szLine,3);
				if (!stricmp(szCmd,"")) {
					FatalError("no command or { following else");
				}
				bRunNextCommand = TRUE;
			} else {
				bRunNextCommand = TRUE;
			}
		}
		return;
    }
    if (szCmd[0]==';' || szCmd[0]=='[')
    {
        pEverQuest->InterpretCmd((EQPlayer*)pChar,szOriginalLine);
        return;
    }



    PMQCOMMAND pCommand=pCommands;
    while(pCommand)
    {
        if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME)
        {
            pCommand=pCommand->pNext;
            continue;
        }
        int Pos=strnicmp(szCmd,pCommand->Command,strlen(szCmd));
        if (Pos<0)
        {// command not found
            break;
        }
        if (Pos==0)
        {
            if (pCommand->Parse && bAllowCommandParse)
            {
                pCommand->Function(pChar,ParseMacroParameter(pChar,szParam)); 
            } else {
                pCommand->Function(pChar,szParam);
			}
            strcpy(szLastCommand,szOriginalLine);
            return;
        }
        pCommand=pCommand->pNext;
    }
    if (!strnicmp(szOriginalLine,"sub ",4)) {
        FatalError("Flow ran into another subroutine.");
        return;
    }

    strcpy(szLastCommand,szOriginalLine);
    MacroError("DoCommand - Couldn't parse '%s'",szOriginalLine);
}
Esempio n. 10
0
    VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) 
    { 
        DebugSpew("CCommandHook::Detour(%s)",szFullLine);
        CHAR szFullCommand[MAX_STRING] = {0}; 
        CHAR szCommand[MAX_STRING] = {0}; 
        CHAR szArgs[MAX_STRING] = {0}; 
        CHAR szOrig[MAX_STRING] = {0};
        CHAR szSub[MAX_STRING] = {0};
        string szSubFullCommand = "";
        unsigned int k=0;
        bool OneCharacterSub = false;
        PALIAS pLoop = pAliases; 
        PSUB pSubLoop = pSubs;

        if (szFullLine[0]!=0) { 
            strcpy(szFullCommand,szFullLine); 
            GetArg(szCommand,szFullCommand,1); 

            if (!stricmp(szCommand,"/camp"))
            {
                if (gMacroBlock)
                {
                    WriteChatColor("A macro is currently running.  You may wish to /endmacro before you finish camping.", CONCOLOR_YELLOW );
                }
            }

            szSubFullCommand = szFullCommand;
            for (unsigned int i=0; i < sizeof(szFullCommand); i++ ) 
            {
                if (szFullCommand[i] == '%') 
                {
                    if (szFullCommand[i+2] == ' ' || szFullCommand[i+2] == '\0' ||
                        !isalnum(szFullCommand[i+2]) ) {
                            if (szFullCommand[i+1] == 'm' || szFullCommand[i+1] == 'M' ||
                                szFullCommand[i+1] == 'o' || szFullCommand[i+1] == 'O' ||
                                szFullCommand[i+1] == 'p' || szFullCommand[i+1] == 'P' ||
                                szFullCommand[i+1] == 'r' || szFullCommand[i+1] == 'R' ||
                                szFullCommand[i+1] == 's' || szFullCommand[i+1] == 'S' ||
                                szFullCommand[i+1] == 't' || szFullCommand[i+1] == 'T' )
                                continue;
                            else { 
                                szOrig[0] = szFullCommand[i+1];
                                szOrig[1] = '\0';
                                k = 1;
                                OneCharacterSub = true;
                            }
                    }

                    if (!OneCharacterSub) {
                        for (unsigned int j=i+1; j < sizeof(szFullCommand); j++ )
                        {
                            if (szFullCommand[j] == ' ' || szFullCommand[j] == '\0' ) 
                                break;
                            else if (!isalnum(szFullCommand[j]))
                                break;
                            szOrig[k] = szFullCommand[j];
                            k++;
                        }
                    }
                    while (pSubLoop)
                    {
                        if (!stricmp(szOrig, pSubLoop->szOrig)) 
                        {
                            sprintf( szSub, "%s", pSubLoop->szSub );
                            break;
                        }
                        pSubLoop = pSubLoop->pNext;
                    }
                    if (szSub[0] != '\0' ) {
                        szSubFullCommand.replace(i,k+1,szSub);
                        sprintf( szFullCommand, "%s",szSubFullCommand.c_str() ); 
                    }
                    szOrig[0] = '\0';
                    szSub[0] = '\0';
                    k=0;
                    OneCharacterSub = false;
                    pSubLoop = pSubs;
                }
            }
            sprintf(szFullCommand, "%s", szSubFullCommand.c_str() );

            while (pLoop) { 
                if (!stricmp(szCommand,pLoop->szName)) { 
                    sprintf(szCommand,"%s%s",pLoop->szCommand,szFullCommand+strlen(pLoop->szName)); 
                    strncpy(szFullCommand,szCommand,MAX_STRING); 
                    break;
                } 
                pLoop = pLoop->pNext; 
            } 
            GetArg(szCommand,szFullCommand,1); 
            strcpy(szArgs, GetNextArg(szFullCommand)); 

            PMQCOMMAND pCommand=pCommands;
            while(pCommand)
            {
                if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME)
                {
                    pCommand=pCommand->pNext;
                    continue;
                }
                int Pos=strnicmp(szCommand,pCommand->Command,strlen(szCommand));
                if (Pos<0)
                {// command not found
                    break;
                }
                if (Pos==0)
                {
                    if (pCommand->Parse && bAllowCommandParse)
                        ParseMacroParameter(pChar,szArgs); 
                    if (pCommand->EQ)
                    {
                        strcat(szCommand," "); 
                        strcat(szCommand,szArgs); 
                        Trampoline(pChar,szCommand); 
                    }
                    else
                    {
                        pCommand->Function(pChar,szArgs);
                    }
                    strcpy(szLastCommand,szFullCommand);
                    return;
                }
                pCommand=pCommand->pNext;
            }
        }
        Trampoline(pChar,szFullLine); 
        strcpy(szLastCommand,szFullCommand);
    } 
Esempio n. 11
0
VOID HideDoCommand(PSPAWNINFO pChar, PCHAR szLine, BOOL delayed)
{
	
    if (delayed)
    {
		lockit lk(ghLockDelayCommand,"HideDoCommand");
		CHAR szTheCmd[MAX_STRING];
		strcpy_s(szTheCmd, szLine);
		PCHATBUF pChat = 0;
		try {
			pChat = new CHATBUF;
			strcpy_s(pChat->szText,szTheCmd);
            pChat->pNext = 0;
            if (!gDelayedCommands) {
                gDelayedCommands = pChat;
            } else {
                PCHATBUF pCurrent = 0;
                for (pCurrent = gDelayedCommands;pCurrent->pNext;pCurrent=pCurrent->pNext);
                pCurrent->pNext = pChat;
            }
		}
		catch(std::bad_alloc& exc)
		{
			UNREFERENCED_PARAMETER(exc);
			MessageBox(NULL,"HideDoCommand failed to allocate memory for gDelayedCommands","Did we just discover a memory leak?",MB_SYSTEMMODAL|MB_OK);
		};
        return;
    }
    CAutoLock DoCommandLock(&gCommandCS);
	CHAR szTheCmd[MAX_STRING];
	strcpy_s(szTheCmd, szLine);
	WeDidStuff();
    CHAR szOriginalLine[MAX_STRING];
    strcpy_s(szOriginalLine,szTheCmd);
	CHAR szArg1[MAX_STRING];
	GetArg(szArg1,szTheCmd,1);
	std::string sName = szArg1;
	std::transform(sName.begin(), sName.end(), sName.begin(), tolower);
	if (mAliases.find(sName) != mAliases.end()) {
		sprintf_s(szTheCmd, "%s%s", mAliases[sName].c_str(), szOriginalLine + sName.size());
	}

    GetArg(szArg1,szTheCmd,1);
    if (szArg1[0]==0)
		return;
	CHAR szParam[MAX_STRING];
	strcpy_s(szParam, GetNextArg(szTheCmd));

    if ((szArg1[0]==':') || (szArg1[0]=='{')) {
        bRunNextCommand = TRUE;
        return;
    }
	PMACROBLOCK pBlock = GetCurrentMacroBlock();
	if (szArg1[0]=='}') {
		if (pBlock && pBlock->Line[pBlock->CurrIndex].LoopStart != 0) {
			pBlock->CurrIndex = pBlock->Line[pBlock->CurrIndex].LoopStart;
			extern void pop_loop();
			pop_loop();
			return;
		}
		if (strstr(szTheCmd,"{")) {
			GetArg(szArg1,szTheCmd,2);
			if (_stricmp(szArg1,"else")) {
				FatalError("} and { seen on the same line without an else present");
			}
			//          DebugSpew("DoCommand - handing {} off to FailIf");
			if(pBlock)
				FailIf(pChar,"{",pBlock->CurrIndex,TRUE);
		} else {
			// handle this: 
			//            /if () {
			//            } else /echo stuff
			GetArg(szArg1,szTheCmd,2);
			if (!_stricmp(szArg1,"else")) {
				// check here to fail this:
				//            /if () {
				//            } else 
				//                /echo stuff
				GetArg(szArg1,szTheCmd,3);
				if (!_stricmp(szArg1,"")) {
					FatalError("no command or { following else");
				}
				bRunNextCommand = TRUE;
			} else {
				bRunNextCommand = TRUE;
			}
		}
		return;
    }
    if (szArg1[0]==';' || szArg1[0]=='[')
    {
        pEverQuest->InterpretCmd((EQPlayer*)pChar,szOriginalLine);
        return;
    }
    PMQCOMMAND pCommand=pCommands;
    while(pCommand)
    {
        if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME)
        {
            pCommand=pCommand->pNext;
            continue;
        }
        int Pos=_strnicmp(szArg1,pCommand->Command,strlen(szArg1));
        if (Pos<0)
        {// command not found
            break;
        }
        if (Pos==0)
        {
            if (pCommand->Parse && bAllowCommandParse)
            {
                pCommand->Function(pChar,ParseMacroParameter(pChar,szParam)); 
            }
			else {
                pCommand->Function(pChar,szParam);
			}
            strcpy_s(szLastCommand,szOriginalLine);
            return;
        }
        pCommand=pCommand->pNext;
    }
    PBINDLIST pBind = pBindList;
    while( pBind )
    {
        if( gGameState != GAMESTATE_INGAME )
        {
            // Macro Binds only supported in-game
            pBind = pBind->pNext;
            continue;
        }

        int Pos = _strnicmp( szArg1, pBind->szName, strlen( szArg1 ) );

        if( Pos == 0 )
        {
            // found it!
            if( pBind->szFuncName )
            {
                if( PCHARINFO pCharInfo = GetCharInfo() )
                {
                    std::string sCallFunc( pBind->szFuncName );
                    sCallFunc += " ";
                    sCallFunc += szParam;
					CHAR szCallFunc[MAX_STRING] = { 0 };
					strcpy_s(szCallFunc, sCallFunc.c_str());
					ParseMacroData(szCallFunc, MAX_STRING);
					//Call(pCharInfo->pSpawn, (PCHAR)szCallFunc.c_str());
					if (pBlock && !pBlock->BindCmd.size()) {
						if (!gBindInProgress) {
							gBindInProgress = true;
							pBlock->BindCmd = szCallFunc;
						}
						else {
							Beep(1000, 100);
							WriteChatf("Can't execute bind while another bind is on progress");
						}
					}
                }
            }
            strcpy_s( szLastCommand, szOriginalLine );
            return;
        }

        pBind = pBind->pNext;
    }

    // skip this logic for Bind Commands.
    if( _strnicmp( szOriginalLine, "sub bind_", 9 ) != 0 ) {
        if( !_strnicmp( szOriginalLine, "sub ", 4 ) ) {
            FatalError( "Flow ran into another subroutine. (%s)", szOriginalLine );
            return;
        }

        strcpy_s( szLastCommand, szOriginalLine );
        MacroError( "DoCommand - Couldn't parse '%s'", szOriginalLine );
    }
}
Esempio n. 12
0
    VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) 
    {
		lockit lk(ghCCommandLock,"CCommandHook::Detour");
        DebugSpew("CCommandHook::Detour(%s)",szFullLine);
        CHAR szFullCommand[MAX_STRING] = {0}; 
        CHAR szCommand[MAX_STRING] = {0}; 
        CHAR szArgs[MAX_STRING] = {0}; 
        CHAR szOrig[MAX_STRING] = {0};
        CHAR szSub[MAX_STRING] = {0};
        std::string szSubFullCommand = "";
        unsigned int k=0;
        bool OneCharacterSub = false;
        PSUB pSubLoop = pSubs;
        if (szFullLine[0]!=0) { 
			strcpy_s(szFullCommand,szFullLine);
            GetArg(szCommand,szFullCommand,1); 

            if (!_stricmp(szCommand,"/camp"))
            {
                if (GetmacroBlockCount())
                {
                    WriteChatColor("A macro is currently running.  You may wish to /endmacro before you finish camping.", CONCOLOR_YELLOW );
                }
            }

            szSubFullCommand = szFullCommand;
            size_t len = strnlen_s(szFullCommand, MAX_STRING);
			for (unsigned int i=0; i < sizeof(szFullCommand); i++ ) 
            {
                if (szFullCommand[i] == '%' && ((i+2)<len))
                {
                    if (szFullCommand[i+2] == ' ' || szFullCommand[i+2] == '\0' ||
                        !isalnum(szFullCommand[i+2]) ) {
                            if (szFullCommand[i+1] == 'm' || szFullCommand[i+1] == 'M' ||
                                szFullCommand[i+1] == 'o' || szFullCommand[i+1] == 'O' ||
                                szFullCommand[i+1] == 'p' || szFullCommand[i+1] == 'P' ||
                                szFullCommand[i+1] == 'r' || szFullCommand[i+1] == 'R' ||
                                szFullCommand[i+1] == 's' || szFullCommand[i+1] == 'S' ||
                                szFullCommand[i+1] == 't' || szFullCommand[i+1] == 'T' )
                                continue;
                            else { 
                                szOrig[0] = szFullCommand[i+1];
                                szOrig[1] = '\0';
                                k = 1;
                                OneCharacterSub = true;
                            }
                    }

                    if (!OneCharacterSub) {
                        for (unsigned int j=i+1; j < sizeof(szFullCommand); j++ )
                        {
                            if (szFullCommand[j] == ' ' || szFullCommand[j] == '\0' ) 
                                break;
                            else if (!isalnum(szFullCommand[j]))
                                break;
                            szOrig[k] = szFullCommand[j];
                            k++;
                        }
                    }
                    while (pSubLoop)
                    {
                        if (!_stricmp(szOrig, pSubLoop->szOrig)) 
                        {
                            sprintf_s( szSub, "%s", pSubLoop->szSub );
                            break;
                        }
                        pSubLoop = pSubLoop->pNext;
                    }
                    if (szSub[0] != '\0' ) {
                        szSubFullCommand.replace(i,k+1,szSub);
						sprintf_s( szFullCommand, "%s",szSubFullCommand.c_str() );
                    }
                    szOrig[0] = '\0';
                    szSub[0] = '\0';
                    k=0;
                    OneCharacterSub = false;
                    pSubLoop = pSubs;
                }
            }
			sprintf_s(szFullCommand, "%s", szSubFullCommand.c_str() );
			std::string sName = szCommand;
			std::transform(sName.begin(), sName.end(), sName.begin(), tolower);
			if (mAliases.find(sName) != mAliases.end()) {
				sprintf_s(szCommand,"%s%s",mAliases[sName].c_str(),szFullCommand+sName.size());
                strcpy_s(szFullCommand,szCommand); 
			}

            GetArg(szCommand,szFullCommand,1); 
            strcpy_s(szArgs, GetNextArg(szFullCommand)); 

            PMQCOMMAND pCommand=pCommands;
            while(pCommand)
            {
                if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME)
                {
                    pCommand=pCommand->pNext;
                    continue;
                }
                int Pos=_strnicmp(szCommand,pCommand->Command,strlen(szCommand));
                if (Pos<0)
                {// command not found
                    break;
                }
                if (Pos==0)
                {
					if (pCommand->Parse && bAllowCommandParse) {
						ParseMacroParameter(pChar, szArgs);
					}
                    if (pCommand->EQ)
                    {
                        strcat_s(szCommand," "); 
						strcat_s(szCommand,szArgs);
                        Trampoline(pChar,szCommand); 
                    }
                    else
                    {
                        pCommand->Function(pChar,szArgs);
                    }
                    strcpy_s(szLastCommand,szFullCommand);
                    return;
                }
                pCommand=pCommand->pNext;
            }

            PBINDLIST pBind = pBindList;
			PMACROBLOCK pBlock = GetCurrentMacroBlock();
            while( pBind )
            {
                if( gGameState != GAMESTATE_INGAME )
                {
                    // Macro Binds only supported in-game
                    pBind = pBind->pNext;
                    continue;
                }

                int Pos = _strnicmp( szCommand, pBind->szName, strlen( szCommand ) );

                if( Pos == 0 )
                {
                    // found it!
                    if( pBind->szFuncName )
                    {
                        if( PCHARINFO pCharInfo = GetCharInfo() )
                        {
                            std::string sCallFunc( pBind->szFuncName );
                            sCallFunc += " ";
                            sCallFunc += szArgs;
							CHAR szCallFunc[MAX_STRING] = { 0 };
							strcpy_s(szCallFunc, sCallFunc.c_str());
							ParseMacroData(szCallFunc, MAX_STRING);
							if (pBlock && !pBlock->BindCmd.size()) {
								if (!gBindInProgress) {
									gBindInProgress = true;
									pBlock->BindCmd = szCallFunc;
								}
								else {
									Beep(1000, 100);
									WriteChatf("Can't execute bind while another bind is on progress");
								}
							}
							//CHAR szOrg[MAX_STRING] = {"${Time}"};
							//ParseMacroData(szOrg, MAX_STRING);
							//WriteChatf("[%s] %s called",szOrg, szCallFunc.c_str());
							//Beep(1000, 100);
                        }
                    }
                    strcpy_s( szLastCommand, szFullCommand );
                    return;
                }

                pBind = pBind->pNext;
            }
        }
        Trampoline(pChar,szFullLine); 
		strcpy_s(szLastCommand,szFullCommand);
    }