mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-25 07:42:30 +02:00
use dedicated bool rather than unreliable dirtyFlags to determine if the entityItem had ever bid for simulation ownership
This commit is contained in:
parent
1a36d9a698
commit
3608998877
2 changed files with 19 additions and 3 deletions
|
@ -688,8 +688,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
|||
somethingChanged = true;
|
||||
_simulationOwner.clearCurrentOwner();
|
||||
}
|
||||
} else if (newSimOwner.matchesValidID(myNodeID) && !(_dirtyFlags & Simulation::DIRTY_SIMULATION_OWNERSHIP_FOR_POKE)
|
||||
&& !(_dirtyFlags & Simulation::DIRTY_SIMULATION_OWNERSHIP_FOR_GRAB)) {
|
||||
} else if (newSimOwner.matchesValidID(myNodeID) && !_hasBidOnSimulation) {
|
||||
// entity-server tells us that we have simulation ownership while we never requested this for this EntityItem,
|
||||
// this could happen when the user reloads the cache and entity tree.
|
||||
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
|
||||
|
@ -1279,6 +1278,7 @@ void EntityItem::pokeSimulationOwnership() {
|
|||
// we don't own it yet
|
||||
_simulationOwner.setPendingPriority(SCRIPT_POKE_SIMULATION_PRIORITY, usecTimestampNow());
|
||||
}
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
void EntityItem::grabSimulationOwnership() {
|
||||
|
@ -1291,6 +1291,7 @@ void EntityItem::grabSimulationOwnership() {
|
|||
// we don't own it yet
|
||||
_simulationOwner.setPendingPriority(SCRIPT_GRAB_SIMULATION_PRIORITY, usecTimestampNow());
|
||||
}
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
bool EntityItem::setProperties(const EntityItemProperties& properties) {
|
||||
|
@ -1861,6 +1862,7 @@ void EntityItem::setSimulationOwner(const QUuid& id, quint8 priority) {
|
|||
qCDebug(entities) << "sim ownership for" << getDebugName() << "is now" << id << priority;
|
||||
}
|
||||
_simulationOwner.set(id, priority);
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
void EntityItem::setSimulationOwner(const SimulationOwner& owner) {
|
||||
|
@ -1869,6 +1871,7 @@ void EntityItem::setSimulationOwner(const SimulationOwner& owner) {
|
|||
}
|
||||
|
||||
_simulationOwner.set(owner);
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
void EntityItem::updateSimulationOwner(const SimulationOwner& owner) {
|
||||
|
@ -1879,6 +1882,7 @@ void EntityItem::updateSimulationOwner(const SimulationOwner& owner) {
|
|||
if (_simulationOwner.set(owner)) {
|
||||
_dirtyFlags |= Simulation::DIRTY_SIMULATOR_ID;
|
||||
}
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
void EntityItem::clearSimulationOwnership() {
|
||||
|
@ -1895,6 +1899,7 @@ void EntityItem::clearSimulationOwnership() {
|
|||
|
||||
void EntityItem::setPendingOwnershipPriority(quint8 priority, const quint64& timestamp) {
|
||||
_simulationOwner.setPendingPriority(priority, timestamp);
|
||||
checkForFirstSimulationBid(_simulationOwner);
|
||||
}
|
||||
|
||||
QString EntityItem::actionsToDebugString() {
|
||||
|
@ -2152,6 +2157,12 @@ void EntityItem::setActionDataInternal(QByteArray actionData) {
|
|||
checkWaitingToRemove();
|
||||
}
|
||||
|
||||
void EntityItem::checkForFirstSimulationBid(const SimulationOwner& simulationOwner) const {
|
||||
if (!_hasBidOnSimulation && simulationOwner.matchesValidID(DependencyManager::get<NodeList>()->getSessionUUID())) {
|
||||
_hasBidOnSimulation = true;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityItem::serializeActions(bool& success, QByteArray& result) const {
|
||||
if (_objectActions.size() == 0) {
|
||||
success = true;
|
||||
|
|
|
@ -478,6 +478,8 @@ protected:
|
|||
const QByteArray getActionDataInternal() const;
|
||||
void setActionDataInternal(QByteArray actionData);
|
||||
|
||||
void checkForFirstSimulationBid(const SimulationOwner& simulationOwner) const;
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
virtual void dimensionsChanged() override;
|
||||
|
||||
|
@ -586,6 +588,9 @@ protected:
|
|||
static quint64 _rememberDeletedActionTime;
|
||||
mutable QHash<QUuid, quint64> _previouslyDeletedActions;
|
||||
|
||||
// per entity keep state if it ever bid on simulation, so that we can ignore false simulation ownership
|
||||
mutable bool _hasBidOnSimulation = false;
|
||||
|
||||
QUuid _sourceUUID; /// the server node UUID we came from
|
||||
|
||||
bool _clientOnly { false };
|
||||
|
@ -594,7 +599,7 @@ protected:
|
|||
// physics related changes from the network to suppress any duplicates and make
|
||||
// sure redundant applications are idempotent
|
||||
glm::vec3 _lastUpdatedPositionValue;
|
||||
glm::quat _lastUpdatedRotationValue;
|
||||
glm::quat _lastUpdatedRotationValue;
|
||||
glm::vec3 _lastUpdatedVelocityValue;
|
||||
glm::vec3 _lastUpdatedAngularVelocityValue;
|
||||
glm::vec3 _lastUpdatedAccelerationValue;
|
||||
|
|
Loading…
Reference in a new issue