Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 3 files). Show all
Unified · Split
| @@ -112,7 +112,6 @@ void EntityScriptServer::handleReloadEntityServerScriptPacket(QSharedPointer<Rec · 111 unmodified lines | ||
| 112 | 112 | |
| 113 | 113 | if (_entityViewer.getTree() && !_shuttingDown) { |
| 114 | 114 | qCDebug(entity_script_server) << "Reloading: " << entityID; |
| 115 | − _entitiesScriptEngine->unloadEntityScript(entityID); | |
| 116 | 115 | checkAndCallPreload(entityID, true); |
| 117 | 116 | } |
| 118 | 117 | } |
| @@ -184,7 +183,6 @@ void EntityScriptServer::updateEntityPPS() { · 65 unmodified lines | ||
| 184 | 183 | pps = std::min(_maxEntityPPS, pps); |
| 185 | 184 | } |
| 186 | 185 | _entityEditSender.setPacketsPerSecond(pps); |
| 187 | − qDebug() << QString("Updating entity PPS to: %1 @ %2 PPS per script = %3 PPS").arg(numRunningScripts).arg(_entityPPSPerScript).arg(pps); | |
| 188 | 186 | } |
| 189 | 187 | |
| 190 | 188 | void EntityScriptServer::handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) { |
| @@ -525,23 +523,25 @@ void EntityScriptServer::deletingEntity(const EntityItemID& entityID) { · 334 unmodified lines | ||
| 525 | 523 | |
| 526 | 524 | void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID, bool reload) { |
| 527 | 525 | if (_entityViewer.getTree() && !_shuttingDown) { |
| 528 | − _entitiesScriptEngine->unloadEntityScript(entityID, true); | |
| 529 | 526 | checkAndCallPreload(entityID, reload); |
| 530 | 527 | } |
| 531 | 528 | } |
| 532 | 529 | |
| 533 | −void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool reload) { | |
| 530 | +void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool forceRedownload) { | |
| 534 | 531 | if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) { |
| 535 | 532 | |
| 536 | 533 | EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID); |
| 537 | 534 | EntityScriptDetails details; |
| 538 | − bool notRunning = !_entitiesScriptEngine->getEntityScriptDetails(entityID, details); | |
| 539 | − if (entity && (reload || notRunning || details.scriptText != entity->getServerScripts())) { | |
| 535 | + bool isRunning = _entitiesScriptEngine->getEntityScriptDetails(entityID, details); | |
| 536 | + if (entity && (forceRedownload || !isRunning || details.scriptText != entity->getServerScripts())) { | |
| 537 | + if (isRunning) { | |
| 538 | + _entitiesScriptEngine->unloadEntityScript(entityID, true); | |
| 539 | + } | |
| 540 | + | |
| 540 | 541 | QString scriptUrl = entity->getServerScripts(); |
| 541 | 542 | if (!scriptUrl.isEmpty()) { |
| 542 | 543 | scriptUrl = DependencyManager::get<ResourceManager>()->normalizeURL(scriptUrl); |
| 543 | − qCDebug(entity_script_server) << "Loading entity server script" << scriptUrl << "for" << entityID; | |
| 544 | − _entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, reload); | |
| 544 | + _entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, forceRedownload); | |
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } |