mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 19:23:58 +02:00
fix broken voxel server build, change some char* to unsigned char*
This commit is contained in:
parent
c921fd9b87
commit
8129c2477a
7 changed files with 20 additions and 20 deletions
|
@ -40,7 +40,7 @@ unsigned char *addAgentToBroadcastPacket(unsigned char *currentPosition, Agent *
|
|||
currentPosition += packAgentId(currentPosition, agentToAdd->getAgentId());
|
||||
|
||||
AvatarData *agentData = (AvatarData *)agentToAdd->getLinkedData();
|
||||
currentPosition += agentData->getBroadcastData((char *) currentPosition);
|
||||
currentPosition += agentData->getBroadcastData(currentPosition);
|
||||
|
||||
return currentPosition;
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ void updateAvatar(float frametime)
|
|||
#endif
|
||||
|
||||
// Send my stream of head/hand data to the avatar mixer and voxel server
|
||||
char broadcastString[200];
|
||||
unsigned char broadcastString[200];
|
||||
int broadcastBytes = myAvatar.getBroadcastData(broadcastString);
|
||||
const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER};
|
||||
|
||||
|
@ -478,7 +478,7 @@ void updateAvatar(float frametime)
|
|||
::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) {
|
||||
|
||||
if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){
|
||||
AgentList::getInstance()->broadcastToAgents((char*)bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
AgentList::getInstance()->broadcastToAgents(bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
delete bufferOut;
|
||||
}
|
||||
}
|
||||
|
@ -1096,14 +1096,14 @@ void sendVoxelServerEraseAll() {
|
|||
char message[100];
|
||||
sprintf(message,"%c%s",'Z',"erase all");
|
||||
int messageSize = strlen(message) + 1;
|
||||
AgentList::getInstance()->broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
AgentList::getInstance()->broadcastToAgents((unsigned char*) message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
}
|
||||
|
||||
void sendVoxelServerAddScene() {
|
||||
char message[100];
|
||||
sprintf(message,"%c%s",'Z',"add scene");
|
||||
int messageSize = strlen(message) + 1;
|
||||
AgentList::getInstance()->broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
AgentList::getInstance()->broadcastToAgents((unsigned char*)message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
}
|
||||
|
||||
void shiftPaintingColor()
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include "AvatarData.h"
|
||||
|
||||
int packFloatAngleToTwoByte(char* buffer, float angle) {
|
||||
int packFloatAngleToTwoByte(unsigned char* buffer, float angle) {
|
||||
const float ANGLE_CONVERSION_RATIO = (std::numeric_limits<uint16_t>::max() / 360.0);
|
||||
|
||||
uint16_t angleHolder = floorf((angle + 180) * ANGLE_CONVERSION_RATIO);
|
||||
|
@ -45,20 +45,20 @@ AvatarData* AvatarData::clone() const {
|
|||
|
||||
// transmit data to agents requesting it
|
||||
// called on me just prior to sending data to others (continuasly called)
|
||||
int AvatarData::getBroadcastData(char* destinationBuffer) {
|
||||
char* bufferPointer = destinationBuffer;
|
||||
|
||||
int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
||||
unsigned char* bufferStart = destinationBuffer;
|
||||
|
||||
// TODO: DRY this up to a shared method
|
||||
// that can pack any type given the number of bytes
|
||||
// and return the number of bytes to push the pointer
|
||||
memcpy(bufferPointer, &_bodyPosition, sizeof(float) * 3);
|
||||
bufferPointer += sizeof(float) * 3;
|
||||
memcpy(destinationBuffer, &_bodyPosition, sizeof(float) * 3);
|
||||
destinationBuffer += sizeof(float) * 3;
|
||||
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyYaw);
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyPitch);
|
||||
bufferPointer += packFloatAngleToTwoByte(bufferPointer, _bodyRoll);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
|
||||
|
||||
return bufferPointer - destinationBuffer;
|
||||
return destinationBuffer - bufferStart;
|
||||
}
|
||||
|
||||
// called on the other agents - assigns it to my views of the others
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
glm::vec3 getBodyPosition();
|
||||
void setBodyPosition(glm::vec3 bodyPosition);
|
||||
|
||||
int getBroadcastData(char* destinationBuffer);
|
||||
int getBroadcastData(unsigned char* destinationBuffer);
|
||||
void parseData(unsigned char* sourceBuffer, int numBytes);
|
||||
|
||||
float getBodyYaw();
|
||||
|
|
|
@ -258,7 +258,7 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
|||
}
|
||||
}
|
||||
|
||||
void AgentList::broadcastToAgents(char *broadcastData, size_t dataBytes, const char* agentTypes, int numAgentTypes) {
|
||||
void AgentList::broadcastToAgents(unsigned char *broadcastData, size_t dataBytes, const char* agentTypes, int numAgentTypes) {
|
||||
for(std::vector<Agent>::iterator agent = agents.begin(); agent != agents.end(); agent++) {
|
||||
// only send to the AgentTypes we are asked to send to.
|
||||
if (agent->getActiveSocket() != NULL && memchr(agentTypes, agent->getType(), numAgentTypes)) {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
void updateAgentWithData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes);
|
||||
void updateAgentWithData(Agent *agent, unsigned char *packetData, int dataBytes);
|
||||
|
||||
void broadcastToAgents(char *broadcastData, size_t dataBytes, const char* agentTypes, int numAgentTypes);
|
||||
void broadcastToAgents(unsigned char *broadcastData, size_t dataBytes, const char* agentTypes, int numAgentTypes);
|
||||
char getOwnerType();
|
||||
unsigned int getSocketListenPort();
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ int main(int argc, const char * argv[])
|
|||
|
||||
sockaddr agentPublicAddress;
|
||||
|
||||
char *packetData = new char[MAX_PACKET_SIZE];
|
||||
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
|
||||
ssize_t receivedBytes;
|
||||
|
||||
// loop to send to agents requesting data
|
||||
|
@ -352,7 +352,7 @@ int main(int argc, const char * argv[])
|
|||
|
||||
// the Z command is a special command that allows the sender to send the voxel server high level semantic
|
||||
// requests, like erase all, or add sphere scene
|
||||
char* command = &packetData[1]; // start of the command
|
||||
char* command = (char*) &packetData[1]; // start of the command
|
||||
int commandLength = strlen(command); // commands are null terminated strings
|
||||
int totalLength = 1+commandLength+1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue