9
3

Traits.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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 "Traits.h"
  17. #include "../../common/ConfigReader.h"
  18. #include "../../common/Log.h"
  19. #include "../Spells.h"
  20. #include "../WorldDatabase.h"
  21. #include <map>
  22. extern ConfigReader configReader;
  23. extern MasterSpellList master_spell_list;
  24. extern WorldDatabase database;
  25. MasterTraitList::MasterTraitList(){
  26. MMasterTraitList.SetName("MasterTraitList::TraitList");
  27. }
  28. MasterTraitList::~MasterTraitList(){
  29. DestroyTraits();
  30. }
  31. void MasterTraitList::AddTrait(TraitData* data){
  32. MMasterTraitList.writelock(__FUNCTION__, __LINE__);
  33. TraitList.push_back(data);
  34. MMasterTraitList.releasewritelock(__FUNCTION__, __LINE__);
  35. }
  36. int MasterTraitList::Size(){
  37. return TraitList.size();
  38. }
  39. EQ2Packet* MasterTraitList::GetTraitListPacket (Client* client)
  40. {
  41. if (!client) {
  42. LogWrite(SPELL__ERROR, 0, "Traits", "GetTraitListPacket called with an invalid client");
  43. return 0;
  44. }
  45. // Sort the Data
  46. if (Size() == 0)
  47. return NULL;
  48. map <int8, map <int8, vector<TraitData*> > > SortedTraitList;
  49. map <int8, map <int8, vector<TraitData*> > >::iterator itr;
  50. map <int8, vector<TraitData*> >::iterator itr2;
  51. vector<TraitData*>::iterator itr3;
  52. map <int8, vector<TraitData*> > ClassTraining;
  53. map <int8, vector<TraitData*> > RaceTraits;
  54. map <int8, vector<TraitData*> > InnateRaceTraits;
  55. map <int8, vector<TraitData*> > FocusEffects;
  56. MMasterTraitList.readlock(__FUNCTION__, __LINE__);
  57. for (int i=0; i < Size(); i++) {
  58. // Sort Character Traits
  59. if (TraitList[i]->classReq == 255 && TraitList[i]->raceReq == 255 && !TraitList[i]->isFocusEffect && TraitList[i]->isTrait) {
  60. itr = SortedTraitList.lower_bound(TraitList[i]->group);
  61. if (itr != SortedTraitList.end() && !(SortedTraitList.key_comp()(TraitList[i]->group, itr->first))) {
  62. itr2 = (itr->second).lower_bound(TraitList[i]->level);
  63. if (itr2 != (itr->second).end() && !((itr->second).key_comp()(TraitList[i]->level, itr2->first))) {
  64. ((itr->second)[itr2->first]).push_back(TraitList[i]);
  65. //LogWrite(SPELL__INFO, 0, "Traits", "Added Trait: %u Tier %i", TraitList[i]->spellID, TraitList[i]->tier);
  66. }
  67. else {
  68. vector<TraitData*> tempVec;
  69. tempVec.push_back(TraitList[i]);
  70. (itr->second).insert(make_pair(TraitList[i]->level, tempVec));
  71. //LogWrite(SPELL__INFO, 0, "Traits", "Added Trait: %u Tier %i", TraitList[i]->spellID, TraitList[i]->tier);
  72. }
  73. }
  74. else {
  75. map <int8, vector<TraitData*> > tempMap;
  76. vector <TraitData*> tempVec;
  77. tempVec.push_back(TraitList[i]);
  78. tempMap.insert(make_pair(TraitList[i]->level, tempVec));
  79. SortedTraitList.insert(make_pair(TraitList[i]->group, tempMap));
  80. //LogWrite(SPELL__INFO, 0, "Traits", "Added Trait: %u Tier %i", TraitList[i]->spellID, TraitList[i]->tier);
  81. }
  82. }
  83. // Sort Class Training
  84. if (TraitList[i]->classReq == client->GetPlayer()->GetAdventureClass() && TraitList[i]->isTraining) {
  85. itr2 = ClassTraining.lower_bound(TraitList[i]->level);
  86. if (itr2 != ClassTraining.end() && !(ClassTraining.key_comp()(TraitList[i]->level, itr2->first))) {
  87. (itr2->second).push_back(TraitList[i]);
  88. }
  89. else {
  90. vector<TraitData*> tempVec;
  91. tempVec.push_back(TraitList[i]);
  92. ClassTraining.insert(make_pair(TraitList[i]->level, tempVec));
  93. }
  94. }
  95. // Sort Racial Abilities
  96. if (TraitList[i]->raceReq == client->GetPlayer()->GetRace() && !TraitList[i]->isInate && !TraitList[i]->isTraining) {
  97. itr2 = RaceTraits.lower_bound(TraitList[i]->group);
  98. if (itr2 != RaceTraits.end() && !(RaceTraits.key_comp()(TraitList[i]->group, itr2->first))) {
  99. (itr2->second).push_back(TraitList[i]);
  100. }
  101. else {
  102. vector<TraitData*> tempVec;
  103. tempVec.push_back(TraitList[i]);
  104. RaceTraits.insert(make_pair(TraitList[i]->group, tempVec));
  105. }
  106. }
  107. // Sort Innate Racial Abilities
  108. if (TraitList[i]->raceReq == client->GetPlayer()->GetRace() && TraitList[i]->isInate) {
  109. itr2 = InnateRaceTraits.lower_bound(TraitList[i]->group);
  110. if (itr2 != InnateRaceTraits.end() && !(InnateRaceTraits.key_comp()(TraitList[i]->group, itr2->first))) {
  111. (itr2->second).push_back(TraitList[i]);
  112. }
  113. else {
  114. vector<TraitData*> tempVec;
  115. tempVec.push_back(TraitList[i]);
  116. InnateRaceTraits.insert(make_pair(TraitList[i]->group, tempVec));
  117. }
  118. }
  119. // Sort Focus Effects
  120. if ((TraitList[i]->classReq == client->GetPlayer()->GetAdventureClass() || TraitList[i]->classReq == 255) && TraitList[i]->isFocusEffect) {
  121. int8 j = 0;
  122. itr2 = FocusEffects.lower_bound(TraitList[i]->group);
  123. if (itr2 != FocusEffects.end() && !(FocusEffects.key_comp()(TraitList[i]->group, itr2->first))) {
  124. (itr2->second).push_back(TraitList[i]);
  125. //LogWrite(SPELL__INFO, 0, "Traits", "Added Focus Effect: %u Tier: %i", TraitList[i]->spellID, TraitList[i]->tier);
  126. j++;
  127. }
  128. else {
  129. vector<TraitData*> tempVec;
  130. tempVec.push_back(TraitList[i]);
  131. FocusEffects.insert(make_pair(TraitList[i]->group, tempVec));
  132. //LogWrite(SPELL__INFO, 0, "Traits", "Added Focus Effect: %u Tier %i", TraitList[i]->spellID, TraitList[i]->tier);
  133. }
  134. }
  135. }
  136. MMasterTraitList.releasereadlock(__FUNCTION__, __LINE__);
  137. int16 version = 1;
  138. int8 count = 0;
  139. int8 index = 0;
  140. int8 num_traits = 0;
  141. int8 traits_size = 0;
  142. int8 num_focuseffects = 0;
  143. char sTrait [20];
  144. char temp [20];
  145. version = client->GetVersion();
  146. // Jabantiz: Get the value for num_traits in the struct (num_traits refers to the number of rows not the total number of traits)
  147. for (itr = SortedTraitList.begin(); itr != SortedTraitList.end(); itr++) {
  148. num_traits += (itr->second).size();
  149. }
  150. PacketStruct* packet = configReader.getStruct("WS_TraitsList", version);
  151. if (packet == NULL)
  152. return NULL;
  153. packet->setArrayLengthByName("num_traits", num_traits);
  154. for (itr = SortedTraitList.begin(); itr != SortedTraitList.end(); itr++) {
  155. for (itr2 = itr->second.begin(); itr2 != itr->second.end(); itr2++, index++) {
  156. traits_size += (itr2->second).size();
  157. count = 0;
  158. Spell* tmp_spell = 0;
  159. packet->setArrayDataByName("trait_level", (*itr2).first, index);
  160. packet->setArrayDataByName("trait_line", 255, index);
  161. //LogWrite(SPELL__INFO, 0, "AA", "Character Traits Size...%i ", traits_size);
  162. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, count++) {
  163. // Jabantiz: cant have more then 5 traits per line
  164. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  165. if(!tmp_spell) {
  166. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  167. continue;
  168. }
  169. if (count > 4)
  170. break;
  171. strcpy(sTrait, "trait");
  172. itoa(count, temp, 10);
  173. strcat(sTrait, temp);
  174. strcpy(temp, sTrait);
  175. strcat(sTrait, "_icon");
  176. if (tmp_spell)
  177. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIcon(), index);
  178. else
  179. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  180. strcpy(sTrait, temp);
  181. strcat(sTrait, "_icon2");
  182. packet->setArrayDataByName(sTrait, 65535, index);
  183. strcpy(sTrait, temp);
  184. strcat(sTrait, "_id");
  185. packet->setArrayDataByName(sTrait, (*itr3)->spellID, index);
  186. strcpy(sTrait, temp);
  187. strcat(sTrait, "_name");
  188. if (tmp_spell)
  189. packet->setArrayDataByName(sTrait, tmp_spell->GetName(), index);
  190. else
  191. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  192. strcpy(sTrait, temp);
  193. strcat(sTrait, "_unknown2");
  194. packet->setArrayDataByName(sTrait, 1, index);
  195. strcpy(sTrait, temp);
  196. strcat(sTrait, "_unknown");
  197. packet->setArrayDataByName(sTrait, 1, index);
  198. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier))
  199. packet->setArrayDataByName("trait_line", count, index);
  200. }
  201. // Jabantiz: If less then 5 fill the rest of the line with FF FF FF FF FF FF FF FF FF FF FF FF
  202. while (count < 5) {
  203. strcpy(sTrait, "trait");
  204. itoa(count, temp, 10);
  205. strcat(sTrait, temp);
  206. strcpy(temp, sTrait);
  207. strcat(sTrait, "_icon");
  208. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  209. strcpy(sTrait, temp);
  210. strcat(sTrait, "_icon2");
  211. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  212. strcpy(sTrait, temp);
  213. strcat(sTrait, "_id");
  214. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  215. strcpy(sTrait, temp);
  216. strcat(sTrait, "_unknown");
  217. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  218. strcpy(sTrait, temp);
  219. strcat(sTrait, "_name");
  220. packet->setArrayDataByName(sTrait, "", index);
  221. count++;
  222. }
  223. }
  224. }
  225. // Class Training portion of the packet
  226. packet->setArrayLengthByName("num_trainings", ClassTraining.size());
  227. index = 0;
  228. for (itr2 = ClassTraining.begin(); itr2 != ClassTraining.end(); itr2++, index++) {
  229. count = 0;
  230. Spell* tmp_spell = 0;
  231. packet->setArrayDataByName("training_level", itr2->first, index);
  232. packet->setArrayDataByName("training_line", 255, index);
  233. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, count++) {
  234. // Jabantiz: cant have more then 5 traits per line
  235. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  236. if(!tmp_spell) {
  237. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  238. continue;
  239. }
  240. if (count > 4)
  241. break;
  242. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  243. packet->setArrayDataByName("training_line", count, index);
  244. }
  245. strcpy(sTrait, "training");
  246. itoa(count, temp, 10);
  247. strcat(sTrait, temp);
  248. strcpy(temp, sTrait);
  249. strcat(sTrait, "_icon");
  250. if (tmp_spell)
  251. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIcon(), index);
  252. else
  253. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  254. strcpy(sTrait, temp);
  255. strcat(sTrait, "_icon2");
  256. if (tmp_spell)
  257. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIconBackdrop(), index);
  258. else
  259. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  260. strcpy(sTrait, temp);
  261. strcat(sTrait, "_id");
  262. packet->setArrayDataByName(sTrait, (*itr3)->spellID, index);
  263. strcpy(sTrait, temp);
  264. strcat(sTrait, "_unknown");
  265. packet->setArrayDataByName(sTrait,0xFFFFFFFF , index);
  266. strcpy(sTrait, temp);
  267. strcat(sTrait, "_unknown2");
  268. packet->setArrayDataByName(sTrait, 1, index);
  269. strcpy(sTrait, temp);
  270. strcat(sTrait, "_name");
  271. if (tmp_spell)
  272. packet->setArrayDataByName(sTrait, tmp_spell->GetName(), index);
  273. else
  274. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  275. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier))
  276. packet->setArrayDataByName("training_line", count, index);
  277. }
  278. // Jabantiz: If less then 5 fill the rest of the line with FF FF FF FF FF FF FF FF FF FF FF FF
  279. while (count < 5) {
  280. strcpy(sTrait, "training");
  281. itoa(count, temp, 10);
  282. strcat(sTrait, temp);
  283. strcpy(temp, sTrait);
  284. strcat(sTrait, "_icon");
  285. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  286. strcpy(sTrait, temp);
  287. strcat(sTrait, "_icon2");
  288. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  289. strcpy(sTrait, temp);
  290. strcat(sTrait, "_id");
  291. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  292. strcpy(sTrait, temp);
  293. strcat(sTrait, "_unknown");
  294. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  295. strcpy(sTrait, temp);
  296. strcat(sTrait, "_name");
  297. packet->setArrayDataByName(sTrait, "", index);
  298. count++;
  299. }
  300. }
  301. // Racial Traits
  302. packet->setArrayLengthByName("num_sections", RaceTraits.size());
  303. index = 0;
  304. string tempStr;
  305. int8 num_selections = 0;
  306. for (itr2 = RaceTraits.begin(); itr2 != RaceTraits.end(); itr2++, index++) {
  307. count = 0;
  308. Spell* tmp_spell = 0;
  309. switch (itr2->first)
  310. {
  311. case TRAITS_ATTRIBUTES:
  312. tempStr = "Attributes";
  313. break;
  314. case TRAITS_COMBAT:
  315. tempStr = "Combat";
  316. break;
  317. case TRAITS_NONCOMBAT:
  318. tempStr = "Noncombat";
  319. break;
  320. case TRAITS_POOLS:
  321. tempStr = "Pools";
  322. break;
  323. case TRAITS_RESIST:
  324. tempStr = "Resist";
  325. break;
  326. case TRAITS_TRADESKILL:
  327. tempStr = "Tradeskill";
  328. break;
  329. default:
  330. tempStr = "Unknown";
  331. break;
  332. }
  333. packet->setArrayDataByName("section_name", tempStr.c_str(), index);
  334. packet->setSubArrayLengthByName("num_traditions", (itr2->second).size(), index);
  335. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, count++) {
  336. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  337. num_selections++;
  338. packet->setSubArrayDataByName("tradition_selected", 1, index, count);
  339. }
  340. else {
  341. packet->setSubArrayDataByName("tradition_selected", 0, index, count);
  342. }
  343. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  344. if (tmp_spell){
  345. packet->setSubArrayDataByName("tradition_icon", tmp_spell->GetSpellIcon(), index, count);
  346. packet->setSubArrayDataByName("tradition_icon2", tmp_spell->GetSpellIconBackdrop(), index, count);
  347. packet->setSubArrayDataByName("tradition_id", (*itr3)->spellID, index, count);
  348. packet->setSubArrayDataByName("tradition_name", tmp_spell->GetName(), index, count);
  349. packet->setSubArrayDataByName("tradition_unknown_58617_MJ1", 1, index, count);
  350. }
  351. else
  352. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  353. }
  354. }
  355. int8 num_available_selections = client->GetPlayer()->GetLevel() / 10;
  356. if (num_selections < num_available_selections)
  357. packet->setDataByName("allow_select", num_available_selections - num_selections);
  358. else
  359. packet->setDataByName("allow_select", 0);
  360. // Innate Racial Traits
  361. index = 0;
  362. // total number of Innate traits
  363. num_traits = 0;
  364. for (itr2 = InnateRaceTraits.begin(); itr2 != InnateRaceTraits.end(); itr2++) {
  365. num_traits += (itr2->second).size();
  366. }
  367. packet->setArrayLengthByName("num_abilities", num_traits);
  368. for (itr2 = InnateRaceTraits.begin(); itr2 != InnateRaceTraits.end(); itr2++) {
  369. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, index++) {
  370. Spell* innate_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  371. if (innate_spell) {
  372. packet->setArrayDataByName("ability_icon", innate_spell->GetSpellIcon(), index);
  373. packet->setArrayDataByName("ability_icon2", innate_spell->GetSpellIconBackdrop(), index);
  374. packet->setArrayDataByName("ability_id", (*itr3)->spellID, index);
  375. packet->setArrayDataByName("ability_name", innate_spell->GetName(), index);
  376. }
  377. else
  378. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  379. }
  380. }
  381. if (client->GetVersion() >= 1188) {
  382. // total number of Focus Effects
  383. num_selections = 0;
  384. num_focuseffects = 0;
  385. index = 0;
  386. for (itr2 = FocusEffects.begin(); itr2 != FocusEffects.end(); itr2++) {
  387. num_focuseffects += (itr2->second).size();
  388. }
  389. packet->setArrayLengthByName("num_focuseffects", num_focuseffects);
  390. for (itr2 = FocusEffects.begin(); itr2 != FocusEffects.end(); itr2++) {
  391. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, index++) {
  392. Spell* spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  393. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  394. num_selections++;
  395. packet->setArrayDataByName("focus_selected", 1, index);
  396. }
  397. else {
  398. packet->setArrayDataByName("focus_selected", 0, index);
  399. }
  400. if (spell) {
  401. packet->setArrayDataByName("focus_unknown2", 1, index);
  402. packet->setArrayDataByName("focus_icon", spell->GetSpellIcon(), index);
  403. packet->setArrayDataByName("focus_icon2", spell->GetSpellIconBackdrop(), index);
  404. packet->setArrayDataByName("focus_spell_crc", (*itr3)->spellID, index);
  405. packet->setArrayDataByName("focus_name", spell->GetName(), index);
  406. packet->setArrayDataByName("focus_unknown_58617_MJ1", 1, index);
  407. }
  408. else
  409. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  410. }
  411. }
  412. num_available_selections = client->GetPlayer()->GetLevel() / 9;
  413. if (num_selections < num_available_selections)
  414. packet->setDataByName("focus_allow_select", num_available_selections - num_selections);
  415. else
  416. packet->setDataByName("focus_allow_select", 0);
  417. }
  418. LogWrite(SPELL__PACKET, 0, "Traits", "Dump/Print Packet in func: %s, line: %i", __FUNCTION__, __LINE__);
  419. #if EQDEBUG >= 9
  420. packet->PrintPacket();
  421. #endif
  422. EQ2Packet* data = packet->serialize();
  423. EQ2Packet* outapp = new EQ2Packet(OP_ClientCmdMsg, data->pBuffer, data->size);
  424. //DumpPacket(outapp);
  425. safe_delete(packet);
  426. safe_delete(data);
  427. return outapp;
  428. }
  429. // Jabantiz: Probably a better way to do this but can't think of it right now
  430. TraitData* MasterTraitList::GetTrait(int32 spellID) {
  431. vector<TraitData*>::iterator itr;
  432. TraitData* data = NULL;
  433. MMasterTraitList.readlock(__FUNCTION__, __LINE__);
  434. for (itr = TraitList.begin(); itr != TraitList.end(); itr++) {
  435. if ((*itr)->spellID == spellID) {
  436. data = (*itr);
  437. break;
  438. }
  439. }
  440. MMasterTraitList.releasereadlock(__FUNCTION__, __LINE__);
  441. return data;
  442. }
  443. void MasterTraitList::DestroyTraits(){
  444. MMasterTraitList.writelock(__FUNCTION__, __LINE__);
  445. vector<TraitData*>::iterator itr;
  446. for (itr = TraitList.begin(); itr != TraitList.end(); itr++)
  447. safe_delete((*itr));
  448. TraitList.clear();
  449. MMasterTraitList.releasewritelock(__FUNCTION__, __LINE__);
  450. }