From 79aa450332015ab3858082e315060e2832ffb726 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 6 Mar 2018 13:11:09 -0800 Subject: [PATCH] some code-review induced changes --- interface/src/Application.cpp | 22 +++++++++++-------- libraries/networking/src/AddressManager.cpp | 5 +++-- .../networking/src/NetworkingConstants.cpp | 2 -- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0cabea07f9..1a5ceec34c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3129,21 +3129,17 @@ void Application::loadServerlessDomain(QUrl domainURL) { return; } + auto nodeList = DependencyManager::get(); clearDomainOctreeDetails(); + getMyAvatar()->setSessionUUID(QUuid()); // clear the sessionID + NodePermissions permissions; // deny all permissions + permissions.setAll(false); + nodeList->setPermissions(permissions); if (domainURL.isEmpty()) { return; } - QUuid serverlessSessionID = QUuid::createUuid(); - getMyAvatar()->setSessionUUID(serverlessSessionID); - DependencyManager::get()->setSessionUUID(serverlessSessionID); - - // there is no domain-server to tell us our permissions, so enable all - NodePermissions permissions; - permissions.setAll(true); - DependencyManager::get()->setPermissions(permissions); - // we can't import directly into the main tree because we would need to lock it, and // Octree::readFromURL calls loop.exec which can run code which will also attempt to lock the tree. EntityTreePointer tmpTree(new EntityTree()); @@ -3153,6 +3149,14 @@ void Application::loadServerlessDomain(QUrl domainURL) { tmpTree->setMyAvatar(myAvatar); bool success = tmpTree->readFromURL(domainURL.toString()); if (success) { + QUuid serverlessSessionID = QUuid::createUuid(); + getMyAvatar()->setSessionUUID(serverlessSessionID); + nodeList->setSessionUUID(serverlessSessionID); + + // there is no domain-server to tell us our permissions, so enable all + permissions.setAll(true); + nodeList->setPermissions(permissions); + tmpTree->reaverageOctreeElements(); tmpTree->sendEntities(&_entityEditSender, getEntities()->getTree(), 0, 0, 0); } diff --git a/libraries/networking/src/AddressManager.cpp b/libraries/networking/src/AddressManager.cpp index 49a166224c..5a89d222b7 100644 --- a/libraries/networking/src/AddressManager.cpp +++ b/libraries/networking/src/AddressManager.cpp @@ -309,9 +309,10 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) { bool isPossiblePlaceName(QString possiblePlaceName) { bool result { false }; int length = possiblePlaceName.length(); - static const int MINIMUM_PLACENAME_LENGTH = 4; + static const int MINIMUM_PLACENAME_LENGTH = 2; static const int MAXIMUM_PLACENAME_LENGTH = 64; - if (possiblePlaceName != "localhost" && length >= MINIMUM_PLACENAME_LENGTH && length <= MAXIMUM_PLACENAME_LENGTH) { + if (possiblePlaceName.toLower() != "localhost" && + length >= MINIMUM_PLACENAME_LENGTH && length <= MAXIMUM_PLACENAME_LENGTH) { const QRegExp PLACE_NAME_REGEX = QRegExp("^[0-9A-Za-z](([0-9A-Za-z]|-(?!-))*[^\\W_]$|$)"); result = PLACE_NAME_REGEX.indexIn(possiblePlaceName) == 0; } diff --git a/libraries/networking/src/NetworkingConstants.cpp b/libraries/networking/src/NetworkingConstants.cpp index 6b8e03493b..bc1167a42e 100644 --- a/libraries/networking/src/NetworkingConstants.cpp +++ b/libraries/networking/src/NetworkingConstants.cpp @@ -9,8 +9,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include "NetworkingConstants.h"