mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
when the entity-server caps a lifetime of an edit from a tmp-rez only interface, bump the lastEdited time forward so that the interface accepts the change back into its local tree
This commit is contained in:
parent
fbfb6f169b
commit
c62b73bf61
1 changed files with 14 additions and 26 deletions
|
@ -130,16 +130,13 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
|||
EntityItemProperties properties = origProperties;
|
||||
|
||||
bool allowLockChange;
|
||||
bool canRezPermanentEntities;
|
||||
QUuid senderID;
|
||||
if (senderNode.isNull()) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
allowLockChange = nodeList->isAllowedEditor();
|
||||
canRezPermanentEntities = nodeList->getThisNodeCanRez();
|
||||
senderID = nodeList->getSessionUUID();
|
||||
} else {
|
||||
allowLockChange = senderNode->isAllowedEditor();
|
||||
canRezPermanentEntities = senderNode->getCanRez();
|
||||
senderID = senderNode->getUUID();
|
||||
}
|
||||
|
||||
|
@ -148,14 +145,6 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!canRezPermanentEntities) {
|
||||
// we don't allow a Node that can't create permanent entities to raise lifetimes on existing ones
|
||||
if (properties.getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME || properties.getLifetime() > _maxTmpEntityLifetime) {
|
||||
qCDebug(entities) << "Capping disallowed entity lifetime adjustment.";
|
||||
properties.setLifetime(_maxTmpEntityLifetime);
|
||||
}
|
||||
}
|
||||
|
||||
// enforce support for locked entities. If an entity is currently locked, then the only
|
||||
// property we allow you to change is the locked property.
|
||||
if (entity->getLocked()) {
|
||||
|
@ -331,17 +320,6 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool clientOnly = props.getClientOnly();
|
||||
|
||||
if (!clientOnly && getIsClient() && !nodeList->getThisNodeCanRez() && nodeList->getThisNodeCanRezTmp()) {
|
||||
// we are a client which is only allowed to rez temporary entities. cap the lifetime.
|
||||
if (props.getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME) {
|
||||
props.setLifetime(_maxTmpEntityLifetime);
|
||||
} else {
|
||||
props.setLifetime(glm::min(props.getLifetime(), _maxTmpEntityLifetime));
|
||||
}
|
||||
}
|
||||
|
||||
bool recordCreationTime = false;
|
||||
if (props.getCreated() == UNKNOWN_CREATED_TIME) {
|
||||
// the entity's creation time was not specified in properties, which means this is a NEW entity
|
||||
|
@ -876,6 +854,13 @@ void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList<Q
|
|||
QString::number((int)pos.y) + "," +
|
||||
QString::number((int)pos.z);
|
||||
}
|
||||
if (properties.lifetimeChanged()) {
|
||||
int index = changedProperties.indexOf("lifetime");
|
||||
if (index >= 0) {
|
||||
float value = properties.getLifetime();
|
||||
changedProperties[index] = QString("lifetime:") + QString::number((int)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned char* editData, int maxLength,
|
||||
|
@ -913,12 +898,15 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
entityItemID, properties);
|
||||
endDecode = usecTimestampNow();
|
||||
|
||||
const quint64 LAST_EDITED_SERVERSIDE_BUMP = 10000; // usec
|
||||
if (!senderNode->getCanRez() && senderNode->getCanRezTmp()) {
|
||||
// this node is only allowed to rez temporary entities. cap the lifetime.
|
||||
if (properties.getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME) {
|
||||
// this node is only allowed to rez temporary entities. if need be, cap the lifetime.
|
||||
if (properties.getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME ||
|
||||
properties.getLifetime() > _maxTmpEntityLifetime) {
|
||||
properties.setLifetime(_maxTmpEntityLifetime);
|
||||
} else {
|
||||
properties.setLifetime(glm::min(properties.getLifetime(), _maxTmpEntityLifetime));
|
||||
// also bump up the lastEdited time of the properties so that the interface that created this edit
|
||||
// will accept our adjustment to lifetime back into its own entity-tree.
|
||||
properties.setLastEdited(properties.getLastEdited() + LAST_EDITED_SERVERSIDE_BUMP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue