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:
Seth Alves 2015-10-01 17:02:02 -07:00
parent f2ebba9863
commit e90b156b7b
2 changed files with 11 additions and 2 deletions

View file

@ -48,6 +48,8 @@ public:
virtual bool lifetimeIsOver() { return false; }
bool locallyAddedButNotYetReceived = false;
protected:
virtual glm::vec3 getPosition() = 0;
virtual void setPosition(glm::vec3 position) = 0;

View file

@ -1506,6 +1506,8 @@ bool EntityItem::addAction(EntitySimulation* simulation, EntityActionPointer act
result = addActionInternal(simulation, action);
if (!result) {
removeActionInternal(action->getID());
} else {
action->locallyAddedButNotYetReceived = true;
}
});
@ -1665,6 +1667,7 @@ void EntityItem::deserializeActionsInternal() {
EntityItemPointer entity = shared_from_this();
EntityActionPointer action = actionFactory->factoryBA(entity, serializedAction);
if (action) {
action->locallyAddedButNotYetReceived = false;
entity->addActionInternal(simulation, action);
}
}
@ -1675,8 +1678,12 @@ void EntityItem::deserializeActionsInternal() {
while (i != _objectActions.end()) {
QUuid id = i.key();
if (!updated.contains(id)) {
_actionsToRemove << id;
_previouslyDeletedActions.insert(id, now);
EntityActionPointer action = i.value();
// 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++;
}