mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:28:09 +02:00
Fix reload mechanic for entity server scripts
This commit is contained in:
parent
75c1bdbf0d
commit
283dabc622
3 changed files with 10 additions and 10 deletions
|
@ -112,7 +112,6 @@ void EntityScriptServer::handleReloadEntityServerScriptPacket(QSharedPointer<Rec
|
||||||
|
|
||||||
if (_entityViewer.getTree() && !_shuttingDown) {
|
if (_entityViewer.getTree() && !_shuttingDown) {
|
||||||
qCDebug(entity_script_server) << "Reloading: " << entityID;
|
qCDebug(entity_script_server) << "Reloading: " << entityID;
|
||||||
_entitiesScriptEngine->unloadEntityScript(entityID);
|
|
||||||
checkAndCallPreload(entityID, true);
|
checkAndCallPreload(entityID, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +183,6 @@ void EntityScriptServer::updateEntityPPS() {
|
||||||
pps = std::min(_maxEntityPPS, pps);
|
pps = std::min(_maxEntityPPS, pps);
|
||||||
}
|
}
|
||||||
_entityEditSender.setPacketsPerSecond(pps);
|
_entityEditSender.setPacketsPerSecond(pps);
|
||||||
qDebug() << QString("Updating entity PPS to: %1 @ %2 PPS per script = %3 PPS").arg(numRunningScripts).arg(_entityPPSPerScript).arg(pps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityScriptServer::handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
void EntityScriptServer::handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
||||||
|
@ -525,23 +523,25 @@ void EntityScriptServer::deletingEntity(const EntityItemID& entityID) {
|
||||||
|
|
||||||
void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID, bool reload) {
|
void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID, bool reload) {
|
||||||
if (_entityViewer.getTree() && !_shuttingDown) {
|
if (_entityViewer.getTree() && !_shuttingDown) {
|
||||||
_entitiesScriptEngine->unloadEntityScript(entityID, true);
|
|
||||||
checkAndCallPreload(entityID, reload);
|
checkAndCallPreload(entityID, reload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool reload) {
|
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool forceRedownload) {
|
||||||
if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) {
|
if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) {
|
||||||
|
|
||||||
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
|
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
|
||||||
EntityScriptDetails details;
|
EntityScriptDetails details;
|
||||||
bool notRunning = !_entitiesScriptEngine->getEntityScriptDetails(entityID, details);
|
bool isRunning = _entitiesScriptEngine->getEntityScriptDetails(entityID, details);
|
||||||
if (entity && (reload || notRunning || details.scriptText != entity->getServerScripts())) {
|
if (entity && (forceRedownload || !isRunning || details.scriptText != entity->getServerScripts())) {
|
||||||
|
if (isRunning) {
|
||||||
|
_entitiesScriptEngine->unloadEntityScript(entityID, true);
|
||||||
|
}
|
||||||
|
|
||||||
QString scriptUrl = entity->getServerScripts();
|
QString scriptUrl = entity->getServerScripts();
|
||||||
if (!scriptUrl.isEmpty()) {
|
if (!scriptUrl.isEmpty()) {
|
||||||
scriptUrl = DependencyManager::get<ResourceManager>()->normalizeURL(scriptUrl);
|
scriptUrl = DependencyManager::get<ResourceManager>()->normalizeURL(scriptUrl);
|
||||||
qCDebug(entity_script_server) << "Loading entity server script" << scriptUrl << "for" << entityID;
|
_entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, forceRedownload);
|
||||||
_entitiesScriptEngine->loadEntityScript(entityID, scriptUrl, reload);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ private:
|
||||||
void addingEntity(const EntityItemID& entityID);
|
void addingEntity(const EntityItemID& entityID);
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void entityServerScriptChanging(const EntityItemID& entityID, bool reload);
|
void entityServerScriptChanging(const EntityItemID& entityID, bool reload);
|
||||||
void checkAndCallPreload(const EntityItemID& entityID, bool reload = false);
|
void checkAndCallPreload(const EntityItemID& entityID, bool forceRedownload = false);
|
||||||
|
|
||||||
void cleanupOldKilledListeners();
|
void cleanupOldKilledListeners();
|
||||||
|
|
||||||
|
|
|
@ -1048,7 +1048,7 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool
|
||||||
QString scriptUrl = entity->getScript();
|
QString scriptUrl = entity->getScript();
|
||||||
if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) {
|
if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) {
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
_entitiesScriptEngine->unloadEntityScript(entityID);
|
_entitiesScriptEngine->unloadEntityScript(entityID);
|
||||||
}
|
}
|
||||||
entity->scriptHasUnloaded();
|
entity->scriptHasUnloaded();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue