]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
A couple more reader/writer things and maybe something else?
authorForest <chocozilla@gmail.com>
Fri, 20 Jul 2018 18:32:21 +0000 (11:32 -0700)
committerForest <chocozilla@gmail.com>
Fri, 20 Jul 2018 18:32:21 +0000 (11:32 -0700)
Hazel/MessageReader.cs
Hazel/MessageWriter.cs

index 7e4fc03507614acaeb61f610090b26a021c35c85..9287023bb19c2703f1f96162388caa6f6958f399 100644 (file)
@@ -76,6 +76,14 @@ namespace Hazel
             return output;
         }
 
+        public short ReadInt16()
+        {
+            short output =
+                (short)(this.Buffer[Position++]
+                | this.Buffer[Position++] << 8);
+            return output;
+        }
+
         public int ReadInt32()
         {
             int output = this.Buffer[Position++]
index 22640e6ac490b81d6ceacdc78404773948ca8fe6..7f388607aa7114a793d3014269c1fcf781433a1b 100644 (file)
@@ -113,6 +113,13 @@ namespace Hazel
             if (this.Position > this.Length) this.Length = this.Position;
         }
 
+        public void Write(short value)
+        {
+            this.Buffer[this.Position++] = (byte)value;
+            this.Buffer[this.Position++] = (byte)(value >> 8);
+            if (this.Position > this.Length) this.Length = this.Position;
+        }
+
         public void Write(ushort value)
         {
             this.Buffer[this.Position++] = (byte)value;
@@ -152,7 +159,7 @@ namespace Hazel
             this.Write(bytes);
         }
 
-        public void WriteBytesFull(byte[] bytes)
+        public void WriteBytesAndSize(byte[] bytes)
         {
             this.WritePacked((uint)bytes.Length);
             this.Write(bytes);