void SetComboSelection(CSidlScreenWnd*pCombo, DWORD index) { CXRect comborect = ((CXWnd*)pCombo)->GetScreenRect(); CXPoint combopt = comborect.CenterPoint(); ((CComboWnd*)pCombo)->SetChoice(index); ((CXWnd*)pCombo)->HandleLButtonDown(&combopt, 0); if (CListWnd*pListWnd = (CListWnd*)pCombo->Items) { int index = pListWnd->GetCurSel(); CXRect listrect = pListWnd->GetItemRect(index, 0); CXPoint listpt = listrect.CenterPoint(); ((CXWnd*)pListWnd)->HandleLButtonDown(&listpt, 0); ((CXWnd*)pListWnd)->HandleLButtonUp(&listpt, 0); WeDidStuff(); } }
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 ); } }