Exemple #1
0
        /// <summary>
        /// Reads in a NetCliConnect message from the stream
        /// </summary>
        /// <param name="s">Stream to read the message from</param>
        /// <returns>Connection YData (an array of 64 bytes) or NULL if the message is malformed</returns>
        protected byte[] IReadNetCliConnect(hsStream s)
        {
            byte[] y_data = null;
            try {
                if (s.ReadByte() != plNetCore.kNetCliConnect) return null;
                int size = (int)s.ReadByte() - 2;
                y_data = s.ReadBytes(size);
            } catch (Exception e) {
            #if DEBUG
                throw e;
            #else
                return null;
            #endif
            }

            // Truncate the YData if it's too large
            if (y_data.Length > 64) {
                byte[] old = y_data;
                y_data = new byte[64];
                Buffer.BlockCopy(old, 0, y_data, 0, 64);
            }

            // The client sends us the YData in Little Endian, but
            // BigNum wants Big Endian (because OpenSSL). Let's fix that.
            Array.Reverse(y_data);

            return y_data;
        }
Exemple #2
0
        public static Color ReadRGBA8(hsStream s)
        {
            int r = (int)s.ReadByte();
            int g = (int)s.ReadByte();
            int b = (int)s.ReadByte();
            int a = (int)s.ReadByte();

            return Color.FromArgb(a, r, g, b);
        }
Exemple #3
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fFlags = s.ReadByte();
            fNumFrames = s.ReadByte();
            fVoiceData = s.ReadStdString();

            fReceivers.Capacity = (int)s.ReadByte();
            for (int i = 0; i < fReceivers.Capacity; i++)
                fReceivers.Insert(i, s.ReadUInt());
        }
Exemple #4
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fSecsRunning = s.ReadDouble();
            fSession = (SessionTypes)s.ReadByte();
        }
Exemple #5
0
 public void Read(hsStream s)
 {
     fType = (ENetProtocol)s.ReadByte();
     if (s.ReadUShort() != kHeaderSize)
         throw new NotSupportedException();
     fBuildID = s.ReadUInt();
     fBuildType = (EBuildType)s.ReadUInt();
     fBranchID = s.ReadUInt();
     fProductUuid = pnHelpers.ReadUuid(s);
 }
Exemple #6
0
 public void Read(hsStream s)
 {
     fType = (ENetProtocol)s.ReadByte();
     if (s.ReadUShort() != kHeaderSize)
         throw new NotSupportedException();
     fBuildID = s.ReadUInt();
     fProtocolVer = s.ReadUInt();
     if (fProtocolVer < 50)
         fProtocolVer = 50; // <= 50 are the old "Build Type" values...
     fBranchID = s.ReadUInt();
     fProductUuid = pnHelpers.ReadUuid(s);
 }
Exemple #7
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fType = (NotificationType)s.ReadInt();
            fState = s.ReadFloat();
            if (s.Version < plVersion.EndOfAges)
                fID = s.ReadInt();
            else
                fID = (int)s.ReadByte();

            fEvents.Capacity = s.ReadInt();
            for (int i = 0; i < fEvents.Capacity; i++)
                fEvents.Add(proEventData.Read(s, mgr));
        }
Exemple #8
0
 public void Read(hsStream s)
 {
     byte mask = s.ReadByte();
     fQuality[0] = (byte)((mask >> 4) | 0xF0);
     fQuality[1] = (byte)(mask | 0xF0);
 }
Exemple #9
0
 internal static int VariableLengthRead(hsStream s, int size)
 {
     if (size < 0x100)
         return (int)s.ReadByte();
     else if (size < 0x10000)
         return (int)s.ReadShort();
     else
         return s.ReadInt();
 }
Exemple #10
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            // Cache it.
            fVersion = mgr.Version;

            // Cyan stores these values, but we're just going to
            //     save the stream and have fun with it...
            fBuffer = new byte[s.ReadInt()];
            Compression type = (Compression)s.ReadByte();
            uint len = s.ReadUInt();

            if (type == Compression.kZlib) {
                short streamType = s.ReadShort();
                byte[] buf = s.ReadBytes((int)len - 2);

                // Create a zlib-compatible inflator
                // Note: incoming has no zlib header/footer
                //       System.IO.Compression sucks.
                Inflater zlib = new Inflater(true);
                zlib.Inflate(buf);

                Buffer.BlockCopy(BitConverter.GetBytes(streamType), 0, fBuffer, 0, 2);
                Buffer.BlockCopy(buf, 0, fBuffer, 2, buf.Length);
            } else
                fBuffer = s.ReadBytes((int)len);
        }
Exemple #11
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            fFlags = (Flags)s.ReadShort();

            if (HasAccount)
                fAcctUUID = new Guid(s.ReadBytes(16));
            if (HasPlayerID)
                fPlayerID = s.ReadUInt();
            if (HasPlayerName)
                fPlayerName = s.ReadStdString();
            if (HasCCRLevel)
                fCCRLevel = s.ReadByte();
            if (HasProtectedLogin)
                fProtectedLogin = s.ReadBool();
            if (HasBuildType)
                fBuildType = s.ReadByte();
            if (HasSrcAddr)
                fSrcAddr = s.ReadUInt();
            if (HasSrcPort)
                fSrcPort = s.ReadUShort();
            if (HasReserved)
                fReserved = s.ReadUShort();
            if (HasClientKey)
                fClientKey = s.ReadStdString();
        }
Exemple #12
0
        public void Read(hsStream s)
        {
            // Magically figure out what version we have...
            uint prpVer = s.ReadUInt();
            switch (prpVer) {
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    s.Version = new plVersion(2, 0, 0, 0);
                    break;
                case 6:
                    s.Version = plVersion.MystOnline;
                    break;
                default:
                    // Must be some sort of Myst 5 variant...
                    s.Rewind();
                    prpVer = (uint)s.ReadUShort();
                    switch (prpVer) {
                        case 6:
                            s.Version = plVersion.EndOfAges;
                            break;
                        case 9:
                            s.Version = plVersion.HexIsle;
                            break;
                        default:
                            throw new plVersionException(prpVer);
                    }
                    break;
            }

            if (s.Version.IsPlasma21)
                IReadClassVersions(s);

            fLocation.Read(s);
            fAge = s.ReadSafeString();
            if (s.Version.IsPreMystOnline) fChapter = s.ReadSafeString();
            else if (s.Version.IsMystOnline) fChapter = "District";
            fPage = s.ReadSafeString();

            // Some more versioning stuff for Uru...
            if (s.Version.IsMystOnline)
                s.Version = new plVersion(2, 0, s.ReadUShort(), 0);
            else if (s.Version.IsPreMystOnline)
                s.Version = new plVersion(2, 0, s.ReadUShort(), s.ReadUShort());

            if (prpVer < 6) {
                if (prpVer < 5) // IndexChecksum -- deprecated...
                    s.ReadUInt();
                if (prpVer >= 2)
                    fReleaseVersion = s.ReadInt();
                if (prpVer >= 3)
                    fFlags = (Flags)s.ReadInt();
            }

            if (prpVer >= 4)
                fChecksum = s.ReadUInt();
            if (prpVer >= 5) {
                fDataStart = s.ReadUInt();
                fIndexStart = s.ReadUInt();
            } else {
                //prm/prx???
                fDataStart = 0;
                fIndexStart = s.ReadByte();
            }

            // Garbage
            if (s.Version.IsMystOnline)
                IReadClassVersions(s);
        }
Exemple #13
0
 public void Read(hsStream s)
 {
     fParent = s.ReadUInt();
     fChild = s.ReadUInt();
     fSaver = s.ReadUInt();
     s.ReadByte(); // "Seen" -- might as well be garbage
 }
        public virtual void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad VarDescriptor IO Version");

            fName = s.ReadSafeString();
            string displayOptions = s.ReadStdString(); // TODO
            fCount = s.ReadInt();
            fType = (plAtomicType)s.ReadByte();
            Default = s.ReadSafeString();
            fFlags = (Flags)s.ReadInt();

            // Derived class in Cyan's code, but this is cleaner
            if (IsStateDesc) {
                fDescName = s.ReadSafeString();
                fVersion = (int)s.ReadShort();
            } else {
                fAtomicCount = (int)s.ReadShort();
                fAtomicType = (plAtomicType)s.ReadByte();
            }
        }
        public void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad StateDescriptor IO Version");

            fName = s.ReadSafeString();
            fVersion = (int)s.ReadShort();

            short count = s.ReadShort();
            fVariables.Capacity = count; // Optimization
            for (short i = 0; i < count; i++) {
                plVarDescriptor var = new plVarDescriptor(s.ReadBool()
                    ? plAtomicType.kStateDescriptor : plAtomicType.kNone);
                var.Read(s);
                fVariables.Add(var);
            }
        }
Exemple #16
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;
        }
Exemple #17
0
 public void Read(hsStream s)
 {
     fLocation = new plLocation();
     fLocation.Read(s);
     fFlags = (NetGroupConstants)s.ReadByte();
 }
Exemple #18
0
        public void Read(hsStream s)
        {
            ContentsFlags contents = (ContentsFlags)s.ReadByte();
            fLocation.Read(s);
            if ((contents & ContentsFlags.kHasLoadMask) != 0)
                if (!s.Version.IsPlasma21) fLoadMask.Read(s);
            fClassType = plManagedType.Read(s);
            if (s.Version.IsUruLive || s.Version.IsPlasma21)
                fObjectID = s.ReadUInt();
            fObjectName = s.ReadSafeString();
            if (s.Version.IsPlasma20) {
                if ((contents & ContentsFlags.kHasCloneIDs) != 0) {
                    fCloneID = s.ReadUInt();
                    fClonePlayerID = s.ReadUInt();
                }
            }

            if ((contents & (ContentsFlags.kHasLoadMask | ContentsFlags.kHasLoadMask2)) != 0)
                if (s.Version.IsPlasma21)
                    fLoadMask.Read(s);
        }
Exemple #19
0
 public static Color ReadRGB8(hsStream s)
 {
     return Color.FromArgb((int)s.ReadByte(), (int)s.ReadByte(), (int)s.ReadByte());
 }
        public void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad StateDescriptor IO Version");

            fName = s.ReadSafeString();
            fVersion = (int)s.ReadShort();

            short count = s.ReadShort();
            fVariables.Capacity = count; // Optimization
            for (short i = 0; i < count; i++) {
                plVarDescriptor var = null;

                bool isSD = s.ReadBool();
                if (isSD)
                    var = new plSDVarDescriptor();
                else
                    var = new plSimpleVarDescriptor();
                var.Read(s);
                fVariables.Add(var);
            }
        }
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            byte count = s.ReadByte();
            for (byte i = 0; i < count; i++)
                fPlayerIDs.Add(s.ReadUInt());
        }
        public virtual void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad VarDescriptor IO Version");

            fName = s.ReadSafeString();
            string displayOptions = s.ReadStdString(); // TODO
            fCount = s.ReadInt();
            fType = (plAtomicType)s.ReadByte();
            Default = s.ReadSafeString();
            fFlags = (Flags)s.ReadInt();
        }
Exemple #23
0
 public void Read(hsStream s)
 {
     Parse(s.Version, s.ReadUInt());
     if (s.Version.IsPlasma21)
         fFlags = (LocFlags)s.ReadByte();
     else
         fFlags = (LocFlags)s.ReadShort();
 }
Exemple #24
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            fFlags = (BitVectorFlags)s.ReadInt();

            if (HasVersion) {
                fVerMajor = s.ReadByte();
                fVerMinor = s.ReadByte();
            }

            if (HasTimeSent)
                fTimeSent = plUnifiedTime.Read(s);
            if (HasContext)
                fContext = s.ReadUInt();
            if (HasTransID)
                fTransID = s.ReadUInt();
            if (HasPlayerID)
                fPlayerID = s.ReadUInt();
            if (HasAccount)
                fAcctUUID = new Guid(s.ReadBytes(16));
        }
Exemple #25
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fCommand = (Cmd)s.ReadByte();
            fUser = s.ReadSafeString();
            fPlayerID = s.ReadUInt();
            fString = s.ReadSafeWString();
            fFlags = (Flags)s.ReadInt();
            fDelay = s.ReadFloat();
            fValue = s.ReadInt();
        }