Traits.cpp 18 KB

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