internal bool Deserialize(ByteArrayWrapper str, ref int pos)
        {
            int id = str.DeserializeShort(ref pos);

            if (id <= 0)
            {
                return(false);
            }
            MiscInfoId = (short)id;
            int iii = str.DeserializeShort(ref pos);

            Pullenti.Morph.MorphClass mc = new Pullenti.Morph.MorphClass();
            mc.Value = (short)iii;
            if (mc.IsMisc && mc.IsProper)
            {
                mc.IsMisc = false;
            }
            Class = mc;
            byte bbb;

            bbb    = str.DeserializeByte(ref pos);
            Gender = (Pullenti.Morph.MorphGender)bbb;
            bbb    = str.DeserializeByte(ref pos);
            Number = (Pullenti.Morph.MorphNumber)bbb;
            bbb    = str.DeserializeByte(ref pos);
            Pullenti.Morph.MorphCase mca = new Pullenti.Morph.MorphCase();
            mca.Value = bbb;
            Case      = mca;
            string s = str.DeserializeString(ref pos);

            NormalTail     = s;
            s              = str.DeserializeString(ref pos);
            FullNormalTail = s;
            return(true);
        }
        void _deserializeBase(ByteArrayWrapper str, ref int pos)
        {
            int cou = str.DeserializeShort(ref pos);

            if (cou > 0)
            {
                RuleIds = new List <int>();
                for (; cou > 0; cou--)
                {
                    int id = str.DeserializeShort(ref pos);
                    if (id == 0)
                    {
                    }
                    RuleIds.Add(id);
                }
            }
            cou = str.DeserializeShort(ref pos);
            if (cou > 0)
            {
                ReverceVariants = new List <MorphRuleVariantRef>();
                for (; cou > 0; cou--)
                {
                    int rid = str.DeserializeShort(ref pos);
                    if (rid == 0)
                    {
                    }
                    int id = str.DeserializeShort(ref pos);
                    int co = str.DeserializeShort(ref pos);
                    ReverceVariants.Add(new MorphRuleVariantRef(rid, (short)id, (short)co));
                }
            }
        }
        internal void DeserializeLazy(ByteArrayWrapper str, MorphEngine me, ref int pos)
        {
            this._deserializeBase(str, ref pos);
            int cou = str.DeserializeShort(ref pos);

            if (cou > 0)
            {
                Nodes = new Dictionary <short, MorphTreeNode>();
                for (; cou > 0; cou--)
                {
                    int           i     = str.DeserializeShort(ref pos);
                    int           pp    = str.DeserializeInt(ref pos);
                    MorphTreeNode child = new MorphTreeNode();
                    child.LazyPos = pos;
                    Nodes.Add((short)i, child);
                    pos = pp;
                }
            }
            int p = pos;

            if (RuleIds != null)
            {
                foreach (int rid in RuleIds)
                {
                    MorphRule r = me.GetMutRule(rid);
                    if (r.LazyPos > 0)
                    {
                        pos = r.LazyPos;
                        r.Deserialize(str, ref pos);
                        r.LazyPos = 0;
                    }
                }
                pos = p;
            }
            if (ReverceVariants != null)
            {
                foreach (MorphRuleVariantRef rv in ReverceVariants)
                {
                    MorphRule r = me.GetMutRule(rv.RuleId);
                    if (r.LazyPos > 0)
                    {
                        pos = r.LazyPos;
                        r.Deserialize(str, ref pos);
                        r.LazyPos = 0;
                    }
                }
                pos = p;
            }
        }
        internal int Deserialize(ByteArrayWrapper str, ref int pos)
        {
            int res = 0;

            this._deserializeBase(str, ref pos);
            int cou = str.DeserializeShort(ref pos);

            if (cou > 0)
            {
                Nodes = new Dictionary <short, MorphTreeNode>();
                for (; cou > 0; cou--)
                {
                    int           i     = str.DeserializeShort(ref pos);
                    int           pp    = str.DeserializeInt(ref pos);
                    MorphTreeNode child = new MorphTreeNode();
                    int           res1  = child.Deserialize(str, ref pos);
                    res += (1 + res1);
                    Nodes.Add((short)i, child);
                }
            }
            return(res);
        }
Exemple #5
0
        internal void Deserialize(ByteArrayWrapper str, ref int pos)
        {
            int ii = str.DeserializeShort(ref pos);

            Id = ii;
            short id = (short)1;

            while (!str.IsEOF(pos))
            {
                byte b = str.DeserializeByte(ref pos);
                if (b == 0xFF)
                {
                    break;
                }
                pos--;
                string key = str.DeserializeString(ref pos);
                if (key == null)
                {
                    key = "";
                }
                List <MorphRuleVariant> li = new List <MorphRuleVariant>();
                while (!str.IsEOF(pos))
                {
                    MorphRuleVariant mrv = new MorphRuleVariant();
                    if (!mrv.Deserialize(str, ref pos))
                    {
                        break;
                    }
                    mrv.Tail   = key;
                    mrv.RuleId = (short)ii;
                    mrv.Id     = id++;
                    li.Add(mrv);
                }
                this.Add(key, li);
            }
        }