mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:10:52 +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() {
|
void Application::sendPingPackets() {
|
||||||
QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
|
QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
|
||||||
getInstance()->controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
||||||
<< NodeType::ParticleServer
|
<< NodeType::ParticleServer
|
||||||
<< NodeType::AudioMixer << NodeType::AvatarMixer
|
<< NodeType::AudioMixer << NodeType::AvatarMixer
|
||||||
<< NodeType::MetavoxelServer);
|
<< NodeType::MetavoxelServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
|
|
|
@ -264,7 +264,7 @@ private:
|
||||||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
||||||
|
|
||||||
static bool sendVoxelsOperation(OctreeElement* node, void* extraData);
|
static bool sendVoxelsOperation(OctreeElement* node, void* extraData);
|
||||||
static void sendPingPackets();
|
void sendPingPackets();
|
||||||
|
|
||||||
void initDisplay();
|
void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
|
|
@ -45,8 +45,7 @@ bool JurisdictionListener::queueJurisdictionRequest() {
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
foreach (const SharedNodePointer& node, nodeList->getNodeHash()) {
|
||||||
if (nodeList->getNodeActiveSocketOrPing(node.data()) &&
|
if (nodeList->getNodeActiveSocketOrPing(node.data()) && node->getType() == getNodeType()) {
|
||||||
node->getType() == getNodeType()) {
|
|
||||||
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
const HifiSockAddr* nodeAddress = node->getActiveSocket();
|
||||||
_packetSender.queuePacketForSending(*nodeAddress, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
_packetSender.queuePacketForSending(*nodeAddress, QByteArray(reinterpret_cast<char*>(bufferOut), sizeOut));
|
||||||
nodeCount++;
|
nodeCount++;
|
||||||
|
|
|
@ -41,6 +41,7 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
|
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
|
||||||
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
AbstractControllerScriptingInterface* controllerScriptingInterface) :
|
||||||
|
_isAvatar(false),
|
||||||
_dataServerScriptingInterface(),
|
_dataServerScriptingInterface(),
|
||||||
_avatarData(NULL)
|
_avatarData(NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,13 +119,13 @@ void NodeList::timePingReply(const QByteArray& packet) {
|
||||||
|
|
||||||
if (matchingNode) {
|
if (matchingNode) {
|
||||||
QDataStream packetStream(packet);
|
QDataStream packetStream(packet);
|
||||||
packetStream.device()->seek(numBytesForPacketHeader(packet));
|
packetStream.skipRawData(numBytesForPacketHeader(packet));
|
||||||
|
|
||||||
qint64 ourOriginalTime, othersReplyTime;
|
quint64 ourOriginalTime, othersReplyTime;
|
||||||
|
|
||||||
packetStream >> ourOriginalTime >> othersReplyTime;
|
packetStream >> ourOriginalTime >> othersReplyTime;
|
||||||
|
|
||||||
qint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
int pingTime = now - ourOriginalTime;
|
int pingTime = now - ourOriginalTime;
|
||||||
int oneWayFlightTime = pingTime / 2; // half of the ping is our one way flight
|
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) {
|
QByteArray NodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||||
|
QDataStream pingPacketStream(pingPacket);
|
||||||
|
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||||
|
|
||||||
quint64 timeFromOriginalPing;
|
quint64 timeFromOriginalPing;
|
||||||
memcpy(&timeFromOriginalPing, pingPacket.data() + numBytesForPacketHeader(pingPacket), sizeof(timeFromOriginalPing));
|
pingPacketStream >> timeFromOriginalPing;
|
||||||
|
|
||||||
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
QByteArray replyPacket = byteArrayWithPopluatedHeader(PacketTypePingReply);
|
||||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
||||||
|
@ -621,8 +624,7 @@ SharedNodePointer NodeList::addOrUpdateNode(const QUuid& uuid, char nodeType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned NodeList::broadcastToNodes(const QByteArray& packet,
|
unsigned NodeList::broadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
||||||
const NodeSet& destinationNodeTypes) {
|
|
||||||
unsigned n = 0;
|
unsigned n = 0;
|
||||||
|
|
||||||
foreach (const SharedNodePointer& node, getNodeHash()) {
|
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
|
// 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
|
// 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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
PacketType mismatchType = packetTypeForPacket(packet);
|
PacketType mismatchType = packetTypeForPacket(packet);
|
||||||
|
|
Loading…
Reference in a new issue