mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge pull request #4707 from sethalves/dont-rez-if-no-rez-rights
don't create entities in local tree if the entity-serer isn't going to accept them.
This commit is contained in:
commit
086abe8468
2 changed files with 21 additions and 4 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include "LightEntityItem.h"
|
#include "LightEntityItem.h"
|
||||||
#include "ModelEntityItem.h"
|
#include "ModelEntityItem.h"
|
||||||
#include "ZoneEntityItem.h"
|
#include "ZoneEntityItem.h"
|
||||||
|
#include "EntitiesLogging.h"
|
||||||
|
|
||||||
|
|
||||||
EntityScriptingInterface::EntityScriptingInterface() :
|
EntityScriptingInterface::EntityScriptingInterface() :
|
||||||
|
@ -78,19 +79,27 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
||||||
|
|
||||||
EntityItemProperties propertiesWithSimID = properties;
|
EntityItemProperties propertiesWithSimID = properties;
|
||||||
|
|
||||||
EntityItemID id(NEW_ENTITY, creatorTokenID, false );
|
EntityItemID id(NEW_ENTITY, creatorTokenID, false);
|
||||||
|
|
||||||
// If we have a local entity tree set, then also update it.
|
// If we have a local entity tree set, then also update it.
|
||||||
|
bool success = true;
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID);
|
EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID);
|
||||||
// This Node is creating a new object. If it's in motion, set this Node as the simulator.
|
if (entity) {
|
||||||
setSimId(propertiesWithSimID, entity);
|
// This Node is creating a new object. If it's in motion, set this Node as the simulator.
|
||||||
|
setSimId(propertiesWithSimID, entity);
|
||||||
|
} else {
|
||||||
|
qCDebug(entities) << "script failed to add new Entity to local Octree";
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// queue the packet
|
// queue the packet
|
||||||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, propertiesWithSimID);
|
if (success) {
|
||||||
|
queueEntityMessage(PacketTypeEntityAddOrEdit, id, propertiesWithSimID);
|
||||||
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,14 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
|
||||||
EntityItem* EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItem* EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
EntityItem* result = NULL;
|
EntityItem* result = NULL;
|
||||||
|
|
||||||
|
if (getIsClient()) {
|
||||||
|
// if our Node isn't allowed to create entities in this domain, don't try.
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
if (!nodeList->getThisNodeCanRez()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: This method is used in the client and the server tree. In the client, it's possible to create EntityItems
|
// NOTE: This method is used in the client and the server tree. In the client, it's possible to create EntityItems
|
||||||
// that do not yet have known IDs. In the server tree however we don't want to have entities without known IDs.
|
// that do not yet have known IDs. In the server tree however we don't want to have entities without known IDs.
|
||||||
bool recordCreationTime = false;
|
bool recordCreationTime = false;
|
||||||
|
|
Loading…
Reference in a new issue