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
26 getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);26 getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
27}27}
28 28
29
30bool EntityScriptingInterface::canEdit() {
31 auto nodeList = DependencyManager::get<NodeList>();
32 return nodeList->getThisNodeCanEdit();
33}
34
35
29EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {36EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& properties) {
30 37
38
31 // The application will keep track of creatorTokenID39 // The application will keep track of creatorTokenID
32 uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID();40 uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID();
33 41
34 EntityItemID id(NEW_ENTITY, creatorTokenID, false );42 EntityItemID id(NEW_ENTITY, creatorTokenID, false );
35 43
36 // If we have a local entity tree set, then also update it.44 if (canEdit()) {
37 if (_entityTree) {45 // If we have a local entity tree set, then also update it.
38 _entityTree->lockForWrite();46 if (_entityTree) {
39 _entityTree->addEntity(id, properties);47 _entityTree->lockForWrite();
40 _entityTree->unlock();48 _entityTree->addEntity(id, properties);
41 }49 _entityTree->unlock();
50 }
42 51
43 // queue the packet52 // queue the packet
44 queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);53 queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
54 }
45 55
46 return id;56 return id;
47}57}
@@ -94,6 +104,11 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID · 46 unmodified lines
94}104}
95 105
96EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {106EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
107
108 if (! canEdit()) {
109 return entityID;
110 }
111
97 EntityItemID actualID = entityID;112 EntityItemID actualID = entityID;
98 // if the entity is unknown, attempt to look it up113 // if the entity is unknown, attempt to look it up
99 if (!entityID.isKnownID) {114 if (!entityID.isKnownID) {