Example #1
0
        public override void Deserialize(Bitstream msg)
        {
            SnapId = msg.ReadUInt32();
            BaselineId = msg.ReadUInt32();

            ushort count = msg.ReadByte();
            Dictionary<int, NetworkObject> state = new Dictionary<int, NetworkObject>();
            int addDeltaCount = 0;
            for (int i=0; i < count; ++i)
            {
                ushort objTypeId = msg.ReadByte();
                var entId = msg.ReadVariableUInt32();

                NetworkObject obj = ObjectMapper.Lookup(entId, objTypeId, true);
                if (obj == null)
                {
                    obj = ObjectMapper.Create(entId, objTypeId);
                }

                NetworkObject realObj = ObjectMapper.Lookup(entId, objTypeId, false);
                var realHash = 0;
                if (realObj != null)
                    realHash = realObj.GetHashCode();

                NetworkObject baseline = null;
                var usebaseLine = msg.ReadBool();
                uint bOffset = 0;
                if (usebaseLine)
                {
                    byte offset = msg.ReadByte();
                    var objBaselineId = BaselineId - (uint)offset;
                    bOffset = objBaselineId;

                    baseline = ObjectMapper.GetBaseline(objBaselineId, realHash);
                }

                var ownerType = obj.GetType().GetTypeInfo();
                var dItem = DataLookupTable.Get(ownerType);
                ReadNetObject(dItem, msg, obj, baseline);
                ObjectMapper.AddDeltaState(realHash, SnapId, obj);

                if (BaselineId != 0 && realHash != 0)
                    addDeltaCount++;
            }

            if (addDeltaCount == count)
                ObjectMapper.LastSimId = BaselineId;
        }
Example #2
0
        private void ReadChunkHeader(Bitstream stream)
        {
            header = new ChunkedHeader();

            header.IsFile = stream.ReadBool();
            if (header.IsFile)
            {
                var filenameLength = stream.ReadUInt32();
                var filename       = new byte[filenameLength + 1]; // semantically wrong. should be
                // 0x104
                stream.Read(filename, 0, (int)filenameLength);     // and then read to end of string
                filename[filenameLength] = 0;                      // whatever
                header.Filename          = Encoding.UTF8.GetString(filename);
                throw new NotImplementedException();
            }

            header.IsCompressed = stream.ReadBool();
            if (header.IsCompressed)
            {
                header.DecompressedLength = stream.ReadBits(26);
            }

            header.ByteLength = stream.ReadBits(26);
            header.ChunkCount =
                (header.ByteLength + DotaGameConnection.BYTES_PER_CHUNK - 1) /
                DotaGameConnection.BYTES_PER_CHUNK;

            Receiving     = true;
            dataIn        = new byte[header.ByteLength];
            dataReceived  = new bool[header.ChunkCount];
            countReceived = 0;
        }
Example #3
0
        private void ReadChunkHeader(Bitstream stream)
        {
            header = new ChunkedHeader();

            header.IsFile = stream.ReadBool();
            if (header.IsFile)
            {
                uint   filenameLength = stream.ReadUInt32();
                byte[] filename       = new byte[filenameLength + 1]; // semantically wrong. should be
                                                                      // 0x104
                stream.Read(filename, 0, (int)filenameLength);        // and then read to end of string
                filename[filenameLength] = 0;                         // whatever
                header.Filename          = Encoding.UTF8.GetString(filename);
                log.ErrorFormat("read filename: \"{0}\" ({1})", filenameLength, header.Filename);
                throw new NotImplementedException();
            }

            header.IsCompressed = stream.ReadBool();
            if (header.IsCompressed)
            {
                header.DecompressedLength = stream.ReadBits(26);
                log.DebugFormat(
                    "chunkheader compressed: decompressed len {0}",
                    header.DecompressedLength);
            }

            header.ByteLength = stream.ReadBits(26);
            header.ChunkCount =
                (header.ByteLength + Connection.BYTES_PER_CHUNK - 1) /
                Connection.BYTES_PER_CHUNK;
            log.DebugFormat(
                "chunkheader len {0} expecting {1} chunks",
                header.ByteLength, header.ChunkCount);

            Receiving     = true;
            dataIn        = new byte[header.ByteLength];
            dataReceived  = new bool[header.ChunkCount];
            countReceived = 0;
        }
Example #4
0
        private void ReadChunkHeader(Bitstream stream) {
            header = new ChunkedHeader();

            header.IsFile = stream.ReadBool();
            if (header.IsFile) {
                uint filenameLength = stream.ReadUInt32();
                byte[] filename = new byte[filenameLength + 1]; // semantically wrong. should be
                                                                // 0x104
                stream.Read(filename, 0, (int)filenameLength); // and then read to end of string
                filename[filenameLength] = 0; // whatever 
                header.Filename = Encoding.UTF8.GetString(filename);
                log.ErrorFormat("read filename: \"{0}\" ({1})", filenameLength, header.Filename);
                throw new NotImplementedException();
            }

            header.IsCompressed = stream.ReadBool();
            if (header.IsCompressed) {
                header.DecompressedLength = stream.ReadBits(26);
                log.DebugFormat(
                    "chunkheader compressed: decompressed len {0}", 
                    header.DecompressedLength);
            }

            header.ByteLength = stream.ReadBits(26);
            header.ChunkCount = 
                (header.ByteLength + Connection.BYTES_PER_CHUNK - 1) /
                Connection.BYTES_PER_CHUNK;
            log.DebugFormat(
                "chunkheader len {0} expecting {1} chunks", 
                header.ByteLength, header.ChunkCount);

            Receiving = true;
            dataIn = new byte[header.ByteLength];
            dataReceived = new bool[header.ChunkCount];
            countReceived = 0;
        }
Example #5
0
 public override void Deserialize(Bitstream msg)
 {
     OwnerEntityId = msg.ReadUInt32();
     Success = msg.ReadBool();
 }
Example #6
0
 public override void Deserialize(Bitstream msg)
 {
     SimId = msg.ReadUInt32();
 }