mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
use a constant number of BYTES_PER_AVATAR as an interim solution
This commit is contained in:
parent
091875aedd
commit
e75add411c
4 changed files with 9 additions and 7 deletions
|
@ -74,6 +74,7 @@
|
|||
#include <PerfStat.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <AvatarData.h>
|
||||
|
||||
#include "ViewFrustum.h"
|
||||
|
||||
|
@ -1316,7 +1317,7 @@ void *networkReceive(void *args)
|
|||
AgentList::getInstance()->processBulkAgentData(&senderAddress,
|
||||
incomingPacket,
|
||||
bytesReceived,
|
||||
(sizeof(float) * 3) + (sizeof(uint16_t) * 3));
|
||||
BYTES_PER_AVATAR);
|
||||
break;
|
||||
default:
|
||||
AgentList::getInstance()->processAgentData(&senderAddress, incomingPacket, bytesReceived);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <cstring>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
|
||||
#include "AvatarData.h"
|
||||
|
@ -23,7 +24,7 @@ int packFloatAngleToTwoByte(unsigned char* buffer, float angle) {
|
|||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
int unpackFloatAngleFromTwoByte(uint16_t *byteAnglePointer, float *destinationPointer) {
|
||||
int unpackFloatAngleFromTwoByte(uint16_t* byteAnglePointer, float* destinationPointer) {
|
||||
*destinationPointer = (*byteAnglePointer / std::numeric_limits<uint16_t>::max()) * 360.0 - 180;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
@ -61,7 +62,6 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
|
||||
// called on the other agents - assigns it to my views of the others
|
||||
void AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
||||
|
||||
// increment to push past the packet header
|
||||
sourceBuffer++;
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include <AgentData.h>
|
||||
|
||||
const int BYTES_PER_AVATAR = 30;
|
||||
|
||||
class AvatarData : public AgentData {
|
||||
public:
|
||||
AvatarData();
|
||||
|
|
|
@ -109,7 +109,7 @@ void AgentList::processBulkAgentData(sockaddr *senderAddress, unsigned char *pac
|
|||
|
||||
unsigned char *startPosition = (unsigned char *)packetData;
|
||||
unsigned char *currentPosition = startPosition + 1;
|
||||
unsigned char *packetHolder = new unsigned char[numBytesPerAgent + 1];
|
||||
unsigned char packetHolder[numBytesPerAgent + 1];
|
||||
|
||||
packetHolder[0] = PACKET_HEADER_HEAD_DATA;
|
||||
|
||||
|
@ -122,13 +122,12 @@ void AgentList::processBulkAgentData(sockaddr *senderAddress, unsigned char *pac
|
|||
int matchingAgentIndex = indexOfMatchingAgent(agentID);
|
||||
|
||||
if (matchingAgentIndex >= 0) {
|
||||
|
||||
updateAgentWithData(&agents[matchingAgentIndex], packetHolder, numBytesPerAgent + 1);
|
||||
}
|
||||
|
||||
currentPosition += numBytesPerAgent;
|
||||
}
|
||||
|
||||
delete[] packetHolder;
|
||||
}
|
||||
|
||||
void AgentList::updateAgentWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
||||
|
@ -148,7 +147,7 @@ void AgentList::updateAgentWithData(Agent *agent, unsigned char *packetData, int
|
|||
linkedDataCreateCallback(agent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
agent->getLinkedData()->parseData(packetData, dataBytes);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue