Merge pull request #12 from Atlante45/ess-pr

Fix server script preload funcitons
This commit is contained in:
Stephen Birarda 2017-01-18 16:44:07 -08:00 committed by GitHub
commit fe2a5d6059
2 changed files with 5 additions and 5 deletions

View file

@ -243,11 +243,11 @@ void EntityScriptServer::entityServerScriptChanging(const EntityItemID& entityID
void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const bool reload) {
if (_entityViewer.getTree() && !_shuttingDown) {
EntityItemPointer entity = _entityViewer.getTree()->findEntityByEntityItemID(entityID);
if (entity && entity->shouldPreloadScript() && _entitiesScriptEngine) {
if (entity && entity->shouldPreloadServerScript() && _entitiesScriptEngine) {
QString scriptUrl = entity->getServerScripts();
scriptUrl = ResourceManager::normalizeURL(scriptUrl);
ScriptEngine::loadEntityScript(_entitiesScriptEngine, entityID, scriptUrl, reload);
entity->scriptHasPreloaded();
entity->serverScriptHasPreloaded();
}
}
}

View file

@ -444,9 +444,8 @@ public:
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
void scriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
bool shouldPreloadServerScript() const { return !_script.isEmpty() &&
((_loadedScript != _script) || (_loadedScriptTimestamp != _scriptTimestamp)); }
void serverScriptHasPreloaded() { _loadedScript = _script; _loadedScriptTimestamp = _scriptTimestamp; }
bool shouldPreloadServerScript() const { return !_serverScripts.isEmpty() && ((_loadedServerScripts != _serverScripts)); }
void serverScriptHasPreloaded() { _loadedServerScripts = _serverScripts; }
bool getClientOnly() const { return _clientOnly; }
void setClientOnly(bool clientOnly) { _clientOnly = clientOnly; }
@ -520,6 +519,7 @@ protected:
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
QString _serverScripts;
QString _loadedServerScripts;
/// 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