mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
type squish and magic number removal
This commit is contained in:
parent
6804ab8a33
commit
544f9c2e7a
1 changed files with 5 additions and 3 deletions
|
@ -90,7 +90,7 @@ void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::processNodeData(sockaddr* senderAddress, unsigned char* packetData, size_t dataBytes) {
|
void NodeList::processNodeData(sockaddr* senderAddress, unsigned char* packetData, size_t dataBytes) {
|
||||||
switch (((char *)packetData)[0]) {
|
switch (packetData[0]) {
|
||||||
case PACKET_TYPE_DOMAIN: {
|
case PACKET_TYPE_DOMAIN: {
|
||||||
processDomainServerList(packetData, dataBytes);
|
processDomainServerList(packetData, dataBytes);
|
||||||
break;
|
break;
|
||||||
|
@ -239,12 +239,14 @@ void NodeList::sendDomainServerCheckIn() {
|
||||||
static unsigned char* checkInPacket = NULL;
|
static unsigned char* checkInPacket = NULL;
|
||||||
static int checkInPacketSize;
|
static int checkInPacketSize;
|
||||||
|
|
||||||
|
const int IP_ADDRESS_BYTES = 4;
|
||||||
|
|
||||||
if (!checkInPacket) {
|
if (!checkInPacket) {
|
||||||
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
int numBytesNodesOfInterest = _nodeTypesOfInterest ? strlen((char*) _nodeTypesOfInterest) : 0;
|
||||||
|
|
||||||
// check in packet has header, node type, port, IP, node types of interest, null termination
|
// check in packet has header, node type, port, IP, node types of interest, null termination
|
||||||
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) +
|
||||||
(sizeof(char) * 4) + 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;
|
||||||
|
|
Loading…
Reference in a new issue