public static void Serialize(GenericWriter writer, VirtueInfo info) { writer.Write((byte)1); // version if (info.m_Values == null) { writer.Write((byte)0); } else { int mask = 0; for (int i = 0; i < 8; ++i) { if (info.m_Values[i] != 0) { mask |= 1 << i; } } writer.Write((byte)mask); for (int i = 0; i < 8; ++i) { if (info.m_Values[i] != 0) { writer.Write((int)info.m_Values[i]); } } } }
public static VirtueInfo Deserialize(GenericReader reader) { int version = reader.ReadByte(); VirtueInfo info = null; switch (version) { case 0: { int mask = reader.ReadByte(); if (mask == 0) { return(null); } info = new VirtueInfo(); for (int i = 0; i < 8; ++i) { if ((mask & (1 << i)) != 0) { info.SetValue(i, reader.ReadInt()); } } break; } } return(info); }
public static void Serialize(GenericWriter writer, VirtueInfo info) { int num2; int num3; writer.Write(((byte)0)); if (info.m_Values == null) { writer.Write(((byte)0)); return; } int num1 = 0; for (num2 = 0; (num2 < 8); ++num2) { if (info.m_Values[num2] != 0) { num1 |= (1 << (num2 & 31)); } } writer.Write(((byte)num1)); for (num3 = 0; (num3 < 8); ++num3) { if (info.m_Values[num3] != 0) { writer.Write(info.m_Values[num3]); } } }
public static void Serialize( GenericWriter writer, VirtueInfo info ) { writer.Write( (byte) 1 ); // version if ( info.m_Values == null ) { writer.Write( (byte) 0 ); } else { int mask = 0; for ( int i = 0; i < 8; ++i ) if ( info.m_Values[i] != 0 ) mask |= 1 << i; writer.Write( (byte) mask ); for ( int i = 0; i < 8; ++i ) if ( info.m_Values[i] != 0 ) writer.Write( (int) info.m_Values[i] ); } }
public virtual void Deserialize( GenericReader reader ) { int version = reader.ReadInt(); switch ( version ) { case 28: { m_LastStatGain = reader.ReadDeltaTime(); goto case 27; } case 27: { m_TithingPoints = reader.ReadInt(); goto case 26; } case 26: case 25: case 24: { m_Corpse = reader.ReadItem() as Container; goto case 23; } case 23: { m_CreationTime = reader.ReadDateTime(); goto case 22; } case 22: // Just removed followers case 21: { m_Stabled = reader.ReadMobileListOrNull(); goto case 20; } case 20: { m_CantWalk = reader.ReadBool(); goto case 19; } case 19: // Just removed variables case 18: { m_Virtues = VirtueInfo.Deserialize( reader ); goto case 17; } case 17: { m_Thirst = reader.ReadInt(); m_BAC = reader.ReadInt(); goto case 16; } case 16: { m_ShortTermMurders = reader.ReadInt(); if ( version <= 24 ) { reader.ReadDateTime(); reader.ReadDateTime(); } goto case 15; } case 15: { if ( version < 22 ) reader.ReadInt(); // followers m_FollowersMax = reader.ReadInt(); goto case 14; } case 14: { m_MagicDamageAbsorb = reader.ReadInt(); goto case 13; } case 13: { m_GuildFealty = reader.ReadMobile(); goto case 12; } case 12: { m_Guild = reader.ReadGuild(); goto case 11; } case 11: { m_DisplayGuildTitle = reader.ReadBool(); goto case 10; } case 10: { m_CanSwim = reader.ReadBool(); goto case 9; } case 9: { m_Squelched = reader.ReadBool(); goto case 8; } case 8: { m_Holding = reader.ReadItem(); goto case 7; } case 7: { m_VirtualArmor = reader.ReadInt(); goto case 6; } case 6: { m_BaseSoundID = reader.ReadInt(); goto case 5; } case 5: { m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); goto case 4; } case 4: { if ( version <= 25 ) { Poison.Deserialize( reader ); /*if ( m_Poison != null ) { m_PoisonTimer = new PoisonTimer( this ); m_PoisonTimer.Start(); }*/ } goto case 3; } case 3: { m_StatCap = reader.ReadInt(); goto case 2; } case 2: { m_NameHue = reader.ReadInt(); goto case 1; } case 1: { m_Hunger = reader.ReadInt(); goto case 0; } case 0: { if ( version < 11 ) m_DisplayGuildTitle = true; if ( version < 3 ) m_StatCap = 225; if ( version < 15 ) { m_Followers = 0; m_FollowersMax = 5; } m_Location = reader.ReadPoint3D(); m_Body = new Body( reader.ReadInt() ); m_Name = reader.ReadString(); if (m_Name != null) m_Name = string.Intern(m_Name); m_GuildTitle = reader.ReadString(); m_Criminal = reader.ReadBool(); m_Kills = reader.ReadInt(); m_SpeechHue = reader.ReadInt(); m_EmoteHue = reader.ReadInt(); m_WhisperHue = reader.ReadInt(); m_YellHue = reader.ReadInt(); m_Language = reader.ReadString(); if (m_Language != null) m_Language = string.Intern(m_Language); m_Female = reader.ReadBool(); m_Warmode = reader.ReadBool(); m_Hidden = reader.ReadBool(); m_Direction = (Direction) reader.ReadByte(); m_Hue = reader.ReadInt(); m_Str = reader.ReadInt(); m_Dex = reader.ReadInt(); m_Int = reader.ReadInt(); m_Hits = reader.ReadInt(); m_Stam = reader.ReadInt(); m_Mana = reader.ReadInt(); m_Map = reader.ReadMap(); m_Blessed = reader.ReadBool(); m_Fame = reader.ReadInt(); m_Karma = reader.ReadInt(); m_AccessLevel = (AccessLevel) reader.ReadByte(); m_Skills = new Skills( this, reader ); int itemCount = reader.ReadInt(); m_Items = new ArrayList( itemCount ); for ( int i = 0; i < itemCount; ++i ) { Item item = reader.ReadItem(); if ( item != null ) m_Items.Add( item ); } m_Player = reader.ReadBool(); m_Title = reader.ReadString(); if (m_Title != null) m_Title = string.Intern(m_Title); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); if ( version <= 18 ) { /*m_LightLevel =*/ reader.ReadInt(); /*m_TotalGold =*/ reader.ReadInt(); /*m_TotalWeight =*/ reader.ReadInt(); } m_AutoPageNotify = reader.ReadBool(); m_LogoutLocation = reader.ReadPoint3D(); m_LogoutMap = reader.ReadMap(); m_StrLock = (StatLockType)reader.ReadByte(); m_DexLock = (StatLockType)reader.ReadByte(); m_IntLock = (StatLockType)reader.ReadByte(); if ( reader.ReadBool() ) { m_StuckMenuUses = new DateTime[reader.ReadInt()]; for ( int i = 0; i < m_StuckMenuUses.Length; ++i ) { m_StuckMenuUses[i] = reader.ReadDateTime(); } } else { m_StuckMenuUses = null; } if ( m_Player && m_Map != Map.Internal ) { m_LogoutLocation = m_Location; m_LogoutMap = m_Map; m_Map = Map.Internal; } if ( m_Map != null ) m_Map.OnEnter( this ); if ( m_Criminal ) { if ( m_ExpireCriminal == null ) m_ExpireCriminal = new ExpireCriminalTimer( this ); m_ExpireCriminal.Start(); } if ( ShouldCheckStatTimers ) CheckStatTimers(); if ( !m_Player && m_Dex <= 100 && m_CombatTimer != null ) m_CombatTimer.Priority = TimerPriority.FiftyMS; else if ( m_CombatTimer != null ) m_CombatTimer.Priority = TimerPriority.EveryTick; m_Region = Region.Find( m_Location, m_Map ); m_Region.InternalEnter( this ); UpdateResistances(); break; } } }
public void DefaultMobileInit() { m_StatCap = 225; m_FollowersMax = 5; m_Skills = new Skills( this ); m_Items = new ArrayList( 1 ); m_StatMods = null; Map = Map.Internal; m_AutoPageNotify = true; m_Aggressors = null; m_Aggressed = null; m_Virtues = null; m_Stabled = null; m_DamageEntries = new ArrayList( 1 ); m_NextSkillTime = DateTime.MinValue; m_CreationTime = Core.Now; }
/// <summary> /// Initialize some fields when creating a fresh new Mobile. Otherwise these should be initialized by <see cref="Deserialize"/> method. /// </summary> private void DefaultMobileInit() { m_StatCap = 225; m_Skills = new Skills( this ); m_EquippedItems = new List<Item>( 1 ); m_StatMods = new List<StatMod>( 1 ); Map = Map.Internal; m_AutoPageNotify = true; m_Virtues = new VirtueInfo(); m_Stabled = new List<Mobile>( 1 ); m_CreationTime = DateTime.Now; }
public virtual void Deserialize( GenericReader reader ) { int version = reader.ReadInt(); switch ( version ) { case 36: case 35: case 34: { byte hairflag = reader.ReadByte(); if ( ( hairflag & 0x01 ) != 0 ) m_Hair = new HairInfo( reader ); if ( ( hairflag & 0x02 ) != 0 ) m_FacialHair = new FacialHairInfo( reader ); m_InstanceID = reader.ReadInt(); m_Race = reader.ReadRace(); if ( version < 36 ) reader.ReadDeltaTime(); m_TithingPoints = reader.ReadInt(); m_Corpse = reader.ReadItem() as Container; m_CreationTime = reader.ReadDateTime(); m_Stabled = reader.ReadStrongMobileList(); m_CantWalk = reader.ReadBool(); m_Virtues = new VirtueInfo( reader ); m_Thirst = reader.ReadInt(); m_BAC = reader.ReadInt(); m_ShortTermMurders = reader.ReadInt(); if ( version < 35 ) reader.ReadInt(); m_MagicDamageAbsorb = reader.ReadInt(); m_GuildFealty = reader.ReadMobile(); m_Guild = reader.ReadGuild(); m_DisplayGuildTitle = reader.ReadBool(); m_CanSwim = reader.ReadBool(); m_Squelched = reader.ReadBool(); m_Holding = reader.ReadItem(); m_BaseSoundID = reader.ReadInt(); m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); m_StatCap = reader.ReadInt(); m_NameHue = reader.ReadInt(); m_Hunger = reader.ReadInt(); m_Location = reader.ReadPoint3D(); m_Body = new Body( reader.ReadInt() ); m_Name = reader.ReadString(); if ( m_Name != null ) m_Name = string.Intern( m_Name ); m_GuildTitle = reader.ReadString(); m_Criminal = reader.ReadBool(); m_Kills = reader.ReadInt(); m_SpeechHue = reader.ReadInt(); m_EmoteHue = reader.ReadInt(); m_WhisperHue = reader.ReadInt(); m_YellHue = reader.ReadInt(); m_Language = reader.ReadString(); if ( m_Language != null ) m_Language = string.Intern( m_Language ); m_Female = reader.ReadBool(); m_Warmode = reader.ReadBool(); m_Hidden = reader.ReadBool(); m_Direction = (Direction) reader.ReadByte(); m_Hue = reader.ReadInt(); m_Str = reader.ReadInt(); m_Dex = reader.ReadInt(); m_Int = reader.ReadInt(); m_Hits = reader.ReadInt(); m_Stam = reader.ReadInt(); m_Mana = reader.ReadInt(); m_Map = reader.ReadMap(); m_Blessed = reader.ReadBool(); m_Fame = reader.ReadInt(); m_Karma = reader.ReadInt(); m_AccessLevel = (AccessLevel) reader.ReadByte(); m_Skills = new Skills( this, reader ); int itemCount = reader.ReadInt(); m_EquippedItems = new List<Item>( itemCount ); for ( int i = 0; i < itemCount; ++i ) { Item item = reader.ReadItem(); if ( item != null ) m_EquippedItems.Add( item ); } m_IsPlayer = reader.ReadBool(); m_Title = reader.ReadString(); if ( m_Title != null ) m_Title = string.Intern( m_Title ); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); m_AutoPageNotify = reader.ReadBool(); m_LogoutLocation = reader.ReadPoint3D(); m_LogoutMap = reader.ReadMap(); m_StrLock = (StatLockType) reader.ReadByte(); m_DexLock = (StatLockType) reader.ReadByte(); m_IntLock = (StatLockType) reader.ReadByte(); m_StatMods = new List<StatMod>(); if ( reader.ReadBool() ) { m_StuckMenuUses = new DateTime[reader.ReadInt()]; for ( int i = 0; i < m_StuckMenuUses.Length; ++i ) { m_StuckMenuUses[i] = reader.ReadDateTime(); } } else { m_StuckMenuUses = null; } if ( m_IsPlayer && m_Map != Map.Internal ) { m_LogoutLocation = m_Location; m_LogoutMap = m_Map; m_Map = Map.Internal; } if ( m_Map != null ) m_Map.OnEnter( this ); if ( m_Criminal ) { if ( m_ExpireCriminal == null ) m_ExpireCriminal = new ExpireCriminalTimer( this ); m_ExpireCriminal.Start(); } if ( ShouldCheckStatTimers ) CheckStatTimers(); UpdateRegion(); UpdateResistances(); break; } } }
public static VirtueInfo Deserialize(GenericReader reader) { int version = reader.ReadByte(); VirtueInfo info = null; switch ( version ) { case 0: { int mask = reader.ReadByte(); if (mask == 0) return null; info = new VirtueInfo(); for ( int i = 0; i < 8; ++i ) if ( (mask & (1 << i)) != 0 ) info.SetValue(i, reader.ReadInt()); break; } } return info; }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 31: { m_STRBonusCap = reader.ReadInt(); goto case 30; } case 30: { int size = reader.ReadInt32(); FlyIDs = new int[size]; for (int i = 0; i < size; i++) { FlyIDs[i] = reader.ReadInt(); } goto case 29; } case 29: { m_CanFly = reader.ReadBool(); goto case 28; } case 28: { m_LastStatGain = reader.ReadDeltaTime(); goto case 27; } case 27: { m_Flags = (MobileFlags)reader.ReadInt32(); goto case 26; } case 26: case 25: case 24: { m_Corpse = reader.ReadItem() as Container; goto case 23; } case 23: { m_CreationTime = reader.ReadDateTime(); goto case 22; } case 22: // Just removed followers case 21: { m_Stabled = reader.ReadMobileList(); goto case 20; } case 20: { m_CantWalk = reader.ReadBool(); goto case 19; } case 19: // Just removed variables case 18: { m_Virtues = new VirtueInfo(reader); goto case 17; } case 17: { m_Thirst = reader.ReadInt32(); m_BAC = reader.ReadInt32(); goto case 16; } case 16: { m_ShortTermMurders = reader.ReadInt32(); if (version <= 24) { reader.ReadDateTime(); reader.ReadDateTime(); } goto case 15; } case 15: { if (version < 22) reader.ReadInt(); // followers m_FollowersMax = reader.ReadInt32(); goto case 14; } case 14: { m_MagicDamageAbsorb = reader.ReadInt32(); goto case 13; } case 13: { m_GuildFealty = reader.ReadMobile(); goto case 12; } case 12: { m_Guild = reader.ReadGuild(); goto case 11; } case 11: { m_DisplayGuildTitle = reader.ReadBool(); goto case 10; } case 10: { m_CanSwim = reader.ReadBool(); goto case 9; } case 9: { m_Squelched = reader.ReadBool(); goto case 8; } case 8: { m_Holding = reader.ReadItem(); goto case 7; } case 7: { m_VirtualArmor = reader.ReadInt32(); goto case 6; } case 6: { m_BaseSoundID = reader.ReadInt32(); goto case 5; } case 5: { m_DisarmReady = reader.ReadBool(); m_StunReady = reader.ReadBool(); goto case 4; } case 4: { if (version <= 25) { Poison.Deserialize(reader); /*if ( m_Poison != null ) { m_PoisonTimer = new PoisonTimer( this ); m_PoisonTimer.Start(); }*/ } goto case 3; } case 3: { m_StatCap = reader.ReadInt32(); goto case 2; } case 2: { m_NameHue = reader.ReadInt32(); goto case 1; } case 1: { m_Hunger = reader.ReadInt32(); goto case 0; } case 0: { if (version < 21) m_Stabled = new ArrayList(); if (version < 18) m_Virtues = new VirtueInfo(); if (version < 11) m_DisplayGuildTitle = true; if (version < 3) m_StatCap = 225; if (version < 15) { m_Followers = 0; m_FollowersMax = 5; } m_Location = reader.ReadPoint3D(); m_Body = new Body(reader.ReadInt32()); m_Name = reader.ReadString(); m_GuildTitle = reader.ReadString(); m_Criminal = reader.ReadBool(); m_Kills = reader.ReadInt32(); m_SpeechHue = reader.ReadInt32(); m_EmoteHue = reader.ReadInt32(); m_WhisperHue = reader.ReadInt32(); m_YellHue = reader.ReadInt32(); m_Language = reader.ReadString(); m_Female = reader.ReadBool(); m_Warmode = reader.ReadBool(); m_Hidden = reader.ReadBool(); m_Direction = (Direction)reader.ReadByte(); m_Hue = reader.ReadInt32(); m_Str = reader.ReadInt32(); m_Dex = reader.ReadInt32(); m_Int = reader.ReadInt32(); m_Hits = reader.ReadInt32(); m_Stam = reader.ReadInt32(); m_Mana = reader.ReadInt32(); m_Map = reader.ReadMap(); m_Blessed = reader.ReadBool(); m_Fame = reader.ReadInt32(); m_Karma = reader.ReadInt32(); m_AccessLevel = (AccessLevel)reader.ReadByte(); // Convert old bonus caps to 'no cap' if (version < 31) m_STRBonusCap = 0; // Convert old access levels to new access levels if (version < 31) { switch (m_AccessLevel) { case (AccessLevel)0: //OldPlayer = 0, { m_AccessLevel = AccessLevel.Player; break; } case (AccessLevel)1: //OldCounselor = 1, { m_AccessLevel = AccessLevel.Counselor; break; } case (AccessLevel)2: //OldGameMaster = 2, { m_AccessLevel = AccessLevel.GameMaster; break; } case (AccessLevel)3: //OldSeer = 3, { m_AccessLevel = AccessLevel.Seer; break; } case (AccessLevel)4: //OldAdministrator = 4, { m_AccessLevel = AccessLevel.Administrator; break; } } } m_Skills = new Skills(this, reader); int itemCount = reader.ReadInt32(); m_Items = new ArrayList(itemCount); for (int i = 0; i < itemCount; ++i) { Item item = reader.ReadItem(); if (item != null) m_Items.Add(item); } m_Player = reader.ReadBool(); m_Title = reader.ReadString(); m_Profile = reader.ReadString(); m_ProfileLocked = reader.ReadBool(); if (version <= 18) { /*m_LightLevel =*/ reader.ReadInt(); /*m_TotalGold =*/ reader.ReadInt(); /*m_TotalWeight =*/ reader.ReadInt(); } m_AutoPageNotify = reader.ReadBool(); m_LogoutLocation = reader.ReadPoint3D(); m_LogoutMap = reader.ReadMap(); m_StrLock = (StatLockType)reader.ReadByte(); m_DexLock = (StatLockType)reader.ReadByte(); m_IntLock = (StatLockType)reader.ReadByte(); m_StatMods = new ArrayList(); if (reader.ReadBool()) { m_StuckMenuUses = new DateTime[reader.ReadInt32()]; for (int i = 0; i < m_StuckMenuUses.Length; ++i) { m_StuckMenuUses[i] = reader.ReadDateTime(); } } else { m_StuckMenuUses = null; } if (m_Player && m_Map != Map.Internal) { m_LogoutLocation = m_Location; m_LogoutMap = m_Map; m_Map = Map.Internal; } if (m_Map != null) m_Map.OnEnter(this); if (m_Criminal) { if (m_ExpireCriminal == null) m_ExpireCriminal = new ExpireCriminalTimer(this); m_ExpireCriminal.Start(); } if (ShouldCheckStatTimers) CheckStatTimers(); if (!m_Player && m_Dex <= 100 && m_CombatTimer != null) m_CombatTimer.Priority = TimerPriority.FiftyMS; else if (m_CombatTimer != null) m_CombatTimer.Priority = TimerPriority.EveryTick; m_Region = Region.Find(m_Location, m_Map); m_Region.InternalEnter(this); //UpdateResistances(); break; } } //Pix: special logic to ensure the DefensiveSpell lock in m_Actions exists if it should //Note protection is a different beast since there are timers that control // BeginAction/EndAction -- protection effects aren't serialized. if (MagicDamageAbsorb > 0 || MeleeDamageAbsorb > 0) { BeginAction(typeof(DefensiveSpell)); } }