Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WorldSession::ReadAddonsInfo(ByteBuffer &data)
- {
- if (data.rpos() + 4 > data.size())
- return;
- uint32 size;
- data >> size;
- if (!size)
- return;
- if (size > 0xFFFFF)
- {
- TC_LOG_DEBUG("addon", "WorldSession::ReadAddonsInfo: AddOnInfo too big, size %u", size);
- return;
- }
- uLongf uSize = size;
- uint32 pos = data.rpos();
- ByteBuffer addonInfo;
- addonInfo.resize(size);
- if (uncompress(addonInfo.contents(), &uSize, data.contents() + pos, data.size() - pos) == Z_OK)
- {
- uint32 addonsCount;
- addonInfo >> addonsCount; // addons count
- for (uint32 i = 0; i < addonsCount; ++i)
- {
- std::string addonName;
- uint8 enabled;
- uint32 crc, unk1;
- // check next addon data format correctness
- if (addonInfo.rpos() + 1 > addonInfo.size())
- return;
- addonInfo >> addonName;
- addonInfo >> enabled >> crc >> unk1;
- TC_LOG_DEBUG("addon", "AddOn: %s (CRC: 0x%x) - enabled: 0x%x - Unknown2: 0x%x", addonName.c_str(), crc, enabled, unk1);
- AddonInfo addon(addonName, enabled, crc, 2, true);
- SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addonName);
- if (savedAddon)
- {
- if (addon.CRC != savedAddon->CRC)
- TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
- else
- TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
- }
- else
- {
- AddonMgr::SaveAddon(addon);
- 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());
- }
- /// @todo Find out when to not use CRC/pubkey, and other possible states.
- m_addonsList.push_back(addon);
- }
- uint32 currentTime;
- addonInfo >> currentTime;
- TC_LOG_DEBUG("addon", "AddOn: CurrentTime: %u", currentTime);
- }
- else
- TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement