当前位置: 首页>>代码示例>>C++>>正文


C++ EvilNumber类代码示例

本文整理汇总了C++中EvilNumber的典型用法代码示例。如果您正苦于以下问题:C++ EvilNumber类的具体用法?C++ EvilNumber怎么用?C++ EvilNumber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EvilNumber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _Subtract

EvilNumber EvilNumber::_Subtract( const EvilNumber & val1, const EvilNumber & val2 )
{
    EvilNumber result;

    // WARNING!  There should be NO implicit or explicit use of the 'this' pointer here!
    if (val2.mType == val1.mType) {
        if (val1.mType == evil_number_float) {
            result.mValue.fVal = val1.mValue.fVal - val2.mValue.fVal;
            result.mType = evil_number_float;
        } else if (val1.mType == evil_number_int) {
            result.mValue.iVal = val1.mValue.iVal - val2.mValue.iVal;
            result.mType = evil_number_int;
        }
    } else {
        // we assume that the val argument is the opposite of the 'this' type
        if (val1.mType == evil_number_float) {
            result.mValue.fVal = val1.mValue.fVal - double(val2.mValue.iVal);
            result.mType = evil_number_float;
        } else if (val1.mType == evil_number_int) {
            double tVal = (double)val1.mValue.iVal; // normal integer number
            result.mValue.fVal = tVal - val2.mValue.fVal;
            result.mType = evil_number_float;
        } else {
            assert(false); // crash
        }

        // check if we are a integer
        result.CheckIntegrity();
    }
    return result;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:31,代码来源:EvilNumber.cpp

示例2: _Divide

EvilNumber EvilNumber::_Divide( const EvilNumber & val1, const EvilNumber & val2 )
{
    EvilNumber result;

    // WARNING!  There should be NO implicit or explicit use of the 'this' pointer here!
    if (val2.mType == val1.mType) {
        if (val1.mType == evil_number_float) {
            result.mValue.fVal = val1.mValue.fVal / val2.mValue.fVal;
            result.mType = evil_number_float;
        } else if (val1.mType == evil_number_int) {
            // make sure we can do things like 2 / 4 = 0.5f
            result.mValue.fVal = double(val1.mValue.iVal) / double(val2.mValue.iVal);
            result.mType = evil_number_float;
            // check if its possibly an integer
            result.CheckIntegrity();
        }
    } else {
        // we assume that the val1 argument type is the opposite of the val2 argument type
        if (val1.mType == evil_number_float) {
            result.mValue.fVal = val1.mValue.fVal / double(val2.mValue.iVal);
            result.mType = evil_number_float;
        } else if (val1.mType == evil_number_int) {
            double tVal = (double)val1.mValue.iVal; // normal integer number
            result.mValue.fVal = tVal / val2.mValue.fVal;
            result.mType = evil_number_float;
        } else {
            assert(false); // crash
        }

        // check if we are an integer
        result.CheckIntegrity();
    }
    return result;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:34,代码来源:EvilNumber.cpp

示例3: ProcessActiveCycle

void ActiveModuleProcessingComponent::ProcessActiveCycle()
{
	//TO-DO: Check to see if capacitor is drained at activation or after the cycle

    //check for stop signal
    if(m_Stop)
        return;

    //else consume capacitor
	EvilNumber capCapacity = m_Ship->GetAttribute(AttrCharge);
	EvilNumber capNeed = m_Mod->GetAttribute(AttrCapacitorNeed);
	capCapacity -= capNeed;

	m_Ship->SetAttribute(AttrCharge, capCapacity.get_float());

    //then check if we are targeting another ship or not and apply attribute changes
	//maybe we can have a check for modules that repeat the same attributes so we
	//send the changes just once at activation and at deactivation

	//--pseudocode--
	//if(target != self)
	//	m_ShipAttrComp->ModifyTargetShipAttribute();
	//else
	//	m_ShipAttrComp->ModifyShipAttribute();
}
开发者ID:B3N4K,项目名称:evemu_server,代码行数:25,代码来源:ActiveModuleProcessingComponent.cpp

示例4: _Modulus

EvilNumber EvilNumber::_Modulus( const EvilNumber & val1, const EvilNumber & val2 )
{
    EvilNumber result;

    // WARNING!  There should be NO implicit or explicit use of the 'this' pointer here!
    if (val2.mType == val1.mType) {
        if (val1.mType == evil_number_float) {
            result.mValue.iVal = (int64)(val1.mValue.fVal) % (int64)(val2.mValue.fVal);
            result.mType = evil_number_int;
        } else if (val1.mType == evil_number_int) {
            result.mValue.iVal = val1.mValue.iVal % val2.mValue.iVal;
            result.mType = evil_number_int;
        }
    } else {
        // we assume that the val1 argument type is the opposite of the val2 argument type
        if (val1.mType == evil_number_float) {
            result.mValue.iVal = (int64)(val1.mValue.fVal) % val2.mValue.iVal;
            result.mType = evil_number_int;
        } else if (val1.mType == evil_number_int) {
            result.mValue.iVal = val1.mValue.iVal % (int64)(val2.mValue.fVal);
            result.mType = evil_number_int;
        } else {
            assert(false); // crash
        }

        // check if we are a integer
        result.CheckIntegrity();
    }
    return result;
}
开发者ID:Almamu,项目名称:evemu_server,代码行数:30,代码来源:EvilNumber.cpp

示例5: GetAttribute

EvilNumber Character::GetSPPerMin( SkillRef skill )
{
    EvilNumber primarySkillTrainingAttr = skill->GetAttribute(AttrPrimaryAttribute);
    EvilNumber secondarySkillTrainingAttr = skill->GetAttribute(AttrSecondaryAttribute);

    EvilNumber primarySPperMin = GetAttribute( (uint32)(primarySkillTrainingAttr.get_int()) );
    EvilNumber secondarySPperMin = GetAttribute( (uint32)(secondarySkillTrainingAttr.get_int()) );

    //EvilNumber skillLearningLevel(0);
    //
    ////3374 - Skill Learning
    //SkillRef skillLearning = GetSkill( 3374 );
    //if( skillLearning )
    //    skillLearningLevel = skillLearning->GetAttribute(AttrSkillLevel);

    primarySPperMin = primarySPperMin + secondarySPperMin / 2.0f;
    //primarySPperMin = primarySPperMin * (EvilNumber(1.0f) + EvilNumber(0.02f) * skillLearningLevel);

    // 100% Training bonus for 30day and under character age has been removed in Incursion
    // http://www.eveonline.com/en/incursion/article/57/learning-skills-are-going-away
    // Check Total SP Trained for this character against the threshold for granting the 100% training bonus:
    //if( m_totalSPtrained.get_float() < ((double)MAX_SP_FOR_100PCT_TRAINING_BONUS) )
    //    primarySPperMin = primarySPperMin * EvilNumber(2.0f);

    return primarySPperMin;
}
开发者ID:Logomorph,项目名称:evemu_crucible,代码行数:26,代码来源:Character.cpp

示例6: EffectiveStanding

EvilNumber EffectiveStanding( EvilNumber YourStanding, EvilNumber ConnectionsSkillLevel, EvilNumber DiplomacySkillLevel )
{
    EvilNumber SkillLevel(0.0);

    if( YourStanding < 0.0 )
        SkillLevel = DiplomacySkillLevel;
    else
        SkillLevel = ConnectionsSkillLevel;

    return (YourStanding.get_float() + ((10.0 - YourStanding.get_float()) * (0.04 * (SkillLevel.get_float()))));
}
开发者ID:Camwarp,项目名称:evemu_server,代码行数:11,代码来源:EVEUtils.cpp

示例7: ME_EffectOnWaste

EvilNumber ME_EffectOnWaste( EvilNumber MaterialAmount, EvilNumber BaseWasteFactor, EvilNumber MaterialEfficiency )
{
    EvilNumber ME_Factor(0.0);

    if( MaterialEfficiency >= 0 )
        ME_Factor = (1.0 / (MaterialEfficiency.get_float() + 1.0));
    else
        ME_Factor = (1.0 - MaterialEfficiency.get_float());

    return (floor(0.5 + (MaterialAmount.get_float() * (BaseWasteFactor.get_float() / 100.0) * ME_Factor.get_float())));
}
开发者ID:Camwarp,项目名称:evemu_server,代码行数:11,代码来源:EVEUtils.cpp

示例8: sigRad

uint32 TargetManager::TimeToLock(ShipRef ship, SystemEntity *target) const {

    EvilNumber scanRes = ship->GetAttribute(AttrScanResolution);
    EvilNumber sigRad(500);

	if( target->Item().get() != NULL )
		if( target->Item()->HasAttribute(AttrSignatureRadius) )
			sigRad = target->Item()->GetAttribute(AttrSignatureRadius);

    EvilNumber time = ( EvilNumber(40000) / ( scanRes ) ) /( EvilNumber::pow( e_log( sigRad + e_sqrt( sigRad * sigRad + 1) ), 2) );

	return static_cast<uint32>(time.get_float() * 1000); // Timer uses ms instead of seconds
}
开发者ID:Camwarp,项目名称:evemu_server,代码行数:13,代码来源:TargetManager.cpp

示例9: Change

bool AttributeMap::Change( uint32 attributeID, EvilNumber& old_val, EvilNumber& new_val )
{
   Notify_OnModuleAttributeChange modChange;

	modChange.ownerID = mItem.ownerID();
	modChange.itemKey = mItem.itemID();
	modChange.attributeID = attributeID;
	modChange.time = Win32TimeNow();
	modChange.newValue = new_val.GetPyObject();
	modChange.oldValue = old_val.GetPyObject();

	return SendAttributeChanges(modChange.Encode());
}
开发者ID:Camwarp,项目名称:evemu_server,代码行数:13,代码来源:EVEAttributeMgr.cpp

示例10: Change

bool AttributeMap::Change( uint32 attributeID, EvilNumber& old_val, EvilNumber& new_val )
{
    mChanged = true;
    PyTuple* AttrChange = new PyTuple(7);
    AttrChange->SetItem(0, new PyString("OnModuleAttributeChange"));
    AttrChange->SetItem(1, new PyInt(mItem.ownerID()));
    AttrChange->SetItem(2, new PyInt(mItem.itemID()));
    AttrChange->SetItem(3, new PyInt(attributeID));
    AttrChange->SetItem(4, new PyLong(Win32TimeNow()));
    AttrChange->SetItem(5, old_val.GetPyObject());
    AttrChange->SetItem(6, new_val.GetPyObject());

    return SendAttributeChanges(AttrChange);
}
开发者ID:stschake,项目名称:evemu-incursion,代码行数:14,代码来源:EVEAttributeMgr.cpp

示例11: ValidateAddItem

/*
 * InventoryEx
 */
void InventoryEx::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
{
    //double volume = item->quantity() * item->volume();
    EvilNumber volume = item->GetAttribute(AttrQuantity) * item->GetAttribute(AttrVolume);
    double capacity = GetRemainingCapacity( flag );
    if( volume > capacity )
    {
        std::map<std::string, PyRep *> args;

        args["available"] = new PyFloat( capacity );
        args["volume"] = volume.GetPyObject();

        throw PyException( MakeUserError( "NotEnoughCargoSpace", args ) );
    }
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:18,代码来源:Inventory.cpp

示例12: if

/* rewrote attrib calculations and implemented true stacking penality, with checks for exceptions.  -allan 13April16  */
void ModifyModuleAttributesComponent::_modifyModuleAttributes(GenericModule* targetMod, uint32 targetAttrID, uint32 sourceAttrID, EVECalculationType type)
{
    uint8 stackSize = 1;
    EvilNumber modVal = m_Mod->GetAttribute(sourceAttrID), startVal = targetMod->GetAttribute(targetAttrID);
    /* check for attribs that are NOT penalized here, and bypass stacking method. */
    /* note:  DCU, rigs and subsystems do not use this method */
    if ((targetAttrID != AttrWarpFactor) or (sourceAttrID != AttrCargoCapacityMultiplier)) {
        std::map<uint16, uint8>::iterator itr = m_attribMap.find(targetAttrID);
        if (itr != m_attribMap.end()) {
            /** @todo   verify these module states  */
            if (m_Mod->GetModuleState() == MOD_ONLINE)
                stackSize = ++itr->second;
            else if ((m_Mod->GetModuleState() == MOD_OFFLINE)
                or (m_Mod->GetModuleState() == MOD_DEACTIVATING))
                /** @todo  implement the difference between MOD_OFFLINE and MOD_DEACTIVATING */
                {
                    if (itr->second == 1)
                        m_attribMap.erase(itr);
                    else
                        stackSize = --itr->second;
                }
        } else
            m_attribMap.emplace(targetAttrID, 1);
    }

    double effectiveness = 1;
    if (m_Mod->GetModuleState() == MOD_ONLINE) {
        effectiveness = exp(-pow(((stackSize - 1)/2.67),2));  //stacking calculation fixed  -allan  20Dec15
        m_Mod->SetEffectiveness(targetAttrID, effectiveness);
    } else if ((m_Mod->GetModuleState() == MOD_OFFLINE) or (m_Mod->GetModuleState() == MOD_DEACTIVATING)) {
        effectiveness = m_Mod->GetEffectiveness(targetAttrID);
    }
    if (effectiveness <= 0) {   /* this should never happen */
        codelog(SHIP__MODULE_ERROR, "MMAC::_modifyModuleAttributes() -  effectiveness <= 0");
        targetMod->GetShipRef()->GetPilot()->SendErrorMsg("Internal Server Error.  Ref: ServerError 25620");
    }
    modVal *= effectiveness;
    EvilNumber newVal = CalculateNewAttributeValue(startVal, modVal, type);
    _log(SHIP__MODULE_TRACE, "MMAC::_modifyModuleAttributes() -  origVal:%f, Mod:%f, newVal:%f, stackSize:%u, effective:%f, type:%i", \
    startVal.get_float(), modVal.get_float(), newVal.get_float(), stackSize, effectiveness, (int)type);

    SetAttribute(targetMod, targetAttrID, newVal);
}
开发者ID:Vortex24,项目名称:evemu-Mainserver,代码行数:44,代码来源:ModifyModuleAttributesComponent.cpp

示例13: _CalculateTotalSPTrained

void Character::_CalculateTotalSPTrained()
{
    // Loop through all skills trained and calculate total SP this character has trained so far,
    // NOT including the skill currently being trained:
    double exponent = 0.0f;
    double totalSP = 0.0f;
    EvilNumber skillLevel;
    EvilNumber skillRank;
    std::vector<InventoryItemRef> skills;
    GetSkillsList( skills );
    std::vector<InventoryItemRef>::iterator cur, end;
    cur = skills.begin();
    end = skills.end();
    for(; cur != end; cur++)
    {
        // Calculate exact SP from each skill and add to total SP
        skillLevel = cur->get()->GetAttribute( AttrSkillLevel );
        skillRank = cur->get()->GetAttribute( AttrSkillTimeConstant );
        totalSP += 250.0f * (double)(skillRank.get_int()) * pow(32.0, (double)(((double)(skillLevel.get_int()) - 1.0f) / 2.0f));
    }

    m_totalSPtrained = totalSP;
}
开发者ID:Logomorph,项目名称:evemu_crucible,代码行数:23,代码来源:Character.cpp

示例14: GetAttribute

EvilNumber Character::GetSPPerMin( SkillRef skill )
{
    EvilNumber primarySkillTrainingAttr = skill->GetAttribute(AttrPrimaryAttribute);
    EvilNumber secondarySkillTrainingAttr = skill->GetAttribute(AttrSecondaryAttribute);

    EvilNumber primarySPperMin = GetAttribute( (uint32)(primarySkillTrainingAttr.get_int()) );
    EvilNumber secondarySPperMin = GetAttribute( (uint32)(secondarySkillTrainingAttr.get_int()) );

    EvilNumber skillLearningLevel(0);

    //3374 - Skill Learning
    SkillRef skillLearning = GetSkill( 3374 );
    if( skillLearning )
        skillLearningLevel = skillLearning->GetAttribute(AttrSkillLevel);

    primarySPperMin = primarySPperMin + secondarySPperMin / 2.0f;
    primarySPperMin = primarySPperMin * (EvilNumber(1.0f) + EvilNumber(0.02f) * skillLearningLevel);

    // Check Total SP Trained for this character against the threshold for granting the 100% training bonus:
    if( m_totalSPtrained.get_float() < ((double)MAX_SP_FOR_100PCT_TRAINING_BONUS) )
        primarySPperMin = primarySPperMin * EvilNumber(2.0f);

    return primarySPperMin;
}
开发者ID:MurdockGT,项目名称:evemu-incursion,代码行数:24,代码来源:Character.cpp

示例15: ProductionTime

EvilNumber ProductionTime( EvilNumber BaseProductionTime, EvilNumber ProductivityModifier, EvilNumber ProductionEfficiency, EvilNumber ProductionTimeModifier )
{
    EvilNumber PE_Factor(0.0);

    if( ProductionEfficiency >= 0.0 )
        PE_Factor = (ProductionEfficiency.get_float() / (1.0 + ProductionEfficiency.get_float()));
    else
        PE_Factor = (ProductionEfficiency.get_float() - 1.0);

    return (BaseProductionTime.get_float()
        * (1.0 - (ProductivityModifier.get_float() / BaseProductionTime.get_float())
        * (PE_Factor.get_float()))
        * ProductionTimeModifier.get_float());
}
开发者ID:Camwarp,项目名称:evemu_server,代码行数:14,代码来源:EVEUtils.cpp


注:本文中的EvilNumber类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。