mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
swap order of local vs server changes in entity scripting to improve potential conflicts
This commit is contained in:
parent
16f9d60df7
commit
25d051090a
1 changed files with 22 additions and 17 deletions
|
@ -31,9 +31,6 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
|||
|
||||
EntityItemID id(NEW_ENTITY, creatorTokenID, false );
|
||||
|
||||
// queue the packet
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||
|
||||
// If we have a local entity tree set, then also update it.
|
||||
if (_entityTree) {
|
||||
_entityTree->lockForWrite();
|
||||
|
@ -41,6 +38,9 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
|||
_entityTree->unlock();
|
||||
}
|
||||
|
||||
// queue the packet
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -97,13 +97,10 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E
|
|||
// if the entity is unknown, attempt to look it up
|
||||
if (!entityID.isKnownID) {
|
||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a local entity tree set, then also update it. We can do this even if we don't know
|
||||
|
@ -113,6 +110,12 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E
|
|||
_entityTree->updateEntity(entityID, properties);
|
||||
_entityTree->unlock();
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (entityID.isKnownID) {
|
||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
||||
}
|
||||
|
||||
return entityID;
|
||||
}
|
||||
|
||||
|
@ -123,13 +126,10 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
|
|||
// if the entity is unknown, attempt to look it up
|
||||
if (!entityID.isKnownID) {
|
||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||
entityID.id = actualID.id;
|
||||
entityID.isKnownID = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a local entity tree set, then also update it.
|
||||
|
@ -138,6 +138,11 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
|
|||
_entityTree->deleteEntity(entityID);
|
||||
_entityTree->unlock();
|
||||
}
|
||||
|
||||
// if at this point, we know the id, send the update to the entity server
|
||||
if (entityID.isKnownID) {
|
||||
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
||||
}
|
||||
}
|
||||
|
||||
EntityItemID EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||
|
|
Loading…
Reference in a new issue