mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 20:23:06 +02:00
handle node killed and remove double IDs in kill packets
This commit is contained in:
parent
5e34795603
commit
44a63ca27e
2 changed files with 42 additions and 8 deletions
|
@ -119,8 +119,18 @@ void AvatarMixer::optionallyReplicatePacket(ReceivedMessage& message, const Node
|
||||||
}, [&](const SharedNodePointer& node) {
|
}, [&](const SharedNodePointer& node) {
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
// construct an NLPacket to send to the replicant that has the contents of the received packet
|
// construct an NLPacket to send to the replicant that has the contents of the received packet
|
||||||
packet = NLPacket::create(replicatedType, message.getSize() + NUM_BYTES_RFC4122_UUID);
|
auto packetSize = message.getSize();
|
||||||
packet->write(message.getSourceID().toRfc4122());
|
|
||||||
|
if (replicatedType != PacketType::ReplicatedKillAvatar) {
|
||||||
|
packetSize += NUM_BYTES_RFC4122_UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
packet = NLPacket::create(replicatedType, packetSize);
|
||||||
|
|
||||||
|
if (replicatedType != PacketType::ReplicatedKillAvatar) {
|
||||||
|
packet->write(message.getSourceID().toRfc4122());
|
||||||
|
}
|
||||||
|
|
||||||
packet->write(message.getMessage());
|
packet->write(message.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,13 +362,38 @@ void AvatarMixer::nodeKilled(SharedNodePointer killedNode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<NLPacket> killPacket;
|
||||||
|
std::unique_ptr<NLPacket> replicatedKillPacket;
|
||||||
|
|
||||||
// this was an avatar we were sending to other people
|
// this was an avatar we were sending to other people
|
||||||
// send a kill packet for it to our other nodes
|
// send a kill packet for it to our other nodes
|
||||||
auto killPacket = NLPacket::create(PacketType::KillAvatar, NUM_BYTES_RFC4122_UUID + sizeof(KillAvatarReason));
|
nodeList->eachMatchingNode([&](const SharedNodePointer& node) {
|
||||||
killPacket->write(killedNode->getUUID().toRfc4122());
|
// we relay avatar kill packets to agents that are not upstream
|
||||||
killPacket->writePrimitive(KillAvatarReason::AvatarDisconnected);
|
// and downstream avatar mixers, if the node that was just killed was being replicated
|
||||||
|
return (node->getType() == NodeType::Agent && !node->isUpstream())
|
||||||
|
|| (killedNode->isReplicated() && node->getType() == NodeType::DownstreamAvatarMixer);
|
||||||
|
}, [&](const SharedNodePointer& node) {
|
||||||
|
if (node->getType() == NodeType::Agent) {
|
||||||
|
if (!killPacket) {
|
||||||
|
killPacket = NLPacket::create(PacketType::KillAvatar, NUM_BYTES_RFC4122_UUID + sizeof(KillAvatarReason));
|
||||||
|
killPacket->write(killedNode->getUUID().toRfc4122());
|
||||||
|
killPacket->writePrimitive(KillAvatarReason::AvatarDisconnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeList->sendUnreliablePacket(*killPacket, *node);
|
||||||
|
} else {
|
||||||
|
// send a replicated kill packet to the downstream avatar mixer
|
||||||
|
if (!replicatedKillPacket) {
|
||||||
|
replicatedKillPacket = NLPacket::create(PacketType::ReplicatedKillAvatar,
|
||||||
|
NUM_BYTES_RFC4122_UUID + sizeof(KillAvatarReason));
|
||||||
|
replicatedKillPacket->write(killedNode->getUUID().toRfc4122());
|
||||||
|
replicatedKillPacket->writePrimitive(KillAvatarReason::AvatarDisconnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeList->sendUnreliablePacket(*replicatedKillPacket, node->getPublicSocket());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
nodeList->broadcastToNodes(std::move(killPacket), NodeSet() << NodeType::Agent);
|
|
||||||
|
|
||||||
// we also want to remove sequence number data for this avatar on our other avatars
|
// we also want to remove sequence number data for this avatar on our other avatars
|
||||||
// so invoke the appropriate method on the AvatarMixerClientData for other avatars
|
// so invoke the appropriate method on the AvatarMixerClientData for other avatars
|
||||||
|
@ -756,7 +791,6 @@ void AvatarMixer::run() {
|
||||||
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AvatarMixer::domainSettingsRequestFailed);
|
connect(&domainHandler, &DomainHandler::settingsReceiveFail, this, &AvatarMixer::domainSettingsRequestFailed);
|
||||||
|
|
||||||
ThreadedAssignment::commonInit(AVATAR_MIXER_LOGGING_NAME, NodeType::AvatarMixer);
|
ThreadedAssignment::commonInit(AVATAR_MIXER_LOGGING_NAME, NodeType::AvatarMixer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarMixerClientData* AvatarMixer::getOrCreateClientData(SharedNodePointer node) {
|
AvatarMixerClientData* AvatarMixer::getOrCreateClientData(SharedNodePointer node) {
|
||||||
|
|
|
@ -550,7 +550,7 @@ bool LimitedNodeList::killNodeWithUUID(const QUuid& nodeUUID) {
|
||||||
|
|
||||||
void LimitedNodeList::processKillNode(ReceivedMessage& message) {
|
void LimitedNodeList::processKillNode(ReceivedMessage& message) {
|
||||||
if (message.getType() == PacketType::ReplicatedAvatarData) {
|
if (message.getType() == PacketType::ReplicatedAvatarData) {
|
||||||
message.seek(NUM_BYTES_RFC4122_UUID);
|
message.seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the node id
|
// read the node id
|
||||||
|
|
Loading…
Reference in a new issue