Example #1
0
C4Effect *C4Effect::Get(const char *szName, int32_t iIndex,
                        int32_t iMaxPriority) {
  // safety
  if (!szName)
    return NULL;
  // check all effects
  C4Effect *pEff = this;
  do {
    // skip dead
    if (pEff->IsDead())
      continue;
    // skip effects with too high priority
    if (iMaxPriority && pEff->iPriority > iMaxPriority)
      continue;
    // wildcard compare name
    const char *szEffectName = pEff->Name;
    if (!SWildcardMatchEx(szEffectName, szName))
      continue;
    // effect name matches
    // check index
    if (iIndex--)
      continue;
    // effect found
    return pEff;
  } while (pEff = pEff->pNext);
  // nothing found
  return NULL;
}
int32_t C4Effect::GetCount(const char *szMask, int32_t iMaxPriority)
{
	// count all matching effects
	int32_t iCnt=0; C4Effect *pEff = this;
	do if (!pEff->IsDead())
			if (!szMask || SWildcardMatchEx(pEff->GetName(), szMask))
				if (!iMaxPriority || pEff->iPriority <= iMaxPriority)
					++iCnt;
	while ((pEff = pEff->pNext));
	// return count
	return iCnt;
}