mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 19:04:32 +02:00
fix crash for dereference null pointer
This commit is contained in:
parent
44d3074561
commit
40f6ecd936
5 changed files with 21 additions and 18 deletions
|
@ -78,10 +78,10 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
// This Node is creating a new object. If it's in motion, set this Node as the simulator.
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
propertiesWithSimID.setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATOR_PRIORITY);
|
||||
propertiesWithSimID.setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||
|
||||
// and make note of it now, so we can act on it right away.
|
||||
entity->setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATOR_PRIORITY);
|
||||
entity->setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
} else {
|
||||
|
@ -163,10 +163,10 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties proper
|
|||
|
||||
// we re-assert our simulation ownership
|
||||
properties.setSimulationOwner(myNodeID,
|
||||
glm::max(entity->getSimulatorPriority(), SCRIPT_EDIT_SIMULATOR_PRIORITY));
|
||||
glm::max(entity->getSimulatorPriority(), SCRIPT_EDIT_SIMULATION_PRIORITY));
|
||||
} else {
|
||||
// we make a bid for simulation ownership
|
||||
properties.setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATOR_PRIORITY);
|
||||
properties.setSimulationOwner(myNodeID, SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||
entity->flagForOwnership();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ void SimulationOwner::clear() {
|
|||
|
||||
void SimulationOwner::setPriority(quint8 priority) {
|
||||
_priority = priority;
|
||||
if (_priority == MAX_SIMULATOR_PRIORITY) {
|
||||
// we extend the the expiry whenever we set MAX_SIMULATOR_PRIORITY
|
||||
if (_priority == MAX_SIMULATION_PRIORITY) {
|
||||
// we extend the the expiry whenever we set MAX_SIMULATION_PRIORITY
|
||||
updateExpiry();
|
||||
} else if (_priority == 0) {
|
||||
// when priority is zero we clear everything
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
|
||||
const quint8 VOLUNTEER_SIMULATOR_PRIORITY = 0x01;
|
||||
const quint8 SCRIPT_EDIT_SIMULATOR_PRIORITY = 0x80;
|
||||
const quint8 MAX_SIMULATOR_PRIORITY = 0xff;
|
||||
const quint8 ATTACHMENT_SIMULATOR_PRIORITY = MAX_SIMULATOR_PRIORITY;
|
||||
const quint8 VOLUNTEER_SIMULATION_PRIORITY = 0x01;
|
||||
const quint8 PERSONAL_SIMULATION_PRIORITY = 0x7f;
|
||||
const quint8 SCRIPT_EDIT_SIMULATION_PRIORITY = 0x80;
|
||||
const quint8 MAX_SIMULATION_PRIORITY = 0xff;
|
||||
const quint8 ATTACHMENT_SIMULATION_PRIORITY = MAX_SIMULATION_PRIORITY;
|
||||
|
||||
class SimulationOwner {
|
||||
public:
|
||||
|
|
|
@ -121,7 +121,7 @@ void EntityMotionState::handleEasyChanges(uint32_t flags, PhysicsEngine* engine)
|
|||
// also known as "bid for ownership with SCRIPT priority"
|
||||
// we're manipulating this object directly via script, so we artificially
|
||||
// manipulate the logic to trigger an immediate bid for ownership
|
||||
setOutgoingPriority(SCRIPT_EDIT_SIMULATOR_PRIORITY);
|
||||
setOutgoingPriority(SCRIPT_EDIT_SIMULATION_PRIORITY);
|
||||
}
|
||||
if ((flags & EntityItem::DIRTY_PHYSICS_ACTIVATION) && !_body->isActive()) {
|
||||
_body->activate();
|
||||
|
@ -201,7 +201,7 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
|
|||
|
||||
if (_loopsWithoutOwner > LOOPS_FOR_SIMULATION_ORPHAN && usecTimestampNow() > _nextOwnershipBid) {
|
||||
//qDebug() << "Warning -- claiming something I saw moving." << getName();
|
||||
setOutgoingPriority(VOLUNTEER_SIMULATOR_PRIORITY);
|
||||
setOutgoingPriority(VOLUNTEER_SIMULATION_PRIORITY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q
|
|||
}
|
||||
} else {
|
||||
// we don't own the simulation for this entity yet, but we're sending a bid for it
|
||||
properties.setSimulationOwner(sessionID, glm::max<uint8_t>(_outgoingPriority, VOLUNTEER_SIMULATOR_PRIORITY));
|
||||
properties.setSimulationOwner(sessionID, glm::max<uint8_t>(_outgoingPriority, VOLUNTEER_SIMULATION_PRIORITY));
|
||||
_nextOwnershipBid = now + USECS_BETWEEN_OWNERSHIP_BIDS;
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ QUuid EntityMotionState::getSimulatorID() const {
|
|||
void EntityMotionState::bump(uint8_t priority) {
|
||||
if (_entity) {
|
||||
//uint8_t inheritedPriority = priority < 2 ? 1 : priority - 1;
|
||||
uint8_t inheritedPriority = VOLUNTEER_SIMULATOR_PRIORITY;
|
||||
uint8_t inheritedPriority = VOLUNTEER_SIMULATION_PRIORITY;
|
||||
setOutgoingPriority(inheritedPriority);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,13 +270,15 @@ void PhysicsEngine::doOwnershipInfection(const btCollisionObject* objectA, const
|
|||
// NOTE: we might own the simulation of a kinematic object (A)
|
||||
// but we don't claim ownership of kinematic objects (B) based on collisions here.
|
||||
if (!objectB->isStaticOrKinematicObject() && b->getSimulatorID() != _sessionID) {
|
||||
b->bump(a->getSimulatorPriority());
|
||||
quint8 priority = a ? a->getSimulatorPriority() : PERSONAL_SIMULATION_PRIORITY;
|
||||
b->bump(priority);
|
||||
}
|
||||
} else if (a && ((b && b->getSimulatorID() == _sessionID && !objectB->isStaticObject()) || (objectB == characterObject))) {
|
||||
// SIMILARLY: we might own the simulation of a kinematic object (B)
|
||||
// but we don't claim ownership of kinematic objects (A) based on collisions here.
|
||||
if (!objectA->isStaticOrKinematicObject() && a->getSimulatorID() != _sessionID) {
|
||||
a->bump(b->getSimulatorPriority());
|
||||
quint8 priority = b ? b->getSimulatorPriority() : PERSONAL_SIMULATION_PRIORITY;
|
||||
a->bump(priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +403,7 @@ void PhysicsEngine::bump(ObjectMotionState* motionState) {
|
|||
if (!objectA->isStaticOrKinematicObject()) {
|
||||
ObjectMotionState* motionStateA = static_cast<ObjectMotionState*>(objectA->getUserPointer());
|
||||
if (motionStateA) {
|
||||
motionStateA->bump(VOLUNTEER_SIMULATOR_PRIORITY);
|
||||
motionStateA->bump(VOLUNTEER_SIMULATION_PRIORITY);
|
||||
objectA->setActivationState(ACTIVE_TAG);
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +411,7 @@ void PhysicsEngine::bump(ObjectMotionState* motionState) {
|
|||
if (!objectB->isStaticOrKinematicObject()) {
|
||||
ObjectMotionState* motionStateB = static_cast<ObjectMotionState*>(objectB->getUserPointer());
|
||||
if (motionStateB) {
|
||||
motionStateB->bump(VOLUNTEER_SIMULATOR_PRIORITY);
|
||||
motionStateB->bump(VOLUNTEER_SIMULATION_PRIORITY);
|
||||
objectB->setActivationState(ACTIVE_TAG);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue