From 8cbb262c248e9c681a771a9e0d0849a3af0ab77c Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 2 May 2024 11:56:59 +1000 Subject: [PATCH] fix directives stitching bug when parsing scale --- .../opensb/interface/chat/chat.config.patch | 2 +- source/game/StarHumanoid.cpp | 19 ++++++++++++------- source/game/StarPlayerInventory.cpp | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/assets/opensb/interface/chat/chat.config.patch b/assets/opensb/interface/chat/chat.config.patch index bed2aa7..54f1b28 100644 --- a/assets/opensb/interface/chat/chat.config.patch +++ b/assets/opensb/interface/chat/chat.config.patch @@ -7,7 +7,7 @@ "colors" : { "local" : "^white;", "party" : "^blue;", - "broadcast" : "^yellow;", + "broadcast" : "^#fe6;", "whisper" : "^pink;", "commandResult" : "^lightgray;", "radioMessage" : "^cyan;", diff --git a/source/game/StarHumanoid.cpp b/source/game/StarHumanoid.cpp index 0b33ba4..1367a30 100644 --- a/source/game/StarHumanoid.cpp +++ b/source/game/StarHumanoid.cpp @@ -1387,8 +1387,8 @@ pair Humanoid::extractScaleFromDirectives(Directives const& d if (!directives) return make_pair(Vec2F::filled(1.f), Directives()); - List operations; - size_t totalLength = 0; + List entries; + size_t toReserve = 0; Maybe scale; for (auto& entry : directives->entries) { @@ -1399,17 +1399,22 @@ pair Humanoid::extractScaleFromDirectives(Directives const& d if (op) scale = scale.value(Vec2F::filled(1.f)).piecewiseMultiply(op->scale); - else - totalLength += operations.emplace_back(string).utf8Size(); + else { + entries.emplace_back(entry); + toReserve += string.utf8Size() + 1; + } } if (!scale) return make_pair(Vec2F::filled(1.f), directives); String mergedDirectives; - mergedDirectives.reserve(totalLength); - for (auto& directive : operations) - mergedDirectives.append(directive.utf8Ptr(), directive.utf8Size()); + mergedDirectives.reserve(toReserve); + for (auto& entry : entries) { + if (entry->begin > 0) + mergedDirectives.append('?'); + mergedDirectives.append(entry->string(*directives)); + } return make_pair(*scale, Directives(mergedDirectives)); } diff --git a/source/game/StarPlayerInventory.cpp b/source/game/StarPlayerInventory.cpp index 0fbcd66..0d74e05 100644 --- a/source/game/StarPlayerInventory.cpp +++ b/source/game/StarPlayerInventory.cpp @@ -447,7 +447,7 @@ ItemBagConstPtr PlayerInventory::bagContents(String const& type) const { return m_bags.get(type); } -void PlayerInventory::condenseBagStacks(String const& bagType) {\ +void PlayerInventory::condenseBagStacks(String const& bagType) { auto bag = m_bags[bagType]; bag->condenseStacks();