mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 02:04:28 +02:00
Merge pull request #1776 from birarda/bent-avatars
repair ping packet parsing in creation of reply, fix AvatarMixer crash with UNIX client
This commit is contained in:
commit
0badc02a93
6 changed files with 16 additions and 14 deletions
|
@ -1413,10 +1413,10 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
|
||||
void Application::sendPingPackets() {
|
||||
QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
|
||||
getInstance()->controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
||||
<< NodeType::ParticleServer
|
||||
<< NodeType::AudioMixer << NodeType::AvatarMixer
|
||||
<< NodeType::MetavoxelServer);
|
||||
controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
||||
<< NodeType::ParticleServer
|
||||
<< NodeType::AudioMixer << NodeType::AvatarMixer
|
||||
<< NodeType::MetavoxelServer);
|
||||
}
|
||||
|
||||
// Every second, check the frame rates and other stuff
|
||||
|
|
|
@ -264,7 +264,7 @@ private:
|
|||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
||||
|
||||
static bool sendVoxelsOperation(OctreeElement* node, void* extraData);
|
||||
static void sendPingPackets();
|
||||
void sendPingPackets();
|
||||
|
||||
void initDisplay();
|
||||
void init();
|
||||
|
|
|
@ -45,8 +45,7 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
|||
NodeList* nodeList = NodeList::getInstance();
|
||||
|
||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||
if (nodeList->getNodeActiveSocketOrPing(node.data()) &&
|
||||
node->getType() == getNodeType()) {
|
||||
if (nodeList->getNodeActiveSocketOrPing(node.data()) && node->getType() == getNodeType()) {
|
||||
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
||||
_packetSender.queuePacketForSending(*nodeAddress, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
||||
nodeCount++;
|
||||
|
|
|
@ -41,6 +41,7 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
|
|||
|
||||
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
|
||||
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
||||
_isAvatar(false),
|
||||
_dataServerScriptingInterface(),
|
||||
_avatarData(NULL)
|
||||
{
|
||||
|
|
|
@ -119,13 +119,13 @@ void NodeList::timePingReply(const QByteArray& packet) {
|
|||
|
||||
if (matchingNode) {
|
||||
QDataStream packetStream(packet);
|
||||
packetStream.device()->seek(numBytesForPacketHeader(packet));
|
||||
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||
|
||||
qint64 ourOriginalTime, othersReplyTime;
|
||||
quint64 ourOriginalTime, othersReplyTime;
|
||||
|
||||
packetStream >> ourOriginalTime >> othersReplyTime;
|
||||
|
||||
qint64 now = usecTimestampNow();
|
||||
quint64 now = usecTimestampNow();
|
||||
int pingTime = now - ourOriginalTime;
|
||||
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
||||
|
||||
|
@ -554,8 +554,11 @@ QByteArray NodeList::constructPingPacket() {
|
|||
}
|
||||
|
||||
QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||
QDataStream pingPacketStream(pingPacket);
|
||||
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||
|
||||
quint64 timeFromOriginalPing;
|
||||
memcpy(&timeFromOriginalPing, pingPacket.data() + numBytesForPacketHeader(pingPacket), sizeof(timeFromOriginalPing));
|
||||
pingPacketStream >> timeFromOriginalPing;
|
||||
|
||||
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
||||
|
@ -621,8 +624,7 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned NodeList::broadcastToNodes(const QByteArray& packet,
|
||||
const NodeSet& destinationNodeTypes) {
|
||||
unsigned NodeList::broadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
||||
unsigned n = 0;
|
||||
|
||||
foreach (const SharedNodePointer& node, getNodeHash()) {
|
||||
|
|
|
@ -80,7 +80,7 @@ bool packetVersionMatch(const QByteArray& packet) {
|
|||
// currently this just checks if the version in the packet matches our return from versionForPacketType
|
||||
// may need to be expanded in the future for types and versions that take > than 1 byte
|
||||
|
||||
if (packet[1] == versionForPacketType(packetTypeForPacket(packet)) || packet[0] == PacketTypeStunResponse) {
|
||||
if (packet[1] == versionForPacketType(packetTypeForPacket(packet)) || packetTypeForPacket(packet) == PacketTypeStunResponse) {
|
||||
return true;
|
||||
} else {
|
||||
PacketType mismatchType = packetTypeForPacket(packet);
|
||||
|
|
Loading…
Reference in a new issue