fix code that causes scripted changes to physics-related entity properties to claim simulation ownership

This commit is contained in:
Seth Alves 2015-04-17 10:41:11 -07:00
parent deec577db6
commit 3da2d1680d
2 changed files with 7 additions and 11 deletions

View file

@ -170,18 +170,14 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E
// if at this point, we know the id, send the update to the entity server
if (entityID.isKnownID) {
// make sure the properties has a type, so that the encode can know which properties to include
if (properties.getType() == EntityTypes::Unknown) {
if (propertiesWithSimID.getType() == EntityTypes::Unknown) {
EntityItem* entity = _entityTree->findEntityByEntityItemID(entityID);
if (entity) {
EntityItemProperties tempProperties = properties;
tempProperties.setType(entity->getType());
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, tempProperties);
return entityID;
propertiesWithSimID.setType(entity->getType());
}
}
// if the properties already includes the type, then use it as is
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, propertiesWithSimID);
}
return entityID;

View file

@ -139,9 +139,9 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro
properties.getSimulatorID() != entity->getSimulatorID()) {
// A Node is trying to take ownership of the simulation of this entity from another Node. Only allow this
// if ownership hasn't recently changed.
quint64 now = usecTimestampNow();
if (now - entity->getSimulatorIDChangedTime() < SIMULATOR_CHANGE_LOCKOUT_PERIOD) {
qDebug() << "SIMULATOR_CHANGE_LOCKOUT_PERIOD";
if (usecTimestampNow() - entity->getSimulatorIDChangedTime() < SIMULATOR_CHANGE_LOCKOUT_PERIOD) {
qCDebug(entities) << "simulator_change_lockout_period:"
<< entity->getSimulatorID() << "to" << properties.getSimulatorID();
// squash the physics-related changes.
properties.setSimulatorIDChanged(false);
properties.setPositionChanged(false);