Ejemplo n.º 1
0
void     Essence(CUIntArray& aX,CUIntArray& aY)//loai bo nhung phan tu trung nhau
{
    aY.RemoveAll();
    for(int i=0; i<aX.GetSize(); i++)
        if(FindUInt(aX[i],aY)==-1)//Neu khong tim thay
            aY.Add(aX[i]);
}
Ejemplo n.º 2
0
/*
枚举串口号
*/
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);   //所有存在的串口
	}
}
Ejemplo n.º 3
0
// ============================================================================
void CVisualMSDoc::GetSelectionSet(CUIntArray &arr)
{
	arr.RemoveAll();

	for(int i = 0; i < m_objects.GetSize(); i++)
	{
		if(IsSelected(i))
			arr.Add(i);
	}
}
Ejemplo n.º 4
0
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;
// 		}
// 	}
	ayNewColGroup.RemoveAll();

	m_bCurChanged = FALSE;
	return TRUE;
}
Ejemplo n.º 5
0
void DVControllerTests::TestInitialiseSaveAsDlgData_DocTypeEffect()
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());

	CStdString sSaveFilters;
	int iFormatCount=0;

	CMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, AfxGetMainWnd());
	CChildFrame *pFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );
	assertTest( pFrame );
	
	CUIntArray aFormats;
	LONG lFormatIndex	= 1;
	LONG lCurrentSaveFormatID = -7;
	LONG lSaveFormatIDDefault = GetApp()->GetDVController(pFrame)->GetComparisonDocController().GetSaveFormatAsDVCode();
//for rtf
	LONG lFlags = 0;
	lFlags |= WSDOCUMENTPROVIDERLib::DF_NEW_DOCUMENT;
	if (lSaveFormatIDDefault !=6)
	{
		lSaveFormatIDDefault=6; //for test rtf
	}
	
	bool origFileFormatValue = Workshare::OptionApi::GetBool(L"AllowFileFormatChange");
	bool origExtSaveFormats = Workshare::OptionApi::GetBool(L"EnableExtendedFileFormats");
	try
	{
		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", false);

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docNew);
		int iCount = (x64_int_cast)aFormats.GetSize();
		assertTest(iCount==1);
		CStdString sFormat = _T("Rich Text Format ( *.rtf)|*.rtf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docAttachToModified);
		iCount = (x64_int_cast)aFormats.GetSize();
		assertTest(iCount==1);
		sFormat = _T("Rich Text Format ( *.rtf)|*.rtf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", true);

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docVersionOfOriginal);
		iCount =(x64_int_cast) aFormats.GetSize();
		assertTest(iCount==1);
		sFormat = _T("Adobe Acrobat File ( *.pdf)|*.pdf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", true);
		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", false);
		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docNew);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docAttachToModified);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docVersionOfOriginal);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  
	}
	catch(...)
	{
		_ASSERTE(!_T("Catch ... How did we get here?"));
		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", origFileFormatValue);
		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", origExtSaveFormats);
		throw;
	}
	Workshare::OptionApi::SetBool(L"AllowFileFormatChange", origFileFormatValue);
	Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", origExtSaveFormats);
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
void CGelView::OnRungel() 
{
	// TODO: Add your control notification handler code here
	CGenedocDoc *pDoc = GetDocument();

//	MakeGel(m_listSequences, m_listEnzymes);
//	pDoc->SetModifiedFlag();

	// CListBox
	int iSeqCount, iEnzCount;

	iSeqCount = m_listSequences.GetSelCount();
	iEnzCount = m_listEnzymes.GetSelCount();

	if ( iSeqCount < 1 || iEnzCount < 1 ) {
		return;
	}

	BeginWaitCursor();

	int *arrSeq = new int[iSeqCount];
	int *arrEnz = new int[iEnzCount];

	m_listSequences.GetSelItems( iSeqCount, arrSeq );
	m_listEnzymes.GetSelItems( iEnzCount, arrEnz );


	POSITION sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		delete (SGel*)m_listGel.GetNext(sPos);
	}
	m_listGel.RemoveAll();

	int s, e;

	for ( s=0; s < iSeqCount; ++s ) {
		POSITION aPos = pDoc->pGSFiller->SegDataList.FindIndex( arrSeq[s] + 2 );
		CGeneSegment *tCGSeg = (CGeneSegment *)pDoc->pGSFiller->SegDataList.GetAt(aPos);

		GeneStor *pGS = (GeneStor *)GlobalLock( tCGSeg->GetTextHandle() );
		// CList
		NewBand(tCGSeg);
		for ( e=0; e < iEnzCount; ++e ) {
			POSITION ePos =  pDoc->m_UserVars.listSearch.FindIndex( arrEnz[e] );
			stcSearch *Enzyme = (stcSearch *)pDoc->m_UserVars.listSearch.GetAt(ePos);

			SearchRebaseGel( Enzyme, pGS, tCGSeg->GetTextLength() );

		}
		GlobalUnlock( tCGSeg->GetTextHandle() );
	}


	CUIntArray arrFrags;

	DWORD MaxLength = 0;
	sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		SGel *pSGel = (SGel *)m_listGel.GetNext(sPos);
		DWORD iLen = pSGel->Sequence->GetLastResidue();
		if ( iLen > MaxLength ) MaxLength = iLen;
	}

	SetYScale ( 0, MaxLength );

	sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		SGel *pSGel = (SGel *)m_listGel.GetNext(sPos);

		int iArr = pSGel->arrCutLoc.GetSize();
		// This code sorts the cut locations
		for ( int ti=0; ti < iArr - 1; ++ti ) {
			for ( int tj=0; tj < iArr - 1; ++tj ) {
				if ( pSGel->arrCutLoc[tj] > pSGel->arrCutLoc[tj+1] ) {
					int t = pSGel->arrCutLoc[tj];
					pSGel->arrCutLoc[tj] = pSGel->arrCutLoc[tj+1];
					pSGel->arrCutLoc[tj+1] = t;
				}
			}
		}
		// Calculate Fragment lengths ..
		DWORD LastCutLoc = 0;
		int i;
		for ( i=0; i < iArr; ++i ) {
			if ( pSGel->arrCutLoc[i] == LastCutLoc ) continue;
			int cl = pSGel->arrCutLoc[i] - LastCutLoc;
			arrFrags.Add( cl );
			LastCutLoc = pSGel->arrCutLoc[i];
		}
		arrFrags.Add( pSGel->Sequence->GetLastResidue() - LastCutLoc );

		// This code sorts the fragment lengths in case that is useful.
//		for ( ti=0; ti < arrFrags.GetSize() - 1; ++ti ) {
//			for ( int tj=0; tj < arrFrags.GetSize()-1; ++tj ) {
//				if ( arrFrags[tj] > arrFrags[tj+1] ) {
//					int t = arrFrags[tj];
//					arrFrags[tj] = arrFrags[tj+1];
//					arrFrags[tj+1] = t;
//				}
//			}
//		}

		iArr = arrFrags.GetSize();
		for ( i=0; i < iArr; ++i ) {
			int iFragLength = arrFrags[i];
			// Normalize fragments to 0 to 1.0
//			double GelLocPerc = 1.0 - (log((double)iFragLength) / log((double)MaxLength));
//			double GelLocPerc = 1.0 - ((double)iFragLength / (double)MaxLength);
			DWORD GelLocPerc = (DWORD)(((double)iFragLength / (double)MaxLength) * 100000000.0);
			// Put Normalized resuls into array for GelObject to draw.
			pSGel->arrGelLoc.Add(GelLocPerc);
		}

		arrFrags.RemoveAll();
	}


	delete arrSeq;
	delete arrEnz;

	EndWaitCursor();
	
	Invalidate();

}
Ejemplo n.º 8
0
void EnumerateSerialPorts(CUIntArray& ports)
{
  //Make sure we clear out any elements which may already be in the array
  ports.RemoveAll();

  //Determine what OS we are running on
  OSVERSIONINFO osvi;
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  BOOL bGetVer = GetVersionEx(&osvi);

  //On NT use the QueryDosDevice API
  if (bGetVer && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))
  {
    //Use QueryDosDevice to look for all devices of the form COMx. This is a better
    //solution as it means that no ports have to be opened at all.
    TCHAR szDevices[65535];
    DWORD dwChars = QueryDosDevice(NULL, szDevices, 65535);
    if (dwChars)
    {
      int i=0;

      for (;;)
      {
        //Get the current device name
        TCHAR* pszCurrentDevice = &szDevices[i];

        //If it looks like "COMX" then
        //add it to the array which will be returned
        int nLen = _tcslen(pszCurrentDevice);
        if (nLen > 3 && _tcsnicmp(pszCurrentDevice, _T("COM"), 3) == 0)
        {
          //Work out the port number
          int nPort = _ttoi(&pszCurrentDevice[3]);
          ports.Add(nPort);
        }

        // Go to next NULL character
        while(szDevices[i] != _T('\0'))
          i++;

        // Bump pointer to the next string
        i++;

        // The list is double-NULL terminated, so if the character is
        // now NULL, we're at the end
        if (szDevices[i] == _T('\0'))
          break;
      }
    }
    else
      TRACE(_T("Failed in call to QueryDosDevice, GetLastError:%d\n"), GetLastError());
  }
  else
  {
    //On 95/98 open up each port to determine their existence

    //Up to 255 COM ports are supported so we iterate through all of them seeing
    //if we can open them or if we fail to open them, get an access denied or general error error.
    //Both of these cases indicate that there is a COM port at that number. 
    for (UINT i=1; i<256; 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();

        //Check to see if the error was because some other app had the port open or a general failure
        if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE)
          bSuccess = TRUE;
      }
      else
      {
        //The port was opened successfully
        bSuccess = TRUE;

        //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);
    }
  }
}
Ejemplo n.º 9
0
 CPage& CPage::operator=(const CPage& ss){ Line.RemoveAll();	return *this;}
Ejemplo n.º 10
0
DWORD WINAPI toolThreadProc(LPVOID lpParam)
{
	CConfigData *config = (CConfigData *)lpParam;
	CMemReader& reader = CMemReader::getMemReader();

	
	
	CUIntArray acceptedItems;
	int uhFallbackNeeded    = 0;
	int grpUhFallbackNeeded = 0;
	int i;

	while (!toolThreadShouldStop)
	{
		Sleep(200);
		if (!reader.isLoggedIn())
			continue;                   // do not proceed if not connected

		CTibiaCharacter *self = reader.readSelfCharacter();

		if (self->hp <= config->m_uhBorderline || config->m_hotkeySelf)
		{
			int uhContainer;

			acceptedItems.RemoveAll();
			if (!uhFallbackNeeded)
			{
				switch (config->m_runetype)
				{
				case 0:
					acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
					break;
				case 1:
					acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
					break;
				}
			}
			else
			{
				acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
				acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
				uhFallbackNeeded = 0;
			}

			CTibiaItem *uhItem = new CTibiaItem();
			uhContainer = -1;

			int contNr;
			int openContNr  = 0;
			int openContMax = reader.readOpenContainerCount();
			for (contNr = 0; contNr < reader.m_memMaxContainers && !uhItem->objectId && openContNr < openContMax; contNr++)
			{
				CTibiaContainer *cont = reader.readContainer(contNr);

				if (cont->flagOnOff)
				{
					openContNr++;
					delete uhItem;
					uhItem      = CModuleUtil::lookupItem(contNr, &acceptedItems);
					uhContainer = contNr;
				};

				delete cont;
			}


			if (uhItem->objectId)
			{
				CVariableStore::setVariable("UH_needed", "true");
				if (self->hp <= config->m_uhBorderline)
				{
					CPackSender::useWithObjectFromContainerOnFloor(
					        uhItem->objectId, 0x40 + uhContainer, uhItem->pos, 0x63,
					        self->x, self->y, self->z);
					Sleep(config->m_sleepAfter);
				}
				if (config->m_hotkeySelf)
				{
					CPackSender::useWithObjectFromContainerOnFloor(
					        uhItem->objectId, 0x40 + uhContainer, uhItem->pos, 0x63,
					        self->x, self->y, self->z, 105);
				}
			}
			else
			{
				if (config->m_fallback)
					uhFallbackNeeded = 1;
			}
			delete uhItem;
		}
		else
		{
			CVariableStore::setVariable("UH_needed", "false");
		}


		// grp heal

		int crNr;
		for (crNr = 0; crNr < reader.m_memMaxCreatures; crNr++)
		{
			CTibiaCharacter *ch = reader.readVisibleCreature(crNr);
			if (ch->tibiaId == 0)
			{
				delete ch;
				break;
			}
			if (ch->visible)
			{
				char chName[128];
				memset(chName, 0, 128);
				memcpy(chName, ch->name, strlen(ch->name));

				int chToHeal = 0;


				for (i = 0; i < config->m_grpMemberCount; i++)
				{
					if (!_strcmpi(config->m_grpMemberList[i], chName))

						chToHeal = 1;
				}
				if (chToHeal && ch->hpPercLeft < config->m_grpBorderline && self->z == ch->z)
				{
					CTibiaItem *uhItem = new CTibiaItem();
					int uhContainer    = -1;

					acceptedItems.RemoveAll();
					if (!grpUhFallbackNeeded)
					{
						switch (config->m_grpRunetype)
						{
						case 0:
							acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
							break;
						case 1:
							acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
							break;
						}
					}
					else
					{
						acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
						acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
						grpUhFallbackNeeded = 0;
					}

					int contNr;
					int openContNr  = 0;
					int openContMax = reader.readOpenContainerCount();
					for (contNr = 0; contNr < reader.m_memMaxContainers && !uhItem->objectId && openContNr < openContMax; contNr++)
					{
						CTibiaContainer *cont = reader.readContainer(contNr);

						if (cont->flagOnOff)
						{
							openContNr++;
							delete uhItem;
							uhItem      = CModuleUtil::lookupItem(contNr, &acceptedItems);
							uhContainer = contNr;
						};

						delete cont;
					}

					if (uhItem->objectId)
					{
						CPackSender::useWithObjectFromContainerOnFloor(
						        uhItem->objectId, 0x40 + uhContainer, uhItem->pos, 0x63,
						        ch->x, ch->y, ch->z);
						Sleep(config->m_sleepAfter);
					}
					else
					{
						if (config->m_grpFallback)
							grpUhFallbackNeeded = 1;
					}
					delete uhItem;
				}
			}

			delete ch;
		}

		delete self;
	}
	CVariableStore::setVariable("UH_needed", "false");
	toolThreadShouldStop = 0;
	return 0;
}