Пример #1
0
        // Overrides the ConvertFrom method of TypeConverter.
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                int64 result = long.Parse((string)value);
                return(result);
            }

            return(base.ConvertFrom(context, culture, value));
        }
        public void ReadSave(SaveState state)
        {
            Name               = state.ReadIndexedString();
            Description        = state.ReadIndexedString();
            LateJoinersAllowed = state.Reader.ReadBooleanStrict();

            // RoundSettings
            int roundSettingCount = state.ReadVariableLengthInt();

            RoundSettings = new Array <Ref <GameRoundSettings> >(roundSettingCount);

            for (int i = 0; i < roundSettingCount; i++)
            {
                string settingName = state.ReadIndexedString();

                // TODO: Object/resource name is "World" with type "GameRoundSettings" - lookups not currently implemented
                RoundSettings.Add(new Ref <GameRoundSettings>());
            }

            // MissionSetting
            int missionSettingCount = state.ReadVariableLengthInt();

            MissionSetting = new Array <MissionSettings>(missionSettingCount);

            for (int i = 0; i < missionSettingCount; i++)
            {
                var settings = new MissionSettings();
                settings.ReadSave(state);

                MissionSetting.Add(settings);
            }

            // Let's serialize this entire structure even though reflection is available. Brilliant.
            EndGameWhenWinnerDecided = state.Reader.ReadBooleanStrict();
            SpawnLives                 = state.ReadVariableLengthInt();
            UseSpawnWaves              = state.Reader.ReadBooleanStrict();
            DeathCamTime               = state.Reader.ReadSingle();
            RespawnTimer               = state.ReadVariableLengthInt();
            GracePeriod                = state.ReadVariableLengthInt();
            InactivityKickTime         = state.ReadVariableLengthInt();
            TimeBetweenMissions        = state.ReadVariableLengthInt();
            BodycountQuota             = state.ReadVariableLengthInt();
            CaHCaptureTime             = state.ReadVariableLengthInt();
            CaCCaptureTimeInner        = state.ReadVariableLengthInt();
            CaCCaptureTimeMiddle       = state.ReadVariableLengthInt();
            CaCCaptureTimeOuter        = state.ReadVariableLengthInt();
            CaSCaptureTime             = state.ReadVariableLengthInt();
            ExplosivePlacing           = state.ReadVariableLengthInt();
            ExplosiveDefusing          = state.ReadVariableLengthInt();
            ExplosiveDetonationTime    = state.ReadVariableLengthInt();
            FriendlyFireEnabled        = state.Reader.ReadBooleanStrict();
            CloseCombatSettings        = (ECloseCombatSettings)state.Reader.ReadByte();
            ShowEnemiesOnRadar         = state.Reader.ReadBooleanStrict();
            ShowAmmoCounter            = state.Reader.ReadBooleanStrict();
            AmmoSettings               = (EAmmoSettings)state.Reader.ReadByte();
            MaxPlayerCount             = state.ReadVariableLengthInt();
            MaxPlayerSpectatorCount    = state.ReadVariableLengthInt();
            MaxAdminSpectatorCount     = state.ReadVariableLengthInt();
            MinClientCount             = state.ReadVariableLengthInt();
            ClansMinPlayerCount        = state.ReadVariableLengthInt();
            ClansForfeitTimer          = state.Reader.ReadInt32();// !
            PlayerHealthSettings       = (EPlayerHealthSettings)state.Reader.ReadByte();
            HealthRegenerationSettings = (EHealthRegenerationSettings)state.Reader.ReadByte();
            MaxBotCount                = state.ReadVariableLengthInt();
            BotFaction                 = (EFaction)state.Reader.ReadByte();
            SplitScreenGame            = state.Reader.ReadBooleanStrict();
            GameMode               = (EGameMode)state.Reader.ReadByte();
            BotzoneGame            = state.Reader.ReadBooleanStrict();
            PracticeGame           = state.Reader.ReadBooleanStrict();
            ClanGame               = state.Reader.ReadBooleanStrict();
            IsCustomGame           = state.Reader.ReadBooleanStrict();
            IsAdminCreatedGame     = state.Reader.ReadBooleanStrict();
            CampaignScoringEnabled = state.Reader.ReadBooleanStrict();
            _ = state.Reader.ReadByte();// !

            PlaylistPassword = state.ReadIndexedString();
            SelectedChallengeRequirements = state.ReadIndexedString();

            // CareerSettings
            int careerSettingCount = state.ReadVariableLengthInt();

            CareerSettings = new Array <ECareerSettings>(careerSettingCount);

            for (int i = 0; i < careerSettingCount; i++)
            {
                CareerSettings.Add((ECareerSettings)state.Reader.ReadByte());
            }

            DisabledUnlockResources = new Array <String>();
            DisabledUnlockResources.DeserializeStateObject(state);

            TrackedLeaderboardStats = new Array <String>();
            TrackedLeaderboardStats.DeserializeStateObject(state);

            CombatHonorsEnabled  = state.Reader.ReadBooleanStrict();
            Creator              = state.ReadIndexedString();
            CreatedTimestamp     = state.Reader.ReadInt64();
            TeamVoiceChat        = state.Reader.ReadBooleanStrict();
            PartiesAllowed       = state.Reader.ReadBooleanStrict();
            PreGameLobbyWaitTime = state.ReadVariableLengthInt();
        }
Пример #3
0
        public static int IdxRowid(Context ctx, BtCursor cur, ref int64 rowid)
        {
            // Get the size of the index entry.  Only indices entries of less than 2GiB are support - anything large must be database corruption.
            // Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so this code can safely assume that nCellKey is 32-bits  
            Debug.Assert(Btree.CursorIsValid(cur));
            long cellKeyLength = 0;
            RC rc = Btree.KeySize(cur, ref cellKeyLength);
            Debug.Assert(rc == RC.OK); // pCur is always valid so KeySize cannot fail
            Debug.Assert(((uint)cellKeyLength & MAX_U32) == (ulong)cellKeyLength);

            // Read in the complete content of the index entry
            Mem m = C._alloc(m);
            //: memset(&m, 0, sizeof(m));
            rc = MemFromBtree(cur, 0, (int)cellKeyLength, true, m);
            if (rc != 0)
                return rc;

            // The index entry must begin with a header size
            uint szHdr = 0; // Size of the header
            ConvertEx.GetVarint32(m.Z_, 0, out szHdr);
            C.ASSERTCOVERAGE(szHdr == 3);
            C.ASSERTCOVERAGE(szHdr == m.N);
            if (unlikely(szHdr < 3 || (int)szHdr > m.n))
                goto idx_rowid_corruption;

            // The last field of the index should be an integer - the ROWID. Verify that the last entry really is an integer.
            uint typeRowid = 0; // Serial type of the rowid
            ConvertEx.GetVarint32(m.Z_, szHdr - 1, out typeRowid);
            C.ASSERTCOVERAGE(typeRowid == 1);
            C.ASSERTCOVERAGE(typeRowid == 2);
            C.ASSERTCOVERAGE(typeRowid == 3);
            C.ASSERTCOVERAGE(typeRowid == 4);
            C.ASSERTCOVERAGE(typeRowid == 5);
            C.ASSERTCOVERAGE(typeRowid == 6);
            C.ASSERTCOVERAGE(typeRowid == 8);
            C.ASSERTCOVERAGE(typeRowid == 9);
            if (unlikely(typeRowid < 1 || typeRowid > 9 || typeRowid == 7))
                goto idx_rowid_corruption;
            uint lenRowid = (uint)SerialTypeLen(typeRowid); // Size of the rowid
            C.ASSERTCOVERAGE((uint)m.N == szHdr + lenRowid);
            if (unlikely((uint)m.N < szHdr + lenRowid))
                goto idx_rowid_corruption;

            // Fetch the integer off the end of the index record
            Mem v = C._alloc(v);
            SerialGet(m.Z_, (int)(m.N - lenRowid), typeRowid, v);
            rowid = v.u.I;
            MemRelease(m);
            return RC.OK;

        // Jump here if database corruption is detected after m has been allocated.  Free the m object and return SQLITE_CORRUPT.
        idx_rowid_corruption:
            //: ASSERTCOVERAGE(m.Malloc != nullptr);
            MemRelease(m);
            return SysEx.CORRUPT_BKPT();
        }