Skip to content

Commit

Permalink
fix: Fixes loot with zero amount (#1666)
Browse files Browse the repository at this point in the history
### Summary

* Adds logging if Amount goes to zero. It should never go to zero!
* Deletes an item if it mutates with zero amount.
* Eliminates possible allocation from `params` for `Type[][]` loot pack construction.
* Renames `Loot.ChestOfHeirloomsContains` to `Loot.RandomChestOfHeirloomsContent`.
  • Loading branch information
kamronbatman authored Jan 30, 2024
1 parent 64a8d6c commit 3f00f6d
Show file tree
Hide file tree
Showing 4 changed files with 509 additions and 553 deletions.
11 changes: 11 additions & 0 deletions Projects/Server/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,17 @@ public int Amount

m_Amount = value;

if (m_Amount <= 0)
{
logger.Error(
new Exception("Item.Amount <= 0 error"),
"Item {Type} ({Serial}) was changed to amount of {Amount}, but must be at least 1",
GetType(),
Serial,
m_Amount
);
}

var newPileWeight = PileWeight;

UpdateTotal(this, TotalType.Weight, newPileWeight - oldPileWeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public ChestOfHeirlooms() : base(0x2811)

for (var i = 0; i < 10; ++i)
{
var item = Loot.ChestOfHeirloomsContains();
var item = Loot.RandomChestOfHeirloomsContent();

var attributeCount = Utility.RandomMinMax(1, 5);
var min = 20;
Expand Down
Loading

0 comments on commit 3f00f6d

Please sign in to comment.