예제 #1
0
 public static void WriteRGBA(hsStream s, Color c)
 {
     s.WriteFloat(Convert.ToSingle(c.R) / 255.0f);
     s.WriteFloat(Convert.ToSingle(c.G) / 255.0f);
     s.WriteFloat(Convert.ToSingle(c.B) / 255.0f);
     s.WriteFloat(Convert.ToSingle(c.A) / 255.0f);
 }
예제 #2
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fSecsRunning = s.ReadDouble();
            fSession = (SessionTypes)s.ReadByte();
        }
예제 #3
0
 public static void WriteRGBA8(hsStream s, Color c)
 {
     s.WriteByte(c.R);
     s.WriteByte(c.G);
     s.WriteByte(c.B);
     s.WriteByte(c.A);
 }
예제 #4
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            s.WriteDouble(fSecsRunning);
            s.WriteByte((byte)fSession);
        }
예제 #5
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;
        }
예제 #6
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            s.WriteInt((int)fCommand);
            s.WriteStdString(fString);
        }
예제 #7
0
 public void Read(hsStream s)
 {
     fX = s.ReadFloat();
     fY = s.ReadFloat();
     fZ = s.ReadFloat();
     fW = s.ReadFloat();
 }
예제 #8
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fCommand = (Cmd)s.ReadInt();
            fString = s.ReadStdString();
        }
예제 #9
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fSynchFlags = (Flags)s.ReadInt();
            if (s.Version.IsPlasma21)
                fSynchFlags &= (Flags)~0x8;

            if (s.Version.IsPlasma21 && (((int)fSynchFlags & 0x06) != 0) ||
               (s.Version.IsPlasma20 && ExcludeStates)) {
                short count = s.ReadShort();
                for (short i = 0; i < count; i++)
                    fExcludeStates.Add((States)Enum.Parse(typeof(States), s.ReadStdString()));
            }

            //Plasma 2.1+ ends here...
            if (s.Version.IsPlasma21) {
                fSynchFlags = 0; // Synch Flags are pretty useless in Plasma21
                return;
            } else if (s.Version.IsPlasma20) {
                if (VolatileStates) {
                    short count = s.ReadShort();
                    for (short i = 0; i < count; i++)
                        fVolatileStates.Add((States)Enum.Parse(typeof(States), s.ReadStdString()));
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Reads a key reference from the stream
        /// </summary>
        /// <param name="s">Stream containing a key reference</param>
        /// <returns>The key referenced in the stream or null (if null reference)</returns>
        public plKey ReadKey(hsStream s)
        {
            if (!s.Version.IsPlasma21)
                if (!s.ReadBool()) return null;

            return ReadUoid(s);
        }
예제 #11
0
 public void Write(hsStream s)
 {
     s.WriteFloat(fX);
     s.WriteFloat(fY);
     s.WriteFloat(fZ);
     s.WriteFloat(fW);
 }
예제 #12
0
 /// <summary>
 /// Reads an arbitrary Creatable from the current position in the stream
 /// </summary>
 /// <param name="s">Stream to read from</param>
 /// <returns></returns>
 public plCreatable ReadCreatable(hsStream s)
 {
     plCreatable pCre = plFactory.Create(plManagedType.Read(s));
     if (pCre != null)
         pCre.Read(s, this);
     return pCre;
 }
예제 #13
0
 public override void Write(hsStream s, hsResMgr mgr)
 {
     if (s.Version.IsMystOnline)
         mgr.WriteKey(s, fpKey);
     else
         mgr.WriteUoid(s, fpKey);
 }
예제 #14
0
 public override void Write(hsStream s)
 {
     s.WriteUInt(fTransID);
     pnHelpers.WriteString(s, fAccount, 64);
     s.WriteBytes(fHash);
     s.WriteUInt(fSrvChg);
     s.WriteUInt(fCliChg);
 }
예제 #15
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            s.WriteBool(fDeliveryTime.HasValue);
            if (fDeliveryTime.HasValue)
                plUnifiedTime.Write(s, fDeliveryTime.Value);
        }
예제 #16
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            s.WriteBool(fIsInitialState);
            s.WriteBool(fPersistOnServer);
            s.WriteBool(fIsAvatarState);
        }
예제 #17
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fIsInitialState = s.ReadBool();
            fPersistOnServer = s.ReadBool();
            fIsAvatarState = s.ReadBool();
        }
예제 #18
0
 public override void Read(hsStream s)
 {
     fTransID = s.ReadUInt();
     fAccount = pnHelpers.ReadString(s, 64);
     fHash = s.ReadBytes(20);
     fSrvChg = s.ReadUInt();
     fCliChg = s.ReadUInt();
 }
예제 #19
0
 public void Write(hsStream s)
 {
     s.WriteByte((byte)fType);
     s.WriteUShort(kHeaderSize);
     s.WriteUInt(fBuildID);
     s.WriteUInt((uint)fBuildType);
     s.WriteUInt(fBranchID);
     pnHelpers.WriteUuid(s, fProductUuid);
 }
예제 #20
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            mgr.WriteUoid(s, fObjectHelper);
            s.WriteBool(fIsPlayer);
            s.WriteBool(fIsLoading);
            s.WriteBool(fIsInitialState);
        }
예제 #21
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);
        }
예제 #22
0
        protected void IWriteNetCliEncrypt(hsStream s, byte[] seed)
        {
            if (seed.Length != 7)
                throw new ArgumentException("seed should be an array of exactly 7 bytes");

            s.WriteByte(plNetCore.kNetCliEncrypt);
            s.WriteByte(9);
            s.WriteBytes(seed);
        }
예제 #23
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fObjectHelper = mgr.ReadUoid(s); // Yes, ReadUoid. Not ReadKey.
            fIsPlayer = s.ReadBool();
            fIsLoading = s.ReadBool();
            fIsInitialState = s.ReadBool();
        }
예제 #24
0
        private void IAcceptConnection(Socket cli)
        {
            hsStream s = new hsStream(new NetworkStream(cli, false));
            pnCli2Srv_Connect hdr = new pnCli2Srv_Connect();
            hdr.Read(s);
            s.Close();

            IAcceptConnection(cli, hdr);
        }
예제 #25
0
 public void WriteCreatable(hsStream s, plCreatable pCre)
 {
     if (pCre == null)
         plManagedType.Write(s, plCreatableID.NULL);
     else {
         plManagedType.Write(s, plFactory.ClassIndex(pCre));
         pCre.Write(s, this);
     }
 }
예제 #26
0
 public override void Read(hsStream s, hsResMgr mgr)
 {
     plKey key = null;
     if (s.Version.IsMystOnline)
         key = mgr.ReadKey(s);
     else
         key = mgr.ReadUoid(s);
     fpKey = key;
 }
예제 #27
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);
 }
예제 #28
0
        public static Color ReadRGB(hsStream s)
        {
            float r = s.ReadFloat();
            float g = s.ReadFloat();
            float b = s.ReadFloat();

            return Color.FromArgb(Convert.ToInt32(r * 255.0f),
                Convert.ToInt32(g * 255.0f),
                Convert.ToInt32(b * 255.0f));
        }
예제 #29
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            fInvisLevel = s.ReadInt();
            fLeavingAge = s.ReadBool();
            fLinkKey = mgr.ReadKey(s);
            fEffects = s.ReadInt();
            fLinkAnimKey = mgr.ReadKey(s);
        }
예제 #30
0
        public override void Write(hsStream s, hsResMgr mgr)
        {
            base.Write(s, mgr);

            s.WriteInt(fInvisLevel);
            s.WriteBool(fLeavingAge);
            mgr.WriteKey(s, fLinkKey);
            s.WriteInt(fEffects);
            mgr.WriteKey(s, fLinkAnimKey);
        }