mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
Merge pull request #17 from Atlante45/ess-pr
Fix scripts not reloading in certain edge cases
This commit is contained in:
commit
6c21339485
3 changed files with 6 additions and 14 deletions
|
@ -216,12 +216,6 @@ void EntityScriptServer::resetEntitiesScriptEngine() {
|
|||
auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor);
|
||||
newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
|
||||
|
||||
|
||||
// newEngine->setEmitScriptUpdatesFunction([this]() {
|
||||
// SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer);
|
||||
// return !entityServerNode || isPhysicsEnabled();
|
||||
// });
|
||||
|
||||
newEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarHashMap>().data());
|
||||
newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||
|
||||
|
@ -287,14 +281,16 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID
|
|||
}
|
||||
|
||||
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) {
|
||||
if (_entityViewer.getTree() && !_shuttingDown) {
|
||||
if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) {
|
||||
|
||||
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
|
||||
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
|
||||
EntityScriptDetails details;
|
||||
bool notRunning = !_entitiesScriptEngine->getEntityScriptDetails(entityID, details);
|
||||
if (entity && (reload || notRunning || details.scriptText != entity->getServerScripts())) {
|
||||
QString scriptUrl = entity->getServerScripts();
|
||||
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
||||
qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
|
||||
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
||||
entity->serverScriptHasPreloaded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,9 +444,6 @@ public:
|
|||
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
|
||||
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
|
||||
|
||||
bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedServerScripts != _serverScripts)); }
|
||||
void serverScriptHasPreloaded() { _loadedServerScripts = _serverScripts; }
|
||||
|
||||
bool getClientOnly() const { return _clientOnly; }
|
||||
void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; }
|
||||
// if this entity is client-only, which avatar is it associated with?
|
||||
|
@ -519,7 +516,6 @@ protected:
|
|||
QString _loadedScript; /// the value of _script when the last preload signal was sent
|
||||
quint64 _scriptTimestamp{ ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP }; /// the script loaded property used for forced reload
|
||||
QString _serverScripts;
|
||||
QString _loadedServerScripts;
|
||||
|
||||
/// the value of _scriptTimestamp when the last preload signal was sent
|
||||
// NOTE: on construction we want this to be different from _scriptTimestamp so we intentionally bump it
|
||||
|
|
|
@ -73,4 +73,4 @@ private:
|
|||
void forceFailureOfPendingRequests(SharedNodePointer node);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue