Exemplo n.º 1
0
        public DataTable(int id, byte[] dataTableData)
        {
            this.ID = id;
            this.Properties = new List<DataTableProperty>();

            ProtoMessage protoMessage = new ProtoMessage(dataTableData);

            List<Object> values;

            if (protoMessage.Values.TryGetValue("1", out values))
            {
                this.IsEnd = (int)values[0] != 0;
            }

            if (protoMessage.Values.TryGetValue("2", out values))
            {
                byte[] buffer = (byte[])values[0];

                this.Name = Encoding.UTF8.GetString(buffer);
            }

            if (protoMessage.Values.TryGetValue("3", out values))
            {
                this.NeedsDecoder = (int)values[0] != 0;
            }

            if (protoMessage.Values.TryGetValue("4", out values))
            {
                for (int i = 0; i < values.Count; i++)
                {
                    byte[] dataTablePropertyData = (byte[])values[i];

                    DataTableProperty dataTableProperty = new DataTableProperty(dataTablePropertyData);

                    this.Properties.Add(dataTableProperty);
                }
            }
        }
Exemplo n.º 2
0
        private Vector ReadVectorXY(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            Vector result = new Vector();

            result.X = ReadFloat(bitStream, dataTableProperty);
            result.Y = ReadFloat(bitStream, dataTableProperty);

            return result;
        }
Exemplo n.º 3
0
        private Vector ReadVector(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            Vector result = new Vector();

            result.X = ReadFloat(bitStream, dataTableProperty);
            result.Y = ReadFloat(bitStream, dataTableProperty);

            if (!dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Normal))
            {
                result.Z = ReadFloat(bitStream, dataTableProperty);
            }
            else
            {
                bool isNegative = bitStream.ReadBit();

                float absolute = result.X * result.X + result.Y * result.Y;

                if (absolute < 1.0f)
                {
                    result.Z = (float)Math.Sqrt(1 - absolute);
                }
                else
                {
                    result.Z = 0f;
                }

                if (isNegative)
                {
                    result.Z *= -1;
                }
            }

            return result;
        }
Exemplo n.º 4
0
        private string ReadString(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            int length = (int)bitStream.ReadBits(9);

            string result = bitStream.ReadString(length);

            return result;
        }
Exemplo n.º 5
0
        private bool ReadSpecialFloat(BitStream bitStream, DataTableProperty dataTableProperty, out float result)
        {
            if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Coord))
            {
                result = ReadBitCoord(bitStream);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CoordMp))
            {
                result = ReadBitCoordMP(bitStream, false, false);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CoordMpLowPrecision))
            {
                result = ReadBitCoordMP(bitStream, false, true);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CoordMpIntegral))
            {
                result = ReadBitCoordMP(bitStream, true, false);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.NoScale))
            {
                result = bitStream.ReadFloat();

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Normal))
            {
                result = ReadBitNormal(bitStream);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CellCoord))
            {
                result = ReadBitCellCoord(bitStream, dataTableProperty.NumberOfBits, false, false);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CellCoordLowPrecision))
            {
                result = ReadBitCellCoord(bitStream, dataTableProperty.NumberOfBits, false, true);

                return true;
            }
            else if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.CellCoordIntegral))
            {
                result = ReadBitCellCoord(bitStream, dataTableProperty.NumberOfBits, true, false);

                return true;
            }

            result = 0;

            return false;
        }
Exemplo n.º 6
0
 private int ReadInt32(BitStream bitStream, DataTableProperty dataTableProperty)
 {
     if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Varint))
     {
         if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Unsigned))
         {
             return (int)bitStream.ReadVarint32();
         }
         else
         {
             return (int)bitStream.ReadVarint32();
         }
     }
     else
     {
         if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Unsigned))
         {
             return (int)bitStream.ReadBits(dataTableProperty.NumberOfBits);
         }
         else
         {
             return (int)bitStream.ReadBits(dataTableProperty.NumberOfBits);
         }
     }
 }
Exemplo n.º 7
0
        private float ReadFloat(BitStream bitStream, DataTableProperty dataTableProperty)
        {
            float result = 0.0f;

            if (ReadSpecialFloat(bitStream, dataTableProperty, out result))
            {
                return result;
            }

            ulong interp = bitStream.ReadBits(dataTableProperty.NumberOfBits);

            result = (float)interp / ((1 << dataTableProperty.NumberOfBits) - 1);
            result = dataTableProperty.LowValue + (dataTableProperty.HighValue - dataTableProperty.LowValue) * result;

            return result;
        }
Exemplo n.º 8
0
 public ServerClassProperty(string name, DataTableProperty dataTableProperty, DataTableProperty arrayElementProperty)
 {
     this.ArrayElementProperty = arrayElementProperty;
     this.DataTableProperty = dataTableProperty;
     this.Name = name;
 }
 private bool IsPropertyExcluded(DataTable dataTable, DataTableProperty dataTableProperty, List<ExcludedDataTableProperty> currentExcludes)
 {
     return currentExcludes.Exists(a => dataTable.Name == a.DataTableName && dataTableProperty.Name == a.Name);
 }