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

summaryrefslogtreecommitdiff
path: root/source/base
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-21 00:59:41 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-21 00:59:41 +1000
commitbd783d319557b41b5865d51f306a74abbf7af18c (patch)
tree5acefc369e7cbc42a1226efb0c28efb9a3d6830e /source/base
parent9b75bd8eb280eb108d9eeef7a17c083a883155c7 (diff)
make the chat really pretty!!
also slightly optimized text shadow rendering, made sure glyphs with directives stay centered and added two extra Lua arguments to canvas.drawText
Diffstat (limited to 'source/base')
-rw-r--r--source/base/StarAssets.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp
index 5066268..aab4468 100644
--- a/source/base/StarAssets.cpp
+++ b/source/base/StarAssets.cpp
@@ -827,29 +827,36 @@ Json Assets::readJson(String const& path) const {
Json result = inputUtf8Json(streamData.begin(), streamData.end(), false);
for (auto const& pair : m_files.get(path).patchSources) {
auto patchStream = pair.second->read(pair.first);
- auto patchData = inputUtf8Json(patchStream.begin(), patchStream.end(), false).toArray();
- try {
- if (patchData.size()) {
- if (patchData.at(0).type() == Json::Type::Array) {
- for (auto const& patch : patchData) {
+ auto patchJson = inputUtf8Json(patchStream.begin(), patchStream.end(), false);
+ if (patchJson.isType(Json::Type::Array)) {
+ auto patchData = patchJson.toArray();
+ try {
+ if (patchData.size()) {
+ if (patchData.at(0).type() == Json::Type::Array) {
+ for (auto const& patch : patchData) {
+ try {
+ result = jsonPatch(result, patch.toArray());
+ } catch (JsonPatchTestFail const& e) {
+ Logger::debug("Patch test failure from file %s in source: %s. Caused by: %s", pair.first, m_assetSourcePaths.getLeft(pair.second), e.what());
+ }
+ }
+ } else if (patchData.at(0).type() == Json::Type::Object) {
try {
- result = jsonPatch(result, patch.toArray());
+ result = jsonPatch(result, patchData);
} catch (JsonPatchTestFail const& e) {
Logger::debug("Patch test failure from file %s in source: %s. Caused by: %s", pair.first, m_assetSourcePaths.getLeft(pair.second), e.what());
}
+ } else {
+ throw JsonPatchException(strf("Patch data is wrong type: %s", Json::typeName(patchData.at(0).type())));
}
- } else if (patchData.at(0).type() == Json::Type::Object) {
- try {
- result = jsonPatch(result, patchData);
- } catch (JsonPatchTestFail const& e) {
- Logger::debug("Patch test failure from file %s in source: %s. Caused by: %s", pair.first, m_assetSourcePaths.getLeft(pair.second), e.what());
- }
- } else {
- throw JsonPatchException(strf("Patch data is wrong type: %s", Json::typeName(patchData.at(0).type())));
}
+ } catch (JsonPatchException const& e) {
+ Logger::error("Could not apply patch from file %s in source: %s. Caused by: %s", pair.first, m_assetSourcePaths.getLeft(pair.second), e.what());
}
- } catch (JsonPatchException const& e) {
- Logger::error("Could not apply patch from file %s in source: %s. Caused by: %s", pair.first, m_assetSourcePaths.getLeft(pair.second), e.what());
+ }
+ else if (patchJson.isType(Json::Type::Object)) { //Kae: Do a good ol' json merge instead if the .patch file is a Json object
+ auto patchData = patchJson.toObject();
+ result = jsonMerge(result, patchData);
}
}
return result;