From 6b797e300e5b5bc7ddfcfad138cb624e9b4ad5c1 Mon Sep 17 00:00:00 2001 From: David Dormagen Date: Sat, 13 Jan 2018 15:24:08 +0100 Subject: [PATCH] inventory bar: stack count always falls back to contained object count Related to #1970 and 5fc07df7574b22a3d956c22ae1bdfadd4f70fe0f This replaces the very hacky implementation just for the dynamite with a more general solution (and e.g. also works with the grenade launcher). --- .../ControllerInventoryBar.ocd/Script.c | 10 +++++----- .../Items.ocd/Tools.ocd/Dynamite.ocd/Script.c | 12 ------------ 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c index 9c5e86e56..391fada6c 100644 --- a/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c +++ b/planet/Objects.ocd/HUD.ocd/Controller.ocd/ControllerInventoryBar.ocd/Script.c @@ -218,12 +218,12 @@ private func UpdateInventory() if (contents) { extra_symbol = contents; - // Stack count: Some contents may provide their own stack count function just for inventory display - extra_symbol_stack_count = contents->~GetContainedDisplayStackCount(); - if (!GetType(extra_symbol_stack_count)) + // Stack count: either actual stack count or stacked object count. + extra_symbol_stack_count = contents->~GetStackCount(); + if (extra_symbol_stack_count == nil) { // Stack count fallback to actually stacked objects - extra_symbol_stack_count = contents->~GetStackCount(); + extra_symbol_stack_count = item->ContentsCount(contents->GetID()); } } extra_slot_player = GetOwner(); @@ -243,7 +243,7 @@ private func UpdateInventory() var extra_text = nil, number_symbol = nil; if (extra_symbol && extra_symbol_stack_count) { - if (contents->IsInfiniteStackCount()) + if (contents->~IsInfiniteStackCount()) number_symbol = Icon_Number; else extra_text = Format("%dx", extra_symbol_stack_count); } diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c index db5fe2ab9..001b40767 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Dynamite.ocd/Script.c @@ -84,18 +84,6 @@ public func OnFuseFinished(object fuse) DoExplode(); } -// This will only when inside a dynamite box to display the remaining dynamite sticks in the HUD -public func GetContainedDisplayStackCount() -{ - if (Contained()) - { - if (Contained()->GetID() == DynamiteBox) - { - return Contained()->ContentsCount(GetID()); - } - } -} - public func IsInfiniteStackCount() { return false;