mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:56:50 +02:00
Merge pull request #17 from Atlante45/ess-pr
Fix scripts not reloading in certain edge cases
This commit is contained in:
commit
6c21339485
3 changed files with 6 additions and 14 deletions
|
@ -216,12 +216,6 @@ void EntityScriptServer::resetEntitiesScriptEngine() {
|
||||||
auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor);
|
auto webSocketServerConstructorValue = newEngine->newFunction(WebSocketServerClass::constructor);
|
||||||
newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
|
newEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
|
||||||
|
|
||||||
|
|
||||||
// newEngine->setEmitScriptUpdatesFunction([this]() {
|
|
||||||
// SharedNodePointer entityServerNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::EntityServer);
|
|
||||||
// return !entityServerNode || isPhysicsEnabled();
|
|
||||||
// });
|
|
||||||
|
|
||||||
newEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarHashMap>().data());
|
newEngine->registerGlobalObject("AvatarList", DependencyManager::get<AvatarHashMap>().data());
|
||||||
newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
newEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data());
|
||||||
|
|
||||||
|
@ -287,14 +281,16 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) {
|
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) {
|
||||||
if (_entityViewer.getTree() && !_shuttingDown) {
|
if (_entityViewer.getTree() && !_shuttingDown && _entitiesScriptEngine) {
|
||||||
|
|
||||||
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
|
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
|
||||||
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
|
EntityScriptDetails details;
|
||||||
|
bool notRunning = !_entitiesScriptEngine->getEntityScriptDetails(entityID, details);
|
||||||
|
if (entity && (reload || notRunning || details.scriptText != entity->getServerScripts())) {
|
||||||
QString scriptUrl = entity->getServerScripts();
|
QString scriptUrl = entity->getServerScripts();
|
||||||
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
|
||||||
qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
|
qDebug() << "Loading entity server script" << scriptUrl << "for" << entityID;
|
||||||
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
|
||||||
entity->serverScriptHasPreloaded();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,9 +444,6 @@ public:
|
||||||
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
|
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
|
||||||
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
|
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
|
||||||
|
|
||||||
bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedServerScripts != _serverScripts)); }
|
|
||||||
void serverScriptHasPreloaded() { _loadedServerScripts = _serverScripts; }
|
|
||||||
|
|
||||||
bool getClientOnly() const { return _clientOnly; }
|
bool getClientOnly() const { return _clientOnly; }
|
||||||
void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; }
|
void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; }
|
||||||
// if this entity is client-only, which avatar is it associated with?
|
// if this entity is client-only, which avatar is it associated with?
|
||||||
|
@ -519,7 +516,6 @@ protected:
|
||||||
QString _loadedScript; /// the value of _script when the last preload signal was sent
|
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
|
quint64 _scriptTimestamp{ ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP }; /// the script loaded property used for forced reload
|
||||||
QString _serverScripts;
|
QString _serverScripts;
|
||||||
QString _loadedServerScripts;
|
|
||||||
|
|
||||||
/// the value of _scriptTimestamp when the last preload signal was sent
|
/// 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
|
// NOTE: on construction we want this to be different from _scriptTimestamp so we intentionally bump it
|
||||||
|
|
|
@ -73,4 +73,4 @@ private:
|
||||||
void forceFailureOfPendingRequests(SharedNodePointer node);
|
void forceFailureOfPendingRequests(SharedNodePointer node);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue