public void LoadFromBinary(BinaryTableReader reader, ref uint key1, ref uint key2)
        {
            id       = key1;
            lv       = key2;
            atk      = new GrowRate();
            atk.rate = reader.ReadInt32(0);
            atk.add  = reader.ReadInt32(0);
            def      = new GrowRate();
            def.rate = reader.ReadInt32(0);
            def.add  = reader.ReadInt32(0);
            hp       = new GrowRate();
            hp.rate  = reader.ReadInt32(0);
            hp.add   = reader.ReadInt32(0);
            elemAtk  = new GrowRate[6];
            int i = 0;

            for (int num = 6; i < num; i++)
            {
                elemAtk[i]      = new GrowRate();
                elemAtk[i].rate = reader.ReadInt32(0);
                elemAtk[i].add  = reader.ReadInt32(0);
            }
            elemDef = new GrowRate[6];
            int j = 0;

            for (int num2 = 6; j < num2; j++)
            {
                elemDef[j]      = new GrowRate();
                elemDef[j].rate = reader.ReadInt32(0);
                elemDef[j].add  = reader.ReadInt32(0);
            }
        }
Пример #2
0
        public IXTable ReadSource(string tableName, XDatabaseContext context)
        {
            List <IXTable> sources = new List <IXTable>();

            // Find the latest source of this type
            ItemVersions sourceVersions   = context.StreamProvider.ItemVersions(LocationType.Source, tableName);
            ItemVersion  latestFullSource = sourceVersions.LatestBeforeCutoff(CrawlType.Full, context.RequestedAsOfDateTime);

            // If there are no sources, there's nothing to rebuild from
            if (sourceVersions.Versions == null || sourceVersions.Versions.Count == 0)
            {
                return(null);
            }

            // Find the latest already converted table
            ItemVersions tableVersions    = context.StreamProvider.ItemVersions(LocationType.Table, tableName);
            ItemVersion  latestBuiltTable = tableVersions.LatestBeforeCutoff(CrawlType.Full, context.RequestedAsOfDateTime);

            // If no source or table was found, throw
            if (latestFullSource == null && latestBuiltTable == null)
            {
                throw new UsageException(tableName, "[Table]", context.StreamProvider.SourceNames());
            }

            // Read the Table or the Full Crawl Source, whichever is newer
            DateTime incrementalNeededAfterCutoff;

            if (latestBuiltTable != null &&
                (latestFullSource == null || !IsOutOfDate(latestBuiltTable.AsOfDate, latestFullSource.AsOfDate)) &&
                TableMetadataSerializer.UncachedExists(context.StreamProvider, latestBuiltTable.Path))
            {
                // If the table is current, reuse it
                sources.Add(BinaryTableReader.Build(context.StreamProvider, latestBuiltTable.Path));
                incrementalNeededAfterCutoff = latestBuiltTable.AsOfDate;
            }
            else
            {
                // Otherwise, build a new table from the latest source full crawl
                sources.AddRange(context.StreamProvider.Enumerate(latestFullSource.Path, EnumerateTypes.File, true).Select((sa) => new TabularFileReader(context.StreamProvider, sa.Path)));
                incrementalNeededAfterCutoff = latestFullSource.AsOfDate;
            }

            // Add incremental crawls between the full source and the reporting date
            DateTime latestComponent = incrementalNeededAfterCutoff;

            foreach (ItemVersion incrementalCrawl in sourceVersions.VersionsInRange(CrawlType.Inc, incrementalNeededAfterCutoff, context.RequestedAsOfDateTime))
            {
                sources.AddRange(context.StreamProvider.Enumerate(incrementalCrawl.Path, EnumerateTypes.File, true).Select((sa) => new TabularFileReader(context.StreamProvider, sa.Path)));
                latestComponent = latestComponent.BiggestOf(incrementalCrawl.AsOfDate);
            }

            // Report the latest incorporated source back
            context.NewestDependency = latestComponent;

            // Return the source (if a single) or concatenated group (if multiple parts)
            return(ConcatenatedTable.Build(sources));
        }
Пример #3
0
 public void LoadFromBinary(BinaryTableReader reader, ref uint key)
 {
     questID          = key;
     questType        = (QUEST_TYPE)reader.ReadInt32(0);
     questStyle       = (QUEST_STYLE)reader.ReadInt32(0);
     rarity           = (RARITY_TYPE)reader.ReadInt32(0);
     getType          = (GET_TYPE)reader.ReadInt32(0);
     eventId          = reader.ReadInt32(0);
     grade            = reader.ReadInt32(0);
     difficulty       = (DIFFICULTY_TYPE)reader.ReadInt32(0);
     sortPriority     = reader.ReadInt32(0);
     locationNumber   = reader.ReadString(string.Empty);
     questNumber      = reader.ReadString(string.Empty);
     questText        = reader.ReadString(string.Empty);
     appearQuestId    = reader.ReadUInt32(0u);
     appearDeliveryId = reader.ReadUInt32(0u);
     rushId           = reader.ReadUInt32(0u);
     mapId            = reader.ReadUInt32(0u);
     for (int i = 0; i < 1; i++)
     {
         stageName[i] = reader.ReadString(string.Empty);
     }
     for (int j = 0; j < 1; j++)
     {
         enemyID[j] = reader.ReadInt32(0);
         enemyLv[j] = reader.ReadInt32(0);
     }
     for (int k = 0; k < 1; k++)
     {
         bgmID[k] = reader.ReadInt32(0);
     }
     limitTime    = reader.ReadSingle(0f);
     missionID[0] = reader.ReadUInt32(0u);
     missionID[1] = reader.ReadUInt32(0u);
     missionID[2] = reader.ReadUInt32(0u);
     cantSale     = reader.ReadBoolean(false);
     forceDefeat  = reader.ReadBoolean(false);
     storyId      = reader.ReadInt32(0);
     if (sortPriority == 0)
     {
         sortPriority = (int)key;
     }
     if (string.IsNullOrEmpty(locationNumber))
     {
         locationNumber = (questID / 100u % 1000u).ToString();
     }
     if (string.IsNullOrEmpty(questNumber))
     {
         questNumber = (questID % 100u).ToString();
     }
     seriesNum = 0;
     for (int l = 0; l < 1 && enemyID[l] != 0; l++)
     {
         seriesNum++;
     }
 }
Пример #4
0
    public static UIntKeyTable <T> CreateUIntKeyTableFromBinary <T>(MemoryStream stream) where T : IUIntKeyBinaryTableData, new()
    {
        UIntKeyTable <T>  uIntKeyTable      = new UIntKeyTable <T>();
        BinaryTableReader binaryTableReader = new BinaryTableReader(stream);

        while (binaryTableReader.MoveNext())
        {
            uint key   = binaryTableReader.ReadUInt32(0u);
            T    value = new T();
            value.LoadFromBinary(binaryTableReader, ref key);
            uIntKeyTable.Add(key, value);
        }
        return(uIntKeyTable);
    }
Пример #5
0
    public static DoubleUIntKeyTable <T> CreateDoubleUIntKeyTableFromBinary <T>(MemoryStream stream) where T : IDoubleUIntKeyBinaryTableData, new()
    {
        DoubleUIntKeyTable <T> doubleUIntKeyTable = new DoubleUIntKeyTable <T>();
        BinaryTableReader      binaryTableReader  = new BinaryTableReader(stream);

        while (binaryTableReader.MoveNext())
        {
            uint key   = binaryTableReader.ReadUInt32(0u);
            uint key2  = binaryTableReader.ReadUInt32(0u);
            T    value = new T();
            value.LoadFromBinary(binaryTableReader, ref key, ref key2);
            doubleUIntKeyTable.Add(key, key2, value);
        }
        return(doubleUIntKeyTable);
    }
    public static DoubleUIntKeyTable <GrowEquipItemNeedItemData> CreateNeedTableBinary(byte[] bytes)
    {
        DoubleUIntKeyTable <GrowEquipItemNeedItemData> doubleUIntKeyTable = new DoubleUIntKeyTable <GrowEquipItemNeedItemData>();
        BinaryTableReader binaryTableReader = new BinaryTableReader(bytes);

        while (binaryTableReader.MoveNext())
        {
            uint key  = binaryTableReader.ReadUInt32(0u);
            uint key2 = binaryTableReader.ReadUInt32(0u);
            GrowEquipItemNeedItemData growEquipItemNeedItemData = new GrowEquipItemNeedItemData();
            growEquipItemNeedItemData.LoadFromBinary(binaryTableReader, ref key, ref key2);
            doubleUIntKeyTable.Add(key, key2, growEquipItemNeedItemData);
        }
        return(doubleUIntKeyTable);
    }
 public void LoadFromBinary(BinaryTableReader reader, ref uint key1, ref uint key2)
 {
     id          = key1;
     this.key2   = key2;
     needAP      = reader.ReadInt32(0);
     name        = reader.ReadString(string.Empty);
     description = reader.ReadString(string.Empty);
     m_info      = new AbilityInfo[3];
     for (int i = 0; i < 3; i++)
     {
         AbilityInfo abilityInfo = new AbilityInfo();
         abilityInfo.type   = (ABILITY_TYPE)reader.ReadInt32(0);
         abilityInfo.target = reader.ReadString(string.Empty);
         abilityInfo.value  = reader.ReadInt32(0);
         m_info[i]          = abilityInfo;
     }
 }
 public void LoadFromBinary(BinaryTableReader reader, ref uint key1, ref uint key2)
 {
     id = key1;
     lv = key2;
     need_material.Clear();
     for (int i = 0; i < NEED_MATERIAL_LENGTH_MAX; i++)
     {
         uint num  = reader.ReadUInt32(0u);
         int  num2 = reader.ReadInt32(0);
         if (num != 0 && num2 != 0)
         {
             need_material.Add(new NeedMaterial(num, num2));
         }
     }
     needMaterial = need_material.ToArray();
     needMoney    = reader.ReadInt32(0);
 }
    public static DoubleUIntKeyTable <AbilityData> CreateTableBinary(byte[] bytes)
    {
        DoubleUIntKeyTable <AbilityData> doubleUIntKeyTable = new DoubleUIntKeyTable <AbilityData>();
        BinaryTableReader binaryTableReader = new BinaryTableReader(bytes);

        while (binaryTableReader.MoveNext())
        {
            uint key  = binaryTableReader.ReadUInt32(0u);
            uint key2 = 0u;
            UIntKeyTable <AbilityData> uIntKeyTable = doubleUIntKeyTable.Get(key);
            if (uIntKeyTable != null)
            {
                key2 = (uint)uIntKeyTable.GetCount();
            }
            AbilityData abilityData = new AbilityData();
            abilityData.LoadFromBinary(binaryTableReader, ref key, ref key2);
            doubleUIntKeyTable.Add(key, key2, abilityData);
        }
        return(doubleUIntKeyTable);
    }
Пример #10
0
        public IXTable Build(string tableName, XDatabaseContext outerContext, bool deferred)
        {
            // Validate the source name is recognized
            if (!Sources.Contains(tableName))
            {
                // If it wasn't in cache, check individually for it live
                if (!XDatabaseContext.StreamProvider.ContainsTable(tableName))
                {
                    throw new UsageException(tableName, "Table", Sources);
                }

                // If found, update the cache
                UpdateSources();
            }

            // If only a Date was passed for AsOfDate, look for the last version as of that day
            if (outerContext.RequestedAsOfDateTime.TimeOfDay == TimeSpan.Zero)
            {
                outerContext.RequestedAsOfDateTime = outerContext.RequestedAsOfDateTime.AddDays(1).AddSeconds(-1);
            }

            // If we previously found the latest for this table, just return it again
            LatestTableForCutoff previousLatest;

            if (_currentTableVersions.TryGet(tableName, out previousLatest) &&
                previousLatest.Cutoff >= outerContext.RequestedAsOfDateTime &&
                previousLatest.TableVersion.AsOfDate <= outerContext.RequestedAsOfDateTime &&
                TableMetadataSerializer.UncachedExists(outerContext.StreamProvider, previousLatest.TableVersion.Path))
            {
                outerContext.NewestDependency = previousLatest.TableVersion.AsOfDate;
                return(BinaryTableReader.Build(outerContext.StreamProvider, previousLatest.TableVersion.Path));
            }

            // Create a context to track what we're building now
            XDatabaseContext innerContext = XDatabaseContext.Push(outerContext);

            innerContext.CurrentTable = tableName;

            // If this is a query, there won't be a cached table - just build a pipeline to make it
            StreamAttributes queryAttributes = innerContext.StreamProvider.Attributes(innerContext.StreamProvider.Path(LocationType.Query, tableName, ".xql"));

            if (queryAttributes.Exists)
            {
                IXTable queryPipeline = innerContext.Query(innerContext.StreamProvider.ReadAllText(queryAttributes.Path));
                innerContext.Pop(outerContext);
                return(queryPipeline);
            }

            // Find the latest already built result, and associated query
            ItemVersions tableVersions    = innerContext.StreamProvider.ItemVersions(LocationType.Table, tableName);
            ItemVersion  latestTable      = tableVersions.LatestBeforeCutoff(CrawlType.Full, outerContext.RequestedAsOfDateTime);
            string       latestTableQuery = null;

            if (latestTable != null)
            {
                latestTableQuery = TableMetadataSerializer.Read(outerContext.StreamProvider, latestTable.Path).Query;
            }

            // Set the dependency date to the latest table we've already built (if any)
            innerContext.NewestDependency = (latestTable == null ? DateTime.MinValue : latestTable.AsOfDate);

            // Determine the XQL to build the table and construct a builder which can do so
            string  xql;
            IXTable builder;

            // Find the config to build the table and scan dependency versions to determine whether table is out-of-date
            StreamAttributes configAttributes = innerContext.StreamProvider.Attributes(innerContext.StreamProvider.Path(LocationType.Config, tableName, ".xql"));

            if (!configAttributes.Exists)
            {
                // If this is a simple source, just reading it is how to build it
                xql = $"read {XqlScanner.Escape(tableName, TokenType.Value)}";

                // Build a reader concatenating all needed pieces
                builder = ReadSource(tableName, innerContext);
            }
            else
            {
                // If there is a config, the config is how to build it
                xql = innerContext.StreamProvider.ReadAllText(configAttributes.Path);

                // Build a pipeline for the query, recursively creating dependencies
                builder = innerContext.Query(xql);
            }

            // If we don't have the table or the source, we have to throw
            if (latestTable == null && builder == null)
            {
                throw new UsageException(tableName, "Table", innerContext.StreamProvider.Tables());
            }

            // Get the path we're either reading or building
            string tablePath = innerContext.StreamProvider.Path(LocationType.Table, tableName, CrawlType.Full, innerContext.NewestDependency);

            // If we can rebuild this table and we need to (sources rebuilt, query changed, out-of-date, deleted), rebuild it
            if (builder != null)
            {
                if (latestTable == null ||
                    innerContext.RebuiltSomething ||
                    (latestTableQuery != null && xql != latestTableQuery) ||
                    IsOutOfDate(latestTable.AsOfDate, innerContext.NewestDependency) ||
                    !TableMetadataSerializer.UncachedExists(outerContext.StreamProvider, latestTable.Path))
                {
                    // If we're not running now, just return how to build it
                    if (deferred)
                    {
                        return(builder);
                    }

                    // Otherwise, build it now; we'll return the query to read the output
                    innerContext.CurrentQuery = xql;
                    Trace.WriteLine($"COMPUTE: [{innerContext.NewestDependency.ToString(StreamProviderExtensions.DateTimeFolderFormat)}] {tableName}");
                    BinaryTableWriter.Build(builder, innerContext, tablePath).RunAndDispose();
                    innerContext.RebuiltSomething = true;
                }
            }

            // Report the newest dependency in this chain to the components above
            innerContext.Pop(outerContext);

            _currentTableVersions.Add(tableName, new LatestTableForCutoff(outerContext.RequestedAsOfDateTime, new ItemVersion(LocationType.Table, tableName, CrawlType.Full, innerContext.NewestDependency)));
            return(BinaryTableReader.Build(innerContext.StreamProvider, tablePath));
        }
Пример #11
0
        public void LoadFromBinary(BinaryTableReader reader, ref uint key)
        {
            id                = key;
            locationNumber    = reader.ReadString(string.Empty);
            deliveryNumber    = reader.ReadString(string.Empty);
            name              = reader.ReadString(string.Empty);
            type              = (DELIVERY_TYPE)reader.ReadUInt32(0u);
            subType           = (DELIVERY_SUB_TYPE)reader.ReadUInt32(0u);
            textType          = (DELIVERY_TYPE)reader.ReadUInt32(0u);
            eventID           = reader.ReadInt32(0);
            fieldMode         = (DIFFICULTY_MODE)reader.ReadUInt32(0u);
            difficulty        = (DIFFICULTY_MODE)reader.ReadUInt32(0u);
            npcID             = reader.ReadUInt32(0u);
            npcComment        = reader.ReadString(string.Empty);
            npcClearComment   = reader.ReadString(string.Empty);
            clearEventID      = reader.ReadUInt32(0u);
            clearEventTitle   = reader.ReadString(string.Empty);
            jumpType          = reader.ReadInt32(0);
            jumpMapID         = reader.ReadInt32(0);
            targetPortalID[0] = reader.ReadInt32(0);
            targetPortalID[1] = reader.ReadInt32(0);
            targetPortalID[2] = reader.ReadInt32(0);
            placeName         = reader.ReadString(string.Empty);
            enemyName         = reader.ReadString(string.Empty);
            appearQuestId     = reader.ReadUInt32(0u);
            appearDeliveryId  = reader.ReadUInt32(0u);
            List <NeedData> list = new List <NeedData>();
            int             i    = 0;

            for (int num = 5; i < num; i++)
            {
                DELIVERY_CONDITION_TYPE dELIVERY_CONDITION_TYPE = DELIVERY_CONDITION_TYPE.NONE;
                uint num2    = 0u;
                uint num3    = 0u;
                uint questId = 0u;
                DELIVERY_RATE_TYPE dELIVERY_RATE_TYPE = DELIVERY_RATE_TYPE.RATE_10000;
                string             empty = string.Empty;
                uint num4 = 0u;
                uint num5 = 0u;
                dELIVERY_CONDITION_TYPE = (DELIVERY_CONDITION_TYPE)reader.ReadUInt32(0u);
                num2 = reader.ReadUInt32(0u);
                num3 = reader.ReadUInt32(0u);
                if (i == 0)
                {
                    questId = reader.ReadUInt32(0u);
                }
                dELIVERY_RATE_TYPE = (DELIVERY_RATE_TYPE)reader.ReadUInt32(0u);
                empty = reader.ReadString(string.Empty);
                num4  = reader.ReadUInt32(0u);
                num5  = reader.ReadUInt32(0u);
                NeedData needData = new NeedData(dELIVERY_CONDITION_TYPE, num2, num3, questId, dELIVERY_RATE_TYPE, empty, num4, num5);
                if (needData.IsValid())
                {
                    list.Add(needData);
                }
            }
            needs = list.ToArray();
            if (string.IsNullOrEmpty(locationNumber))
            {
                locationNumber = (id / 100u % 1000u).ToString();
            }
            if (string.IsNullOrEmpty(deliveryNumber))
            {
                deliveryNumber = (id % 100u).ToString();
            }
        }
 public void LoadFromBinary(BinaryTableReader reader, ref uint key1, ref uint key2)
 {
     itemId    = key1;
     this.key2 = key2;
     questId   = reader.ReadUInt32(0u);
 }