コード例 #1
0
        public static ModSetting Read(BinaryReader stream)
        {
            ModSetting ret = new ModSetting();

            ret.type = stream.ReadByte();
            switch (ret.type)
            {
            case 1: goto case 4;

            case 2: goto case 4;

            case 3: goto case 4;

            case 4:
                ret.name = Reader.ReadComplexString(stream);
                break;

            default:
                throw new IOException("Wrong setting type");
            }
            switch (ret.type)
            {
            case 1:
                ret.value = stream.ReadBoolean();
                break;

            case 2:
                ret.value = stream.ReadDouble();
                break;

            case 3:
                ret.value = stream.ReadInt64();
                break;

            case 4:
                ret.value = Reader.ReadComplexString(stream);
                break;

            default:
                throw new IOException("Wrong setting type");
            }
            return(ret);
        }
コード例 #2
0
        public override void FromBytes(byte[] data)
        {
            MemoryStream ms = new MemoryStream(data);
            BinaryReader stream = new BinaryReader(ms);

            clientrequestId = stream.ReadInt32();
            status = stream.ReadByte();
            gameName = Reader.ReadString(stream);
            serverHash = Reader.ReadString(stream);
            description = Reader.ReadString(stream);
            latency = stream.ReadByte();
            gameId = stream.ReadInt32();

            serverUsername = Reader.ReadString(stream);
            mapSavingProgress = stream.ReadByte();
            var0 = Reader.ReadVarShort(stream);
            short clientscnt = Reader.ReadVarShort(stream);
            clients = new Client[clientscnt];
            for (int i = 0; i < clientscnt; i++)
                clients[i] = Client.Read(stream);

            firstSequenceNumberToExpect = stream.ReadInt32();
            firstSequenceNumberToSend = stream.ReadInt32();
            newPeerId = stream.ReadInt16();

            short modscnt = Reader.ReadVarShort(stream);
            mods = new ModInfo[modscnt];
            for (int i = 0; i < modscnt; i++)
                mods[i] = ModInfo.Read(stream);
            short modsettingscnt = Reader.ReadVarShort(stream);
            modSettings = new ModSetting[modsettingscnt];
            for (int i = 0; i < modsettingscnt; i++)
                modSettings[i] = ModSetting.Read(stream);

            pausedBy = stream.ReadInt16();

            lanGameId = stream.ReadInt32();
            name = Reader.ReadString(stream);
            applicationVersion = Version.Read(stream);
            buildVersion = stream.ReadInt16();
            serverDescription = Reader.ReadString(stream);
            maxPlayers = stream.ReadInt16();
            gameTimeElapsed = stream.ReadInt32();
            hasPassword = stream.ReadBoolean();
            int hostaddrln = stream.ReadInt32();
            byte[] hostaddrstrb = new byte[hostaddrln];
            stream.Read(hostaddrstrb, 0, hostaddrln);
            hostAddress = Encoding.UTF8.GetString(hostaddrstrb);

            int tagscnt = Reader.ReadVarInt(stream);
            tags = new string[tagscnt];
            for (int i = 0; i < tagscnt; i++)
                tags[i] = Reader.ReadString(stream);
            serverUsername1 = Reader.ReadString(stream);
            autosaveInterval = stream.ReadInt32();
            autosaveSlots = stream.ReadInt32();
            AFKAutoKickInterval = stream.ReadInt32();
            allowCommands = stream.ReadBoolean();
            maxUploadInKilobytesPerSecond = stream.ReadInt32();
            minimumLatencyInTicks = stream.ReadByte();
            ignorePlayerLimitForReturnongPlayers = stream.ReadBoolean();
            onlyAdminsCanPauseTheGame = stream.ReadBoolean();
            requireUserVerification = stream.ReadBoolean();

            int adminscnt = Reader.ReadVarInt(stream);
            admins = new string[adminscnt];
            for (int i = 0; i < adminscnt; i++)
                admins[i] = Reader.ReadString(stream);

            int whitelistcnt = Reader.ReadVarInt(stream);
            whitelist = new ListItem[whitelistcnt];
            for (int i = 0; i < whitelistcnt; i++)
                whitelist[i] = ListItem.Read(stream);
            int whitelistmappingcnt = Reader.ReadVarInt(stream);
            whitelistMappings = new AddressToUsernameMapping[whitelistmappingcnt];
            for (int i = 0; i < whitelistmappingcnt; i++)
                whitelistMappings[i] = AddressToUsernameMapping.Read(stream);

            int banlistcnt = Reader.ReadVarInt(stream);
            banlist = new ListItem[banlistcnt];
            for (int i = 0; i < banlistcnt; i++)
                banlist[i] = ListItem.Read(stream);
            int banlistmappingscnt = Reader.ReadVarInt(stream);
            banlistMappings = new AddressToUsernameMapping[banlistmappingscnt];
            for (int i = 0; i < banlistmappingscnt; i++)
                banlistMappings[i] = AddressToUsernameMapping.Read(stream);

            online = true;
        }