コード例 #1
0
        internal override void ReadData(AwesomeReader ar)
        {
            _strings.Clear();

            int count = ar.ReadInt32();

            ar.BaseStream.Position += 12; // Skips to entries
            long stringTableOffset = ar.BaseStream.Position + (count * 16);

            ulong[] key    = new ulong[count];
            long[]  offset = new long[count];

            for (int i = 0; i < count; i++)
            {
                key[i]    = ar.ReadUInt64();
                offset[i] = ar.ReadInt32();
                ar.BaseStream.Position += 4; // Should be zero
            }

            for (int i = 0; i < count; i++)
            {
                ar.BaseStream.Position = offset[i] + stringTableOffset;
                string text = ar.ReadNullString();

                if (!_strings.ContainsKey(key[i]))
                {
                    _strings.Add(key[i], text);
                    continue;
                }

                // Evidently the same string with different casings will have the same key (only for directory paths?)
                if (string.Compare(_strings[key[i]], text, true) == 0)
                {
                    _strings.Remove(key[i]);
                    _strings.Add(key[i], text);
                }
                else
                {
                    throw new Exception($"STRING ERROR: {_strings[key[i]]} != {text}");
                }
            }

            foreach (var d in _strings)
            {
                // Updates global string value
                StringKey.UpdateValue(d.Key, d.Value, _localization);
            }

            // English localization is missing directory path entry
            if (Localization == Localization.Japanese)
            {
                StringKey.UpdateValue(DirectoryPath.Key, _strings[DirectoryPath.Key], Localization.English);
            }
        }
コード例 #2
0
ファイル: HKey.cs プロジェクト: PikminGuts92/BFForever
        internal HKey Extend(string extension)
        {
            if (!IsValidValue(extension))
            {
                throw new Exception(InvalidValueMessage());
            }

            ulong newKey = HKey.GetHash(extension, _key);

            if (StringKey.ContainsStringKey(_key))
            {
                // Adds new value
                string newValue = StringKey.GetValue(_key, Localization.English) + extension;
                StringKey.UpdateValue(newKey, newValue);
                return(new HKey(newKey));
            }

            return(new HKey(newKey));
        }
コード例 #3
0
        public FString(string value)
        {
            if (!IsValidValue(value))
            {
                throw new Exception();
            }
            _key = CalculateHash(value);

            if (_key == 0)
            {
                // Adds null if not already present
                if (!StringKey.ContainsStringKey(0))
                {
                    StringKey.UpdateValue(0, "");
                }
                return;
            }

            StringKey.UpdateValue(_key, value);
        }