From 3f9e00d977bf0b18563a160de3396222f5ddd8cd Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 5 Dec 2013 15:10:01 -0800 Subject: [PATCH] fix a boneheaded mistake in AvatarMixer broadcastAvatarData --- assignment-client/src/avatars/AvatarMixer.cpp | 10 ++++++---- interface/src/Application.cpp | 2 +- libraries/shared/src/NodeList.cpp | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index c1486a170d..0f72ae9680 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -58,9 +58,8 @@ void attachAvatarDataToNode(Node* newNode) { // determine which avatars are included in the packet stream // 4) we should optimize the avatar data format to be more compact (100 bytes is pretty wasteful). void broadcastAvatarData() { - static unsigned char broadcastPacketBuffer[MAX_PACKET_SIZE]; + static unsigned char broadcastPacket[MAX_PACKET_SIZE]; static unsigned char avatarDataBuffer[MAX_PACKET_SIZE]; - unsigned char* broadcastPacket = (unsigned char*)&broadcastPacketBuffer[0]; int numHeaderBytes = populateTypeAndVersion(broadcastPacket, PACKET_TYPE_BULK_AVATAR_DATA); unsigned char* currentBufferPosition = broadcastPacket + numHeaderBytes; int packetLength = currentBufferPosition - broadcastPacket; @@ -79,7 +78,9 @@ void broadcastAvatarData() { // send back a packet with other active node data to this node for (NodeList::iterator otherNode = nodeList->begin(); otherNode != nodeList->end(); otherNode++) { if (otherNode->getLinkedData() && otherNode->getUUID() != node->getUUID()) { - unsigned char* avatarDataEndpoint = addNodeToBroadcastPacket((unsigned char*)&avatarDataBuffer[0], &*node); + + unsigned char* avatarDataEndpoint = addNodeToBroadcastPacket((unsigned char*)&avatarDataBuffer[0], + &*otherNode); int avatarDataLength = avatarDataEndpoint - (unsigned char*)&avatarDataBuffer; if (avatarDataLength + packetLength <= MAX_PACKET_SIZE) { @@ -89,7 +90,8 @@ void broadcastAvatarData() { } else { packetsSent++; //printf("packetsSent=%d packetLength=%d\n", packetsSent, packetLength); - nodeList->getNodeSocket().writeDatagram((char*) broadcastPacket, currentBufferPosition - broadcastPacket, + nodeList->getNodeSocket().writeDatagram((char*) broadcastPacket, + currentBufferPosition - broadcastPacket, node->getActiveSocket()->getAddress(), node->getActiveSocket()->getPort()); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ba2b302902..b48a622772 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1997,7 +1997,7 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm:: for(NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { node->lock(); - if (node->getLinkedData() != NULL) { + if (node->getLinkedData()) { Avatar *avatar = (Avatar *)node->getLinkedData(); if (!avatar->isInitialized()) { avatar->init(); diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 3df90d4377..7f0a26a364 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -175,6 +175,7 @@ void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned c Node* bulkSendNode = nodeWithAddress(senderAddress); if (bulkSendNode) { + bulkSendNode->setLastHeardMicrostamp(usecTimestampNow()); bulkSendNode->recordBytesReceived(numTotalBytes);