fix: Fixes treasure map chest crash from null guardians (#2236)
This commit is contained in:
parent
aab731ed96
commit
8a118170e7
2 changed files with 9 additions and 6 deletions
|
|
@ -12,6 +12,7 @@ namespace Server.Items;
|
||||||
[SerializationGenerator(2, false)]
|
[SerializationGenerator(2, false)]
|
||||||
public partial class TreasureMapChest : LockableContainer
|
public partial class TreasureMapChest : LockableContainer
|
||||||
{
|
{
|
||||||
|
[Tidy]
|
||||||
[SerializableField(0, setter: "private")]
|
[SerializableField(0, setter: "private")]
|
||||||
private List<Mobile> _guardians;
|
private List<Mobile> _guardians;
|
||||||
|
|
||||||
|
|
@ -57,7 +58,7 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
_level = level;
|
_level = level;
|
||||||
|
|
||||||
_temporary = temporary;
|
_temporary = temporary;
|
||||||
_guardians = new List<Mobile>();
|
_guardians = [];
|
||||||
|
|
||||||
_expireTimer = Timer.DelayCall(TimeSpan.FromHours(3.0), Delete);
|
_expireTimer = Timer.DelayCall(TimeSpan.FromHours(3.0), Delete);
|
||||||
Fill(this, level);
|
Fill(this, level);
|
||||||
|
|
@ -66,7 +67,7 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
public override int LabelNumber => 3000541;
|
public override int LabelNumber => 3000541;
|
||||||
|
|
||||||
public static Type[] Artifacts { get; } =
|
public static Type[] Artifacts { get; } =
|
||||||
{
|
[
|
||||||
typeof(CandelabraOfSouls), typeof(GoldBricks), typeof(PhillipsWoodenSteed),
|
typeof(CandelabraOfSouls), typeof(GoldBricks), typeof(PhillipsWoodenSteed),
|
||||||
typeof(ArcticDeathDealer), typeof(BlazeOfDeath), typeof(BurglarsBandana),
|
typeof(ArcticDeathDealer), typeof(BlazeOfDeath), typeof(BurglarsBandana),
|
||||||
typeof(CavortingClub), typeof(DreadPirateHat),
|
typeof(CavortingClub), typeof(DreadPirateHat),
|
||||||
|
|
@ -74,7 +75,7 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
typeof(LunaLance), typeof(NightsKiss), typeof(NoxRangersHeavyCrossbow),
|
typeof(LunaLance), typeof(NightsKiss), typeof(NoxRangersHeavyCrossbow),
|
||||||
typeof(PolarBearMask), typeof(VioletCourage), typeof(HeartOfTheLion),
|
typeof(PolarBearMask), typeof(VioletCourage), typeof(HeartOfTheLion),
|
||||||
typeof(ColdBlood), typeof(AlchemistsBauble)
|
typeof(ColdBlood), typeof(AlchemistsBauble)
|
||||||
};
|
];
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public DateTime DeleteTime => _expireTimer.Next;
|
public DateTime DeleteTime => _expireTimer.Next;
|
||||||
|
|
@ -299,8 +300,9 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
|
|
||||||
if (_level == 0 && from.AccessLevel < AccessLevel.GameMaster)
|
if (_level == 0 && from.AccessLevel < AccessLevel.GameMaster)
|
||||||
{
|
{
|
||||||
foreach (var m in _guardians)
|
for (var i = 0; i < _guardians.Count; i++)
|
||||||
{
|
{
|
||||||
|
var m = _guardians[i];
|
||||||
if (m.Alive)
|
if (m.Alive)
|
||||||
{
|
{
|
||||||
// You must first kill the guardians before you may open this chest.
|
// You must first kill the guardians before you may open this chest.
|
||||||
|
|
@ -366,7 +368,7 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
|
|
||||||
if (notYetLifted)
|
if (notYetLifted)
|
||||||
{
|
{
|
||||||
_lifted ??= new HashSet<Item>();
|
_lifted ??= [];
|
||||||
_lifted.Add(item);
|
_lifted.Add(item);
|
||||||
|
|
||||||
if (Utility.RandomDouble() < 0.1) // 10% chance to spawn a new monster
|
if (Utility.RandomDouble() < 0.1) // 10% chance to spawn a new monster
|
||||||
|
|
@ -391,7 +393,7 @@ public partial class TreasureMapChest : LockableContainer
|
||||||
|
|
||||||
private void Deserialize(IGenericReader reader, int version)
|
private void Deserialize(IGenericReader reader, int version)
|
||||||
{
|
{
|
||||||
_guardians = new List<Mobile>();
|
_guardians = [];
|
||||||
|
|
||||||
_owner = reader.ReadEntity<Mobile>();
|
_owner = reader.ReadEntity<Mobile>();
|
||||||
_level = reader.ReadInt();
|
_level = reader.ReadInt();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"type": "System.Collections.Generic.List\u003CServer.Mobile\u003E",
|
"type": "System.Collections.Generic.List\u003CServer.Mobile\u003E",
|
||||||
"rule": "ListMigrationRule",
|
"rule": "ListMigrationRule",
|
||||||
"ruleArguments": [
|
"ruleArguments": [
|
||||||
|
"@Tidy",
|
||||||
"Server.Mobile",
|
"Server.Mobile",
|
||||||
"SerializableInterfaceMigrationRule"
|
"SerializableInterfaceMigrationRule"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue