Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 4 files). Show all
Unified · Split
| @@ -216,12 +216,6 @@ void EntityScriptServer::resetEntitiesScriptEngine() { · 215 unmodified lines | ||
| 216 | 216 | auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor); |
| 217 | 217 | newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue); |
| 218 | 218 | |
| 219 | − | |
| 220 | −// newEngine->setEmitScriptUpdatesFunction([this]() { | |
| 221 | −// SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer); | |
| 222 | −// return !entityServerNode || isPhysicsEnabled(); | |
| 223 | −// }); | |
| 224 | − | |
| 225 | 219 | newEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarHashMap>().data()); |
| 226 | 220 | newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); |
| 227 | 221 | |
| @@ -287,14 +281,15 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID · 59 unmodified lines | ||
| 287 | 281 | } |
| 288 | 282 | |
| 289 | 283 | void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) { |
| 290 | − if (_entityViewer.getTree() && !_shuttingDown) { | |
| 284 | + if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) { | |
| 285 | + auto details = _entitiesScriptEngine->getEntityScriptDetails(entityID); | |
| 286 | + | |
| 291 | 287 | EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID); |
| 292 | − if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) { | |
| 288 | + if (entity && (details.scriptText != entity->getServerScripts() || reload)) { | |
| 293 | 289 | QString scriptUrl = entity->getServerScripts(); |
| 294 | 290 | scriptUrl = ResourceManager::normalizeURL(scriptUrl); |
| 295 | 291 | qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID; |
| 296 | 292 | ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload); |
| 297 | − entity->serverScriptHasPreloaded(); | |
| 298 | 293 | } |
| 299 | 294 | } |
| 300 | 295 | } |