Exemplo n.º 1
0
        internal ZDictionary(Story story, ZText ztext)
        {
            this.story = story;
            this.ztext = ztext;

            this.address = Header.ReadDictionaryAddress(story.Memory);

            var reader = new MemoryReader(story.Memory, address);

            int wordSepCount = reader.NextByte();

            this.wordSeparators = reader.NextBytes(wordSepCount).ConvertAll(b => (char)b).AsReadOnly();

            int entryLength = reader.NextByte();
            int entryCount  = reader.NextWord();

            int zwordsSize = story.Version <= 3 ? 2 : 3;
            int dataSize   = entryLength - (zwordsSize * 2);

            this.entries = new List <ZDictionaryEntry>(entryCount);
            for (int i = 0; i < entryCount; i++)
            {
                var entryAddress = reader.Address;
                var entryZWords  = reader.NextWords(zwordsSize);
                var entryData    = reader.NextBytes(dataSize);
                var entryZText   = ztext.ZWordsAsString(entryZWords, ZTextFlags.All);
                entries.Add(new ZDictionaryEntry(entryAddress, i, entryZWords, entryZText, entryData));
            }
        }
Exemplo n.º 2
0
        public string GetPropertyName(int propNum)
        {
            var address = memoryMap[MemoryMapRegionKind.PropertyNamesTable].Base + (propNum * 2);
            var propNamePackedAddress = memory.ReadWord(address);
            var propNameAddress       = Header.UnpackStringAddress(memory, propNamePackedAddress);

            var propNameZWords = ZText.ReadZWords(memory, propNameAddress);

            return(ztext.ZWordsAsString(propNameZWords, ZTextFlags.None));
        }