mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 17:00:13 +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 );
|
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 we have a local entity tree set, then also update it.
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
|
@ -41,6 +38,9 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// queue the packet
|
||||||
|
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +97,10 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E
|
||||||
// if the entity is unknown, attempt to look it up
|
// if the entity is unknown, attempt to look it up
|
||||||
if (!entityID.isKnownID) {
|
if (!entityID.isKnownID) {
|
||||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||||
}
|
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||||
|
entityID.id = actualID.id;
|
||||||
// if at this point, we know the id, send the update to the entity server
|
entityID.isKnownID = true;
|
||||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
}
|
||||||
entityID.id = actualID.id;
|
|
||||||
entityID.isKnownID = true;
|
|
||||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a local entity tree set, then also update it. We can do this even if we don't know
|
// 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->updateEntity(entityID, properties);
|
||||||
_entityTree->unlock();
|
_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;
|
return entityID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,13 +126,10 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
|
||||||
// if the entity is unknown, attempt to look it up
|
// if the entity is unknown, attempt to look it up
|
||||||
if (!entityID.isKnownID) {
|
if (!entityID.isKnownID) {
|
||||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||||
}
|
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||||
|
entityID.id = actualID.id;
|
||||||
// if at this point, we know the id, send the update to the entity server
|
entityID.isKnownID = true;
|
||||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
}
|
||||||
entityID.id = actualID.id;
|
|
||||||
entityID.isKnownID = true;
|
|
||||||
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a local entity tree set, then also update it.
|
// 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->deleteEntity(entityID);
|
||||||
_entityTree->unlock();
|
_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 {
|
EntityItemID EntityScriptingInterface::findClosestEntity(const glm::vec3& center, float radius) const {
|
||||||
|
|
Loading…
Reference in a new issue