Advertisement
NatedogServer

Check Lore Crafted items

Nov 28th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. bool Client::TradeskillLoreCheck(DBTradeskillRecipe_Struct *spec) {
  2.     uint8 conflicts = 0;
  3.     uint8 resolved = 0;
  4.    
  5.     //pull the list of components
  6.     std::string query = StringFormat("SELECT tre.item_id "
  7.         "FROM tradeskill_recipe_entries AS tre "
  8.         "WHERE tre.componentcount > 0 AND tre.recipe_id = %u",
  9.         spec->recipe_id);
  10.     auto results = database.QueryDatabase(query);
  11.     if (!results.Success()) {
  12.         return false; //Error in query
  13.     }
  14.     if (!results.RowCount()) {
  15.         return false; //no components..
  16.     }
  17.  
  18.     std::vector< std::pair<uint32, uint8> >::iterator itr;
  19.     const Item_Struct* item = nullptr;
  20.     const Item_Struct* item_comp = nullptr;
  21.  
  22.     itr = spec->onsuccess.begin();
  23.     while (itr != spec->onsuccess.end() && !spec->quest) {
  24.         item = database.GetItem(itr->first);
  25.         if (item && CheckLoreConflict(item)) { //This item is lore!
  26.             conflicts++;
  27.             for (auto row = results.begin(); row != results.end(); ++row) {
  28.                 //todo.. fix this shit..
  29.                 item_comp = database.GetItem(atoi(row[0]));
  30.                 if(atoi(row[0]) == item->ID) {
  31.                     resolved++; //Item crafted is lore but returned...
  32.                     break;
  33.                 }
  34.                 else if (item_comp && item_comp->LoreGroup > 0 && item_comp->LoreGroup == item->LoreGroup) {
  35.                     resolved++; //Item crafted is in a Loregroup but we are using that Loregroupitem to craft this shit
  36.                     break;
  37.                 }
  38.             }
  39.         }
  40.         ++itr;
  41.     }
  42.  
  43.     if (conflicts > resolved) {
  44.         Message_StringID(MT_Emote, TRADESKILL_LORE, item->Name);
  45.         return true;
  46.     }
  47.  
  48.     return false;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement