Iomega0318

Member
ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So I can't wrap my head around the way serialization works and in this case something was removed but the write number was still increased according to the changes on the github which really confuses me.. anyways I need help merging the following:
C#:
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(30); // version

            writer.Write(IsSoulbound);

            writer.Write(m_ForceActiveSpeed);
            writer.Write(m_ForcePassiveSpeed);

            writer.Write(CanMove);
            writer.Write(_LockDirection);
            writer.Write(ApproachWait);
            writer.Write(ApproachRange);

            writer.Write((int)m_CurrentAI);
            writer.Write((int)m_DefaultAI);

            writer.Write(m_iRangePerception);
            writer.Write(m_iRangeFight);

            writer.Write(m_iTeam);

            writer.Write(m_dActiveSpeed);
            writer.Write(m_dPassiveSpeed);
            writer.Write(m_dCurrentSpeed);

            writer.Write(m_pHome.X);
            writer.Write(m_pHome.Y);
            writer.Write(m_pHome.Z);

            // Version 1
            writer.Write(m_iRangeHome);

            int i = 0;

            writer.Write(m_arSpellAttack.Count);

            for (i = 0; i < m_arSpellAttack.Count; i++)
            {
                writer.Write(m_arSpellAttack[i].ToString());
            }

            writer.Write(m_arSpellDefense.Count);

            for (i = 0; i < m_arSpellDefense.Count; i++)
            {
                writer.Write(m_arSpellDefense[i].ToString());
            }

            // Version 2
            writer.Write((int)m_FightMode);

            writer.Write(m_bControlled);
            writer.Write(m_ControlMaster);
            writer.Write(m_ControlTarget is Mobile ? (Mobile)m_ControlTarget : null);
            writer.Write(m_ControlDest);
            writer.Write((int)m_ControlOrder);
            writer.Write(m_dMinTameSkill);

            writer.Write(m_bTamable);
            writer.Write(m_bSummoned);

            if (m_bSummoned)
            {
                writer.WriteDeltaTime(m_SummonEnd);
            }

            writer.Write(m_iControlSlots);

            // Version 3
            writer.Write(m_Loyalty);

            // Version 4
            writer.Write(m_CurrentWayPoint);

            // Verison 5
            writer.Write(m_SummonMaster);

            // Version 6
            writer.Write(m_HitsMax);
            writer.Write(m_StamMax);
            writer.Write(m_ManaMax);
            writer.Write(m_DamageMin);
            writer.Write(m_DamageMax);

            // Version 7
            writer.Write(m_PhysicalResistance);
            writer.Write(m_PhysicalDamage);

            writer.Write(m_FireResistance);
            writer.Write(m_FireDamage);

            writer.Write(m_ColdResistance);
            writer.Write(m_ColdDamage);

            writer.Write(m_PoisonResistance);
            writer.Write(m_PoisonDamage);

            writer.Write(m_EnergyResistance);
            writer.Write(m_EnergyDamage);

            // Version 8
            writer.Write(m_Owners, true);

            // Version 10
            writer.Write(m_IsDeadPet);
            writer.Write(m_IsBonded);
            writer.Write(m_BondingBegin);
            writer.Write(m_OwnerAbandonTime);

            // Version 11
            writer.Write(m_HasGeneratedLoot);

            // Version 12
            writer.Write(m_Paragon);

            // Version 13
            writer.Write((m_Friends != null && m_Friends.Count > 0));

            if (m_Friends != null && m_Friends.Count > 0)
            {
                writer.Write(m_Friends, true);
            }

            // Version 14
            writer.Write(m_RemoveIfUntamed);
            writer.Write(m_RemoveStep);

            // Version 17
            if (IsStabled || (Controlled && ControlMaster != null))
            {
                writer.Write(TimeSpan.Zero);
            }
            else
            {
                writer.Write(DeleteTimeLeft);
            }

            // Version 18
            writer.Write(m_CorpseNameOverride);

            // Mondain's Legacy version 19
            writer.Write(m_Allured);
            
            // Version 21 FS:ATS EDITS
            writer.Write( (bool) m_IsMating );
            writer.Write( (int) m_ABPoints );
            writer.Write( (int) m_Exp );
            writer.Write( (int) m_NextLevel );
            writer.Write( (int) m_Level );
            writer.Write( (int) m_MaxLevel );
            writer.Write( (bool) m_AllowMating );
            writer.Write( (bool) m_Evolves );
            writer.Write( (int) m_Gen );
            writer.Write( (DateTime) m_MatingDelay );
            writer.Write( (int) m_Form1 );
            writer.Write( (int) m_Form2 );
            writer.Write( (int) m_Form3 );
            writer.Write( (int) m_Form4 );
            writer.Write( (int) m_Form5 );
            writer.Write( (int) m_Form6 );
            writer.Write( (int) m_Form7 );
            writer.Write( (int) m_Form8 );
            writer.Write( (int) m_Form9 );
            writer.Write( (int) m_Sound1 );
            writer.Write( (int) m_Sound2 );
            writer.Write( (int) m_Sound3 );
            writer.Write( (int) m_Sound4 );
            writer.Write( (int) m_Sound5 );
            writer.Write( (int) m_Sound6 );
            writer.Write( (int) m_Sound7 );
            writer.Write( (int) m_Sound8 );
            writer.Write( (int) m_Sound9 );
            writer.Write( (bool) m_UsesForm1 );
            writer.Write( (bool) m_UsesForm2 );
            writer.Write( (bool) m_UsesForm3 );
            writer.Write( (bool) m_UsesForm4 );
            writer.Write( (bool) m_UsesForm5 );
            writer.Write( (bool) m_UsesForm6 );
            writer.Write( (bool) m_UsesForm7 );
            writer.Write( (bool) m_UsesForm8 );
            writer.Write( (bool) m_UsesForm9 );
            writer.Write( (bool) m_F0 );
            writer.Write( (bool) m_F1 );
            writer.Write( (bool) m_F2 );
            writer.Write( (bool) m_F3 );
            writer.Write( (bool) m_F4 );
            writer.Write( (bool) m_F5 );
            writer.Write( (bool) m_F6 );
            writer.Write( (bool) m_F7 );
            writer.Write( (bool) m_F8 );
            writer.Write( (bool) m_F9 );
            writer.Write( (int) m_RoarAttack );
            writer.Write( (int) m_PetPoisonAttack );
            writer.Write( (int) m_FireBreathAttack );

            // Pet Branding version 22
            writer.Write(m_EngravedText);

            // Version 24 Pet Training
            writer.Write(ControlSlotsMin);
            writer.Write(ControlSlotsMax);

            writer.Write((int)Mastery);

            if (_Profile != null)
            {
                writer.Write(1);
                _Profile.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }

            if (_TrainingProfile != null)
            {
                writer.Write(1);
                _TrainingProfile.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }

            // Version 25 Current Tame Skill
            writer.Write(m_CurrentTameSkill);
        }

        private static readonly double[] m_StandardActiveSpeeds = new[] { 0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8 };

        private static readonly double[] m_StandardPassiveSpeeds = new[] { 0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0 };

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
            if (version == 29)
            {
                reader.Info = "V";
            }

            switch (version)
            {
                case 30:
                    goto case 29;
                case 29:
                    IsSoulbound = reader.ReadBool();
                    goto case 28;
                case 28:
                    m_ForceActiveSpeed = reader.ReadDouble();
                    m_ForcePassiveSpeed = reader.ReadDouble();
                    goto case 27;
                case 27: // Pet Slot Fix
                case 26:
                {
                    CanMove = reader.ReadBool();
                    _LockDirection = reader.ReadBool();

                    ApproachWait = reader.ReadBool();
                    ApproachRange = reader.ReadInt();
                }
                    break;
            }

            m_CurrentAI = (AIType)reader.ReadInt();
            m_DefaultAI = (AIType)reader.ReadInt();

            m_iRangePerception = reader.ReadInt();
            m_iRangeFight = reader.ReadInt();

            m_iTeam = reader.ReadInt();

            m_dActiveSpeed = reader.ReadDouble();
            m_dPassiveSpeed = reader.ReadDouble();
            m_dCurrentSpeed = reader.ReadDouble();

            if (m_iRangePerception == OldRangePerception)
            {
                m_iRangePerception = DefaultRangePerception;
            }

            m_pHome.X = reader.ReadInt();
            m_pHome.Y = reader.ReadInt();
            m_pHome.Z = reader.ReadInt();

            if (version >= 1)
            {
                m_iRangeHome = reader.ReadInt();

                int i, iCount;

                iCount = reader.ReadInt();
                for (i = 0; i < iCount; i++)
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType(str);

                    if (type != null)
                    {
                        m_arSpellAttack.Add(type);
                    }
                }

                iCount = reader.ReadInt();
                for (i = 0; i < iCount; i++)
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType(str);

                    if (type != null)
                    {
                        m_arSpellDefense.Add(type);
                    }
                }
            }
            else
            {
                m_iRangeHome = 0;
            }

            if (version >= 2)
            {
                m_FightMode = (FightMode)reader.ReadInt();

                m_bControlled = reader.ReadBool();
                m_ControlMaster = reader.ReadMobile();
                m_ControlTarget = reader.ReadMobile();
                m_ControlDest = reader.ReadPoint3D();
                m_ControlOrder = (OrderType)reader.ReadInt();

                m_dMinTameSkill = reader.ReadDouble();

                if (version < 9)
                {
                    reader.ReadDouble();
                }

                m_bTamable = reader.ReadBool();
                m_bSummoned = reader.ReadBool();

                if (m_bSummoned)
                {
                    m_SummonEnd = reader.ReadDeltaTime();
                    new UnsummonTimer(m_ControlMaster, this, m_SummonEnd - DateTime.UtcNow).Start();
                }

                m_iControlSlots = reader.ReadInt();
            }
            else
            {
                m_FightMode = FightMode.Closest;

                m_bControlled = false;
                m_ControlMaster = null;
                m_ControlTarget = null;
                m_ControlOrder = OrderType.None;
            }

            if (version >= 3)
            {
                m_Loyalty = reader.ReadInt();
            }
            else
            {
                m_Loyalty = MaxLoyalty; // Wonderfully Happy
            }

            if (version >= 4)
            {
                m_CurrentWayPoint = reader.ReadItem() as WayPoint;
            }

            if (version >= 5)
            {
                m_SummonMaster = reader.ReadMobile();
            }

            if (version >= 6)
            {
                m_HitsMax = reader.ReadInt();
                m_StamMax = reader.ReadInt();
                m_ManaMax = reader.ReadInt();
                m_DamageMin = reader.ReadInt();
                m_DamageMax = reader.ReadInt();
            }

            if (version >= 7)
            {
                m_PhysicalResistance = reader.ReadInt();
                m_PhysicalDamage = reader.ReadInt();

                m_FireResistance = reader.ReadInt();
                m_FireDamage = reader.ReadInt();

                m_ColdResistance = reader.ReadInt();
                m_ColdDamage = reader.ReadInt();

                m_PoisonResistance = reader.ReadInt();
                m_PoisonDamage = reader.ReadInt();

                m_EnergyResistance = reader.ReadInt();
                m_EnergyDamage = reader.ReadInt();
            }

            if (version >= 8)
            {
                m_Owners = reader.ReadStrongMobileList();
            }
            else
            {
                m_Owners = new List<Mobile>();
            }

            if (version >= 10)
            {
                m_IsDeadPet = reader.ReadBool();
                m_IsBonded = reader.ReadBool();
                m_BondingBegin = reader.ReadDateTime();
                m_OwnerAbandonTime = reader.ReadDateTime();
            }

            if (version >= 11)
            {
                m_HasGeneratedLoot = reader.ReadBool();
            }
            else
            {
                m_HasGeneratedLoot = true;
            }

            if (version >= 12)
            {
                m_Paragon = reader.ReadBool();
            }
            else
            {
                m_Paragon = false;
            }

            if (version >= 13 && reader.ReadBool())
            {
                m_Friends = reader.ReadStrongMobileList();
            }
            else if (version < 13 && m_ControlOrder >= OrderType.Unfriend)
            {
                ++m_ControlOrder;
            }

            if (version < 16 && Loyalty != MaxLoyalty)
            {
                Loyalty *= 10;
            }

            double activeSpeed = m_dActiveSpeed;
            double passiveSpeed = m_dPassiveSpeed;

            if (version >= 28)
            {
                SpeedInfo.GetSpeedsNew(this, ref activeSpeed, ref passiveSpeed);

                m_dActiveSpeed = activeSpeed;
                m_dPassiveSpeed = passiveSpeed;
            }
            else
            {
                SpeedInfo.GetSpeeds(this, ref activeSpeed, ref passiveSpeed);

                bool isStandardActive = false;
                for (int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i)
                {
                    isStandardActive = (m_dActiveSpeed == m_StandardActiveSpeeds[i]);
                }

                bool isStandardPassive = false;
                for (int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i)
                {
                    isStandardPassive = (m_dPassiveSpeed == m_StandardPassiveSpeeds[i]);
                }

                if (isStandardActive && m_dCurrentSpeed == m_dActiveSpeed)
                {
                    m_dCurrentSpeed = activeSpeed;
                }
                else if (isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed)
                {
                    m_dCurrentSpeed = passiveSpeed;
                }

                if (isStandardActive && !m_Paragon)
                {
                    m_dActiveSpeed = activeSpeed;
                }

                if (isStandardPassive && !m_Paragon)
                {
                    m_dPassiveSpeed = passiveSpeed;
                }
            }

            if (version >= 14)
            {
                m_RemoveIfUntamed = reader.ReadBool();
                m_RemoveStep = reader.ReadInt();
            }

            TimeSpan deleteTime = TimeSpan.Zero;

            if (version >= 17)
            {
                deleteTime = reader.ReadTimeSpan();
            }

            if (deleteTime > TimeSpan.Zero || LastOwner != null && !Controlled && !IsStabled)
            {
                if (deleteTime == TimeSpan.Zero)
                {
                    deleteTime = TimeSpan.FromDays(3.0);
                }

                m_DeleteTimer = new DeleteTimer(this, deleteTime);
                m_DeleteTimer.Start();
            }

            if (version >= 18)
            {
                m_CorpseNameOverride = reader.ReadString();
            }

            if (version >= 19)
            {
                m_Allured = reader.ReadBool();
            }

            if (version <= 20)
            {
                reader.ReadInt();
            }

            if (version < 26)
            {
                CanMove = true;

                ApproachWait = false;
                ApproachRange = 10;
            }
            
            // FS ATS Starts
            if ( version >= 21 )
            {
                m_IsMating = reader.ReadBool();
                m_ABPoints = reader.ReadInt();
                m_Exp = reader.ReadInt();
                m_NextLevel = reader.ReadInt();
                m_Level = reader.ReadInt();
                m_MaxLevel = reader.ReadInt();
                m_AllowMating = reader.ReadBool();
                m_Evolves = reader.ReadBool();
                m_Gen = reader.ReadInt();
                m_MatingDelay = reader.ReadDateTime();
                m_Form1 = reader.ReadInt();
                m_Form2 = reader.ReadInt();
                m_Form3 = reader.ReadInt();
                m_Form4 = reader.ReadInt();
                m_Form5 = reader.ReadInt();
                m_Form6 = reader.ReadInt();
                m_Form7 = reader.ReadInt();
                m_Form8 = reader.ReadInt();
                m_Form9 = reader.ReadInt();
                m_Sound1 = reader.ReadInt();
                m_Sound2 = reader.ReadInt();
                m_Sound3 = reader.ReadInt();
                m_Sound4 = reader.ReadInt();
                m_Sound5 = reader.ReadInt();
                m_Sound6 = reader.ReadInt();
                m_Sound7 = reader.ReadInt();
                m_Sound8 = reader.ReadInt();
                m_Sound9 = reader.ReadInt();
                m_UsesForm1 = reader.ReadBool();
                m_UsesForm2 = reader.ReadBool();
                m_UsesForm3 = reader.ReadBool();
                m_UsesForm4 = reader.ReadBool();
                m_UsesForm5 = reader.ReadBool();
                m_UsesForm6 = reader.ReadBool();
                m_UsesForm7 = reader.ReadBool();
                m_UsesForm8 = reader.ReadBool();
                m_UsesForm9 = reader.ReadBool();
                m_F0 = reader.ReadBool();
                m_F1 = reader.ReadBool();
                m_F2 = reader.ReadBool();
                m_F3 = reader.ReadBool();
                m_F4 = reader.ReadBool();
                m_F5 = reader.ReadBool();
                m_F6 = reader.ReadBool();
                m_F7 = reader.ReadBool();
                m_F8 = reader.ReadBool();
                m_F9 = reader.ReadBool();
                m_RoarAttack = reader.ReadInt();
                m_PetPoisonAttack = reader.ReadInt();
                m_FireBreathAttack = reader.ReadInt();
            }
            // FS ATS Ends

            if (version >= 22)
            {
                m_EngravedText = reader.ReadString();
            }

            if (version == 23)
            {
                reader.ReadBool();
            }

            if (version >= 24)
            {
                ControlSlotsMin = reader.ReadInt();
                ControlSlotsMax = reader.ReadInt();

                Mastery = (SkillName)reader.ReadInt();

                if (reader.ReadInt() == 1)
                {
                    _Profile = new AbilityProfile(this, reader);
                }

                if (reader.ReadInt() == 1)
                {
                    _TrainingProfile = new TrainingProfile(this, reader);
                }
            }
            else
            {
                if (Tamable)
                {
                    CalculateSlots(m_iControlSlots);

                    if (m_iControlSlots < ControlSlotsMin)
                    {
                        ControlSlotsMin = m_iControlSlots;
                    }

                    ControlSlots = ControlSlotsMin;
                }

                InitializeAbilities();
            }

            if (version >= 25)
            {
                CurrentTameSkill = reader.ReadDouble();

                if (Controlled && version == 26)
                {
                    AdjustTameRequirements();
                }
                else if (Controlled && CurrentTameSkill > MaxTameRequirement)
                {
                    CurrentTameSkill = MaxTameRequirement;
                }
            }
            else
            {
                AdjustTameRequirements();
            }

            if (version <= 14 && m_Paragon && Hue == 0x31)
            {
                Hue = Paragon.Hue; //Paragon hue fixed, should now be 0x501.
            }

            CheckStatTimers();

            ChangeAIType(m_CurrentAI);

            AddFollowers();

            if (IsAnimatedDead)
            {
                AnimateDeadSpell.Register(m_SummonMaster, this);
            }

            if (Tamable && CurrentTameSkill == 0)
            {
                AdjustTameRequirements();
            }
        }
with:
C#:
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(30); // version

            writer.Write(m_ForceActiveSpeed);
            writer.Write(m_ForcePassiveSpeed);

            writer.Write(CanMove);
            writer.Write(_LockDirection);
            writer.Write(ApproachWait);
            writer.Write(ApproachRange);

            writer.Write((int)m_CurrentAI);
            writer.Write((int)m_DefaultAI);

            writer.Write(m_iRangePerception);
            writer.Write(m_iRangeFight);

            writer.Write(m_iTeam);

            writer.Write(m_dActiveSpeed);
            writer.Write(m_dPassiveSpeed);
            writer.Write(m_dCurrentSpeed);

            writer.Write(m_pHome.X);
            writer.Write(m_pHome.Y);
            writer.Write(m_pHome.Z);

            // Version 1
            writer.Write(m_iRangeHome);

            int i = 0;

            writer.Write(m_arSpellAttack.Count);

            for (i = 0; i < m_arSpellAttack.Count; i++)
            {
                writer.Write(m_arSpellAttack[i].ToString());
            }

            writer.Write(m_arSpellDefense.Count);

            for (i = 0; i < m_arSpellDefense.Count; i++)
            {
                writer.Write(m_arSpellDefense[i].ToString());
            }

            // Version 2
            writer.Write((int)m_FightMode);

            writer.Write(m_bControlled);
            writer.Write(m_ControlMaster);
            writer.Write(m_ControlTarget is Mobile ? (Mobile)m_ControlTarget : null);
            writer.Write(m_ControlDest);
            writer.Write((int)m_ControlOrder);
            writer.Write(m_dMinTameSkill);

            writer.Write(m_bTamable);
            writer.Write(m_bSummoned);

            if (m_bSummoned)
            {
                writer.WriteDeltaTime(m_SummonEnd);
            }

            writer.Write(m_iControlSlots);

            // Version 3
            writer.Write(m_Loyalty);

            // Version 4
            writer.Write(m_CurrentWayPoint);

            // Verison 5
            writer.Write(m_SummonMaster);

            // Version 6
            writer.Write(m_HitsMax);
            writer.Write(m_StamMax);
            writer.Write(m_ManaMax);
            writer.Write(m_DamageMin);
            writer.Write(m_DamageMax);

            // Version 7
            writer.Write(m_PhysicalResistance);
            writer.Write(m_PhysicalDamage);

            writer.Write(m_FireResistance);
            writer.Write(m_FireDamage);

            writer.Write(m_ColdResistance);
            writer.Write(m_ColdDamage);

            writer.Write(m_PoisonResistance);
            writer.Write(m_PoisonDamage);

            writer.Write(m_EnergyResistance);
            writer.Write(m_EnergyDamage);

            // Version 8
            writer.Write(m_Owners, true);

            // Version 10
            writer.Write(m_IsDeadPet);
            writer.Write(m_IsBonded);
            writer.Write(m_BondingBegin);
            writer.Write(m_OwnerAbandonTime);

            // Version 11
            writer.Write(m_HasGeneratedLoot);

            // Version 12
            writer.Write(m_Paragon);

            // Version 13
            writer.Write((m_Friends != null && m_Friends.Count > 0));

            if (m_Friends != null && m_Friends.Count > 0)
            {
                writer.Write(m_Friends, true);
            }

            // Version 14
            writer.Write(m_RemoveIfUntamed);
            writer.Write(m_RemoveStep);

            // Version 17
            if (IsStabled || (Controlled && ControlMaster != null))
            {
                writer.Write(TimeSpan.Zero);
            }
            else
            {
                writer.Write(DeleteTimeLeft);
            }

            // Version 18
            writer.Write(m_CorpseNameOverride);

            // Mondain's Legacy version 19
            writer.Write(m_Allured);

            // Pet Branding version 22
            writer.Write(m_EngravedText);

            // Version 24 Pet Training
            writer.Write(ControlSlotsMin);
            writer.Write(ControlSlotsMax);

            writer.Write((int)Mastery);

            if (_Profile != null)
            {
                writer.Write(1);
                _Profile.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }

            if (_TrainingProfile != null)
            {
                writer.Write(1);
                _TrainingProfile.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }

            // Version 25 Current Tame Skill
            writer.Write(m_CurrentTameSkill);
        }

        private static readonly double[] m_StandardActiveSpeeds = new[] { 0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8 };

        private static readonly double[] m_StandardPassiveSpeeds = new[] { 0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0 };

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 30:
                    goto case 28;
                case 29:
                    reader.ReadBool();
                    goto case 28;
                case 28:
                    m_ForceActiveSpeed = reader.ReadDouble();
                    m_ForcePassiveSpeed = reader.ReadDouble();
                    goto case 27;
                case 27: // Pet Slot Fix
                case 26:
                    {
                        CanMove = reader.ReadBool();
                        _LockDirection = reader.ReadBool();

                        ApproachWait = reader.ReadBool();
                        ApproachRange = reader.ReadInt();
                    }
                    break;
            }

            m_CurrentAI = (AIType)reader.ReadInt();
            m_DefaultAI = (AIType)reader.ReadInt();

            m_iRangePerception = reader.ReadInt();
            m_iRangeFight = reader.ReadInt();

            m_iTeam = reader.ReadInt();

            m_dActiveSpeed = reader.ReadDouble();
            m_dPassiveSpeed = reader.ReadDouble();
            m_dCurrentSpeed = reader.ReadDouble();

            if (m_iRangePerception == OldRangePerception)
            {
                m_iRangePerception = DefaultRangePerception;
            }

            m_pHome.X = reader.ReadInt();
            m_pHome.Y = reader.ReadInt();
            m_pHome.Z = reader.ReadInt();

            if (version >= 1)
            {
                m_iRangeHome = reader.ReadInt();

                int i, iCount;

                iCount = reader.ReadInt();
                for (i = 0; i < iCount; i++)
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType(str);

                    if (type != null)
                    {
                        m_arSpellAttack.Add(type);
                    }
                }

                iCount = reader.ReadInt();
                for (i = 0; i < iCount; i++)
                {
                    string str = reader.ReadString();
                    Type type = Type.GetType(str);

                    if (type != null)
                    {
                        m_arSpellDefense.Add(type);
                    }
                }
            }
            else
            {
                m_iRangeHome = 0;
            }

            if (version >= 2)
            {
                m_FightMode = (FightMode)reader.ReadInt();

                m_bControlled = reader.ReadBool();
                m_ControlMaster = reader.ReadMobile();
                m_ControlTarget = reader.ReadMobile();
                m_ControlDest = reader.ReadPoint3D();
                m_ControlOrder = (OrderType)reader.ReadInt();

                m_dMinTameSkill = reader.ReadDouble();

                if (version < 9)
                {
                    reader.ReadDouble();
                }

                m_bTamable = reader.ReadBool();
                m_bSummoned = reader.ReadBool();

                if (m_bSummoned)
                {
                    m_SummonEnd = reader.ReadDeltaTime();
                    new UnsummonTimer(m_ControlMaster, this, m_SummonEnd - DateTime.UtcNow).Start();
                }

                m_iControlSlots = reader.ReadInt();
            }
            else
            {
                m_FightMode = FightMode.Closest;

                m_bControlled = false;
                m_ControlMaster = null;
                m_ControlTarget = null;
                m_ControlOrder = OrderType.None;
            }

            if (version >= 3)
            {
                m_Loyalty = reader.ReadInt();
            }
            else
            {
                m_Loyalty = MaxLoyalty; // Wonderfully Happy
            }

            if (version >= 4)
            {
                m_CurrentWayPoint = reader.ReadItem() as WayPoint;
            }

            if (version >= 5)
            {
                m_SummonMaster = reader.ReadMobile();
            }

            if (version >= 6)
            {
                m_HitsMax = reader.ReadInt();
                m_StamMax = reader.ReadInt();
                m_ManaMax = reader.ReadInt();
                m_DamageMin = reader.ReadInt();
                m_DamageMax = reader.ReadInt();
            }

            if (version >= 7)
            {
                m_PhysicalResistance = reader.ReadInt();
                m_PhysicalDamage = reader.ReadInt();

                m_FireResistance = reader.ReadInt();
                m_FireDamage = reader.ReadInt();

                m_ColdResistance = reader.ReadInt();
                m_ColdDamage = reader.ReadInt();

                m_PoisonResistance = reader.ReadInt();
                m_PoisonDamage = reader.ReadInt();

                m_EnergyResistance = reader.ReadInt();
                m_EnergyDamage = reader.ReadInt();
            }

            if (version >= 8)
            {
                m_Owners = reader.ReadStrongMobileList();
            }
            else
            {
                m_Owners = new List<Mobile>();
            }

            if (version >= 10)
            {
                m_IsDeadPet = reader.ReadBool();
                m_IsBonded = reader.ReadBool();
                m_BondingBegin = reader.ReadDateTime();
                m_OwnerAbandonTime = reader.ReadDateTime();
            }

            if (version >= 11)
            {
                m_HasGeneratedLoot = reader.ReadBool();
            }
            else
            {
                m_HasGeneratedLoot = true;
            }

            if (version >= 12)
            {
                m_Paragon = reader.ReadBool();
            }
            else
            {
                m_Paragon = false;
            }

            if (version >= 13 && reader.ReadBool())
            {
                m_Friends = reader.ReadStrongMobileList();
            }
            else if (version < 13 && m_ControlOrder >= OrderType.Unfriend)
            {
                ++m_ControlOrder;
            }

            if (version < 16 && Loyalty != MaxLoyalty)
            {
                Loyalty *= 10;
            }

            double activeSpeed = m_dActiveSpeed;
            double passiveSpeed = m_dPassiveSpeed;

            if (version >= 28)
            {
                SpeedInfo.GetSpeedsNew(this, ref activeSpeed, ref passiveSpeed);

                m_dActiveSpeed = activeSpeed;
                m_dPassiveSpeed = passiveSpeed;
            }
            else
            {
                SpeedInfo.GetSpeeds(this, ref activeSpeed, ref passiveSpeed);

                bool isStandardActive = false;
                for (int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i)
                {
                    isStandardActive = (m_dActiveSpeed == m_StandardActiveSpeeds[i]);
                }

                bool isStandardPassive = false;
                for (int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i)
                {
                    isStandardPassive = (m_dPassiveSpeed == m_StandardPassiveSpeeds[i]);
                }

                if (isStandardActive && m_dCurrentSpeed == m_dActiveSpeed)
                {
                    m_dCurrentSpeed = activeSpeed;
                }
                else if (isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed)
                {
                    m_dCurrentSpeed = passiveSpeed;
                }

                if (isStandardActive && !m_Paragon)
                {
                    m_dActiveSpeed = activeSpeed;
                }

                if (isStandardPassive && !m_Paragon)
                {
                    m_dPassiveSpeed = passiveSpeed;
                }
            }

            if (version >= 14)
            {
                m_RemoveIfUntamed = reader.ReadBool();
                m_RemoveStep = reader.ReadInt();
            }

            TimeSpan deleteTime = TimeSpan.Zero;

            if (version >= 17)
            {
                deleteTime = reader.ReadTimeSpan();
            }

            if (deleteTime > TimeSpan.Zero || LastOwner != null && !Controlled && !IsStabled)
            {
                if (deleteTime == TimeSpan.Zero)
                {
                    deleteTime = TimeSpan.FromDays(3.0);
                }

                m_DeleteTimer = new DeleteTimer(this, deleteTime);
                m_DeleteTimer.Start();
            }

            if (version >= 18)
            {
                m_CorpseNameOverride = reader.ReadString();
            }

            if (version >= 19)
            {
                m_Allured = reader.ReadBool();
            }

            if (version <= 20)
            {
                reader.ReadInt();
            }

            if (version < 26)
            {
                CanMove = true;

                ApproachWait = false;
                ApproachRange = 10;
            }

            if (version >= 22)
            {
                m_EngravedText = reader.ReadString();
            }

            if (version == 23)
            {
                reader.ReadBool();
            }

            if (version >= 24)
            {
                ControlSlotsMin = reader.ReadInt();
                ControlSlotsMax = reader.ReadInt();

                Mastery = (SkillName)reader.ReadInt();

                if (reader.ReadInt() == 1)
                {
                    _Profile = new AbilityProfile(this, reader);
                }

                if (reader.ReadInt() == 1)
                {
                    _TrainingProfile = new TrainingProfile(this, reader);
                }
            }
            else
            {
                if (Tamable)
                {
                    CalculateSlots(m_iControlSlots);

                    if (m_iControlSlots < ControlSlotsMin)
                    {
                        ControlSlotsMin = m_iControlSlots;
                    }

                    ControlSlots = ControlSlotsMin;
                }

                InitializeAbilities();
            }

            if (version >= 25)
            {
                CurrentTameSkill = reader.ReadDouble();

                if (Controlled && version == 26)
                {
                    AdjustTameRequirements();
                }
                else if (Controlled && CurrentTameSkill > MaxTameRequirement)
                {
                    CurrentTameSkill = MaxTameRequirement;
                }
            }
            else
            {
                AdjustTameRequirements();
            }

            if (version <= 14 && m_Paragon && Hue == 0x31)
            {
                Hue = Paragon.Hue; //Paragon hue fixed, should now be 0x501.
            }

            CheckStatTimers();

            ChangeAIType(m_CurrentAI);

            AddFollowers();

            if (IsAnimatedDead)
            {
                AnimateDeadSpell.Register(m_SummonMaster, this);
            }

            if (Tamable && CurrentTameSkill == 0)
            {
                AdjustTameRequirements();
            }
        }

And here is the change I was referencing..
1658022483401.png

I can remove the souldbound portion and it loads fine but if I save and restart it wants to delete all my creatures so clearly I'm not merging those changes right..
 
So case 30 already exists in my case do I not need to increase that when merging? does that matter?
The first code is my script unmerged, it is not edited with the changes posted in the second code.
 
So case 30 already exists in my case do I not need to increase that when merging? does that matter?
The first code is my script unmerged, it is not edited with the changes posted in the second code.
yes, still increase it and create a new case for Deserialize
iirc, this was a way to remove information saved without the compiler requiring deletion of existing items.

NOTE: don't delete any existing cases in the deserializer, and make sure that case 30 goes to case 29 instead of case 28 as @PyrO stated
I'm a little confused what you're trying to do exactly though
You added a new serializer version but removed the property IsSoulBound ??
 
Last edited:
Ok so writer should be increased to 31, indicating it was changed, reader would then have case 31 which points to 28, 30 which points to 29 then in turn points to 28. Is that correct?
yes, still increase it and create a new case for Deserialize
iirc, this was a way to remove information saved without the compiler requiring deletion of existing items.

NOTE: don't delete any existing cases in the deserializer, and make sure that case 30 goes to case 29 instead of case 28 as @PyrO stated
I'm a little confused what you're trying to do exactly though
You added a new serializer version but removed the property IsSoulBound ??
Haha you posted your note after I responded, it did seem to save and load just fine with that though thank you! I assume you can never really change case 30, or other cases without deleting your entire world?

I was just merging changes from github and IsSoulBound was removed but they(ServUO) also increased the case I don't know why I assumed I had to do the same thing? If not please correct me haha I'm just following the changes.




Also correct me if I'm wrong,
Increasing the case in Serialization tells the system you have made a change?
Adding the case in Deserialization tells the system what order to read it back in when loading?

You cannot go down, both must increase and you tell the new case to bypass the old case or to "continue"
You cannot change the deserialization case without destroying your world because the mobiles can no longer be read in the same order?

I'm still confused about the way it works but today it's made a little more sense.
 
Last edited:
Ok so writer should be increased to 31, indicating it was changed, reader would then have case 31 which points to 28, 30 which points to 29 then in turn points to 28. Is that correct?

Haha you posted your note after I responded, it did seem to save and load just fine with that though thank you! I assume you can never really change case 30, or other cases without deleting your entire world?

I was just merging changes from github and IsSoulBound was removed but they(ServUO) also increased the case I don't know why I assumed I had to do the same thing? If not please correct me haha I'm just following the changes.
well this may be more confusing than helpful, but...
- if you already had IsSoulBound on your server then merging correctly would prevent deletion of existing items
- else, 1 to 1 merge wasn't necessary

The reason IsSoulBound = reader.ReadBool(); was changed to just reader.ReadBool(); is because it's a place holder to be backwards compatible for servers that already had the IsSoulBound item property.
 
well this may be more confusing than helpful, but...
- if you already had IsSoulBound on your server then merging correctly would prevent deletion of existing items
- else, 1 to 1 merge wasn't necessary

The reason IsSoulBound = reader.ReadBool(); was changed to just reader.ReadBool(); is because it's a place holder to be backwards compatible for servers that already had the IsSoulBound item property.
I believe it makes sense, so in theory if I hadn't had my changes moving to that version of BC would allow my prior save to load correctly?

Also are you able to answer the second part of my post, if not I can wait for someone to explain it lol. I'm just curious, I'm sure there are more serialization changes in my future as I continue merging changes.
 
I believe it makes sense, so in theory if I hadn't had my changes moving to that version of BC would allow my prior save to load correctly?

Also are you able to answer the second part of my post, if not I can wait for someone to explain it lol. I'm just curious, I'm sure there are more serialization changes in my future as I continue merging changes.
Well, yeah, if done right you can keep saves

2nd part? I'll take a look
I'm uncertain what the second portion is but two things i didn't see last night

The case # 30 was created to skip case 29 on purpose, this is part of the removing a property process

Also, depending on your existing copy the FS:ATS changes shouldn't [typically] be on version 21. This may be accurate depending on your files but it looks wrong
 
Last edited:
Well, yeah, if done right you can keep saves

2nd part? I'll take a look
I'm uncertain what the second portion is but two things i didn't see last night

The case # 30 was created to skip case 29 on purpose, this is part of the removing a property process

Also, depending on your existing copy the FS:ATS changes shouldn't [typically] be on version 21. This may be accurate depending on your files but it looks wrong
Second part of the post was me just asking questions about serialization.
C#:
Also correct me if I'm wrong,
Increasing the case in Serialization tells the system you have made a change?
Adding the case in Deserialization tells the system what order to read it back in when loading?

You cannot go down, both must increase and you tell the new case to bypass the old case or to "continue"
You cannot change the deserialization case without destroying your world because the mobiles can no longer be read in the same order?

I'm still confused about the way it works but today it's made a little more sense.
And yeah I got this copy of ServUO Pub 57 pre-merged with FS:ATS and OWLTR so that just how it came, I never changed anything other than adding in my own things.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back