Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 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. uint32 addonsCount;
  28. addonInfo >> addonsCount; // addons count
  29.  
  30. for (uint32 i = 0; i < addonsCount; ++i)
  31. {
  32. std::string addonName;
  33. uint8 enabled;
  34. uint32 crc, unk1;
  35.  
  36. // check next addon data format correctness
  37. if (addonInfo.rpos() + 1 > addonInfo.size())
  38. return;
  39.  
  40. addonInfo >> addonName;
  41.  
  42. addonInfo >> enabled >> crc >> unk1;
  43.  
  44. TC_LOG_DEBUG("addon", "AddOn: %s (CRC: 0x%x) - enabled: 0x%x - Unknown2: 0x%x", addonName.c_str(), crc, enabled, unk1);
  45.  
  46. AddonInfo addon(addonName, enabled, crc, 2, true);
  47.  
  48. SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addonName);
  49. if (savedAddon)
  50. {
  51. if (addon.CRC != savedAddon->CRC)
  52. TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  53. else
  54. TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
  55. }
  56. else
  57. {
  58. AddonMgr::SaveAddon(addon);
  59. 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());
  60. }
  61.  
  62. /// @todo Find out when to not use CRC/pubkey, and other possible states.
  63. m_addonsList.push_back(addon);
  64. }
  65.  
  66. uint32 currentTime;
  67. addonInfo >> currentTime;
  68. TC_LOG_DEBUG("addon", "AddOn: CurrentTime: %u", currentTime);
  69. }
  70. else
  71. TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement