Recipe.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <assert.h>
  17. #include "../../common/debug.h"
  18. #include "../../common/Log.h"
  19. #include "../../common/database.h"
  20. #include "Recipe.h"
  21. #include "../../common/ConfigReader.h"
  22. #include "../Items/Items.h"
  23. extern ConfigReader configReader;
  24. extern MasterItemList master_item_list;
  25. Recipe::Recipe() {
  26. id = 0;
  27. book_id = 0;
  28. memset(name, 0, sizeof(name));
  29. memset(book_name, 0, sizeof(book_name));
  30. memset(book, 0, sizeof(book));
  31. memset(device, 0, sizeof(device));
  32. level = 0;
  33. tier = 0;
  34. icon = 0;
  35. skill = 0;
  36. technique = 0;
  37. knowledge = 0;
  38. classes = 0;
  39. unknown2 = 0;
  40. unknown3 = 0;
  41. unknown4 = 0;
  42. }
  43. Recipe::~Recipe() {
  44. map<int8, RecipeProducts*>::iterator itr;
  45. for (itr = products.begin(); itr != products.end(); itr++)
  46. safe_delete(itr->second);
  47. }
  48. Recipe::Recipe(Recipe *in){
  49. assert(in);
  50. id = in->GetID();
  51. book_id = in->GetBookID();
  52. strncpy(name, in->GetName(), sizeof(name));
  53. strncpy(book_name, in->GetBookName(), sizeof(book_name));
  54. strncpy(book, in->GetBook(), sizeof(book));
  55. strncpy(device, in->GetDevice(), sizeof(device));
  56. strncpy(product_name, in->product_name, sizeof(product_name));
  57. strncpy(primary_build_comp_title, in->primary_build_comp_title, sizeof(primary_build_comp_title));
  58. strncpy(build1_comp_title, in->build1_comp_title, sizeof(build1_comp_title));
  59. strncpy(build2_comp_title, in->build2_comp_title, sizeof(build2_comp_title));
  60. strncpy(build3_comp_title, in->build3_comp_title, sizeof(build3_comp_title));
  61. strncpy(build4_comp_title, in->build4_comp_title, sizeof(build4_comp_title));
  62. level = in->GetLevel();
  63. tier = in->GetTier();
  64. icon = in->GetIcon();
  65. skill = in->GetSkill();
  66. technique = in->GetTechnique();
  67. knowledge = in->GetKnowledge();
  68. classes = in->GetClasses();
  69. device_sub_type = in-> GetDevice_Sub_Type();
  70. unknown2 = in->GetUnknown2();
  71. unknown3 = in->GetUnknown3();
  72. unknown4 = in->GetUnknown4();
  73. }
  74. MasterRecipeList::MasterRecipeList() {
  75. m_recipes.SetName("MasterRecipeList::recipes");
  76. }
  77. MasterRecipeList::~MasterRecipeList() {
  78. ClearRecipes();
  79. }
  80. bool MasterRecipeList::AddRecipe(Recipe *recipe) {
  81. bool ret = false;
  82. int32 id;
  83. assert(recipe);
  84. id = recipe->GetID();
  85. m_recipes.writelock(__FUNCTION__, __LINE__);
  86. if (recipes.count(id) == 0) {
  87. recipes[id] = recipe;
  88. ret = true;
  89. }
  90. m_recipes.releasewritelock(__FUNCTION__, __LINE__);
  91. return ret;
  92. }
  93. Recipe * MasterRecipeList::GetRecipe(int32 recipe_id) {
  94. Recipe *ret = 0;
  95. m_recipes.readlock(__FUNCTION__, __LINE__);
  96. if (recipes.count(recipe_id) > 0)
  97. ret = recipes[recipe_id];
  98. m_recipes.releasereadlock(__FUNCTION__, __LINE__);
  99. return ret;
  100. }
  101. Recipe* MasterRecipeList::GetRecipeByName(const char* name) {
  102. Recipe* ret = 0;
  103. map<int32, Recipe*>::iterator itr;
  104. m_recipes.readlock(__FUNCTION__, __LINE__);
  105. for (itr = recipes.begin(); itr != recipes.end(); itr++) {
  106. if (::ToLower(string(name)) == ::ToLower(string(itr->second->GetName()))) {
  107. ret = itr->second;
  108. break;
  109. }
  110. }
  111. m_recipes.releasereadlock(__FUNCTION__, __LINE__);
  112. return ret;
  113. }
  114. void MasterRecipeList::ClearRecipes() {
  115. map<int32, Recipe *>::iterator itr;
  116. m_recipes.writelock(__FUNCTION__, __LINE__);
  117. for (itr = recipes.begin(); itr != recipes.end(); itr++)
  118. safe_delete(itr->second);
  119. recipes.clear();
  120. m_recipes.releasewritelock(__FUNCTION__, __LINE__);
  121. }
  122. int32 MasterRecipeList::Size() {
  123. int32 ret;
  124. m_recipes.readlock(__FUNCTION__, __LINE__);
  125. ret = (int32)recipes.size();
  126. m_recipes.releasereadlock(__FUNCTION__, __LINE__);
  127. return ret;
  128. }
  129. vector<Recipe*> MasterRecipeList::GetRecipes(const char* book_name) {
  130. vector<Recipe*> ret;
  131. map<int32, Recipe *>::iterator itr;
  132. m_recipes.writelock(__FUNCTION__, __LINE__);
  133. for (itr = recipes.begin(); itr != recipes.end(); itr++) {
  134. if (::ToLower(string(book_name)) == ::ToLower(string(itr->second->GetBook())))
  135. ret.push_back(itr->second);
  136. }
  137. m_recipes.releasewritelock(__FUNCTION__, __LINE__);
  138. return ret;
  139. }
  140. PlayerRecipeList::PlayerRecipeList(){
  141. }
  142. PlayerRecipeList::~PlayerRecipeList(){
  143. ClearRecipes();
  144. }
  145. bool PlayerRecipeList::AddRecipe(Recipe *recipe){
  146. std::unique_lock lock(player_recipe_mutex);
  147. assert(recipe);
  148. if(recipes.count(recipe->GetID()) == 0){
  149. recipes[recipe->GetID()] = recipe;
  150. return true;
  151. }
  152. return false;
  153. }
  154. Recipe * PlayerRecipeList::GetRecipe(int32 recipe_id){
  155. std::shared_lock lock(player_recipe_mutex);
  156. if (recipes.count(recipe_id) > 0)
  157. return recipes[recipe_id];
  158. return 0;
  159. }
  160. void PlayerRecipeList::ClearRecipes(){
  161. std::unique_lock lock(player_recipe_mutex);
  162. map<int32, Recipe *>::iterator itr;
  163. for (itr = recipes.begin(); itr != recipes.end(); itr++)
  164. safe_delete(itr->second);
  165. recipes.clear();
  166. }
  167. bool PlayerRecipeList::RemoveRecipe(int32 recipe_id) {
  168. std::unique_lock lock(player_recipe_mutex);
  169. bool ret = false;
  170. if (recipes.count(recipe_id) > 0) {
  171. recipes.erase(recipe_id);
  172. ret = true;
  173. }
  174. return ret;
  175. }
  176. MasterRecipeBookList::MasterRecipeBookList(){
  177. m_recipeBooks.SetName("MasterRecipeBookList::recipeBooks");
  178. }
  179. MasterRecipeBookList::~MasterRecipeBookList(){
  180. ClearRecipeBooks();
  181. }
  182. bool MasterRecipeBookList::AddRecipeBook(Recipe *recipe){
  183. bool ret = false;
  184. int32 id = 0;
  185. assert(recipe);
  186. id = recipe->GetBookID();
  187. m_recipeBooks.writelock(__FUNCTION__, __LINE__);
  188. if(recipeBooks.count(id) == 0){
  189. recipeBooks[id] = recipe;
  190. ret = true;
  191. }
  192. m_recipeBooks.releasewritelock(__FUNCTION__, __LINE__);
  193. return ret;
  194. }
  195. Recipe * MasterRecipeBookList::GetRecipeBooks(int32 recipebook_id){
  196. Recipe *ret = 0;
  197. m_recipeBooks.readlock(__FUNCTION__, __LINE__);
  198. if (recipeBooks.count(recipebook_id) > 0)
  199. ret = recipeBooks[recipebook_id];
  200. m_recipeBooks.releasereadlock(__FUNCTION__, __LINE__);
  201. return ret;
  202. }
  203. void MasterRecipeBookList::ClearRecipeBooks(){
  204. map<int32, Recipe *>::iterator itr;
  205. m_recipeBooks.writelock(__FUNCTION__, __LINE__);
  206. for (itr = recipeBooks.begin(); itr != recipeBooks.end(); itr++)
  207. safe_delete(itr->second);
  208. recipeBooks.clear();
  209. m_recipeBooks.releasewritelock(__FUNCTION__, __LINE__);
  210. }
  211. int32 MasterRecipeBookList::Size(){
  212. int32 ret = 0;
  213. m_recipeBooks.readlock(__FUNCTION__, __LINE__);
  214. ret = (int32)recipeBooks.size();
  215. m_recipeBooks.releasereadlock(__FUNCTION__, __LINE__);
  216. return ret;
  217. }
  218. EQ2Packet* MasterRecipeList::GetRecipePacket(int32 recipe_id, Client* client, bool display, int8 packet_type){
  219. Recipe *recipe = GetRecipe(recipe_id);
  220. if(recipe){
  221. LogWrite(TRADESKILL__DEBUG, 5, "Recipes", "Recipe ID: %u Recipe Name: %s", recipe->GetID(), recipe->GetName());
  222. return recipe->SerializeRecipe(client, recipe, display, packet_type);
  223. }
  224. return 0;
  225. }
  226. PlayerRecipeBookList::PlayerRecipeBookList(){
  227. }
  228. PlayerRecipeBookList::~PlayerRecipeBookList(){
  229. ClearRecipeBooks();
  230. }
  231. bool PlayerRecipeBookList::AddRecipeBook(Recipe *recipe){
  232. assert(recipe);
  233. if(recipeBooks.count(recipe->GetBookID()) == 0){
  234. recipeBooks[recipe->GetBookID()] = recipe;
  235. return true;
  236. }
  237. return false;
  238. }
  239. Recipe * PlayerRecipeBookList::GetRecipeBook(int32 recipebook_id){
  240. if(recipeBooks.count(recipebook_id) > 0)
  241. return recipeBooks[recipebook_id];
  242. return 0;
  243. }
  244. bool PlayerRecipeBookList::HasRecipeBook(int32 book_id) {
  245. if (recipeBooks.count(book_id) > 0)
  246. return true;
  247. return false;
  248. }
  249. void PlayerRecipeBookList::ClearRecipeBooks(){
  250. map<int32, Recipe*>::iterator itr;
  251. for(itr = recipeBooks.begin(); itr != recipeBooks.end(); itr++)
  252. safe_delete(itr->second);
  253. recipeBooks.clear();
  254. }
  255. EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display, int8 packet_type, int8 subpacket_type, const char *struct_name){
  256. int16 version = 1;
  257. Item* item = 0;
  258. RecipeProducts* rp = 0;
  259. vector<int32>::iterator itr;
  260. vector<RecipeComp> comp_list;
  261. int8 i = 0;
  262. int32 firstID = 0;
  263. int32 primary_comp_id = 0;
  264. if(client)
  265. version = client->GetVersion();
  266. if(!struct_name)
  267. struct_name = "WS_ExamineRecipeInfo";
  268. PacketStruct *packet = configReader.getStruct(struct_name, version);
  269. if(display)
  270. packet->setSubstructDataByName("info_header", "show_name", 1);
  271. else
  272. packet->setSubstructDataByName("info_header", "show_popup", 1);
  273. if(packet_type > 0)
  274. packet->setSubstructDataByName("info_header", "packettype", GetItemPacketType(packet->GetVersion()));
  275. else
  276. if(version == 1096)
  277. packet->setSubstructDataByName("info_header", "packettype",0x35FE);
  278. if (version == 1208)
  279. packet->setSubstructDataByName("info_header", "packettype", 0x45FE);
  280. if(version >= 57048)
  281. packet->setSubstructDataByName("info_header", "packettype",0x48FE);
  282. if(subpacket_type == 0)
  283. subpacket_type = 0x02;
  284. packet->setSubstructDataByName("info_header", "packetsubtype", subpacket_type);
  285. packet->setSubstructDataByName("recipe_info", "id", recipe->GetID());
  286. packet->setSubstructDataByName("recipe_info", "unknown", 3);
  287. packet->setSubstructDataByName("recipe_info", "level", recipe->GetLevel());
  288. packet->setSubstructDataByName("recipe_info", "technique", recipe->GetTechnique());
  289. packet->setSubstructDataByName("recipe_info", "skill_level", 50); //50
  290. packet->setSubstructDataByName("recipe_info", "knowledge", recipe->GetKnowledge());
  291. packet->setSubstructDataByName("recipe_info", "device", recipe->GetDevice());
  292. packet->setSubstructDataByName("recipe_info", "icon", recipe->GetIcon());
  293. packet->setSubstructDataByName("recipe_info", "unknown3", 1);
  294. packet->setSubstructDataByName("recipe_info", "adventure_id", 0xFF);
  295. packet->setSubstructDataByName("recipe_info", "tradeskill_id", client ? client->GetPlayer()->GetTradeskillClass() : 0);
  296. packet->setSubstructDataByName("recipe_info", "unknown4a", 100);
  297. packet->setSubstructDataByName("recipe_info", "unknown4aa", 1);
  298. packet->setSubstructDataByName("recipe_info", "unknown5a", 20);//level *10
  299. packet->setSubstructDataByName("recipe_info", "product_classes", recipe->GetClasses());
  300. int32 HS = 0;
  301. if (client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID()) == NULL)
  302. HS = 0;
  303. else
  304. HS = client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID())->highestStage;
  305. packet->setSubstructDataByName("recipe_info", "show_previous", HS);// recipe->highestStage);
  306. rp = recipe->products[1];
  307. if (rp->product_id > 0) {
  308. item = 0;
  309. item = master_item_list.GetItem(rp->product_id);
  310. if (item) {
  311. packet->setSubstructDataByName("recipe_info", "previous1_icon", item->details.icon);
  312. packet->setSubstructDataByName("recipe_info", "previous1_name", "previous1_name");
  313. packet->setSubstructDataByName("recipe_info", "previous1_qty", recipe->products[1]->product_qty);
  314. packet->setSubstructDataByName("recipe_info", "previous1_item_id", recipe->products[1]->product_id);
  315. packet->setSubstructDataByName("recipe_info", "previous1_item_crc", -853046774);
  316. packet->setSubstructDataByName("recipe_info", "firstbar_icon", item->details.icon);
  317. packet->setSubstructDataByName("recipe_info", "firstbar_name", "firstbar_name");
  318. packet->setSubstructDataByName("recipe_info", "firstbar_qty", recipe->products[1]->product_qty);
  319. packet->setSubstructDataByName("recipe_info", "firstbar_item_id", recipe->products[2]->product_id);
  320. packet->setSubstructDataByName("recipe_info", "firstbar_item_crc", -853046774);
  321. }
  322. }
  323. rp = recipe->products[2];
  324. if (rp->product_id > 0) {
  325. item = 0;
  326. item = master_item_list.GetItem(rp->product_id);
  327. if (item) {
  328. packet->setSubstructDataByName("recipe_info", "previous2_icon", item->details.icon);
  329. packet->setSubstructDataByName("recipe_info", "previous2_name", "previous2_name");
  330. packet->setSubstructDataByName("recipe_info", "previous2_qty", recipe->products[2]->product_qty);
  331. packet->setSubstructDataByName("recipe_info", "previous2_item_id", recipe->products[2]->product_id);
  332. packet->setSubstructDataByName("recipe_info", "previous2_item_crc", -853046774);
  333. packet->setSubstructDataByName("recipe_info", "secondbar_icon", item->details.icon);
  334. packet->setSubstructDataByName("recipe_info", "secondbar_name", "secondbar_name");
  335. packet->setSubstructDataByName("recipe_info", "secondbar_qty", recipe->products[2]->product_qty);
  336. packet->setSubstructDataByName("recipe_info", "secondbar_item_id", recipe->products[2]->product_id);
  337. packet->setSubstructDataByName("recipe_info", "secondbar_item_crc", -853046774);
  338. }
  339. }
  340. rp = recipe->products[3];
  341. if (rp->product_id > 0) {
  342. item = 0;
  343. item = master_item_list.GetItem(rp->product_id);
  344. if (item) {
  345. packet->setSubstructDataByName("recipe_info", "previous3_icon", item->details.icon);
  346. packet->setSubstructDataByName("recipe_info", "previous3_name", "previous3_name");
  347. packet->setSubstructDataByName("recipe_info", "previous3_qty", recipe->products[3]->product_qty);
  348. packet->setSubstructDataByName("recipe_info", "previous3_item_id", recipe->products[3]->product_id);
  349. packet->setSubstructDataByName("recipe_info", "previous3_item_crc", -853046774);
  350. packet->setSubstructDataByName("recipe_info", "thirdbar_icon", item->details.icon);
  351. packet->setSubstructDataByName("recipe_info", "thirdbar_name", "thirdbar_name");
  352. packet->setSubstructDataByName("recipe_info", "thirdbar_qty", recipe->products[3]->product_qty);
  353. packet->setSubstructDataByName("recipe_info", "thirdbar_item_id", recipe->products[3]->product_id);
  354. packet->setSubstructDataByName("recipe_info", "thirdbar_item_crc", -2065846136);
  355. }
  356. }
  357. //item = master_item_list.GetItemByName(recipe->GetName());// TODO: MJ we should be getting item by item number in case of multiple items with same name
  358. item = master_item_list.GetItem(recipe->GetProductID());
  359. if(item) {
  360. packet->setSubstructDataByName("recipe_info", "product_icon", item->details.icon); //item->details.icon);
  361. packet->setSubstructDataByName("recipe_info", "product_name", item->name.c_str()); //item->name);
  362. packet->setSubstructDataByName("recipe_info", "product_qty", 1);
  363. packet->setSubstructDataByName("recipe_info", "product_item_id", item->details.item_id); //item->details.item_id);
  364. packet->setSubstructDataByName("recipe_info", "product_item_crc", 0); //item->details.item_crc);
  365. }
  366. rp = recipe->products[0];
  367. if (rp->byproduct_id > 0) {
  368. item = 0;
  369. item = master_item_list.GetItem(rp->byproduct_id);
  370. if (item) {
  371. packet->setSubstructDataByName("recipe_info", "byproduct_icon", item->details.icon);//11
  372. packet->setSubstructDataByName("recipe_info", "byproduct_id", item->details.item_id);
  373. }
  374. }
  375. rp = recipe->products[1];
  376. if (rp->product_id > 0) {
  377. item = 0;
  378. item = master_item_list.GetItem(rp->product_id);
  379. if (item) {
  380. packet->setSubstructDataByName("recipe_info", "byproduct_icon", item->details.icon);//11
  381. packet->setSubstructDataByName("recipe_info", "byproduct_id", item->details.item_id);
  382. }
  383. }
  384. item = 0;
  385. // Check to see if we have a primary component (slot = 0)
  386. vector<Item*> itemss;
  387. if (recipe->components.count(0) > 0) {
  388. int16 have_qty = 0;
  389. vector<int32> rc = recipe->components[0];
  390. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  391. item = master_item_list.GetItem(*itr);
  392. packet->setSubstructDataByName("recipe_info", "primary_comp", recipe->primary_build_comp_title);
  393. packet->setSubstructDataByName("recipe_info", "primary_qty", recipe->GetPrimaryComponentQuantity());
  394. item = 0;
  395. item = client->GetPlayer()->item_list.GetItemFromID((*itr));
  396. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  397. if (itemss.size() > 0) {
  398. int16 needed_qty = recipe->GetPrimaryComponentQuantity();
  399. for (int8 i = 0; i < itemss.size(); i++) {
  400. have_qty += itemss[i]->details.count;
  401. }
  402. }
  403. }
  404. packet->setSubstructDataByName("recipe_info", "primary_qty_avail", have_qty);
  405. }
  406. int8 total_build_components = 0;
  407. if (recipe->components.count(1) > 0)
  408. total_build_components++;
  409. if (recipe->components.count(2) > 0)
  410. total_build_components++;
  411. if (recipe->components.count(3) > 0)
  412. total_build_components++;
  413. if (recipe->components.count(4) > 0)
  414. total_build_components++;
  415. if (total_build_components > 0) {
  416. packet->setSubstructArrayLengthByName("recipe_info", "num_comps", total_build_components);
  417. for (int8 index = 0; index < 4; index++) {
  418. if (recipe->components.count(index + 1) == 0)
  419. continue;
  420. vector<int32> rc = recipe->components[index + 1];
  421. int16 have_qty = 0;
  422. string comp_title;
  423. int8 comp_qty;
  424. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  425. if (index == 0) {
  426. comp_title = recipe->build1_comp_title;
  427. comp_qty = recipe->build1_comp_qty;
  428. }
  429. else if (index == 1) {
  430. comp_title = recipe->build2_comp_title;
  431. comp_qty = recipe->build2_comp_qty;
  432. }
  433. else if (index == 2) {
  434. comp_title = recipe->build3_comp_title;
  435. comp_qty = recipe->build3_comp_qty;
  436. }
  437. else if (index == 3) {
  438. comp_title = recipe->build4_comp_title;
  439. comp_qty = recipe->build4_comp_qty;
  440. }
  441. item = master_item_list.GetItem(*itr);
  442. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  443. for (int8 j = 0; j < itemss.size(); j++) {
  444. have_qty += itemss[j]->details.count;
  445. }
  446. }
  447. packet->setArrayDataByName("build_comp", comp_title.c_str(), index);
  448. packet->setArrayDataByName("build_comp_qty", comp_qty, index);
  449. packet->setArrayDataByName("build_comp_qty_avail", have_qty, index);
  450. }
  451. }
  452. // Check to see if we have a fuel component (slot = 5)
  453. if (recipe->components.count(5) > 0) {
  454. vector<int32> rc = recipe->components[5];
  455. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  456. item = master_item_list.GetItem(*itr);
  457. packet->setSubstructDataByName("recipe_info", "fuel_comp", recipe->fuel_comp_title);
  458. packet->setSubstructDataByName("recipe_info", "fuel_comp_qty", recipe->fuel_comp_qty);
  459. item = 0;
  460. item = client->GetPlayer()->item_list.GetItemFromID((*itr));
  461. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  462. if (itemss.size() > 0) {
  463. int16 have_qty = 0;
  464. for (int8 i = 0; i < itemss.size(); i++) {
  465. have_qty += itemss[i]->details.count;
  466. }
  467. packet->setSubstructDataByName("recipe_info", "fuel_comp_qty_avail", have_qty);
  468. break;
  469. }
  470. }
  471. }
  472. packet->setSubstructDataByName("recipe_info", "build_comp_qty_avail_flag", 1);
  473. packet->setSubstructDataByName("recipe_info", "unknown6", 4, 0);
  474. packet->setSubstructDataByName("recipe_info", "min_product", 1);
  475. packet->setSubstructDataByName("recipe_info", "max_product", 1);
  476. packet->setSubstructDataByName("recipe_info", "available_flag", 4);
  477. packet->setSubstructDataByName("recipe_info", "not_commissionable", 1);
  478. packet->setSubstructDataByName("recipe_info", "recipe_name", recipe->GetName());
  479. packet->setSubstructDataByName("recipe_info", "recipe_description", recipe->GetDescription());
  480. //packet->PrintPacket();
  481. EQ2Packet* data = packet->serialize();
  482. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, data->pBuffer, data->size);
  483. safe_delete(packet);
  484. safe_delete(data);
  485. //DumpPacket(app);
  486. return app;
  487. }
  488. void Recipe::AddBuildComp(int32 itemID, int8 slot, bool preffered) {
  489. if (preffered)
  490. components[slot].insert(components[slot].begin(), itemID);
  491. else
  492. components[slot].push_back(itemID);
  493. }