Exemplo n.º 1
0
        public static void ReadAddonData(byte[] buffer, int size, WorldClass session)
        {
            // Clean possible addon data
            session.Addons.Clear();

            string addonName;
            byte addonEnabled;
            uint addonCRC, UrlStringCRC;

            // Decompress received Addon Data
            PacketReader addonData = new PacketReader(ZLib.ZLibDecompress(buffer, true, size), false);

            // Get Addon number
            int ctr, numAddons = addonData.Read<int>();

            // For each addon, read data from decoded packet and store into session for later use if needed
            for (ctr = 0; ctr < numAddons; ctr++)
            {
                addonName       = addonData.ReadCString();
                addonEnabled    = addonData.Read<byte>();
                addonCRC        = addonData.Read<uint>();
                UrlStringCRC    = addonData.Read<uint>();

                // Get the addon with same properties
                var Addon = AddonMgr.GetAddon(addonName, addonEnabled, addonCRC, UrlStringCRC);

                // Add if found, add default one if not.
                if (Addon != null)
                    session.Addons.Add(Addon);
                else
                    // Note: This can be skipped for those with no addon data.
                    // TODO: Test that!
                    session.Addons.Add(new Framework.ObjectDefines.Addon()
                    {
                        AuthType        = 2,
                        Enabled         = addonEnabled,
                        CRC             = addonCRC,
                        HasPUBData      = 0,
                        PUBData         = null,
                        Version         = 1, // Fixed value
                        HasUrlString    = 0,
                        UrlString       = addonName,
                        UrlStringCRC    = UrlStringCRC
                    });
            }

            int addonEnd = addonData.Read<int>(); // Unknown
        }