Recipe.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. assert(recipe);
  147. if(recipes.count(recipe->GetID()) == 0){
  148. recipes[recipe->GetID()] = recipe;
  149. return true;
  150. }
  151. return false;
  152. }
  153. Recipe * PlayerRecipeList::GetRecipe(int32 recipe_id){
  154. if (recipes.count(recipe_id) > 0)
  155. return recipes[recipe_id];
  156. return 0;
  157. }
  158. void PlayerRecipeList::ClearRecipes(){
  159. map<int32, Recipe *>::iterator itr;
  160. for (itr = recipes.begin(); itr != recipes.end(); itr++)
  161. safe_delete(itr->second);
  162. recipes.clear();
  163. }
  164. MasterRecipeBookList::MasterRecipeBookList(){
  165. m_recipeBooks.SetName("MasterRecipeBookList::recipeBooks");
  166. }
  167. MasterRecipeBookList::~MasterRecipeBookList(){
  168. ClearRecipeBooks();
  169. }
  170. bool MasterRecipeBookList::AddRecipeBook(Recipe *recipe){
  171. bool ret = false;
  172. int32 id = 0;
  173. assert(recipe);
  174. id = recipe->GetBookID();
  175. m_recipeBooks.writelock(__FUNCTION__, __LINE__);
  176. if(recipeBooks.count(id) == 0){
  177. recipeBooks[id] = recipe;
  178. ret = true;
  179. }
  180. m_recipeBooks.releasewritelock(__FUNCTION__, __LINE__);
  181. return ret;
  182. }
  183. Recipe * MasterRecipeBookList::GetRecipeBooks(int32 recipebook_id){
  184. Recipe *ret = 0;
  185. m_recipeBooks.readlock(__FUNCTION__, __LINE__);
  186. if (recipeBooks.count(recipebook_id) > 0)
  187. ret = recipeBooks[recipebook_id];
  188. m_recipeBooks.releasereadlock(__FUNCTION__, __LINE__);
  189. return ret;
  190. }
  191. void MasterRecipeBookList::ClearRecipeBooks(){
  192. map<int32, Recipe *>::iterator itr;
  193. m_recipeBooks.writelock(__FUNCTION__, __LINE__);
  194. for (itr = recipeBooks.begin(); itr != recipeBooks.end(); itr++)
  195. safe_delete(itr->second);
  196. recipeBooks.clear();
  197. m_recipeBooks.releasewritelock(__FUNCTION__, __LINE__);
  198. }
  199. int32 MasterRecipeBookList::Size(){
  200. int32 ret = 0;
  201. m_recipeBooks.readlock(__FUNCTION__, __LINE__);
  202. ret = (int32)recipeBooks.size();
  203. m_recipeBooks.releasereadlock(__FUNCTION__, __LINE__);
  204. return ret;
  205. }
  206. EQ2Packet* MasterRecipeList::GetRecipePacket(int32 recipe_id, Client* client, bool display, int8 packet_type){
  207. Recipe *recipe = GetRecipe(recipe_id);
  208. if(recipe){
  209. LogWrite(TRADESKILL__DEBUG, 5, "Recipes", "Recipe ID: %u Recipe Name: %s", recipe->GetID(), recipe->GetName());
  210. return recipe->SerializeRecipe(client, recipe, display, packet_type);
  211. }
  212. return 0;
  213. }
  214. PlayerRecipeBookList::PlayerRecipeBookList(){
  215. }
  216. PlayerRecipeBookList::~PlayerRecipeBookList(){
  217. ClearRecipeBooks();
  218. }
  219. bool PlayerRecipeBookList::AddRecipeBook(Recipe *recipe){
  220. assert(recipe);
  221. if(recipeBooks.count(recipe->GetBookID()) == 0){
  222. recipeBooks[recipe->GetBookID()] = recipe;
  223. return true;
  224. }
  225. return false;
  226. }
  227. Recipe * PlayerRecipeBookList::GetRecipeBook(int32 recipebook_id){
  228. if(recipeBooks.count(recipebook_id) > 0)
  229. return recipeBooks[recipebook_id];
  230. return 0;
  231. }
  232. bool PlayerRecipeBookList::HasRecipeBook(int32 book_id) {
  233. if (recipeBooks.count(book_id) > 0)
  234. return true;
  235. return false;
  236. }
  237. void PlayerRecipeBookList::ClearRecipeBooks(){
  238. map<int32, Recipe*>::iterator itr;
  239. for(itr = recipeBooks.begin(); itr != recipeBooks.end(); itr++)
  240. safe_delete(itr->second);
  241. recipeBooks.clear();
  242. }
  243. EQ2Packet * Recipe::SerializeRecipe(Client *client, Recipe *recipe, bool display, int8 packet_type, int8 subpacket_type, const char *struct_name){
  244. int16 version = 1;
  245. Item* item = 0;
  246. RecipeProducts* rp = 0;
  247. vector<int32>::iterator itr;
  248. vector<RecipeComp> comp_list;
  249. int8 i = 0;
  250. int32 firstID = 0;
  251. int32 primary_comp_id = 0;
  252. if(client)
  253. version = client->GetVersion();
  254. if(!struct_name)
  255. struct_name = "WS_ExamineRecipeInfo";
  256. PacketStruct *packet = configReader.getStruct(struct_name, version);
  257. if(display)
  258. packet->setSubstructDataByName("info_header", "show_name", 1);
  259. else
  260. packet->setSubstructDataByName("info_header", "show_popup", 1);
  261. if(packet_type > 0)
  262. packet->setSubstructDataByName("info_header", "packettype", GetItemPacketType(packet->GetVersion()));
  263. else
  264. if(version == 1096)
  265. packet->setSubstructDataByName("info_header", "packettype",0x35FE);
  266. if (version == 1208)
  267. packet->setSubstructDataByName("info_header", "packettype", 0x45FE);
  268. if(version >= 57048)
  269. packet->setSubstructDataByName("info_header", "packettype",0x48FE);
  270. if(subpacket_type == 0)
  271. subpacket_type = 0x02;
  272. packet->setSubstructDataByName("info_header", "packetsubtype", subpacket_type);
  273. packet->setSubstructDataByName("recipe_info", "id", recipe->GetID());
  274. packet->setSubstructDataByName("recipe_info", "unknown", 3);
  275. packet->setSubstructDataByName("recipe_info", "level", recipe->GetLevel());
  276. packet->setSubstructDataByName("recipe_info", "technique", recipe->GetTechnique());
  277. packet->setSubstructDataByName("recipe_info", "skill_level", 50); //50
  278. packet->setSubstructDataByName("recipe_info", "knowledge", recipe->GetKnowledge());
  279. packet->setSubstructDataByName("recipe_info", "device", recipe->GetDevice());
  280. packet->setSubstructDataByName("recipe_info", "icon", recipe->GetIcon());
  281. packet->setSubstructDataByName("recipe_info", "unknown3", 1);
  282. packet->setSubstructDataByName("recipe_info", "adventure_id", 0xFF);
  283. packet->setSubstructDataByName("recipe_info", "tradeskill_id", client ? client->GetPlayer()->GetTradeskillClass() : 0);
  284. packet->setSubstructDataByName("recipe_info", "unknown4a", 100);
  285. packet->setSubstructDataByName("recipe_info", "unknown4aa", 1);
  286. packet->setSubstructDataByName("recipe_info", "unknown5a", 20);//level *10
  287. packet->setSubstructDataByName("recipe_info", "product_classes", recipe->GetClasses());
  288. int32 HS = 0;
  289. if (client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID()) == NULL)
  290. HS = 0;
  291. else
  292. HS = client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID())->highestStage;
  293. packet->setSubstructDataByName("recipe_info", "show_previous", HS);// recipe->highestStage);
  294. rp = recipe->products[1];
  295. if (rp->product_id > 0) {
  296. item = 0;
  297. item = master_item_list.GetItem(rp->product_id);
  298. if (item) {
  299. packet->setSubstructDataByName("recipe_info", "previous1_icon", item->details.icon);
  300. packet->setSubstructDataByName("recipe_info", "previous1_name", "previous1_name");
  301. packet->setSubstructDataByName("recipe_info", "previous1_qty", recipe->products[1]->product_qty);
  302. packet->setSubstructDataByName("recipe_info", "previous1_item_id", recipe->products[1]->product_id);
  303. packet->setSubstructDataByName("recipe_info", "previous1_item_crc", -853046774);
  304. packet->setSubstructDataByName("recipe_info", "firstbar_icon", item->details.icon);
  305. packet->setSubstructDataByName("recipe_info", "firstbar_name", "firstbar_name");
  306. packet->setSubstructDataByName("recipe_info", "firstbar_qty", recipe->products[1]->product_qty);
  307. packet->setSubstructDataByName("recipe_info", "firstbar_item_id", recipe->products[2]->product_id);
  308. packet->setSubstructDataByName("recipe_info", "firstbar_item_crc", -853046774);
  309. }
  310. }
  311. rp = recipe->products[2];
  312. if (rp->product_id > 0) {
  313. item = 0;
  314. item = master_item_list.GetItem(rp->product_id);
  315. if (item) {
  316. packet->setSubstructDataByName("recipe_info", "previous2_icon", item->details.icon);
  317. packet->setSubstructDataByName("recipe_info", "previous2_name", "previous2_name");
  318. packet->setSubstructDataByName("recipe_info", "previous2_qty", recipe->products[2]->product_qty);
  319. packet->setSubstructDataByName("recipe_info", "previous2_item_id", recipe->products[2]->product_id);
  320. packet->setSubstructDataByName("recipe_info", "previous2_item_crc", -853046774);
  321. packet->setSubstructDataByName("recipe_info", "secondbar_icon", item->details.icon);
  322. packet->setSubstructDataByName("recipe_info", "secondbar_name", "secondbar_name");
  323. packet->setSubstructDataByName("recipe_info", "secondbar_qty", recipe->products[2]->product_qty);
  324. packet->setSubstructDataByName("recipe_info", "secondbar_item_id", recipe->products[2]->product_id);
  325. packet->setSubstructDataByName("recipe_info", "secondbar_item_crc", -853046774);
  326. }
  327. }
  328. rp = recipe->products[3];
  329. if (rp->product_id > 0) {
  330. item = 0;
  331. item = master_item_list.GetItem(rp->product_id);
  332. if (item) {
  333. packet->setSubstructDataByName("recipe_info", "previous3_icon", item->details.icon);
  334. packet->setSubstructDataByName("recipe_info", "previous3_name", "previous3_name");
  335. packet->setSubstructDataByName("recipe_info", "previous3_qty", recipe->products[3]->product_qty);
  336. packet->setSubstructDataByName("recipe_info", "previous3_item_id", recipe->products[3]->product_id);
  337. packet->setSubstructDataByName("recipe_info", "previous3_item_crc", -853046774);
  338. packet->setSubstructDataByName("recipe_info", "thirdbar_icon", item->details.icon);
  339. packet->setSubstructDataByName("recipe_info", "thirdbar_name", "thirdbar_name");
  340. packet->setSubstructDataByName("recipe_info", "thirdbar_qty", recipe->products[3]->product_qty);
  341. packet->setSubstructDataByName("recipe_info", "thirdbar_item_id", recipe->products[3]->product_id);
  342. packet->setSubstructDataByName("recipe_info", "thirdbar_item_crc", -2065846136);
  343. }
  344. }
  345. //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
  346. item = master_item_list.GetItem(recipe->GetProductID());
  347. if(item) {
  348. packet->setSubstructDataByName("recipe_info", "product_icon", item->details.icon); //item->details.icon);
  349. packet->setSubstructDataByName("recipe_info", "product_name", item->name.c_str()); //item->name);
  350. packet->setSubstructDataByName("recipe_info", "product_qty", 1);
  351. packet->setSubstructDataByName("recipe_info", "product_item_id", item->details.item_id); //item->details.item_id);
  352. packet->setSubstructDataByName("recipe_info", "product_item_crc", 0); //item->details.item_crc);
  353. }
  354. rp = recipe->products[0];
  355. if (rp->byproduct_id > 0) {
  356. item = 0;
  357. item = master_item_list.GetItem(rp->byproduct_id);
  358. if (item) {
  359. packet->setSubstructDataByName("recipe_info", "byproduct_icon", item->details.icon);//11
  360. packet->setSubstructDataByName("recipe_info", "byproduct_id", item->details.item_id);
  361. }
  362. }
  363. rp = recipe->products[1];
  364. if (rp->product_id > 0) {
  365. item = 0;
  366. item = master_item_list.GetItem(rp->product_id);
  367. if (item) {
  368. packet->setSubstructDataByName("recipe_info", "byproduct_icon", item->details.icon);//11
  369. packet->setSubstructDataByName("recipe_info", "byproduct_id", item->details.item_id);
  370. }
  371. }
  372. item = 0;
  373. // Check to see if we have a primary component (slot = 0)
  374. vector<Item*> itemss;
  375. if (recipe->components.count(0) > 0) {
  376. int16 have_qty = 0;
  377. vector<int32> rc = recipe->components[0];
  378. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  379. item = master_item_list.GetItem(*itr);
  380. packet->setSubstructDataByName("recipe_info", "primary_comp", recipe->primary_build_comp_title);
  381. packet->setSubstructDataByName("recipe_info", "primary_qty", recipe->GetPrimaryComponentQuantity());
  382. item = 0;
  383. item = client->GetPlayer()->item_list.GetItemFromID((*itr));
  384. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  385. if (itemss.size() > 0) {
  386. int16 needed_qty = recipe->GetPrimaryComponentQuantity();
  387. for (int8 i = 0; i < itemss.size(); i++) {
  388. have_qty += itemss[i]->details.count;
  389. }
  390. }
  391. }
  392. packet->setSubstructDataByName("recipe_info", "primary_qty_avail", have_qty);
  393. }
  394. int8 total_build_components = 0;
  395. if (recipe->components.count(1) > 0)
  396. total_build_components++;
  397. if (recipe->components.count(2) > 0)
  398. total_build_components++;
  399. if (recipe->components.count(3) > 0)
  400. total_build_components++;
  401. if (recipe->components.count(4) > 0)
  402. total_build_components++;
  403. if (total_build_components > 0) {
  404. packet->setSubstructArrayLengthByName("recipe_info", "num_comps", total_build_components);
  405. for (int8 index = 0; index < 4; index++) {
  406. if (recipe->components.count(index + 1) == 0)
  407. continue;
  408. vector<int32> rc = recipe->components[index + 1];
  409. int16 have_qty = 0;
  410. string comp_title;
  411. int8 comp_qty;
  412. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  413. if (index == 0) {
  414. comp_title = recipe->build1_comp_title;
  415. comp_qty = recipe->build1_comp_qty;
  416. }
  417. else if (index == 1) {
  418. comp_title = recipe->build2_comp_title;
  419. comp_qty = recipe->build2_comp_qty;
  420. }
  421. else if (index == 2) {
  422. comp_title = recipe->build3_comp_title;
  423. comp_qty = recipe->build3_comp_qty;
  424. }
  425. else if (index == 3) {
  426. comp_title = recipe->build4_comp_title;
  427. comp_qty = recipe->build4_comp_qty;
  428. }
  429. item = master_item_list.GetItem(*itr);
  430. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  431. for (int8 j = 0; j < itemss.size(); j++) {
  432. have_qty += itemss[j]->details.count;
  433. }
  434. }
  435. packet->setArrayDataByName("build_comp", comp_title.c_str(), index);
  436. packet->setArrayDataByName("build_comp_qty", comp_qty, index);
  437. packet->setArrayDataByName("build_comp_qty_avail", have_qty, index);
  438. }
  439. }
  440. // Check to see if we have a fuel component (slot = 5)
  441. if (recipe->components.count(5) > 0) {
  442. vector<int32> rc = recipe->components[5];
  443. for (itr = rc.begin(); itr != rc.end(); itr++, i++) {
  444. item = master_item_list.GetItem(*itr);
  445. packet->setSubstructDataByName("recipe_info", "fuel_comp", recipe->fuel_comp_title);
  446. packet->setSubstructDataByName("recipe_info", "fuel_comp_qty", recipe->fuel_comp_qty);
  447. item = 0;
  448. item = client->GetPlayer()->item_list.GetItemFromID((*itr));
  449. itemss = client->GetPlayer()->item_list.GetAllItemsFromID((*itr));
  450. if (itemss.size() > 0) {
  451. int16 have_qty = 0;
  452. for (int8 i = 0; i < itemss.size(); i++) {
  453. have_qty += itemss[i]->details.count;
  454. }
  455. packet->setSubstructDataByName("recipe_info", "fuel_comp_qty_avail", have_qty);
  456. break;
  457. }
  458. }
  459. }
  460. packet->setSubstructDataByName("recipe_info", "build_comp_qty_avail_flag", 1);
  461. packet->setSubstructDataByName("recipe_info", "unknown6", 4, 0);
  462. packet->setSubstructDataByName("recipe_info", "min_product", 1);
  463. packet->setSubstructDataByName("recipe_info", "max_product", 1);
  464. packet->setSubstructDataByName("recipe_info", "available_flag", 4);
  465. packet->setSubstructDataByName("recipe_info", "not_commissionable", 1);
  466. packet->setSubstructDataByName("recipe_info", "recipe_name", recipe->GetName());
  467. packet->setSubstructDataByName("recipe_info", "recipe_description", recipe->GetDescription());
  468. //packet->PrintPacket();
  469. EQ2Packet* data = packet->serialize();
  470. EQ2Packet* app = new EQ2Packet(OP_ClientCmdMsg, data->pBuffer, data->size);
  471. safe_delete(packet);
  472. safe_delete(data);
  473. //DumpPacket(app);
  474. return app;
  475. }
  476. void Recipe::AddBuildComp(int32 itemID, int8 slot, bool preffered) {
  477. if (preffered)
  478. components[slot].insert(components[slot].begin(), itemID);
  479. else
  480. components[slot].push_back(itemID);
  481. }