예제 #1
0
        /// <summary>
        /// Gets the ID of a row by its label.
        /// </summary>
        /// <param name="table">Table to look at.</param>
        /// <param name="label">Label name.</param>
        /// <returns></returns>
        public int GetIDOfLabelFromTable(SpecDBTables table, string label)
        {
            if ((int)table >= 0 && (int)table < Fixed_Tables.Length)
            {
                return(Fixed_Tables[(int)table].GetIDOfLabel(label));
            }

            return(-1);
        }
예제 #2
0
        /// <summary>
        /// Gets the row data from a table by ID.
        /// </summary>
        /// <param name="table"></param>
        /// <param name="keyCode"></param>
        /// <param name="rowData"></param>
        /// <returns></returns>
        public int GetRowFromTable(SpecDBTables table, int keyCode, out Span <byte> rowData)
        {
            rowData = default;
            if (Fixed_Tables[(int)table] != null)
            {
                return(Fixed_Tables[(int)table].GetRowN(keyCode, out rowData));
            }

            return(0);
        }
예제 #3
0
        /// <summary>
        /// Gets the offset of the string key for a row code in the IDI.
        /// </summary>
        /// <param name="table">Table to look at.</param>
        /// <param name="code">Code of the row.</param>
        /// <returns></returns>
        public int GetLabelOffsetByIDFromTable(SpecDBTables table, int code)
        {
            SpecDBTable sTable = Fixed_Tables[(int)table];
            IDI         idi    = sTable.IDI;

            SpanReader sr = new SpanReader(idi.Buffer);

            sr.Position = 4;
            int entryCount = sr.ReadInt32();

            // "original" implementation had one while and one do loop, probably decompiler that just failed
            for (int i = 0; i < entryCount; i++)
            {
                sr.Position = IDI.HeaderSize + (i * 8) + 4;
                int entryCode = sr.ReadInt32();
                if (entryCode == code)
                {
                    // Original: return (char*)(idiFile + index * 8 + *(int*)(iVar3 * 8 + idiFile + 0x10) + 0x12);

                    // *(int*)(iVar3 * 8 + idiFile + 0x10)
                    int entryPos = IDI.HeaderSize + (i * 8);
                    sr.Position = entryPos;
                    int stringOffset = sr.ReadInt32();

                    // idiFile + index * 8 (go to the beginning of the second table)
                    sr.Position = IDI.HeaderSize + entryCount * 8; // Header is added due to below

                    // Add the two
                    sr.Position += stringOffset;

                    //0x12 is just the base header + the string length as short, optimized
                    return(sr.Position + 2);
                }
            }

            return(-1); // NULL
        }
예제 #4
0
        public int GetLabelCountForTable(SpecDBTables table)
        {
            IDI idTable = Fixed_Tables[(int)table].IDI;

            return(idTable.KeyCount);
        }