ace/Source/ACE.Server/WorldObjects/Stackable.cs
Mag-nus a9abbb574d
EncumbranceVal and Value should not be ephemeral by default (#1443)
* EncumbranceVal and Value should not be ephemeral by default

EncumbranceVal is now ephemeral only for containers

Value is now ephemeral only for non-creature containers.

This allows items to persist their EncumbranceVal and Value changes to the database.

For containers, they will retain their original (default) value from the database, load that into the ephemeral dictionary and build from there. Those changes will then be lost and reset next time the object is loaded.

* revert the program.cs change

* Use SetStackSize() to also set EncumbranceVal and Value

* Fix server status hours reported to work after 24hrs.

* comment added

* Even the base container needs to have a value if it's not a creature
2019-02-17 18:08:46 -06:00

36 lines
1.1 KiB
C#

using ACE.Database.Models.Shard;
using ACE.Database.Models.World;
using ACE.Entity;
namespace ACE.Server.WorldObjects
{
public class Stackable : WorldObject
{
/// <summary>
/// A new biota be created taking all of its values from weenie.
/// </summary>
public Stackable(Weenie weenie, ObjectGuid guid) : base(weenie, guid)
{
SetEphemeralValues();
}
/// <summary>
/// Restore a WorldObject from the database.
/// </summary>
public Stackable(Biota biota) : base(biota)
{
SetEphemeralValues();
}
private void SetEphemeralValues()
{
// This is needed to fix stackables that were created before we removed the [Ephemeral] attribute from Encumbranceval and Value
// In the distance future, this can be removed. 2019-02-13 Mag-nus
if (MaxStackSize > 1)
{
EncumbranceVal = (StackUnitEncumbrance ?? 0) * (StackSize ?? 1);
Value = (StackUnitValue ?? 0) * (StackSize ?? 1);
}
}
}
}