History

Fix scripts not reloading in certain edge cases

Atlante45 committed 9 years ago

Commit 20a82df1 parent bb5c6e44 files · +12 −13Browse files

Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 4 files). Show all

Unified · Split

assignment-client/src/scripts/EntityScriptServer.cpp+4−9
@@ -216,12 +216,6 @@ void EntityScriptServer::resetEntitiesScriptEngine() { · 215 unmodified lines
216216 auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor);
217217 newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
218218
219−
220−// newEngine->setEmitScriptUpdatesFunction([this]() {
221−// SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer);
222−// return !entityServerNode || isPhysicsEnabled();
223−// });
224−
225219 newEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarHashMap>().data());
226220 newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
227221
@@ -287,14 +281,15 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID · 59 unmodified lines
287281 }
288282
289283 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+
291287 EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
292− if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
288+ if (entity && (details.scriptText != entity->getServerScripts() || reload)) {
293289 QString scriptUrl = entity->getServerScripts();
294290 scriptUrl = ResourceManager::normalizeURL(scriptUrl);
295291 qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
296292 ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
297− entity->serverScriptHasPreloaded();
298293 }
299294 }
300295 }