Ejemplo n.º 1
0
bool RamProxyDB::GetJobVerifyProperties(const uint32 jobID, uint32 &ownerID, uint64 &endProductionTime, EVERamRestrictionMask &restrictionMask, EVERamCompletedStatus &status) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
                "SELECT job.ownerID, job.endProductionTime, job.completedStatusID, line.restrictionMask"
                " FROM ramJobs AS job"
                " LEFT JOIN ramAssemblyLines AS line ON line.assemblyLineID = job.assemblyLineID"
                " WHERE job.jobID = %u",
                jobID))
    {
        _log(DATABASE__ERROR, "Unable to query completion properties for job %u: %s", jobID, res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "No completion properties found for job %u.", jobID);
        return false;
    }

    ownerID = row.GetUInt(0);
    endProductionTime = row.GetUInt64(1);
    status = (EVERamCompletedStatus)row.GetUInt(2);
    restrictionMask = (EVERamRestrictionMask)row.GetUInt(3);

    return true;
}
Ejemplo n.º 2
0
bool RamProxyDB::GetRequiredItems(const uint32 typeID, const EVERamActivity activity, std::vector<RequiredItem> &into) {
    DBQueryResult res;

    if(!sDatabase.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;
}
bool CorporationDB::GetCurrentApplicationInfo(uint32 charID, uint32 corpID, ApplicationInfo & aInfo) {
    DBQueryResult res;
    if (!sDatabase.RunQuery(res,
        " SELECT "
        " status, applicationText, applicationDateTime, roles, grantableRoles, lastCorpUpdaterID, deleted "
        " FROM chrApplications "
        " WHERE characterID = %u AND corporationID = %u ",
        charID, corpID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        aInfo.valid = false;
        return false;
    }

    DBResultRow row;
    if (!res.GetRow(row)) {
        _log(DATABASE__ERROR, "There's no previous application.");
        aInfo.valid = false;
        return false;
    }

    aInfo.charID = charID;
    aInfo.corpID = corpID;
    aInfo.status = row.GetUInt(0);
    aInfo.appText = row.GetText(1);
    aInfo.appTime = row.GetUInt64(2);
    aInfo.role = row.GetUInt64(3);
    aInfo.grantRole = row.GetUInt64(4);
    aInfo.lastCID = row.GetUInt(5);
    aInfo.deleted = row.GetUInt(6);
    aInfo.valid = true;
    return true;
}
Ejemplo n.º 4
0
// ////////////////////// DGM_Type_Effects_Table Class ////////////////////////////
TypeEffectsList::TypeEffectsList(uint32 typeID)
{
    //first get list of all effects from dgmTypeEffects table for the given typeID
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetDgmTypeEffects(typeID, *res);

    //counter
	uint32 effectID = 0;
	uint32 isDefault = 0;
	uint32 total_effect_count = 0;

	m_typeEffectsList.clear();

	//go through and insert each effectID into the list
    DBResultRow row;
    while( res->GetRow(row) )
    {
		effectID = row.GetUInt(0);
		isDefault = row.IsNull(1) ? 0 : row.GetUInt(1);
		m_typeEffectsList.insert(std::pair<uint32,uint32>(effectID,isDefault));
		total_effect_count++;
    }

    //cleanup
    delete res;
    res = NULL;
}
Ejemplo n.º 5
0
void DGM_Type_Effects_Table::_Populate()
{
    //first get list of all effects from dgmEffects table
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetAllTypeIDs(*res);

    //counter
	TypeEffectsList * typeEffectsListPtr;
	uint32 total_type_count = 0;
	uint32 error_count = 0;

    DBResultRow row;
    while( res->GetRow(row) )
    {
		typeEffectsListPtr = new TypeEffectsList(row.GetUInt(0));
		if( typeEffectsListPtr->GetEffectCount() > 0 )
			m_TypeEffectsMap.insert(std::pair<uint32, TypeEffectsList *>(row.GetUInt(0),typeEffectsListPtr));
		else
			delete typeEffectsListPtr;

		total_type_count++;
    }

	if( error_count > 0 )
		sLog.Error("DGM_Type_Effects_Table::_Populate()","ERROR Populating the DGM_Type_Effects_Table memory object: %u of %u types failed to load!", error_count, total_type_count);

	sLog.Log("DGM_Type_Effects_Table", "..........%u total type effect objects loaded", total_type_count);

    //cleanup
    delete res;
    res = NULL;
}
Ejemplo n.º 6
0
bool CharacterDB::GetAttributesFromAncestry(uint32 ancestryID, uint8 &intelligence, uint8 &charisma, uint8 &perception, uint8 &memory, uint8 &willpower) {
    DBQueryResult res;

    if (!sDatabase.RunQuery(res,
        " SELECT "
        "        intelligence, charisma, perception, memory, willpower "
        " FROM chrAncestries "
        " WHERE ancestryID = %u ", ancestryID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return (false);
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Failed to find ancestry information for ancestry %u", ancestryID);
        return false;
    }

    intelligence += row.GetUInt(0);
    charisma += row.GetUInt(1);
    perception += row.GetUInt(2);
    memory += row.GetUInt(3);
    willpower += row.GetUInt(4);

    return (true);
}
Ejemplo n.º 7
0
bool CharacterDB::GetLocationByStation(uint32 staID, CharacterData &cdata) {
    DBQueryResult res;
    if (!sDatabase.RunQuery(res,
     "SELECT "
     "  stationID, "
     "  solarSystemID, "
     "  constellationID, "
     "  regionID "
     " FROM staStations"
     " WHERE stationID = %u", staID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return (false);
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Failed to find station %u", staID);
        return false;
    }

    cdata.stationID = staID;
    cdata.solarSystemID = row.GetUInt(1);
    cdata.constellationID = row.GetUInt(2);
    cdata.regionID = row.GetUInt(3);

    return (true);

}
Ejemplo n.º 8
0
bool RamProxyDB::GetAssemblyLineVerifyProperties(const uint32 assemblyLineID, uint32 &ownerID, double &minCharSecurity, double &maxCharSecurity, EVERamRestrictionMask &restrictionMask, EVERamActivity &activity) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
        "SELECT"
        " ownerID,"
        " minimumCharSecurity,"
        " maximumCharSecurity,"
        " restrictionMask,"
        " activityID"
        " FROM ramAssemblyLines"
        " WHERE assemblyLineID = %u",
        assemblyLineID))
    {
        _log(DATABASE__ERROR, "Failed to query verify properties for assembly line %u: %s.", assemblyLineID, res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "No verify properties found for assembly line %u.", assemblyLineID);
        return false;
    }

    ownerID = row.GetUInt(0);
    minCharSecurity = row.GetDouble(1);
    maxCharSecurity = row.GetDouble(2);
    restrictionMask = (EVERamRestrictionMask)row.GetUInt(3);
    activity = (EVERamActivity)row.GetUInt(4);

    return true;
}
Ejemplo n.º 9
0
bool ServiceDB::GetAccountInformation( const char* username, const char* password, AccountInfo & account_info )
{
    std::string _username = username;
    std::string _escaped_username;

    DBcore::DoEscapeString(_escaped_username, _username);

    DBQueryResult res;
    if (!DBcore::RunQuery(res, "SELECT accountID, password, hash, role, online, banned, logonCount, lastLogin FROM srvAccount WHERE accountName = '%s'", _escaped_username.c_str()))
    {
        SysLog::Error( "ServiceDB", "Error in query: %s.", res.error.c_str() );
        return false;
    }

    DBResultRow row;
    if (!res.GetRow( row )) {
		// account not found, create new one if autoAccountRole is not zero (0)
		if(EVEServerConfig::account.autoAccountRole > 0) {
			uint32 accountID = CreateNewAccount( _username.c_str(), password, EVEServerConfig::account.autoAccountRole);
			if( accountID > 0 ) {
				// add new account successful, get account info again
				bool ret = GetAccountInformation(username, password, account_info);
				return ret;
			}
			else
				return false;
		}
		else
			return false;
	}

    /* when any of the text gets are NULL it will fail... I think.. */
    account_info.id         = row.GetUInt(0);

    if (!row.IsNull(1))
        account_info.password = row.GetText(1);

    if (!row.IsNull(2))
        account_info.hash   = row.GetText(2);

    account_info.name       = _escaped_username;
    account_info.role       = row.GetUInt64(3);
    account_info.online     = row.GetBool(4);
    account_info.banned     = row.GetBool(5);
    account_info.visits     = row.GetUInt(6);

    if (!row.IsNull(7))
        account_info.last_login = row.GetText(7);

    return true;
}
Ejemplo n.º 10
0
bool ServiceDB::GetConstant(const char *name, uint32 &into) {
    DBQueryResult res;

    std::string escaped;
    DBcore::DoEscapeString(escaped, name);

    if(!DBcore::RunQuery(res,
    "SELECT"
    "    constantValue"
    " FROM eveConstants"
    " WHERE constantID='%s'",
        escaped.c_str()
    ))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Unable to find constant %s", name);
        return false;
    }

    into = row.GetUInt(0);

    return true;
}
Ejemplo n.º 11
0
uint32 ServiceDB::GetDestinationStargateID(uint32 fromSystem, uint32 toSystem) {
    DBQueryResult res;

    if(!DBcore::RunQuery(res,
        " SELECT "
        "    fromStargate.solarSystemID AS fromSystem,"
        "    fromStargate.itemID AS fromGate,"
        "    toStargate.itemID AS toGate,"
        "    toStargate.solarSystemID AS toSystem"
        " FROM mapJumps AS jump"
        " LEFT JOIN mapDenormalize AS fromStargate"
        "    ON fromStargate.itemID = jump.stargateID"
        " LEFT JOIN mapDenormalize AS toStargate"
        "    ON toStargate.itemID = jump.celestialID"
        " WHERE fromStargate.solarSystemID = %u"
        "    AND toStargate.solarSystemID = %u",
        fromSystem, toSystem
    ))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return(0);
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Error in query: no data for %d, %d", fromSystem, toSystem);
        return(0);
    }

    return row.GetUInt(2);
}
Ejemplo n.º 12
0
bool CommandDB::ItemSearch(const char *query, std::map<uint32, std::string> &into) {

    std::string escaped;
    sDatabase.DoEscapeString(escaped, query);

    DBQueryResult result;
    DBResultRow row;

    into.clear();

    //we need to query out the primary message here... not sure how to properly
    //grab the "main message" though... the text/plain clause is pretty hackish.
    if (!sDatabase.RunQuery(result,
        " SELECT typeID,typeName"
        " FROM invTypes"
        " WHERE"
        "  typeName rlike '%s'",
            escaped.c_str()
        ))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", result.error.c_str());
        return (false);
    }

    while(result.GetRow(row)) {
        into[row.GetUInt(0)] = row.GetText(1);
    }
    return true;
}
Ejemplo n.º 13
0
bool CommandDB::FullSkillList(std::vector<uint32> &skillList) {

    DBQueryResult result;
    DBResultRow row;

    skillList.clear();

    if (!sDatabase.RunQuery(result,
        " SELECT * FROM `invTypes` WHERE "
		" ((`groupID` IN (SELECT groupID FROM invGroups WHERE categoryID = 16)) AND (published = 1)) "
        ))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", result.error.c_str());
        return (false);
    }

    while(result.GetRow(row)) {
		skillList.push_back( (row.GetUInt(0)) );
    }

	// Because we searched skills with published = 1 and some GM skills are not published but still usable,
	// we will add them manually here:
	skillList.push_back( 3755 );	// Jove Frigate
	skillList.push_back( 3758 );	// Jove Cruiser
	skillList.push_back( 9955 );	// Polaris
	skillList.push_back( 10264 );	// Concord
	skillList.push_back( 11075 );	// Jove Industrial
	skillList.push_back( 11078 );	// Jove Battleship
	skillList.push_back( 19430 );	// Omnipotent
	skillList.push_back( 28604 );	// Tournament Observation

    return true;
}
Ejemplo n.º 14
0
/**
 * this function isn't used.
 */
void DBResultToIntIntlistDict( DBQueryResult &result, std::map<int32, PyRep *> &into ) {
    /* this builds a map from the int in result[0], to a list of each result[1]
     * which is has the same result[0]. This function assumes the result is
     * ORDER BY result[0]
     */
    uint32 last_key = 0xFFFFFFFF;

    PyList *l = NULL;

    DBResultRow row;
    while( result.GetRow( row ) )
    {
        uint32 k = row.GetUInt(0);
        if( k != last_key )
        {
            //watch for overwrite, no guarantee we are dealing with a key.
            std::map<int32, PyRep *>::iterator res = into.find(k);
            if( res != into.end() )
                //log an error or warning?
                PyDecRef( res->second );

            into[k] = l = new PyList();
            last_key = k;
        }

        l->AddItemInt( row.GetInt( 1 ) );
    }
}
Ejemplo n.º 15
0
uint32 MarketDB::FindSellOrder(
    uint32 stationID,
    uint32 typeID,
    double price,
    uint32 quantity,
    uint32 orderRange
) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
        "SELECT orderID"
        "    FROM market_orders"
        "    WHERE bid=0"
        "        AND typeID=%u"
        "        AND stationID=%u"
        "        AND volRemaining >= %u"
        "        AND price <= %f"
        "    ORDER BY price ASC"
        "    LIMIT 1",    //right now, we just care about the first order which can satisfy our needs.
        typeID,
        stationID,
        quantity,
        price))
    {
        codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row))
        return(0);    //no order found.

    return(row.GetUInt(0));
}
Ejemplo n.º 16
0
void CharacterDB::load_name_validation_set()
{
	DBQueryResult res;
	if(!sDatabase.RunQuery(res,
		"SELECT"
		" characterID, itemName AS characterName"
		" FROM character_"
		"	JOIN entity ON characterID = itemID"
		))
	{
		codelog(SERVICE__ERROR, "Error in query for %s", res.error.c_str());
		return;
	}

	DBResultRow row;
	while(res.GetRow(row) == true)
	{
		uint32 characterID = row.GetUInt(0);
		const char* name = row.GetText(1);

		//printf("initializing name validation: %s\n", name);
		uint32 hash = djb2_hash(name);

		mNameValidation.insert(hash);
		mIdNameContainer.insert(std::make_pair(characterID, name));
	}
}
Ejemplo n.º 17
0
bool CorporationDB::CreateMemberAttributeUpdate(MemberAttributeUpdate & attrib, uint32 newCorpID, uint32 charID) {
    // What are we doing here exactly?
    // Corporation gets a new member
    // it's new to it

    DBQueryResult res;
    DBResultRow row;
    if (!sDatabase.RunQuery(res,
        " SELECT "
        "   title, corporationDateTime, corporationID, "
        "   corpRole, rolesAtAll, rolesAtBase, "
        "   rolesAtHQ, rolesAtOther "
        " FROM character_ "
        " WHERE character_.characterID = %u ", charID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return false;
    }

    if (!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Cannot find character in database");
        return false;
    }

    // this could be stored in the db
#define PRN new PyNone()
#define PRI(i) new PyInt(i)
#define PRL(i) new PyLong(i)
#define PRS(s) new PyString(s)
#define PRNI(i) (row.IsNull(i) ? PRI(0) : PRI(row.GetUInt64(i)))
#define F(name, o, n) \
    attrib.name##Old = o; \
    attrib.name##New = n

    //element                   Old Value               New Value
    F(accountKey,               PRN,                    PRN);
    // i don't even know what this could refer to
    F(baseID,                   PRN,                    PRN);
    F(characterID,              PRN,                    PRI(charID));
    F(corporationID,            PRI(row.GetUInt(2)),    PRI(newCorpID));
    // these also have to be queried from the db
    F(divisionID,               PRN,                    PRN);
    F(roles,                    PRNI(3),                PRI(0));
    F(grantableRoles,           PRNI(4),                PRI(0));
    F(grantableRolesAtBase,     PRNI(5),                PRI(0));
    F(grantableRolesAtHQ,       PRNI(6),                PRI(0));
    F(grantableRolesAtOther,    PRNI(7),                PRI(0));
    F(squadronID,               PRN,                    PRN);
    F(startDateTime,            PRL(row.GetUInt64(1)),  PRL(Win32TimeNow()));
    // another one i have no idea
    F(titleMask,                PRN,                    PRI(0));
    F(baseID,                   PRS(row.GetText(0)),    PRS(""));
#undef F
#undef PRN
#undef PRI
#undef PRS
#undef PRNI

    return true;
}
Ejemplo n.º 18
0
uint32 RamProxyDB::CountResearchJobs(const uint32 installerID) {
    DBQueryResult res;

    if(!DBcore::RunQuery(res,
        "SELECT"
        " COUNT(job.jobID)"
        " FROM srvRamJobs AS job"
        " LEFT JOIN ramAssemblyLines AS line ON job.assemblyLineID = line.assemblyLineID"
        " WHERE job.installerID = %u"
        " AND job.completedStatusID = 0"
        " AND line.activityID != 1",
        installerID))
    {
        _log(DATABASE__ERROR, "Failed to count research jobs for installer %u.", installerID);
        return 0;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "No rows returned while counting research jobs for installer %u.", installerID);
        return 0;
    }

    return(row.GetUInt(0));
}
Ejemplo n.º 19
0
bool APIServiceDB::GetAccountIdFromUserID(std::string userID, uint32 * accountID)
{
    DBQueryResult res;

    // Find accountID in 'accountapi' table using userID:
    if( !sDatabase.RunQuery(res,
        "SELECT"
        "    accountID "
        " FROM accountApi "
        " WHERE userID='%s'" , userID.c_str() ))
    {
        sLog.Error( "APIServiceDB::GetAccountIdFromUserID()", "Cannot find accountID for userID %s", userID.c_str() );
        return false;
    }

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

    *accountID = row.GetUInt(0);        // Grab accountID from the retrieved row from the 'accountapi' table
    return true;
}
Ejemplo n.º 20
0
bool CharacterDB::GetRespecInfo(uint32 characterId, uint32& out_freeRespecs, uint64& out_nextRespec)
{
    DBQueryResult res;
    if (!sDatabase.RunQuery(res, "SELECT freeRespecs, nextRespec FROM character_ WHERE characterID = %u", characterId))
        return false;
    if (res.GetRowCount() < 1)
        return false;
    DBResultRow row;
    res.GetRow(row);
    out_freeRespecs = row.GetUInt(0);
    out_nextRespec = row.GetUInt64(1);

    // can't have more than two
    if (out_freeRespecs == 2)
        out_nextRespec = 0;
    else if (out_freeRespecs < 2 && out_nextRespec < Win32TimeNow())
    {
        // you may get another
        out_freeRespecs++;
        if (out_freeRespecs == 1)
            out_nextRespec = Win32TimeNow() + Win32Time_Year;
        else
            out_nextRespec = 0;

        // reflect this in the database, too
        DBerror err;
        sDatabase.RunQuery(err, "UPDATE character_ SET freeRespecs = %u, nextRespec = %" PRIu64 " WHERE characterId = %u",
            out_freeRespecs, out_nextRespec, characterId);
    }

    return true;
}
Ejemplo n.º 21
0
int CommandDB::GetAttributeID(const char *attributeName) {

    DBQueryResult res;
    DBResultRow row;
    std::string escape;
    sDatabase.DoEscapeString(escape, attributeName);

    if(!sDatabase.RunQuery(res,
        " SELECT "
        " attributeID "
        " FROM dgmAttributeTypes "
        " WHERE attributeName = '%s' ",
        escape.c_str() ) )
    {
        _log(DATABASE__ERROR, "Error retrieving attributeID for attributeName = '%s' ", escape.c_str() );
        return 0;
    }

    if( !res.GetRow(row) ){
        _log(DATABASE__ERROR, "Null result finding attributeID for attributeName = '%s' ", escape.c_str() );
        return 0;
    }

    return row.GetUInt( 0 );

}
Ejemplo n.º 22
0
bool APIServiceDB::GetApiAccountInfoUsingUserID(std::string userID, std::string * apiFullKey, std::string * apiLimitedKey, uint32 * apiRole)
{
    DBQueryResult res;

    // Find fullKey, limitedKey, and apiRole from 'accountApi' table using userID supplied from an API query string:
    if( !sDatabase.RunQuery(res,
        "SELECT"
        "    fullKey, limitedKey, apiRole "
        " FROM accountApi "
        " WHERE userID='%s'" , userID.c_str() ))
    {
        sLog.Error( "APIServiceDB::GetApiAccountInfoUsingUserID()", "Cannot find userID '%s' in 'accountApi' table", userID.c_str() );
        return false;
    }

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

    *apiFullKey = row.GetText(0);        // Grab Full API Key from retrieved row from the 'accountApi' table
    *apiLimitedKey = row.GetText(1);    // Grab Limited API Key from retrieved row from the 'accountApi' table
    *apiRole = row.GetUInt(2);            // Grab API Role from retrieved row from the 'accountApi' table
    return true;
}
Ejemplo n.º 23
0
bool AttributeMap::ResetAttribute(uint32 attrID, bool notify)
{
    //this isn't particularly efficient, but until I write a better solution, this will do
    DBQueryResult res;

    if(!sDatabase.RunQuery(res, "SELECT * FROM dgmTypeAttributes WHERE typeID='%u'", mItem.typeID())) {
        sLog.Error("AttributeMap", "Error in db load query: %s", res.error.c_str());
        return false;
    }

    DBResultRow row;
    EvilNumber attrVal;
    uint32 attributeID;

    int amount = res.GetRowCount();
    for (int i = 0; i < amount; i++)
    {
        res.GetRow(row);
        attributeID = row.GetUInt(1);
        if( attributeID == attrID )
        {
            if(!row.IsNull(2))
                attrVal = row.GetUInt64(2);
            else
                attrVal = row.GetDouble(3);

            SetAttribute(attributeID, attrVal, notify);
        }
    }

    return true;

}
Ejemplo n.º 24
0
bool BookmarkDB::GetBookmarkInformation(uint32 bookmarkID, uint32 &ownerID, uint32 &itemID, uint32 &typeID,
                                        uint32 &flag, std::string &memo, uint64 &created, double &x, double &y,
                                        double &z, uint32 &locationID)
{
	DBQueryResult res;
   	DBResultRow row;

    // Query database 'bookmarks' table for the supplied bookmarkID and retrieve entire row:
	if (!sDatabase.RunQuery(res, 
		" SELECT "
		"	bookmarkID, "
        "   ownerID, "
        "   itemID, "
        "   typeID, "
        "   flag, "
        "   memo, "
        "   created, "
        "   x, "
        "   y, "
        "   z, "
        "   locationID "
		" FROM bookmarks "
		" WHERE bookmarkID = %u ", bookmarkID))
	{
        sLog.Error( "BookmarkDB::GetBookmarkInformation()", "Error in query: %s", res.error.c_str() );
		return false;
	}

    // Query went through, but check to see if there were zero rows, ie bookmarkID was invalid:
	if ( !(res.GetRow(row)) )
        return false;

    // Bookmark 'bookmarkID' was found, Send back bookmark information:
    ownerID = row.GetUInt(1);
    itemID = row.GetUInt(2);
    typeID = row.GetUInt(3);
    flag = row.GetUInt(4);
    memo = row.GetText(5);
    created = row.GetUInt64(6);
    x = row.GetDouble(7);
    y = row.GetDouble(8);
    z = row.GetDouble(9);
    locationID = row.GetUInt(10);

    return true;
}
Ejemplo n.º 25
0
// Function: Query 'channels' table for the channel whose 'channelID' matches the ID specified,
// then return all parameters for that channel.
void LSCDB::GetChannelInformation(uint32 channelID, std::string & name,
	    std::string & motd, uint32 & ownerid, std::string & compkey,
	    bool & memberless, std::string & password, bool & maillist,
	    uint32 & cspa, uint32 & temp, uint32 & mode)
{
	DBQueryResult res;

	if (!sDatabase.RunQuery(res, 
		" SELECT "
		"	channelID, "
		"	displayName, "
		"   motd, "
		"   ownerID, "
		"   comparisonKey, "
		"   memberless, "
		"   password, "
		"   mailingList, "
		"   cspa, "
		"   temporary, "
		"   mode "
		" FROM channels "
		" WHERE channelID = %u", channelID))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		return;
	}

	DBResultRow row;

	if (!(res.GetRow(row)))
	{
            _log(SERVICE__ERROR, "Channel named '%s' isn't present in the database", name.c_str() );
            return;
	}

	name = (row.GetText(1) == NULL ? "" : row.GetText(1));	// empty displayName field in channels table row returns NULL, so fill this string with "" in that case
	motd = (row.GetText(2) == NULL ? "" : row.GetText(2));	// empty motd field in channels table row returns NULL, so fill this string with "" in that case
	ownerid = row.GetUInt(3);
	compkey = (row.GetText(4) == NULL ? "" : row.GetText(4));	// empty comparisonKey field in channels table row returns NULL, so fill this string with "" in that case
	memberless = row.GetUInt(5) ? true : false;
	password = (row.GetText(6) == NULL ? "" : row.GetText(6));	// empty password field in channels table row returns NULL, so fill this string with "" in that case
	maillist = row.GetUInt(7) ? true : false;
	cspa = row.GetUInt(8);
	temp = row.GetUInt(9);
	mode = row.GetUInt(10);
}
Ejemplo n.º 26
0
bool CharacterDB::GetSkillsByCareerSpeciality(uint32 careerSpecialityID, std::map<uint32, uint32> &into) {
	DBQueryResult res;

	if (!sDatabase.RunQuery(res,
		"SELECT "
		"        skillTypeID, levels"
		" FROM chrCareerSpecialitySkills"
		" WHERE specialityID = %u", careerSpecialityID))
	{
		_log(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		return false;
	}
	
	DBResultRow row;
	while(res.GetRow(row)) {
		if(into.find(row.GetUInt(0)) == into.end())
			into[row.GetUInt(0)] = row.GetUInt(1);
		else
			into[row.GetUInt(0)] += row.GetUInt(1);
		//check to avoid more than 5 levels by skill
		if(into[row.GetUInt(0)] > 5)
			into[row.GetUInt(0)] = 5;
	}

	return true;
}
Ejemplo n.º 27
0
PyRep *LSCDB::GetMailDetails(uint32 messageID, uint32 readerID) {
	DBQueryResult result;
	DBResultRow row;

	//we need to query out the primary message here... not sure how to properly
	//grab the "main message" though... the text/plain clause is pretty hackish.
	if (!sDatabase.RunQuery(result,
		" SELECT eveMail.messageID, eveMail.senderID, eveMail.subject, " // need messageID as char*
		" eveMailDetails.attachment, eveMailDetails.mimeTypeID, "
		" eveMailMimeType.mimeType, eveMailMimeType.`binary`, "
		" eveMail.created, eveMail.channelID "
		" FROM eveMail "
		" LEFT JOIN eveMailDetails"
		"	ON eveMailDetails.messageID = eveMail.messageID "
		" LEFT JOIN eveMailMimeType"
		"	ON eveMailMimeType.mimeTypeID = eveMailDetails.mimeTypeID "
		" WHERE eveMail.messageID=%u"
		"	AND channelID=%u",
			messageID, readerID
		))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", result.error.c_str());
		return (NULL);
	}

	if (!result.GetRow(row)) {
		codelog(SERVICE__MESSAGE, "No message with messageID %u", messageID);
		return (NULL);
	}

	Rsp_GetEVEMailDetails details;
	details.messageID = row.GetUInt(0);
	details.senderID = row.GetUInt(1);
	details.subject = row.GetText(2);
	details.body = row.GetText(3);
	details.created = row.GetUInt64(7);
	details.channelID = row.GetUInt(8);
	details.deleted = 0; // If a message's details are sent, then it isn't deleted. If it's deleted, details cannot be sent
	details.mimeTypeID = row.GetInt(4);
	details.mimeType = row.GetText(5);
	details.binary = row.GetInt(6);

	return(details.Encode());
}
Ejemplo n.º 28
0
bool ServiceDB::GetStaticItemInfo(uint32 itemID, uint32 *systemID, uint32 *constellationID, uint32 *regionID, GPoint *position) {
    if(       systemID == NULL
        && constellationID == NULL
        && regionID == NULL
        && position == NULL
    )
        return true;

    DBQueryResult res;
    if(!DBcore::RunQuery(res,
        "SELECT"
        " solarSystemID,"
        " constellationID,"
        " regionID,"
        " x, y, z"
        " FROM mapDenormalize"
        " WHERE itemID = %u",
        itemID))
    {
        _log(DATABASE__ERROR, "Failed to query info for static item %u: %s.", itemID, res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "Failed to query info for static item %u: Item not found.", itemID);
        return false;
    }

    if(systemID != NULL)
        *systemID = row.GetUInt(0);
    if(constellationID != NULL)
        *constellationID = row.GetUInt(1);
    if(regionID != NULL)
        *regionID = row.GetUInt(2);
    if(position != NULL)
        *position = GPoint(
            row.GetDouble(3),
            row.GetDouble(4),
            row.GetDouble(5)
        );

    return true;
}
Ejemplo n.º 29
0
bool MarketDB::GetOrderInfo(uint32 orderID, uint32 *orderOwnerID, uint32 *typeID, uint32 *stationID, uint32 *quantity, double *price, bool *isBuy, bool *isCorp) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
        "SELECT"
        " volRemaining,"
        " price,"
        " typeID,"
        " stationID,"
        " charID,"
        " bid,"
        " isCorp"
        " FROM market_orders"
        " WHERE orderID=%u",
        orderID))
    {
        _log(MARKET__ERROR, "Error in query: %s.", res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(MARKET__ERROR, "Order %u not found.", orderID);
        return false;
    }

    if(quantity != NULL)
        *quantity = row.GetUInt(0);
    if(price != NULL)
        *price = row.GetDouble(1);
    if(typeID != NULL)
        *typeID = row.GetUInt(2);
    if(stationID != NULL)
        *stationID = row.GetUInt(3);
    if(orderOwnerID != NULL)
        *orderOwnerID = row.GetUInt(4);
    if(isBuy != NULL)
        *isBuy = row.GetInt(5) ? true : false;
    if(isCorp != NULL)
        *isCorp = row.GetInt(6) ? true : false;

    return true;
}
Ejemplo n.º 30
0
uint32 CharacterDB::GetBounty(uint32 charID) {
    DBQueryResult res;
    if(!sDatabase.RunQuery(res, "SELECT `bounty` FROM character_ WHERE `characterID` = %u", charID)) {
        sLog.Error("CharacterDB", "Error in GetBounty query: %s", res.error.c_str());
        return 0;
    }
    DBResultRow row;
    if(!res.GetRow(row))
        return 0;
    else
        return row.GetUInt(0);
}