diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index adb88147e9..eb99feca47 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1143,25 +1143,20 @@ void Application::editPreferences() { return; } - - const char* newHostname = domainServerHostname->text().toLocal8Bit().data(); - + char newHostname[MAX_HOSTNAME_BYTES] = {}; + memcpy(newHostname, domainServerHostname->text().toAscii().data(), domainServerHostname->text().size()); + // check if the domain server hostname is new - if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname, sizeof(&newHostname)) != 0) { - // if so we need to clear the nodelist and delete the local voxels - Node *voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER); - - if (voxelServer) { - voxelServer->lock(); - } - - _voxels.killLocalVoxels(); - - if (voxelServer) { - voxelServer->unlock(); - } + if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname, strlen(newHostname)) != 0) { NodeList::getInstance()->clear(); + + // kill the local voxels + _voxels.killLocalVoxels(); + + // reset the environment to default + _environment.resetToDefault(); + NodeList::getInstance()->setDomainHostname(newHostname); } @@ -3352,7 +3347,7 @@ void* Application::networkReceive(void* args) { case PACKET_TYPE_ENVIRONMENT_DATA: { if (app->_renderVoxels->isChecked()) { Node* voxelServer = NodeList::getInstance()->soloNodeOfType(NODE_TYPE_VOXEL_SERVER); - if (voxelServer) { + if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { voxelServer->lock(); if (app->_incomingPacket[0] == PACKET_TYPE_ENVIRONMENT_DATA) { diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index 35ed121e38..adfb1cfb3b 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -47,6 +47,11 @@ void Environment::init() { _data[getZeroAddress()][0]; } +void Environment::resetToDefault() { + _data.clear(); + _data[getZeroAddress()][0]; +} + void Environment::renderAtmospheres(Camera& camera) { // get the lock for the duration of the call QMutexLocker locker(&_mutex); diff --git a/interface/src/Environment.h b/interface/src/Environment.h index f711f0c38c..7bdbfa600b 100644 --- a/interface/src/Environment.h +++ b/interface/src/Environment.h @@ -24,6 +24,7 @@ class Environment { public: void init(); + void resetToDefault(); void renderAtmospheres(Camera& camera); glm::vec3 getGravity (const glm::vec3& position); diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 20eaddc738..0c8a68d38c 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -32,7 +32,7 @@ const int DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000; extern const char SOLO_NODE_TYPES[3]; -const int MAX_HOSTNAME_BYTES = 255; +const int MAX_HOSTNAME_BYTES = 256; extern const char DEFAULT_DOMAIN_HOSTNAME[MAX_HOSTNAME_BYTES]; extern const char DEFAULT_DOMAIN_IP[INET_ADDRSTRLEN]; // IP Address will be re-set by lookup on startup