From e94cccf08d65f707f2e19ce5a88852ead814f5a0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 18 Jan 2017 15:57:55 -0800 Subject: [PATCH 1/2] Fix server script preload funcitons --- assignment-client/src/scripts/EntityScriptServer.cpp | 4 ++-- libraries/entities/src/EntityItem.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/scripts/EntityScriptServer.cpp b/assignment-client/src/scripts/EntityScriptServer.cpp index fb5afd5a0d..fba375aeef 100644 --- a/assignment-client/src/scripts/EntityScriptServer.cpp +++ b/assignment-client/src/scripts/EntityScriptServer.cpp @@ -243,11 +243,11 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) { if (_entityViewer.getTree() && !_shuttingDown) { EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID); - if (entity && entity->shouldPreloadScript() && _entitiesScriptEngine) { + if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) { QString scriptUrl = entity->getServerScripts(); scriptUrl = ResourceManager::normalizeURL(scriptUrl); ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload); - entity->scriptHasPreloaded(); + entity->serverScriptHasPreloaded(); } } } diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 60afe38662..8ea0df1f1a 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -444,9 +444,8 @@ public: ((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); } void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; } - bool shouldPreloadServerScript() const { return !_script.isEmpty() && - ((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); } - void serverScriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; } + bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedScript != _script)); } + void serverScriptHasPreloaded() { _loadedScript = _script; } bool getClientOnly() const { return _clientOnly; } void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; } @@ -520,6 +519,7 @@ 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 From cbc69fbf9e768fd47cf91d68b0c4051f9cef5165 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Wed, 18 Jan 2017 16:37:01 -0800 Subject: [PATCH 2/2] Fix script preload functions --- libraries/entities/src/EntityItem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 8ea0df1f1a..d4b62e74de 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -444,8 +444,8 @@ public: ((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); } void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; } - bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedScript != _script)); } - void serverScriptHasPreloaded() { _loadedScript = _script; } + bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedServerScripts != _serverScripts)); } + void serverScriptHasPreloaded() { _loadedServerScripts = _serverScripts; } bool getClientOnly() const { return _clientOnly; } void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; }