Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. void WorldSession::ReadAddonsInfo(ByteBuffer &data)
  2. {
  3. if (data.rpos() + 4 > data.size())
  4. return;
  5.  
  6. uint32 size;
  7. data >> size;
  8.  
  9. if (!size)
  10. return;
  11.  
  12. if (size > 0xFFFFF)
  13. {
  14. TC_LOG_DEBUG("addon", "WorldSession::ReadAddonsInfo: AddOnInfo too big, size %u", size);
  15. return;
  16. }
  17.  
  18. uLongf uSize = size;
  19.  
  20. uint32 pos = data.rpos();
  21.  
  22. ByteBuffer addonInfo;
  23. addonInfo.resize(size);
  24.  
  25. if (uncompress(addonInfo.contents(), &uSize, data.contents() + pos, data.size() - pos) == Z_OK)
  26. {
  27. try
  28. {
  29. uint32 addonsCount;
  30. addonInfo >> addonsCount; // addons count
  31.  
  32. for (uint32 i = 0; i < addonsCount; ++i)
  33. {
  34. std::string addonName;
  35. uint8 enabled;
  36. uint32 crc, unk1;
  37.  
  38. // check next addon data format correctness
  39. if (addonInfo.rpos() + 1 > addonInfo.size())
  40. return;
  41.  
  42. addonInfo >> addonName;
  43.  
  44. addonInfo >> enabled >> crc >> unk1;
  45.  
  46. TC_LOG_DEBUG("addon", "AddOn: %s (CRC: 0x%x) - enabled: 0x%x - Unknown2: 0x%x", addonName.c_str(), crc, enabled, unk1);
  47.  
  48. AddonInfo addon(addonName, enabled, crc, 2, true);
  49.  
  50. SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addonName);
  51. if (savedAddon)
  52. {
  53. if (addon.CRC != savedAddon->CRC)
  54. TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  55. else
  56. TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  57. }
  58. else
  59. {
  60. AddonMgr::SaveAddon(addon);
  61. TC_LOG_WARN("addon", "Addon: %s: unknown (CRC: 0x%x) - accountId %d (storing addon name and checksum to database)", addon.Name.c_str(), addon.CRC, GetAccountId());
  62. }
  63.  
  64. /// @todo Find out when to not use CRC/pubkey, and other possible states.
  65. m_addonsList.push_back(addon);
  66.  
  67. }
  68. catch (ByteBufferException const& e)
  69. {
  70. }
  71. }
  72.  
  73. uint32 currentTime;
  74. addonInfo >> currentTime;
  75. TC_LOG_DEBUG("addon", "AddOn: CurrentTime: %u", currentTime);
  76. }
  77. else
  78. TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement