Example #1
0
/**
  * @todo Here should come a call to Corp??::CharacterJoinToCorp or what the heck... for now we only put it there
  */
bool CharacterDB::GetLocationCorporationByCareer(CharacterData &cdata) {
	DBQueryResult res;
	if (!sDatabase.RunQuery(res, 
	 "SELECT "
	 "  chrSchools.corporationID, "
	 "  chrSchools.schoolID, "
	 "  corporation.allianceID, "
	 "  corporation.stationID, "
	 "  staStations.solarSystemID, "
	 "  staStations.constellationID, "
	 "  staStations.regionID "
	 " FROM staStations"
	 "  LEFT JOIN corporation ON corporation.stationID=staStations.stationID"
	 "  LEFT JOIN chrSchools ON corporation.corporationID=chrSchools.corporationID"
	 "  LEFT JOIN chrCareers ON chrSchools.careerID=chrCareers.careerID"
	 " WHERE chrCareers.careerID = %u", cdata.careerID))
	{
		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 career %u", cdata.careerID);
		return false;
	}
	
	cdata.corporationID = row.GetUInt(0);
	cdata.schoolID = row.GetUInt(1);
	cdata.allianceID = row.GetUInt(2);

	cdata.stationID = row.GetUInt(3);
	cdata.solarSystemID = row.GetUInt(4);
	cdata.constellationID = row.GetUInt(5);
	cdata.regionID = row.GetUInt(6);

	return (true);
}
PyObject *CharacterDB::GetCharPublicInfo(uint32 characterID) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
                           "SELECT "
                           " entity.typeID,"
                           " character_.corporationID,"
                           " chrBloodlines.raceID,"
                           " bloodlineTypes.bloodlineID,"
                           " character_.ancestryID,"
                           " character_.careerID,"
                           " character_.schoolID,"
                           " character_.careerSpecialityID,"
                           " entity.itemName AS characterName,"
                           " 0 as age,"	//hack
                           " character_.createDateTime,"
                           " character_.gender,"
                           " character_.characterID,"
                           " character_.description,"
                           " character_.corporationDateTime"
                           " FROM character_ "
                           "	LEFT JOIN entity ON characterID = itemID"
                           "	LEFT JOIN bloodlineTypes USING (typeID)"
                           "	LEFT JOIN chrBloodlines USING (bloodlineID)"
                           " WHERE characterID=%u", characterID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(SERVICE__ERROR, "Error in GetCharPublicInfo query: no data for char %d", characterID);
        return NULL;
    }
    return(DBRowToKeyVal(row));

}
Example #3
0
// Function: Return true or false result for the check of whether or not the specified
// channel 'displayName' is already being used by a channel.
bool LSCDB::IsChannelNameAvailable(std::string name)
{
	DBQueryResult res;

	// MySQL query channels table for any channel whose displayName matches "name":
	if (!sDatabase.RunQuery(res, 
		" SELECT "
		"	displayName "
		" FROM channels "
		" WHERE displayName = upper('%s')", name.c_str()))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		return false;
	}

	DBResultRow row;

    // Return true (this 'displayName' not in use) if there are no rows returned by the query:
	if (!res.GetRow(row))
		return true;
	else
		return false;
}
Example #4
0
// Function: Return true or false result for the check of whether or not the channel
// specified by channelID is already subscribed to by the character specified by charID.
bool LSCDB::IsChannelSubscribedByThisChar(uint32 charID, uint32 channelID)
{
	DBQueryResult res;

	if (!sDatabase.RunQuery(res, 
		" SELECT "
		"	channelID, "
		"   charID "
		" FROM channelChars "
		" WHERE channelID = %u AND charID = %u", channelID, charID ))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		return false;
	}

	DBResultRow row;

    // Return false (no subscription exists) if there are no rows returned by the query:
	if (!(res.GetRow(row)))
		return false;
	else
		return true;
}
uint32 CorporationDB::GetQuoteForRentingAnOffice(uint32 stationID) {
    DBQueryResult res;
    DBResultRow row;

    if (!sDatabase.RunQuery(res,
        " SELECT "
        " officeRentalCost "
        " FROM staStations "
        " WHERE staStations.stationID = %u ", stationID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        // Try to look more clever than we actually are...
        return 10000;
    }

    if (!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Unable to find station data, stationID: %u", stationID);
        // Try to look more clever than we actually are...
        return 10000;
    }

    return row.GetUInt(0);
}
Example #6
0
bool ReprocessingDB::GetRecoverables(const uint32 typeID, std::vector<Recoverable> &into) {
	DBQueryResult res;
	DBResultRow row;

	if (!sDatabase.RunQuery(res,
		"SELECT materialTypeID, MIN(quantity) FROM invTypeMaterials WHERE typeID = %u"
		" GROUP BY materialTypeID",
		typeID))
	{
		_log(DATABASE__ERROR, "Unable to get recoverables for type ID %u: '%s'", typeID, res.error.c_str());
		return false;
	}

	Recoverable rec;

	while (res.GetRow(row)) {
		rec.typeID = row.GetInt(0);
		rec.amountPerBatch = row.GetInt(1);
		into.push_back(rec);
	}

	return true;
}
Example #7
0
PyRep *MarketDB::GetOrderRow(uint32 orderID) {
    DBQueryResult res;

    if(!sDatabase.RunQuery(res,
        "SELECT"
        "    price, volRemaining, typeID, `range`, orderID,"
        "   volEntered, minVolume, bid, issued as issueDate, duration,"
        "   stationID, regionID, solarSystemID, jumps"
        " FROM market_orders"
        " WHERE orderID=%u", orderID))
    {
        codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

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

    return(DBRowToPackedRow(row));
}
Example #8
0
void DGM_Ship_Bonus_Modifiers_Table::_Populate()
{
    //first get list of all effects from dgmShipBonusModifiers table
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetAllDgmShipBonusModifiers(*res);

    //counter
    ShipBonusModifier * mShipBonusModifierPtr;
    mShipBonusModifierPtr = NULL;
    uint32 shipID;

	uint32 total_modifier_count = 0;
	uint32 error_count = 0;

	//go through and populate each ship bonus modifier
    DBResultRow row;
    while( res->GetRow(row) )
    {
        shipID = row.GetInt(0);
        mShipBonusModifierPtr = new ShipBonusModifier(shipID);
		if( mShipBonusModifierPtr->IsModifierLoaded() )
			m_ShipBonusModifiersMap.insert(std::pair<uint32, ShipBonusModifier *>(shipID,mShipBonusModifierPtr));
		else
			error_count++;

		total_modifier_count++;
    }

	if( error_count > 0 )
		sLog.Error("DGM_Ship_Bonus_Modifiers_Table::_Populate()","ERROR Populating the DGM_Ship_Bonus_Modifiers_Table memory object: %u of %u ship bonus modifiers failed to load!", error_count, total_modifier_count);

	sLog.Log("DGM_Ship_Bonus_Modifiers_Table", "..........%u total modifier objects loaded", total_modifier_count);

    //cleanup
    delete res;
    res = NULL;
}
Example #9
0
void DGM_Effects_Table::_Populate()
{
    //first get list of all effects from dgmEffects table
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetAllDgmEffects(*res);

    //counter
    MEffect * mEffectPtr;
    mEffectPtr = NULL;
    uint32 effectID;

	uint32 total_effect_count = 0;
	uint32 error_count = 0;

	//go through and populate each effect
    DBResultRow row;
    while( res->GetRow(row) )
    {
        effectID = row.GetInt(0);
        mEffectPtr = new MEffect(effectID);
		if( mEffectPtr->IsEffectLoaded() )
			m_EffectsMap.insert(std::pair<uint32, MEffect *>(effectID,mEffectPtr));
		else
			error_count++;

		total_effect_count++;
    }

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

	sLog.Log("DGM_Effects_Table", "..........%u total effects objects loaded", total_effect_count);

    //cleanup
    delete res;
    res = NULL;
}
Example #10
0
AgentLevel *MissionDB::LoadAgentLevel(uint8 level) {
	AgentLevel *result = new AgentLevel;
	
	DBQueryResult res;

	if(!sDatabase.RunQuery(res,
		"SELECT missionID,missionName,missionLevel,"
		"	agtMissions.missionTypeID,missionTypeName,"
		"	importantMission"
		" FROM agtMissions"
		"	NATURAL JOIN agtMissionTypes"
		" WHERE missionLevel=%d",
		level
	))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		delete result;
		return NULL;
	}

	std::vector<uint32> IDs;
	DBResultRow row;

	IDs.clear();
	while(res.GetRow(row)) {
		AgentMissionSpec *spec = new AgentMissionSpec;
		spec->missionID = row.GetUInt(0);
		spec->missionName = row.GetText(1);
		spec->missionLevel = row.GetUInt(2);
		spec->missionTypeID = row.GetUInt(3);
		spec->missionTypeName = row.GetText(1);
		spec->importantMission = (row.GetUInt(2)==0)?false:true;
		result->missions.push_back(spec);
	}
	
}
Example #11
0
// TODO: hangarGraphicID went missing. maybe no longer in the dump?
PyRep *StationDB::GetStationItemBits(uint32 sid) {
	DBQueryResult res;

	if(!sDatabase.RunQuery(res,
		" SELECT "
		" staStations.stationID, "
		" staStations.stationTypeID, staStations.corporationID AS ownerID, "
		" staStationTypes.hangarGraphicID, "
		// damn mysql returns the result of the sum as string and so it is sent to the client as string and so it freaks out...
		" CAST(SUM(staOperationServices.serviceID) as UNSIGNED INTEGER) AS serviceMask "
		" FROM staStations "
		" LEFT JOIN staStationTypes ON staStations.stationTypeID = staStationTypes.stationTypeID "
		" LEFT JOIN staOperationServices ON staStations.operationID = staOperationServices.operationID "
		" WHERE staStations.stationID = %u "
		" GROUP BY staStations.stationID ", sid
	))
	{
		_log(SERVICE__ERROR, "Error in GetStationItemBits query: %s", res.error.c_str());
		return NULL;
	}

	DBResultRow row;
	if(!res.GetRow(row)) {
		_log(SERVICE__ERROR, "Error in GetStationItemBits query: no station for id %d", sid);
		return NULL;
	}

	PyTuple * result = new PyTuple(5);
	result->SetItem(0, new PyInt(row.GetUInt(3)));
	result->SetItem(1, new PyInt(row.GetUInt(2)));
	result->SetItem(2, new PyInt(row.GetUInt(0)));
	result->SetItem(3, new PyInt(row.GetUInt(4)));
	result->SetItem(4, new PyInt(row.GetUInt(1)));

	return result;
}
Example #12
0
uint32 BookmarkDB::GetNextAvailableBookmarkID()
{
	DBQueryResult res;

	if (!sDatabase.RunQuery(res, 
		" SELECT "
		"	bookmarkID "
		" FROM bookmarks "
		" WHERE bookmarkID >= %u ", 0))
	{
        sLog.Error( "BookmarkDB::GetNextAvailableBookmarkID()", "Error in query: %s", res.error.c_str() );
		return 0;
	}

	uint32 currentBookmarkID = 0;

	// Traverse through the rows in the query result until the first gap is found
	// and return the value that would be first (or only one) in the gap as the next
	// free bookmark ID:
	DBResultRow row;
	while( res.GetRow(row) )
	{
        const uint32 bookmarkID = row.GetUInt( 0 );

        if( currentBookmarkID < bookmarkID )
            return currentBookmarkID;

        ++currentBookmarkID;
	}

        // Check to make sure that the next available bookmarkID is not equal to the Maximum bookmarkID value
	if( currentBookmarkID <= BookmarkService::MAX_BOOKMARK_ID )
        return currentBookmarkID;
	else
        return 0;	// No free bookmarkIDs found (this should never happen as there are way too many IDs to exhaust)
}
Example #13
0
// Return the Home station of the char based on the active clone
bool CharacterDB::GetCharHomeStation(uint32 characterID, uint32 &stationID) {
	uint32 activeCloneID;
	if( !GetActiveClone(characterID, activeCloneID) )
	{
		_log( DATABASE__ERROR, "Could't get the active clone for char %u", characterID );
		return false;
	}

	DBQueryResult res;
	if( !sDatabase.RunQuery(res,
		"SELECT locationID "
		"FROM entity "
		"WHERE itemID = %u",
		activeCloneID ))
	{
		_log(DATABASE__ERROR, "Could't get the location of the clone for char %u", characterID );
		return false;
	}

	DBResultRow row;
    res.GetRow(row);
    stationID = row.GetUInt(0);
	return true;
}
Example #14
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;
}
Example #15
0
bool CorporationDB::CreateCorporationCreatePacket(Notify_OnCorporaionChanged & cc, uint32 oldCorpID, uint32 newCorpID) {
    DBQueryResult res;
    DBResultRow row;

    if (!sDatabase.RunQuery(res,
        " SELECT "
        "   corporationID,corporationName,description,tickerName,url,"
        "   taxRate,minimumJoinStanding,corporationType,hasPlayerPersonnelManager,"
        "   sendCharTerminationMessage,creatorID,ceoID,stationID,raceID,"
        "   allianceID,shares,memberCount,memberLimit,allowedMemberRaceIDs,"
        "   graphicID,shape1,shape2,shape3,color1,color2,color3,typeface,"
        "   division1,division2,division3,division4,division5,division6,"
        "   division7,deleted"
        " FROM corporation "
        " WHERE corporationID = %u ", newCorpID
        ))
    {
        codelog(SERVICE__ERROR, "Error in retrieving new corporation's data (%u)", newCorpID);
        return false;
    }

    if(!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Unable to find corporation's data (%u)", newCorpID);
        return false;
    }

    cc.allianceIDOld = new PyNone();
    cc.allowedMemberRaceIDsOld = new PyNone();
    cc.ceoIDOld = new PyNone();
    cc.color1Old = new PyNone();
    cc.color2Old = new PyNone();
    cc.color3Old = new PyNone();
    cc.corporationIDOld = new PyNone();
    cc.corporationNameOld = new PyNone();
    cc.corporationTypeOld = new PyNone();
    cc.creatorIDOld = new PyNone();
    cc.deletedOld = new PyNone();
    cc.descriptionOld = new PyNone();
    cc.division1Old = new PyNone();
    cc.division2Old = new PyNone();
    cc.division3Old = new PyNone();
    cc.division4Old = new PyNone();
    cc.division5Old = new PyNone();
    cc.division6Old = new PyNone();
    cc.division7Old = new PyNone();
    cc.graphicIDOld = new PyNone();
    cc.hasPlayerPersonnelManagerOld = new PyNone();
    cc.memberCountOld = new PyNone();
    cc.memberLimitOld = new PyNone();
    cc.minimumJoinStandingOld = new PyNone();
    cc.raceIDOld = new PyNone();
    cc.sendCharTerminationMessageOld = new PyNone();
    cc.shape1Old = new PyNone();
    cc.shape2Old = new PyNone();
    cc.shape3Old = new PyNone();
    cc.sharesOld = new PyNone();
    cc.stationIDOld = new PyNone();
    cc.taxRateOld = new PyNone();
    cc.tickerNameOld = new PyNone();
    cc.typefaceOld = new PyNone();
    cc.urlOld = new PyNone();

    cc.corporationIDNew = row.GetUInt(0);
    cc.corporationNameNew = row.GetText(1);
    cc.descriptionNew = row.GetText(2);
    cc.tickerNameNew = row.GetText(3);
    cc.urlNew = row.GetText(4);
    cc.taxRateNew = row.GetDouble(5);
    cc.minimumJoinStandingNew = row.GetDouble(6);
    cc.corporationTypeNew = row.GetUInt(7);
    cc.hasPlayerPersonnelManagerNew = row.GetUInt(8);
    cc.sendCharTerminationMessageNew = row.GetUInt(9);
    cc.creatorIDNew = row.GetUInt(10);
    cc.ceoIDNew = row.GetUInt(11);
    cc.stationIDNew = row.GetUInt(12);
    _NI(raceIDNew, 13);
    _NI(allianceIDNew, 14);
    cc.sharesNew = row.GetUInt64(15);
    cc.memberCountNew = row.GetUInt(16);
    cc.memberLimitNew = row.GetUInt(17);
    cc.allowedMemberRaceIDsNew = row.GetUInt(18);
    cc.graphicIDNew = row.GetUInt(19);
    _NI(shape1New, 20);
    _NI(shape2New, 21);
    _NI(shape3New, 22);
    _NI(color1New, 23);
    _NI(color2New, 24);
    _NI(color3New, 25);
    _NI(typefaceNew, 26);
    _NI(division1New, 27);
    _NI(division2New, 28);
    _NI(division3New, 29);
    _NI(division4New, 30);
    _NI(division5New, 31);
    _NI(division6New, 32);
    _NI(division7New, 33);
    cc.deletedNew = row.GetUInt(34);

    return true;
}
Example #16
0
// this one needs some love
//int henk = "bla";
PyRep *StationDB::DoGetStation(uint32 sid)
{
	DBQueryResult res;

//" SELECT staStations.stationID, staStations.security, staStations.dockingCostPerVolume, staStations.maxShipVolumeDockable, staStations.officeRentalCost, staStations.operationID, staStations.stationTypeID, staStations.corporationID AS ownerID, staStations.solarSystemID, staStations.constellationID, staStations.regionID, staStations.stationName, staStations.x, staStations.y, staStations.z, staStations.reprocessingEfficiency, staStations.reprocessingStationsTake, staStations.reprocessingHangarFlag, staOperations.description, CAST(SUM(staOperationServices.serviceID) as UNSIGNED INTEGER) AS serviceMask FROM staStations LEFT JOIN staOperations ON staStations.operationID = staOperations.operationID LEFT JOIN staOperationServices ON staStations.operationID = staOperationServices.operationID WHERE staStations.stationID = %u GROUP BY staStations.stationID 

    if(!sDatabase.RunQuery(res, "SELECT"
    "staStations.x,"
    "staStations.y,"
    "staStations.z,"
    "mapDenormalize.orbitID,"
    "staStationTypes.hangarGraphicID,"
    "staStations.stationID,"
    "0 AS upgradelevel,"
    "invtypes.graphicID,"
    "staStations.regionID,"
    "staStations.security,"
    "staStations.stationTypeID,"
    "staStationTypes.dockingBayGraphicID,"
    "staStations.officeRentalCost,"
    "staStations.stationName,"
    "staOperations.description,"
    "staStations.constellationID,"
    "staStations.operationID,"
    "staStations.solarSystemID,"
    "staStationTypes.dockOrientationX,"
    "staStationTypes.dockOrientationY,"
    "staStationTypes.dockOrientationZ,"
    "staStations.corporationID AS standingOwnerID,"
    //"58012245 AS serviceMask,"
    "CAST(SUM(staOperationServices.serviceID) as UNSIGNED INTEGER) AS serviceMask "
    "staStations.dockingCostPerVolume,"
    "staStations.reprocessingHangarFlag,"
    "staStations.reprocessingEfficiency,"
    "staStationTypes.dockEntryX,"
    "staStationTypes.dockEntryY,"
    "staStationTypes.dockEntryZ,"
    "staStations.maxShipVolumeDockable,"
    "staStations.corporationID AS ownerID,"
    "staStationTypes.conquerable,"
    "mapDenormalize.radius"
    "from staStations "
    "LEFT JOIN staStationTypes ON "
    "staStations.stationTypeID=staStationTypes.stationTypeID "
    "LEFT JOIN mapDenormalize ON "
    "staStations.stationID=mapDenormalize.itemID "
    "LEFT JOIN invtypes ON "
    "staStations.stationTypeID=invtypes.typeID "
    "LEFT JOIN staOperations ON "
    "staStations.operationID=staOperations.operationID "
    "LEFT JOIN staOperationServices ON "
    "staStations.operationID=staOperationServices.operationID "
    "WHERE staStations.stationID = %u GROUP BY staStations.stationID", sid ))
    {
        //_log(SERVICE__ERROR, "Error in DoGetStation query: %s", res.error.c_str());
        sLog.Error("StationDB", "Error in DoGetStation query: %s", res.error.c_str());
        return NULL;
    }

	/*if(!sDatabase.RunQuery(res,
		" SELECT "
		" staStations.stationID, staStations.security, staStations.dockingCostPerVolume, staStations.maxShipVolumeDockable, "
		" staStations.officeRentalCost, staStations.operationID, staStations.stationTypeID, staStations.corporationID AS ownerID, staStations.solarSystemID, staStations.constellationID, "
		" staStations.regionID, staStations.stationName, staStations.x, staStations.y, staStations.z, staStations.reprocessingEfficiency, staStations.reprocessingStationsTake, staStations.reprocessingHangarFlag, "
		" staOperations.description, "
		// damn mysql returns the result of the sum as string and so it is sent to the client as string and so it freaks out...
		" CAST(SUM(staOperationServices.serviceID) as UNSIGNED INTEGER) AS serviceMask "
		" FROM staStations "
		" LEFT JOIN staOperations ON staStations.operationID = staOperations.operationID "
		" LEFT JOIN staOperationServices ON staStations.operationID = staOperationServices.operationID "
		" WHERE staStations.stationID = %u "
		" GROUP BY staStations.stationID ", sid
	))
    
	{
		_log(SERVICE__ERROR, "Error in DoGetStation query: %s", res.error.c_str());
		return NULL;
	}*/

	DBResultRow row;
	if(!res.GetRow(row)) {
		_log(SERVICE__ERROR, "Error in DoGetStation query: no station for id %d", sid);
		return NULL;
	}

	//only a guess that this is row
	return DBRowToKeyVal(row);
}
Example #17
0
void MEffect::_Populate(uint32 effectID)
{
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetDgmEffects(effectID, *res);

    // First, get all general info on this effectID from the dgmEffects table:
    DBResultRow row1;
    if( !res->GetRow(row1) )
        sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffects' table", effectID);
    else
    {
        //get all the data from the query
        m_EffectID = effectID;
        m_EffectName = row1.GetText(0);
        m_EffectCategory = row1.GetInt(1);
        m_PreExpression = row1.GetInt(2);
        m_PostExpression = row1.GetInt(3);
        if( !row1.IsNull(4) )
            m_Description = row1.GetText(4);
        if( !row1.IsNull(5) )
            m_Guid = row1.GetText(5);
        if( !row1.IsNull(6) )
            m_IconID = row1.GetInt(6);
        m_IsOffensive = row1.GetInt(7);
        m_IsAssistance = row1.GetInt(8);
        if( !row1.IsNull(9) )
            m_DurationAttributeID = row1.GetInt(9);
        if( !row1.IsNull(10) )
            m_TrackingSpeedAttributeID = row1.GetInt(10);
        if( !row1.IsNull(11) )
            m_DischargeAttributeID = row1.GetInt(11);
        if( !row1.IsNull(12) )
            m_RangeAttributeID = row1.GetInt(12);
        if( !row1.IsNull(13) )
            m_FalloffAttributeID = row1.GetInt(13);
        if( !row1.IsNull(14) )
            m_DisallowAutoRepeat = row1.GetInt(14);
        m_Published = row1.GetInt(15);
        if( !row1.IsNull(16) )
            m_DisplayName = row1.GetText(16);
        m_IsWarpSafe = row1.GetInt(17);
        m_RangeChance = row1.GetInt(18);
        m_ElectronicChance = row1.GetInt(19);
        m_PropulsionChance = row1.GetInt(20);
        if( !row1.IsNull(21) )
            m_Distribution = row1.GetInt(21);
        if( !row1.IsNull(22) )
            m_SfxName = row1.GetText(22);
        if( !row1.IsNull(23) )
            m_NpcUsageChanceAttributeID = row1.GetInt(23);
        if( !row1.IsNull(24) )
            m_NpcActivationChanceAttributeID = row1.GetInt(24);
        if( !row1.IsNull(25) )
            m_FittingUsageChanceAttributeID = row1.GetInt(25);
    }

    // Next, get the info from the dgmEffectsInfo table:
    ModuleDB::GetDgmEffectsInfo(effectID, *res);

    DBResultRow row2;

    // Initialize the new tables
    m_TargetAttributeIDs = new int[res->GetRowCount()];
    m_SourceAttributeIDs = new int[res->GetRowCount()];
    m_CalculationTypeIDs = new int[res->GetRowCount()];
    m_ReverseCalculationTypeIDs = new int[res->GetRowCount()];

    int count = 0;

    while( res->GetRow(row2) )
    {
        m_TargetAttributeIDs[count] = row2.GetInt(0);
        m_SourceAttributeIDs[count] = row2.GetInt(1);
        m_CalculationTypeIDs[count] = row2.GetInt(2);
        m_ReverseCalculationTypeIDs[count] = row2.GetInt(3);
        count++;
    }

    if( count == 0 )
        sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffectsInfo' table as the SQL query returned ZERO rows", effectID);

    m_numOfIDs = count;

    // Finally, get the info for this effectID from the dgmEffectsActions table:
    ModuleDB::GetDgmEffectsActions(effectID, *res);

    DBResultRow row3;

    if( !(res->GetRow(row3)) )
        sLog.Error("MEffect","Could not populate effect information for effectID: %u from 'dgmEffectsActions table", effectID);
    else
    {
        m_EffectAppliedWhenID = row3.GetInt(0);
        m_EffectAppliedTargetID = row3.GetInt(1);
        m_EffectApplicationTypeID = row3.GetInt(2);
        m_StackingPenaltyAppliedID = row3.GetInt(3);
        m_NullifyOnlineEffectEnable = row3.GetInt(4);
        m_NullifiedOnlineEffectID = row3.GetInt(5);
    }

    delete res;
    res = NULL;
}
Example #18
0
void ModuleEffects::_populate(uint32 typeID)
{
    //first get list of all of the effects associated with the typeID
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetDgmTypeEffectsInformation(typeID, *res);

    //counter
    MEffect * mEffectPtr;
    mEffectPtr = NULL;
    m_defaultEffect = NULL;     // Set this to NULL until the default effect is found, if there is any
    uint32 effectID;
    uint32 isDefault;

    //go through and populate each effect
    DBResultRow row;
    while( res->GetRow(row) )
    {
        effectID = row.GetInt(0);
        isDefault = row.GetInt(1);
        switch( effectID )
        {
            case 11:    // loPower
            case 12:    // hiPower
            case 13:    // medPower
                // We do not need to make MEffect objects these effectIDs, since they do nothing
                mEffectPtr = NULL;
                break;

            default:
                mEffectPtr = new MEffect( effectID );
                break;
        }

        if( isDefault > 0 )
            m_defaultEffect = mEffectPtr;

        // This switch is assuming that all entries in 'dgmEffectsInfo' for this effectID are applied during the same module state,
        // which should really be the case anyway, for every effectID, so we just check index 0 of the effectIDs list of attributes
        // that are modified by this effect for which module state during which the effect is active:
        if( mEffectPtr != NULL )
        {
            switch( mEffectPtr->GetModuleStateWhenEffectApplied(0) )
            {
                case EFFECT_ONLINE:
                    m_OnlineEffects.insert(std::pair<uint32, MEffect *>(effectID,mEffectPtr));
                    break;
                case EFFECT_ACTIVE:
                    m_ActiveEffects.insert(std::pair<uint32, MEffect *>(effectID,mEffectPtr));
                    break;
                case EFFECT_OVERLOAD:
                    m_OverloadEffects.insert(std::pair<uint32, MEffect *>(effectID,mEffectPtr));
                    break;
                default:
                    sLog.Error("ModuleEffects::_populate()", "Illegal value '%u' obtained from the 'effectAppliedInState' field of the 'dgmEffectsInfo' table", mEffectPtr->GetModuleStateWhenEffectApplied(0));
                    break;
            }
        }
    }

    //cleanup
    delete res;
    res = NULL;

}
Example #19
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;
}
Example #20
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;
}
Example #21
0
//this is a crap load of work... there HAS to be a better way to do this..
PyObject *MarketDB::GetMarketGroups() {
	DBQueryResult res;

	//returns cached object marketProxy.GetMarketGroups
	//marketGroupID, parentGroupID, marketGroupName, description, graphicID, hasTypes, types
	//this is going to be a real pain... another "nested" query thing...
	// I really wanna know how they do this crap with their MS SQL server.. 
	// I hope its not as much of a nightmare as it is for us....

	//first we need to query out all the types because we need them to 
	// fill in the 'types' subquery for each row of the result
	std::map< int, std::set<uint32> > types;	//maps marketGroupID -> typeID
	if(!sDatabase.RunQuery(res,
		"SELECT"
		"	marketGroupID,typeID"
		" FROM invTypes"
		" WHERE marketGroupID IS NOT NULL"
		" ORDER BY marketGroupID"))
	{
		codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str());
		return NULL;
	}
	
	DBResultRow row;
	while(res.GetRow(row))
		types[row.GetUInt(0)].insert(row.GetUInt(1));

	if(!sDatabase.RunQuery(res,
		"SELECT"
		"	marketGroupID, parentGroupID"
		" FROM invMarketGroups"))
	{
		codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str());
		return NULL;
	}

	std::map<int, int> parentChild;	//maps child -> parent
	std::map<int, std::set<int> > childParent; //maps parent -> all children.
	while(res.GetRow(row)) {
		//figure out the parent ID, mapping NULL to -1 for our map.
		int marketGroupID = row.GetUInt(0);
		int parentGroupID = row.IsNull(1) ? -1 : row.GetUInt(1);

		parentChild[marketGroupID] = parentGroupID;
		childParent[parentGroupID].insert(marketGroupID);
	}

	//now we need to propigate all of the items up the tree (a parent group's items list contains ALL items of its children.)
	_PropigateItems(types, parentChild, childParent, -1);

	//now we get to do the other query.
	if(!sDatabase.RunQuery(res,
		"SELECT"
		"	marketGroupID, parentGroupID, marketGroupName, description, graphicID, hasTypes"
		" FROM invMarketGroups"))
	{
		codelog(MARKET__ERROR, "Error in query: %s", res.error.c_str());
		return NULL;
	}

	//doing this the long (non XML) way to avoid the extra copies due to the huge volume of data here.
	PyDict *args = new PyDict();

	PyDict *parentSets = new PyDict();
	PyList *header = new PyList();
	
	header->AddItemString("marketGroupID");
	header->AddItemString("parentGroupID");
	header->AddItemString("marketGroupName");
	header->AddItemString("description");
	header->AddItemString("graphicID");
	header->AddItemString("hasTypes");
	header->AddItemString("types");	//this column really contains an entire list.
	header->AddItemString("dataID");
	
	args->SetItemString("header", header);
	args->SetItemString("idName", new PyString("parentGroupID"));
	args->SetItemString("RowClass", new PyToken("util.Row"));
	args->SetItemString("idName2", new PyNone);
	args->SetItemString("items", parentSets);
	
	//now fill in items.
	// we have to satisfy this structure... which uses parentGroupID as the
	// main dict key, each dict entry is then a list of MarketGroup_Entrys
	// which have that parentGroupID
	//marketGroupID, parentGroupID, marketGroupName, description, graphicID, hasTypes, types
	std::map< int, std::set<uint32> >::const_iterator tt;
	MarketGroup_Entry entry;
    PyList* list;
    PyList* parents = new PyList();
	while( res.GetRow(row) )
	{
		entry.marketGroupID = row.GetUInt( 0 );

		//figure out the parent ID, mapping NULL to -1 for our map.
		entry.parentGroupID = ( row.IsNull( 1 ) ? -1 : row.GetUInt( 1 ) );

		entry.marketGroupName = row.GetText( 2 );
		entry.description = row.GetText( 3 );
		entry.graphicID = ( row.IsNull( 4 ) ? -1 : row.GetUInt( 4 ) );		
		entry.hasTypes = row.GetUInt( 5 );

		// Insert all types
		entry.types.clear();
		tt = types.find( entry.marketGroupID );
		if( tt != types.end() )
			entry.types.insert( entry.types.begin(), tt->second.begin(), tt->second.end() );

        if(entry.parentGroupID == -1)
			list = parents;
		else
			list = static_cast<PyList*> (parentSets->GetItem(new PyInt( entry.parentGroupID )));
        if(list == NULL)
            list = new PyList();
        list->AddItem(entry.Encode());
        PySafeIncRef(list);
        if(entry.parentGroupID != -1)
			parentSets->SetItem(new PyInt(entry.parentGroupID), list);
	}
    parentSets->SetItem(new PyNone, parents);

	return new PyObject( "util.FilterRowset", args );
}
Example #22
0
PyRep *ConfigDB::GetCelestialStatistic(uint32 celestialID) {
    DBQueryResult res;
    DBResultRow row;

    if (!sDatabase.RunQuery(res,
        " SELECT "
        " groupID "
        " FROM eveNames "
        " WHERE itemID = %u ", celestialID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    if (!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Unable to find celestial object %u", celestialID);
        return NULL;
    }

    uint32 groupID = row.GetUInt(0);

    std::string query = "";

    switch (groupID) {
    case EVEDB::invGroups::Sun:
            query = " SELECT "
                    "    CONCAT( FORMAT( temperature, 0 ) , \" K\" ) AS temperature, "
                    "    spectralClass, "
                    "    FORMAT( luminosity, 5 ) as luminosity, "
                    "    CONCAT( FORMAT( CAST( age /60 /60 /24 /365 /1000000 AS UNSIGNED INTEGER ) *1000000, 0 ) , \" Years\" ) AS age, "
                    "    CONCAT( FORMAT( radius /1000, 0 ) , \" km\" ) AS radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Planet:
            query = " SELECT "
                    "    CONCAT( FORMAT( temperature, 0 ) , \" K\" ) AS temperature, "
                    "    CONCAT( FORMAT( orbitRadius / 1.49598E11, 3), \" AU\") AS \"Orbit Radius\", "
                    "    FORMAT( eccentricity, 3) AS eccentricity, "
                    "    CONCAT( FORMAT( massDust / POW(10, ROUND(LOG10(massDust), 0)), 1), \"e+0\", ROUND(LOG10(massDust), 0), \" kg\") AS mass, "
                    "    CONCAT( FORMAT( density, 1), \" g/cm^3\") AS density, "
                    "    CONCAT( FORMAT( surfaceGravity, 1), \" m/s^2\") AS \"Surface Gravity\", "
                    "    CONCAT( FORMAT( escapeVelocity / 1000, 1), \" km/s\") AS \"Escape Velocity\", "
                    "    CONCAT( FORMAT( orbitPeriod / 864000, 0), \" days\") AS \"Orbit Period\", "
                    "    CONCAT( FORMAT( pressure / 100000, 0), \" kPa\") AS pressure, "
                    "    CONCAT( FORMAT( radius /1000, 0), \" km\") AS radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Moon:
            query = " SELECT "
                    "    CONCAT( FORMAT( temperature, 0 ) , \" K\" ) AS temperature, "
                    "    CONCAT( FORMAT( orbitRadius, 0), \" km\") AS \"Orbit Radius\", "
                    "    CONCAT( FORMAT( massDust / POW(10, ROUND(LOG10(massDust), 0)), 1), \"e+0\", ROUND(LOG10(massDust), 0), \" kg\") AS mass, "
                    "    CONCAT( FORMAT( density, 1), \" g/cm^3\") AS density, "
                    "    CONCAT( FORMAT( surfaceGravity, 1), \" m/s^2\") AS \"Surface Gravity\", "
                    "    CONCAT( FORMAT( escapeVelocity / 1000, 1), \" km/s\") AS \"Escape Velocity\", "
                    "    CONCAT( FORMAT( orbitPeriod / 864000, 3), \" days\") AS \"Orbit Period\", "
                    "    CONCAT( FORMAT( pressure / 100000, 0), \" kPa\") AS pressure, "
                    "    CONCAT( FORMAT( radius /1000, 0), \" km\") AS radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Asteroid_Belt:
            query = " SELECT "
                    "    CONCAT( FORMAT( orbitRadius, 0), \" km\") AS \"Orbit Radius\", "
                    "    FORMAT( eccentricity, 3) AS eccentricity, "
                    "    CONCAT( FORMAT( massDust / POW(10, ROUND(LOG10(massDust), 0)), 1), \"e+0\", ROUND(LOG10(massDust), 0), \" kg\") AS mass, "
                    "    CONCAT( FORMAT( density, 1), \" g/cm^3\") AS density, "
                    "    CONCAT( FORMAT( orbitPeriod / 864000, 0), \" days\") AS \"Orbit Period\" "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;

    default:
            codelog(SERVICE__ERROR, "Invalid object groupID (%u) for %u", groupID, celestialID);
            return (NULL);
    }

    if (!sDatabase.RunQuery(res, query.c_str(), celestialID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    return DBResultToRowset(res);
}
Example #23
0
PyRep *ConfigDB::GetMultiOwnersEx(const std::vector<int32> &entityIDs) {
#ifndef WIN32
#warning we need to deal with corporations!
#endif
    //im not sure how this query is supposed to work, as far as what table
    //we use to get the fields from.
    //we only get called for items which are not already sent in the
    // eveStaticOwners cachable object.

    std::string ids;
    ListToINString(entityIDs, ids, "-1");

    DBQueryResult res;
    DBResultRow row;

    if(!sDatabase.RunQuery(res,
        "SELECT "
        " entity.itemID as ownerID,"
        " entity.itemName as ownerName,"
        " entity.typeID,"
        " NULL as ownerNameID,"
        " 0 as gender"
        " FROM entity "
        " WHERE itemID in (%s)", ids.c_str()))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    //this is pretty hackish... will NOT work if they mix things...
    //this was only put in to deal with "new" statics, like corporations.
    if(!res.GetRow(row)) {
        if(!sDatabase.RunQuery(res,
            "SELECT "
            " ownerID,ownerName,typeID,"
            " NULL as ownerNameID,"
            " 0 as gender"
            " FROM eveStaticOwners "
            " WHERE ownerID in (%s)", ids.c_str()))
        {
            codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
            return NULL;
        }
    } else {
        res.Reset();
    }

    if(!res.GetRow(row)) {
        if(!sDatabase.RunQuery(res,
            "SELECT "
            " characterID as ownerID,"
            " itemName as ownerName,"
            " typeID,"
            " NULL as ownerNameID,"
            " 0 as gender"
            " FROM character_ "
            " LEFT JOIN entity ON characterID = itemID"
            " WHERE characterID in (%s)", ids.c_str()))
        {
            codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
            return NULL;
        }
    } else {
        res.Reset();
    }

    return(DBResultToTupleSet(res));
}
Example #24
0
bool ServiceDB::GetStationInfo(uint32 stationID, uint32 *systemID, uint32 *constellationID, uint32 *regionID, GPoint *position, GPoint *dockPosition, GVector *dockOrientation) {
    if(       systemID == NULL
        && constellationID == NULL
        && regionID == NULL
        && position == NULL
        && dockPosition == NULL
        && dockOrientation == NULL
    )
        return true;

    DBQueryResult res;
    if(!DBcore::RunQuery(res,
        "SELECT"
        " solarSystemID,"
        " constellationID,"
        " regionID,"
        " x, y, z,"
        " dockEntryX, dockEntryY, dockEntryZ,"
        " dockOrientationX, dockOrientationY, dockOrientationZ"
        " FROM staStations"
        " LEFT JOIN staStationTypes USING (stationTypeID)"
        " WHERE stationID = %u",
        stationID))
    {
        _log(DATABASE__ERROR, "Failed to query info for station %u: %s.", stationID, res.error.c_str());
        return false;
    }

    DBResultRow row;
    if(!res.GetRow(row)) {
        _log(DATABASE__ERROR, "Failed to query info for station %u: Station not found.", stationID);
        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)
        );
    if(dockPosition != NULL)
        *dockPosition = GPoint(
            row.GetDouble(3) + row.GetDouble(6),
            row.GetDouble(4) + row.GetDouble(7),
            row.GetDouble(5) + row.GetDouble(8)
        );
    if(dockOrientation != NULL) {
        *dockOrientation = GVector(
            row.GetDouble(9),
            row.GetDouble(10),
            row.GetDouble(11)
        );
        // as it's direction, it should be normalized
        //dockOrientation->normalize();
    }

    return true;
}
void MEffect::_Populate(uint32 effectID)
{
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetDgmEffects(effectID, *res);

    // First, get all general info on this effectID from the dgmEffects table:
    DBResultRow row1;
    if( !res->GetRow(row1) )
        sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffects' table", effectID);
    else
    {
        //get all the data from the query
        m_EffectID = effectID;
        m_EffectName = row1.GetText(0);
        m_EffectCategory = row1.GetInt(1);
        m_PreExpression = row1.GetInt(2);
        m_PostExpression = row1.GetInt(3);
        if( !row1.IsNull(4) )
            m_Description = row1.GetText(4);
        if( !row1.IsNull(5) )
            m_Guid = row1.GetText(5);
        if( !row1.IsNull(6) )
            m_IconID = row1.GetInt(6);
        m_IsOffensive = row1.GetInt(7);
        m_IsAssistance = row1.GetInt(8);
        if( !row1.IsNull(9) )
            m_DurationAttributeID = row1.GetInt(9);
        if( !row1.IsNull(10) )
            m_TrackingSpeedAttributeID = row1.GetInt(10);
        if( !row1.IsNull(11) )
            m_DischargeAttributeID = row1.GetInt(11);
        if( !row1.IsNull(12) )
            m_RangeAttributeID = row1.GetInt(12);
        if( !row1.IsNull(13) )
            m_FalloffAttributeID = row1.GetInt(13);
        if( !row1.IsNull(14) )
            m_DisallowAutoRepeat = row1.GetInt(14);
        m_Published = row1.GetInt(15);
        if( !row1.IsNull(16) )
            m_DisplayName = row1.GetText(16);
        m_IsWarpSafe = row1.GetInt(17);
        m_RangeChance = row1.GetInt(18);
        m_ElectronicChance = row1.GetInt(19);
        m_PropulsionChance = row1.GetInt(20);
        if( !row1.IsNull(21) )
            m_Distribution = row1.GetInt(21);
        if( !row1.IsNull(22) )
            m_SfxName = row1.GetText(22);
        if( !row1.IsNull(23) )
            m_NpcUsageChanceAttributeID = row1.GetInt(23);
        if( !row1.IsNull(24) )
            m_NpcActivationChanceAttributeID = row1.GetInt(24);
        if( !row1.IsNull(25) )
            m_FittingUsageChanceAttributeID = row1.GetInt(25);
    }

    // Next, get the info from the dgmEffectsInfo table:
    ModuleDB::GetDgmEffectsInfo(effectID, *res);

    DBResultRow row2;

    // Initialize the new tables
    m_TargetAttributeIDs = new int[res->GetRowCount()];
    m_SourceAttributeIDs = new int[res->GetRowCount()];
    m_CalculationTypeIDs = new int[res->GetRowCount()];
    m_ReverseCalculationTypeIDs = new int[res->GetRowCount()];
    m_EffectAppliedToTargetIDs = new int[res->GetRowCount()];
    m_EffectAppliedBehaviorIDs = new int[res->GetRowCount()];
    m_EffectApplicationTypeIDs = new int[res->GetRowCount()];
    m_TargetEquipmentTypeIDs = new int[res->GetRowCount()];
    m_StackingPenaltyAppliedIDs = new int[res->GetRowCount()];
    
	int count = 0;
    std::string targetGroupIDs;
    typeTargetGroupIDlist * TargetGroupIDs;

    while( res->GetRow(row2) )
    {
        m_TargetAttributeIDs[count] = row2.GetInt(0);
        m_SourceAttributeIDs[count] = row2.GetInt(1);
        m_CalculationTypeIDs[count] = row2.GetInt(2);
        m_ReverseCalculationTypeIDs[count] = row2.GetInt(3);
        m_EffectAppliedToTargetIDs[count] = row2.GetInt(4);
        m_EffectAppliedBehaviorIDs[count] = row2.GetInt(5);
        m_EffectApplicationTypeIDs[count] = row2.GetInt(6);
        m_TargetEquipmentTypeIDs[count] = row2.GetInt(7);
        targetGroupIDs = row2.GetText(8);
        m_StackingPenaltyAppliedIDs[count] = row2.GetInt(9);

        TargetGroupIDs = new typeTargetGroupIDlist;
        if( !(targetGroupIDs.empty()) )
        {
            int pos = 0;
            std::string tempString = "";
            std::vector<uint32>::iterator it;

			// WARNING!  This may be insufficient to properly detect and handle an EMPTY "" list of targetGroupIDs
            pos = targetGroupIDs.find_first_of(',');
            tempString = targetGroupIDs.substr(0,pos);

            while( (pos = targetGroupIDs.find_first_of(',')) )
            {
                tempString = targetGroupIDs.substr(0,pos);
                TargetGroupIDs->insert( it, (atoi(tempString.c_str())) );
            }

            m_TargetGroupIDlists.insert(std::pair<uint32, typeTargetGroupIDlist *>(count, TargetGroupIDs));
        }

        count++;
    }

    if( count == 0 )
	{
        ;//sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffectsInfo' table as the SQL query returned ZERO rows", effectID);
		m_EffectLoaded = false;
	}
	else
	{
		m_numOfIDs = count;

		// Finally, get the info for this effectID from the dgmEffectsActions table:
		ModuleDB::GetDgmEffectsActions(effectID, *res);

		DBResultRow row3;

		if( !(res->GetRow(row3)) )
		{
			;//sLog.Error("MEffect","Could not populate effect information for effectID: %u from 'dgmEffectsActions table", effectID);
		}
		else
		{
			m_EffectAppliedWhenID = row3.GetInt(0);
			m_NullifyOnlineEffectEnable = row3.GetInt(1);
			m_NullifiedOnlineEffectID = row3.GetInt(2);
		}

		m_EffectLoaded = true;
	}

    delete res;
    res = NULL;
}
Example #26
0
void MEffect::_Populate(uint32 effectID)
{
    DBQueryResult *res = new DBQueryResult();
    ModuleDB::GetDgmEffects(effectID, *res);

    // First, get all general info on this effectID from the dgmEffects table:
    DBResultRow row1;
    if( !res->GetRow(row1) )
        sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffects' table", effectID);
    else
    {
        //get all the data from the query
        m_EffectID = effectID;
        m_EffectName = row1.GetText(0);
		m_EffectCategory = row1.GetUInt(1);
        m_PreExpression = row1.GetUInt(2);
        m_PostExpression = row1.GetUInt(3);
        if( !row1.IsNull(4) )
            m_Description = row1.GetText(4);
        if( !row1.IsNull(5) )
            m_Guid = row1.GetText(5);
        if( !row1.IsNull(6) )
            m_IconID = row1.GetUInt(6);
        m_IsOffensive = row1.GetUInt(7);
        m_IsAssistance = row1.GetUInt(8);
        if( !row1.IsNull(9) )
            m_DurationAttributeID = row1.GetUInt(9);
        if( !row1.IsNull(10) )
            m_TrackingSpeedAttributeID = row1.GetUInt(10);
        if( !row1.IsNull(11) )
            m_DischargeAttributeID = row1.GetUInt(11);
        if( !row1.IsNull(12) )
            m_RangeAttributeID = row1.GetUInt(12);
        if( !row1.IsNull(13) )
            m_FalloffAttributeID = row1.GetUInt(13);
        if( !row1.IsNull(14) )
            m_DisallowAutoRepeat = row1.GetUInt(14);
        m_Published = row1.GetUInt(15);
        if( !row1.IsNull(16) )
            m_DisplayName = row1.GetText(16);
        m_IsWarpSafe = row1.GetUInt(17);
        m_RangeChance = row1.GetUInt(18);
        m_ElectronicChance = row1.GetUInt(19);
        m_PropulsionChance = row1.GetUInt(20);
        if( !row1.IsNull(21) )
            m_Distribution = row1.GetUInt(21);
        if( !row1.IsNull(22) )
            m_SfxName = row1.GetText(22);
        if( !row1.IsNull(23) )
            m_NpcUsageChanceAttributeID = row1.GetUInt(23);
        if( !row1.IsNull(24) )
            m_NpcActivationChanceAttributeID = row1.GetUInt(24);
        if( !row1.IsNull(25) )
            m_FittingUsageChanceAttributeID = row1.GetUInt(25);
    }

    // Next, get the info from the dgmEffectsInfo table:
    ModuleDB::GetDgmEffectsInfo(effectID, *res);

    DBResultRow row2;

    // Initialize the new tables
	if( res->GetRowCount() > 0 )
	{
		m_SourceAttributeIDs = new uint32[res->GetRowCount()];
		m_TargetAttributeIDs = new uint32[res->GetRowCount()];
		m_CalculationTypeIDs = new uint32[res->GetRowCount()];
		m_ReverseCalculationTypeIDs = new uint32[res->GetRowCount()];
		m_StackingPenaltyAppliedIDs = new uint32[res->GetRowCount()];
		m_EffectAppliedInStateIDs = new uint32[res->GetRowCount()];
		m_AffectingIDs = new uint32[res->GetRowCount()];
		m_AffectingTypes = new uint32[res->GetRowCount()];
		m_AffectedTypes = new uint32[res->GetRowCount()];

		int count = 0;
		std::string targetGroupIDs;
		typeTargetGroupIDlist * TargetGroupIDs;

		while( res->GetRow(row2) )
		{
			m_SourceAttributeIDs[count] = row2.GetUInt(0);
			m_TargetAttributeIDs[count] = row2.GetUInt(1);
			m_CalculationTypeIDs[count] = row2.GetUInt(2);
			m_Descriptions.insert(std::pair<uint32,std::string>(count,row2.GetText(3)));
			m_ReverseCalculationTypeIDs[count] = row2.GetUInt(4);
			targetGroupIDs = row2.GetText(5);
			m_StackingPenaltyAppliedIDs[count] = row2.GetUInt(6);
			m_EffectAppliedInStateIDs[count] = row2.GetUInt(7);
			m_AffectingIDs[count] = row2.GetUInt(8);
			m_AffectingTypes[count] = row2.GetUInt(9);
			m_AffectedTypes[count] = row2.GetUInt(10);

			TargetGroupIDs = new typeTargetGroupIDlist;
			if( !(targetGroupIDs.empty()) )
			{
				// targetGroupIDs string is not empty, so extract one number at a time until it is empty
				int pos = 0;
				std::string tempString = "";

				pos = targetGroupIDs.find_first_of(';');
				if( pos < 0 )
					pos = targetGroupIDs.length()-1;	// we did not find any ';' characters, so targetGroupIDs contains only one number
				tempString = targetGroupIDs.substr(0,pos);

				while( (pos = targetGroupIDs.find_first_of(';')) > 0 )
				{
					tempString = targetGroupIDs.substr(0,pos);
					TargetGroupIDs->insert(TargetGroupIDs->begin(), (atoi(tempString.c_str())));
					targetGroupIDs = targetGroupIDs.substr(pos+1,targetGroupIDs.length()-1);
				}

				// Get final number now that there are no more separators to find:
				if( !(targetGroupIDs.empty()) )
					TargetGroupIDs->insert(TargetGroupIDs->begin(), (atoi(targetGroupIDs.c_str())));

				m_TargetGroupIDlists.insert(std::pair<uint32, typeTargetGroupIDlist *>(count, TargetGroupIDs));
			}

			count++;
		}

		if( count == 0 )
		{
			;//sLog.Error("MEffect","Could not populate effect information for effectID: %u from the 'dgmEffectsInfo' table as the SQL query returned ZERO rows", effectID);
			m_EffectsInfoLoaded = false;
		}
		else
		{
			m_numOfIDs = count;
			m_EffectsInfoLoaded = true;
		}
	}
	else
		m_EffectsInfoLoaded = false;

	m_EffectLoaded = true;
    delete res;
    res = NULL;
}
Example #27
0
// Function: Query the 'channelChars' table for all channels subscribed to by the character specified by charID and
// return lists of parameters for all of those channels as well as a total channel count.
void LSCDB::GetChannelSubscriptions(uint32 charID, std::vector<unsigned long> & ids, std::vector<std::string> & names,
		std::vector<std::string> & MOTDs, std::vector<unsigned long> & ownerids, std::vector<std::string> & compkeys,
		std::vector<int> & memberless, std::vector<std::string> & passwords, std::vector<int> & maillists,
		std::vector<int> & cspas, std::vector<int> & temps, std::vector<int> & modes, int & channelCount)
{
	DBQueryResult res;

	// Cross-reference "channelchars" table with "channels" table using the charID
	// The result is a two column multi-row structure where each row is a channel
	// that the character (charID) is subscribed to where the channel ID is presented
	// in the first column and the display name of that channel in the second column
	if (!sDatabase.RunQuery(res,
		" SELECT "
		"	channelID, "
		"	displayName, "
		"   motd, "
		"   ownerID, "
		"   comparisonKey, "
		"   memberless, "
		"   password, "
		"   mailingList, "
		"   cspa, "
		"   temporary, "
		"   mode "
		" FROM channels "
		" WHERE channelID = ANY ("
		"   SELECT channelID FROM channelChars WHERE charID = %u )", charID))
	{
		codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
		return;
	}

	DBResultRow row;
	int rowCount = 0;

	// Traverse through all rows in the query result and copy the IDs and displayNames to the
	// "ids" and "names" vectors for return to the calling function:
	while(res.GetRow(row))
	{
		++rowCount;

		ids.push_back(row.GetUInt(0));
		names.push_back((row.GetText(1) == NULL ? "" : row.GetText(1)));	// empty displayName field in channels table row returns NULL, so fill this string with "" in that case
		MOTDs.push_back((row.GetText(2) == NULL ? "" : row.GetText(2)));	// empty motd field in channels table row returns NULL, so fill this string with "" in that case
		ownerids.push_back(row.GetUInt(3));
		compkeys.push_back((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.push_back(row.GetUInt(5));
		passwords.push_back((row.GetText(6) == NULL ? "" : row.GetText(6)));	// empty password field in channels table row returns NULL, so fill this string with "" in that case
		maillists.push_back(row.GetUInt(7));
		cspas.push_back(row.GetUInt(8));
		temps.push_back(row.GetUInt(9));
		modes.push_back(row.GetUInt(10));
	}

	if (rowCount == 0) {
		_log(SERVICE__ERROR, "CharID %u isn't present in the database", charID);
		return;
	}

	channelCount = rowCount;
}
Example #28
0
PyRep *ConfigDB::GetCelestialStatistic(uint32 celestialID) {
    DBQueryResult res;
    DBResultRow row;

    if (!sDatabase.RunQuery(res,
        " SELECT "
        " groupID "
        " FROM evenames "
        " WHERE itemID = %u ", celestialID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    if (!res.GetRow(row)) {
        codelog(SERVICE__ERROR, "Unable to find celestial object %u", celestialID);
        return NULL;
    }
    uint32 groupID = row.GetUInt(0);

    std::string query = "";

    switch (groupID) {
    case EVEDB::invGroups::Sun:
            query = " SELECT "
                    "    temperature, "
                    "    spectralClass, "
                    "    luminosity, "
                    "    age, "
                    "    radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Planet:
            query = " SELECT "
                    "     temperature, "
                    "    orbitRadius, "
                    "    eccentricity, "
                    "    massDust, "
                    "    density, "
                    "    surfaceGravity, "
                    "    escapeVelocity, "
                    "    orbitPeriod, "
                    "    pressure, "
                    "    radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Moon:
            query = " SELECT "
                    "    temperature, "
                    "    orbitRadius, "
                    "    massDust, "
                    "    density, "
                    "    surfaceGravity, "
                    "    escapeVelocity, "
                    "    orbitPeriod, "
                    "    pressure, "
                    "    radius "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;
    case EVEDB::invGroups::Asteroid_Belt:
            query = " SELECT "
                    "    orbitRadius, "
                    "    eccentricity, "
                    "    massDust, "
                    "    density, "
                    "    orbitPeriod "
                    " FROM mapCelestialStatistics "
                    " WHERE celestialID = %u ";
            break;

    default:
            codelog(SERVICE__ERROR, "Invalid object groupID (%u) for %u", groupID, celestialID);
            return (NULL);
    }

    if (!sDatabase.RunQuery(res, query.c_str(), celestialID))
    {
        codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str());
        return NULL;
    }

    return DBResultToCRowset(res);
}
Example #29
0
PyRep *SearchDB::QuickQuery(std::string match, std::vector<int> *SearchID) {
    DBQueryResult     res; 
    DBResultRow       row;
    uint32            i, size;
    std::stringstream st;
    std::stringstream supplement;
    std::string       query      = "";
    std::string       equal      = "";
    std::string       matchEsc   = "";

    //SearchIDs are :
    // 1 : agent
    // 2 : character
    // 3 : corporation
    // 4 : alliance
    // 5 : faction
    // 6 : constellation
    // 7 : solar system
    // 8 : region
    // 9 : station

    // Find out if search is exact or not and remove the trailing '*'
    std::size_t found=match.find('*');
    if (found!=std::string::npos) {
      match.erase (std::remove(match.begin(), match.end(), '*'), match.end());
      equal = " RLIKE ";
    } else {
      equal = " = ";
    }


    // If the SearchID is for character we must filter out agents
    size = SearchID->size();
    if ((size == 1) && (SearchID->at(0)) == 2){
        supplement << "AND itemId >= ";
        supplement << EVEMU_MINIMUM_ID;
    }

    // Transform SearchId in groupID to search the rights typeIDs
    int transform[9] = {1,1,2,32,19,4,5,3,15};
    for(i=0; i<size; i++)
    {
        st << transform[SearchID->at(i)-1];
        if (i<(size-1))
            st << ", ";
    }
    
    // Escape the match string
    sDatabase.DoEscapeString(matchEsc, match.c_str());

    //Form the query and execute it
    query = "SELECT itemID,itemName FROM entity"
            " WHERE itemName RLIKE '%s' %s"
            " AND typeID in (SELECT typeID FROM invTypes LEFT JOIN invGroups ON invTypes.groupid = invGroups.groupID"
            " WHERE invGroups.groupID IN (%s))"
            " ORDER BY itemName";


    _log(SERVICE__MESSAGE, query.c_str(), matchEsc.c_str(), supplement.str().c_str() ,st.str().c_str());

    if(!sDatabase.RunQuery(res,query.c_str(), matchEsc.c_str(), supplement.str().c_str() , st.str().c_str() ))
    {
        _log(SERVICE__ERROR, "Error in LookupChars query: %s", res.error.c_str());
        return NULL;
    }

    // The cliant wants a List if Ids in return
    PyList *result = new PyList();
    while( res.GetRow( row ) ){
        result->AddItem( new PyInt(row.GetUInt(0) ));
    }

    return result;


}
Example #30
0
bool AttributeMap::Load()
{
    /* First, we load default attributes values using existing attribute system */
    DgmTypeAttributeSet *attr_set = sDgmTypeAttrMgr.GetDmgTypeAttributeSet( mItem.typeID() );
    if (attr_set == NULL)
        return false;

    DgmTypeAttributeSet::AttrSetItr itr = attr_set->attributeset.begin();

    for (; itr != attr_set->attributeset.end(); itr++)
        SetAttribute((*itr)->attributeID, (*itr)->number, false);

    /* Then we load the saved attributes from the db, if there are any yet, and overwrite the defaults */
    DBQueryResult res;

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

    DBResultRow row;

    int amount = res.GetRowCount();
    for (int i = 0; i < amount; i++)
    {
        EvilNumber attr_value;
        res.GetRow(row);
        uint32 attributeID = row.GetUInt(1);
        if (!row.IsNull(2))
            attr_value = row.GetInt64(2);
        else
            attr_value = row.GetDouble(3);
        SetAttribute(attributeID, attr_value, false);
    }

    return true;

/*
    /// EXISTING AttributeMap::Load() function
    DBQueryResult res;

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

    DBResultRow row;

    int amount = res.GetRowCount();

    // Right now, assume that we need to load all attributes with default values from dgmTypeAttributes table
    // IF AND ONLY IF the number of attributes pulled from the entity_attributes table for this item is ZERO:
    if( amount > 0 )
    {
        // This item was found in the 'entity_attributes' table, so load all attributes found there
        // into the Attribute Map for this item:
        for (int i = 0; i < amount; i++)
        {
            res.GetRow(row);
            EvilNumber attr_value;
            uint32 attributeID = row.GetUInt(1);
            if ( !row.IsNull(2) )
                attr_value = row.GetInt64(2);
            else if( !row.IsNull(3) )
                attr_value = row.GetDouble(3);
            else
                sLog.Error( "AttributeMap::Load()", "Both valueInt and valueFloat fields of this (itemID,attributeID) = (%u,%u) are NULL.", row.GetInt(0), attributeID );

            SetAttribute(attributeID, attr_value, false);
            //Add(attributeID, attr_value);
        }
    }
    else
    {
        // This item was NOT found in the 'entity_attributes' table, so let's assume that
        // this item was just created.
        // 1) Get complete list of attributes with default values from dgmTypeAttributes table using the item's typeID:
        DgmTypeAttributeSet *attr_set = sDgmTypeAttrMgr.GetDmgTypeAttributeSet( mItem.typeID() );
        if (attr_set == NULL)
            return false;

        DgmTypeAttributeSet::AttrSetItr itr = attr_set->attributeset.begin();

        // Store all these attributes to the item's AttributeMap
        for (; itr != attr_set->attributeset.end(); itr++)
        {
            SetAttribute((*itr)->attributeID, (*itr)->number, false);
            //Add((*itr)->attributeID, (*itr)->number);
        }

        // 2) Save these newly created and loaded attributes to the 'entity_attributes' table
        SaveAttributes();
    }

    return true;
*/
}