Traits.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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. if (count > 4)
  165. break;
  166. strcpy(sTrait, "trait");
  167. itoa(count, temp, 10);
  168. strcat(sTrait, temp);
  169. strcpy(temp, sTrait);
  170. strcat(sTrait, "_icon");
  171. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  172. if (tmp_spell)
  173. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIcon(), index);
  174. else
  175. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  176. strcpy(sTrait, temp);
  177. strcat(sTrait, "_icon2");
  178. packet->setArrayDataByName(sTrait, 65535, index);
  179. strcpy(sTrait, temp);
  180. strcat(sTrait, "_id");
  181. packet->setArrayDataByName(sTrait, (*itr3)->spellID, index);
  182. strcpy(sTrait, temp);
  183. strcat(sTrait, "_name");
  184. if (tmp_spell)
  185. packet->setArrayDataByName(sTrait, tmp_spell->GetName(), index);
  186. else
  187. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  188. strcpy(sTrait, temp);
  189. strcat(sTrait, "_unknown2");
  190. packet->setArrayDataByName(sTrait, 1, index);
  191. strcpy(sTrait, temp);
  192. strcat(sTrait, "_unknown");
  193. packet->setArrayDataByName(sTrait, 1, index);
  194. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier))
  195. packet->setArrayDataByName("trait_line", count, index);
  196. }
  197. // Jabantiz: If less then 5 fill the rest of the line with FF FF FF FF FF FF FF FF FF FF FF FF
  198. while (count < 5) {
  199. strcpy(sTrait, "trait");
  200. itoa(count, temp, 10);
  201. strcat(sTrait, temp);
  202. strcpy(temp, sTrait);
  203. strcat(sTrait, "_icon");
  204. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  205. strcpy(sTrait, temp);
  206. strcat(sTrait, "_icon2");
  207. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  208. strcpy(sTrait, temp);
  209. strcat(sTrait, "_id");
  210. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  211. strcpy(sTrait, temp);
  212. strcat(sTrait, "_unknown");
  213. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  214. strcpy(sTrait, temp);
  215. strcat(sTrait, "_name");
  216. packet->setArrayDataByName(sTrait, "", index);
  217. count++;
  218. }
  219. }
  220. }
  221. // Class Training portion of the packet
  222. packet->setArrayLengthByName("num_trainings", ClassTraining.size());
  223. index = 0;
  224. for (itr2 = ClassTraining.begin(); itr2 != ClassTraining.end(); itr2++, index++) {
  225. count = 0;
  226. Spell* tmp_spell = 0;
  227. packet->setArrayDataByName("training_level", itr2->first, index);
  228. packet->setArrayDataByName("training_line", 255, index);
  229. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, count++) {
  230. // Jabantiz: cant have more then 5 traits per line
  231. if (count > 4)
  232. break;
  233. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  234. packet->setArrayDataByName("training_line", count, index);
  235. }
  236. strcpy(sTrait, "training");
  237. itoa(count, temp, 10);
  238. strcat(sTrait, temp);
  239. strcpy(temp, sTrait);
  240. strcat(sTrait, "_icon");
  241. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  242. if (tmp_spell)
  243. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIcon(), index);
  244. else
  245. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  246. strcpy(sTrait, temp);
  247. strcat(sTrait, "_icon2");
  248. if (tmp_spell)
  249. packet->setArrayDataByName(sTrait, tmp_spell->GetSpellIconBackdrop(), index);
  250. else
  251. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  252. strcpy(sTrait, temp);
  253. strcat(sTrait, "_id");
  254. packet->setArrayDataByName(sTrait, (*itr3)->spellID, index);
  255. strcpy(sTrait, temp);
  256. strcat(sTrait, "_unknown");
  257. packet->setArrayDataByName(sTrait,0xFFFFFFFF , index);
  258. strcpy(sTrait, temp);
  259. strcat(sTrait, "_unknown2");
  260. packet->setArrayDataByName(sTrait, 1, index);
  261. strcpy(sTrait, temp);
  262. strcat(sTrait, "_name");
  263. if (tmp_spell)
  264. packet->setArrayDataByName(sTrait, tmp_spell->GetName(), index);
  265. else
  266. LogWrite(SPELL__ERROR, 0, "Training", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  267. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier))
  268. packet->setArrayDataByName("training_line", count, index);
  269. }
  270. // Jabantiz: If less then 5 fill the rest of the line with FF FF FF FF FF FF FF FF FF FF FF FF
  271. while (count < 5) {
  272. strcpy(sTrait, "training");
  273. itoa(count, temp, 10);
  274. strcat(sTrait, temp);
  275. strcpy(temp, sTrait);
  276. strcat(sTrait, "_icon");
  277. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  278. strcpy(sTrait, temp);
  279. strcat(sTrait, "_icon2");
  280. packet->setArrayDataByName(sTrait, 65535, index); // FF FF
  281. strcpy(sTrait, temp);
  282. strcat(sTrait, "_id");
  283. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  284. strcpy(sTrait, temp);
  285. strcat(sTrait, "_unknown");
  286. packet->setArrayDataByName(sTrait, 0xFFFFFFFF, index);
  287. strcpy(sTrait, temp);
  288. strcat(sTrait, "_name");
  289. packet->setArrayDataByName(sTrait, "", index);
  290. count++;
  291. }
  292. }
  293. // Racial Traits
  294. packet->setArrayLengthByName("num_sections", RaceTraits.size());
  295. index = 0;
  296. string tempStr;
  297. int8 num_selections = 0;
  298. for (itr2 = RaceTraits.begin(); itr2 != RaceTraits.end(); itr2++, index++) {
  299. count = 0;
  300. Spell* tmp_spell = 0;
  301. switch (itr2->first)
  302. {
  303. case TRAITS_ATTRIBUTES:
  304. tempStr = "Attributes";
  305. break;
  306. case TRAITS_COMBAT:
  307. tempStr = "Combat";
  308. break;
  309. case TRAITS_NONCOMBAT:
  310. tempStr = "Noncombat";
  311. break;
  312. case TRAITS_POOLS:
  313. tempStr = "Pools";
  314. break;
  315. case TRAITS_RESIST:
  316. tempStr = "Resist";
  317. break;
  318. case TRAITS_TRADESKILL:
  319. tempStr = "Tradeskill";
  320. break;
  321. default:
  322. tempStr = "Unknown";
  323. break;
  324. }
  325. packet->setArrayDataByName("section_name", tempStr.c_str(), index);
  326. packet->setSubArrayLengthByName("num_traditions", (itr2->second).size(), index);
  327. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, count++) {
  328. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  329. num_selections++;
  330. packet->setSubArrayDataByName("tradition_selected", 1, index, count);
  331. }
  332. else {
  333. packet->setSubArrayDataByName("tradition_selected", 0, index, count);
  334. }
  335. tmp_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  336. if (tmp_spell){
  337. packet->setSubArrayDataByName("tradition_icon", tmp_spell->GetSpellIcon(), index, count);
  338. packet->setSubArrayDataByName("tradition_icon2", tmp_spell->GetSpellIconBackdrop(), index, count);
  339. packet->setSubArrayDataByName("tradition_id", (*itr3)->spellID, index, count);
  340. packet->setSubArrayDataByName("tradition_name", tmp_spell->GetName(), index, count);
  341. packet->setSubArrayDataByName("tradition_unknown_58617_MJ1", 1, index, count);
  342. }
  343. else
  344. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  345. }
  346. }
  347. int8 num_available_selections = client->GetPlayer()->GetLevel() / 10;
  348. if (num_selections < num_available_selections)
  349. packet->setDataByName("allow_select", num_available_selections - num_selections);
  350. else
  351. packet->setDataByName("allow_select", 0);
  352. // Innate Racial Traits
  353. index = 0;
  354. // total number of Innate traits
  355. num_traits = 0;
  356. for (itr2 = InnateRaceTraits.begin(); itr2 != InnateRaceTraits.end(); itr2++) {
  357. num_traits += (itr2->second).size();
  358. }
  359. packet->setArrayLengthByName("num_abilities", num_traits);
  360. for (itr2 = InnateRaceTraits.begin(); itr2 != InnateRaceTraits.end(); itr2++) {
  361. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, index++) {
  362. Spell* innate_spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  363. if (innate_spell) {
  364. packet->setArrayDataByName("ability_icon", innate_spell->GetSpellIcon(), index);
  365. packet->setArrayDataByName("ability_icon2", innate_spell->GetSpellIconBackdrop(), index);
  366. packet->setArrayDataByName("ability_id", (*itr3)->spellID, index);
  367. packet->setArrayDataByName("ability_name", innate_spell->GetName(), index);
  368. }
  369. else
  370. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  371. }
  372. }
  373. if (client->GetVersion() >= 1188) {
  374. // total number of Focus Effects
  375. num_selections = 0;
  376. num_focuseffects = 0;
  377. index = 0;
  378. for (itr2 = FocusEffects.begin(); itr2 != FocusEffects.end(); itr2++) {
  379. num_focuseffects += (itr2->second).size();
  380. }
  381. packet->setArrayLengthByName("num_focuseffects", num_focuseffects);
  382. for (itr2 = FocusEffects.begin(); itr2 != FocusEffects.end(); itr2++) {
  383. for (itr3 = itr2->second.begin(); itr3 != itr2->second.end(); itr3++, index++) {
  384. Spell* spell = master_spell_list.GetSpell((*itr3)->spellID, (*itr3)->tier);
  385. if (client->GetPlayer()->HasSpell((*itr3)->spellID, (*itr3)->tier)) {
  386. num_selections++;
  387. packet->setArrayDataByName("focus_selected", 1, index);
  388. }
  389. else {
  390. packet->setArrayDataByName("focus_selected", 0, index);
  391. }
  392. if (spell) {
  393. packet->setArrayDataByName("focus_unknown2", 1, index);
  394. packet->setArrayDataByName("focus_icon", spell->GetSpellIcon(), index);
  395. packet->setArrayDataByName("focus_icon2", spell->GetSpellIconBackdrop(), index);
  396. packet->setArrayDataByName("focus_spell_crc", (*itr3)->spellID, index);
  397. packet->setArrayDataByName("focus_name", spell->GetName(), index);
  398. packet->setArrayDataByName("focus_unknown_58617_MJ1", 1, index);
  399. }
  400. else
  401. LogWrite(SPELL__ERROR, 0, "Traits", "Could not find SpellID %u and Tier %i in Master Spell List (line: %i)", (*itr3)->spellID, (*itr3)->tier, __LINE__);
  402. }
  403. }
  404. num_available_selections = client->GetPlayer()->GetLevel() / 9;
  405. if (num_selections < num_available_selections)
  406. packet->setDataByName("focus_allow_select", num_available_selections - num_selections);
  407. else
  408. packet->setDataByName("focus_allow_select", 0);
  409. }
  410. LogWrite(SPELL__PACKET, 0, "Traits", "Dump/Print Packet in func: %s, line: %i", __FUNCTION__, __LINE__);
  411. #if EQDEBUG >= 9
  412. packet->PrintPacket();
  413. #endif
  414. EQ2Packet* data = packet->serialize();
  415. EQ2Packet* outapp = new EQ2Packet(OP_ClientCmdMsg, data->pBuffer, data->size);
  416. //DumpPacket(outapp);
  417. safe_delete(packet);
  418. safe_delete(data);
  419. return outapp;
  420. }
  421. // Jabantiz: Probably a better way to do this but can't think of it right now
  422. TraitData* MasterTraitList::GetTrait(int32 spellID) {
  423. vector<TraitData*>::iterator itr;
  424. TraitData* data = NULL;
  425. MMasterTraitList.readlock(__FUNCTION__, __LINE__);
  426. for (itr = TraitList.begin(); itr != TraitList.end(); itr++) {
  427. if ((*itr)->spellID == spellID) {
  428. data = (*itr);
  429. break;
  430. }
  431. }
  432. MMasterTraitList.releasereadlock(__FUNCTION__, __LINE__);
  433. return data;
  434. }
  435. void MasterTraitList::DestroyTraits(){
  436. MMasterTraitList.writelock(__FUNCTION__, __LINE__);
  437. vector<TraitData*>::iterator itr;
  438. for (itr = TraitList.begin(); itr != TraitList.end(); itr++)
  439. safe_delete((*itr));
  440. TraitList.clear();
  441. MMasterTraitList.releasewritelock(__FUNCTION__, __LINE__);
  442. }