Skip to content

Commit

Permalink
fix: fluid clamp (#1698)
Browse files Browse the repository at this point in the history
Previous PR did some math on fluids that didn't work when dropping
splashes, this fixes it to be more deterministic.
  • Loading branch information
luan authored Oct 13, 2023
1 parent a9198d2 commit 5c4b79d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/items/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ Item::Item(const uint16_t itemId, uint16_t itemCount /*= 0*/) :
const ItemType &it = items[id];
auto itemCharges = it.charges;
if (it.isFluidContainer() || it.isSplash()) {
setAttribute(ItemAttribute_t::FLUIDTYPE, itemCount * (itemCount < sizeof(Fluids_t)));
auto fluidType = std::clamp<uint16_t>(itemCount, 1, FLUID_INK);
setAttribute(ItemAttribute_t::FLUIDTYPE, fluidType);
} else if (it.stackable) {
if (itemCount != 0) {
setItemCount(static_cast<uint8_t>(itemCount));
Expand Down

0 comments on commit 5c4b79d

Please sign in to comment.