fix(accounting): Fixes NPE when joining faction due to codegen (#658)

This commit is contained in:
Kamron Batman 2021-07-12 00:03:46 -07:00 committed by GitHub
parent f8820e581a
commit 1de0b656a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,12 +61,32 @@ namespace Server.Accounting
[SerializableField(9, "private", "private")]
private Mobile[] _mobiles;
[SerializableField(10, setter: "private")]
private List<AccountComment> _comments;
[SerializableField(11, setter: "private")]
[SerializableField(10)]
public List<AccountComment> Comments
{
get => _comments ??= new List<AccountComment>();
private set
{
_comments = value;
((ISerializable)this).MarkDirty();
}
}
private List<AccountTag> _tags;
[SerializableField(11)]
public List<AccountTag> Tags
{
get => _tags ??= new List<AccountTag>();
private set
{
_tags = value;
((ISerializable)this).MarkDirty();
}
}
[SerializableField(12)]
private IPAddress[] _loginIPs;
@ -293,12 +313,12 @@ namespace Server.Accounting
[AfterDeserialization]
private void AfterDeserialization()
{
if (_comments.Count == 0)
if (_comments?.Count == 0)
{
_comments = null;
}
if (_tags.Count == 0)
if (_tags?.Count == 0)
{
_tags = null;
}
@ -656,7 +676,7 @@ namespace Server.Accounting
/// <param name="value">New tag value.</param>
public void AddTag(string name, string value)
{
_tags.Add(new AccountTag(name, value));
Tags.Add(new AccountTag(name, value));
((ISerializable)this).MarkDirty();
}
@ -677,7 +697,7 @@ namespace Server.Accounting
if (tag.Name == name)
{
_tags.RemoveAt(i);
_tags?.RemoveAt(i);
((ISerializable)this).MarkDirty();
}
}
@ -690,7 +710,7 @@ namespace Server.Accounting
/// <param name="value">Tag value.</param>
public void SetTag(string name, string value)
{
for (var i = 0; i < _tags.Count; ++i)
for (var i = 0; i < Tags.Count; ++i)
{
var tag = _tags[i];
@ -711,7 +731,7 @@ namespace Server.Accounting
/// <param name="name">Name of the desired tag value.</param>
public string GetTag(string name)
{
for (var i = 0; i < _tags.Count; ++i)
for (var i = 0; i < Tags.Count; ++i)
{
var tag = _tags[i];