adjust avatar-energy code to avoid editing local tree and then not telling the entity-server about it

This commit is contained in:
Seth Alves 2016-02-17 14:36:18 -08:00
parent 784dc2b538
commit af1640ac4e

View file

@ -135,9 +135,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
if (cost > _currentAvatarEnergy) {
return QUuid();
} else {
//debit the avatar energy and continue
emit debitEnergySource(cost);
}
EntityItemID id = EntityItemID(QUuid::createUuid());
@ -173,6 +170,7 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
// queue the packet
if (success) {
emit debitEnergySource(cost);
queueEntityMessage(PacketType::EntityAdd, id, propertiesWithSimID);
}
@ -284,7 +282,6 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
}
}
properties = convertLocationFromScriptSemantics(properties);
updatedEntity = _entityTree->updateEntity(entityID, properties);
float cost = calculateCost(density * volume, oldVelocity, newVelocity);
cost *= costMultiplier;
@ -293,8 +290,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
updatedEntity = false;
} else {
//debit the avatar energy and continue
updatedEntity = _entityTree->updateEntity(entityID, properties);
if (updatedEntity) {
emit debitEnergySource(cost);
}
}
});
if (!updatedEntity) {
@ -379,6 +379,7 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
cost *= costMultiplier;
if (cost > _currentAvatarEnergy) {
shouldDelete = false;
return;
} else {
//debit the avatar energy and continue