ReadSByte() private method

private ReadSByte ( ) : sbyte
return sbyte
        protected void Button1_Click(object sender, EventArgs e)
        {
            //byte[] buffer = new Buffer[512];

            using (FileStream fs = File.Open(@"Z:\20121204.SVD", FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    FileHead fh = new FileHead();

                    fh.Name = br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString();
                    fh.Ver = br.ReadSByte().ToString();
                    fh.Size = br.ReadInt16().ToString();

                    byte[] temp = new byte[8];
                    br.Read(temp, 0, 8);

                    //fh.MachineSN = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
                    fh.MachineSN = temp.ToHexString();
                    fh.BootVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
                    fh.SoftVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
                    fh.SumRecord = br.ReadInt32().ToString();
                    fh.UploadRecord = br.ReadInt32().ToString();
                    fh.NextUploadFPtr = br.ReadInt32().ToString();

                    Response.Write(fh.ToString());
                }
            }
        }
Example #2
0
		public static FacetSector readSector(BinaryReader r) {
			FacetSector fs = new FacetSector();
			fs.facetID = r.ReadByte();
			fs.sectorID = r.ReadUInt16();

			for (int x = 0; x < 64; ++x) {
				fs.tiles[x] = new facetTile_t[64];
				for (int y = 0; y < 64; ++y) {
					fs.tiles[x][y].z = r.ReadSByte();
					fs.tiles[x][y].landtileGraphic = r.ReadUInt16();
					fs.tiles[x][y].delimitersCount = r.ReadByte();
					if (fs.tiles[x][y].delimitersCount > 0) {
						fs.tiles[x][y].delimiters = new facetDelimiter_t[fs.tiles[x][y].delimitersCount];
						for (int i = 0; i < fs.tiles[x][y].delimitersCount; ++i) {
							fs.tiles[x][y].delimiters[i].direction = r.ReadByte();
							if (fs.tiles[x][y].delimiters[i].direction < 8) {
								fs.tiles[x][y].delimiters[i].z = r.ReadSByte();
								fs.tiles[x][y].delimiters[i].graphic = r.ReadUInt32();
							}
						}
					}
					fs.tiles[x][y].staticsCount = r.ReadByte();
					if (fs.tiles[x][y].staticsCount > 0) {
						fs.tiles[x][y].statics = new facetStatic_t[fs.tiles[x][y].staticsCount];
						for (int i = 0; i < fs.tiles[x][y].staticsCount; ++i) {
							fs.tiles[x][y].statics[i].graphic = r.ReadUInt32();
							fs.tiles[x][y].statics[i].z = r.ReadSByte();
							fs.tiles[x][y].statics[i].color = r.ReadUInt32();
						}
					}
				}
			}

			return fs;
		}
 //--Methods
 public InstrumentChunk(string id, int size, BinaryReader reader)
     : base(id, size)
 {
     instNote = reader.ReadByte();
     instFineTune = reader.ReadSByte();
     instGain = reader.ReadSByte();
     instLowNote = reader.ReadByte();
     instHighNote = reader.ReadByte();
     instLowVelocity = reader.ReadByte();
     instHighVelocity = reader.ReadByte();
     reader.ReadByte(); //always read pad
 }
	public Metric(BinaryReader br)
	{
		advance = br.ReadSingle();
		u = br.ReadInt16();
		v = br.ReadInt16();
		bearingX = br.ReadSByte();
		bearingY = br.ReadSByte();
		width = br.ReadByte();
		height = br.ReadByte();
		first = br.ReadByte();
		second = br.ReadByte();
		prevNum = br.ReadByte();
		nextNum = br.ReadByte();
	}
 private void ClientData(BinaryReader source)
 {
     var mask = source.ReadUInt16();
     var view_ofs_z = (0!=(mask & 0x0001))?source.ReadSByte():22;
     var ang_ofs_1 = (0 != (mask & 0x0002)) ? (float)source.ReadSByte() : 0.0;
     var angles_0 = (0 != (mask & 0x0004)) ? source.ReadSByte() : 0;
     var vel_0 = (0 != (mask & 0x0020)) ? (source.ReadSByte()) : 0;
     var angles_1 = (0 != (mask & 0x0008)) ? (source.ReadSByte()) : 0;
     var vel_1 = (0 != (mask & 0x0040)) ? source.ReadSByte() : 0;
     var angles_2 = (0 != (mask & 0x0010)) ? source.ReadSByte() : 0;
     var vel_2 = (0 != (mask & 0x0080)) ? source.ReadSByte() : 0;
     var items = (0 != (mask & 0x0200)) ? source.ReadInt32() : 0x4001;
     var uk_bit_b10 = (0 != (mask & 0x0400)) ? 1 : 0; // bit 10
     var uk_bit_b11 = (0 != (mask & 0x0800)) ? 1 : 0; // bit 11
     var weaponframe = (0 != (mask & 0x1000)) ? source.ReadByte() : 0;
     var armorvalue = (0 != (mask & 0x2000)) ? source.ReadByte() : 0;
     var weaponmodel = (0 != (mask & 0x4000)) ? source.ReadByte() : 0;
     var health = source.ReadInt16();
     var currentammo = source.ReadByte();
     var ammo_shells = source.ReadByte();
     var ammo_nails = source.ReadByte();
     var ammo_rockets = source.ReadByte();
     var ammo_cells = source.ReadByte();
     var weapon = source.ReadByte();
 }
 public static string DeserializeToString(byte[] data)
 {
     MemoryStream stream = new MemoryStream(data);
     BinaryReader reader = new BinaryReader(stream);
     reader.ReadSByte();      //取出第一个null字符
     StringBuilder builder = new StringBuilder();
     int count = reader.ReadInt32();
     for (int i = 0; i < count; ++i)
     {
         sbyte flag = reader.ReadSByte();
         if (flag == LineFlag)
         {
             int line = reader.ReadInt32();
             flag = reader.ReadSByte();
             int sourceLine = builder.ToString().Split('\n').Length;
             for (int j = sourceLine; j < line; ++j)
                 builder.Append('\n');
         }
         TokenType type = (TokenType)flag;
         object value = null;
         switch (type)
         {
             case TokenType.Boolean:
                 value = (reader.ReadSByte() == 1);
                 break;
             case TokenType.String:
                 value = "\"" + Util.ReadString(reader).Replace("\n", "\\n") + "\"";
                 break;
             case TokenType.SimpleString:
                 value = "@\"" + Util.ReadString(reader) + "\"";
                 break;
             case TokenType.Identifier:
                 value = Util.ReadString(reader);
                 break;
             case TokenType.Number:
                 if (reader.ReadSByte() == 1)
                     value = reader.ReadDouble();
                 else
                     value = reader.ReadInt64() + "L";
                 break;
             default:
                 value = GetTokenString(type);
                 break;
         }
         builder.Append(value + " ");
     }
     return builder.ToString();
 }
Example #7
0
			public void Read(BinaryReader reader, MDStream stream)
			{	
				offs = reader.ReadUInt32 ();
				size = reader.ReadUInt32 ();

				StringBuilder name_builder = new StringBuilder ();
				while (true) {
					sbyte c = reader.ReadSByte();
					if (c == 0) 
						break;
					name_builder.Append ((char) c);
				}

				name = name_builder.ToString ();
				if (name.Length == 0)
					throw new BadImageException("Invalid stream name.");

				// Round up to dword boundary.
				long pos = reader.BaseStream.Position;
				if (stream != null) 
					pos -= stream.Root.filePos;
				pos += 3;
				pos &= ~3;
				if (stream != null) 
					pos += stream.Root.filePos;
				
				// Advance file pointer.
				reader.BaseStream.Position = pos;
			}
Example #8
0
        public static HighEnumLiteral Read(CatalogReader catalog, BinaryReader reader, uint literalSize, bool isSigned)
        {
            string name = catalog.GetString(reader.ReadUInt32());

            long value;
            switch (literalSize)
            {
                case 8:
                    value = reader.ReadInt64();
                    break;
                case 4:
                    if (isSigned)
                        value = reader.ReadInt32();
                    else
                        value = reader.ReadUInt32();
                    break;
                case 2:
                    if (isSigned)
                        value = reader.ReadInt16();
                    else
                        value = reader.ReadUInt16();
                    break;
                case 1:
                    if (isSigned)
                        value = reader.ReadSByte();
                    else
                        value = reader.ReadByte();
                    break;
                default:
                    throw new ArgumentException();
            }

            return new HighEnumLiteral(name, value);
        }
 public override object Read(BinaryReader buffer, Type resultType, TypeDescription typeDescriptor, byte code, BinaryJSONReader binaryJsonReader)
 {
     switch (code)
     {
         case BinaryValue.BYTE:
             return Convert.ChangeType(buffer.ReadByte(), resultType);
         case BinaryValue.SBYTE:
             return Convert.ChangeType(buffer.ReadSByte(), resultType);
         case BinaryValue.INT16:
             return Convert.ChangeType(buffer.ReadInt16(), resultType);
         case BinaryValue.UINT16:
             return Convert.ChangeType(buffer.ReadUInt16(), resultType);
         case BinaryValue.INT32:
             return Convert.ChangeType(buffer.ReadInt32(), resultType);
         case BinaryValue.UINT32:
             return Convert.ChangeType(buffer.ReadUInt32(), resultType);
         case BinaryValue.INT64:
             return Convert.ChangeType(buffer.ReadInt64(), resultType);
         case BinaryValue.UINT64:
             return Convert.ChangeType(buffer.ReadUInt64(), resultType);
         case BinaryValue.FLOAT:
             return Convert.ChangeType(buffer.ReadSingle(), resultType);
         case BinaryValue.BOOLEAN:
             return Convert.ChangeType(buffer.ReadBoolean(), resultType);
         case BinaryValue.DOUBLE:
             return Convert.ChangeType(buffer.ReadDouble(), resultType);
         case BinaryValue.DECIMAL:
             return Convert.ChangeType(buffer.ReadDecimal(), resultType);
         case BinaryValue.CHAR:
             return Convert.ChangeType(buffer.ReadChar(), resultType);
     }
     return null;
 }
Example #10
0
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     Interaction = reader.ReadUInt16();
     x = reader.ReadInt16();
     y = reader.ReadInt16();
     level = reader.ReadSByte();
 }
Example #11
0
 public static void DecodePackedFile(BinaryReader reader)
 {
     reader.ReadSByte();
     List<string> dictionary = PS.readDictionary(reader);
     XmlNode xmlroot = xDoc.CreateNode(XmlNodeType.Element, FileName, "");
     PS.readElement(reader, xmlroot, xDoc, dictionary);
     xDoc.AppendChild(xmlroot);
 }
Example #12
0
 public override void Deserialize(BinaryReader reader)
 {
     Interaction = reader.ReadUInt16();
     CallerID = reader.ReadInt16();
     x = reader.ReadInt16();
     y = reader.ReadInt16();
     level = reader.ReadSByte();
 }
Example #13
0
 public override void Deserialize(BinaryReader reader)
 {
     GUID = reader.ReadUInt32();
     x = reader.ReadInt16();
     y = reader.ReadInt16();
     level = reader.ReadSByte();
     dir = (Direction)reader.ReadByte();
 }
Example #14
0
 public string readBase64(BinaryReader reader, int lengthInBytes)
 {
     sbyte[] bytes = new sbyte[lengthInBytes];
     for (int i = 0; i < lengthInBytes; i++)
     {
         bytes[i] = reader.ReadSByte();
     }
     return byteArrayToBase64(bytes);
 }
 public static uint ReadUInt16FromSbytes(BinaryReader br)
 {
     sbyte[] b = new sbyte[2];
     for (int i = 0; i < 2; i++)
     {
         b[i] = br.ReadSByte();
     }
     return (ushort)(((b[0] & 0xff) << 8) | (b[1] & 0xff));
 }
 public static int ReadInt32FromSbytes(BinaryReader br)
 {
     sbyte[] b = new sbyte[4];
     for (int i = 0; i < 4; i++)
     {
         b[i] = br.ReadSByte();
     }
     return (((b[0] & 0xff) << 24) | ((b[1] & 0xff) << 16) | ((b[2] & 0xff) << 8) | (b[3] & 0xff));
 }
Example #17
0
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     ObjectID = reader.ReadInt16();
     x = reader.ReadInt16();
     y = reader.ReadInt16();
     level = reader.ReadSByte();
     dir = (Direction)reader.ReadByte();
 }
 public static List<Token> Deserialize(byte[] data)
 {
     MemoryStream stream = new MemoryStream(data);
     BinaryReader reader = new BinaryReader(stream);
     reader.ReadSByte();      //取出第一个null字符
     List<Token> tokens = new List<Token>();
     int count = reader.ReadInt32();
     int sourceLine = 0;
     for (int i = 0; i < count; ++i)
     {
         sbyte flag = reader.ReadSByte();
         if (flag == LineFlag)
         {
             sourceLine = reader.ReadInt32();
             flag = reader.ReadSByte();
         }
         TokenType type = (TokenType)flag;
         object value = null;
         switch (type)
         {
             case TokenType.Boolean:
                 value = (reader.ReadSByte() == 1);
                 break;
             case TokenType.String:
             case TokenType.SimpleString:
                 value = Util.ReadString(reader);
                 break;
             case TokenType.Identifier:
                 value = Util.ReadString(reader);
                 break;
             case TokenType.Number:
                 if (reader.ReadSByte() == 1)
                     value = reader.ReadDouble();
                 else
                     value = reader.ReadInt64();
                 break;
             default:
                 value = type.ToString();
                 break;
         }
         tokens.Add(new Token(type, value, sourceLine - 1, 0));
     }
     return tokens;
 }
 public void Deserialize(BinaryReader reader)
 {
     Operand = new VMSetBalloonHeadlineOperand();
     Operand.Read(reader.ReadBytes(8));
     Target = reader.ReadInt16();
     IconTarget = reader.ReadInt16();
     Index = reader.ReadSByte();
     Duration = reader.ReadInt32();
     Anim = reader.ReadInt32();
 }
 private static void ReadChild(BinaryReader reader, INode parent, ICollection<INode> container)
 {
     var type = (Type)reader.ReadSByte();
     if (type == Type.Folder)
     {
         ReadFolder(reader, parent, container);
     }
     else
     {
         ReadImageData(reader, parent, container);
     }
 }
Example #21
0
 public ItemState(BinaryReader reader, short type)
     : this()
 {
     Type = type;
     reader.ReadByte();
     Class = (ItemClass)reader.ReadByte();
     Slot = (ItemSlot)reader.ReadByte();
     BreakRate = reader.ReadByte();
     Gender = (Gender)reader.ReadByte();
     FreeHands = reader.ReadByte();
     LifePointsBonus = reader.ReadByte();
     SpellPointsBonus = reader.ReadByte();
     AttributeType = (AttributeType)reader.ReadByte();
     AttributeBonus = reader.ReadByte();
     SkillTypeBonus = (SkillType)reader.ReadByte();
     SkillBonus = reader.ReadByte();
     PhysicalDamageProtection = reader.ReadByte();
     PhysicalDamageCaused = reader.ReadByte();
     AmmunitionType = reader.ReadByte();
     SkillType1Tax = (SkillType)reader.ReadByte();
     SkillType2Tax = (SkillType)reader.ReadByte();
     Skill1Tax = reader.ReadSByte();
     Skill2Tax = reader.ReadSByte();
     TorchIntensity = reader.ReadByte();
     AmmoAnimation = reader.ReadByte();
     Spell = (ItemSpellType)reader.ReadByte();
     SpellID = reader.ReadByte();
     Charges = reader.ReadByte();
     NumRecharged = reader.ReadByte();
     MaxNumRecharged = reader.ReadByte();
     MaxCharges = reader.ReadByte();
     Count1 = reader.ReadByte();
     Count2 = reader.ReadByte();
     IconAnim = reader.ReadByte();
     Weight = reader.ReadInt16();
     Value = reader.ReadInt16()/10f;
     Icon = reader.ReadInt16();
     UsingClass = reader.ReadInt16();
     UsingRace = reader.ReadInt16();
 }
 public SampleHeader(BinaryReader reader)
 {
     sampleName = IOHelper.Read8BitString(reader, 20);
     start = reader.ReadUInt32();
     end = reader.ReadUInt32();
     startLoop = reader.ReadUInt32();
     endLoop = reader.ReadUInt32();
     sampleRate = reader.ReadUInt32();
     originalPitch = reader.ReadByte();
     pitchCorrection = reader.ReadSByte();
     sampleLink = reader.ReadUInt16();
     soundFontSampleLink = (SFSampleLink)reader.ReadUInt16();
 }
Example #23
0
 public Material(BinaryReader r)
 {
     name = ASCIIEncoding.ASCII.GetString(r.ReadBytes(32)).Split((char)0)[0];
     ambient = ReadColor(r);
     diffuse = ReadColor(r);
     specular = ReadColor(r);
     emissive = ReadColor(r);
     shininess = r.ReadSingle();
     transparency = r.ReadSingle();
     mode = r.ReadSByte();
     textureFile = ASCIIEncoding.ASCII.GetString(r.ReadBytes(128)).Split((char)0)[0];
     alphaMapFile = ASCIIEncoding.ASCII.GetString(r.ReadBytes(128)).Split((char)0)[0];
 }
Example #24
0
        public bool readBoolean(BinaryReader reader, int lengthInBytes)
        {
            bool @bool = lengthInBytes == 1;
            if (@bool)
            {
                if (reader.ReadSByte() != 1)
                {
                    throw new System.ArgumentException("Boolean error");
                }
            }

            return @bool;
        }
Example #25
0
        public void Deserialize(BinaryReader reader)
        {
            Type = (VMArchitectureCommandType)reader.ReadByte();
            x = reader.ReadInt32();
            y = reader.ReadInt32();
            level = reader.ReadSByte();

            x2 = reader.ReadInt32();
            y2 = reader.ReadInt32();

            pattern = reader.ReadUInt16();
            style = reader.ReadUInt16();
        }
Example #26
0
        static object Read(World world, BinaryReader r, Type t, ref bool result)
        {
            if (t == typeof(byte))
                return r.ReadByte();

            if (t == typeof(sbyte))
                return r.ReadSByte();

            if (t == typeof(char))
                return r.ReadChar();

            if (t == typeof(int))
                return r.ReadInt32();

            if (t == typeof(uint))
                return r.ReadUInt32();

            if (t == typeof(bool))
                return r.ReadBoolean();

            if (t == typeof(string))
                return r.ReadString(true);

            if (t == typeof(int2))
                return r.ReadInt2();

            if (t == typeof(long))
                return r.ReadInt64();

            if (t == typeof(ulong))
                return r.ReadUInt64();

            if (t == typeof(short))
                return r.ReadInt16();

            if (t == typeof(ushort))
                return r.ReadUInt16();

            if (t == typeof(Actor))
            {
                Actor ret;
                if (result)
                    result = TryGetActorFromUInt(world, r.ReadUInt32(), out ret);
                else
                    TryGetActorFromUInt(world, r.ReadUInt32(), out ret);

                return ret;
            }

            throw new Exception("Tried to deserialize unhandled type.");
        }
Example #27
0
        public EncounterGift6(byte[] data, bool oras)
        {
            Data = data;
            ORAS = oras;
            using (BinaryReader br = new BinaryReader(new MemoryStream(Data)))
            {
                Species = br.ReadUInt16();
                u2 = br.ReadUInt16();
                Form = br.ReadByte();
                Level = br.ReadByte();
                Shiny = br.ReadByte();
                Ability = br.ReadSByte();
                Nature = br.ReadSByte();
                u9 = br.ReadByte();
                uA = br.ReadByte();
                uB = br.ReadByte();
                HeldItem = br.ReadInt32();
                Gender = br.ReadSByte();

                if (ORAS)
                {
                    u11 = br.ReadByte();
                    MetLocation = br.ReadInt16();
                    Move = br.ReadUInt16();
                }

                for (int i = 0; i < 6; i++)
                    IVs[i] = br.ReadSByte();

                if (ORAS)
                {
                    ContestStats = br.ReadBytes(6);
                    u22 = br.ReadByte();
                }

                uLast = br.ReadByte();
            }
        }
Example #28
0
		static private sbyte[] streamToSbyte(BinaryReader stream, int length)
		{
			List<sbyte> list = new List<sbyte>();
			{
				sbyte ch;
				var i = 0;
				while ((ch = stream.ReadSByte()) != -1 && i < length)
				{
					list.Add(ch);
					i++;
				}
			}
			return list.ToArray();
		}
Example #29
0
File: Group.cs Project: tpb3d/TPB3D
        public Group(BinaryReader r)
        {
            flags = (Flags)r.ReadByte();
            name = ASCIIEncoding.ASCII.GetString(r.ReadBytes(32)).Split((char)0)[0];
            numTriangles = r.ReadUInt16();

            triangleIndices = new ushort[numTriangles];
            for (int i = 0; i < numTriangles; i++)
            {
                triangleIndices[i] = r.ReadUInt16();
            }

            materialIndex = r.ReadSByte();
        }
Example #30
0
 public static PmdMaterial Parse(BinaryReader br)
 {
     return new PmdMaterial
     {
         Diffuse = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle() },
         Power = br.ReadSingle(),
         Specular = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() },
         Ambient = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() },
         ToonIndex = br.ReadSByte(),
         NoEdge = br.ReadBoolean(),
         IndexCount = br.ReadInt32(),
         Texture = PmdDocument.ReadPmdString(br, 20),
     };
 }