Advertisement
Guest User

Untitled

a guest
Aug 29th, 2012
1,664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.56 KB | None | 0 0
  1. ///////////////////////////////
  2. //**** Created By EroniX ****//
  3. ///////////////////////////////
  4. //
  5. // #Files: - TransmogHandler.cpp
  6. //
  7. // - TransmogEngine.cpp
  8. // - TransmogEngine.h
  9. //
  10. // - TransmogMgr.cpp
  11. // - TransmogMgr.h
  12. //
  13. //
  14. // #Core Mods: - Player.cpp:
  15. // - #include "TransmogEngine.h"
  16. // - EquipItem:
  17. // - TransmogEngine::SetTransmogDisplay(this, slot);
  18. //
  19. // - RemoveItem:
  20. // - TransmogEngine::RemoveTransmog(this, slot);
  21. //
  22. // - Player.h:
  23. // - uint32 selectedSlotID;
  24. // - Loot* selectedInterface;
  25. //
  26. // - LootHandler.cpp:
  27. // - #include "TransmogEngine.h"
  28. // - HandleAutostoreLootItemOpcode:
  29. // if(TransmogEngine::IsActiveInterface(lguid) && player)
  30. // {
  31. // if(Creature* creature = player->GetMap()->GetCreature(lguid))
  32. // TransmogEngine::HandleInterfaceSelect(player, creature, player->selectedInterface, lootSlot);
  33. //
  34. // return;
  35. // }
  36. //
  37. // - HandleLootReleaseOpcode:
  38. // if(Player* player = GetPlayer())
  39. // if(TransmogEngine::IsActiveInterface(guid))
  40. // {
  41. // if(Creature* creature = GetPlayer()->GetMap()->GetCreature(guid))
  42. // TransmogEngine::SendInterfaceClose(player, guid);
  43. //
  44. // return;
  45. // }
  46.  
  47. #include "TransmogEngine.h"
  48. #include "TransmogMgr.h"
  49.  
  50. //////////////////////////////////////////////////////////////
  51. //********************* Variables **************************//
  52. //////////////////////////////////////////////////////////////
  53.  
  54. std::list<CharacterTransmog*> TransmogMgr::characterTransmogList;
  55. bool TransmogMgr::loaded;
  56.  
  57. //////////////////////////////////////////////////////////////
  58. //********************* Transmog Load **********************//
  59. //////////////////////////////////////////////////////////////
  60.  
  61. void TransmogMgr::LoadCharacterTransmog()
  62. {
  63. loaded = true;
  64.  
  65. QueryResult result = CharacterDatabase.Query("SELECT * FROM character_transmog ORDER BY player_guid");
  66. if(!result)
  67. return;
  68.  
  69. do
  70. {
  71. Field* fields = result->Fetch();
  72.  
  73. CharacterTransmog* characterTransmog = new CharacterTransmog(fields[0].GetUInt32(), fields[1].GetUInt32(), fields[2].GetUInt32());
  74. characterTransmogList.push_back(characterTransmog);
  75.  
  76. } while(result->NextRow());
  77. }
  78.  
  79. //////////////////////////////////////////////////////////////
  80. //******************* Transmog Remove **********************//
  81. //////////////////////////////////////////////////////////////
  82.  
  83. void TransmogMgr::RemoveTransmogItem(uint32 itemGUID)
  84. {
  85. if(IsEmpty())
  86. return;
  87.  
  88. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  89. {
  90. CharacterTransmog* characterTransmog = *itrBegin;
  91. if(!characterTransmog)
  92. continue;
  93.  
  94. if(characterTransmog->itemGUID == itemGUID)
  95. {
  96. characterTransmogList.remove(characterTransmog);
  97. return;
  98. }
  99. }
  100. }
  101.  
  102. void TransmogMgr::RemoveTransmogPlayer(uint32 playerGUID)
  103. {
  104. if(IsEmpty())
  105. return;
  106.  
  107. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  108. {
  109. CharacterTransmog* characterTransmog = *itrBegin;
  110. if(!characterTransmog)
  111. continue;
  112.  
  113. if(characterTransmog->playerGUID == playerGUID)
  114. {
  115. characterTransmogList.remove(characterTransmog);
  116. return;
  117. }
  118. }
  119. }
  120.  
  121. //////////////////////////////////////////////////////////////
  122. //********************* Transmog Add ***********************//
  123. //////////////////////////////////////////////////////////////
  124.  
  125. void TransmogMgr::AddTransmog(uint32 playerGUID, uint32 itemGUID, uint32 itemENTRY)
  126. {
  127. if(!TransmogMgr::IsTransmogedItem(itemGUID))
  128. {
  129. CharacterTransmog* characterTransmog = new CharacterTransmog(playerGUID, itemGUID, itemENTRY);
  130. characterTransmogList.push_back(characterTransmog);
  131. }
  132. }
  133.  
  134. void TransmogMgr::UpdateTransmog(uint32 playerGUID, uint32 itemGUID, uint32 itemENTRY)
  135. {
  136. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  137. {
  138. CharacterTransmog* characterTransmog = *itrBegin;
  139. if(!characterTransmog)
  140. continue;
  141.  
  142. if(characterTransmog->itemGUID == itemGUID)
  143. {
  144. characterTransmog->playerGUID = playerGUID;
  145. characterTransmog->itemENTRY = itemENTRY;
  146. return;
  147. }
  148. }
  149.  
  150. TransmogMgr::AddTransmog(playerGUID, itemGUID, itemENTRY);
  151. }
  152.  
  153. //////////////////////////////////////////////////////////////
  154. //********************** Helpers ***************************//
  155. //////////////////////////////////////////////////////////////
  156.  
  157. uint32 TransmogMgr::GetTransmogsCount(uint32 playerGUID)
  158. {
  159. uint32 counter = 0;
  160.  
  161. if(IsEmpty())
  162. return counter;
  163.  
  164. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  165. {
  166. CharacterTransmog* characterTransmog = *itrBegin;
  167. if(!characterTransmog)
  168. continue;
  169.  
  170. if(characterTransmog->playerGUID == playerGUID)
  171. counter++;
  172. }
  173.  
  174. return counter;
  175. }
  176.  
  177. uint32 TransmogMgr::GetEntry(uint32 itemGUID)
  178. {
  179. if(IsEmpty())
  180. return PROBLEM;
  181.  
  182. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  183. {
  184. CharacterTransmog* characterTransmog = *itrBegin;
  185. if(!characterTransmog)
  186. continue;
  187.  
  188. if(characterTransmog->itemGUID == itemGUID)
  189. return characterTransmog->itemENTRY;
  190. }
  191.  
  192. return PROBLEM;
  193. }
  194.  
  195. //////////////////////////////////////////////////////////////
  196. //********************** Checkers **************************//
  197. //////////////////////////////////////////////////////////////
  198.  
  199. bool TransmogMgr::IsTransmogedItem(uint32 itemGUID)
  200. {
  201. if(IsEmpty())
  202. return false;
  203.  
  204. for(CharacterTransmogList::iterator itrBegin = characterTransmogList.begin(), itrEnd = characterTransmogList.end(); itrBegin != itrEnd; itrBegin++)
  205. {
  206. CharacterTransmog* characterTransmog = *itrBegin;
  207. if(!characterTransmog)
  208. continue;
  209.  
  210. if(characterTransmog->itemGUID == itemGUID)
  211. return true;
  212.  
  213. }
  214.  
  215. return false;
  216. }
  217.  
  218. //////////////////////////////////////////////////////////////
  219. //********************* WorldScript ************************//
  220. //////////////////////////////////////////////////////////////
  221.  
  222. class StartUpTransmog : public WorldScript
  223. {
  224. public:
  225. StartUpTransmog() : WorldScript("StartUpTransmog") { }
  226.  
  227. void OnStartup()
  228. {
  229. TransmogMgr::LoadCharacterTransmog();
  230. }
  231. };
  232.  
  233. void AddSC_StartUpTransmog()
  234. {
  235. new StartUpTransmog();
  236. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement