Example #1
0
void CIntSet::RemoveElement (int iElement)

//	RemoveElement
//
//	Removes the given element in the set

	{
	DWORD dwBucket = ((DWORD)iElement) / g_BitsPerBucket;

	//	Look for the bucket

	CIntArray *pBucket;
	if (m_Set.Lookup(dwBucket, (CObject **)&pBucket) != NOERROR)
		return;

	DWORD dwBucketBit = ((DWORD)iElement) % g_BitsPerBucket;
	DWORD dwOffset = dwBucketBit / 32;

	if ((int)dwOffset >= pBucket->GetCount())
		return;

	DWORD dwBit = dwBucketBit % 32;
	DWORD dwNewValue = ((DWORD)pBucket->GetElement(dwOffset)) & ~(1 << dwBit);
	pBucket->ReplaceElement(dwOffset, dwNewValue);
	}
Example #2
0
int CEnHeaderCtrl::GetItemWidths(CIntArray& aWidths) const
{
	int nItem = GetItemCount();
	aWidths.SetSize(nItem);

	while (nItem--)
		aWidths[nItem] = GetItemWidth(nItem);

	return aWidths.GetSize();
}
Example #3
0
int CEnHeaderCtrl::GetTrackedItems(CIntArray& aTracked) const
{
	int nItem = GetItemCount();
	aTracked.SetSize(nItem);
	
	while (nItem--)
		aTracked[nItem] = IsItemTracked(nItem);
	
	return aTracked.GetSize();
}
Example #4
0
void Disp(CIntArray array)
{
  Viss(2);

  int i;

  for(i = 0; i < array.NumOf(); i++)
    cout <<  array.Get(i) << ' ';
  cout << endl;

  Viss(3);
}
Example #5
0
BOOL CEnHeaderCtrl::SetTrackedItems(const CIntArray& aTracked)
{
	int nItem = GetItemCount();
	ASSERT(nItem == aTracked.GetSize());
	
	if (nItem != aTracked.GetSize())
		return FALSE;
	
	while (nItem--)
		SetTrackedItem(nItem, aTracked[nItem]);
	
	return TRUE;
}
Example #6
0
inline string CIntArrayToString( const CIntArray &array )
{
	CString CRet;
	char buffer[10];
	for ( size_t i = 0; i < array.size(); i++ )
	{
		CRet += itoa( array.at( i ), buffer, 10 );
		if ( i != ( array.size() - 1 ) )
			CRet += ",";
	}
	string sRet = CRet.GetBuffer();
	return sRet;
}
Example #7
0
int CEnHeaderCtrl::GetItemOrder(CIntArray& aOrder) const
{
	int nNumItems = GetItemCount();
	aOrder.SetSize(nNumItems);
	
	CEnHeaderCtrl* pThis = const_cast<CEnHeaderCtrl*>(this);
	
	if (pThis->GetOrderArray(aOrder.GetData(), nNumItems))
		return nNumItems;

	// else
	aOrder.RemoveAll();
	return 0;
}
Example #8
0
inline CIntArray StringToCIntArray( const string &str )
{
	CIntArray ret;
	CString cstr = str.c_str();
	int pos = 0;

	CString resToken;
	resToken = cstr.Tokenize( ",", pos);
	while ( resToken != "" )
	{
		ret.push_back( atoi( resToken.GetBuffer() ) );
		resToken = cstr.Tokenize( ",", pos );
	};

	return ret;
}
Example #9
0
ALERROR CIntSet::EnumElements (CIntArray *pArray) const

//	EnumElements
//
//	Fills in the given array with an enumeration of all the
//	elements in the set.

	{
	ALERROR error;

	//	Loop over all buckets

	int i;
	for (i = 0; i < m_Set.GetCount(); i++)
		{
		DWORD dwBucket = (DWORD)m_Set.GetKey(i) * (DWORD)g_BitsPerBucket;
		CIntArray *pBucket = (CIntArray *)m_Set.GetValue(i);

		//	Now look over all elements in the bucket

		int j;
		for (j = 0; j < pBucket->GetCount(); j++)
			{
			DWORD dwElement = (DWORD)pBucket->GetElement(j);

			if (dwElement != 0)
				{
				//	Iterate over all bits

				int k;
				DWORD dwTest = 1;
				for (k = 0; k < 32; k++)
					{
					if (dwElement & dwTest)
						{
						if (error = pArray->AppendElement(dwBucket + (DWORD)(j * 32 + k), NULL))
							return error;
						}

					dwTest = dwTest << 1;
					}
				}
			}
		}

	return NOERROR;
	}
Example #10
0
BOOL CEnHeaderCtrl::SetItemWidths(const CIntArray& aWidths)
{
	int nItem = GetItemCount();
	ASSERT(nItem == aWidths.GetSize());

	if (nItem != aWidths.GetSize())
		return FALSE;

	while (nItem--)
	{
		if (!SetItemWidth(nItem, aWidths[nItem], FALSE))
			return FALSE;
	}

	RecalcItemTooltipRects();
	return TRUE;
}
Example #11
0
ALERROR CIntSet::AddElement (int iElement)

//	AddElement
//
//	Adds an element to the set

	{
	ALERROR error;
	DWORD dwBucket = ((DWORD)iElement) / g_BitsPerBucket;

	//	Look for the bucket; if we don't find it, add a new one

	CIntArray *pBucket;
	if (error = m_Set.Lookup(dwBucket, (CObject **)&pBucket))
		{
		pBucket = new CIntArray;
		if (pBucket == NULL)
			return ERR_MEMORY;

		if (error = m_Set.AddEntry(dwBucket, pBucket))
			{
			delete pBucket;
			return error;
			}
		}

	//	Look for the bit in the bucket

	DWORD dwBucketBit = ((DWORD)iElement) % g_BitsPerBucket;
	DWORD dwOffset = dwBucketBit / 32;

	//	Make sure there is room in the bucket

	if ((int)dwOffset >= pBucket->GetCount())
		{
		int iOldCount = pBucket->GetCount();
		int iExpandBy = ((int)dwOffset + 1) - iOldCount;

		if (error = pBucket->ExpandArray(-1, iExpandBy))
			return error;

		for (int i = iOldCount; i < pBucket->GetCount(); i++)
			pBucket->ReplaceElement(i, 0);
		}

	//	OR-in the new element

	DWORD dwBit = dwBucketBit % 32;
	DWORD dwNewValue = ((DWORD)pBucket->GetElement(dwOffset)) | (1 << dwBit);
	pBucket->ReplaceElement(dwOffset, dwNewValue);

	return NOERROR;
	}
Example #12
0
void CManageTagsDlg::OnBnClickedManageTagsEditBtn()
{
	int lCount = m_ManageTagsList.GetSelCount() ;
	if(lCount != 1 )
		return;

	CString lTagName;
	CIntArray lSelItems;
	lSelItems.SetSize(lCount);
	m_ManageTagsList.GetSelItems(lCount, lSelItems.GetData()); 
	int lSelTagIdx = lSelItems.GetAt(0);
	m_ManageTagsList.GetText(lSelTagIdx, lTagName);
	CTagsEditTagDlg lEditTagsDlg(lTagName);
	if(lEditTagsDlg.DoModal() == IDOK)
	{
		DWORD_PTR lTagID = m_ManageTagsList.GetItemData(lSelTagIdx);
		m_ManageTagsList.DeleteString(lSelTagIdx);
		lSelTagIdx = m_ManageTagsList.AddString(lTagName);
		m_ManageTagsList.SetItemData(lSelTagIdx, lTagID);
	}
	UpdateUI();
}
Example #13
0
int CEnHeaderCtrl::GetItemPosition(int nItem, const CIntArray& aOrder)
{
	int i = aOrder.GetSize();

	while (i--)
	{
		if (aOrder[i] == nItem)
			return i;
	}

	// not found ?
	ASSERT(0);
	return -1;
}
Example #14
0
bool CIntSet::HasElement (int iElement) const

//	HasElement
//
//	Returns TRUE if the set has the given element

	{
	DWORD dwBucket = ((DWORD)iElement) / g_BitsPerBucket;

	//	Look for the bucket

	CIntArray *pBucket;
	if (m_Set.Lookup(dwBucket, (CObject **)&pBucket) != NOERROR)
		return false;

	DWORD dwBucketBit = ((DWORD)iElement) % g_BitsPerBucket;
	DWORD dwOffset = dwBucketBit / 32;

	if ((int)dwOffset >= pBucket->GetCount())
		return false;

	DWORD dwBit = dwBucketBit % 32;
	return (((DWORD)pBucket->GetElement(dwOffset)) & (1 << dwBit) ? true : false);
	}
Example #15
0
// Szabi, case 195
void CManageTagsDlg::OnBnClickedManageTagsDeleteBtn()
{
	CTTags lTags(m_pParamCDB->pDB);
	if (AfxMessageBox(_T("Are you sure you want to delete this tag?"), MB_YESNO|MB_ICONQUESTION) == IDYES)
	{
		int lCount = m_ManageTagsList.GetSelCount();
		if(lCount <= 0)
			return;

		CIntArray lListBoxSelArray;
		lListBoxSelArray.SetSize(lCount);
		m_ManageTagsList.GetSelItems(lCount, lListBoxSelArray.GetData()); 

		int lIndex;
		CString lTagStr;
		int lTagStrLen;
		int lLastIndex = -1;

		for(int i = lCount - 1; i >= 0; i--)
		{
			lIndex = lListBoxSelArray.GetAt(i);
			lTagStrLen = m_ManageTagsList.GetTextLen(lIndex);
			m_ManageTagsList.GetText(lIndex, lTagStr.GetBuffer(lTagStrLen));
			lTagStr.ReleaseBuffer();

			if(	lTags.DeleteByName(lTagStr))
				m_ManageTagsList.DeleteString(lIndex);

			if (lLastIndex == -1) lLastIndex = lIndex;
		}
		lLastIndex = (lLastIndex + 1) - lCount;
		if (lLastIndex > m_ManageTagsList.GetCount() - 1) lLastIndex = m_ManageTagsList.GetCount() - 1;
		m_ManageTagsList.SetSel(lLastIndex, TRUE);
	}
	UpdateUI();
}
Example #16
0
void CCriteria::Adjust(CIntArray& array) 
{
  switch (array.size()) 
  {
    case 1: 
    {
      array.Insert(array.at(0)); 
      break;
    }
    case 0: 
    {
      return; 
    }
    default:
    {
      break;
    }

  }

  if (!(isDefaultValue(array.at(0))) && !(isDefaultValue(array.at(1)))) 
  {
    if (array.at(0) > array.at(1))
    {
      int32_t tmp = array.at(0);
      array.ReplaceAt(array.begin(), array.at(1));
      array.ReplaceAt(array.begin() + 1, tmp);
    }
  } 
  else if ((isDefaultValue(array.at(0))) && !(isDefaultValue(array.at(1)))) 
  {
    array.ReplaceAt(array.begin(), array.at(1));
  } 
  else if (!(isDefaultValue(array.at(0))) && (isDefaultValue(array.at(1)))) 
  {
    array.ReplaceAt(array.begin() + 1 , array.at(0));
  }

}
Example #17
0
ALERROR CShieldClass::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CItemType *pType, CDeviceClass **retpShield)

//	CreateFromXML
//
//	Creates from an XML element

	{
	ALERROR error;
	CShieldClass *pShield;
	int i;

	pShield = new CShieldClass;
	if (pShield == NULL)
		return ERR_MEMORY;

	pShield->InitDeviceFromXML(Ctx, pDesc, pType);

	pShield->m_iHitPoints = pDesc->GetAttributeInteger(HIT_POINTS_ATTRIB);
	pShield->m_iArmorShield = pDesc->GetAttributeInteger(ARMOR_SHIELD_ATTRIB);
	pShield->m_iPowerUse = pDesc->GetAttributeIntegerBounded(POWER_USE_ATTRIB, 0, -1, 0);
	pShield->m_iIdlePowerUse = pDesc->GetAttributeIntegerBounded(IDLE_POWER_USE_ATTRIB, 0, -1, pShield->m_iPowerUse / 2);
	pShield->m_iExtraHPPerCharge = pDesc->GetAttributeInteger(HP_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iExtraPowerPerCharge = pDesc->GetAttributeInteger(POWER_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iExtraRegenPerCharge = pDesc->GetAttributeInteger(REGEN_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iMaxCharges = pDesc->GetAttributeInteger(MAX_CHARGES_ATTRIB);

	//	Load regen value

	int iRegen;
	if (pDesc->FindAttributeInteger(REGEN_ATTRIB, &iRegen))
		{
		//	Regen specified in hp per 180 ticks. We need to convert that to RegenHP and RegenRate
		
		if ((iRegen % 12) == 0)
			pShield->m_iRegenRate = 15;
		else if ((iRegen % 10) == 0)
			pShield->m_iRegenRate = 18;
		else if ((iRegen % 9) == 0)
			pShield->m_iRegenRate = 20;
		else if ((iRegen % 6) == 0)
			pShield->m_iRegenRate = 30;
		else if ((iRegen % 5) == 0)
			pShield->m_iRegenRate = 36;
		else if ((iRegen % 4) == 0)
			pShield->m_iRegenRate = 45;
		else if ((iRegen % 3) == 0)
			pShield->m_iRegenRate = 60;
		else
			pShield->m_iRegenRate = 90;

		pShield->m_iRegenHP = iRegen * pShield->m_iRegenRate / 180;

		int iDepletion;
		if (pDesc->FindAttributeInteger(DEPLETION_DELAY_ATTRIB, &iDepletion))
			pShield->m_iDepletionDelay = iDepletion / pShield->m_iRegenRate;
		else
			pShield->m_iDepletionDelay = 360 / pShield->m_iRegenRate;
		}
	else
		{
		pShield->m_iRegenHP = pDesc->GetAttributeInteger(REGEN_HP_ATTRIB);
		pShield->m_iRegenRate = (int)((pDesc->GetAttributeInteger(REGEN_TIME_ATTRIB) / STD_SECONDS_PER_UPDATE) + 0.5);
		pShield->m_iDepletionDelay = pDesc->GetAttributeInteger(DEPLETION_DELAY_ATTRIB);

		if (pShield->m_iRegenRate == 0)
			{
			pShield->m_iRegenRate = 15;
			pShield->m_iRegenHP = 0;
			}
		}

	//	Load damage adjustment

	pShield->m_iDamageAdjLevel = pDesc->GetAttributeIntegerBounded(DAMAGE_ADJ_LEVEL_ATTRIB, 1, MAX_ITEM_LEVEL, pType->GetLevel());
	if (error = LoadDamageAdj(pDesc, g_StdDamageAdj[pShield->m_iDamageAdjLevel - 1], pShield->m_iDamageAdj))
		return error;

	//	Load absorb adjustment; if attribute not found, assume 100% for everything

	CString sAbsorbAdj;
	if (pDesc->FindAttribute(ABSORB_ADJ_ATTRIB, &sAbsorbAdj))
		{
		CIntArray AbsorbAdj;
		if (error = ::ParseAttributeIntegerList(sAbsorbAdj, &AbsorbAdj))
			return error;

		for (i = 0; i < damageCount; i++)
			pShield->m_iAbsorbAdj[i] = (i < AbsorbAdj.GetCount() ? AbsorbAdj.GetElement(i) : 0);
		}
	else
		{
		for (i = 0; i < damageCount; i++)
			pShield->m_iAbsorbAdj[i] = 100;
		}

	//	Load the weapon suppress

	if (error = pShield->m_WeaponSuppress.InitFromXML(pDesc->GetAttribute(WEAPON_SUPPRESS_ATTRIB)))
		return error;

	//	Load reflection

	if (error = pShield->m_Reflective.InitFromXML(pDesc->GetAttribute(REFLECT_ATTRIB)))
		return error;

	//	Effects

	if (error = pShield->m_pHitEffect.LoadEffect(Ctx,
			strPatternSubst(CONSTLIT("%d:h"), pType->GetUNID()),
			pDesc->GetContentElementByTag(HIT_EFFECT_TAG),
			pDesc->GetAttribute(HIT_EFFECT_ATTRIB)))
		return error;

	//	Done

	*retpShield = pShield;

	return NOERROR;
	}
Example #18
0
BOOL CEnHeaderCtrl::SetItemOrder(const CIntArray& aOrder)
{
	return SetOrderArray(aOrder.GetSize(), (LPINT)aOrder.GetData());
}
Example #19
0
ALERROR CShieldClass::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CItemType *pType, CDeviceClass **retpShield)

//	CreateFromXML
//
//	Creates from an XML element

	{
	ALERROR error;
	CShieldClass *pShield;
	int i;

	pShield = new CShieldClass;
	if (pShield == NULL)
		return ERR_MEMORY;

	if (error = pShield->InitDeviceFromXML(Ctx, pDesc, pType))
		return error;

	pShield->m_iHitPoints = pDesc->GetAttributeInteger(HIT_POINTS_ATTRIB);
	pShield->m_iArmorShield = pDesc->GetAttributeInteger(ARMOR_SHIELD_ATTRIB);
	pShield->m_iPowerUse = pDesc->GetAttributeIntegerBounded(POWER_USE_ATTRIB, 0, -1, 0);
	pShield->m_iIdlePowerUse = pDesc->GetAttributeIntegerBounded(IDLE_POWER_USE_ATTRIB, 0, -1, pShield->m_iPowerUse / 2);
	pShield->m_iExtraHPPerCharge = pDesc->GetAttributeInteger(HP_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iExtraPowerPerCharge = pDesc->GetAttributeInteger(POWER_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iExtraRegenPerCharge = pDesc->GetAttributeInteger(REGEN_ADJ_PER_CHARGE_ATTRIB);
	pShield->m_iMaxCharges = pDesc->GetAttributeInteger(MAX_CHARGES_ATTRIB);

	//	Load regen value

	CString sRegen;
	if (pDesc->FindAttribute(REGEN_ATTRIB, &sRegen))
		{
		if (error = pShield->m_Regen.InitFromRegenString(Ctx, sRegen))
			return error;

		int iDepletion;
		if (pDesc->FindAttributeInteger(DEPLETION_DELAY_ATTRIB, &iDepletion))
			pShield->m_iDepletionTicks = Max(1, iDepletion);
		else
			pShield->m_iDepletionTicks = 360;
		}
	else
		{
		int iRegenTime = pDesc->GetAttributeInteger(REGEN_TIME_ATTRIB);

		if (error = pShield->m_Regen.InitFromRegenTimeAndHP(Ctx, iRegenTime, pDesc->GetAttributeInteger(REGEN_HP_ATTRIB)))
			return error;

		int iDepletion;
		if (pDesc->FindAttributeInteger(DEPLETION_DELAY_ATTRIB, &iDepletion))
			pShield->m_iDepletionTicks = Max(1, iDepletion * iRegenTime);
		else
			pShield->m_iDepletionTicks = 360;
		}

	//	Load damage adjustment

	pShield->m_iDamageAdjLevel = pDesc->GetAttributeIntegerBounded(DAMAGE_ADJ_LEVEL_ATTRIB, 1, MAX_ITEM_LEVEL, pType->GetLevel());
	if (error = pShield->m_DamageAdj.InitFromXML(Ctx, pDesc))
		return error;

	//	Load absorb adjustment; if attribute not found, assume 100% for everything

	CString sAbsorbAdj;
	if (pDesc->FindAttribute(ABSORB_ADJ_ATTRIB, &sAbsorbAdj))
		{
		CIntArray AbsorbAdj;
		if (error = ::ParseAttributeIntegerList(sAbsorbAdj, &AbsorbAdj))
			return error;

		for (i = 0; i < damageCount; i++)
			pShield->m_iAbsorbAdj[i] = (i < AbsorbAdj.GetCount() ? AbsorbAdj.GetElement(i) : 0);
		}
	else
		{
		for (i = 0; i < damageCount; i++)
			pShield->m_iAbsorbAdj[i] = 100;
		}

	//	Load the weapon suppress

	if (error = pShield->m_WeaponSuppress.InitFromXML(pDesc->GetAttribute(WEAPON_SUPPRESS_ATTRIB)))
		{
		Ctx.sError = CONSTLIT("Unable to load weapon suppress attribute");
		return error;
		}

	//	Load reflection

	if (error = pShield->m_Reflective.InitFromXML(pDesc->GetAttribute(REFLECT_ATTRIB)))
		{
		Ctx.sError = CONSTLIT("Unable to load reflective attribute");
		return error;
		}

	//	Effects

	if (error = pShield->m_pHitEffect.LoadEffect(Ctx,
			strPatternSubst(CONSTLIT("%d:h"), pType->GetUNID()),
			pDesc->GetContentElementByTag(HIT_EFFECT_TAG),
			pDesc->GetAttribute(HIT_EFFECT_ATTRIB)))
		return error;

	//	Done

	*retpShield = pShield;

	return NOERROR;
	}