mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:35:45 +02:00
Merge branch 'master' of git://github.com/worklist/hifi into the_midget_are_coming
This commit is contained in:
commit
aaa9038e4c
3 changed files with 16 additions and 19 deletions
|
@ -63,10 +63,7 @@ NodeList::NodeList(char newOwnerType, unsigned int newSocketListenPort) :
|
||||||
_ownerType(newOwnerType),
|
_ownerType(newOwnerType),
|
||||||
_nodeTypesOfInterest(NULL),
|
_nodeTypesOfInterest(NULL),
|
||||||
_ownerID(UNKNOWN_NODE_ID),
|
_ownerID(UNKNOWN_NODE_ID),
|
||||||
_lastNodeID(0),
|
_lastNodeID(0) {
|
||||||
_printedDomainServerIP(false),
|
|
||||||
_checkInPacket(NULL),
|
|
||||||
_checkInPacketSize(0) {
|
|
||||||
pthread_mutex_init(&mutex, 0);
|
pthread_mutex_init(&mutex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +218,8 @@ void NodeList::setNodeTypesOfInterest(const char* nodeTypesOfInterest, int numNo
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::sendDomainServerCheckIn() {
|
void NodeList::sendDomainServerCheckIn() {
|
||||||
|
static bool printedDomainServerIP = false;
|
||||||
|
|
||||||
// Lookup the IP address of the domain server if we need to
|
// Lookup the IP address of the domain server if we need to
|
||||||
if (atoi(DOMAIN_IP) == 0) {
|
if (atoi(DOMAIN_IP) == 0) {
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
|
@ -232,13 +231,16 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
} else {
|
} else {
|
||||||
printLog("Failed domain server lookup\n");
|
printLog("Failed domain server lookup\n");
|
||||||
}
|
}
|
||||||
} else if (!_printedDomainServerIP) {
|
} else if (!printedDomainServerIP) {
|
||||||
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
printLog("Domain Server IP: %s\n", DOMAIN_IP);
|
||||||
_printedDomainServerIP = true;
|
printedDomainServerIP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned char* checkInPacket = NULL;
|
||||||
|
static int checkInPacketSize = 0;
|
||||||
|
|
||||||
// construct the DS check in packet if we need to
|
// construct the DS check in packet if we need to
|
||||||
if (!_checkInPacket) {
|
if (!checkInPacket) {
|
||||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||||
|
|
||||||
const int IP_ADDRESS_BYTES = 4;
|
const int IP_ADDRESS_BYTES = 4;
|
||||||
|
@ -247,8 +249,8 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) + sizeof(uint16_t) +
|
int numPacketBytes = sizeof(PACKET_TYPE) + sizeof(PACKET_VERSION) + sizeof(NODE_TYPE) + sizeof(uint16_t) +
|
||||||
IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
IP_ADDRESS_BYTES + numBytesNodesOfInterest + sizeof(unsigned char);
|
||||||
|
|
||||||
_checkInPacket = new unsigned char[numPacketBytes];
|
checkInPacket = new unsigned char[numPacketBytes];
|
||||||
unsigned char* packetPosition = _checkInPacket;
|
unsigned char* packetPosition = checkInPacket;
|
||||||
|
|
||||||
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
PACKET_TYPE nodePacketType = (memchr(SOLO_NODE_TYPES, _ownerType, sizeof(SOLO_NODE_TYPES)))
|
||||||
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
? PACKET_TYPE_DOMAIN_REPORT_FOR_DUTY
|
||||||
|
@ -259,7 +261,7 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
|
|
||||||
*(packetPosition++) = _ownerType;
|
*(packetPosition++) = _ownerType;
|
||||||
|
|
||||||
packetPosition += packSocket(_checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
packetPosition += packSocket(checkInPacket + numHeaderBytes + sizeof(NODE_TYPE),
|
||||||
getLocalAddress(),
|
getLocalAddress(),
|
||||||
htons(_nodeSocket.getListeningPort()));
|
htons(_nodeSocket.getListeningPort()));
|
||||||
|
|
||||||
|
@ -274,10 +276,10 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
packetPosition += numBytesNodesOfInterest;
|
packetPosition += numBytesNodesOfInterest;
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkInPacketSize = packetPosition - _checkInPacket;
|
checkInPacketSize = packetPosition - checkInPacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nodeSocket.send(DOMAIN_IP, DOMAINSERVER_PORT, _checkInPacket, _checkInPacketSize);
|
_nodeSocket.send(DOMAIN_IP, DOMAINSERVER_PORT, checkInPacket, checkInPacketSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
int NodeList::processDomainServerList(unsigned char* packetData, size_t dataBytes) {
|
||||||
|
|
|
@ -113,10 +113,6 @@ private:
|
||||||
pthread_t checkInWithDomainServerThread;
|
pthread_t checkInWithDomainServerThread;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
bool _printedDomainServerIP;
|
|
||||||
unsigned char* _checkInPacket;
|
|
||||||
int _checkInPacketSize;
|
|
||||||
|
|
||||||
void handlePingReply(sockaddr *nodeAddress);
|
void handlePingReply(sockaddr *nodeAddress);
|
||||||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||||
};
|
};
|
||||||
|
|
|
@ -261,11 +261,10 @@ void deepestLevelVoxelDistributor(NodeList* nodeList,
|
||||||
}
|
}
|
||||||
// send the environment packet
|
// send the environment packet
|
||||||
if (shouldSendEnvironments) {
|
if (shouldSendEnvironments) {
|
||||||
int envPacketLength = 1;
|
|
||||||
|
|
||||||
int numBytesPacketHeader = populateTypeAndVersion(tempOutputBuffer, PACKET_TYPE_ENVIRONMENT_DATA);
|
int numBytesPacketHeader = populateTypeAndVersion(tempOutputBuffer, PACKET_TYPE_ENVIRONMENT_DATA);
|
||||||
|
int envPacketLength = numBytesPacketHeader;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(environmentData) / numBytesPacketHeader; i++) {
|
for (int i = 0; i < sizeof(environmentData) / sizeof(EnvironmentData); i++) {
|
||||||
envPacketLength += environmentData[i].getBroadcastData(tempOutputBuffer + envPacketLength);
|
envPacketLength += environmentData[i].getBroadcastData(tempOutputBuffer + envPacketLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue