Esempio n. 1
0
        private List<HoldingKey> IReadKeyring(hsStream s, plLocation loc)
        {
            List<HoldingKey> keyring = new List<HoldingKey>();

            int types = s.ReadInt();
            for (int i = 0; i < types; i++) {
                plCreatableID type = plManagedType.Read(s);
                if (s.Version >= plVersion.MystOnline) {
                    s.ReadInt();  // Size until the next type
                    s.ReadByte(); // Flags???
                }

                int count = s.ReadInt();

                // Some optimizations
                keyring.Capacity += count;
                fKeyCollector.Reserve(loc, type, count);

                for (int j = 0; j < count; j++) {
                    HoldingKey key = new HoldingKey();
                    key.fKey = ReadUoid(s);
                    key.fOffset = s.ReadInt();
                    key.fSize = s.ReadInt();
                    key.fStream = s;

                    keyring.Add(key);
                }
            }

            plDebugLog.GetLog("ResManager").Debug(String.Format("\t* Keyring: {0} Keys", keyring.Count));
            return keyring;
        }
Esempio n. 2
0
        private void IReadHoldingKey(HoldingKey key)
        {
            // Prep the source stream...
            hsStream s = key.fStream;
            s.Seek(key.fOffset);

            // Let's dump this object into a protected stream
            MemoryStream ms = new MemoryStream();
            ms.Write(s.ReadBytes(key.fSize), 0, key.fSize);
            ms.Position = 0;

            //Now read the creatable from that protected stream
            hsStream pStream = new hsStream(ms);
            pStream.Version = s.Version;
            plCreatable pCre = ReadCreatable(pStream);

            // Do we need to use a plHexBuffer (unimplemented data)
            if (pCre == null) {
                plHexBuffer buf = new plHexBuffer();
                buf.Read(pStream, this);
                fObjects.Add(key.fKey, buf);

                plDebugLog.GetLog("ResManager").Warn(String.Format(
                    "Unimplemented KeyedObject '{0}' in {1}",
                    plManagedType.ClassName(key.fKey.ClassType),
                    key.fKey.Location));
            } else
                fObjects.Add(key.fKey, (hsKeyedObject)pCre);

            //Need to warn about read/size mismatch?
            if (ms.Length > ms.Position)
                plDebugLog.GetLog("ResManager").Warn(
                    String.Format("Read Error: {0} has {1} bytes left over", key.fKey.ObjectName, (ms.Length - ms.Position)));

            // Clean up
            pStream.Close();
            ms.Close();
        }