Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-05-02 11:56:59 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-05-02 11:56:59 +1000
commit8cbb262c248e9c681a771a9e0d0849a3af0ab77c (patch)
treed7746cd735363f534e55fe58fb4cff51fbbb6d54
parent789597dde49bf8ce6e374ea9afd00dd7295e21ce (diff)
fix directives stitching bug when parsing scale
-rw-r--r--assets/opensb/interface/chat/chat.config.patch2
-rw-r--r--source/game/StarHumanoid.cpp19
-rw-r--r--source/game/StarPlayerInventory.cpp2
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<Vec2F, Directives> Humanoid::extractScaleFromDirectives(Directives const& d
if (!directives)
return make_pair(Vec2F::filled(1.f), Directives());
- List<StringView> operations;
- size_t totalLength = 0;
+ List<Directives::Entry*> entries;
+ size_t toReserve = 0;
Maybe<Vec2F> scale;
for (auto& entry : directives->entries) {
@@ -1399,17 +1399,22 @@ pair<Vec2F, Directives> 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();