From fbf8497c59c63e633b7c118803c76c313773a692 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 00:53:47 -0700 Subject: [PATCH] fix: Fix PlantSystem serialization of LeftSeeds and LeftResources at zero (#2255) * Initial plan * Add SerializableFieldDefault attributes for LeftSeeds and LeftResources This fixes the serialization bug where _leftSeeds and _leftResources were initialized to 8 in the constructor but didn't serialize when their value was 0. Upon deserialization, the constructor would run again and reset these values back to 8. The SerializableFieldDefault attributes tell the serialization system that the default value is 8, so it will properly serialize 0 values and maintain the correct state across server restarts. Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com> * Update ShouldSerialize methods to check against default value Changed ShouldSerializeLeftSeeds() and ShouldSerializeLeftResources() to check if the value is != 8 (the default) instead of != 0. This ensures that only non-default values are serialized, following the same pattern used in BaseWeapon.cs and other classes with SerializableFieldDefault attributes. Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kamronbatman <3953314+kamronbatman@users.noreply.github.com> --- Projects/UOContent/Engines/Plants/PlantSystem.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Projects/UOContent/Engines/Plants/PlantSystem.cs b/Projects/UOContent/Engines/Plants/PlantSystem.cs index 61d017c0f..cbbd0cb9c 100644 --- a/Projects/UOContent/Engines/Plants/PlantSystem.cs +++ b/Projects/UOContent/Engines/Plants/PlantSystem.cs @@ -320,7 +320,10 @@ namespace Server.Engines.Plants } [SerializableFieldSaveFlag(17)] - private bool ShouldSerializeLeftSeeds() => _leftSeeds != 0; + private bool ShouldSerializeLeftSeeds() => _leftSeeds != 8; + + [SerializableFieldDefault(17)] + private int LeftSeedsDefaultValue() => 8; [SerializableProperty(18)] public int AvailableResources @@ -340,7 +343,10 @@ namespace Server.Engines.Plants } [SerializableFieldSaveFlag(19)] - private bool ShouldSerializeLeftResources() => _leftResources != 0; + private bool ShouldSerializeLeftResources() => _leftResources != 8; + + [SerializableFieldDefault(19)] + private int LeftResourcesDefaultValue() => 8; public void Reset(bool potions) {