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..d4b62e74de 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() && ((_loadedServerScripts != _serverScripts)); } + void serverScriptHasPreloaded() { _loadedServerScripts = _serverScripts; } 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