History

Allowed Editors setting in DomainServer; domain-list wire protocol includes "you can edit" boolean after uuid; entity server checks canEdit flag of node who sends edit requests; interface does not attempt to do edits if DomainServer sent false for "you can edit"

Seth Alves committed 11 years ago

Commit 485785b1 parent 35430a411 files · +80 −30Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 11 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+23−8
@@ -26,22 +26,32 @@ void EntityScriptingInterface::queueEntityMessage(PacketType packetType, · 25 unmodified lines
2626 getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
2727 }
2828
29+
30+bool EntityScriptingInterface::canEdit() {
31+ auto nodeList = DependencyManager::get<NodeList>();
32+ return nodeList->getThisNodeCanEdit();
33+}
34+
35+
2936 EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
3037
38+
3139 // The application will keep track of creatorTokenID
3240 uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID();
3341
3442 EntityItemID id(NEW_ENTITY, creatorTokenID, false );
3543
36− // If we have a local entity tree set, then also update it.
37− if (_entityTree) {
38− _entityTree->lockForWrite();
39− _entityTree->addEntity(id, properties);
40− _entityTree->unlock();
41− }
44+ if (canEdit()) {
45+ // If we have a local entity tree set, then also update it.
46+ if (_entityTree) {
47+ _entityTree->lockForWrite();
48+ _entityTree->addEntity(id, properties);
49+ _entityTree->unlock();
50+ }
4251
43− // queue the packet
44− queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
52+ // queue the packet
53+ queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
54+ }
4555
4656 return id;
4757 }
@@ -94,6 +104,11 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 46 unmodified lines
94104 }
95105
96106 EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
107+
108+ if (! canEdit()) {
109+ return entityID;
110+ }
111+
97112 EntityItemID actualID = entityID;
98113 // if the entity is unknown, attempt to look it up
99114 if (!entityID.isKnownID) {