fix(codegen): Adds default codegen option for save flags. Fixes world load issues. (#707)

This commit is contained in:
Kamron Batman 2021-08-19 22:51:44 -07:00 • committed by GitHub
parent 3fc2b76468
commit ca5e9342a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 204 additions and 109 deletions

View file

@ -113,7 +113,7 @@ namespace Server.Engines.BulkOrders
}
}
[AfterDeserialization]
[AfterDeserialization(false)]
private void AfterDeserialization()
{
if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)

View file

@ -20,6 +20,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeAosAttributes() => !_attributes.IsEmpty;
[SerializableFieldDefault(0)]
private AosAttributes AttributesDefaultValue() => new(this);
[SerializableField(1, setter: "private")]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster, canModify: true)]")]
private AosArmorAttributes _armorAttributes;
@ -27,6 +30,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeArmorAttributes() => !_armorAttributes.IsEmpty;
[SerializableFieldDefault(1)]
private AosArmorAttributes ArmorAttributesDefaultValue() => new(this);
[InvalidateProperties]
[SerializableField(2)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
@ -135,6 +141,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(23)]
private bool ShouldSerializeSkillBonuses() => !_skillBonuses.IsEmpty;
[SerializableFieldDefault(23)]
private AosSkillBonuses SkillBonusesDefaultValue() => new(this);
[SerializableField(24)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
public bool _playerConstructed;
@ -269,6 +278,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(14)]
private bool ShouldSerializeResource() => _resource != DefaultResource;
[SerializableFieldDefault(14)]
private CraftResource ResourceDefaultValue() => DefaultResource;
[SerializableField(15)]
[CommandProperty(AccessLevel.GameMaster)]
public int BaseArmorRating
@ -285,6 +297,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(15)]
private bool ShouldSerializeArmorBase() => _armorBase != -1;
[SerializableFieldDefault(15)]
private int ArmorBaseDefaultValue() => -1;
public double BaseArmorRatingScaled => BaseArmorRating * ArmorScalar;
public virtual double ArmorRating
@ -358,6 +373,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(16)]
private bool ShouldSerializeStrBonus() => _strBonus != -1;
[SerializableFieldDefault(16)]
private int StrBonusDefaultValue() => -1;
[SerializableField(17)]
[CommandProperty(AccessLevel.GameMaster)]
public int DexBonus
@ -374,6 +392,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(17)]
private bool ShouldSerializeDexBonus() => _dexBonus != -1;
[SerializableFieldDefault(17)]
private int DexBonusDefaultValue() => -1;
[SerializableField(18)]
[CommandProperty(AccessLevel.GameMaster)]
public int IntBonus
@ -390,6 +411,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(18)]
private bool ShouldSerializeIntBonus() => _intBonus != -1;
[SerializableFieldDefault(18)]
private int IntBonusDefaultValue() => -1;
[SerializableField(19)]
[CommandProperty(AccessLevel.GameMaster)]
public int StrRequirement
@ -406,6 +430,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(19)]
private bool ShouldSerializeStrReq() => _strReq != -1;
[SerializableFieldDefault(19)]
private int StrReqDefaultValue() => -1;
[SerializableField(20)]
[CommandProperty(AccessLevel.GameMaster)]
public int DexRequirement
@ -422,6 +449,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(20)]
private bool ShouldSerializeDexReq() => _dexReq != -1;
[SerializableFieldDefault(20)]
private int DexReqDefaultValue() => -1;
[SerializableField(21)]
[CommandProperty(AccessLevel.GameMaster)]
public int IntRequirement
@ -438,6 +468,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(21)]
private bool ShouldSerializeIntReq() => _intReq != -1;
[SerializableFieldDefault(21)]
private int IntReqDefaultValue() => -1;
[SerializableField(22)]
[CommandProperty(AccessLevel.GameMaster)]
public AMA MeditationAllowance
@ -1044,10 +1077,6 @@ namespace Server.Items
[AfterDeserialization]
private void AfterDeserialization()
{
Attributes ??= new AosAttributes(this);
ArmorAttributes ??= new AosArmorAttributes(this);
SkillBonuses ??= new AosSkillBonuses(this);
var m = Parent as Mobile;
if (Core.AOS && m != null)

View file

@ -37,11 +37,8 @@ namespace Server.Items
[SerializableFieldSaveFlag(0)]
private bool ShouldSerializeWeaponAttributes() => !_weaponAttributes.IsEmpty;
[AfterDeserialization]
private void AfterDeserialization()
{
_weaponAttributes ??= new AosWeaponAttributes(this);
}
[SerializableFieldDefault(0)]
private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this);
public override void AppendChildNameProperties(ObjectPropertyList list)
{

View file

@ -23,6 +23,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(1)]
private bool ShouldSerializeTitle() => _title != DefaultContent?.Title;
[SerializableFieldDefault(1)]
private string TitleDefaultValue() => DefaultContent?.Title;
[InvalidateProperties]
[SerializableField(2)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
@ -31,6 +34,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(2)]
private bool ShouldSerializeAuthor() => _author != DefaultContent?.Author;
[SerializableFieldDefault(2)]
private string AuthorDefaultValue() => DefaultContent?.Author;
[SerializableField(3)]
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
private bool _writable;
@ -44,6 +50,9 @@ namespace Server.Items
[SerializableFieldSaveFlag(4)]
private bool ShouldSerializePages() => DefaultContent?.IsMatch(_pages) != true;
[SerializableFieldDefault(4)]
private BookPageInfo[] PagesDefaultvalue() => DefaultContent?.Copy() ?? Array.Empty<BookPageInfo>();
[Constructible]
public BaseBook(int itemID, int pageCount = 20, bool writable = true) : this(itemID, null, null, pageCount, writable)
{
@ -122,18 +131,6 @@ namespace Server.Items
SetSecureLevelEntry.AddTo(from, this, list);
}
[AfterDeserialization]
private void AfterDeserialization()
{
var content = DefaultContent;
if (content != null)
{
_title ??= content.Title;
_author ??= content.Author;
}
}
private void Deserialize(IGenericReader reader, int version)
{
Level = (SecureLevel)reader.ReadInt();

View file

@ -172,7 +172,7 @@ namespace Server.Items
base.PlaySwingAnimation( attacker );
}*/
[AfterDeserialization]
[AfterDeserialization(false)]
private void OnAfterDeserialization()
{
Delete();