fix: Fixes plants crashing on older clients (#1243)
This commit is contained in:
parent
ed8f2438fd
commit
d494a9c78c
2 changed files with 37 additions and 55 deletions
|
|
@ -57,7 +57,7 @@ namespace Server.Engines.Plants
|
|||
public PlantSystem PlantSystem { get; private set; }
|
||||
|
||||
public ObjectPropertyList OldClientPropertyList =>
|
||||
_oldClientPropertyList ??= InitializePropertyList(_oldClientPropertyList);
|
||||
_oldClientPropertyList ??= InitializePropertyList(new ObjectPropertyList(this));
|
||||
|
||||
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
||||
|
||||
|
|
@ -202,22 +202,13 @@ namespace Server.Engines.Plants
|
|||
|
||||
public int GetLocalizedPlantStatus()
|
||||
{
|
||||
if (m_PlantStatus >= PlantStatus.Plant)
|
||||
return m_PlantStatus switch
|
||||
{
|
||||
return 1060812; // plant
|
||||
}
|
||||
|
||||
if (m_PlantStatus >= PlantStatus.Sapling)
|
||||
{
|
||||
return 1023305; // sapling
|
||||
}
|
||||
|
||||
if (m_PlantStatus >= PlantStatus.Seed)
|
||||
{
|
||||
return 1060810; // seed
|
||||
}
|
||||
|
||||
return 1026951; // dirt
|
||||
>= PlantStatus.Plant => 1060812, // plant
|
||||
>= PlantStatus.Sapling => 1023305, // sapling
|
||||
>= PlantStatus.Seed => 1060810, // seed
|
||||
_ => 1026951 // dirt
|
||||
};
|
||||
}
|
||||
|
||||
public int GetLocalizedContainerType() => 1150435;
|
||||
|
|
@ -292,29 +283,31 @@ namespace Server.Engines.Plants
|
|||
|
||||
public override void InvalidateProperties()
|
||||
{
|
||||
base.InvalidateProperties();
|
||||
|
||||
if (!ObjectPropertyList.Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.InvalidateProperties();
|
||||
|
||||
if (Map != null && Map != Map.Internal && !World.Loading)
|
||||
{
|
||||
int? oldHash = _oldClientPropertyList?.Hash;
|
||||
|
||||
if (oldHash != null)
|
||||
int? oldHash;
|
||||
int newHash;
|
||||
if (_oldClientPropertyList != null)
|
||||
{
|
||||
oldHash = _oldClientPropertyList.Hash;
|
||||
_oldClientPropertyList.Reset();
|
||||
InitializePropertyList(_oldClientPropertyList);
|
||||
newHash = _oldClientPropertyList.Hash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_oldClientPropertyList = new ObjectPropertyList(this);
|
||||
oldHash = null;
|
||||
newHash = OldClientPropertyList.Hash;
|
||||
}
|
||||
|
||||
InitializePropertyList(_oldClientPropertyList);
|
||||
|
||||
if (oldHash != _oldClientPropertyList.Hash)
|
||||
if (oldHash != newHash)
|
||||
{
|
||||
Delta(ItemDelta.Properties);
|
||||
}
|
||||
|
|
@ -359,6 +352,15 @@ namespace Server.Engines.Plants
|
|||
return;
|
||||
}
|
||||
|
||||
var typeInfo = PlantTypeInfo.GetInfo(m_PlantType);
|
||||
var hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
|
||||
|
||||
if (m_PlantStatus >= PlantStatus.DecorativePlant)
|
||||
{
|
||||
list.Add(typeInfo.GetPlantLabelDecorative(hueInfo), $"{hueInfo.Name:#}\t{typeInfo.Name:#}");
|
||||
return;
|
||||
}
|
||||
|
||||
var container = GetLocalizedContainerType();
|
||||
var dirt = PlantSystem.GetLocalizedDirtStatus();
|
||||
var health = PlantSystem.GetLocalizedHealth();
|
||||
|
|
@ -367,7 +369,7 @@ namespace Server.Engines.Plants
|
|||
if (m_PlantStatus < PlantStatus.Seed)
|
||||
{
|
||||
// Clients above 7.0.12.0 use the regular PropertyList
|
||||
if (list != _oldClientPropertyList)
|
||||
if (list != OldClientPropertyList)
|
||||
{
|
||||
// a ~1_val~ of ~2_val~ dirt
|
||||
list.Add(1060830, $"{container:#}\t{dirt:#}");
|
||||
|
|
@ -381,15 +383,6 @@ namespace Server.Engines.Plants
|
|||
return;
|
||||
}
|
||||
|
||||
var typeInfo = PlantTypeInfo.GetInfo(m_PlantType);
|
||||
var hueInfo = PlantHueInfo.GetInfo(m_PlantHue);
|
||||
|
||||
if (m_PlantStatus >= PlantStatus.DecorativePlant)
|
||||
{
|
||||
list.Add(typeInfo.GetPlantLabelDecorative(hueInfo), $"{hueInfo.Name:#}\t{typeInfo.Name:#}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_PlantStatus >= PlantStatus.FullGrownPlant)
|
||||
{
|
||||
list.Add(
|
||||
|
|
@ -430,7 +423,7 @@ namespace Server.Engines.Plants
|
|||
}
|
||||
else
|
||||
{
|
||||
list.Add(plantNumber,$"{dirt:#}\t{health:#}\t{category:#}\t{plantStatus:#}");
|
||||
list.Add(plantNumber, $"{dirt:#}\t{health:#}\t{category:#}\t{plantStatus:#}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -315,25 +315,14 @@ namespace Server.Engines.Plants
|
|||
m_LeftResources = 8;
|
||||
}
|
||||
|
||||
public int GetLocalizedDirtStatus()
|
||||
{
|
||||
if (Water <= 1)
|
||||
public int GetLocalizedDirtStatus() =>
|
||||
Water switch
|
||||
{
|
||||
return 1060826; // hard
|
||||
}
|
||||
|
||||
if (Water <= 2)
|
||||
{
|
||||
return 1060827; // soft
|
||||
}
|
||||
|
||||
if (Water <= 3)
|
||||
{
|
||||
return 1060828; // squishy
|
||||
}
|
||||
|
||||
return 1060829; // sopping wet
|
||||
}
|
||||
<= 1 => 1060826, // hard
|
||||
<= 2 => 1060827, // soft
|
||||
<= 3 => 1060828, // squishy
|
||||
_ => 1060829 // sappy wet
|
||||
};
|
||||
|
||||
public int GetLocalizedHealth()
|
||||
{
|
||||
|
|
@ -342,7 +331,7 @@ namespace Server.Engines.Plants
|
|||
PlantHealth.Dying => 1060825, // dying
|
||||
PlantHealth.Wilted => 1060824, // wilted
|
||||
PlantHealth.Healthy => 1060823, // healthy
|
||||
_ => 1060822
|
||||
_ => 1060822 // vibrant
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue