mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
switch from strchr to memchr for broadcastToAgents
This commit is contained in:
parent
c378241afb
commit
010c7e028d
3 changed files with 8 additions and 12 deletions
|
@ -471,13 +471,9 @@ void simulateHead(float frametime)
|
|||
// Send my stream of head/hand data to the avatar mixer and voxel server
|
||||
char broadcastString[200];
|
||||
int broadcastBytes = myAvatar.getBroadcastData(broadcastString);
|
||||
const char broadcastReceivers[2] = {AGENT_TYPE_VOXEL, AGENT_TYPE_AVATAR_MIXER};
|
||||
|
||||
char broadcastReceivers[3];
|
||||
*broadcastReceivers = AGENT_TYPE_VOXEL;
|
||||
*(broadcastReceivers + 1) = AGENT_TYPE_AVATAR_MIXER;
|
||||
*(broadcastReceivers + 2) = '\0';
|
||||
|
||||
agentList.broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers);
|
||||
agentList.broadcastToAgents(broadcastString, broadcastBytes, broadcastReceivers, 2);
|
||||
|
||||
// If I'm in paint mode, send a voxel out to VOXEL server agents.
|
||||
if (::paintOn) {
|
||||
|
@ -497,7 +493,7 @@ void simulateHead(float frametime)
|
|||
::paintingVoxel.z >= 0.0 && ::paintingVoxel.z <= 1.0) {
|
||||
|
||||
if (createVoxelEditMessage(PACKET_HEADER_SET_VOXEL, 0, 1, &::paintingVoxel, bufferOut, sizeOut)){
|
||||
agentList.broadcastToAgents((char*)bufferOut, sizeOut, &AGENT_TYPE_VOXEL);
|
||||
agentList.broadcastToAgents((char*)bufferOut, sizeOut, &AGENT_TYPE_VOXEL, 1);
|
||||
delete bufferOut;
|
||||
}
|
||||
}
|
||||
|
@ -864,14 +860,14 @@ void sendVoxelServerEraseAll() {
|
|||
char message[100];
|
||||
sprintf(message,"%c%s",'Z',"erase all");
|
||||
int messageSize = strlen(message) + 1;
|
||||
::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL);
|
||||
::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
}
|
||||
|
||||
void sendVoxelServerAddScene() {
|
||||
char message[100];
|
||||
sprintf(message,"%c%s",'Z',"add scene");
|
||||
int messageSize = strlen(message) + 1;
|
||||
::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL);
|
||||
::agentList.broadcastToAgents(message, messageSize, &AGENT_TYPE_VOXEL, 1);
|
||||
}
|
||||
|
||||
void shiftPaintingColor()
|
||||
|
|
|
@ -246,10 +246,10 @@ bool AgentList::addOrUpdateAgent(sockaddr *publicSocket, sockaddr *localSocket,
|
|||
}
|
||||
}
|
||||
|
||||
void AgentList::broadcastToAgents(char *broadcastData, size_t dataBytes, const char* agentTypes) {
|
||||
void AgentList::broadcastToAgents(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 && strchr(agentTypes,agent->getType())) {
|
||||
if (agent->getActiveSocket() != NULL && memchr(agentTypes, agent->getType(), numAgentTypes)) {
|
||||
// we know which socket is good for this agent, send there
|
||||
agentSocket.send(agent->getActiveSocket(), broadcastData, dataBytes);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
void updateAgentWithData(sockaddr *senderAddress, void *packetData, size_t dataBytes);
|
||||
void updateAgentWithData(Agent *agent, void *packetData, int dataBytes);
|
||||
|
||||
void broadcastToAgents(char *broadcastData, size_t dataBytes, const char* agentTypes);
|
||||
void broadcastToAgents(char *broadcastData, size_t dataBytes, const char* agentTypes, int numAgentTypes);
|
||||
char getOwnerType();
|
||||
unsigned int getSocketListenPort();
|
||||
|
||||
|
|
Loading…
Reference in a new issue