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>
This commit is contained in:
parent
df171926bb
commit
fbf8497c59
1 changed files with 8 additions and 2 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue