fix(core): Fixes some properties that cannot be modified ingame (#604)

- [X] Adds a property to `CommandProperty` to allow modifying `PropertyObject` where there is no property setter that is accessible.
- [X] Updates AosAttributes and friends

Example of how to make this work:
```cs
        [CommandProperty(AccessLevel.GameMaster, canModify: true)]
        public AosWeaponAttributes WeaponAttributes { get; private set; }
```

This fix is necessary because in release mode the optimizer will sometimes _entirely remove the setter_ because it knows it can do something that is more efficient _when the property setter is private_. RunUO got around this by declaring a public setter explicitly that _was empty_.

### Screenshot
<img width="313" alt="Screen Shot 2021-05-15 at 11 34 01 PM" src="https://user-images.githubusercontent.com/3953314/118387955-49293c00-b5d6-11eb-8f31-a3b5e31bd18b.png">
This commit is contained in:
Kamron Batman 2021-05-15 23:47:33 -07:00 • committed by GitHub
parent 3023254d87
commit db02a6b6e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 98 additions and 99 deletions

View file

@ -23,7 +23,7 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public Arena Arena { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
@ -475,7 +475,7 @@ namespace Server.Engines.ConPVP
[CommandProperty(AccessLevel.GameMaster)]
public bool IsOccupied => Players.Count > 0;
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public ArenaStartPoints Points { get; }
public Item Teleporter { get; set; }

View file

@ -20,7 +20,7 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty(AccessLevel.Administrator)]
[CommandProperty(AccessLevel.Administrator, canModify: true)]
public Ladder Ladder { get; private set; }
public override string DefaultName => "ladder controller";

View file

@ -28,7 +28,7 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty(AccessLevel.Administrator)]
[CommandProperty(AccessLevel.Administrator, canModify: true)]
public Preferences Preferences { get; private set; }
public override string DefaultName => "preferences controller";

View file

@ -996,10 +996,11 @@ namespace Server.Engines.ConPVP
{
for (var j = 0; j < alerts.Length; ++j)
{
var alert = alerts[j];
Timer.DelayCall(
TimeSpan.FromSeconds(Math.Max(j - 0.5, 0.0)),
() => arena.Announcer.PublicOverheadMessage(MessageType.Regular, 0x35, false, alert)
(announcer, alert) => announcer.PublicOverheadMessage(MessageType.Regular, 0x35, false, alert),
arena.Announcer,
alerts[j]
);
}
}

View file

@ -23,7 +23,7 @@ namespace Server.Engines.ConPVP
{
}
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public Tournament Tournament { get; private set; }
public static bool IsActive

View file

@ -229,9 +229,7 @@ namespace Server.Gumps
var cpa = GetCPA(prop);
// !prop.GetType().IsValueType
if (prop.CanWrite && m_Mobile.AccessLevel >= cpa?.WriteLevel && !cpa.ReadOnly)
if (cpa?.ReadOnly == false && m_Mobile.AccessLevel >= cpa.WriteLevel && (prop.CanWrite || cpa.CanModify))
{
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3);
}
@ -295,10 +293,10 @@ namespace Server.Gumps
return;
}
var attr = GetCPA(prop);
var cpa = GetCPA(prop);
if (!prop.CanWrite || attr == null ||
from.AccessLevel < attr.WriteLevel || attr.ReadOnly)
if (cpa == null || !(prop.CanWrite || cpa.CanModify) || cpa.ReadOnly ||
from.AccessLevel < cpa.WriteLevel)
{
return;
}

View file

@ -357,13 +357,13 @@ namespace Server.Items
}
}
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosArmorAttributes ArmorAttributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]

View file

@ -35,7 +35,7 @@ namespace Server.Items
public override CraftResource DefaultResource => CraftResource.RegularLeather;
public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All;
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosWeaponAttributes WeaponAttributes { get; private set; }
public override void AppendChildNameProperties(ObjectPropertyList list)

View file

@ -104,16 +104,16 @@ namespace Server.Items
}
}
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosArmorAttributes ClothingAttributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosElementAttributes Resistances { get; private set; }
public virtual int BasePhysicalResistance => 0;

View file

@ -76,12 +76,13 @@ namespace Server.Items
}
}
[CommandProperty(AccessLevel.Player)] public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosElementAttributes Resistances { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]

View file

@ -38,7 +38,7 @@ namespace Server.Items
public override int DefaultMaxWeight => 50;
public override double DefaultWeight => 2.0;
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]

View file

@ -119,10 +119,10 @@ namespace Server.Items
public override bool DisplayWeight => false;
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
public virtual SpellbookType SpellbookType => SpellbookType.Regular;

View file

@ -320,10 +320,10 @@ namespace Server.Items
}
}
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
public static void Initialize()

View file

@ -183,16 +183,16 @@ namespace Server.Items
public virtual SkillName AccuracySkill => SkillName.Tactics;
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosAttributes Attributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosWeaponAttributes WeaponAttributes { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosSkillBonuses SkillBonuses { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
[CommandProperty(AccessLevel.GameMaster, canModify: true)]
public AosElementAttributes AosElementDamages { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]