Tradeskills.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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 "Tradeskills.h"
  17. #include "../client.h"
  18. #include "../../common/ConfigReader.h"
  19. #include "../classes.h"
  20. //#include "../../common/debug.h"
  21. #include "../../common/Log.h"
  22. //#include "../zoneserver.h"
  23. //#include "../Skills.h"
  24. //#include "../classes.h"
  25. #include "../World.h"
  26. //#include "../LuaInterface.h"
  27. #include "../ClientPacketFunctions.h"
  28. #include "../WorldDatabase.h"
  29. #include "../Rules/Rules.h"
  30. extern Classes classes;
  31. extern ConfigReader configReader;
  32. extern MasterSkillList master_skill_list;
  33. extern MasterRecipeList master_recipe_list;
  34. extern MasterTradeskillEventsList master_tradeskillevent_list;
  35. extern WorldDatabase database;
  36. extern RuleManager rule_manager;
  37. TradeskillMgr::TradeskillMgr() {
  38. m_tradeskills.SetName("TradeskillMgr::tradeskillsList");
  39. // % chance for each was made up by me (Jabantiz) and may need some tweaking
  40. // 2% for crit fail
  41. m_success = rule_manager.GetGlobalRule(R_World, TradeskillSuccessChance)->GetFloat();
  42. m_critSuccess = rule_manager.GetGlobalRule(R_World, TradeskillCritSuccessChance)->GetFloat();
  43. m_fail = rule_manager.GetGlobalRule(R_World, TradeskillFailChance)->GetFloat();
  44. m_critFail = rule_manager.GetGlobalRule(R_World, TradeskillCritFailChance)->GetFloat();
  45. m_eventChance = rule_manager.GetGlobalRule(R_World, TradeskillEventChance)->GetFloat();
  46. if ((m_success + m_critSuccess + m_fail + m_critFail) != 100.0f) {
  47. LogWrite(TRADESKILL__ERROR, 0, "Tradeskills", "Success, crit success, fail, and crit fail MUST add up to 100, reverting to defaults...");
  48. m_success = 87.0f;
  49. m_critSuccess = 2.0f;
  50. m_fail = 10.0f;
  51. m_critFail = 1.0f;
  52. }
  53. }
  54. TradeskillMgr::~TradeskillMgr() {
  55. m_tradeskills.writelock(__FUNCTION__, __LINE__);
  56. map<Client*, Tradeskill*>::iterator itr;
  57. for (itr = tradeskillList.begin(); itr != tradeskillList.end(); itr++)
  58. safe_delete(itr->second);
  59. tradeskillList.clear();
  60. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  61. }
  62. void TradeskillMgr::Process() {
  63. m_tradeskills.writelock(__FUNCTION__, __LINE__);
  64. map<Client*, Tradeskill*>::iterator itr = tradeskillList.begin();
  65. while (itr != tradeskillList.end()) {
  66. Tradeskill* tradeskill = 0;
  67. tradeskill = itr->second;
  68. if (!tradeskill)
  69. continue;
  70. if (Timer::GetCurrentTime2() >= tradeskill->nextUpdateTime) {
  71. Client* client = itr->first;
  72. sint32 progress = 0;
  73. sint32 durability = 0;
  74. /*
  75. Following was grabbed from
  76. http://eq2.stratics.com/content/guides/padasher_crafting_2.php
  77. old but the base fail/succes should still be the same
  78. -100 Durability / -50 Progress (Critical Failure)
  79. -50 Durability / 0 Progress (Failure)
  80. -10 Durability / +50 Progress (Standard tick)
  81. +10 Durability / + 100 Progress (Critical Success)
  82. */
  83. float roll = MakeRandomFloat(0, 100);
  84. int8 effect = 0; //1 is critical success, 2 is success, 3 is failure, and 4 is critical failure.
  85. float success = m_success;
  86. float crit_success = m_critSuccess;
  87. float fail = m_fail;
  88. float crit_fail = m_critFail;
  89. // Modify the % chance for success based off of stats
  90. client->GetPlayer()->MStats.lock();
  91. fail -= client->GetPlayer()->stats[ITEM_STAT_SUCCESS_MOD];
  92. success += client->GetPlayer()->stats[ITEM_STAT_SUCCESS_MOD];
  93. client->GetPlayer()->MStats.unlock();
  94. // add values together for the if
  95. crit_success += crit_fail;
  96. fail += crit_success;
  97. success += fail;
  98. // Crit fail
  99. if (roll <= crit_fail) {
  100. progress = -50;
  101. durability = -100;
  102. effect = 4;
  103. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Critical failure!");
  104. }
  105. // Crit success
  106. else if (roll > crit_fail && roll <= crit_success) {
  107. progress = 100;
  108. durability = 10;
  109. effect = 1;
  110. client->SimpleMessage(CHANNEL_COLOR_YELLOW, "Critical success!");
  111. }
  112. // Fail
  113. else if (roll > crit_success && roll <= fail) {
  114. progress = 0;
  115. durability = -50;
  116. effect = 3;
  117. }
  118. // Success
  119. else if (roll > fail && roll <= success) {
  120. progress = 50;
  121. durability = -10;
  122. effect = 2;
  123. }
  124. else {
  125. // Just a debug, should never end up in this, if we do write out a log but treat as a success for the player
  126. LogWrite(TRADESKILL__ERROR, 0, "Tradeskills", "Process roll was not within valid range. roll = %f, crit fail = %f, crit success = %f, fail = %f, success = %f", roll, crit_fail, crit_success, fail, success);
  127. progress = 50;
  128. durability = -10;
  129. effect = 2;
  130. }
  131. // Check to see if there was an event, if there was give out the rewards/penalties for it
  132. if (tradeskill->CurrentEvent) {
  133. if (tradeskill->eventCountered) {
  134. progress += tradeskill->CurrentEvent->SuccessProgress;
  135. durability += tradeskill->CurrentEvent->SuccessDurability;
  136. }
  137. else {
  138. progress += tradeskill->CurrentEvent->FailProgress;
  139. durability += tradeskill->CurrentEvent->FailDurability;
  140. }
  141. }
  142. // Modify the progress/durability by the players stats
  143. client->GetPlayer()->MStats.lock();
  144. progress += client->GetPlayer()->stats[ITEM_STAT_PROGRESS_ADD];
  145. durability += client->GetPlayer()->stats[ITEM_STAT_DURABILITY_ADD];
  146. client->GetPlayer()->MStats.unlock();
  147. tradeskill->currentDurability += durability;
  148. tradeskill->currentProgress += progress;
  149. PacketStruct* packet = configReader.getStruct("WS_UpdateCreateItem", client->GetVersion());
  150. if (packet) {
  151. packet->setDataByName("spawn_id", client->GetPlayer()->GetIDWithPlayerSpawn(tradeskill->table));
  152. packet->setDataByName("effect", effect);
  153. packet->setDataByName("total_durability", tradeskill->currentDurability);
  154. packet->setDataByName("total_progress", tradeskill->currentProgress);
  155. packet->setDataByName("durability_change", durability);
  156. packet->setDataByName("progress_change", progress);
  157. if (tradeskill->currentProgress >= 1000)
  158. packet->setDataByName("progress_level", 4);
  159. else if (tradeskill->currentProgress >= 800)
  160. packet->setDataByName("progress_level", 3);
  161. else if (tradeskill->currentProgress >= 600)
  162. packet->setDataByName("progress_level", 2);
  163. else if (tradeskill->currentProgress >= 400)
  164. packet->setDataByName("progress_level", 1);
  165. else
  166. packet->setDataByName("progress_level", 0);
  167. // Reset the tradeskill event
  168. tradeskill->CurrentEvent = 0;
  169. tradeskill->eventChecked = false;
  170. tradeskill->eventCountered = false;
  171. // 15% chance for an event (change this to a rule probably)
  172. int eventRoll = MakeRandomFloat(0, 100);
  173. if (eventRoll <= m_eventChance) {
  174. // Get a vector of all possible events for this crafting technique
  175. vector<TradeskillEvent*>* events = master_tradeskillevent_list.GetEventByTechnique(tradeskill->recipe->GetTechnique());
  176. if (events) {
  177. // Get the size of the vector
  178. int size = events->size();
  179. // Get a random number from 0 to size - 1 to use as an index
  180. int index = MakeRandomInt(0, size - 1);
  181. // use the index to get an event
  182. TradeskillEvent* TSEvent = events->at(index);
  183. if (TSEvent) {
  184. // Now that we got a random event set it in the packet
  185. packet->setDataByName("reaction_icon", TSEvent->Icon);
  186. packet->setDataByName("reaction_name", TSEvent->Name);
  187. // Set the current tradeskill event
  188. tradeskill->CurrentEvent = TSEvent;
  189. }
  190. }
  191. }
  192. client->QueuePacket(packet->serialize());
  193. safe_delete(packet);
  194. }
  195. if (tradeskill->currentProgress >= 1000) {
  196. itr++;
  197. StopCrafting(client, false);
  198. continue;
  199. }
  200. else
  201. tradeskill->nextUpdateTime = Timer::GetCurrentTime2() + 4000;
  202. }
  203. itr++;
  204. }
  205. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  206. }
  207. void TradeskillMgr::BeginCrafting(Client* client, vector<int32> components) {
  208. Recipe* recipe = master_recipe_list.GetRecipe(client->GetPlayer()->GetCurrentRecipe());
  209. if (!recipe) {
  210. LogWrite(TRADESKILL__ERROR, 0, "Recipe", "Recipe (%u) not found in TradeskillMgr::BeginCrafting()", client->GetPlayer()->GetCurrentRecipe());
  211. ClientPacketFunctions::StopCrafting(client);
  212. return;
  213. }
  214. // TODO: use the vecotr to lock inventory slots
  215. vector<int32>::iterator itr;
  216. bool missingItem = false;
  217. int32 itemid = 0;
  218. vector<Item*> tmpItems;
  219. for (itr = components.begin(); itr != components.end(); itr++) {
  220. itemid = *itr;
  221. Item* item = client->GetPlayer()->item_list.GetItemFromID(itemid);
  222. if(!item)
  223. {
  224. missingItem = true;
  225. break;
  226. }
  227. item->details.item_locked = true;
  228. tmpItems.push_back(item);
  229. }
  230. if (missingItem) {
  231. LogWrite(TRADESKILL__ERROR, 0, "Recipe", "Recipe (%u) player missing item %u",itemid);
  232. vector<Item*>::iterator itemitr;
  233. for (itemitr = tmpItems.begin(); itemitr != tmpItems.end(); itemitr++) {
  234. Item* tmpItem = *itemitr;
  235. tmpItem->details.item_locked = false;
  236. }
  237. ClientPacketFunctions::StopCrafting(client);
  238. return;
  239. }
  240. ClientPacketFunctions::SendItemCreationUI(client, recipe);
  241. Tradeskill* tradeskill = new Tradeskill;
  242. tradeskill->player = client->GetPlayer();
  243. tradeskill->table = client->GetPlayer()->GetTarget();
  244. tradeskill->recipe = recipe;
  245. tradeskill->currentDurability = 1000;
  246. tradeskill->currentProgress = 0;
  247. tradeskill->nextUpdateTime = Timer::GetCurrentTime2() + 500;
  248. tradeskill->usedComponents = components;
  249. tradeskill->CurrentEvent = 0;
  250. tradeskill->eventChecked = false;
  251. tradeskill->eventCountered = false;
  252. m_tradeskills.writelock(__FUNCTION__, __LINE__);
  253. tradeskillList.insert(make_pair(client, tradeskill));
  254. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  255. // Unlock TS Spells and lock all others
  256. client->GetPlayer()->UnlockTSSpells();
  257. client->ClearSentItemDetails();
  258. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  259. if (outapp)
  260. client->QueuePacket(outapp);
  261. }
  262. void TradeskillMgr::StopCrafting(Client* client, bool lock) {
  263. if (lock)
  264. m_tradeskills.writelock(__FUNCTION__, __LINE__);
  265. if (tradeskillList.count(client) == 0) {
  266. if (lock)
  267. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  268. return;
  269. }
  270. Tradeskill* tradeskill = 0;
  271. tradeskill = tradeskillList[client];
  272. //TODO: unlock inventory slots, give the product to the player, give tradeskill xp
  273. ClientPacketFunctions::StopCrafting(client);
  274. int32 dur = tradeskill->currentDurability;
  275. int32 progress = tradeskill->currentProgress;
  276. Recipe* recipe = tradeskill->recipe;
  277. vector<int32>::iterator itr;
  278. Item* item = 0;
  279. int32 item_id = 0;
  280. int8 i = 0;
  281. int8 qty = 0;
  282. Recipe* playerRecipe = client->GetPlayer()->GetRecipeList()->GetRecipe(recipe->GetID());
  283. if(!playerRecipe)
  284. {
  285. LogWrite(TRADESKILL__ERROR, 0, "Tradeskills", "%s: TradeskillMgr::StopCrafting Error finding player recipe in their recipe book for recipe id %u", client->GetPlayer()->GetName(), recipe->GetID());
  286. client->Message(CHANNEL_COLOR_RED, "%s: StopCrafting Error finding player recipe in their recipe book for recipe id %u!", client->GetPlayer()->GetName(), recipe->GetID());
  287. if (lock)
  288. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  289. return;
  290. }
  291. bool updateInvReq = false;
  292. // cycle through the list of used items and remove them
  293. for (itr = tradeskill->usedComponents.begin(); itr != tradeskill->usedComponents.end(); itr++, i++) {
  294. // get the quantity to remove, first item in the vectore is always the primary, last is always the fuel
  295. if (i == 0)
  296. qty = 1;
  297. else if (i == 1 && i != tradeskill->usedComponents.size() - 1)
  298. qty = recipe->GetBuild1ComponentQuantity();
  299. else if (i == 2 && i != tradeskill->usedComponents.size() - 1)
  300. qty = recipe->GetBuild2ComponentQuantity();
  301. else if (i == 3 && i != tradeskill->usedComponents.size() - 1)
  302. qty = recipe->GetBuild3ComponentQuantity();
  303. else if (i == 4 && i != tradeskill->usedComponents.size() - 1)
  304. qty = recipe->GetBuild4ComponentQuantity();
  305. else if (i == 5 || i == tradeskill->usedComponents.size() - 1)
  306. qty = recipe->GetFuelComponentQuantity();
  307. // Get the item in the players inventory and remove or reduce the quantity
  308. int32 itmid = *itr;
  309. item = client->GetPlayer()->item_list.GetItemFromID(itmid);
  310. if (item && item->details.count <= qty)
  311. {
  312. item->details.item_locked = false;
  313. client->GetPlayer()->item_list.RemoveItem(item);
  314. }
  315. else if(item) {
  316. item->details.count -= qty;
  317. item->details.item_locked = false;
  318. item->save_needed = true;
  319. updateInvReq = true;
  320. }
  321. else
  322. {
  323. LogWrite(TRADESKILL__ERROR, 0, "Tradeskills", "%s: TradeskillMgr::StopCrafting Error finding item %u to remove quantity for recipe id %u", client->GetPlayer()->GetName(), itmid, recipe->GetID());
  324. client->Message(CHANNEL_COLOR_RED, "%s: StopCrafting Error finding item %u to remove quantity for recipe id %u!", client->GetPlayer()->GetName(), itmid, recipe->GetID());
  325. }
  326. }
  327. if(updateInvReq)
  328. {
  329. EQ2Packet* outapp = client->GetPlayer()->SendInventoryUpdate(client->GetVersion());
  330. if (outapp)
  331. client->QueuePacket(outapp);
  332. }
  333. item = 0;
  334. qty = recipe->GetFuelComponentQuantity();
  335. item_id = recipe->components[5][0];
  336. if (progress >= 400 && progress < 600) {
  337. if (playerRecipe->GetHighestStage() < 1) {
  338. playerRecipe->SetHighestStage(1);
  339. database.UpdatePlayerRecipe(client->GetPlayer(), recipe->GetID(), 1);
  340. }
  341. if (recipe->products.count(1) > 0) {
  342. item_id = recipe->products[1]->product_id;
  343. qty = recipe->products[1]->product_qty;
  344. }
  345. }
  346. else if ((dur < 200 && progress >= 600) || (dur >= 200 && progress >= 600 && progress < 800)) {
  347. if (playerRecipe->GetHighestStage() < 2) {
  348. playerRecipe->SetHighestStage(2);
  349. database.UpdatePlayerRecipe(client->GetPlayer(), recipe->GetID(), 2);
  350. }
  351. if (recipe->products.count(2) > 0) {
  352. item_id = recipe->products[2]->product_id;
  353. qty = recipe->products[2]->product_qty;
  354. }
  355. }
  356. else if ((dur >= 200 && dur < 800 && progress >= 800) || (dur >= 800 && progress >= 800 && progress < 1000)) {
  357. if (playerRecipe->GetHighestStage() < 3) {
  358. playerRecipe->SetHighestStage(3);
  359. database.UpdatePlayerRecipe(client->GetPlayer(), recipe->GetID(), 3);
  360. }
  361. if (recipe->products.count(3) > 0) {
  362. item_id = recipe->products[3]->product_id;
  363. qty = recipe->products[3]->product_qty;
  364. }
  365. }
  366. else if (dur >= 800 && progress >= 1000) {
  367. if (playerRecipe->GetHighestStage() < 4) {
  368. playerRecipe->SetHighestStage(4);
  369. database.UpdatePlayerRecipe(client->GetPlayer(), recipe->GetID(), 4);
  370. }
  371. if (recipe->products.count(4) > 0) {
  372. item_id = recipe->products[4]->product_id;
  373. qty = recipe->products[4]->product_qty;
  374. }
  375. }
  376. item = new Item(master_item_list.GetItem(item_id));
  377. if (!item) {
  378. LogWrite(TRADESKILL__ERROR, 0, "Tradeskills", "Item (%u) not found.", item_id);
  379. }
  380. else {
  381. item->details.count = qty;
  382. // use CHANNEL_COLOR_CHAT_RELATIONSHIP as that is the same value (4) as it is in a log for this message
  383. client->Message(CHANNEL_COLOR_CHAT_RELATIONSHIP, "You created %s.", item->CreateItemLink(client->GetVersion()).c_str());
  384. client->AddItem(item);
  385. //Check for crafting quest updates
  386. int8 update_amt = 0;
  387. if(item->stack_count > 1)
  388. update_amt = 1;
  389. else
  390. update_amt = qty;
  391. client->GetPlayer()->CheckQuestsCraftUpdate(item, update_amt);
  392. }
  393. float xp = client->GetPlayer()->CalculateTSXP(recipe->GetLevel());
  394. if (xp > 0) {
  395. int16 level = client->GetPlayer()->GetTSLevel();
  396. if (client->GetPlayer()->AddTSXP((int32)xp)) {
  397. client->Message(CHANNEL_REWARD, "You gain %u Tradeskill XP!", (int32)xp);
  398. LogWrite(PLAYER__DEBUG, 0, "Player", "Player: %s earned %u tradeskill experience.", client->GetPlayer()->GetName(), (int32)xp);
  399. if(client->GetPlayer()->GetTSLevel() != level)
  400. client->ChangeTSLevel(level, client->GetPlayer()->GetTSLevel());
  401. client->GetPlayer()->SetCharSheetChanged(true);
  402. }
  403. }
  404. tradeskillList.erase(client);
  405. safe_delete(tradeskill);
  406. if (lock)
  407. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  408. // Lock TS spells and unlock all others
  409. client->GetPlayer()->LockTSSpells();
  410. }
  411. bool TradeskillMgr::IsClientCrafting(Client* client) {
  412. bool ret = false;
  413. m_tradeskills.readlock(__FUNCTION__, __LINE__);
  414. ret = tradeskillList.count(client) > 0;
  415. m_tradeskills.releasereadlock(__FUNCTION__, __LINE__);
  416. return ret;
  417. }
  418. void TradeskillMgr::CheckTradeskillEvent(Client* client, int16 icon) {
  419. // Check to see if the given client is crafting
  420. if (!IsClientCrafting(client))
  421. return;
  422. m_tradeskills.writelock(__FUNCTION__, __LINE__);
  423. // check to see if the client currently has an event and if it does if we had already tried to counter it this round
  424. if (tradeskillList[client]->CurrentEvent == 0 || tradeskillList[client]->eventChecked) {
  425. // No current event, or we already tried to counter it, return out
  426. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  427. return;
  428. }
  429. // set the eventChecked flag so we don't try to counter it again
  430. tradeskillList[client]->eventChecked = true;
  431. // compare the event icon with the given spell icon to see if we countered it and store the result for the update
  432. bool countered = (icon == tradeskillList[client]->CurrentEvent->Icon);
  433. tradeskillList[client]->eventCountered = countered;
  434. // send the success or fail message to the client
  435. client->Message(CHANNEL_NARRATIVE, "You %s %s.", countered ? "successfully countered" : "failed to counter", tradeskillList[client]->CurrentEvent->Name);
  436. // unlock the list and send the result packet
  437. m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
  438. ClientPacketFunctions::CounterReaction(client, countered);
  439. }
  440. Tradeskill* TradeskillMgr::GetTradeskill(Client* client) {
  441. if (tradeskillList.count(client) == 0)
  442. return 0;
  443. return tradeskillList[client];
  444. }
  445. MasterTradeskillEventsList::MasterTradeskillEventsList() {
  446. m_eventList.SetName("MasterTradeskillEventsList::eventList");
  447. }
  448. MasterTradeskillEventsList::~MasterTradeskillEventsList() {
  449. m_eventList.writelock(__FUNCTION__, __LINE__);
  450. map<int32, vector<TradeskillEvent*> >::iterator itr;
  451. vector<TradeskillEvent*>::iterator ts_itr;
  452. for (itr = eventList.begin(); itr != eventList.end(); itr++){
  453. for (ts_itr = itr->second.begin(); ts_itr != itr->second.end(); ts_itr++){
  454. safe_delete(*ts_itr);
  455. }
  456. }
  457. eventList.clear();
  458. m_eventList.releasewritelock(__FUNCTION__, __LINE__);
  459. }
  460. void MasterTradeskillEventsList::AddEvent(TradeskillEvent* tradeskillEvent) {
  461. m_eventList.writelock(__FUNCTION__, __LINE__);
  462. eventList[tradeskillEvent->Technique].push_back(tradeskillEvent);
  463. m_eventList.releasewritelock(__FUNCTION__, __LINE__);
  464. }
  465. vector<TradeskillEvent*>* MasterTradeskillEventsList::GetEventByTechnique(int32 technique) {
  466. if (eventList.count(technique) == 0)
  467. return 0;
  468. return &eventList[technique];
  469. }
  470. int32 MasterTradeskillEventsList::Size() {
  471. int32 count = 0;
  472. m_eventList.readlock(__FUNCTION__, __LINE__);
  473. map<int32, vector<TradeskillEvent*> >::iterator itr;
  474. for (itr = eventList.begin(); itr != eventList.end(); itr++)
  475. count += itr->second.size();
  476. m_eventList.releasereadlock(__FUNCTION__, __LINE__);
  477. return count;
  478. }