예제 #1
0
        public static long DecodeInt64(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
        {
            if (((SendPropFlag)prop.Flags & SendPropFlag.VARINT) != 0)
            {
                if (((SendPropFlag)prop.Flags & SendPropFlag.UNSIGNED) != 0)
                {
                    return((long)bitBuffer.ReadVarInt64());
                }

                return(bitBuffer.ReadSignedVarInt64());
            }

            uint highInt = 0;
            uint lowInt  = 0;
            var  sign    = 1;

            if (((SendPropFlag)prop.Flags & SendPropFlag.UNSIGNED) == 0)
            {
                sign    = bitBuffer.ReadOneBit() ? -1 : 1;
                lowInt  = bitBuffer.ReadUBitLong(32);
                highInt = bitBuffer.ReadUBitLong(prop.NumBits - 32 - 1);
            }
            else
            {
                lowInt  = bitBuffer.ReadUBitLong(32);
                highInt = bitBuffer.ReadUBitLong(prop.NumBits - 32);
            }

            long temp = lowInt | highInt << 32;

            return(temp * sign);
        }
예제 #2
0
 public static Vector2 DecodeVectorXY(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
 {
     return(new Vector2
     {
         x = DecodeFloat(bitBuffer, prop),
         y = DecodeFloat(bitBuffer, prop)
     });
 }
예제 #3
0
        private bool IsPropExcluded(CSVCMsgSendTable table, CSVCMsgSendTable.SendpropT prop)
        {
            for (var i = 0; i < _excludes.Count; ++i)
            {
                var exclude = _excludes[i];
                if (table.NetTableName == exclude.DtName && prop.VarName == exclude.VarName)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        public static float DecodeFloat(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
        {
            var val = 0f;

            if (DecodeSpecialFloat(bitBuffer, prop, out val))
            {
                return(val);
            }

            var interp = bitBuffer.ReadUBitLong(prop.NumBits);

            val = (float)interp / ((1 << prop.NumBits) - 1);
            val = prop.LowValue + (prop.HighValue - prop.LowValue) * val;

            return(val);
        }
예제 #5
0
        public static string DecodeString(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
        {
            const int maxStringBits   = 9;
            const int maxStringLength = 1 << maxStringBits;

            var len    = bitBuffer.ReadUBitLong(maxStringBits);
            var buffer = new byte[len + 1];

            if (len >= maxStringLength)
            {
                throw new Exception("Mathematics has failed us");
            }

            bitBuffer.ReadBits(buffer, (int)len << 3);

            return(Encoding.UTF8.GetString(buffer));
        }
예제 #6
0
        public static int DecodeInt(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
        {
            var flags = (SendPropFlag)prop.Flags;

            if ((flags & SendPropFlag.VARINT) != 0)
            {
                if ((flags & SendPropFlag.UNSIGNED) != 0)
                {
                    return((int)bitBuffer.ReadVarInt32());
                }

                return(bitBuffer.ReadSignedVarInt32());
            }

            if ((flags & SendPropFlag.UNSIGNED) != 0)
            {
                return((int)bitBuffer.ReadUBitLong(prop.NumBits));
            }

            return(bitBuffer.ReadSBitLong(prop.NumBits));
        }
예제 #7
0
        public static Vector3 DecodeVector(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop)
        {
            var vec = new Vector3
            {
                x = DecodeFloat(bitBuffer, prop),
                z = DecodeFloat(bitBuffer, prop)
            };

            if (((SendPropFlag)prop.Flags & SendPropFlag.NORMAL) == 0)
            {
                vec.y = DecodeFloat(bitBuffer, prop);
                return(vec);
            }

            var sign = bitBuffer.ReadOneBit() ? -1 : 1;
            var a2b2 = vec.x * vec.x + vec.z * vec.z;

            if (a2b2 < 1f)
            {
                vec.y = Mathf.Sqrt(1f - a2b2) * sign;
            }

            return(vec);
        }
예제 #8
0
        private static bool DecodeSpecialFloat(BitBuffer bitBuffer, CSVCMsgSendTable.SendpropT prop, out float val)
        {
            val = default(float);

            var flags = (SendPropFlag)prop.Flags;

            if ((flags & SendPropFlag.COORD) != 0)
            {
                val = bitBuffer.ReadBitCoord();
                return(true);
            }

            if ((flags & SendPropFlag.COORD_MP) != 0)
            {
                val = bitBuffer.ReadBitCoordMP(BitCoordType.None);
                return(true);
            }

            if ((flags & SendPropFlag.COORD_MP_LOWPRECISION) != 0)
            {
                val = bitBuffer.ReadBitCoordMP(BitCoordType.LowPrecision);
                return(true);
            }

            if ((flags & SendPropFlag.CELL_COORD_INTEGRAL) != 0)
            {
                val = bitBuffer.ReadBitCoordMP(BitCoordType.Integral);
                return(true);
            }

            if ((flags & SendPropFlag.NOSCALE) != 0)
            {
                val = bitBuffer.ReadBitFloat();
                return(true);
            }

            if ((flags & SendPropFlag.NORMAL) != 0)
            {
                val = bitBuffer.ReadBitNormal();
                return(true);
            }

            if ((flags & SendPropFlag.CELL_COORD) != 0)
            {
                val = bitBuffer.ReadBitCellCoord(prop.NumBits, BitCoordType.None);
                return(true);
            }

            if ((flags & SendPropFlag.CELL_COORD_LOWPRECISION) != 0)
            {
                val = bitBuffer.ReadBitCellCoord(prop.NumBits, BitCoordType.LowPrecision);
                return(true);
            }

            if ((flags & SendPropFlag.CELL_COORD_INTEGRAL) != 0)
            {
                val = bitBuffer.ReadBitCellCoord(prop.NumBits, BitCoordType.Integral);
                return(true);
            }

            return(false);
        }
예제 #9
0
        internal void ReadProperty <TVal>(CSVCMsgSendTable.SendpropT prop, int index, TVal value)
        {
            //Debug.LogFormat("{0}: {1}", prop.VarName, value);

            OnReadProperty(prop.VarName, index, value);
        }
예제 #10
0
 public FlattenedProperty(CSVCMsgSendTable.SendpropT prop, CSVCMsgSendTable.SendpropT arrayElemProp)
 {
     Property             = prop;
     ArrayElementProperty = arrayElemProp;
 }