예제 #1
0
bool RamProxyDB::GetRequiredItems(const uint32 typeID, const EVERamActivity activity, std::vector<RequiredItem> &into) {
    DBQueryResult res;

    if(!DBcore::RunQuery(res,
        "SELECT"
        " material.requiredTypeID,"
        " material.quantity,"
        " material.damagePerJob,"
        " IF(materialGroup.categoryID = 16, 1, 0) AS isSkill"
        " FROM typeActivityMaterials AS material"
        " LEFT JOIN invTypes AS materialType ON material.requiredTypeID = materialType.typeID"
        " LEFT JOIN invGroups AS materialGroup ON materialType.groupID = materialGroup.groupID"
        " WHERE material.typeID = %u"
        " AND material.activityID = %d"
        //this is needed as db is quite crappy ...
        " AND material.quantity > 0",
        typeID, (const int)activity))
    {
        _log(DATABASE__ERROR, "Failed to query data to build BillOfMaterials: %s.", res.error.c_str());
        return false;
    }

    DBResultRow row;
    while(res.GetRow(row))
        into.push_back(RequiredItem(row.GetUInt(0), row.GetUInt(1), row.GetFloat(2), row.GetInt(3) ? true : false));

    return true;
}
예제 #2
0
dgmtypeattributemgr::dgmtypeattributemgr()
{
    // load shit from db
    DBQueryResult res;

    if( !DBcore::RunQuery( res,
        "SELECT * FROM dgmTypeAttributes ORDER BY typeID" ) )
    {
        SysLog::Error("DgmTypeAttrMgr", "Error in db load query: %s", res.error.c_str());
        return;
    }

    uint32 currentID = 0;
    DgmTypeAttributeSet * entry = NULL;
    DBResultRow row;

    int amount = res.GetRowCount();
    for (int i = 0; i < amount; i++)
    {
        res.GetRow(row);
        uint32 typeID = row.GetUInt(0);

        if (currentID != typeID) {
            currentID = typeID;
            entry = new DgmTypeAttributeSet;
            mDgmTypeAttrInfo.insert(std::make_pair(currentID, entry));
        }

        DgmTypeAttribute * attr_entry = new DgmTypeAttribute();
        attr_entry->attributeID = row.GetUInt(1);
        if (row.IsNull(2) == true) {
            attr_entry->number = EvilNumber(row.GetFloat(3));
        } else {
            attr_entry->number = EvilNumber(row.GetInt(2));
        }

        entry->attributeset.push_back(attr_entry);
    }
}
예제 #3
0
bool APICharacterDB::GetCharacterSkillQueue(uint32 characterID, std::vector<std::string> & orderList, std::vector<std::string> & typeIdList,
    std::vector<std::string> & levelList, std::vector<std::string> & rankList, std::vector<std::string> & skillIdList,
    std::vector<std::string> & primaryAttrList, std::vector<std::string> & secondaryAttrList, std::vector<std::string> & skillPointsTrainedList)
{
    DBQueryResult res;

    // Get list of characters and their corporation info from the accountID:
    if( !sDatabase.RunQuery(res,
        " SELECT "
        "  chrSkillQueue.*, "
        "  dgmTypeAttributes.attributeID, "
        "  dgmTypeAttributes.valueInt, "
        "  dgmTypeAttributes.valueFloat, "
        "  entity.itemID, "
        "  entity_attributes.valueInt, "
        "  entity_attributes.valueFloat "
        " FROM chrSkillQueue "
        "  LEFT JOIN dgmTypeAttributes ON dgmTypeAttributes.typeID = chrSkillQueue.typeID "
        "  LEFT JOIN entity ON entity.typeID = chrSkillQueue.typeID "
        "  LEFT JOIN entity_attributes ON entity_attributes.itemID = entity.itemID "
        " WHERE chrSkillQueue.characterID = %u AND dgmTypeAttributes.typeID = chrSkillQueue.typeID AND "
        "  dgmTypeAttributes.attributeID IN (%u,%u,%u) AND entity.ownerID = %u AND entity_attributes.attributeID = %u ",
        characterID, AttrPrimaryAttribute, AttrSecondaryAttribute, AttrSkillTimeConstant, characterID, AttrSkillPoints ))
    {
        sLog.Error( "APIAccountDB::GetCharacterSkillQueue()", "Cannot find characterID %u", characterID );
        return false;
    }

    DBResultRow row;
    bool row_found = false;
    uint32 prev_orderIndex = 4294967295UL;
    while( res.GetRow( row ) )
    {
        row_found = true;

        if( prev_orderIndex != row.GetUInt(1) )
        {
            prev_orderIndex = row.GetUInt(1);
            orderList.push_back( std::string(row.GetText(1)) );
            typeIdList.push_back( std::string(row.GetText(2)) );
            levelList.push_back( std::string(row.GetText(3)) );
            skillIdList.push_back( std::string(row.GetText(7)) );

            if( row.GetText(8) == NULL )
                // Get value from the query's 'valueFloat' column since 'valueInt' contains 'NULL'
                skillPointsTrainedList.push_back( std::string((row.GetText(9) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(9))))) );
            else
                // Get value from the query's 'valueInt' column since it does not contain 'NULL'
                skillPointsTrainedList.push_back( std::string((row.GetText(8) == NULL ? "0" : row.GetText(8))) );
        }

        if( row.GetUInt(4) == AttrPrimaryAttribute )
        {
            if( row.GetText(5) == NULL )
                // Get value from the query's 'valueFloat' column since 'valueInt' contains 'NULL'
                primaryAttrList.push_back( std::string((row.GetText(6) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(6))))) );
            else
                // Get value from the query's 'valueInt' column since it does not contain 'NULL'
                primaryAttrList.push_back( std::string((row.GetText(5) == NULL ? "0" : row.GetText(5))) );
        }
        else if( row.GetUInt(4) == AttrSecondaryAttribute )
        {
            if( row.GetText(5) == NULL )
                // Get value from the query's 'valueFloat' column since 'valueInt' contains 'NULL'
                secondaryAttrList.push_back( std::string((row.GetText(6) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(6))))) );
            else
                // Get value from the query's 'valueInt' column since it does not contain 'NULL'
                secondaryAttrList.push_back( std::string((row.GetText(5) == NULL ? "0" : row.GetText(5))) );
        }
        else if( row.GetUInt(4) == AttrSkillTimeConstant )
        {
            if( row.GetText(5) == NULL )
                // Get value from the query's 'valueFloat' column since 'valueInt' contains 'NULL'
                rankList.push_back( std::string((row.GetText(6) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(6))))) );
            else
                // Get value from the query's 'valueInt' column since it does not contain 'NULL'
                rankList.push_back( std::string((row.GetText(5) == NULL ? "0" : row.GetText(5))) );
        }
    }

    if( !row_found )
    {
        sLog.Error( "APIServiceDB::GetCharacterSkillQueue()", "res.GetRow(row) failed for unknown reason." );
        return false;
    }

    return true;
}
예제 #4
0
bool APICharacterDB::GetCharacterSkillsTrained(uint32 characterID, std::vector<std::string> & skillTypeIDList, std::vector<std::string> & skillPointsList,
    std::vector<std::string> & skillLevelList, std::vector<std::string> & skillPublishedList)
{
    DBQueryResult res;

    // Get list of characters and their corporation info from the accountID:
    if( !sDatabase.RunQuery(res,
        " SELECT "
        "   entity.itemID, "
        "   entity.typeID, "
        "   entity_attributes.attributeID, "
        "   entity_attributes.valueInt, "
        "   entity_attributes.valueFloat, "
        "   invTypes.groupID, "
        "   invTypes.published, "
        "   invGroups.categoryID "
        " FROM `entity` "
        "   LEFT JOIN entity_attributes ON entity_attributes.itemID = entity.itemID "
        "   LEFT JOIN invTypes ON invTypes.typeID = entity.typeID "
        "   LEFT JOIN invGroups ON invGroups.groupID = invTypes.groupID "
        " WHERE `ownerID` = %u AND invGroups.categoryID = 16 ", characterID ))
    {
        sLog.Error( "APIAccountDB::GetCharacterSkillsTrained()", "Cannot find characterID %u", characterID );
        return false;
    }

    uint32 prevTypeID = 0;
    bool gotSkillPoints = false;
    bool gotSkillLevel = false;
    DBResultRow row;
    std::map<std::string, std::string> charInfo;
    while( res.GetRow( row ) )
    {
        if( prevTypeID != row.GetUInt(1) )
        {
            if( (!gotSkillPoints) && (prevTypeID != 0) )
                skillPointsList.push_back( std::string("0") );

            if( (!gotSkillLevel) && (prevTypeID != 0) )
                skillLevelList.push_back( std::string("0") );

            gotSkillPoints = false;
            gotSkillLevel = false;
            skillTypeIDList.push_back( std::string(row.GetText(1)) );
			skillPublishedList.push_back( std::string(itoa(row.GetBool(6) ? 1 : 0)) );
        }

        prevTypeID = row.GetUInt(1);

        if( row.GetUInt(2) == AttrSkillPoints )
        {
            gotSkillPoints = true;
            if( row.GetText(3) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                skillPointsList.push_back( std::string((row.GetText(4) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(4))))) );
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                skillPointsList.push_back( std::string((row.GetText(3) == NULL ? "0" : row.GetText(3))) );
        }

        if( row.GetUInt(2) == AttrSkillLevel )
        {
            gotSkillLevel = true;
            if( row.GetText(3) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                skillLevelList.push_back( std::string((row.GetText(4) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(4))))) );
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                skillLevelList.push_back( std::string((row.GetText(3) == NULL ? "0" : row.GetText(3))) );
        }
    }

    return true;
}
예제 #5
0
bool APICharacterDB::GetCharacterAttributes(uint32 characterID, std::map<std::string, std::string> & attribList)
{
    DBQueryResult res;

    // Get list of characters and their corporation info from the accountID:
    if( !sDatabase.RunQuery(res,
        " SELECT "
        "  itemID, "
        "  attributeID, "
        "  valueInt, "
        "  valueFloat "
        " FROM entity_attributes "
        " WHERE itemID = %u ", characterID ))
    {
        sLog.Error( "APIAccountDB::GetCharacterAttributes()", "Cannot find characterID %u", characterID );
        return false;
    }

    DBResultRow row;
    bool row_found = false;
    while( res.GetRow( row ) )
    {
        row_found = true;

        if( row.GetUInt(1) == AttrCharisma )
        {
            // Charisma
            if( row.GetText(2) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrCharisma)), std::string((row.GetText(3) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(3))))) ));
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrCharisma)), std::string((row.GetText(2) == NULL ? "0" : row.GetText(2))) ));
        }

        if( row.GetUInt(1) == AttrIntelligence )
        {
            // Intelligence
            if( row.GetText(2) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrIntelligence)), std::string((row.GetText(3) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(3))))) ));
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrIntelligence)), std::string((row.GetText(2) == NULL ? "0" : row.GetText(2))) ));
        }

        if( row.GetUInt(1) == AttrMemory )
        {
            // Memory
            if( row.GetText(2) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrMemory)), std::string((row.GetText(3) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(3))))) ));
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrMemory)), std::string((row.GetText(2) == NULL ? "0" : row.GetText(2))) ));
        }

        if( row.GetUInt(1) == AttrPerception )
        {
            // Perception
            if( row.GetText(2) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrPerception)), std::string((row.GetText(3) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(3))))) ));
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrPerception)), std::string((row.GetText(2) == NULL ? "0" : row.GetText(2))) ));
        }

        if( row.GetUInt(1) == AttrWillpower )
        {
            // Will Power
            if( row.GetText(2) == NULL )
                // Get value from 'entity_attributes' table 'valueFloat' column since 'valueInt' contains 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrWillpower)), std::string((row.GetText(3) == NULL ? "0.0" : itoa((uint32)(row.GetFloat(3))))) ));
            else
                // Get value from 'entity_attributes' table 'valueInt' column since it does not contain 'NULL'
                attribList.insert( std::pair<std::string, std::string>(std::string(itoa(AttrWillpower)), std::string((row.GetText(2) == NULL ? "0" : row.GetText(2))) ));
        }
    }

    if( !row_found )
    {
        sLog.Error( "APIServiceDB::GetAccountIdFromUsername()", "res.GetRow(row) failed for unknown reason." );
        return false;
    }

    return true;
}