public void Deserialize(NetBuffer pPacketReader)
 {
     name     = pPacketReader.ReadString();
     subspace = pPacketReader.ReadInt32();
     clock    = pPacketReader.ReadDouble();
     unk      = pPacketReader.ReadBool();
 }
Пример #2
0
        public static GameVersion Deserialize(NetBuffer buffer)
        {
            GameVersionPhase phase = (GameVersionPhase)buffer.ReadByte();
            uint             major = buffer.ReadUInt32();
            uint             minor = buffer.ReadUInt32();
            char?            rev   = null;

            if (buffer.ReadBool())
            {
                rev = buffer.ReadChar();
            }

            return(new GameVersion(phase, major, minor, rev));
        }
Пример #3
0
        void R_SetBlock(NetConnection client, NetBuffer buffer, ushort numArgs)
        {
            int cx = buffer.ReadInt16();
            int cy = buffer.ReadInt16();
            int cz = buffer.ReadInt16();

            int bx = buffer.ReadUInt16();
            int by = buffer.ReadUInt16();
            int bz = buffer.ReadUInt16();

            byte r = buffer.ReadByte();
            byte g = buffer.ReadByte();
            byte b = buffer.ReadByte();
            byte d = buffer.ReadByte();

            bool placement = buffer.ReadBool();

            ServerMPPlayer player;

            if (players.TryGetValue(client, out player))
            {
                IndexPosition chunkPos = new IndexPosition(cx, cy, cz);
                IndexPosition blockPos = new IndexPosition(bx, by, bz);

                Block block = new Block(new Nybble2(d), r, g, b);
                // Validate modification
                float distToBlock = (player.GetCamera().Position - Chunk.ChunkBlockToWorldCoords(chunkPos, blockPos)).Length;
                if (!placement /* && distToBlock <= Spade.MODIFY_RANGE*/)
                {
                    SetBlock(chunkPos, blockPos, block, placement);

                    if (block == Block.AIR)
                    {
                        player.NumBlocks++;
                    }
                }
                else if (placement && /*distToBlock <= BlockItem.PLACE_RANGE
                                       * &&*/player.NumBlocks > 0)
                {
                    SetBlock(chunkPos, blockPos, block, placement);

                    if (!DashCMD.GetCVar <bool>("ch_infammo"))
                    {
                        player.NumBlocks--;
                    }
                }
            }
        }
Пример #4
0
        static object ReadPrimitive(NetBuffer buffer, SnapshotPrimitiveType type)
        {
            switch (type)
            {
            case SnapshotPrimitiveType.Byte:
                return(buffer.ReadByte());

            case SnapshotPrimitiveType.Char:
                return(buffer.ReadChar());

            case SnapshotPrimitiveType.Boolean:
                return(buffer.ReadBool());

            case SnapshotPrimitiveType.Int16:
            case SnapshotPrimitiveType.SByte:     // SByte is written as a short
                return(buffer.ReadInt16());

            case SnapshotPrimitiveType.UInt16:
                return(buffer.ReadUInt16());

            case SnapshotPrimitiveType.Int32:
                return(buffer.ReadInt32());

            case SnapshotPrimitiveType.UInt32:
                return(buffer.ReadUInt32());

            case SnapshotPrimitiveType.Int64:
                return(buffer.ReadInt64());

            case SnapshotPrimitiveType.UInt64:
                return(buffer.ReadUInt64());

            case SnapshotPrimitiveType.Single:
                return(buffer.ReadFloat());

            case SnapshotPrimitiveType.Double:
                return(buffer.ReadDouble());

            case SnapshotPrimitiveType.ByteFlag:
                return(buffer.ReadByteFlag());

            default:
                throw new Exception("Snapshot primitive type '" + type + "' is not supported!");
            }
        }
        void R_AddInitialNetPlayers(NetConnection server, NetBuffer data, ushort numArgs)
        {
            OurNetPlayerId = data.ReadUInt16();
            ushort numPlayers = data.ReadUInt16();

            for (int i = 0; i < numPlayers; i++)
            {
                ushort playerId   = data.ReadUInt16();
                string playerName = data.ReadString();
                Team   team       = (Team)data.ReadByte();
                ushort?charId     = null;
                if (data.ReadBool()) // Only read charId if the player has a character
                {
                    charId = data.ReadUInt16();
                }

                DashCMD.WriteLine("[NPM] Got NetPlayer[{1}] '{0}' on team {2}", playerName, playerId, team);

                NetworkPlayer player = new NetworkPlayer(playerName, playerId);
                player.Team        = team;
                player.CharacterId = charId;

                if (!netPlayers.ContainsKey(playerId))
                {
                    snapshotComponent.WorldSnapshot.NetworkPlayerListSnapshot.AddNetPlayer(player, false);
                    netPlayers.Add(playerId, player);
                }
                else
                {
                    DashCMD.WriteError("[NPM] Got NetPlayer[{1}] '{0}', but we already added this player!",
                                       playerName, playerId);
                }
            }

            if (OnNetPlayersInitialized != null)
            {
                OnNetPlayersInitialized(this, EventArgs.Empty);
            }
        }
 public void Deserialize(NetBuffer pPacketReader)
 {
     name  = pPacketReader.ReadString();
     force = pPacketReader.ReadBool();
 }
 public void Deserialize(NetBuffer pPacketReader)
 {
     name   = pPacketReader.ReadString();
     player = pPacketReader.ReadString();
     result = pPacketReader.ReadBool();
 }