mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:36:41 +02:00
avoid: add an action, immediately receive an update to that entities action, delete the just-added action because it wasn't in the packet
This commit is contained in:
parent
f2ebba9863
commit
e90b156b7b
2 changed files with 11 additions and 2 deletions
|
@ -48,6 +48,8 @@ public:
|
||||||
|
|
||||||
virtual bool lifetimeIsOver() { return false; }
|
virtual bool lifetimeIsOver() { return false; }
|
||||||
|
|
||||||
|
bool locallyAddedButNotYetReceived = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual glm::vec3 getPosition() = 0;
|
virtual glm::vec3 getPosition() = 0;
|
||||||
virtual void setPosition(glm::vec3 position) = 0;
|
virtual void setPosition(glm::vec3 position) = 0;
|
||||||
|
|
|
@ -1506,6 +1506,8 @@ bool EntityItem::addAction(EntitySimulation* simulation, EntityActionPointer act
|
||||||
result = addActionInternal(simulation, action);
|
result = addActionInternal(simulation, action);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
removeActionInternal(action->getID());
|
removeActionInternal(action->getID());
|
||||||
|
} else {
|
||||||
|
action->locallyAddedButNotYetReceived = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1665,6 +1667,7 @@ void EntityItem::deserializeActionsInternal() {
|
||||||
EntityItemPointer entity = shared_from_this();
|
EntityItemPointer entity = shared_from_this();
|
||||||
EntityActionPointer action = actionFactory->factoryBA(entity, serializedAction);
|
EntityActionPointer action = actionFactory->factoryBA(entity, serializedAction);
|
||||||
if (action) {
|
if (action) {
|
||||||
|
action->locallyAddedButNotYetReceived = false;
|
||||||
entity->addActionInternal(simulation, action);
|
entity->addActionInternal(simulation, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1675,8 +1678,12 @@ void EntityItem::deserializeActionsInternal() {
|
||||||
while (i != _objectActions.end()) {
|
while (i != _objectActions.end()) {
|
||||||
QUuid id = i.key();
|
QUuid id = i.key();
|
||||||
if (!updated.contains(id)) {
|
if (!updated.contains(id)) {
|
||||||
_actionsToRemove << id;
|
EntityActionPointer action = i.value();
|
||||||
_previouslyDeletedActions.insert(id, now);
|
// if we've just added this action, don't remove it due to lack of mention in an incoming packet.
|
||||||
|
if (! action->locallyAddedButNotYetReceived) {
|
||||||
|
_actionsToRemove << id;
|
||||||
|
_previouslyDeletedActions.insert(id, now);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue