mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 22:39:18 +02:00
don't apply out of order edits to entities that have been deleted
This commit is contained in:
parent
9c29ba2ca3
commit
2f3cf82202
4 changed files with 48 additions and 9 deletions
|
@ -500,6 +500,15 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// before proceeding, check to see if this is an entity that we know has been deleted, which
|
||||||
|
// might happen in the case of out-of-order and/or recorvered packets, if we've deleted the entity
|
||||||
|
// we can confidently ignore this packet
|
||||||
|
EntityTreePointer tree = getTree();
|
||||||
|
if (tree && tree->isDeletedEntity(_id)) {
|
||||||
|
qDebug() << "Recieved packet for previously deleted entity [" << _id << "] ignoring. (inside " << __FUNCTION__ << ")";
|
||||||
|
ignoreServerPacket = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (ignoreServerPacket) {
|
if (ignoreServerPacket) {
|
||||||
overwriteLocalData = false;
|
overwriteLocalData = false;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
|
|
|
@ -68,6 +68,7 @@ void EntityTree::eraseAllOctreeElements(bool createNewRoot) {
|
||||||
Octree::eraseAllOctreeElements(createNewRoot);
|
Octree::eraseAllOctreeElements(createNewRoot);
|
||||||
|
|
||||||
resetClientEditStats();
|
resetClientEditStats();
|
||||||
|
clearDeletedEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityTree::handlesEditPacketType(PacketType packetType) const {
|
bool EntityTree::handlesEditPacketType(PacketType packetType) const {
|
||||||
|
@ -398,6 +399,9 @@ void EntityTree::processRemovedEntities(const DeleteEntityOperator& theOperator)
|
||||||
// set up the deleted entities ID
|
// set up the deleted entities ID
|
||||||
QWriteLocker locker(&_recentlyDeletedEntitiesLock);
|
QWriteLocker locker(&_recentlyDeletedEntitiesLock);
|
||||||
_recentlyDeletedEntityItemIDs.insert(deletedAt, theEntity->getEntityItemID());
|
_recentlyDeletedEntityItemIDs.insert(deletedAt, theEntity->getEntityItemID());
|
||||||
|
} else {
|
||||||
|
// on the client side, we also remember that we deleted this entity, we don't care about the time
|
||||||
|
trackDeletedEntity(theEntity->getEntityItemID());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_simulation) {
|
if (_simulation) {
|
||||||
|
|
|
@ -228,6 +228,11 @@ public:
|
||||||
|
|
||||||
EntityTreePointer getThisPointer() { return std::static_pointer_cast<EntityTree>(shared_from_this()); }
|
EntityTreePointer getThisPointer() { return std::static_pointer_cast<EntityTree>(shared_from_this()); }
|
||||||
|
|
||||||
|
bool isDeletedEntity(const QUuid& id) {
|
||||||
|
QReadLocker locker(&_deletedEntitiesLock);
|
||||||
|
return _deletedEntityItemIDs.contains(id);
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deletingEntity(const EntityItemID& entityID);
|
void deletingEntity(const EntityItemID& entityID);
|
||||||
void addingEntity(const EntityItemID& entityID);
|
void addingEntity(const EntityItemID& entityID);
|
||||||
|
@ -235,7 +240,7 @@ signals:
|
||||||
void newCollisionSoundURL(const QUrl& url);
|
void newCollisionSoundURL(const QUrl& url);
|
||||||
void clearingEntities();
|
void clearingEntities();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
void processRemovedEntities(const DeleteEntityOperator& theOperator);
|
void processRemovedEntities(const DeleteEntityOperator& theOperator);
|
||||||
bool updateEntityWithElement(EntityItemPointer entity, const EntityItemProperties& properties,
|
bool updateEntityWithElement(EntityItemPointer entity, const EntityItemProperties& properties,
|
||||||
|
@ -252,8 +257,22 @@ private:
|
||||||
QReadWriteLock _newlyCreatedHooksLock;
|
QReadWriteLock _newlyCreatedHooksLock;
|
||||||
QVector<NewlyCreatedEntityHook*> _newlyCreatedHooks;
|
QVector<NewlyCreatedEntityHook*> _newlyCreatedHooks;
|
||||||
|
|
||||||
mutable QReadWriteLock _recentlyDeletedEntitiesLock;
|
mutable QReadWriteLock _recentlyDeletedEntitiesLock; /// lock of server side recent deletes
|
||||||
QMultiMap<quint64, QUuid> _recentlyDeletedEntityItemIDs;
|
QMultiMap<quint64, QUuid> _recentlyDeletedEntityItemIDs; /// server side recent deletes
|
||||||
|
|
||||||
|
mutable QReadWriteLock _deletedEntitiesLock; /// lock of client side recent deletes
|
||||||
|
QSet<QUuid> _deletedEntityItemIDs; /// client side recent deletes
|
||||||
|
|
||||||
|
void clearDeletedEntities() {
|
||||||
|
QWriteLocker locker(&_deletedEntitiesLock);
|
||||||
|
_deletedEntityItemIDs.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void trackDeletedEntity(const QUuid& id) {
|
||||||
|
QWriteLocker locker(&_deletedEntitiesLock);
|
||||||
|
_deletedEntityItemIDs << id;
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemFBXService* _fbxService;
|
EntityItemFBXService* _fbxService;
|
||||||
|
|
||||||
QHash<EntityItemID, EntityTreeElementPointer> _entityToElementMap;
|
QHash<EntityItemID, EntityTreeElementPointer> _entityToElementMap;
|
||||||
|
|
|
@ -894,12 +894,19 @@ int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int
|
||||||
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
entityItem = EntityTypes::constructEntityItem(dataAt, bytesLeftToRead, args);
|
||||||
if (entityItem) {
|
if (entityItem) {
|
||||||
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
bytesForThisEntity = entityItem->readEntityDataFromBuffer(dataAt, bytesLeftToRead, args);
|
||||||
addEntityItem(entityItem); // add this new entity to this elements entities
|
|
||||||
entityItemID = entityItem->getEntityItemID();
|
// don't add if we've recently deleted....
|
||||||
_myTree->setContainingElement(entityItemID, getThisPointer());
|
if (!_myTree->isDeletedEntity(entityItem->getID())) {
|
||||||
_myTree->postAddEntity(entityItem);
|
addEntityItem(entityItem); // add this new entity to this elements entities
|
||||||
if (entityItem->getCreated() == UNKNOWN_CREATED_TIME) {
|
entityItemID = entityItem->getEntityItemID();
|
||||||
entityItem->recordCreationTime();
|
_myTree->setContainingElement(entityItemID, getThisPointer());
|
||||||
|
_myTree->postAddEntity(entityItem);
|
||||||
|
if (entityItem->getCreated() == UNKNOWN_CREATED_TIME) {
|
||||||
|
entityItem->recordCreationTime();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Recieved packet for previously deleted entity [" <<
|
||||||
|
entityItem->getID() << "] ignoring. (inside " << __FUNCTION__ << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue