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

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/application/StarMainApplication_sdl.cpp2
-rw-r--r--source/base/StarAssets.cpp12
-rw-r--r--source/base/StarAssets.hpp2
-rw-r--r--source/core/scripting/StarUtilityLuaBindings.cpp1
-rw-r--r--source/frontend/StarClientCommandProcessor.cpp6
-rw-r--r--source/frontend/StarClientCommandProcessor.hpp1
-rw-r--r--source/frontend/StarInventory.cpp7
-rw-r--r--source/game/StarPlayer.cpp2
-rw-r--r--source/game/StarRoot.cpp5
-rw-r--r--source/game/StarRoot.hpp2
-rw-r--r--source/game/StarStatusController.cpp5
11 files changed, 39 insertions, 6 deletions
diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp
index e0dfd37..c3ffbf0 100644
--- a/source/application/StarMainApplication_sdl.cpp
+++ b/source/application/StarMainApplication_sdl.cpp
@@ -522,7 +522,7 @@ private:
}
bool isFocused() const override {
- return (SDL_GetWindowFlags(parent->m_sdlWindow) & (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS)) != 0;
+ return (SDL_GetWindowFlags(parent->m_sdlWindow) & SDL_WINDOW_INPUT_FOCUS) != 0;
}
void setTargetUpdateRate(float targetUpdateRate) override {
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp
index ecd2068..7db8efe 100644
--- a/source/base/StarAssets.cpp
+++ b/source/base/StarAssets.cpp
@@ -348,6 +348,13 @@ Assets::~Assets() {
m_workerThreads.clear();
}
+void Assets::hotReload() const {
+ MutexLocker assetsLocker(m_assetsMutex);
+ m_assetsCache.clear();
+ m_queue.clear();
+ m_framesSpecifications.clear();
+}
+
StringList Assets::assetSources() const {
MutexLocker assetsLocker(m_assetsMutex);
return m_assetSources;
@@ -779,6 +786,11 @@ void Assets::workerMain() {
if (m_stopThreads)
break;
+ {
+ RecursiveMutexLocker luaLocker(m_luaMutex);
+ as<LuaEngine>(m_luaEngine.get())->collectGarbage();
+ }
+
MutexLocker assetsLocker(m_assetsMutex);
AssetId assetId;
diff --git a/source/base/StarAssets.hpp b/source/base/StarAssets.hpp
index e7b8611..6ffcb05 100644
--- a/source/base/StarAssets.hpp
+++ b/source/base/StarAssets.hpp
@@ -161,6 +161,8 @@ public:
Assets(Settings settings, StringList assetSources);
~Assets();
+ void hotReload() const;
+
// Returns a list of all the asset source paths used by Assets in load order.
StringList assetSources() const;
diff --git a/source/core/scripting/StarUtilityLuaBindings.cpp b/source/core/scripting/StarUtilityLuaBindings.cpp
index 98ad239..8fb65cc 100644
--- a/source/core/scripting/StarUtilityLuaBindings.cpp
+++ b/source/core/scripting/StarUtilityLuaBindings.cpp
@@ -120,6 +120,7 @@ LuaCallbacks LuaBindings::makeUtilityCallbacks() {
callbacks.registerCallback("replaceTags", UtilityCallbacks::replaceTags);
callbacks.registerCallback("parseJsonSequence", [](String const& json) { return Json::parseSequence(json); });
callbacks.registerCallback("jsonMerge", [](Json const& a, Json const& b) { return jsonMerge(a, b); });
+ callbacks.registerCallback("jsonEqual", [](Json const& a, Json const& b) { return a == b; });
callbacks.registerCallback("jsonQuery", [](Json const& json, String const& path, Json const& def) { return json.query(path, def); });
callbacks.registerCallback("makeRandomSource", [](Maybe<uint64_t> seed) { return seed ? RandomSource(*seed) : RandomSource(); });
callbacks.registerCallback("makePerlinSource", [](Json const& config) { return PerlinF(config); });
diff --git a/source/frontend/StarClientCommandProcessor.cpp b/source/frontend/StarClientCommandProcessor.cpp
index 7671a00..c19c68f 100644
--- a/source/frontend/StarClientCommandProcessor.cpp
+++ b/source/frontend/StarClientCommandProcessor.cpp
@@ -20,6 +20,7 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
m_paneManager(paneManager), m_macroCommands(std::move(macroCommands)) {
m_builtinCommands = {
{"reload", bind(&ClientCommandProcessor::reload, this)},
+ {"hotReload", bind(&ClientCommandProcessor::hotReload, this)},
{"whoami", bind(&ClientCommandProcessor::whoami, this)},
{"gravity", bind(&ClientCommandProcessor::gravity, this)},
{"debug", bind(&ClientCommandProcessor::debug, this, _1)},
@@ -128,6 +129,11 @@ String ClientCommandProcessor::reload() {
return "Client Star::Root reloaded";
}
+String ClientCommandProcessor::hotReload() {
+ Root::singleton().hotReload();
+ return "Hot-reloaded assets";
+}
+
String ClientCommandProcessor::whoami() {
return strf("Client: You are {}. You are {}an Admin.",
m_universeClient->mainPlayer()->name(), m_universeClient->mainPlayer()->isAdmin() ? "" : "not ");
diff --git a/source/frontend/StarClientCommandProcessor.hpp b/source/frontend/StarClientCommandProcessor.hpp
index c3978a4..df60b96 100644
--- a/source/frontend/StarClientCommandProcessor.hpp
+++ b/source/frontend/StarClientCommandProcessor.hpp
@@ -26,6 +26,7 @@ private:
String previewQuestPane(StringList const& arguments, function<PanePtr(QuestPtr)> createPane);
String reload();
+ String hotReload();
String whoami();
String gravity();
String debug(String const& argumentsString);
diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp
index 3730c9b..1c42a0d 100644
--- a/source/frontend/StarInventory.cpp
+++ b/source/frontend/StarInventory.cpp
@@ -450,12 +450,13 @@ void InventoryPane::update(float dt) {
}
if (auto item = inventory->swapSlotItem()) {
+ float pitch = 1.f - ((float)item->count() / (float)item->maxStack()) * .2f;
if (!m_currentSwapSlotItem || !item->matches(*m_currentSwapSlotItem, true))
- context->playAudio(RandomSource().randFrom(m_pickUpSounds));
+ context->playAudio(RandomSource().randFrom(m_pickUpSounds), 0, 1.f, pitch);
else if (item->count() > m_currentSwapSlotItem->count())
- context->playAudio(RandomSource().randFrom(m_someUpSounds));
+ context->playAudio(RandomSource().randFrom(m_someUpSounds), 0, 1.f, pitch);
else if (item->count() < m_currentSwapSlotItem->count())
- context->playAudio(RandomSource().randFrom(m_someDownSounds));
+ context->playAudio(RandomSource().randFrom(m_someDownSounds), 0, 1.f, pitch);
m_currentSwapSlotItem = item->descriptor();
} else {
diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp
index c094bbb..af85cce 100644
--- a/source/game/StarPlayer.cpp
+++ b/source/game/StarPlayer.cpp
@@ -1086,7 +1086,7 @@ void Player::update(float dt, uint64_t) {
}
if (calculateHeadRotation) { // master or not an OpenStarbound player
float headRotation = 0.f;
- if (m_humanoid->primaryHandHoldingItem() || m_humanoid->altHandHoldingItem() || m_humanoid->dance()) {
+ if (Humanoid::globalHeadRotation() && (m_humanoid->primaryHandHoldingItem() || m_humanoid->altHandHoldingItem() || m_humanoid->dance())) {
auto primary = m_tools->primaryHandItem();
auto alt = m_tools->altHandItem();
String const disableFlag = "disableHeadRotation";
diff --git a/source/game/StarRoot.cpp b/source/game/StarRoot.cpp
index fbf818f..e429646 100644
--- a/source/game/StarRoot.cpp
+++ b/source/game/StarRoot.cpp
@@ -371,6 +371,11 @@ void Root::registerReloadListener(ListenerWeakPtr reloadListener) {
m_reloadListeners.addListener(std::move(reloadListener));
}
+void Root::hotReload() {
+ assets()->hotReload();
+ m_reloadListeners.trigger();
+}
+
String Root::toStoragePath(String const& path) const {
return File::relativeTo(m_settings.storageDirectory, File::convertDirSeparators(path));
}
diff --git a/source/game/StarRoot.hpp b/source/game/StarRoot.hpp
index 2079a5e..4659488 100644
--- a/source/game/StarRoot.hpp
+++ b/source/game/StarRoot.hpp
@@ -131,6 +131,8 @@ public:
// the internal listener list.
void registerReloadListener(ListenerWeakPtr reloadListener);
+ void hotReload();
+
// Translates the given path to be relative to the configured storage
// location.
String toStoragePath(String const& path) const;
diff --git a/source/game/StarStatusController.cpp b/source/game/StarStatusController.cpp
index 26c83d0..d6635b6 100644
--- a/source/game/StarStatusController.cpp
+++ b/source/game/StarStatusController.cpp
@@ -132,7 +132,10 @@ Json StatusController::statusProperty(String const& name, Json const& def) const
}
void StatusController::setStatusProperty(String const& name, Json value) {
- m_statusProperties.set(name, value);
+ if (value.isNull())
+ m_statusProperties.remove(name);
+ else
+ m_statusProperties.set(name, value);
}
StringList StatusController::statNames() const {