keep track of actions we are editing and ignore updates from server for these actions

This commit is contained in:
Seth Alves 2016-05-02 14:23:36 -07:00
parent 2ef87557fc
commit ae8f502808
3 changed files with 9 additions and 1 deletions

View file

@ -54,6 +54,9 @@ public:
virtual bool lifetimeIsOver() { return false; }
virtual quint64 getExpires() { return 0; }
virtual bool isMine() { return _isMine; }
virtual void setIsMine(bool value) { _isMine = value; }
bool locallyAddedButNotYetReceived = false;
virtual bool shouldSuppressLocationEdits() { return false; }
@ -89,6 +92,7 @@ protected:
QUuid _id;
EntityActionType _type;
bool _active { false };
bool _isMine { false }; // did this interface create / edit this action?
};

View file

@ -1702,6 +1702,7 @@ bool EntityItem::updateAction(EntitySimulation* simulation, const QUuid& actionI
success = action->updateArguments(arguments);
if (success) {
action->setIsMine(true);
serializeActions(success, _allActionsDataCache);
_dirtyFlags |= Simulation::DIRTY_PHYSICS_ACTIVATION;
} else {
@ -1808,7 +1809,9 @@ void EntityItem::deserializeActionsInternal() {
EntityActionPointer action = _objectActions[actionID];
// TODO: make sure types match? there isn't currently a way to
// change the type of an existing action.
action->deserialize(serializedAction);
if (!action->isMine()) {
action->deserialize(serializedAction);
}
action->locallyAddedButNotYetReceived = false;
updated << actionID;
} else {

View file

@ -830,6 +830,7 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString,
if (!action) {
return false;
}
action->setIsMine(true);
success = entity->addAction(simulation, action);
entity->grabSimulationOwnership();
return false; // Physics will cause a packet to be sent, so don't send from here.