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

summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2025-01-25 10:42:15 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2025-01-25 10:42:15 +1100
commita7aa6679397563b144c016ef8712bf438cfa63df (patch)
tree8c102cbb52ed32a19e6a9005cf1752c9572fdbfd /source
parent93b78ec8e80b404346ee3b4781f98a4d9342863f (diff)
Fix callbacks not being updated properly in chat scripts
Diffstat (limited to 'source')
-rw-r--r--source/client/StarClientApplication.cpp8
-rw-r--r--source/game/StarUniverseClient.cpp9
-rw-r--r--source/game/StarUniverseClient.hpp3
3 files changed, 12 insertions, 8 deletions
diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp
index 40287b6..908d0da 100644
--- a/source/client/StarClientApplication.cpp
+++ b/source/client/StarClientApplication.cpp
@@ -19,6 +19,8 @@
#include "StarCurve25519.hpp"
#include "StarInterpolation.hpp"
+#include "StarTeamClientLuaBindings.hpp"
+#include "StarCelestialLuaBindings.hpp"
#include "StarInterfaceLuaBindings.hpp"
#include "StarInputLuaBindings.hpp"
#include "StarVoiceLuaBindings.hpp"
@@ -726,12 +728,16 @@ void ClientApplication::changeState(MainAppState newState) {
m_titleScreen->stopMusic();
+ m_universeClient->restartLua();
m_mainInterface = make_shared<MainInterface>(m_universeClient, m_worldPainter, m_cinematicOverlay);
m_universeClient->setLuaCallbacks("interface", LuaBindings::makeInterfaceCallbacks(m_mainInterface.get()));
m_universeClient->setLuaCallbacks("chat", LuaBindings::makeChatCallbacks(m_mainInterface.get(), m_universeClient.get()));
+ m_universeClient->setLuaCallbacks("celestial", LuaBindings::makeCelestialCallbacks(m_universeClient.get()));
+ m_universeClient->setLuaCallbacks("team", LuaBindings::makeTeamClientCallbacks(m_universeClient->teamClient().get()));
+ m_universeClient->setLuaCallbacks("world", LuaBindings::makeWorldCallbacks(m_universeClient->worldClient().get()));
m_mainInterface->displayDefaultPanes();
+ m_universeClient->startLuaScripts();
- m_universeClient->startLua();
m_mainMixer->setWorldPainter(m_worldPainter);
if (auto renderer = Application::renderer()) {
diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp
index 75d1dbf..12d72ee 100644
--- a/source/game/StarUniverseClient.cpp
+++ b/source/game/StarUniverseClient.cpp
@@ -23,8 +23,6 @@
#include "StarQuestManager.hpp"
#include "StarPlayerUniverseMap.hpp"
#include "StarWorldTemplate.hpp"
-#include "StarCelestialLuaBindings.hpp"
-#include "StarTeamClientLuaBindings.hpp"
namespace Star {
@@ -497,12 +495,11 @@ void UniverseClient::setLuaCallbacks(String const& groupName, LuaCallbacks const
m_luaRoot->addCallbacks(groupName, callbacks);
}
-void UniverseClient::startLua() {
+void UniverseClient::restartLua() {
m_luaRoot->restart();
- setLuaCallbacks("celestial", LuaBindings::makeCelestialCallbacks(this));
- setLuaCallbacks("team", LuaBindings::makeTeamClientCallbacks(m_teamClient.get()));
- setLuaCallbacks("world", LuaBindings::makeWorldCallbacks(m_worldClient.get()));
+}
+void UniverseClient::startLuaScripts() {
auto assets = Root::singleton().assets();
for (auto& p : assets->json("/client.config:universeScriptContexts").toObject()) {
auto scriptComponent = make_shared<ScriptComponent>();
diff --git a/source/game/StarUniverseClient.hpp b/source/game/StarUniverseClient.hpp
index b951e25..b770b07 100644
--- a/source/game/StarUniverseClient.hpp
+++ b/source/game/StarUniverseClient.hpp
@@ -87,7 +87,8 @@ public:
uint16_t maxPlayers();
void setLuaCallbacks(String const& groupName, LuaCallbacks const& callbacks);
- void startLua();
+ void restartLua();
+ void startLuaScripts();
void stopLua();
LuaRootPtr luaRoot();