bool MailDB::CreateLabel(int characterID, Call_CreateLabel& args, uint32& newID) const { // we need to get the next free bit index; can't avoid a SELECT DBQueryResult res; sDatabase.RunQuery(res, "SELECT bit FROM mailLabel WHERE ownerID = %u ORDER BY bit DESC LIMIT 1", characterID); // 6 is a guessed default; there are some hardcoded labels that we don't have the details on yet int bit = 6; if (res.GetRowCount() > 0) { DBResultRow row; res.GetRow(row); // we want the next one, not the current one, so +1 bit = row.GetInt(0) + 1; } DBerror error; if (!sDatabase.RunQuery(error, "INSERT INTO mailLabel (bit, name, color, ownerID) VALUES (%u, '%s', %u, %u)", bit, args.name.c_str(), args.color, characterID)) { codelog(SERVICE__ERROR, "Failed to insert new mail label into database"); // since this is an out parameter, make sure we assign this even in case of an error newID = 0; return false; } // the client wants the power of 2, not the bitset index newID = (uint32)pow((float)2, bit); return true; }
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; }
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; }
PyString* MailDB::GetMailBody(int id) const { DBQueryResult res; if (!sDatabase.RunQuery(res, "SELECT body FROM mailMessage WHERE messageID = %u", id)) return NULL; if (res.GetRowCount() <= 0) return NULL; DBResultRow row; if (!res.GetRow(row) || row.IsNull(0)) return NULL; return new PyString(row.GetText(0), row.ColumnLength(0)); }
dgmtypeattributemgr::dgmtypeattributemgr() { // load shit from db DBQueryResult res; if( !DBcore::RunQuery( res, "SELECT * FROM dgmTypeAttributes ORDER BY typeID" ) ) { SysLog::Error("DgmTypeAttrMgr", "Error in db load query: %s", res.error.c_str()); return; } uint32 currentID = 0; DgmTypeAttributeSet * entry = NULL; DBResultRow row; int amount = res.GetRowCount(); for (int i = 0; i < amount; i++) { res.GetRow(row); uint32 typeID = row.GetUInt(0); if (currentID != typeID) { currentID = typeID; entry = new DgmTypeAttributeSet; mDgmTypeAttrInfo.insert(std::make_pair(currentID, entry)); } DgmTypeAttribute * attr_entry = new DgmTypeAttribute(); attr_entry->attributeID = row.GetUInt(1); if (row.IsNull(2) == true) { attr_entry->number = EvilNumber(row.GetFloat(3)); } else { attr_entry->number = EvilNumber(row.GetInt(2)); } entry->attributeset.push_back(attr_entry); } }
PyRep *MarketDB::GetOrders( uint32 regionID, uint32 typeID ) { DBQueryResult res; PyList* tup = new PyList(); /*DBColumnTypeMap colmap; colmap["volRemaining"] = DBTYPE_R8; colmap["price"] = DBTYPE_CY; colmap["issued"] = DBTYPE_FILETIME; colmap["orderID"] = DBTYPE_I4; colmap["volEntered"] = DBTYPE_I4; colmap["minVolume"] = DBTYPE_I4; colmap["stationID"] = DBTYPE_I4; colmap["regionID"] = DBTYPE_I4; colmap["solarSystemID"] = DBTYPE_I4; colmap["jumps"] = DBTYPE_I4; colmap["duration"] = DBTYPE_I2; colmap["typeID"] = DBTYPE_I2; colmap["range"] = DBTYPE_I2; colmap["bid"] = DBTYPE_BOOL; //ordering: (painstakingly determined from packets) DBColumnOrdering ordering; ordering.push_back("price"); ordering.push_back("volRemaining"); ordering.push_back("issued"); ordering.push_back("orderID"); ordering.push_back("volEntered"); ordering.push_back("minVolume"); ordering.push_back("stationID"); ordering.push_back("regionID"); ordering.push_back("solarSystemID"); ordering.push_back("jumps"); //not working right... ordering.push_back("typeID"); ordering.push_back("range"); ordering.push_back("duration"); ordering.push_back("bid");*/ //query sell orders //TODO: consider the `jumps` field... is it actually used? might be a pain in the ass if we need to actually populate it based on each queryier's location 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 regionID=%u AND typeID=%u AND bid=%d", regionID, typeID, TransactionTypeSell)) { codelog( MARKET__ERROR, "Error in query: %s", res.error.c_str() ); PyDecRef( tup ); return NULL; } sLog.Debug("MarketDB::GetOrders", "Fetched %d sell orders for type %d", res.GetRowCount(), typeID); //this is wrong. tup->AddItem( DBResultToCRowset( res ) ); //query buy orders 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 regionID=%u AND typeID=%u AND bid=%d", regionID, typeID, TransactionTypeBuy)) { codelog( MARKET__ERROR, "Error in query: %s", res.error.c_str() ); PyDecRef( tup ); return NULL; } sLog.Debug("MarketDB::GetOrders", "Fetched %d buy orders for type %d", res.GetRowCount(), typeID); //this is wrong. tup->AddItem( DBResultToCRowset( res ) ); return tup; }
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; }
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; */ }
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; }
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; }
void ShipBonusModifier::_Populate(uint32 shipID) { DBQueryResult *res = new DBQueryResult(); ModuleDB::GetDgmShipBonusModifiers(shipID, *res); DBResultRow row1; if( res->GetRowCount() == 0 ) { sLog.Error("ShipBonusModifier","Could not populate ship bonus modifier information for shipID: %u from the 'dgmShipBonusModifiers' table", shipID); m_ModifierLoaded = false; } else { m_EffectIDs = new uint32[res->GetRowCount()]; m_AttributeSkillIDs = new uint32[res->GetRowCount()]; 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_AppliedPerLevelList = 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(row1) ) { m_EffectIDs[count] = row1.GetUInt(0); m_AttributeSkillIDs[count] = row1.GetUInt(1); m_SourceAttributeIDs[count] = row1.GetUInt(2); m_TargetAttributeIDs[count] = row1.GetUInt(3); m_CalculationTypeIDs[count] = row1.GetUInt(4); m_Descriptions.insert(std::pair<uint32,std::string>(count,row1.GetText(5))); m_ReverseCalculationTypeIDs[count] = row1.GetUInt(6); targetGroupIDs = row1.GetText(7); m_AppliedPerLevelList[count] = row1.GetUInt(8); m_AffectingTypes[count] = row1.GetUInt(9); m_AffectedTypes[count] = row1.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("ShipBonusModifier","Could not populate bonus modifier information for shipID: %u from the 'dgmShipBonusModifiers' table as the SQL query returned ZERO rows", shipID); m_ModifierLoaded = false; } else { m_numOfIDs = count; m_ModifierLoaded = true; } } delete res; res = NULL; }