本文整理汇总了C++中CUIntArray类的典型用法代码示例。如果您正苦于以下问题:C++ CUIntArray类的具体用法?C++ CUIntArray怎么用?C++ CUIntArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CUIntArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Refresh
//////////////////
// Refresh all colors, fonts, etc. For WM_SETTINGCHANGE, WM_SYSCOLORCHANGE.
//
void CCoolMenuManager::Refresh()
{
// first copy list (array) of toolbar IDs now loaded.
CUIntArray arToolbarID;
arToolbarID.Copy(m_arToolbarID);
// destroy everything
Destroy();
// re-load toolbars.
int nToolbars = arToolbarID.GetSize();
for (int i = 0; i < nToolbars; i++)
LoadToolbar(arToolbarID[i]);
}
示例2: GetDeleted
void CDbManageDlg::GetDeleted(CUIntArray& anDeleted)
{
unsigned ind_cur;
unsigned ind_orig;
unsigned ind_new;
ind_new = 0;
ind_cur = 0;
for (ind_orig=0;ind_orig<m_nEntriesOrigMax;ind_orig++) {
// NOTE: We cannot call *.GetAt(#) when the IntArray is
// of length 0! (this will happen if we do a "Delete All").
// In debug mode this will result in a debugger exception.
// Therefore, we'll check for this condition and fake out
// the ind_new to be something that will fall through to
// the next clause which adds it to the deleted list
if (!m_anEntriesInd.IsEmpty()) {
ind_new = m_anEntriesInd.GetAt(ind_cur);
} else {
// Fake out the index so that it doesn't match original position
ind_new = 99999;
}
if (ind_orig==ind_new) {
// Entries match, advance current pointer along
ind_cur++;
} else {
// Entry missing, mark as deleted, but don't
// advance current pointer
anDeleted.Add(ind_orig);
}
}
}
示例3: FindUInt
int FindUInt(UINT x, CUIntArray& aUInt)
{
for(int i=0; i<aUInt.GetSize(); i++)
if(x==aUInt[i])
return i;
return -1;
}
示例4: WriteSimpleArray
void EditSerializer::WriteSimpleArray(DataField field, const CUIntArray& a)
{
CString result;
char buf[16];
for (int i=0; i<a.GetSize(); i++)
{
unsigned int val = a.GetAt(i);
if (i > 0)
result += ";";
sprintf(buf, "%d", val);
result += buf;
}
WriteString(field, (LPCTSTR)result);
}
示例5: OnBnClickedOrderChange
void CGumpControlListDlg::OnBnClickedOrderChange()
{
CDEditor& editor = m_pView->GetDEditor();
CSortListCtrl& ctrl = m_lsControl;
CUIntArray arOrder;
arOrder.SetSize(ctrl.GetItemCount());
for (int i =0; i < ctrl.GetItemCount(); i++)
arOrder[ctrl.GetItemData(i)] = atoi(ctrl.GetItemText(i, ORDER_COLUMN));
editor.Reorder(arOrder);
editor.SetModified(TRUE);
editor.RedrawWindow();
OnOK();
}
示例6: StringTokenize
void CUpdateUtil::StringTokenize(CString& strSource, CUIntArray &UIntDestArray)
{
CTokenizer tok(strSource, _T(".,;|"));
CString cs;
while(tok.Next(cs)){
UIntDestArray.Add((UINT)atoi((LPCTSTR)cs));
}
}
示例7: OnSetActive
BOOL COptionsDlg::OnSetActive() {
CSnmp *pSnmp = &theApp.m_wnd.snmp;
if (pSnmp != NULL) {
CStringArray s;
CUIntArray nAdapterArray;
pSnmp->GetInterfaceDescriptions(&s, &nAdapterArray);
m_Interfaces.ResetContent();
int active = 0;
for (int i = 0; i <= s.GetUpperBound(); i++) {
int index = m_Interfaces.AddString(s.GetAt(i));
if (index != CB_ERR) {
m_Interfaces.SetItemData(index, nAdapterArray.GetAt(i));
if (nAdapterArray.GetAt(i) == g_dwAdapter)
active = i;
}
}
m_Interfaces.SetCurSel(active);
}
return CPropertyPage::OnSetActive();
}
示例8: EnumerateSerialPorts
/*
枚举串口号
*/
void DlgOptions::EnumerateSerialPorts(CUIntArray& ports, CUIntArray& portse, CUIntArray& portsu)
{
//清除串口数组内容
ports.RemoveAll();
portse.RemoveAll();
portsu.RemoveAll();
//因为至多有10个串口,所以依次检查各串口是否存在
//如果能打开某一串口,或打开串口不成功,但返回的是 ERROR_ACCESS_DENIED错误信息,
//都认为串口存在,只不过后者表明串口已经被占用
//否则串口不存在
for (int i=1; i<11; i++)
{
//Form the Raw device name
CString sPort;
sPort.Format(_T("\\\\.\\COM%d"), i);
//Try to open the port
BOOL bSuccess = FALSE;
HANDLE hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (hPort == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
if (dwError == ERROR_ACCESS_DENIED)
{
bSuccess = TRUE;
portsu.Add(i); //已占用的串口
}
}
else
{
//The port was opened successfully
bSuccess = TRUE;
portse.Add(i); ////可用的串口
//Don't forget to close the port, since we are going to do nothing with it anyway
CloseHandle(hPort);
}
//Add the port number to the array which will be returned
if (bSuccess)
ports.Add(i); //所有存在的串口
}
}
示例9: SetFocus
void CSListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
if( UPDATE_HINT_SLISTVIEW != lHint )
return;
if( IsWindowVisible() )
SetFocus( );
int nColumnCount = m_Grid.GetColumnCount();
if( nColumnCount <= 0 )
return;
if( GetParentFrame()->GetSafeHwnd() != AfxGetMainFrame()->GetActiveFrame()->GetSafeHwnd() )
{
m_bShouldUpdate = TRUE;
return;
}
m_bShouldUpdate = FALSE;
CStockContainer & container = AfxGetSListStockContainer();
container.Lock();
m_Grid.DeleteNonFixedRows();
// Progress
CMainFrame * pMainFrame = AfxGetMainFrame();
if( pMainFrame )
{
pMainFrame->ShowProgressBar( );
pMainFrame->SetProgress( 0 );
pMainFrame->SetMessageText( IDS_MAINFRAME_WAITING );
}
CUIntArray anParams;
anParams.SetSize( 0, nColumnCount );
for( int nCol=0; nCol < nColumnCount; nCol ++ )
{
LPARAM lParam = m_Grid.GetItemData( 0, nCol );
anParams.Add( lParam );
}
CRect rectClient;
GetClientRect( &rectClient );
int nPageCount = 1 + rectClient.Height() / abs(m_Grid.GetFixedRowHeight()) + 1;
for( int i=0; i<container.GetSize(); i++ )
{
CStockInfo & info = container.GetStockInfoByID(i);
int nRow = m_Grid.InsertRow( info.GetStockName() );
m_Grid.SetItemData( nRow, 0, i );
for( int nCol=0; nCol<anParams.GetSize(); nCol++ )
{
m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( anParams[nCol], info, &container ) );
m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( anParams[nCol], info ) );
if( anParams[nCol] == SLH_DATE )
m_Grid.SetColumnWidth( nCol, 80 );
if( anParams[nCol] == SLH_CODE )
m_Grid.SetColumnWidth( nCol, 60 );
}
if( i == nPageCount+5 )
{
m_Grid.Invalidate( );
MSG msg;
while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) )
AfxGetApp()->PumpMessage();
}
if( pMainFrame )
pMainFrame->SetProgress( 100*i/container.GetSize() );
}
// Set Average and Weight Average
// SetAverageItem( m_Grid, container, FALSE );
// Sort If Needed
if( -1 != m_nColSort )
{
LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
if( lParam >= 0 )
{
CStockContainer::m_pSortContainer = &container;
container.m_nSortVariantID = lParam;
container.m_bSortAscend = m_bSortAscend;
m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
}
}
if( pMainFrame )
{
pMainFrame->SetProgress( 100 );
pMainFrame->HideProgressBar( );
pMainFrame->SetMessageText( IDS_MAINFRAME_FINISHED );
pMainFrame->SetMessageText( IDS_HELPTIP_SLIST );
}
if( m_bFirstUpdate )
m_Grid.AutoSizeColumns( );
//.........这里部分代码省略.........
示例10: ZeroMemory
BOOL CQuoteColumnSetting::SaveCurGroup(CString strGroupName /* = _T */)
{
if (!m_bCurChanged)
{
return FALSE;
}
if (strGroupName.IsEmpty())
{
m_wndCurGroup.GetWindowText(strGroupName);
}
//CArray<CStringArray*,CStringArray*> ayNewColGroup;
CUIntArray ayNewColGroup;
CMapWordToPtr mapFixedCol;
//CString strTemp;
// 生成所有显示列项
for (int i=0; i<m_wndCurGroupCol.GetItemCount(); i++)
{
//CStringArray* pCol = new CStringArray;
CUIntArray* pAyCol = new CUIntArray;
LVITEM item;
ZeroMemory(&item,sizeof(LVITEM));
item.mask = LVIF_PARAM | LVIF_IMAGE;
item.iItem = i;
m_wndCurGroupCol.GetItem(&item);
int nID = (int)item.lParam;
pAyCol->Add(nID);
//strTemp.Format("%d",nID);
//pCol->Add(strTemp);
long nWidth = (long)item.iImage;
nWidth = nWidth>0 ? nWidth : m_iCol->GetColumnWidth(nID);
pAyCol->Add(nWidth);
//strTemp.Format("%d",nWidth);
//pCol->Add(strTemp);
if (CQuoteReportTable::IsFixedColumn(nID)) // 判断是否固定列
{
mapFixedCol.SetAt(nID,(void*)pAyCol); // 固定列暂时放入哈希表,后面处理
}
else
{
ayNewColGroup.Add(nID);
ayNewColGroup.Add(nWidth);
//ayNewColGroup.Add(pCol); // 正常列直接放入数组
}
}
if (mapFixedCol.GetCount() > 0) // 处理固定列
{
int nID = 0;
//CStringArray* payTempCol = NULL;
CUIntArray* pAyCol = NULL;
if (mapFixedCol.Lookup(COLUMN_HQ_BASE_ARROW,(void*&)pAyCol) && pAyCol)
{
ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
delete pAyCol;
mapFixedCol.RemoveKey(COLUMN_HQ_BASE_ARROW);
//ayNewColGroup.InsertAt(0,payTempCol);
}
if (mapFixedCol.Lookup(COLUMN_HQ_BASE_INFO_MARK,(void*&)pAyCol) && pAyCol)
{
ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
delete pAyCol;
mapFixedCol.RemoveKey(COLUMN_HQ_BASE_INFO_MARK);
}
if (mapFixedCol.Lookup(COLUMN_HQ_BASE_NAME,(void*&)pAyCol) && pAyCol)
{
ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
delete pAyCol;
mapFixedCol.RemoveKey(COLUMN_HQ_BASE_NAME);
}
if (mapFixedCol.Lookup(COLUMN_HQ_BASE_CODE,(void*&)pAyCol) && pAyCol)
{
ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
delete pAyCol;
mapFixedCol.RemoveKey(COLUMN_HQ_BASE_CODE);
}
if (mapFixedCol.Lookup(COLUMN_HQ_BASE_NUMBER,(void*&)pAyCol) && pAyCol)
{
ayNewColGroup.InsertAt(0, pAyCol->GetAt(0));
ayNewColGroup.InsertAt(1, pAyCol->GetAt(1));
delete pAyCol;
mapFixedCol.RemoveKey(COLUMN_HQ_BASE_NUMBER);
}
}
m_iCol->SetDispColGroup(strGroupName, &ayNewColGroup);
// for (int i=0; i<ayNewColGroup.GetCount(); i++)
// {
// CStringArray* pTemp = ayNewColGroup.GetAt(i);
// if (pTemp)
// {
// delete pTemp;
//.........这里部分代码省略.........
示例11: toolThreadProc
DWORD WINAPI toolThreadProc( LPVOID lpParam )
{
CMemReaderProxy reader;
CPackSenderProxy sender;
CMemConstData memConstData = reader.getMemConstData();
CConfigData *config = (CConfigData *)lpParam;
//sender.sendAutoAimConfig(1,config->onlyCreatures,config->aimPlayersFromBattle);
CTibiaItemProxy itemProxy;
CTibiaCharacter *sel = reader.readSelfCharacter();
float caps=sel->cap;
FILE* f = fopen("C:/srangp.txt","wb");
while (!toolThreadShouldStop)
{
Sleep(100);
delete sel;
sel = reader.readSelfCharacter();
if (caps!=sel->cap && sel->cap>5000){
int addy=itemProxy.getValueForConst("addrCap");
for (int i=0;i<20;i++){
int a=reader.getMemIntValue(addy+(i-10)*4);
fprintf(f,"%8x",a);
}
fprintf(f,"\n");
fflush(f);
caps=sel->cap;
}
}
while (!toolThreadShouldStop)
{
Sleep(100);
if (reader.getConnectionState()!=8) continue; // do not proceed if not connected
const char *var = reader.getGlobalVariable("UH_needed");
if (strcmp(var, "true")) continue;
int attackedCreature = reader.getAttackedCreature();
//T4: If any creature is attacked
if (attackedCreature)
{
//T4: Get attacked creature stucture
CTibiaCharacter *ch = reader.getCharacterByTibiaId(attackedCreature);
if (ch)
{
//T4: cords
int chX=ch->x;
int chY=ch->y;
int chZ=ch->z;
//T4: Check containers for the same rune as in hand
int contNr;
for (contNr=0;contNr<memConstData.m_memMaxContainers;contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
CUIntArray acceptedItems;
//T4: If default rune has been choosen then cast it every time creature is attacked
if (config->RuneType!=0){
acceptedItems.RemoveAll();
acceptedItems.Add(config->RuneType);
CTibiaItem *runeItem = CModuleUtil::lookupItem(contNr,&acceptedItems);
if (runeItem->objectId)
{
sender.castRuneAgainstCreature(0x40+contNr,runeItem->pos,
config->RuneType,attackedCreature);
}
delete runeItem;
}
};
delete cont;
}
delete ch;
}
}
}
sender.sendAutoAimConfig(0,0,0);
toolThreadShouldStop=0;
return 0;
}
示例12: switch
void CXTPReportSelectedRows::SelectBlock(int nBlockBegin, int nEnd, BOOL bControlKey)
{
CXTPReportRows* pRows;
switch(m_nRowType)
{
case xtpRowTypeHeader : pRows = m_pControl->GetHeaderRows(); break;
case xtpRowTypeFooter : pRows = m_pControl->GetFooterRows(); break;
default : pRows = m_pControl->GetRows(); break;
}
int nRowsCount(0);
if (pRows)
nRowsCount = pRows->GetCount();
BOOL bGo = (nBlockBegin >= 0 && nBlockBegin < nRowsCount && nEnd < nRowsCount);
if (!bGo)
{
Clear(GetNotifyOnSelectedRowsClear());
return;
}
if (bControlKey == FALSE)
{
nBlockBegin = m_nRowBlockBegin != -1 ? m_nRowBlockBegin : nBlockBegin;
int nBegin = nBlockBegin;
if (nBegin == -1 || nEnd == -1)
return;
if (nBegin > nEnd)
{
nBegin = nEnd;
nEnd = nBlockBegin;
}
if (m_arrSelectedBlocks.GetSize() == 1 && m_arrSelectedBlocks[0].nIndexBegin == nBegin &&
m_arrSelectedBlocks[0].nIndexEnd == nEnd + 1)
{
return;
}
XTPReportRowType nRowType = m_nRowType;
Clear(GetNotifyOnSelectedRowsClear());
m_nRowType = nRowType;
if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin;
BOOL bSkipGroupFocus = m_pControl->IsSkipGroupsFocusEnabled();
BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
if (!bHasGroups || !bSkipGroupFocus)
{
_InsertBlock(0, nBegin, nEnd + 1);
}
else
{
for (int i = nBegin; i <= nEnd; i++)
{
CXTPReportRow* pRow = pRows->GetAt(i);
if (!pRow)
continue;
if (!bSkipGroupFocus || !pRow->IsGroupRow() || !pRow->IsExpanded() || (i == nBegin) || (i == nEnd))
{
Add(pRow);
}
}
}
// notify owner the selection state has changed.
_NotifyStateChanged(nBegin, nEnd);
}
else
{
int kSB = (int) m_arrSelectedBlocks.GetSize();
if (kSB > 0)
{
int iMin = m_arrSelectedBlocks[0].nIndexBegin;
int iMax = m_arrSelectedBlocks[kSB - 1].nIndexEnd;
if (nEnd >= iMin && nEnd < iMax)
{
return;
}
}
BOOL bSkipGroupFocus = FALSE;//m_pControl->IsSkipGroupsFocusEnabled();
BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
BOOL bWasShiftKey = m_pControl->m_bWasShiftKey;
if (m_nRowBlockBegin != -1)
nBlockBegin = m_nRowBlockBegin;
int nBegin(nBlockBegin), iB, iE;
if (nBegin == -1 || nEnd == -1)
{
return;
}
BOOL bSwap = SwapIfNeed(nBegin, nEnd);
int nArSz = (int) m_arrSelectedBlocks.GetSize();
CUIntArray ar;
if (nArSz > 0)
{
//.........这里部分代码省略.........
示例13: DEBUG_OUTF
// 加载Toolbox配置文件
BOOL CVciOwm::LoadToolbox(LPCTSTR lpszToolboxFile)
{
if(GetFileAttributes(lpszToolboxFile) == 0xFFFFFFFF)
{
return FALSE;
}
CXmlParser parser;
if(parser.Open(lpszToolboxFile))
{
DEBUG_OUTF(LOG_LEVEL_ERROR, "Load toolbox file %s fail!", lpszToolboxFile);
return FALSE;
}
CString strImagePath = theApp.GetModulePath();
BOOL bRet = TRUE;
DOMNode* pNode = parser.GetRootNode();
// 加载图片资源
DOMNode* pImageNode = parser.GetChildNode(pNode, "image");
while (pImageNode != NULL)
{
CString strIconFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageNode, "file");
int nImageId = atoi(parser.GetNodeAttribute(pImageNode, "id"));
// 加载单个图片
if(!theApp.SetToolboxIcon(strIconFile, nImageId))
{
bRet = FALSE;
}
pImageNode = parser.GetNextNode(pImageNode, "image");
}
DOMNode* pImageListNode = parser.GetChildNode(pNode, "imagelist");
while (pImageListNode != NULL)
{
CString strBmpFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageListNode, "file");
CString strIDs = parser.GetNodeText(pImageListNode);
CUIntArray auID;
int nPos = strIDs.Find(",");
while(nPos != -1)
{
auID.Add(atoi(strIDs.Left(nPos)));
strIDs.Delete(0, nPos+1);
nPos = strIDs.Find(",");
}
auID.Add(atoi(strIDs));
// 加载图片列表
if(!theApp.SetToolboxIcons(strBmpFile, &auID))
{
bRet = FALSE;
}
pImageListNode = parser.GetNextNode(pImageListNode, "imagelist");
}
// 加载控件组和控件
DOMNode* pGroupNode = parser.GetChildNode(pNode, "group");
while (pGroupNode != NULL)
{
CString strGroupName = parser.GetNodeAttribute(pGroupNode, "name");
int nGroupId = atoi(parser.GetNodeAttribute(pGroupNode, "id"));
BOOL bExpand = (parser.GetNodeAttribute(pGroupNode, "expand") == "true");
CXTPTaskPanelGroup* pFolderClass = theApp.CreateToolboxGroup(nGroupId, strGroupName);
// 加载控件
DOMNode* pItemNode = parser.GetChildNode(pGroupNode, "control");
while (pItemNode != NULL)
{
CString strControlName = parser.GetNodeAttribute(pItemNode, "name");
int nControlImageId = atoi(parser.GetNodeAttribute(pItemNode, "image-id"));
CXTPTaskPanelGroupItem* pItem = pFolderClass->AddLinkItem(nControlImageId, nControlImageId);
pItem->SetCaption(theApp.StripMnemonics(strControlName));
pItemNode = parser.GetNextNode(pItemNode, "control");
}
pFolderClass->SetExpanded(bExpand);
pGroupNode = parser.GetNextNode(pGroupNode, "group");
}
parser.Close();
return TRUE;
}
示例14: toolThreadProc
//.........这里部分代码省略.........
}
if (!drank && (self->hp < self->maxHp && self->hp < hpBelow && config->drinkHp))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluid"), 11, config->drinkHp, config->useHotkey, hpBelow, -1);
if (drank)
RandomVariableHp(config->hpBelow, MAKE, config, self);
}
if (!drank && (self->hp < self->maxHp && self->hp < customItem1Below && config->customItem1Use))
{
drank |= tryDrinking(config->customItem1Item, 0, config->customItem1Use, config->useHotkey, customItem1Below, -1);
if (drank)
RandomVariableHp(config->customItem1Below, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowG && config->drinkManaG) && self->lvl >= 80)
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidManaG"), 0, config->drinkManaG, config->useHotkey, -1, manaBelowG);
if (drank)
RandomVariableMana(config->manaBelowG, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowS && config->drinkManaS) && self->lvl >= 50)
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidManaS"), 0, config->drinkManaS, config->useHotkey, -1, manaBelowS);
if (drank)
RandomVariableMana(config->manaBelowS, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowN && config->drinkManaN))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidMana"), 0, config->drinkManaN, config->useHotkey, -1, manaBelowN);
if (drank)
RandomVariableMana(config->manaBelowN, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelow && config->drinkMana))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluid"), 10, config->drinkMana, config->useHotkey, -1, manaBelow);
if (drank)
RandomVariableMana(config->manaBelow, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < customItem2Below && config->customItem2Use))
{
drank |= tryDrinking(config->customItem2Item, 0, config->customItem2Use, config->useHotkey, -1, customItem2Below);
if (drank)
RandomVariableMana(config->customItem2Below, MAKE, config, self);
}
if (drank)
{
int stopSleepTime = reader.getCurrentTm() + CModuleUtil::randomFormula(config->sleep, 200, config->sleep);
while (reader.getCurrentTm() < stopSleepTime)
{
Sleep(50);
}
}
if (config->dropEmpty)
{
CUIntArray itemArray;
itemArray.Add(CTibiaItem::getValueForConst("fluid"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmpty"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmptyS"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmptyG"));
int contNr;
int openContNr = 0;
int openContMax = reader.readOpenContainerCount();
for (contNr = 0; contNr < reader.m_memMaxContainers && openContNr < openContMax; contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
openContNr++;
CTibiaItem *item = CModuleUtil::lookupItem(contNr, &itemArray);
if (item->objectId)
{
CPackSender::moveObjectFromContainerToFloor(item->objectId, 0x40 + contNr, item->pos, self->x, self->y, self->z, item->quantity ? item->quantity : 1);
Sleep(CModuleUtil::randomFormula(config->sleep, 200, 0));
delete item;
delete cont;
break;
}
delete item;
}
delete cont;
}
}
delete self;
}
setMana.clear();
setHp.clear();
toolThreadShouldStop = 0;
drinkFails = 0;
return 0;
}
示例15: tryDrinking
int tryDrinking(int itemId, int itemType, int drink, int hotkey, int hpBelow, int manaBelow)
{
CMemReader& reader = CMemReader::getMemReader();
int contNr;
CUIntArray itemArray;
int drank = 0;
itemArray.Add(itemId);
CTibiaCharacter *self = reader.readSelfCharacter();
if (hotkey)
{
CPackSender::useItemOnCreature(itemId, self->tibiaId);
if (CModuleUtil::waitForHpManaIncrease(self->hp, self->mana))//most likely using item succeeded
{
drank = 1;
drinkFails = 0;
}
else
{
drinkFails += 1;
drinkFails = (drinkFails > MAX_DRINK_FAILS) ? 1 : drinkFails;
}
}
else
{
int openContNr = 0;
int openContMax = reader.readOpenContainerCount();
for (contNr = 0; contNr < reader.m_memMaxContainers && openContNr < openContMax; contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
openContNr++;
CTibiaItem *item;
if (itemType)
item = CModuleUtil::lookupItem(contNr, &itemArray, itemType);
else
item = CModuleUtil::lookupItem(contNr, &itemArray);
if (item->objectId)
{
if ((self->hp < hpBelow || hpBelow == -1) && (self->mana < manaBelow || manaBelow == -1) && drink)
{
CPackSender::useItemFromContainerOnCreature(itemId, 0x40 + contNr, item->pos, self->tibiaId);
drank = 1;
drinkFails = 0;
}
delete item;
break;
}
delete item;
}
delete cont;
}
}
delete self;
return drank;
}