Exemplo n.º 1
0
QVariant ParameterFileModel::data(const QModelIndex& ind, int role) const {
	// mapper to convert parameter.type into QVariant::Type
	const VarTypeMap& mapper = VarTypeMap::instance();
	int row = ind.row();
	int col = ind.column();
	QString key = _keys[row];
	QString val;
	QVariant res;

	switch (role) {

	case Qt::EditRole:
	case Qt::DisplayRole:
		if ((row >= 0) && (row < _keys.size())) {
			switch (col) {
			case 0:
				// parameter name (without prefix)
				if (!_prefix.isEmpty())
					key.remove(0, _prefix.length());

				// remove dot after valid prefix
				if (key[0] == '.')
					key.remove(0, 1);
				return key;

			case 1:
				if (_parameterFile->isSet(_keys[row])) {
					val = _parameterFile->get(_keys[row]);
				}
				else if (_onlyParams) {
					val = getDefault(_keys[row]);
				}

				// handle parameter links
				if (val.startsWith('@')) {
					QString ref = val.mid(1);
					if(_parameterFile->isSet(ref)) {
						val = _parameterFile->get(ref);
					}
					else if(role == Qt::DisplayRole) {
						val = tr("[invalid reference to %1]").arg(ref);
					}
				}

				// handle QVariant type
				res = val;
				if (_useMetaInfo && isParameter(key)) {
					QString typestring = getType(key);
					QVariant::Type type = mapper[typestring];
					Q_ASSERT(res.canConvert(type));
					res.convert(type);
				}
				return res;

			case 2:
				if (role == Qt::DisplayRole) {
					return QVariant();
				}
				return getValue(key + ".editorpriority").toUInt();
			}
		}
		break;

	case Qt::ToolTipRole:
		if (_useMetaInfo) {
			QString ret = _metaInfos->getDocString(key, getClass(key));
			return ret.isEmpty() ? QVariant() : ret;
		}
		break;

	case Qt::ForegroundRole:
		if (_onlyParams && !isSet(key)) {
			return QColor(Qt::lightGray);
		}
		break;

	case Qt::BackgroundRole:
		switch (getValue(key+".editorpriority").toInt()) {
		case 1:
			return QColor("#8f8");
		case 2:
			return QColor("#ff8");
		case 3:
			return QColor("#f80");
		default:
			break;
		}
		break;

	case Qt::CheckStateRole:
		if (_useMetaInfo && col == 1 &&
				isParameter(key) && getType(key) == "bool") {
			const bool& checked = isSet(key) ?
					QVariant(getValue(key)).toBool() :
					QVariant(getDefault(key)).toBool();
			return checked ? Qt::Checked : Qt::Unchecked;
		}
		break;

	case Qt::StatusTipRole:
		if(col == 1) {
			if (isSet(key)) {
				QString ret = getValue(key);
				if(ret.startsWith('@')) {
					return tr("link to: %1").arg(ret.mid(1));
				}
			}
		}
		break;

	case Qt::DecorationRole:
		if(col == 1) {
			if (isSet(key)) {
				QString ret = getValue(key);
				if(ret.startsWith('@')) {
					return QIcon(":/icons/symlink.png");
				}
			}
		}
		break;

	} // role switch

	return QVariant();
}
Exemplo n.º 2
0
AOSContext::ReturnCode AOSModule_Wiki_ViewFromFileSystem::execute(AOSContext& context, const AXmlElement& moduleParams)
{
    //a_Get base path
    AString basePath;
    if (!moduleParams.emitString(AOS_Wiki_Constants::PARAM_BASE_PATH, basePath))
    {
        context.addError(getClass(), ASWNL("Unable to find module/base-path parameter"));
        return AOSContext::RETURN_ERROR;
    }
    AFilename wikifile(m_Services.useConfiguration().getAosBaseDataDirectory());
    wikifile.join(basePath, true);

    //a_Get relative wiki path
    AString str;
    context.useRequestParameterPairs().get(ASW("wikipath",8), str);
    wikifile.join(str, false);

    u4 type = AFileSystem::getType(wikifile);
    //a_Directory only will get default index.html
    if (type & AFileSystem::Directory)
    {
        //a_Directory name specified
        wikifile.useFilename().assign(ASW("index.html",10));
    }
    else
        wikifile.setExtension(ASW(".html",5));

    AString strData;
    if (context.useRequestParameterPairs().get(ASW("wiki.newdata",12), strData))
    {
        //a_Check if authentication passed
        if (
            moduleParams.exists(AOS_Wiki_Constants::PARAM_SECURE)
            && !context.useModel().exists(ASW("wiki/Authenticated",18))
        )
        {
            context.useModel().overwriteElement(ASW("wiki/AuthFailed",15));
            return AOSContext::RETURN_OK;
        }

        //a_New data submitted
        u4 type = AFileSystem::getType(wikifile);
        if (AFileSystem::DoesNotExist != type)
        {
            //a_New data submitted, old file exists
            AFilename newwikifile(wikifile);

            //a_Temporary filename to use during the swap
            AFilename tempwikifile(newwikifile);
            tempwikifile.setExtension(ASW("_temporary_rename_",19));

            //a_Generate temporary filename
            AFileSystem::generateTemporaryFilename(newwikifile);

            //a_Save new data to temp filename
            AFile_Physical file(newwikifile, "wb");
            file.open();
            file.write(strData);
            file.close();

            //a_Add to context so it can ve viewed after save
            context.useModel().overwriteElement(AOS_Wiki_Constants::ELEMENT_DATA).addData(strData, AXmlElement::ENC_CDATADIRECT);

            //a_Rename temp to current
            AFileSystem::rename(wikifile, tempwikifile);
            AFileSystem::rename(newwikifile, wikifile);
            AFileSystem::remove(tempwikifile);
        }
        else
        {
            //a_Does not exist yet
            //a_Make sure directories exist
            AFileSystem::createDirectories(wikifile);

            //a_Save new data
            AFile_Physical file(wikifile, "wb");
            file.open();
            file.write(strData);
            file.close();

            //a_Add to context so it can ve viewed after save
            context.useModel().overwriteElement(AOS_Wiki_Constants::ELEMENT_DATA).addData(strData, AXmlElement::ENC_CDATADIRECT);
        }
    }
    else
    {
        u4 type = AFileSystem::getType(wikifile);
        if (AFileSystem::DoesNotExist != type)
        {
            AFile_Physical file(wikifile);
            file.open();
            context.useModel().overwriteElement(AOS_Wiki_Constants::ELEMENT_DATA).addData(file, AXmlElement::ENC_CDATADIRECT);
        }
        else
        {
            //a_Signal that the wiki file does not exist
            context.useModel().overwriteElement(AOS_Wiki_Constants::ELEMENT_DOES_NOT_EXIST);
        }

        if (moduleParams.exists(AOS_Wiki_Constants::PARAM_SECURE))
        {
            context.useModel().overwriteElement(AOS_Wiki_Constants::ELEMENT_SECURE_EDIT);
        }

    }

    return AOSContext::RETURN_OK;
}
Exemplo n.º 3
0
void Player::UpdateAttackPowerAndDamage(bool ranged)
{
    float val2 = 0.0f;
    float level = float(getLevel());

    UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;

    uint16 index = UNIT_FIELD_ATTACK_POWER;
    uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
    uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;

    if (ranged)
    {
        index = UNIT_FIELD_RANGED_ATTACK_POWER;
        index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
        index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;

        switch (getClass())
        {
        case CLASS_HUNTER:
            val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f;
            break;
        case CLASS_ROGUE:
            val2 = level        + GetStat(STAT_AGILITY) - 10.0f;
            break;
        case CLASS_WARRIOR:
            val2 = level        + GetStat(STAT_AGILITY) - 10.0f;
            break;
        case CLASS_DRUID:
            switch (GetShapeshiftForm())
            {
            case FORM_CAT:
            case FORM_BEAR:
            case FORM_DIREBEAR:
                val2 = 0.0f;
                break;
            default:
                val2 = GetStat(STAT_AGILITY) - 10.0f;
                break;
            }
            break;
        default:
            val2 = GetStat(STAT_AGILITY) - 10.0f;
            break;
        }
    }
    else
    {
        switch (getClass())
        {
        case CLASS_WARRIOR:
            val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f                  - 20.0f;
            break;
        case CLASS_PALADIN:
            val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f                  - 20.0f;
            break;
        case CLASS_DEATH_KNIGHT:
            val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f                  - 20.0f;
            break;
        case CLASS_ROGUE:
            val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
            break;
        case CLASS_HUNTER:
            val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
            break;
        case CLASS_SHAMAN:
            val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f;
            break;
        case CLASS_DRUID:
        {
            ShapeshiftForm form = GetShapeshiftForm();
            // Check if Predatory Strikes is skilled
            float mLevelMult = 0.0f;
            switch (form)
            {
            case FORM_CAT:
            case FORM_BEAR:
            case FORM_DIREBEAR:
            case FORM_MOONKIN:
            {
                Unit::AuraEffectList const& mDummy = GetAuraEffectsByType(SPELL_AURA_DUMMY);
                for (Unit::AuraEffectList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
                {
                    // Predatory Strikes (effect 0)
                    if ((*itr)->GetEffIndex() == 0 && (*itr)->GetSpellProto()->SpellIconID == 1563)
                    {
                        mLevelMult = CalculatePctN(1.0f, (*itr)->GetAmount());
                        break;
                    }
                }
                break;
            }
            default:
                break;
            }

            switch (form)
            {
            case FORM_CAT:
                val2 = getLevel() * (mLevelMult + 2.0f) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + m_baseFeralAP;
                break;
            case FORM_BEAR:
            case FORM_DIREBEAR:
                val2 = getLevel() * (mLevelMult + 3.0f) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
                break;
            case FORM_MOONKIN:
                val2 = getLevel() * (mLevelMult + 1.5f) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
                break;
            default:
                val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
                break;
            }
            break;
        }
        case CLASS_MAGE:
            val2 =              GetStat(STAT_STRENGTH)                         - 10.0f;
            break;
        case CLASS_PRIEST:
            val2 =              GetStat(STAT_STRENGTH)                         - 10.0f;
            break;
        case CLASS_WARLOCK:
            val2 =              GetStat(STAT_STRENGTH)                         - 10.0f;
            break;
        }
    }

    SetModifierValue(unitMod, BASE_VALUE, val2);

    float base_attPower  = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
    float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);

    //add dynamic flat mods
    if (ranged)
    {
        if ((getClassMask() & CLASSMASK_WAND_USERS) == 0)
        {
            AuraEffectList const& mRAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
            for (AuraEffectList::const_iterator i = mRAPbyStat.begin(); i != mRAPbyStat.end(); ++i)
                attPowerMod += CalculatePctN(GetStat(Stats((*i)->GetMiscValue())), (*i)->GetAmount());
        }
    }
    else
    {
        AuraEffectList const& mAPbyStat = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
        for (AuraEffectList::const_iterator i = mAPbyStat.begin(); i != mAPbyStat.end(); ++i)
            attPowerMod += CalculatePctN(GetStat(Stats((*i)->GetMiscValue())), (*i)->GetAmount());

        AuraEffectList const& mAPbyArmor = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
        for (AuraEffectList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter)
            // always: ((*i)->GetModifier()->m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
            attPowerMod += int32(GetArmor() / (*iter)->GetAmount());
    }

    float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;

    SetInt32Value(index, (uint32)base_attPower);            //UNIT_FIELD_(RANGED)_ATTACK_POWER field
    SetInt32Value(index_mod, (uint32)attPowerMod);          //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
    SetFloatValue(index_mult, attPowerMultiplier);          //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field

    Pet *pet = GetPet();                                //update pet's AP
    //automatically update weapon damage after attack power modification
    if (ranged)
    {
        UpdateDamagePhysical(RANGED_ATTACK);
        if (pet && pet->isHunterPet()) // At ranged attack change for hunter pet
            pet->UpdateAttackPowerAndDamage();
    }
    else
    {
        UpdateDamagePhysical(BASE_ATTACK);
        if (CanDualWield() && haveOffhandWeapon())           //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
            UpdateDamagePhysical(OFF_ATTACK);
        if (getClass() == CLASS_SHAMAN || getClass() == CLASS_PALADIN)                      // mental quickness
            UpdateSpellDamageAndHealingBonus();

        if (pet && pet->IsPetGhoul()) // At ranged attack change for hunter pet
            pet->UpdateAttackPowerAndDamage();
    }
}
Exemplo n.º 4
0
bool Player::UpdateAllStats()
{
    for (int8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
    {
        float value = GetTotalStatValue(Stats(i));
        SetStat(Stats(i), int32(value));
    }

    UpdateArmor();
    // calls UpdateAttackPowerAndDamage() in UpdateArmor for SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR
    UpdateAttackPowerAndDamage(true);
    UpdateMaxHealth();

    for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
        UpdateMaxPower(Powers(i));

    // Custom MoP script
    // Jab Override Driver
    if (GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_MONK)
    {
        Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);

        if (mainItem && mainItem->GetTemplate()->Class == ITEM_CLASS_WEAPON && !HasAura(125660))
        {
            RemoveAura(108561); // 2H Staff Override
            RemoveAura(115697); // 2H Polearm Override
            RemoveAura(115689); // D/W Axes
            RemoveAura(115694); // D/W Maces
            RemoveAura(115696); // D/W Swords

            switch (mainItem->GetTemplate()->SubClass)
            {
                case ITEM_SUBCLASS_WEAPON_STAFF:
                    CastSpell(this, 108561, true);
                    break;
                case ITEM_SUBCLASS_WEAPON_POLEARM:
                    CastSpell(this, 115697, true);
                    break;
                case ITEM_SUBCLASS_WEAPON_AXE:
                    CastSpell(this, 115689, true);
                    break;
                case ITEM_SUBCLASS_WEAPON_MACE:
                    CastSpell(this, 115694, true);
                    break;
                case ITEM_SUBCLASS_WEAPON_SWORD:
                    CastSpell(this, 115696, true);
                    break;
                default:
                    break;
            }
        }
        else if (HasAura(125660))
        {
            RemoveAura(108561); // 2H Staff Override
            RemoveAura(115697); // 2H Polearm Override
            RemoveAura(115689); // D/W Axes
            RemoveAura(115694); // D/W Maces
            RemoveAura(115696); // D/W Swords
        }
    }

    UpdateAllRatings();
    UpdateAllCritPercentages();
    UpdateAllSpellCritChances();
    UpdateBlockPercentage();
    UpdateParryPercentage();
    UpdateDodgePercentage();
    UpdateSpellDamageAndHealingBonus();
    UpdateManaRegen();
    UpdateExpertise(BASE_ATTACK);
    UpdateExpertise(OFF_ATTACK);
    UpdateExpertise(RANGED_ATTACK);
    for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
        UpdateResistances(i);

    return true;
}
Exemplo n.º 5
0
void Player::UpdateParryPercentage()
{
    // Table for base parry values
    const int parry_base[MAX_CLASSES] =
    {
        3, // Warrior
        3, // Paladin
        0, // Hunter
        3, // Rogue
        0, // Priest
        3, // DK
        0, // Shaman
        0, // Mage
        0, // Warlock
        3, // Monk
        0  // Druid
    };

    const float parry_cap[MAX_CLASSES] =
    {
        237.186f,       // Warrior
        237.186f,       // Paladin
        0.0f,           // Hunter
        90.6424f,       // Rogue
        0.0f,           // Priest
        237.186f,       // DK
        0.0f,           // Shaman
        0.0f,           // Mage
        0.0f,           // Warlock
        90.6424f,       // Monk
        0.0f            // Druid
    };

    // No parry
    float value = 0.0f;
    uint32 pclass = getClass()-1;
    if (CanParry() && parry_cap[pclass] > 0.0f)
    {
        float nondiminishing = parry_base[pclass];
        // Parry from rating
        float diminishing = GetRatingBonusValue(CR_PARRY);
        // TODO: research if talents/effects that increase total parry by x% should increase non-diminishing part
        float base_strength = GetCreateStat(STAT_STRENGTH) * m_auraModifiersGroup[UNIT_MOD_STAT_START + STAT_STRENGTH][BASE_PCT];
        float bonus_strength = GetTotalStatValue(STAT_STRENGTH) - base_strength;
        float perc_cap = sObjectMgr->GetParryCapForClassLevel(pclass * GT_MAX_LEVEL + getLevel() - 1);

        // calculate diminishing (green in char screen) and non-diminishing (white) contribution
        diminishing += (bonus_strength / perc_cap) / ((bonus_strength / perc_cap) / parry_cap[pclass] + m_diminishing_k[pclass]);
        nondiminishing += base_strength / perc_cap;
        // Parry from SPELL_AURA_MOD_PARRY_PERCENT aura
        nondiminishing += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT);
        // apply diminishing formula to diminishing parry chance
        value = nondiminishing + diminishing;

        if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE))
            value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) : value;

        value = value < 0.0f ? 0.0f : value;
    }
    SetStatFloatValue(PLAYER_PARRY_PERCENTAGE, value);
}
Exemplo n.º 6
0
void Player::UpdateAttackPowerAndDamage(bool ranged )
{
    float val2 = 0.0f;
    float level = float(getLevel());

    UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;

    uint16 index = UNIT_FIELD_ATTACK_POWER;
    uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
    uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;

    if(ranged)
    {
        index = UNIT_FIELD_RANGED_ATTACK_POWER;
        index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
        index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;

        switch(getClass())
        {
            case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_ROGUE:  val2 = level        + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_WARRIOR:val2 = level        + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_DRUID:
                switch(m_form)
                {
                    case FORM_CAT:
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                        val2 = 0.0f; break;
                    default:
                        val2 = GetStat(STAT_AGILITY) - 10.0f; break;
                }
                break;
            default: val2 = GetStat(STAT_AGILITY) - 10.0f; break;
        }
    }
    else
    {
        switch(getClass())
        {
            case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_ROGUE:   val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
            case CLASS_HUNTER:  val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
            case CLASS_SHAMAN:  val2 = level*2.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_DRUID:
            {
                //Check if Predatory Strikes is skilled
                float mLevelMult = 0.0;
                switch(m_form)
                {
                    case FORM_CAT:
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                    case FORM_MOONKIN:
                    {
                        Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY);
                        for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
                        {
                            // Predatory Strikes
                            if ((*itr)->GetSpellProto()->SpellIconID == 1563)
                            {
                                mLevelMult = (*itr)->GetModifier()->m_amount / 100.0f;
                                break;
                            }
                        }
                        break;
                    }
                }

                switch(m_form)
                {
                    case FORM_CAT:
                        val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f; break;
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                        val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
                    case FORM_MOONKIN:
                        val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
                    default:
                        val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
                }
                break;
            }
            case CLASS_MAGE:    val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
            case CLASS_PRIEST:  val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
            case CLASS_WARLOCK: val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
        }
    }

    SetModifierValue(unitMod, BASE_VALUE, val2);

    float base_attPower  = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
    float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);

    //add dynamic flat mods
    if( ranged && (getClassMask() & CLASSMASK_WAND_USERS)==0)
    {
        AuraList const& mRAPbyIntellect = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
        for(AuraList::const_iterator i = mRAPbyIntellect.begin();i != mRAPbyIntellect.end(); ++i)
            attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount * (*i)->m_stackAmount / 100.0f);
    }

    float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;

    SetUInt32Value(index, (uint32)base_attPower);           //UNIT_FIELD_(RANGED)_ATTACK_POWER field
    SetUInt32Value(index_mod, (uint32)attPowerMod);         //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
    SetFloatValue(index_mult, attPowerMultiplier);          //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field

    //automatically update weapon damage after attack power modification
    if(ranged)
    {
        UpdateDamagePhysical(RANGED_ATTACK);

        Pet *pet = GetPet();                                //update pet's AP
        if(pet)
            pet->UpdateAttackPowerAndDamage();
    }
    else
    {
        UpdateDamagePhysical(BASE_ATTACK);
        if(CanDualWield() && haveOffhandWeapon())           //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
            UpdateDamagePhysical(OFF_ATTACK);
    }
}
Exemplo n.º 7
0
void CPlayer::CreatePet(uint32 entry, bool classcheck)
{
    if (classcheck && getClass() != CLASS_HUNTER)
        return;

    CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(entry);
    if (!cinfo)
    {
        BoxChat << MSG_COLOR_WHITE << " This pet doesn't exist in our database. Please report that creature " << entry << " is missing." << std::endl;
        return;
    }

    CreatureCreatePos pos(GetSession()->GetPlayer(), GetOrientation());

    Creature* pCreature = new Creature;

    // used guids from specially reserved range (can be 0 if no free values)
    uint32 lowguid = sObjectMgr.GenerateStaticCreatureLowGuid();
    if (!lowguid)
        return;

    if (!pCreature->Create(lowguid, pos, cinfo))
    {
        delete pCreature;
        return;
    }

    //--------------------------------------------------

    if (GetPetGuid())
        UnsummonPetTemporaryIfAny();

    Pet* pet = new Pet(HUNTER_PET);

    if (!pet->CreateBaseAtCreature(pCreature))
    {
        delete pet;
        return;
    }

    pet->SetOwnerGuid(GetObjectGuid());
    pet->SetCreatorGuid(GetObjectGuid());
    pet->setFaction(getFaction());
    pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, 13481);

    if (IsPvP())
        pet->SetPvP(true);

    if (!pet->InitStatsForLevel(pCreature->getLevel()))
    {
        sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!", pCreature->GetEntry());
        delete pet;
        return;
    }

    pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
    // this enables pet details window (Shift+P)
    pet->AIM_Initialize();
    pet->InitPetCreateSpells();
    pet->SetHealth(pet->GetMaxHealth());

    // add to world
    pet->GetMap()->Add((Creature*)pet);

    // visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, 70);

    for (auto x = 0; x < 6; x++)
    {
        pet->SetPower(POWER_HAPPINESS, 66600000);
        pet->ModifyLoyalty(150000);
        pet->TickLoyaltyChange();
        pet->SetTP(350);
    }

    // caster have pet now
    SetPet(pet);

    pet->SavePetToDB(PET_SAVE_AS_CURRENT);
    PetSpellInitialize();
    pet->learnSpell(27052);
    pet->learnSpell(35698);
    pet->learnSpell(25076);
    pet->learnSpell(27048);
    pet->learnSpell(27053);
    pet->learnSpell(27054);
    pet->learnSpell(27062);
    pet->learnSpell(27047);
    pet->learnSpell(24551);
    delete pCreature;
}
Exemplo n.º 8
0
 jbool JObject::equals(JObject* o){
     if (o==NULL || getClass()!=o->getClass()){
         return false;
     }
     return this==o;
 }
// This is only called from SimpleResponseHandler.deliver() but lives in this
// class because all asyncronous response must have a "response" pointer
// to go through. Only operation classes have a response pointer
void OperationResponseHandler::send(Boolean isComplete)
{
	// some handlers do not send async because their callers cannot handle
	// partial responses. If this is the case, stop here.

	if (isAsync() == false)
	{
		// preserve tradional behavior
		if (isComplete == true)
        {
            transfer();
        }

        return;
	}

	SimpleResponseHandler *simpleP = dynamic_cast<SimpleResponseHandler*>(this);

	// It is possible to instantiate this class directly (not derived)
	// The caller would do this only if the operation does not have any data to
	// be returned

	if (! simpleP)
	{
		// if there is no data to be returned, then the message should NEVER be
		// incomplete (even on an error)
		if (isComplete == false)
        {
            PEGASUS_ASSERT(false);
        }

        return;
	}

	SimpleResponseHandler &simple = *simpleP;
	PEGASUS_ASSERT(_response);
	Uint32 objectCount = simple.size();

	// have not reached threshold yet
	if ((isComplete == false) && (objectCount < _responseObjectThreshold))
    {
        return;
    }

	CIMResponseMessage *response = _response;

	// for complete responses, just use the one handed down from caller
	// otherwise, create our own that the caller never sees but is
	// utilized for async responses underneath

	if (isComplete == false)
    {
        _response = _request->buildResponse();
    }

	_response->setComplete(isComplete);
	_responseObjectTotal += objectCount;

	// since we are reusing response for every chunk,keep track of original count
	_response->setIndex(_responseMessageTotal++);

	// set the originally allocated response to one more than the current.
	// The reason for doing this is proactive in case of an exception. This
	// allows the last response to be set as it may not re-enter this code.

	if (isComplete == false)
    {
        response->setIndex(_responseMessageTotal);
    }

	validate();

	if (_response->cimException.getCode() != CIM_ERR_SUCCESS)
    {
        simple.clear();
    }

	String function = getClass() + "::" + "transfer";
	Logger::put(
        Logger::STANDARD_LOG,
        System::CIMSERVER,
        Logger::TRACE,
        function);

	transfer();
	simple.clear();

	// l10n
	_response->operationContext.set(ContentLanguageListContainer(simple.getLanguages()));

	// call thru ProviderManager to get externally declared entry point

	if (isComplete == false)
	{
		ProviderManagerService::handleCimResponse(*_request, *_response);
	}

	// put caller's allocated response back in place. Note that _response
	// is INVALID after sending because it has been deleted externally

	_response = response;
}
std::string ModuleHolder::getName() const {
  static auto method = getClass()->getMethod<jstring()>("getName");
  return method(self())->toStdString();
}
Exemplo n.º 11
0
 jbool JObject::isInstanceOf(JClass* c){
     if (c==NULL){
         throw new JNullPointerException();
     }
     return c->isAssignableFrom(getClass());
 }
Exemplo n.º 12
0
void Cres::reinit(LocalePtr locale)
{
   BUNDLE = ResourceAccessor::fetch(getClass(), locale);
}
void VerilogDocGen::writeVerilogDeclarations(MemberDef* mdef,OutputList &ol,
                   ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
                   bool inGroup) {
 
  static bool bComp=false;
  LockingPtr<MemberDef> lock(mdef,mdef);
 
  Definition *d=0;
  ASSERT (cd!=0 || nd!=0 || fd!=0 || gd!=0); // member should belong to something
 if (cd) d=cd; else if (nd) d=nd; else if (fd) d=fd; else d=gd;
//if (cd) d=cd;
  // write tag file information of this member
 int memType=mdef->getMemberSpecifiers();

  if (!Config_getString("GENERATE_TAGFILE").isEmpty())
  {
    Doxygen::tagFile << "    <member kind=\"";
    Doxygen::tagFile << VerilogDocGen::convertTypeToString(memType);
     
    Doxygen::tagFile << "\">" << endl;
    Doxygen::tagFile << "      <type>" << convertToXML(mdef->typeString()) << "</type>" << endl;
    Doxygen::tagFile << "      <name>" << convertToXML(mdef->name()) << "</name>" << endl;
    Doxygen::tagFile << "      <anchorfile>" << convertToXML(mdef->getOutputFileBase()+Doxygen::htmlFileExtension) << "</anchorfile>" << endl;
    Doxygen::tagFile << "      <anchor>" << convertToXML(mdef->anchor()) << "</anchor>" << endl;
  
	if(memType==VerilogDocGen::FUNCTION)
		Doxygen::tagFile << "      <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList().pointer(),true)) << "</arglist>" << endl;
    else if(memType==VerilogDocGen::ALWAYS)
		Doxygen::tagFile << "      <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList().pointer(),false)) << "</arglist>" << endl;
	else{
	Doxygen::tagFile << "      <arglist>" << convertToXML(mdef->argsString()) << "</arglist>" << endl;
   Doxygen::tagFile << "      <arglist>" << convertToXML(mdef->typeString()) << "</arglist>" << endl; 
    }
	mdef->writeDocAnchorsToTagFile();
    Doxygen::tagFile << "    </member>" << endl;
 
  }
  
  // write search index info
  if (Doxygen::searchIndex)
  {
    Doxygen::searchIndex->setCurrentDoc(mdef->qualifiedName(),mdef->getOutputFileBase(),mdef->anchor());
    Doxygen::searchIndex->addWord(mdef->localName(),TRUE);
    Doxygen::searchIndex->addWord(mdef->qualifiedName(),FALSE);
  }

  QCString cname  = d->name();
  QCString cfname = mdef->getOutputFileBase();

 // HtmlHelp *htmlHelp=0;
//  bool hasHtmlHelp = Config_getBool("GENERATE_HTML") && Config_getBool("GENERATE_HTMLHELP");
//  if (hasHtmlHelp) htmlHelp = HtmlHelp::getInstance();

  // search for the last anonymous scope in the member type
//  ClassDef *annoClassDef=mdef->getClassDefOfAnonymousType();

  // start a new member declaration
 // bool isAnonymous =  annoClassDef; // || m_impl->annMemb || m_impl->annEnumType;
  ///printf("startMemberItem for %s\n",name().data());
 
//  if(mdef->getMemberSpecifiers()==VerilogDocGen::FEATURE)
//  ol.startMemberItem(mdef->anchor(),3); //? 1 : m_impl->tArgList ? 3 : 0);
//  else
 ol.startMemberItem(mdef->anchor(), 0);// ? 1 : m_impl->tArgList ? 3 : 0);


  // If there is no detailed description we need to write the anchor here.
  bool detailsVisible = mdef->isDetailedSectionLinkable();
  if (!detailsVisible) // && !m_impl->annMemb)
  {
     QCString doxyName=mdef->name().copy();
    if (!cname.isEmpty()) doxyName.prepend(cname+"::");
    QCString doxyArgs=mdef->argsString();
    ol.startDoxyAnchor(cfname,cname,mdef->anchor(),doxyName,doxyArgs);

    ol.pushGeneratorState();
    ol.disable(OutputGenerator::Man);
    ol.disable(OutputGenerator::Latex);
    ol.docify("\n");
    ol.popGeneratorState();
    
  }
// *** write type
     /*Verilog CHANGE */
   VhdlDocGen::adjustRecordMember(mdef); 
  
   QCString ltype(mdef->typeString()); 
   QCString largs(mdef->argsString());
 
   int mm=mdef->getMemberSpecifiers();

   ClassDef *kl=NULL;
   FileDef *fdd=NULL;
   LockingPtr<ArgumentList> alp = mdef->argumentList();
   QCString nn;
   if(gd)gd=NULL;
   switch(mm)
   {
       
       case VhdlDocGen::MISCELLANEOUS:
      VhdlDocGen::writeCodeFragment(mdef,ol);
      break;
      case VhdlDocGen::UCF_CONST: 
		  mm=mdef->name().findRev('_');
        if(mm>0)		 
		  mdef->setName(mdef->name().left(mm));
		  VhdlDocGen::writeUCFLink(mdef,ol);
        break;
   case VerilogDocGen::INCLUDE: 
     bool ambig;
     largs=mdef->name();
     fdd=findFileDef(Doxygen::inputNameDict,largs.data(),ambig);
     if(fdd){
      QCString fbb=fdd->getFileBase();
      fbb=fdd->getReference();
     fbb= fdd->getOutputFileBase();
     fbb=fdd->getSourceFileBase();
     fbb=fdd->convertNameToFile(largs.data(),true);
     fbb=fdd->getPath();
     fbb+=fdd->getOutputFileBase()+".html";
   
       ol.writeObjectLink(fdd->getReference(),
                     fdd->getOutputFileBase(),
		     0,
		     fdd->name());
	}
	else
	 VhdlDocGen::formatString(largs,ol,mdef);	
	
        break;
	case VerilogDocGen::FEATURE: 
	
       	parseDefineConstruct(largs,mdef,ol);
		
		break;

	case VerilogDocGen::MODULE: 
       	ol.startBold();
        VhdlDocGen::formatString(ltype,ol,mdef);
        ol.endBold();
		ol.insertMemberAlign();
	   //writeLink(mdef,ol);
    case VerilogDocGen::PORT:
 		  VhdlDocGen::writeLink(mdef,ol);
		 ol.insertMemberAlign();
		  if(largs.length()>0)
		    VhdlDocGen::formatString(largs,ol,mdef);
          if(ltype.length()>0)
		    VhdlDocGen::formatString(ltype,ol,mdef);	  
		  break;
    case VerilogDocGen::ALWAYS:
	     VhdlDocGen::writeLink(mdef,ol);  
	     ol.insertMemberAlign();
		 VhdlDocGen::writeProcessProto(ol,alp.pointer(),mdef);
		break;
   case VerilogDocGen::FUNCTION:
    case VerilogDocGen::TASK:      
         VhdlDocGen::writeLink(mdef,ol);  
	   	  ol.docify(" ");// need for pdf has no effect in html
		 ol.insertMemberAlign();
		 if(ltype.length()>0)
		    VhdlDocGen::formatString(ltype,ol,mdef);
	 	   writeFunctionProto(ol,alp.pointer(),mdef);
		 break;
   case VerilogDocGen::SIGNAL:
          if(largs.length()>0)
		    VhdlDocGen::formatString(largs,ol,mdef);
           ol.docify(" ");
       	    ol.insertMemberAlign();
        
            VhdlDocGen::writeLink(mdef,ol);  
            ol.docify(" ");
	     if(ltype.length())
		    VhdlDocGen::formatString(ltype,ol,mdef);       
        break;
   case VerilogDocGen::CONFIGURATION:
   case VerilogDocGen::LIBRARY:
         VhdlDocGen::writeLink(mdef,ol);  
         break;
   case VerilogDocGen::INPUT:
   case VerilogDocGen::OUTPUT:
   case VerilogDocGen::INOUT:
   case VerilogDocGen::PARAMETER:   
          VhdlDocGen::writeLink(mdef,ol);   
	     ol.docify(" ");	   	
		 ol.insertMemberAlign();
		 if(ltype.length()>0){
		    VhdlDocGen::formatString(ltype,ol,mdef);
	   	   ol.writeString("  ");
	    }
	  //ol.insertMemberAlign();
	  if(largs.length()>0)
		    VhdlDocGen::formatString(largs,ol,mdef);	 
	 	 break;
     case VerilogDocGen::COMPONENT:
		 //VhdlDocGen::writeLink(mdef,ol);
        if(true)
		{
		nn=mdef->name();
		kl=getClass(nn);
	  //if(kl==NULL){
	    ol.startBold();
	    QCString inst=mdef->name()+"::"+ltype;
          ol.writeObjectLink(mdef->getReference(),
                     mdef->getOutputFileBase(),
		     mdef->anchor(),
		     inst.data());
        ol.docify("  ");
        ol.endBold();
       //}
       	ol.insertMemberAlign();
	
		if(kl) {
			nn=kl->getOutputFileBase();
		
		ol.pushGeneratorState();
        ol.disableAllBut(OutputGenerator::Html);
         ol.docify("   ");
        QCString name=VerilogDocGen::getClassTitle(kl);
	     name=VhdlDocGen::getIndexWord(name.data(),1);
	    // ol.insertMemberAlign();
	 
	     ol.startBold();
		ol.docify(name.data());
		ol.endBold();
		ol.startEmphasis();
		   ol.docify(" ");
      
		   ol.writeObjectLink(kl->getReference(),kl->getOutputFileBase(),0,mdef->name().data());
	    ol.endEmphasis();
        ol.popGeneratorState();
		}
		if(largs.data())
			{
				ol.docify(" ");
			ol.docify(largs.data());
			}

        } 
		break;
  default: break;
   }

   bool htmlOn = ol.isEnabled(OutputGenerator::Html);
  if (htmlOn &&  !ltype.isEmpty())
  {
    ol.disable(OutputGenerator::Html);
  }
  if (!ltype.isEmpty()) ol.docify(" ");
  
  if (htmlOn) 
  {
    ol.enable(OutputGenerator::Html);
  }

  if (!detailsVisible)// && !m_impl->annMemb)
  {
    ol.endDoxyAnchor(cfname,mdef->anchor());
  }

  //printf("endMember %s annoClassDef=%p annEnumType=%p\n",
  //    name().data(),annoClassDef,annEnumType);
  ol.endMemberItem();
   if (!mdef->briefDescription().isEmpty() &&   Config_getBool("BRIEF_MEMBER_DESC") /* && !annMemb */)
  {
	  ol.startMemberDescription(mdef->anchor());
    ol.parseDoc(mdef->briefFile(),mdef->briefLine(),mdef->getOuterScope()?mdef->getOuterScope():d,mdef,mdef->briefDescription(),TRUE,FALSE,0,TRUE,FALSE);
    if (detailsVisible) 
    {
      ol.pushGeneratorState();
      ol.disableAllBut(OutputGenerator::Html);
      //ol.endEmphasis();
      ol.docify(" ");
      if (mdef->getGroupDef()!=0 && gd==0) // forward link to the group
      {
        ol.startTextLink(mdef->getOutputFileBase(),mdef->anchor());
      }
      else // local link
      {
        ol.startTextLink(0,mdef->anchor());
      }
      ol.endTextLink();
      //ol.startEmphasis();
      ol.popGeneratorState();
    }
    //ol.newParagraph();

    ol.endMemberDescription();
    // if(VhdlDocGen::isComponent(mdef))
   //    ol.lineBreak();
  }
   mdef->warnIfUndocumented();

  }// end writeVerilogDeclaration
const MetaClass* Camera::getInstanceClass() const {
   return getClass();
}
Exemplo n.º 15
0
bool Player::UpdateStats(Stats stat)
{
    if(stat > STAT_SPIRIT)
        return false;

    // value = ((base_value * base_pct) + total_value) * total_pct
    float value  = GetTotalStatValue(stat);

    SetStat(stat, int32(value));

    if(stat == STAT_STAMINA || stat == STAT_INTELLECT || stat == STAT_STRENGTH)
    {
        Pet *pet = GetPet();
        if(pet)
		{
            pet->UpdateStats(stat);
			if (getClass() == CLASS_DEATH_KNIGHT && pet->getPetType() == SUMMON_PET)
            {
                pet->RemoveAllAuras();
                pet->CastPetAuras(true);
            }
        }
    }

    switch(stat)
    {
        case STAT_STRENGTH:
            UpdateShieldBlockValue();
            break;
        case STAT_AGILITY:
            UpdateArmor();
            UpdateAllCritPercentages();
            UpdateDodgePercentage();
            break;
        case STAT_STAMINA:   UpdateMaxHealth(); break;
        case STAT_INTELLECT:
            UpdateMaxPower(POWER_MANA);
            UpdateAllSpellCritChances();
            UpdateArmor();                                  //SPELL_AURA_MOD_RESISTANCE_OF_INTELLECT_PERCENT, only armor currently
            break;

        case STAT_SPIRIT:
            break;

        default:
            break;
    }
    // Need update (exist AP from stat auras)
    UpdateAttackPowerAndDamage();
    UpdateAttackPowerAndDamage(true);

    UpdateSpellDamageAndHealingBonus();
    UpdateManaRegen();

    // Update ratings in exist SPELL_AURA_MOD_RATING_FROM_STAT and only depends from stat
    uint32 mask = 0;
    AuraList const& modRatingFromStat = GetAurasByType(SPELL_AURA_MOD_RATING_FROM_STAT);
    for(AuraList::const_iterator i = modRatingFromStat.begin();i != modRatingFromStat.end(); ++i)
        if (Stats((*i)->GetMiscBValue()) == stat)
            mask |= (*i)->GetMiscValue();
    if (mask)
    {
        for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
            if (mask & (1 << rating))
                ApplyRatingMod(CombatRating(rating), 0, true);
    }
    return true;
}
Exemplo n.º 16
0
bool IPEndpoint::V4::isMulticast () const
{
    return getClass() == 'D';
}
Exemplo n.º 17
0
void Player::UpdateAttackPowerAndDamage(bool ranged )
{
    float val2 = 0.0f;
    float level = float(getLevel());

    UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;

    uint16 index = UNIT_FIELD_ATTACK_POWER;
    uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
    uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;

    if (ranged)
    {
        index = UNIT_FIELD_RANGED_ATTACK_POWER;
        index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
        index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;

        switch(getClass())
        {
            case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_ROGUE:  val2 = level        + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_WARRIOR:val2 = level        + GetStat(STAT_AGILITY) - 10.0f;    break;
            case CLASS_DRUID:
                switch(m_form)
                {
                    case FORM_CAT:
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                        val2 = 0.0f; break;
                    default:
                        val2 = GetStat(STAT_AGILITY) - 10.0f; break;
                }
                break;
            default: val2 = GetStat(STAT_AGILITY) - 10.0f; break;
        }
    }
    else
    {
        switch(getClass())
        {
            case CLASS_WARRIOR:      val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_PALADIN:      val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_DEATH_KNIGHT: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f                    - 20.0f; break;
            case CLASS_ROGUE:        val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
            case CLASS_HUNTER:       val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
            case CLASS_SHAMAN:       val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
            case CLASS_DRUID:
            {
                //Check if Predatory Strikes is skilled
                float mLevelBonus = 0.0f;
                float mBonusWeaponAtt = 0.0f;
                switch(m_form)
                {
                    case FORM_CAT:
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                    case FORM_MOONKIN:
                    {
                        Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY);
                        for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
                        {
                            if ((*itr)->GetSpellProto()->SpellIconID != 1563)
                                continue;

                            // Predatory Strikes (effect 0)
                            if ((*itr)->GetEffIndex() == EFFECT_INDEX_0 && IsInFeralForm())
                                mLevelBonus = getLevel() * (*itr)->GetModifier()->m_amount / 100.0f;
                            // Predatory Strikes (effect 1)
                            else if ((*itr)->GetEffIndex() == EFFECT_INDEX_1)
                                mBonusWeaponAtt = (*itr)->GetModifier()->m_amount * m_baseFeralAP / 100.0f;

                            if (mLevelBonus != 0.0f && mBonusWeaponAtt != 0.0f)
                                break;
                        }
                        break;
                    }
                    default: break;
                }

                switch(m_form)
                {
                    case FORM_CAT:
                        val2 = GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break;
                    case FORM_BEAR:
                    case FORM_DIREBEAR:
                        val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break;
                    case FORM_MOONKIN:
                        val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f + m_baseFeralAP + mBonusWeaponAtt; break;
                    default:
                        val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
                }
                break;
            }
            case CLASS_MAGE:    val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
            case CLASS_PRIEST:  val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
            case CLASS_WARLOCK: val2 =              GetStat(STAT_STRENGTH)                         - 10.0f; break;
        }
    }

    SetModifierValue(unitMod, BASE_VALUE, val2);

    float base_attPower  = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
    float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);

    //add dynamic flat mods
    if ( ranged )
    {
        if ((getClassMask() & CLASSMASK_WAND_USERS)==0)
        {
            AuraList const& mRAPbyStat = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
            for(AuraList::const_iterator i = mRAPbyStat.begin();i != mRAPbyStat.end(); ++i)
                attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f);
        }
    }
    else
    {
        AuraList const& mAPbyStat = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
        for(AuraList::const_iterator i = mAPbyStat.begin();i != mAPbyStat.end(); ++i)
            attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f);

        AuraList const& mAPbyArmor = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
        for(AuraList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter)
            // always: ((*i)->GetModifier()->m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
            attPowerMod += int32(GetArmor() / (*iter)->GetModifier()->m_amount);
    }

    float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;

    SetInt32Value(index, (uint32)base_attPower);            //UNIT_FIELD_(RANGED)_ATTACK_POWER field
    SetInt32Value(index_mod, (uint32)attPowerMod);          //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
    SetFloatValue(index_mult, attPowerMultiplier);          //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field

    //automatically update weapon damage after attack power modification
    if (ranged)
    {
        UpdateDamagePhysical(RANGED_ATTACK);
    }
    else
    {
        UpdateDamagePhysical(BASE_ATTACK);
        if (CanDualWield() && haveOffhandWeapon())           //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
            UpdateDamagePhysical(OFF_ATTACK);
    }

    Pet *pet = GetPet();                                //update pet's AP
    if (pet)
        pet->UpdateAttackPowerAndDamage();
}
Exemplo n.º 18
0
static CMPIStatus ClassProviderEnumClassNames(CMPIClassMI * mi,
                                          CMPIContext * ctx,
                                          CMPIResult * rslt,
                                          CMPIObjectPath * ref)
{
   CMPIStatus st = { CMPI_RC_OK, NULL };
   char *cn=NULL;
   CMPIFlags flgs=0;
   CMPIString *cni;
   ClassBase *cb;
   Iterator it;
   char *key;
   int rc,n;
   ClassRecord *crec;
   CMPIObjectPath *op;
   ClassRegister *cReg;
   char *ns;

   _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderEnumClassNames");
   
   cReg=getNsReg(ref, &rc);
   if (cReg==NULL) {
      CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL };
      _SFCB_RETURN(st);
   }
      
   ns=(char*)CMGetNameSpace(ref,NULL)->hdl;
   flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
   cni=ref->ft->getClassName(ref,NULL);
   if (cni) {
      cn=(char*)cni->hdl;
      if (cn && *cn==0) cn=NULL;
   }   
   cb = (ClassBase *) cReg->hdl;  

   cReg->ft->wLock(cReg);
      
   if (cn && strcasecmp(cn,"$ClassProvider$")==0) cn=NULL;
   
   if (cn==NULL) {
      n=0;
      for (it = cReg->ft->getFirstClassRecord(cReg, &key, &crec);
           key && it && crec;
           it = cReg->ft->getNextClassRecord(cReg, it, &key, &crec)) {
         if ((flgs & CMPI_FLAG_DeepInheritance) || crec->parent==NULL) { 
            if (((flgs & FL_assocsOnly)==0) || crec->flags & CREC_isAssociation) {
               op=CMNewObjectPath(_broker,ns,key,NULL);
               CMReturnObjectPath(rslt,op);
            }   
         }   
      }     
   } else {
     CMPIConstClass *cls = getClass(cReg,cn,NULL);
     if (cls == NULL) {
       st.rc = CMPI_RC_ERR_INVALID_CLASS;
     } else if ((flgs & CMPI_FLAG_DeepInheritance)==0) {
       UtilList *ul = getChildren(cReg,cn);
       char *child;
       if (ul) for (child = (char *) ul->ft->getFirst(ul); child;  child = (char *) ul->ft->getNext(ul)) {
         op=CMNewObjectPath(_broker,ns,child,NULL);
         CMReturnObjectPath(rslt,op);
       }     
     } else if (flgs & CMPI_FLAG_DeepInheritance) {
       if (((flgs & FL_assocsOnly)==0) || crec->flags & CREC_isAssociation)
         loopOnChildNames(cReg, cn, rslt);
     }
   }
     
   cReg->ft->wUnLock(cReg);
      
   _SFCB_RETURN(st);
}
Exemplo n.º 19
0
void CPlayer::FillGreenSpellList()
{
    uint32 trainerid = 0;

    switch (getClass())
    {
    case CLASS_WARRIOR:
        trainerid = 26332;
        break;
    case CLASS_PALADIN:
        trainerid = 26327;
        break;
    case CLASS_HUNTER:
        trainerid = 26325;
        break;
    case CLASS_ROGUE:
        trainerid = 26329;
        break;
    case CLASS_PRIEST:
        trainerid = 26328;
        break;
    case CLASS_SHAMAN:
        trainerid = 26330;
        break;
    case CLASS_MAGE:
        trainerid = 26326;
        break;
    case CLASS_WARLOCK:
        trainerid = 26331;
        break;
    case CLASS_DRUID:
        trainerid = 26324;
        break;
    default:
        break;
    }

    if (!trainerid)
        return;

    Custom::SpellContainer* allSpellContainer = sCustom.GetCachedSpellContainer(getClass());

    if (!allSpellContainer)
    {
        allSpellContainer = new Custom::SpellContainer;

        Custom::SpellContainer classSpellContainer = sCustom.GetSpellContainerByCreatureEntry(trainerid);

        for (auto& itr : classSpellContainer)
            allSpellContainer->push_back(itr);

        sCustom.CacheSpellContainer(getClass(), allSpellContainer);
    }

    if (allSpellContainer->empty())
        return;

    m_DelayedSpellLearn.clear();

    for (auto itr = allSpellContainer->cbegin(); itr != allSpellContainer->cend(); ++itr)
    {
        TrainerSpell const* tSpell = &*itr;

        TrainerSpellState state = GetTrainerSpellState(tSpell, tSpell->reqLevel);

        if (state == TRAINER_SPELL_GREEN)
        {
            if (IsInWorld())
            {
                bool CastLearned = false;

                if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(tSpell->spell))
                {
                    for (auto i = 0; i < MAX_EFFECT_INDEX; ++i)
                    {
                        if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL)
                        {
                            CastLearned = true;

                            if (!HasSpell(spellInfo->EffectTriggerSpell[i]))
                                m_DelayedSpellLearn.push_back(spellInfo->EffectTriggerSpell[i]);
                        }
                    }
                }

                if (!CastLearned)
                    m_DelayedSpellLearn.push_back(tSpell->spell);
            }
        }
    }
}
Exemplo n.º 20
0
static CMPIStatus ClassProviderEnumClasses(CMPIClassMI * mi,
                                      CMPIContext * ctx,
                                      CMPIResult * rslt,
                                      CMPIObjectPath * ref)
{
   CMPIStatus st = { CMPI_RC_OK, NULL };
   char *cn=NULL;
   CMPIFlags flgs=0;
   CMPIString *cni;
   ClassBase *cb;
   Iterator it;
   char *key;
   int rc;
   CMPIConstClass *cls;
   ClassRegister *cReg;
   void *cid;

   _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderEnumClasss");
   
   cReg=getNsReg(ref, &rc);
   if (cReg==NULL) {
      CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL };
      _SFCB_RETURN(st);
   }
           
   cReg->ft->wLock(cReg);
   
   flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32;
   cni=ref->ft->getClassName(ref,NULL);
   if (cni) {
      cn=(char*)cni->hdl;
      if (cn && *cn==0) cn=NULL;
   }   
   cb = (ClassBase *) cReg->hdl;
 
      
   if (cn==NULL) {
      for (it = cReg->ft->getFirstClass(cReg, &key, &cls,&cid);
           key && it && cls;
           it = cReg->ft->getNextClass(cReg, it, &key, &cls,&cid)) {
         if ((flgs & CMPI_FLAG_DeepInheritance) || cls->ft->getCharSuperClassName(cls)==NULL) {  
            CMReturnInstance(rslt, (CMPIInstance *) cls);
         }   
 	 if(cid == NULL) CMRelease(cls);
      }     
   } else {
     cls = getClass(cReg,cn,NULL);
     if (cls == NULL) {
       st.rc = CMPI_RC_ERR_INVALID_CLASS;
     } else if ((flgs & CMPI_FLAG_DeepInheritance)==0) {
       UtilList *ul = getChildren(cReg,cn);
       char *child;
       if (ul) for (child = (char *) ul->ft->getFirst(ul); child;  child = (char *) ul->ft->getNext(ul)) {
         cls = getClass(cReg,child,&cid);
         CMReturnInstance(rslt, (CMPIInstance *) cls);
         if (cid==NULL) CMRelease(cls);
       }     
     } else if (cn && (flgs & CMPI_FLAG_DeepInheritance)) {
       loopOnChildren(cReg, cn, rslt);
     }
   }
     
   cReg->ft->wUnLock(cReg);
   
   _SFCB_RETURN(st);
}
Exemplo n.º 21
0
void CPlayer::ApplyEnchantTemplate(uint8 spec)
{
    for (auto& itr : sCustom.GetEnchantContainer())
        if (itr->ClassId == getClass() && itr->SpecId == spec)
            EnchantItem(itr->SpellId, itr->SlotId);
}
Exemplo n.º 22
0
Object DateTimeData::wrap(req::ptr<DateTime> dt) {
  Object obj{getClass()};
  DateTimeData* data = Native::data<DateTimeData>(obj);
  data->m_dt = dt;
  return obj;
}
Exemplo n.º 23
0
void Player::UpdateAttackPowerAndDamage(bool ranged)
{
    float val2 = 0.0f;
    float level = float(getLevel());

    ChrClassesEntry const* entry = sChrClassesStore.LookupEntry(getClass());
    UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;

    uint16 index = UNIT_FIELD_ATTACK_POWER;
    uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;

    if (ranged)
    {
        index = UNIT_FIELD_RANGED_ATTACK_POWER;
        index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
        val2 = (level + std::max(GetStat(STAT_AGILITY) - 10.0f, 0.0f)) * entry->RAPPerAgility;
    }
    else
    {
        float strengthValue = std::max((GetStat(STAT_STRENGTH) - 10.0f) * entry->APPerStrenth, 0.0f);
        float agilityValue = std::max((GetStat(STAT_AGILITY) - 10.0f) * entry->APPerAgility, 0.0f);

        if (GetShapeshiftForm() == FORM_CAT || GetShapeshiftForm() == FORM_BEAR)
            agilityValue += std::max((GetStat(STAT_AGILITY) - 10.0f) * 2, 0.0f);

        val2 = strengthValue + agilityValue;
    }

    SetModifierValue(unitMod, BASE_VALUE, val2);

    float base_attPower = GetModifierValue(unitMod, BASE_VALUE) * GetModifierValue(unitMod, BASE_PCT);
    float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
    float attPowerMultiplier = GetModifierValue(unitMod, TOTAL_PCT) - 1.0f;

    //add dynamic flat mods
    if (!ranged && HasAuraType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR))
    {
        AuraEffectList const& mAPbyArmor = GetAuraEffectsByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
        for (AuraEffectList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter)
        {
            // always: ((*i)->GetModifier()->m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
            int32 temp = int32(GetArmor() / (*iter)->GetAmount());
            if (temp > 0)
                attPowerMod += temp;
            else
                attPowerMod -= temp;
        }
    }

    if (HasAuraType(SPELL_AURA_OVERRIDE_AP_BY_SPELL_POWER_PCT))
    {
        int32 ApBySpellPct = 0;
        int32 spellPower = ToPlayer()->GetBaseSpellPowerBonus(); // SpellPower from Weapon
        spellPower += std::max(0, int32(ToPlayer()->GetStat(STAT_INTELLECT)) - 10); // SpellPower from intellect

        AuraEffectList const& mAPFromSpellPowerPct = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_AP_BY_SPELL_POWER_PCT);
        for (AuraEffectList::const_iterator i = mAPFromSpellPowerPct.begin(); i != mAPFromSpellPowerPct.end(); ++i)
            ApBySpellPct += CalculatePct(spellPower, (*i)->GetAmount());

        if (ApBySpellPct > 0)
        {
            SetInt32Value(index, uint32(ApBySpellPct));     //UNIT_FIELD_(RANGED)_ATTACK_POWER field
            SetFloatValue(index_mult, attPowerMultiplier);  //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
        }
        else
        {
            SetInt32Value(index, uint32(base_attPower + attPowerMod));  //UNIT_FIELD_(RANGED)_ATTACK_POWER field
            SetFloatValue(index_mult, attPowerMultiplier);              //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
        }
    }
    else
    {
        SetInt32Value(index, uint32(base_attPower + attPowerMod));  //UNIT_FIELD_(RANGED)_ATTACK_POWER field
        SetFloatValue(index_mult, attPowerMultiplier);              //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
    }

    Pet* pet = GetPet();                                //update pet's AP
    //automatically update weapon damage after attack power modification
    if (ranged)
    {
        UpdateDamagePhysical(RANGED_ATTACK);
        if (pet && pet->isHunterPet()) // At ranged attack change for hunter pet
            pet->UpdateAttackPowerAndDamage();
    }
    else
    {
        UpdateDamagePhysical(BASE_ATTACK);
        if (CanDualWield() && haveOffhandWeapon())           //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
            UpdateDamagePhysical(OFF_ATTACK);
        if (getClass() == CLASS_SHAMAN || getClass() == CLASS_PALADIN)                      // mental quickness
            UpdateSpellDamageAndHealingBonus();

        if (pet && pet->IsPetGhoul()) // At ranged attack change for hunter pet
            pet->UpdateAttackPowerAndDamage();
    }
}
Exemplo n.º 24
0
Object DateTimeZoneData::wrap(req::ptr<TimeZone> tz) {
  Object obj{getClass()};
  DateTimeZoneData* data = Native::data<DateTimeZoneData>(obj);
  data->m_tz = tz;
  return obj;
}
Exemplo n.º 25
0
void Player::UpdateDodgePercentage()
{
    // Table for base dodge values
    const int dodge_base[MAX_CLASSES] =
    {
        3, // Warrior
        3, // Paladin
        3, // Hunter
        3, // Rogue
        3, // Priest
        5, // DK
        3, // Shaman
        3, // Mage
        3, // Warlock
        3, // Monk
        5  // Druid
    };
    // Table for dodge cap values
    const float dodge_cap[MAX_CLASSES] =
    {
        90.6425f,       // Warrior
        66.567f,        // Paladin
        145.560408f,    // Hunter
        145.560408f,    // Rogue
        150.375940f,    // Priest
        90.6426f,       // DK
        66.567f,        // Shaman
        150.375940f,    // Mage
        150.375940f,    // Warlock
        501.253f,       // Monk
        150.375940f     // Druid
    };

    float diminishing = 0.0f, nondiminishing = 0.0f;
    uint32 pclass = getClass() - 1;
    // Warriors, Death Knights and Paladins no longer gain dodge from agility
    if (getClass() != CLASS_WARRIOR && getClass() != CLASS_DEATH_KNIGHT && getClass() != CLASS_PALADIN)
    {
        // TODO: research if talents/effects that increase total agility by x% should increase non-diminishing part
        float base_agility = GetCreateStat(STAT_AGILITY) * m_auraModifiersGroup[UNIT_MOD_STAT_START + STAT_AGILITY][BASE_PCT];
        float bonus_agility = GetTotalStatValue(STAT_AGILITY) - base_agility;
        float perc_cap = sObjectMgr->GetDodgeCapForClassLevel(pclass * GT_MAX_LEVEL + getLevel() - 1);

        // calculate diminishing (green in char screen) and non-diminishing (white) contribution
        diminishing = (bonus_agility / perc_cap) / ((bonus_agility / perc_cap) / dodge_cap[pclass] + m_diminishing_k[pclass]);
        nondiminishing = dodge_base[pclass] + base_agility / perc_cap;
    }
    else
        nondiminishing = dodge_base[pclass];

    // Dodge from SPELL_AURA_MOD_DODGE_PERCENT aura
    nondiminishing += GetTotalAuraModifier(SPELL_AURA_MOD_DODGE_PERCENT);
    // Dodge from rating
    diminishing += GetRatingBonusValue(CR_DODGE);
    // apply diminishing formula to diminishing dodge chance
    float value = nondiminishing + diminishing;

    if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE))
        value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) : value;

    value = value < 0.0f ? 0.0f : value;
    SetStatFloatValue(PLAYER_DODGE_PERCENTAGE, value);
}
Exemplo n.º 26
0
Object DateIntervalData::wrap(req::ptr<DateInterval> di) {
  Object obj{getClass()};
  DateIntervalData* data = Native::data<DateIntervalData>(obj);
  data->m_di = di;
  return obj;
}
Exemplo n.º 27
0
void oEvent::generatePreReport(gdioutput &gdi)
{
  CurrentSortOrder=SortByName;
  Runners.sort();

  int lVacId = getVacantClub();

  oRunnerList::iterator r_it;
  oTeamList::iterator t_it;

  //BIB, START, NAME, CLUB, RANK, SI
  int dx[6]={0, 0, 70, 300, 470, 470};

  bool withrank = hasRank();
  bool withbib = hasBib(true, true);
  int i;

  if (withrank) dx[5]+=50;
  if (withbib) for(i=1;i<6;i++) dx[i]+=40;

  int y=gdi.getCY();
  int x=gdi.getCX();
  int lh=gdi.getLineHeight();

  gdi.addStringUT(2, lang.tl("Rapport inför: ") + getName());

  gdi.addStringUT(1, getDate());
  gdi.dropLine();
  char bf[256];

  list<pRunner> no_card;
  list<pRunner> no_start;
  list<pRunner> no_class;
  list<pRunner> no_course;
  list<pRunner> no_club;

  for (r_it=Runners.begin(); r_it != Runners.end(); ++r_it){
    if (r_it->isRemoved())
      continue;

    bool needStartTime = true;
    bool needCourse = true;

    pClass pc = r_it->Class;
    if (pc) {
      LegTypes lt = pc->getLegType(r_it->tLeg);
      if (lt == LTIgnore) {
        needStartTime = false;
        needCourse = false;
      }
      if (pc->hasDirectResult())
        needCourse = false;

      StartTypes st = pc->getStartType(r_it->tLeg);

      if (st != STTime && st != STDrawn)
        needStartTime = false;

      if (pc->hasFreeStart())
        needStartTime = false;
    }
    if ( r_it->getClubId() != lVacId) {
      if (needCourse && r_it->getCardNo()==0)
        no_card.push_back(&*r_it);
      if (needStartTime && r_it->getStartTime()==0)
        no_start.push_back(&*r_it);
      if (r_it->getClubId()==0)
        no_club.push_back(&*r_it);
    }

    if (r_it->getClassId()==0)
      no_class.push_back(&*r_it);
    else if (needCourse && r_it->getCourse(false)==0)
      no_course.push_back(&*r_it);
  }

  list<pRunner> si_duplicate;

  if (Runners.size()>1){
    Runners.sort(oRunner::CompareSINumber);

    r_it=Runners.begin();
    while (++r_it != Runners.end()){
      oRunnerList::iterator r_it2=r_it;
      r_it2--;

      if (r_it2->getCardNo() && r_it2->getCardNo()==r_it->getCardNo()){

        if (si_duplicate.size()==0 || si_duplicate.back()->getId()!=r_it2->getId())
          si_duplicate.push_back(&*r_it2);

        si_duplicate.push_back(&*r_it);
      }
    }
  }

  const string Ellipsis="[ ... ]";

  sprintf_s(bf, lang.tl("Löpare utan klass: %d.").c_str(), no_class.size());
  gdi.addStringUT(1, bf);
  i=0;

  while(!no_class.empty() && ++i<20){
    pRunner r=no_class.front();
    no_class.pop_front();
    sprintf_s(bf, "%s (%s)", r->getName().c_str(), r->getClub().c_str());
    gdi.addStringUT(0, bf);
  }
  if (!no_class.empty()) gdi.addStringUT(1, Ellipsis);

  gdi.dropLine();
  sprintf_s(bf, lang.tl("Löpare utan bana: %d.").c_str(), no_course.size());
  gdi.addStringUT(1, bf);
  i=0;

  while(!no_course.empty() && ++i<20){
    pRunner r=no_course.front();
    no_course.pop_front();
    sprintf_s(bf, "%s: %s (%s)", r->getClass().c_str(), r->getName().c_str(), r->getClub().c_str());
    gdi.addStringUT(0, bf);
  }
  if (!no_course.empty()) gdi.addStringUT(1, Ellipsis);

  if (oe->getMeOSFeatures().hasFeature(MeOSFeatures::Clubs)) {
    gdi.dropLine();
    sprintf_s(bf, lang.tl("Löpare utan klubb: %d.").c_str(), no_club.size());
    gdi.addStringUT(1, bf);
    i=0;

    while(!no_club.empty() && ++i<20){
      pRunner r=no_club.front();
      no_club.pop_front();
      sprintf_s(bf, "%s: %s", r->getClass().c_str(), r->getName().c_str());
      gdi.addStringUT(0, bf);
    }
    if (!no_club.empty()) gdi.addStringUT(1, Ellipsis);
  }

  gdi.dropLine();
  sprintf_s(bf, lang.tl("Löpare utan starttid: %d.").c_str(), no_start.size());
  gdi.addStringUT(1, bf);
  i=0;

  while(!no_start.empty() && ++i<20){
    pRunner r=no_start.front();
    no_start.pop_front();
    sprintf_s(bf, "%s: %s (%s)", r->getClass().c_str(), r->getName().c_str(), r->getClub().c_str());
    gdi.addStringUT(0, bf);
  }
  if (!no_start.empty()) gdi.addStringUT(1, Ellipsis);

  gdi.dropLine();
  sprintf_s(bf, lang.tl("Löpare utan SI-bricka: %d.").c_str(), no_card.size());
  gdi.addStringUT(1, bf);
  i=0;

  while(!no_card.empty() && ++i<20){
    pRunner r=no_card.front();
    no_card.pop_front();
    sprintf_s(bf, "%s: %s (%s)", r->getClass().c_str(), r->getName().c_str(), r->getClub().c_str());
    gdi.addStringUT(0, bf);
  }
  if (!no_card.empty()) gdi.addStringUT(1, Ellipsis);


  gdi.dropLine();
  sprintf_s(bf, lang.tl("SI-dubbletter: %d.").c_str(), si_duplicate.size());
  gdi.addStringUT(1, bf);
  i=0;

  while(!si_duplicate.empty() && ++i<20){
    pRunner r=si_duplicate.front();
    si_duplicate.pop_front();
    sprintf_s(bf, "%s: %s (%s) SI=%d", r->getClass().c_str(),
              r->getName().c_str(), r->getClub().c_str(), r->getCardNo());
    gdi.addStringUT(0, bf);
  }
  if (!si_duplicate.empty()) gdi.addStringUT(1, Ellipsis);


  //List all competitors not in a team.
  if (oe->hasTeam()) {
    for (r_it=Runners.begin(); r_it != Runners.end(); ++r_it)
      r_it->_objectmarker=0;

    for (t_it=Teams.begin(); t_it != Teams.end(); ++t_it){
      pClass pc=getClass(t_it->getClassId());

      if (pc){
        for(unsigned i=0;i<pc->getNumStages();i++){
          pRunner r=t_it->getRunner(i);
          if (r) r->_objectmarker++;
        }
      }
    }

    gdi.dropLine();
    gdi.addString("", 1, "Löpare som förekommer i mer än ett lag:");
    bool any = false;
    for (r_it=Runners.begin(); r_it != Runners.end(); ++r_it){
      if (r_it->_objectmarker>1){
        sprintf_s(bf, "%s: %s (%s)", r_it->getClass().c_str(), r_it->getName().c_str(), r_it->getClub().c_str());
        gdi.addStringUT(0, bf);
        any = true;
      }
    }
    if (!any)
      gdi.addStringUT(1, "0");
  }
  sortRunners(ClassStartTime);

  gdi.dropLine();
  gdi.addString("", 1, "Individuella deltagare");

  y=gdi.getCY();
  int tab[5]={0, 100, 350, 420, 550};
  for (r_it=Runners.begin(); r_it != Runners.end(); ++r_it){
    if (r_it->_objectmarker==0){ //Only consider runners not in a team.
      gdi.addStringUT(y, x+tab[0], 0, r_it->getClass(), tab[1]-tab[0]);
      gdi.addStringUT(y, x+tab[1], 0, r_it->getName()+" ("+r_it->getClub()+")", tab[2]-tab[1]);
      gdi.addStringUT(y, x+tab[2], 0, itos(r_it->getCardNo()), tab[3]-tab[2]);
      gdi.addStringUT(y, x+tab[3], 0, r_it->getCourseName(), tab[4]-tab[3]);
      y+=lh;
      pCourse pc=r_it->getCourse(true);

      if (pc){
        vector<string> res = pc->getCourseReadable(101);
        for (size_t k = 0; k<res.size(); k++) {
          gdi.addStringUT(y, x+tab[1], 0, res[k]);
          y+=lh;
        }
      }
    }
  }

  gdi.dropLine();
  gdi.addString("", 1, "Lag(flera)");

  for (t_it=Teams.begin(); t_it != Teams.end(); ++t_it){
    pClass pc=getClass(t_it->getClassId());

    gdi.addStringUT(0, t_it->getClass() + ": " + t_it->getName() + "  " +t_it->getStartTimeS());

    if (pc){
      for(unsigned i=0;i<pc->getNumStages();i++){
        pRunner r=t_it->getRunner(i);
        if (r){
          gdi.addStringUT(0, r->getName()+ " SI: " +itos(r->getCardNo()));

          pCourse pcourse=r->getCourse(true);

          if (pcourse){
            y = gdi.getCY();
            vector<string> res = pcourse->getCourseReadable(101);
            for (size_t k = 0; k<res.size(); k++) {
              gdi.addStringUT(y, x+tab[1], 0, res[k]);
              y+=lh;
            }
          }
        }
        else
          gdi.addString("", 0, "Löpare saknas");
      }
    }
    gdi.dropLine();
  }

  gdi.updateScrollbars();
}
Exemplo n.º 28
0
int SystemHero::maxLevel() const {
    return m_classInherit->maxLevel() == -1 ? getClass()->maxLevel() :
        m_classInherit->maxLevel();
}
Exemplo n.º 29
0
void Player::MakeTalentGlyphLink(std::ostringstream &out)
{

    // |cff4e96f7|Htalent:1396:4|h[Unleashed Fury]|h|r
    // |cff66bbff|Hglyph:23:460|h[Glyph of Fortitude]|h|r

    if (m_specsCount)
        // loop through all specs (only 1 for now)
        for (uint32 specIdx = 0; specIdx < m_specsCount; ++specIdx)
        {
            // find class talent tabs (all players have 3 talent tabs)
            uint32 const* talentTabIds = GetTalentTabPages(getClass());

            out << "\n" << "Active Talents ";

            for (uint32 i = 0; i < 3; ++i)
            {
                uint32 talentTabId = talentTabIds[i];
                for (PlayerTalentMap::iterator iter = m_talents[specIdx].begin(); iter != m_talents[specIdx].end(); ++iter)
                {
                    PlayerTalent talent = (*iter).second;

                    if (talent.state == PLAYERSPELL_REMOVED)
                        continue;

                    // skip another tab talents
                    if (talent.talentEntry->TalentTab != talentTabId)
                        continue;

                    TalentEntry const *talentInfo = sTalentStore.LookupEntry(talent.talentEntry->TalentID);

                    SpellEntry const* spell_entry = sSpellStore.LookupEntry(talentInfo->RankID[talent.currentRank]);

                    out << "|cff4e96f7|Htalent:" << talent.talentEntry->TalentID << ":" << talent.currentRank
                        << " |h[" << spell_entry->SpellName[GetSession()->GetSessionDbcLocale()] << "]|h|r";
                }
            }

            uint32 freepoints = 0;

            out << " Unspent points : ";

            if ((freepoints = GetFreeTalentPoints()) > 0)
                out << "|h|cff00ff00" << freepoints << "|h|r";
            else
                out << "|h|cffff0000" << freepoints << "|h|r";

            out << "\n" << "Active Glyphs ";
            // GlyphProperties.dbc
            for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
            {
                GlyphPropertiesEntry const* glyph = sGlyphPropertiesStore.LookupEntry(m_glyphs[specIdx][i].GetId());
                if (!glyph)
                    continue;

                SpellEntry const* spell_entry = sSpellStore.LookupEntry(glyph->SpellId);

                out << "|cff66bbff|Hglyph:" << GetGlyphSlot(i) << ":" << m_glyphs[specIdx][i].GetId()
                    << " |h[" << spell_entry->SpellName[GetSession()->GetSessionDbcLocale()] << "]|h|r";

            }
        }
}
Exemplo n.º 30
0
bool ParameterFileModel::setData(
		const QModelIndex& ind, const QVariant& value, int role) {

	if (!prefixValid())
		return false;

	switch (role) {
	case Qt::EditRole:
	case Qt::DisplayRole:
		if ((ind.row() >= 0) && (ind.row() < _keys.size())) {
			switch (ind.column()) {
			case 0:
				if (_onlyParams)
					return false;

				if (value.canConvert(QVariant::String)) {
					QString oldName = _keys[ind.row()];
					QString newName;
					// do not forget the prefix at the beginning of the name
					if (!_prefix.isEmpty())
						newName = _prefix + ".";
					newName += value.toString();
					if (oldName == newName)
						return true; // nothing to do
					if (_parameterFile->isSet(newName))
						return false; // don't overwrite existing value

					// save value
					QString val = getValue(oldName);
					erase(oldName);
					setValue(newName, val);
					emit dataChanged(ind, ind);
					return true;
				}
				break;
			case 1:
				if (value.canConvert(QVariant::String)) {
					QString valueStr = value.toString();
					QString keyStr = _keys[ind.row()];
					if (valueStr == getValue(keyStr))
						return true; // nothing to do

					setValue(keyStr, valueStr);
					if (_onlyParams && _metaInfos->isDynamic(getClass(keyStr))) {
						save();
						_updateDynamics();
						QTimer::singleShot(0, this, SLOT(_update()));
						emit dynamicUpdate();
					}
					emit dataChanged(index(ind.row(), 0), ind);
					return true;
				}
				break;
			case 2:
				if (value.canConvert(QVariant::Int)) {
					// check if value is allowed
					int valueInt = value.toInt();
					QString valueStr = QVariant(valueInt).toString();
					if (valueInt < 0 || valueInt > 3) {
						return false;
					}

					if (valueInt == 0) {
						// 0 is default value -> no entry needed
						if (isSet(_keys[ind.row()] + ".editorpriority")) {
							// check if value exists to prevent exceptions
							erase(_keys[ind.row()] + ".editorpriority");
							emit dataChanged(index(ind.row(), 0), ind);
						}
						return true;
					}

					if (valueStr ==
							getValue(_keys[ind.row()] + ".editorpriority")) {
						return true; // nothing to do
					}

					setValue(_keys[ind.row()] + ".editorpriority", valueStr);
					emit dataChanged(index(ind.row(), 0), ind);
					return true;
				}
				break;
			}
		}
		break;

	case Qt::CheckStateRole:
		if (_useMetaInfo && ind.column()==1 && isParameter(_keys[ind.row()])) {
			Q_ASSERT(getType(_keys[ind.row()]) == "bool");
			bool checked (value.toBool());
			setValue (_keys[ind.row()], checked ? "true" : "false");
            emit dataChanged(index(ind.row(),0),ind);
            if (_keys[ind.row()].contains("active") && checked == true){
                reactivatePreviousPlugins();
            }
            // additional check whether the changed Parameter is the ActiveInactive
            if (_keys[ind.row()].contains("active") && checked == false){
                deactivate();
            }
        }
		break;
	}
	return false;
}